From: Sudeep Holla <sudeep.holla@kernel.org>
To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Cc: Sudeep Holla <sudeep.holla@kernel.org>,
Jassi Brar <jassisinghbrar@gmail.com>,
Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH] mailbox: pcc: Release probe resources on failure
Date: Wed, 28 Oct 2026 15:48:41 +0000 [thread overview]
Message-ID: <20261028154841.3315321-1-sudeep.holla@kernel.org> (raw)
PCC probe maps register addresses and registers platform GSIs as it
initializes subspaces. When a later step fails, the error path only
releases the PCCT reference, leaving those mappings and GSIs behind.
Record each registered GSI and unwind all resources acquired for every
started subspace, including the partially initialized one.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-d17640d2-d890-497b-9888-783c8b23208e
Fixes: 800cda7b63f2 ("mailbox: pcc: Add PCC register bundle and associated accessor functions")
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
---
drivers/mailbox/pcc.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index 14dc4a187bfc..18925cbf472d 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -90,6 +90,7 @@ struct pcc_chan_reg {
* @cmd_update: PCC register bundle for the command complete update register
* @error: PCC register bundle for the error status register
* @plat_irq: platform interrupt
+ * @plat_gsi: ACPI GSI registered for the platform interrupt
* @type: PCC subspace type
* @plat_irq_flags: platform interrupt flags
* @chan_in_use: lockless flag used by type 3 initiator subspaces to filter
@@ -106,6 +107,7 @@ struct pcc_chan_info {
struct pcc_chan_reg cmd_update;
struct pcc_chan_reg error;
int plat_irq;
+ u32 plat_gsi;
u8 type;
unsigned int plat_irq_flags;
bool chan_in_use;
@@ -606,6 +608,22 @@ pcc_chan_reg_init(struct pcc_chan_reg *reg, struct acpi_generic_address *gas,
return 0;
}
+static void pcc_release_subspace(struct pcc_chan_info *pchan)
+{
+ if (pchan->error.vaddr)
+ iounmap(pchan->error.vaddr);
+ if (pchan->cmd_update.vaddr)
+ iounmap(pchan->cmd_update.vaddr);
+ if (pchan->cmd_complete.vaddr)
+ iounmap(pchan->cmd_complete.vaddr);
+ if (pchan->db.vaddr)
+ iounmap(pchan->db.vaddr);
+ if (pchan->plat_irq_ack.vaddr)
+ iounmap(pchan->plat_irq_ack.vaddr);
+ if (pchan->plat_irq > 0)
+ acpi_unregister_gsi(pchan->plat_gsi);
+}
+
/**
* pcc_parse_subspace_irq - Parse the PCC IRQ and PCC ACK register
*
@@ -636,6 +654,7 @@ static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan,
pcct_ss->platform_interrupt);
return -EINVAL;
}
+ pchan->plat_gsi = pcct_ss->platform_interrupt;
pchan->plat_irq_flags = pcct_ss->flags;
if (pcct_ss->header.type == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) {
@@ -820,7 +839,7 @@ static int pcc_mbox_probe(struct platform_device *pdev)
struct acpi_subtable_header *pcct_entry;
struct acpi_table_pcct *acpi_pcct_tbl;
acpi_status status = AE_OK;
- int i, rc, count = pcc_chan_count;
+ int idx = 0, rc, count = pcc_chan_count;
/* Search for PCCT */
status = acpi_get_table(ACPI_SIG_PCCT, 0, &pcct_tbl);
@@ -860,11 +879,12 @@ static int pcc_mbox_probe(struct platform_device *pdev)
pcc_mbox_ctrl->txdone_poll = true;
}
- for (i = 0; i < count; i++) {
- struct pcc_chan_info *pchan = chan_info + i;
+ while (idx < count) {
+ struct pcc_chan_info *pchan = chan_info + idx;
+ struct mbox_chan *chan = &pcc_mbox_channels[idx++];
- pcc_mbox_channels[i].con_priv = pchan;
- pchan->chan.mchan = &pcc_mbox_channels[i];
+ chan->con_priv = pchan;
+ pchan->chan.mchan = chan;
if (pcct_entry->type == ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE &&
!pcc_mbox_ctrl->txdone_irq) {
@@ -904,6 +924,8 @@ static int pcc_mbox_probe(struct platform_device *pdev)
else
return 0;
err:
+ while (idx > 0)
+ pcc_release_subspace(&chan_info[--idx]);
acpi_put_table(pcct_tbl);
return rc;
}
--
2.43.0
reply other threads:[~2026-10-28 15:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261028154841.3315321-1-sudeep.holla@kernel.org \
--to=sudeep.holla@kernel.org \
--cc=jassisinghbrar@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®