]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mailbox: pcc: Refactor error handling in irq handler into separate function
authorSudeep Holla <sudeep.holla@arm.com>
Thu, 13 Mar 2025 15:28:52 +0000 (15:28 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2025 21:24:56 +0000 (06:24 +0900)
[ Upstream commit 3a675f50415b95f2ae10bfd932e2154ba1a08ee7 ]

The existing error handling logic in pcc_mbox_irq() is intermixed with the
main flow of the function. The command complete check and the complete
complete update/acknowledgment are nicely factored into separate functions.

Moves error detection and clearing logic into a separate function called:
pcc_mbox_error_check_and_clear() by extracting error-handling logic from
pcc_mbox_irq().

This ensures error checking and clearing are handled separately and it
improves maintainability by keeping the IRQ handler focused on processing
events.

Acked-by: Huisong Li <lihuisong@huawei.com>
Tested-by: Huisong Li <lihuisong@huawei.com>
Tested-by: Adam Young <admiyo@os.amperecomputing.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
Stable-dep-of: ff0e4d4c97c9 ("mailbox: pcc: don't zero error register")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mailbox/pcc.c

index 49254d99a8ad68463e44a9fdad70f3706844d84b..bb977cf8ad42352d8b6df5b6bab10537873489af 100644 (file)
@@ -269,6 +269,25 @@ static bool pcc_mbox_cmd_complete_check(struct pcc_chan_info *pchan)
        return !!val;
 }
 
+static int pcc_mbox_error_check_and_clear(struct pcc_chan_info *pchan)
+{
+       u64 val;
+       int ret;
+
+       ret = pcc_chan_reg_read(&pchan->error, &val);
+       if (ret)
+               return ret;
+
+       val &= pchan->error.status_mask;
+       if (val) {
+               val &= ~pchan->error.status_mask;
+               pcc_chan_reg_write(&pchan->error, val);
+               return -EIO;
+       }
+
+       return 0;
+}
+
 static void check_and_ack(struct pcc_chan_info *pchan, struct mbox_chan *chan)
 {
        struct acpi_pcct_ext_pcc_shared_memory pcc_hdr;
@@ -309,8 +328,6 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
 {
        struct pcc_chan_info *pchan;
        struct mbox_chan *chan = p;
-       u64 val;
-       int ret;
 
        pchan = chan->con_priv;
 
@@ -324,15 +341,8 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
        if (!pcc_mbox_cmd_complete_check(pchan))
                return IRQ_NONE;
 
-       ret = pcc_chan_reg_read(&pchan->error, &val);
-       if (ret)
+       if (pcc_mbox_error_check_and_clear(pchan))
                return IRQ_NONE;
-       val &= pchan->error.status_mask;
-       if (val) {
-               val &= ~pchan->error.status_mask;
-               pcc_chan_reg_write(&pchan->error, val);
-               return IRQ_NONE;
-       }
 
        /*
         * Clear this flag after updating interrupt ack register and just