From nobody Fri Jul 24 05:21:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38920440A26; Thu, 23 Jul 2026 14:39:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784817597; cv=none; b=mGTyBm4uA5SfBDZJATgy/bLaOrCygyxCrNFGXbRfxuKFilIpGx0o/Hp5YW5HRmXR6wWDNmLYQ+nDg9w2ygrGwJCpRO2WzvaI4b4Y0Oig9IJpY4QZvxrQpjvi9bzARQD9QxCDs44ZTiMxWX6vWS9HU0qMuduZLRTiqlW54EnqUjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784817597; c=relaxed/simple; bh=2QBNKKO2SRZwALMcFZRDC1w6ApklXtdDfYPwaHFr2nQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XwpekD/TqhPlxUX39pmIR4y86LTWYW3CmBpXd5rN8Hxx3mB0BhmgRod/bBirPODs5kqs3lm+vawAz3bmCVOLv2IULT98kHmSLT+VgxdpKVv3DdI9uRliIKXTDunwEw6b7R2Qsuo7Th25KLl5YGxwJf07fzfN+fp8WRe0LO1TDsg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ReE3IyJP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ReE3IyJP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0B621F00A3D; Thu, 23 Jul 2026 14:39:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784817583; bh=zXpqNVMM7ESu0cT0hoZNWBS1i4qtsT9J4fhzluMciYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ReE3IyJPZAvVCC7Io1SzulDdGCJ6k5SlK2S8/UaBB+7+cnHrGBLaGLOfSIOJjv1oF z8txWOSI2EhQ+8EqlE28kpgfi78bwB3g7NwMHJ31TWVDEyS8yNmo0vaHRulK/Y9Q+3 Hpx65JYyHv1b4VaasNCnGxIBa/L50m87de/0Mz/kzrBr4drC33uNVuH5F4syyquIHj fD+YKOIBs2eVkluhBgmLe3bpprUNFtYlGw2UVlKabdpKRCAH7+1hYetDggCtFFEIFm Y+fXeN3zRfgxc8AgogLCowIqT2NHmR0pMnUAZXQeY+dGjJeuhI8nbWv4SXq/0P7Bcf WekrOwnuT4Xfw== From: Sudeep Holla To: Jassi Brar , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Huisong Li , Cristian Marussi Subject: [PATCH v2 1/3] mailbox: pcc: Notify clients on polled completion Date: Thu, 23 Jul 2026 15:39:26 +0100 Message-ID: <20260723143928.2625970-2-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260723143928.2625970-1-sudeep.holla@kernel.org> References: <20260723143928.2625970-1-sudeep.holla@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" PCC channels without a platform interrupt rely on the mailbox polling path to detect command completion. That path currently only reports transmit completion to the mailbox core, so clients that wait for their receive callback do not get notified when the command completes. Call mbox_chan_received_data() when polling observes completion on a channel without a platform IRQ, matching the interrupt-driven completion path. Reported-by: Cristian Marussi Acked-by: Huisong Li Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 636879ae1db7..d96b8b54e77e 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -449,7 +449,15 @@ static bool pcc_last_tx_done(struct mbox_chan *chan) { struct pcc_chan_info *pchan =3D chan->con_priv; =20 - return pcc_mbox_cmd_complete_check(pchan); + if (!(chan->txdone_method & MBOX_TXDONE_BY_POLL)) + return false; + + if (!pcc_mbox_cmd_complete_check(pchan)) + return false; + + mbox_chan_received_data(chan, NULL); + + return true; } =20 /** --=20 2.43.0 From nobody Fri Jul 24 05:21:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9C972FE566; Thu, 23 Jul 2026 14:39:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784817594; cv=none; b=erCkltm7wRSS/8iZ320rfwokOMsfSzBR0MPZuN8Q9BgtF6kFR8Y1TUsJAexh7g+KzWIGCuwSR/04nG4URaTAjOwIsBsEsraU8QG3gFIAiVp8gMVleFDwt937mrVrcdM1ypNhlBSELE3LDf8OLyQWS1Zl62INJNKB+bdxzphMF+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784817594; c=relaxed/simple; bh=AG2LRkto9w3xmViEcMhCZoTnCGM09ad2FMqFX/B0cvw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vCxFxQL4JxdrevpiXmQwyInXW7m7kIwtp4C7+l/dYzFVzwULlp9gPuZJCrnyUDSPLow0RfWCgngyzkoiZUErJK7OWY2nbNhSd6tKOO5Hf+BWZ677e8r7XIesdSn1LieHVl1XrHgjL6VawUKyBclnsVH7w1vH388bsLZAX55aQWg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oK0lRej+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oK0lRej+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 541641F00A3E; Thu, 23 Jul 2026 14:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784817585; bh=uO2/fVWZERlN2SXDU0pXLI74BtIAR6r36vIFkTbpHqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oK0lRej+/t4FtbcfefotJI1JePHFiPDdIcJ7+pEw3RyI61FwAqL7TrFmApoI70rRb T3ajcu0U51cIVYmZQCxSvC2E9/3EtXhsxtlytfVVwmnFi2eiB58eZZcqrKYOvSAErG 9tlg3Ii5w3EY4EAZhFX4by1RWhedF6PvT+h5WG9ErDH6sce0adg4EpCOF2ZYS5rPfQ EndPLZTfv4AMYOgJ4cSs+TZEMPg8JvhnRoc/sa6wtS52nihgjNEn6XSXgTqtDEpVRg qw1/Axl3FjRx5baFLo4B6bUMamzuhVjXGIvLoJgmiT94iIDVE6oL8M/JFsySO2IDax PeiUhvx4qVyjA== From: Sudeep Holla To: Jassi Brar , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Huisong Li Subject: [PATCH v2 2/3] mailbox: pcc: Check shared memory signature on request Date: Thu, 23 Jul 2026 15:39:27 +0100 Message-ID: <20260723143928.2625970-3-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260723143928.2625970-1-sudeep.holla@kernel.org> References: <20260723143928.2625970-1-sudeep.holla@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ACPI 6.6 Tables 14.9 and 14.12 define the PCC shared memory signature as the bitwise OR of 0x50434300 and the PCC subspace ID. They also clarify that the signature is populated by the platform and verified by OSPM. The signature is at byte offset 0 in the generic, extended and reduced PCC shared memory layouts. Check the signature when a client requests a PCC mailbox channel, after mapping shared memory and before binding the mailbox client. This keeps the check in the PCC mailbox controller instead of duplicating it in individual clients. Treat a signature mismatch as a warning rather than rejecting the channel request. Making this newly added check fatal could break existing systems whose firmware did not populate the signature correctly even though PCC communication works. Continue to reject shared memory that is too small to contain a signature because it cannot be inspected safely. Cc: Jassi Brar Cc: Huisong Li Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index d96b8b54e77e..8dfa80b0a90f 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -345,6 +345,26 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) return IRQ_HANDLED; } =20 +static int pcc_mbox_validate_signature(struct pcc_mbox_chan *pcc_mchan, + int subspace_id) +{ + u32 expected_signature =3D PCC_SIGNATURE | subspace_id; + u32 signature; + + if (pcc_mchan->shmem_size < sizeof(signature)) { + pr_err("PCC subspace %d shared memory is too small\n", + subspace_id); + return -EINVAL; + } + + signature =3D ioread32(pcc_mchan->shmem); + if (signature !=3D expected_signature) + pr_warn("PCC subspace %d invalid signature %#x expected %#x\n", + subspace_id, signature, expected_signature); + + return 0; +} + /** * pcc_mbox_request_channel - PCC clients call this function to * request a pointer to their PCC subspace, from which they @@ -381,14 +401,20 @@ pcc_mbox_request_channel(struct mbox_client *cl, int = subspace_id) if (!pcc_mchan->shmem) return ERR_PTR(-ENXIO); =20 + rc =3D pcc_mbox_validate_signature(pcc_mchan, subspace_id); + if (rc) + goto err_unmap_shmem; + rc =3D mbox_bind_client(chan, cl); - if (rc) { - iounmap(pcc_mchan->shmem); - pcc_mchan->shmem =3D NULL; - return ERR_PTR(rc); - } + if (rc) + goto err_unmap_shmem; =20 return pcc_mchan; + +err_unmap_shmem: + iounmap(pcc_mchan->shmem); + pcc_mchan->shmem =3D NULL; + return ERR_PTR(rc); } EXPORT_SYMBOL_GPL(pcc_mbox_request_channel); =20 --=20 2.43.0 From nobody Fri Jul 24 05:21:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 339044C9549; Thu, 23 Jul 2026 14:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784817598; cv=none; b=Mu8MSj3yqC0WK/TWfiXdUVmVsaB0o0XTEgiJCLh5Ue4BNLCf1hbO8e9q9Lf96uCNwFc2CLZzHOTd6PeOBj9r28Il3LrkWsQtkpBWSlh5iArkDey/4rDHW57uFMSEzIbYvi0DbGysY9HDOCE3fHxPtdjeqzYlgKdYBUhl8ByiH1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784817598; c=relaxed/simple; bh=GcI2SiPc0YGZnO56whRXr7+e5nlvFiscXF4ro/2oLjE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OSk92whh22c10ar0KHLoRLRzM88NJacV+8luICCcFdVGsKatu9L+4psylrwhK4v2FypcIUWc02NC9NEIreyVSz/OF+foUXZkLJBpx3Bc5DA5cvpOWTtrnguVJJWxWlqxPZ7esC7aWQbvUQtUmm7HGmMzXg5/AAw6qefWTjq5rMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PuL+UN19; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PuL+UN19" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6EBC1F00A3F; Thu, 23 Jul 2026 14:39:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784817586; bh=FYAIdNSFBh1tmWSYv6lySAtsNEn5shjkM0e1ZGc5R34=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PuL+UN198q7F/FI5K2WK66u6V0dGz+4sEVxeovHwtnaTHcezoiNVfSXWiDuYK2nWM BKAsn4THe7WXp8dXXfI+QfirBef4So5lAQ+U1fCby+P5MvhTcoe6Zsm/2fGNxahafx jLoGrla2CQ7AN5krQDzf5F1qRf3jWpZCdg/vVrj55syHMdY0q5qOiynaYdXR4cTw6T eWRw7S0Hw7wWdljODviiHS0YP6ArA4S/5VxiCM1CeEIB46e/MrY+jrlaLGg2x11u97 V7mCjbKDsdu7ZswFLY1rbYlyfQdFD2SbzKA0T46VB4ygPSoKqvAticlV5ngxRfrT6z rfYcfW7b8kyrw== From: Sudeep Holla To: Jassi Brar , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Huisong Li Subject: [PATCH v2 3/3] mailbox: pcc: Fix command timeout due to missed interrupt Date: Thu, 23 Jul 2026 15:39:28 +0100 Message-ID: <20260723143928.2625970-4-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260723143928.2625970-1-sudeep.holla@kernel.org> References: <20260723143928.2625970-1-sudeep.holla@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Huisong Li PCC command execution can time out when a fast platform completes a transaction and signals the platform interrupt before pcc_send_data() marks the channel as in use. For shared platform interrupts, the type 3 handler uses chan_in_use to decide whether the interrupt belongs to the channel. If it observes false, it ignores the completion and the caller waits until timeout. Publish chan_in_use before ringing the doorbell. Use WRITE_ONCE() for the lockless flag updates and READ_ONCE() in the interrupt handler. The following ordered I/O accessor orders the flag store before the platform is notified. Clear chan_in_use if ringing the doorbell fails. Otherwise, leave it set until the interrupt handler completes the transaction, clearing it before the mailbox core can submit another transfer. Fixes: 3db174e478cb ("mailbox: pcc: Support shared interrupt for multiple s= ubspaces") Signed-off-by: Huisong Li Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 8dfa80b0a90f..9888dab64639 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -91,12 +91,11 @@ struct pcc_chan_reg { * @plat_irq: platform interrupt * @type: PCC subspace type * @plat_irq_flags: platform interrupt flags - * @chan_in_use: this flag is used just to check if the interrupt needs - * handling when it is shared. Since only one transfer can occur - * at a time and mailbox takes care of locking, this flag can be - * accessed without a lock. Note: the type only support the - * communication from OSPM to Platform, like type3, use it, and - * other types completely ignore it. + * @chan_in_use: lockless flag used by type 3 initiator subspaces to filter + * platform interrupts. Only one transfer can occur at a time, but + * the interrupt handler may sample the flag on another CPU, so all + * accesses must use READ_ONCE() or WRITE_ONCE(). Other subspace + * types do not test it. */ struct pcc_chan_info { struct pcc_mbox_chan chan; @@ -320,8 +319,13 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack)) return IRQ_NONE; =20 + /* + * Initiator subspaces use this flag to filter shared interrupts. Use + * READ_ONCE() to sample the lockless flag written by pcc_send_data() + * on another CPU. + */ if (pchan->type =3D=3D ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE && - !pchan->chan_in_use) + !READ_ONCE(pchan->chan_in_use)) return IRQ_NONE; =20 if (!pcc_mbox_cmd_complete_check(pchan)) @@ -331,12 +335,12 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) return IRQ_NONE; =20 /* - * Clear this flag after updating interrupt ack register and just - * before mbox_chan_received_data() which might call pcc_send_data() - * where the flag is set again to start new transfer. This is - * required to avoid any possible race in updatation of this flag. + * Clear this flag after updating the interrupt ack register and before + * notifying the client and mailbox core. mbox_chan_txdone() may submit + * the next queued transfer and set the flag again. Use WRITE_ONCE() for + * the lockless update observed by the send and interrupt paths. */ - pchan->chan_in_use =3D false; + WRITE_ONCE(pchan->chan_in_use, false); mbox_chan_received_data(chan, NULL); mbox_chan_txdone(chan, 0); =20 @@ -464,9 +468,18 @@ static int pcc_send_data(struct mbox_chan *chan, void = *data) if (ret) return ret; =20 + /* + * Set chan_in_use before ringing the doorbell so a fast completion + * interrupt is not mistaken for a shared interrupt from another + * subspace. Use WRITE_ONCE() for the lockless flag update. The + * ordered I/O accessor used to ring the doorbell orders this store + * before the platform is notified. + */ + if (pchan->plat_irq > 0) + WRITE_ONCE(pchan->chan_in_use, true); ret =3D pcc_chan_reg_read_modify_write(&pchan->db); - if (!ret && pchan->plat_irq > 0) - pchan->chan_in_use =3D true; + if (ret && pchan->plat_irq > 0) + WRITE_ONCE(pchan->chan_in_use, false); =20 return ret; } --=20 2.43.0