From nobody Sat Jul 25 05:59:25 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 008BB3CF1E3; Fri, 17 Jul 2026 07:57:04 +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=1784275027; cv=none; b=M9p3BBi/+9rI95r089D8H83Ys94YGsTClfNK8FzoGoO2qIKkQ3BgOMmcmYon4qi72riz3P2iqbQKxlTmggQXQc8JA82HCNpP14LZ1CFrLgl7A004WNnX5aFAHfJEiQl1QFCx7oAV3Ioe9lG1tOV3DOiOuF3AFcvlwAgwVuvQP0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275027; c=relaxed/simple; bh=2QBNKKO2SRZwALMcFZRDC1w6ApklXtdDfYPwaHFr2nQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y2y6QUqVVE3DYVtAliVaj2ZaVR1oZCKg2SCcPjzzr3R32DR8ddBGVlL97ndeQHynYFkaBafts7vODwB133zFGneFiL9Qx415rsrgRD+3FOApQW6UUPGjyy7KMwFqmLQSpnZt4MiEJZeXfyBoH1GsOspK/Frnb8Mo0mwMulXVSTQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JeMIAqgU; 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="JeMIAqgU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CD011F000E9; Fri, 17 Jul 2026 07:57:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784275023; bh=zXpqNVMM7ESu0cT0hoZNWBS1i4qtsT9J4fhzluMciYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JeMIAqgUyqbWUjzNTuI336cboeS3B6qxJGHv1u9EmqX3VYhNBZGu0SItTjDsQjlF+ WOZ54QuxjVnYqL/7yL/3vDU1l6IhyWtiB0fd+XHhWsmqMtX10UaI1BX64NS0S3Gwg9 eOwffR93M6w9V+huyp6yoljABRxPZZy6K6p6kLHVOhroEys5HWalb5uZ1zTwJT08zr NuqgX8naK+tDs9geO3/zUDdyga03FeP3hB7+FYgKzaZdTLdUr2dQ8qyGB3JFNT2DB9 EvDixAYmNlFbdIbP8yteC6zKSZHojCyidWarrZ7380NsFO7wD7kD3mwgZg1e7r16Rk JuaAv/rl+G5Ug== 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 1/3] mailbox: pcc: Notify clients on polled completion Date: Fri, 17 Jul 2026 08:56:47 +0100 Message-ID: <20260717075649.467172-2-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260717075649.467172-1-sudeep.holla@kernel.org> References: <20260717075649.467172-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 Reviewed-by: Adam Young reviewed-by tag. --- 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 Sat Jul 25 05:59:25 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 110523B9D8B; Fri, 17 Jul 2026 07:57:05 +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=1784275028; cv=none; b=rjmGlLT/gboP7ATy7VL4D+iX09MljwcIHxXnbdSKTl0PCOwkPvYEc3cEG858UUTydV1zll1vFEkxj/tNcSH1hsXQMVv2TfNnK0zxEr/WCgt12s0xgZIVYWWkHULSVWQPsgoraJrk96p9X0KxDhcunQmAa9WKqF1wBVAtYCCVrIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275028; c=relaxed/simple; bh=AG2LRkto9w3xmViEcMhCZoTnCGM09ad2FMqFX/B0cvw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FKhDKC7q05ifbK8eoCh1JEui+UUuarJ4nzppAZW7hA7TN5as+TNJSFz/caBc/o2O+Ak4LGQydiJ6nXiJRBl+8btVCDnp19zg7TsbiHF4Wo8Ehkr/P4UpJpj5qUr2Sk3UOsFWwDBYcrcVRTXuYVqxAPkSgNxoL2UKfCrGj1pDcA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WgCXiRJ2; 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="WgCXiRJ2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E11451F00A3A; Fri, 17 Jul 2026 07:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784275025; bh=uO2/fVWZERlN2SXDU0pXLI74BtIAR6r36vIFkTbpHqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WgCXiRJ24x/09FPRB7IsMqZZ3xxQ/785QWJxyebssc1d8qIAYx6BlnmXvtPLCqYy7 3redyUOdTzOmSTt1NkaYHlkEOEsfhaUu4nmkoEO9Qth+ZTYg+DmajfcM0dmwA/iuo+ l2Q+DI8TUcjQdDwz/+Fxu4OZqxZwV9W3SR9kAa2I4KZXG8IS8vgPFWvMntn7gw8hzF 1T0qoIscmuICytyWeGIx6elNYO/4c6zpbP8LO6OLbU1XU9NgXTk1RIQr2guMvEHgEu AFiTMG0eYhFBLKlRooGiqg0kz4mPb91SlONC9AW4TKyUhl9V3jBLPBaKOKti8KaliU C585zJzAIe8YQ== From: Sudeep Holla To: Jassi Brar , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Huisong Li Subject: [PATCH 2/3] mailbox: pcc: Check shared memory signature on request Date: Fri, 17 Jul 2026 08:56:48 +0100 Message-ID: <20260717075649.467172-3-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260717075649.467172-1-sudeep.holla@kernel.org> References: <20260717075649.467172-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 Acked-by: Huisong Li Reviewed-by: Alexey Klimov Tested-by: Adam Young --- 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 Sat Jul 25 05:59:25 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 EF83D3D0905; Fri, 17 Jul 2026 07:57:06 +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=1784275029; cv=none; b=ONdGLMv8bH5uAumK6zX4xXSu7LdccudItnt04M1BiczH1yoqNCBXqKPpexDIPIqctaagScJ8L1NB4bOZUBYALPnX+tTacXDW5tzuvKNcdZ0QYa26nfAUHy14ejVycBgz33MAD4jw+2eI+eb6kU8/5mdExM4AH//fyWnC/9ir3rI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275029; c=relaxed/simple; bh=VYkib/2tRK0MBPMozIws6bs2eWmGsXy9ur+00gGPjsI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RBtfg1/7DoHDPCcc2CcPCXdncq7rUq0fOJAanYakxNIXHsR1VTnOcLEGAEk1Zp0T1A2sRo8LFwETRLEROwad2e0qN0h/Df91wGVnqoNssUGM5/yQHvCe972G2qW4MKQ0O6AUrY/w6cvsv97jTG8ei0xzcMmyHgDqv6CSwthrwWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XjUYeDjw; 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="XjUYeDjw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 593191F00A3D; Fri, 17 Jul 2026 07:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784275026; bh=l3gnAzfGUV0GNzGVkfZ16Z7U7vo259vFrwqGerv2HUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XjUYeDjwBeDv4RcNTGVLbpROQIk+JP+bX0Ou3MuG0qYgm4NA9APpkBey4CC5On7EN eK45M6ebVj5oYDAsBuCayDBwAld1jmxuf1KgCcvgOF7XNRMDkQCSDdlHAwKfkzU7iw 4kGGB7i2MD83NaWflGp9QgR31ORl5Yy7nDSAKBrANbnnwf83ARONjZ0D8/vBbm2kv5 h1gkShOj4fp0V3wDeQoMNE7y6UD8V8yJB7qUDnbYkOMl269QIDbjdeM4fLmtC9priR 9R11q6fP6GWz4eWMw9JGBaFdig3lsZsZmIMADe1H86tOGyr04Bdbgkh4075GFW9+zM Yh7OP3VZCWEbg== From: Sudeep Holla To: Jassi Brar , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Huisong Li Subject: [PATCH 3/3] mailbox: pcc: Fix command timeout due to missed interrupt Date: Fri, 17 Jul 2026 08:56:49 +0100 Message-ID: <20260717075649.467172-4-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260717075649.467172-1-sudeep.holla@kernel.org> References: <20260717075649.467172-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 update and READ_ONCE() in the interrupt handler when filtering shared interrupts. The following ordered MMIO accessor used for the doorbell keeps the earlier store visible before the platform is notified. Clear chan_in_use with WRITE_ONCE() when completing the transaction, matching the lockless flag protocol used by the interrupt and send paths. 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 | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 8dfa80b0a90f..7f99d4ab0129 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 initiator subspaces, such as type 3, + * to filter shared 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 ignore 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 + /* + * Master 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 just + * before mbox_chan_received_data(), which might call pcc_send_data() + * and set the flag again to start a new transfer. 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 MMIO accessor used to ring the doorbell keeps this store + * visible 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; + WRITE_ONCE(pchan->chan_in_use, false); =20 return ret; } --=20 2.43.0