From patchwork Wed Mar 5 16:38:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003002 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 984DA191F66; Wed, 5 Mar 2025 16:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192742; cv=none; b=JTG+tEY4KIF7TXz1vz2HZitkEWgxWvX14uMz2g383GpBwDo4zjyS/7X7tj7YF0I7BiLnmlw1nevVM9l8o/sbq0KVfWTvSi4c1qKzMZkVgrXdrMXBzro+oG2FM5a9iq0GxngSi/SaciasvsmamK7di1ti2AoRxPU3LZGD3kswq/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192742; c=relaxed/simple; bh=g9voXRH9b5scUtRJQUT9IkYk1Q1woAlbAN5ZVwPOsw0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Fg7iJndJEgQnpmhqRKt/aHrF6ZppVUHH92u8a9FuvrsdAOswGhSyEEeZvgH/SkIEuEHTxH+MxP37Us0OBD9vBYFbZyBrzuQZ/+2BtRwWdoPGwHwC0JElQTPFs4u3rC02cer+8Nczvl1c6E3n5U2Uam3QooBQnNdT7IeDnTQgGFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 266831007; Wed, 5 Mar 2025 08:39:13 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2C653F5A1; Wed, 5 Mar 2025 08:38:58 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:05 +0000 Subject: [PATCH v2 01/13] mailbox: pcc: Fix the possible race in updation of chan_in_use flag Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-1-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3054; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=V6iDNkf7FB8p7g5HOzBVjRnuDYthQbqnBHp6HSZoQ4M=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4eFfRXbdJVo7fM20REaros5LzuuqUZWFuvu uS87yr5R6OJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HgAKCRAAQbq8MX7i mOQlEAC4nSoZMV7mnkebG2/TGHeV/HEO2YzCQrnCqwREIy9tOmVfsIEB35W6nF/44S8O0XvrkqU QYaXpjsbm2gDJAHsSFsVc/+FCCweCrjZXOAtK4Sd/G8kp1dAcxYXbzXDu9A4bmX7Buh8Rkzegu1 DWsE1/S7Wqct7EW0/ZAsZlzwZm26+IVThJYUb3crunt/5JYiKWGOg4k/EoKHzRWTtv7KMMATaY5 mGHkjictRTm+IZmUWc6Hqs9gL3fVXvdktNKIO1EwOs8Ek6SKy3PIEBxTlnM6sopyYlcvKq+x0LT +X1iZQKR0zCNJNlwH1g+yy/IGaos971c2yy4+Ah8Zb9EhUHHzVbhJSIMckjGe2GkTUGbMwgCKVg 4R1Ytq8Sv1yz28RAJFQ93RGNo0F+YOwxb31+75FTfoGxqsNv75xNNawvXsVgtZQy3dg0Bqk1LWD Es3Ni6QkRPtXvZ7Wg1PfU4BGkzg65txP6MnfMGzMVxMkLvSmOj4zRVywHyvQmJtJ3jgLwhPM2Af 4y0Y64VUmdi2Wm+OKts7G6qEu/Ds1xlW/KUxsc1Rked2puMJxRYtgBePFvTWdfqxqEQRXorJ/XE VxEYy+XjiZzN/qlA6pBW3fj7jNXrBhZvp+g8xw3C/wmdXd2XtufD/alex0Aq1TK/lIsxZgElOXs AdUXeFmWVUBic5Q== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 From: Huisong Li The function mbox_chan_received_data() calls the Rx callback of the mailbox client driver. The callback might set chan_in_use flag from pcc_send_data(). This flag's status determines whether the PCC channel is in use. However, there is a potential race condition where chan_in_use is updated incorrectly due to concurrency between the interrupt handler (pcc_mbox_irq()) and the command sender(pcc_send_data()). The 'chan_in_use' flag of a channel is set to true after sending a command. And the flag of the new command may be cleared erroneous by the interrupt handler afer mbox_chan_received_data() returns, As a result, the interrupt being level triggered can't be cleared in pcc_mbox_irq() and it will be disabled after the number of handled times exceeds the specified value. The error log is as follows: | kunpeng_hccs HISI04B2:00: PCC command executed timeout! | kunpeng_hccs HISI04B2:00: get port link status info failed, ret = -110 | irq 13: nobody cared (try booting with the "irqpoll" option) | Call trace: | dump_backtrace+0x0/0x210 | show_stack+0x1c/0x2c | dump_stack+0xec/0x130 | __report_bad_irq+0x50/0x190 | note_interrupt+0x1e4/0x260 | handle_irq_event+0x144/0x17c | handle_fasteoi_irq+0xd0/0x240 | __handle_domain_irq+0x80/0xf0 | gic_handle_irq+0x74/0x2d0 | el1_irq+0xbc/0x140 | mnt_clone_write+0x0/0x70 | file_update_time+0xcc/0x160 | fault_dirty_shared_page+0xe8/0x150 | do_shared_fault+0x80/0x1d0 | do_fault+0x118/0x1a4 | handle_pte_fault+0x154/0x230 | __handle_mm_fault+0x1ac/0x390 | handle_mm_fault+0xf0/0x250 | do_page_fault+0x184/0x454 | do_translation_fault+0xac/0xd4 | do_mem_abort+0x44/0xb4 | el0_da+0x40/0x74 | el0_sync_handler+0x60/0xb4 | el0_sync+0x168/0x180 | handlers: | pcc_mbox_irq | Disabling IRQ #13 To solve this issue, pcc_mbox_irq() must clear 'chan_in_use' flag before the call to mbox_chan_received_data(). Signed-off-by: Huisong Li (sudeep.holla: Minor updates to the subject and commit message) Signed-off-by: Sudeep Holla Tested-by: Robbie King --- drivers/mailbox/pcc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 82102a4c5d68839170238540a6fed61afa5185a0..f2e4087281c70eeb5b9b33371596613a371dff4f 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -333,10 +333,15 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack)) return IRQ_NONE; + /* + * Clear this flag immediately after updating interrupt ack register + * to avoid possible race in updatation of the flag from + * pcc_send_data() that could execute from mbox_chan_received_data() + */ + pchan->chan_in_use = false; mbox_chan_received_data(chan, NULL); check_and_ack(pchan, chan); - pchan->chan_in_use = false; return IRQ_HANDLED; } From patchwork Wed Mar 5 16:38:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003003 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0633419DF41; Wed, 5 Mar 2025 16:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192743; cv=none; b=FcT7rHgCKk0mPZVybyz9Z1ZiyKqMFQ0gVKVq/X9vURMUKkQGHLscS0cB0x048c5nsajjc6UOh2QaN6DKcRh/E9HpPBlqlJ+LeymBN07CpyK7Y2NUuFBh6Jwdk5IbAAjpfIvEE1CG3gUYN0Bi2omQ+bTzjgLM+uQ/6YHeQgzreVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192743; c=relaxed/simple; bh=s7B+ahRe/ZrUp9puXvR0Xlhm02ueQhd2vnuyBhYBT4w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LlHviubIpTMNv/F1FozlrTWm/kbeoBzHvU8cC6OLs4NmzguW8J06qP0LYjNE5HbuOHPD8jdWPSXN1dloPCbqalRLVXvTQOYI9hOFVn+Ie948kfksgr5l5IKZWHbeucE1a3nlNxttKKSb8RWTKJ43FrQ9kMHJ+EUAanc5rVgw5cQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 98BD71713; Wed, 5 Mar 2025 08:39:14 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 30E5D3F5A1; Wed, 5 Mar 2025 08:39:00 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:06 +0000 Subject: [PATCH v2 02/13] mailbox: pcc: Always clear the platform ack interrupt first Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-2-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4712; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=s7B+ahRe/ZrUp9puXvR0Xlhm02ueQhd2vnuyBhYBT4w=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4evRpTuF123iDB5y1GdK8xJsTkhVLbO8sOs elKveJw+bCJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HgAKCRAAQbq8MX7i mMEUD/4v/Fp6tmnX9I4A+awLnmgk/+qqIyGlVhtZXOES/xK+wN8lvCA4no+Ps6QtQS6Fl3TS+x8 kUrJ14afbjXnFMxGVc5CtK1YWSc/BX0rmnFcLjMklXW9IrMtvyUp7+C5Hn/utLRYX80jYdZl2Jo Qovsk7zuDAu0VKOCCNj3MSlwgCI1nHL4+VgnedCsE4OXnMozOkcfStmwfNUSVM1zp5HJMvuKGwF spIIL/q4SSvx5dP5zgnMjD/qQXjILNBegkRkPKiF8FGN8Vak8Y85lnizthprAVE5KzKIRwSxY8t ikAxbQ1feq/lEtmWGLPMNx1Gxht00FeuPYTrivtPhmzBWBPk8udmHQ2YPRV+4qmycPYA4I1p/wP jKnwqK12aG1QlOHUu4LyvLZ/GlNZsl9TCHmHMPdPQdRsFcry8vTlRtHyr0xCkD2YB8E/oVXOJFc yXk5/6dvH6zhywCAnH+guEbvD9drm0kgxQkB9IH7Q44s6xLqNFpUqo9q51FXmscpmpHKbWSlaGd J1PEroS5Btmo9VT7Gr2GF7OP2V4CjYshruEDtD4ARw0yunTSpIyPLww6+Qd5lk/HJKhfMJpfzFm fLfyNEwSWkIa4GDpfXnE7gbShsNW7x86fAskXIEelRGZ6sWpEJpYGqFtrYixxr1zR2ZSzM2rZDn RclVZYZZPtvXABg== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The PCC mailbox interrupt handler (pcc_mbox_irq()) currently checks for command completion flags and any error status before clearing the interrupt. The below sequence highlights an issue in the handling of PCC mailbox interrupts, specifically when dealing with doorbell notifications and acknowledgment between the OSPM and the platform where type3 and type4 channels are sharing the interrupt. ------------------------------------------------------------------------- | T | Platform Firmware | OSPM/Linux PCC driver | |---|---------------------------------|---------------------------------| | 1 | | Build message in shmem | | 2 | | Ring Type3 chan doorbell | | 3 | Receives the doorbell interrupt | | | 4 | Process the message from OSPM | | | 5 | Build response for the message | | | 6 | Ring Platform ACK interrupt on | | | | Type3 chan to OSPM | Received the interrupt | | 7 | Build Notification in Type4 Chan| | | 8 | | Start processing interrupt in | | | | pcc_mbox_irq() handler | | 9 | | Enter PCC handler for Type4 chan| |10 | | Check command complete cleared | |11 | | Read the notification | |12 | | Clear Platform ACK interrupt | | | No effect from the previous step yet as the Platform ACK | | | interrupt has not yet been triggered for this channel | |13 | Ring Platform ACK interrupt on | | | | Type4 chan to OSPM | | |14 | | Enter PCC handler for Type3 chan| |15 | | Command complete is set. | |16 | | Read the response. | |17 | | Clear Platform ACK interrupt | |18 | | Leave PCC handler for Type3 | |19 | | Leave pcc_mbox_irq() handler | |20 | | Re-enter pcc_mbox_irq() handler | |21 | | Enter PCC handler for Type4 chan| |22 | | Leave PCC handler for Type4 chan| |23 | | Enter PCC handler for Type3 chan| |24 | | Leave PCC handler for Type3 chan| |25 | | Leave pcc_mbox_irq() handler | ------------------------------------------------------------------------- The key issue occurs when OSPM tries to acknowledge platform ack interrupt for a notification which is ready to be read and processed but the interrupt itself is not yet triggered by the platform. This ineffective acknowledgment leads to an issue later in time where the interrupt remains pending as we exit the interrupt handler without clearing the platform ack interrupt as there is no pending response or notification. The interrupt acknowledgment order is incorrect. To resolve this issue, the platform acknowledgment interrupt should always be cleared before processing the interrupt for any notifications or response. Reported-by: Robbie King Reviewed-by: Huisong Li Signed-off-by: Sudeep Holla Tested-by: Huisong Li tested-by: admiyo@os.amperecomputing.com Tested-by: Robbie King --- drivers/mailbox/pcc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index f2e4087281c70eeb5b9b33371596613a371dff4f..4c582fa2b8bf4c9a9368dba8220f567555dba963 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -313,6 +313,10 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) int ret; pchan = chan->con_priv; + + if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack)) + return IRQ_NONE; + if (pchan->type == ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE && !pchan->chan_in_use) return IRQ_NONE; @@ -330,9 +334,6 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) return IRQ_NONE; } - if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack)) - return IRQ_NONE; - /* * Clear this flag immediately after updating interrupt ack register * to avoid possible race in updatation of the flag from From patchwork Wed Mar 5 16:38:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003004 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8349A1AB531; Wed, 5 Mar 2025 16:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192745; cv=none; b=FLHTiJNFdbqWemBK9n3+yqnjsdGpeVUDeRk/J1PegoaqOlVS+t4LXfSN4QByoVhS/RCcoz4XNBuXUHEHPmop7J2SfcJ5LwalcMAWwtguX7BL62x33TYF3L5ZbPlgNJ6Fcqelal7d/0mrCc7CwmfHAM+TV61KP+rTH2FmEwPSJFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192745; c=relaxed/simple; bh=12e2e0dB2lXxvdlCmBvDPuISEpM3AnCYciIJsM+VoEU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DIjhf2KVn2gAXe4FV9HYzFF7ziFWgneuD9KPOMxgMAVxX7UCc5fGf2ps781pGKK3DsSMmEOauxyHy/rGmq3vMuYywouWbHBG3epwEX2JW7xAx/xQl8qpUH47sLm3NHkY/mMXmC55tepb1BLjwKE2Myt5kqxQ+Kmghk9WBqmwq4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 16DA2175D; Wed, 5 Mar 2025 08:39:16 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A354F3F5A1; Wed, 5 Mar 2025 08:39:01 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:07 +0000 Subject: [PATCH v2 03/13] mailbox: pcc: Drop unnecessary endianness conversion of pcc_hdr.flags Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-3-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2041; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=12e2e0dB2lXxvdlCmBvDPuISEpM3AnCYciIJsM+VoEU=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4ea58zBwAHlZGatJPdQa+A347wiSYI+RQHQ eWjnwgAIvCJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HgAKCRAAQbq8MX7i mEKDEACiA2EUJ4bgtjGduofUPnjXlg3VIKPwHkTdnv09vKcIqmMN6SlDMhJSw1/15HH9144DcVR x+skEt7VLxJ3coBhfq4imjQYSD0FIwDzF7euIFDSxmSUlqVy3fCKlY7ydE2dRl343Eb5QIw/7mK 6webgEO+d+TtJA87g73X+62/1E/RoUOwL5FCvZYHhYNxrnH6o+6LwbSAR8hwiQhRUMTdhKekOSg 7nsPUR4DTYRkEH36vqCFkc3SxluGxpS622oWXWzPcH23SNrDMbpyASF3qU1PyoIpWou1Q2hIntX gs+akCD5V6MspWEUDzBq9INnNz8vNZn0mA0xx4NOwQrznZ9YOd9u2A3fXzSfWleGkUt8zO6FVsf cgrfY73dbNvp5kmPY0l26TyDYaEBtJOVxKGcyuQ6Vhvh8JZJmvs5MePH53f03/7d7DQchoYeoN9 NCxEYsSJWAOtujBIpLb7PNuslbR82oA1Iutu1MDBGEBvyA/EqXa7+BnR67XUn1FAj08wrgpl5Nq rmvoBup5vD3kxajH4V4RE4oq1+HJRujBYTQIK/iUYKk/APAPxxlDxBmu/G5cvH94BwSxXZ4kwqA ByDX1dZyrYWNmj02unxi/vPVf2O432VjgjrS8VwiblOd5OvJHhkX0gZkNtPWlBbruuivQnzWJnA 2+w/WCZAth/mJPA== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The Sparse static checker flags a type mismatch warning related to endianness conversion: | warning: incorrect type in argument 1 (different base types) | expected restricted __le32 const [usertype] *p | got unsigned int * This is because an explicit endianness conversion (le32_to_cpu()) was applied unnecessarily to a pcc_hdr.flags field that is already in little-endian format. The PCC driver is only enabled on little-endian kernels due to its dependency on ACPI and EFI, making the explicit conversion unnecessary. The redundant conversion occurs in pcc_chan_check_and_ack() for the pcc_hdr.flags field. Drop this unnecessary endianness conversion of pcc_hdr.flags. Also drop the redundant PCC_ACK_FLAG_MASK definition and use the more appropriate and already defined PCC_CMD_COMPLETION_NOTIFY. Signed-off-by: Sudeep Holla Acked-by: Huisong Li tested-by: admiyo@os.amperecomputing.com --- drivers/mailbox/pcc.c | 2 +- include/acpi/pcc.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 4c582fa2b8bf4c9a9368dba8220f567555dba963..42dd405482e407cf90e66917a46fb8e350e0eeaf 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -292,7 +292,7 @@ static void check_and_ack(struct pcc_chan_info *pchan, struct mbox_chan *chan) * * The PCC master subspace channel clears chan_in_use to free channel. */ - if (le32_to_cpup(&pcc_hdr.flags) & PCC_ACK_FLAG_MASK) + if (pcc_hdr.flags & PCC_CMD_COMPLETION_NOTIFY) pcc_send_data(chan, NULL); else pcc_chan_reg_read_modify_write(&pchan->cmd_update); diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h index 699c1a37b8e7846362bae35477eb5736be15d79e..d1e506f041c5a80857d4a025fa3c1803746ba4b9 100644 --- a/include/acpi/pcc.h +++ b/include/acpi/pcc.h @@ -32,7 +32,6 @@ struct pcc_mbox_chan { #define PCC_CMD_COMPLETION_NOTIFY BIT(0) #define MAX_PCC_SUBSPACES 256 -#define PCC_ACK_FLAG_MASK 0x1 #ifdef CONFIG_PCC extern struct pcc_mbox_chan * From patchwork Wed Mar 5 16:38:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003005 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72B7D1C6FEB; Wed, 5 Mar 2025 16:39:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192745; cv=none; b=G8CXQUmXcz2xlzYjFTA65FDwlpCN9QBvnfHwyYNfg6Le+ZeQV8Q9luTiME3kjxUY6l8qeeiLsHlCeV0F2Bo5OGAefH6JBx/x3a3vq/dfPxKkjo+hnnNonDcue13oQerE+jCManJTRGRYH0VDqK/Mj8P5bWcvzRIaTC+gdsOU7NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192745; c=relaxed/simple; bh=u7IOglKs+EyHqGuH1VZb2e5m2zCVGlEZYh8pGjyJYA8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O6TgymWkpYI3q2z8rRptMZUM4N6Z0kUL2pkBTrMrgFL7VMTxtX0J6EbiyhJ0Wo8gb5PR6CQOK63FY/IfivQXB9ybSyuwqWUOpqIyTqRO9Jgp0HOEYL1FnmQ7ef6qJMOTojpylSenpRqKCz07ZBDJQ3MEjLuEnxp7qK8MYxNtaQQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 894981FC7; Wed, 5 Mar 2025 08:39:17 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 219703F5A1; Wed, 5 Mar 2025 08:39:02 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:08 +0000 Subject: [PATCH v2 04/13] mailbox: pcc: Return early if no GAS register from pcc_mbox_cmd_complete_check Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-4-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1140; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=u7IOglKs+EyHqGuH1VZb2e5m2zCVGlEZYh8pGjyJYA8=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4fZ6fdf+KECuKLt/Z7eiJPtCHzqYSSOa+iD 1uh6RheShaJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HwAKCRAAQbq8MX7i mDWlD/4sL2iQEquO9LaTH/+dIxXIsWMw3la9ywEN4szrwY1s+1AuFbzueDBQ9rLQkbqO18ycCFS fD75wZguLr/tc1AGsjGhZpWVcJwakpPmOPJ72UdbvnW8qgnskzG8D5vw0B1/3Gq3Kubb7Xuoa+y eKeh9OAK/JdFhEIewaOZhYICQAQZMMOu4/ASOZ1lDzx4gWug6XMqYxKZ/JpsRq2FcwcfX2Sr6/L XpmUUyXFq07zsN8BgLzg8xW+TBZVU+cf1hn31XHZiUUJw1jJlyAPonCNZwXNTdokeJvaBO2Xwnw ZUzI/1EQjTAwWMoMtzvEFT6a7k/hOPH7NmO4utD2VawvzoU/uJ6DGOTlGA8vry8KaRoMHsrN84L +S8pzii3Bavw0uNPK5FQmlZIIghSqXq0CYOrjp/Vjq2/zNS/k3OwlO6Mnhinz7Knyeink91nJhu azgmU9bhUfwdqxBhK4XKSkGLKJh+tRCiyyV7sHKtCDpyfDcrlM5++PiBWd4yeCmud91NqcW7aqa fAZrvq1SC2So7uJiYGTmiZjM7RdSmduwBKz0P+VZxqCbDGl3L+IlpLgAsskEzvZKaaPaLux9VW6 lvAwYnaKIILHVr5Pad7KmDsKL7S7u7cxKVpiXmg7nnTv+Jh35rkWvgHRyAaQR0bQ2yEMUqmGsbf eg1hYUA1rNTnfwg== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 pcc_mbox_cmd_complete_check() accesses pchan->cmd_complete.gas to check command completion status. Even if GAS is NULL, pcc_chan_reg_read() gets called which returns success doing nothing and then we return. Add an early return if pchan->cmd_complete.gas == NULL before performing any operations. Acked-by: Huisong Li Signed-off-by: Sudeep Holla Tested-by: Huisong Li tested-by: admiyo@os.amperecomputing.com --- drivers/mailbox/pcc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 42dd405482e407cf90e66917a46fb8e350e0eeaf..5a9ae67f5c50a3e43d30aa368c31c80b81db01f7 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -245,13 +245,13 @@ static bool pcc_mbox_cmd_complete_check(struct pcc_chan_info *pchan) u64 val; int ret; + if (!pchan->cmd_complete.gas) + return true; + ret = pcc_chan_reg_read(&pchan->cmd_complete, &val); if (ret) return false; - if (!pchan->cmd_complete.gas) - return true; - /* * Judge if the channel respond the interrupt based on the value of * command complete. From patchwork Wed Mar 5 16:38:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003006 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E313225332F; Wed, 5 Mar 2025 16:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192747; cv=none; b=a6sNIYleBHgQRBiuvtDkuCR8DLZEM2vCskaZcCNnnVzd8W9pOeW19nDfZ99amwfQmbFMVRHPz+BxRWIFfkfW8hIWvWT4wwMW0Inap1mfF4EMYfX+K1nhMM/qIf9yh5Ji5ySiKBkKmVSAYds8VsAe75xIBgTPKBjf2+xe+Cqjnls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192747; c=relaxed/simple; bh=9BkIGgfS0RG6AgwZYwfBR/H6S0S8n79d9GcPGd/VSic=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mo5JhpRo+8AAXl0DmpvQbySO0ivhje50686g+vqoEAnjrfbR6EURCOUgTmvMCFVViwZ0eEdd/Y6W5AEtcikxRiNO/8bbHUOkkCbMG3202ud9HHfBpL5SjwdnbeqKVOGL4885QukClR39V6FZGPt7jm2jgezX/cM/wnC2ZO3L4rs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 071561FCD; Wed, 5 Mar 2025 08:39:19 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 93B253F5A1; Wed, 5 Mar 2025 08:39:04 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:09 +0000 Subject: [PATCH v2 05/13] mailbox: pcc: Use acpi_os_ioremap() instead of ioremap() Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-5-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1277; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=9BkIGgfS0RG6AgwZYwfBR/H6S0S8n79d9GcPGd/VSic=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4fdgv5QsAezQ1z9+Y/UIgvXihIakDP3PBkG aQ54yp0LPmJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HwAKCRAAQbq8MX7i mNjiD/9n5QdcY5P5URbCWoCuIspKXYgjIPDgULuV396obVfUUwZ2yEgG6gZGocPnt4a1F5jVitE q67L4yKR07ux6FMMccGGGoSICec4E7VpOXstbA4bqh3RU08BEx/W9vGffT90h0K5b1YfyizjC1q XSDUlSx4/x6wclBJvAIt1H+VcOu9apAJChg6scCjkLAc4riPOb0xb7bVssxy9MDi/7Y0ZU2hLKN nyCswu7zmIdm3t/m53tnmnaRa8kmVCHtuoUmAeQm7Ml9mmbooc+rrcBFGvlw98nwvkjdyeykdjG yyX4SAbWLEcolYShuown4clTzTnZJ1VtuOfmH9ubYuK+sAYg6E5vyh8276KkPgvds7oPo+7tT0b yaRBuy7Gz8pcdj2BCzTihktMUY0VqinX7IaO03zmVUyQ6PVSsuvn5OaNjU1icYOMaNlUJ36k7CK 39wA+Ab4UaAh0JDEt1GOZXf7QZwWdrf/URwOych4le3BbCW/FNfps//lDgRocZTmfdTYHsI3sGd Smp+euoONXFR6DSP6HQSm8715Tnw99o38hYZBuiFIdoT7uHug8WJI2Wfw2jEeVqSKSnOrp6OqVQ emKvEQqjTZxXPRagfwhXY8gSmBLDo0aUQzIpIapojLY9tfml4vWVT0SOjumZ0ryoi/QUVb1SQlV NH9SNjZO8LcXk2A== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The Platform Communication Channel (PCC) mailbox driver currently uses ioremap() to map channel shared memory regions. However it is preferred to use acpi_os_ioremap(), which is mapping function specific to EFI/ACPI defined memory regions. It ensures that the correct memory attributes are applied when mapping ACPI-provided regions. While at it, also add checks for handling any errors with the mapping. Signed-off-by: Sudeep Holla Acked-by: Huisong Li Tested-by: Huisong Li tested-by: admiyo@os.amperecomputing.com --- drivers/mailbox/pcc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 5a9ae67f5c50a3e43d30aa368c31c80b81db01f7..b1b8223b5da7002fc522523dbc82f6124215439a 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -418,8 +418,12 @@ int pcc_mbox_ioremap(struct mbox_chan *chan) return -1; pchan_info = chan->con_priv; pcc_mbox_chan = &pchan_info->chan; - pcc_mbox_chan->shmem = ioremap(pcc_mbox_chan->shmem_base_addr, - pcc_mbox_chan->shmem_size); + + pcc_mbox_chan->shmem = acpi_os_ioremap(pcc_mbox_chan->shmem_base_addr, + pcc_mbox_chan->shmem_size); + if (!pcc_mbox_chan->shmem) + return -ENXIO; + return 0; } EXPORT_SYMBOL_GPL(pcc_mbox_ioremap); From patchwork Wed Mar 5 16:38:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003007 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79DF8253B49; Wed, 5 Mar 2025 16:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192749; cv=none; b=gJWIf7uelM11HNHvHR1ju0Gn/dMia2JOKSq4F7PXcleZO9FWquHR1S+8RjiFyj0ZAba45qps96wsyQBXeRjpZIF8j7y/xVwbs/FFjSXKd9eEODRhwFnL2ASAixrq6JFR2ZzLKcUIaUC4EsBAeSe8mXX2Tp65n1O6nCZvf53lA/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192749; c=relaxed/simple; bh=DRH/HW8c1VcvGJoJWUjrx/wudPtyFYzck+Lc7GivUvQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LU4QKE6nfNq6f9nYkBLiYRDZ3vJ5UcIjYI62v4+mVa5Ug+fs65sSKhCUxABZNEbGDvPXprcGO1mI71/rYKp5ZlDJT44cVjh6toUMjLCPKoWw6uTNPi6pGAe7orG/M7lFoJoe0y6EYqj2WY8qAPrP7CDoVCVISBfCtBK4k7zeo0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 86EF41007; Wed, 5 Mar 2025 08:39:20 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 11C273F5A1; Wed, 5 Mar 2025 08:39:05 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:10 +0000 Subject: [PATCH v2 06/13] mailbox: pcc: Refactor error handling in irq handler into separate function Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-6-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2268; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=DRH/HW8c1VcvGJoJWUjrx/wudPtyFYzck+Lc7GivUvQ=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4fjyyoihzv7P4evKi/PgcHENfIFGeNed1Gr /CjennMOqiJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HwAKCRAAQbq8MX7i mK6jEACzRTSrhQCUszDp1kapXWaARXGrfjmx0KApmsHP3mK3i3nlpb+eElzqp+x2/6JRjPeaIH/ f/e2Gi376ZE6Hotqd1jIfHQX+DiAesxRBwYfyDn/49owNtgemmA2ZfbG94PhXka5FhhBNpiqsbG WxCJJ43ma5gJ3Dig9RWO4cQ0CM47smuCeUauAcfX5D7jE5EEn1zJ+NE49oBOP14ipzOjbjSkbrM nkTHz8lprh2PRvWNLuF0BlIaRTDO5t0XifUtFSuV2sb7UtvjjediRT2RPyqqsZqeNRTNYPrXKgt L6rZiOhhxJ70BkCdSRgaNrZXhWkMMPx9fA2G52Z1+ufSEe8MB6XuwsZaMU2x+k6KcR9u4r5q/3A wgGUXW1fej4hAMlNd5jtHXT27He5hSNE1j7di+mSWVyVByb93pzLB6CD78ZLsdXjrO53pxHq+OV 5vxm2UUjEd9PsUupiPRfSyNoniGmsUGwCXz1GpNXu8OhQ7G1KwQtf14GNDjPwgPBqvIcDP3nChj WdP0squIfDC13q77ogsPkw+ifKANTxPdL0nWRHY7S1vaON2ZjkSZMisjtKAGa/oTCv2lP80dk+E fFPrGk3ro3a1VN3FXB9np+WC63rYU8rB35crRyx38pio7iS90u8p6Myh7MGiRZiomQZEW8GjVLt KJ2lWBQKEiCNTqw== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 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. Signed-off-by: Sudeep Holla Acked-by: Huisong Li Tested-by: Huisong Li tested-by: Adam Young --- drivers/mailbox/pcc.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index b1b8223b5da7002fc522523dbc82f6124215439a..41bd14851216e8c4f03052c81aaf938a5e5c5343 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -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 immediately after updating interrupt ack register From patchwork Wed Mar 5 16:38:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003008 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4DE2253B6C; Wed, 5 Mar 2025 16:39:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192750; cv=none; b=F3hOXu9fFHneU7FlsBSFGYtSX/k/44mDiUmQyJ+yDWybJMKK1lP5HW++DZEeaZM+EyY1BLsE2BTQV9NOUX7k8kzx6CX74fOnY9X1ANWt/NImLXOOL3pLG2qPwYpLySIr3Zl+kjrt62LStuVSlNt/jbCT8ujutx4F5sa102VC4jA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192750; c=relaxed/simple; bh=3gG4bhdBBdPQXYHnCh1tDD44kshqbRCDD5IBuZJ5OCQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ce6T1jo2VLcYRGM3tU0KZJYy4qurYftw7cROn6AcqN1QZMqvtT5ea8epQn/NrGWIP1w8XwJXD1kmBWR6qB7Q6M37PMaoWhuvAsUTZsD5Tp0y/lN+jhFrgzbMr95chaoHdM7WAfzcgIKq4IcvQM4Gw9uTqkWv61DtBRSDEV0nkRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EBA0F175D; Wed, 5 Mar 2025 08:39:21 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 841883F5A1; Wed, 5 Mar 2025 08:39:07 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:11 +0000 Subject: [PATCH v2 07/13] mailbox: pcc: Always map the shared memory communication address Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-7-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3589; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=3gG4bhdBBdPQXYHnCh1tDD44kshqbRCDD5IBuZJ5OCQ=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4fKGUhzok51QkKceWpORVOsgFh4eaCT86xb Ap8QvMV+7WJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HwAKCRAAQbq8MX7i mAt4EADVZw+JPfCSfHGsbdintdw7QqBVsxE/5Jbgs0YTNfb3HRGGSNnHt7ULjk7gJToWABMuded 1HsSdhUYAOiicBhuaMk+J0FAV8SJJVtULfkKzLMvLtSZYmdMt91WTxIYZmF8JAWgblSybtKcK+R x9m2BmgpRgEE4qnYwT3mAIAWjKr5wQFZd6REvfZj6GAtAEzc+KJ1+3BALwBvemn2s4tlRMs9fxq UGaazyhSEvvM3LDgl7dFS/+F1yxobViQGNBa9dDoEmRI0KH6T18c5Hes1k872eV2o79fjmrZvO9 E587oC7AgwmlmsayO3V6F+OfpHDntjNRsbngD94o8uNlbVDK2wgknvQLWeQDvuh2JShTCJQ/JMY E31ovzHPopOTu6AgPhWdNWv0Si9Lr3sZGrM8qaXxqPoZ3RaTE4YvB1CnjPqoJak7MtBfqugWOTI gPNWmy6wsbBmNxPI18wWo/nifSmEimlkODMoWSxvuhcZ4gs+fBKfseoLcwPYFWJyiAw0F0Xj31W qmZ2oPBkeaGr5o8/a3aoxnHgWNfkBkEdhYXoYtuXBko3ScpwnMlegX4zhvon0ASCVc8/YE3n9Yw 2AJ3RYUuKqLv2cjGUMHlQ9NdhCY2L8FuPpBKW/TuvwqWK6vxJ9Ou7fGxxq0HK8KqpUNurOVLZNL 6P1CoAMiiTr7qOQ== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 Currently the shared memory communication address was mapped by the mailbox client drivers leading to all sorts of inconsistencies. It also has resulted in the inconsistent attributes used while mapping the shared memory regions. In order to remove/eliminate any issues, let us ensures the shared memory address is always mapped and unmapped when the PCC channels are requested and release. We need to map them as the ACPI PCCT associates these shared memory with each channel subspace and may need use the status or the flags in the headers of those shared memory communication address regions to manage the transport/channel. Since there are no users of pcc_chan_ioremap() and also it is mapped by default, we can stop exporting it and merge the functionality into pcc_mbox_request_channel(). Signed-off-by: Sudeep Holla Acked-by: Huisong Li Tested-by: Huisong Li tested-by: Adam Young --- drivers/mailbox/pcc.c | 29 +++++++++-------------------- include/acpi/pcc.h | 5 ----- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 41bd14851216e8c4f03052c81aaf938a5e5c5343..b3d133170aac7f8acfd1999564c69b7fe4f6d582 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -372,6 +372,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) struct pcc_mbox_chan * pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) { + struct pcc_mbox_chan *pcc_mchan; struct pcc_chan_info *pchan; struct mbox_chan *chan; int rc; @@ -390,7 +391,14 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) if (rc) return ERR_PTR(rc); - return &pchan->chan; + pcc_mchan = &pchan->chan; + pcc_mchan->shmem = acpi_os_ioremap(pcc_mchan->shmem_base_addr, + pcc_mchan->shmem_size); + if (pcc_mchan->shmem) + return pcc_mchan; + + mbox_free_channel(chan); + return ERR_PTR(-ENXIO); } EXPORT_SYMBOL_GPL(pcc_mbox_request_channel); @@ -419,25 +427,6 @@ void pcc_mbox_free_channel(struct pcc_mbox_chan *pchan) } EXPORT_SYMBOL_GPL(pcc_mbox_free_channel); -int pcc_mbox_ioremap(struct mbox_chan *chan) -{ - struct pcc_chan_info *pchan_info; - struct pcc_mbox_chan *pcc_mbox_chan; - - if (!chan || !chan->cl) - return -1; - pchan_info = chan->con_priv; - pcc_mbox_chan = &pchan_info->chan; - - pcc_mbox_chan->shmem = acpi_os_ioremap(pcc_mbox_chan->shmem_base_addr, - pcc_mbox_chan->shmem_size); - if (!pcc_mbox_chan->shmem) - return -ENXIO; - - return 0; -} -EXPORT_SYMBOL_GPL(pcc_mbox_ioremap); - /** * pcc_send_data - Called from Mailbox Controller code. Used * here only to ring the channel doorbell. The PCC client diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h index d1e506f041c5a80857d4a025fa3c1803746ba4b9..840bfc95bae3329605da5f66cf37b7d2ca183f48 100644 --- a/include/acpi/pcc.h +++ b/include/acpi/pcc.h @@ -37,7 +37,6 @@ struct pcc_mbox_chan { extern struct pcc_mbox_chan * pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id); extern void pcc_mbox_free_channel(struct pcc_mbox_chan *chan); -extern int pcc_mbox_ioremap(struct mbox_chan *chan); #else static inline struct pcc_mbox_chan * pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) @@ -45,10 +44,6 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) return ERR_PTR(-ENODEV); } static inline void pcc_mbox_free_channel(struct pcc_mbox_chan *chan) { } -static inline int pcc_mbox_ioremap(struct mbox_chan *chan) -{ - return 0; -}; #endif #endif /* _PCC_H */ From patchwork Wed Mar 5 16:38:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003009 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C70D253F09; Wed, 5 Mar 2025 16:39:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192751; cv=none; b=ilcw0pIgfMDhAJsExFlsLuPx1yLntavFR2FDKjRG4B2PqEz0+uK1FGJuv1UBu8WIMsHDdHPsYl2CteXH3CGZGGm5xCwKaO6arCnWAGZ70Aj+nNSYl4GPhHxURC325zPjt3icINM1HR3kJuq/iNNPNjO88BEnXPiAPQvLQCQs6JI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192751; c=relaxed/simple; bh=cIMK+n2o3rsEDin9AdC2kdUyZidm53z6uq3MCcTwSQg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tqyGMwvO8p5zYyqOYqltg2IHvRCzW+ThfC8tF/UDF18QL1eTixncBLgm4i7j08uRpo0l883eX9AtGYmT51dXIVCY7PtXGdk8NehRkQ1xKxMOxdYgEUlP3cd2q3xQgLru7N/yoouyWVIsKJQ1XHXlw4CUYbz6/P88TDwh2xnpHJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 69EF01007; Wed, 5 Mar 2025 08:39:23 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 024B33F5A1; Wed, 5 Mar 2025 08:39:08 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:12 +0000 Subject: [PATCH v2 08/13] mailbox: pcc: Refactor and simplify check_and_ack() Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-8-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3255; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=cIMK+n2o3rsEDin9AdC2kdUyZidm53z6uq3MCcTwSQg=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4feH/zpixLfwK1FIMsiLYeun31q3x7DjtWE 38wETNpmQ6JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HwAKCRAAQbq8MX7i mPSaD/0SqruOF5TMB89h/SJ7N9Gar+UBqixxFlGmCdBwc0PwKs60XV+ORSdQC0YHGy/jGjNKy9e cRvtmteTRjJwvqjAs8m7u6SVaYqQPYvdELlBITUzgl/hSwRwFefujJ4piaHeB7ZGXEadwwJv0ih lBDTsZDIRL4R58ztikkmNmMeAFNJN9a1rkNOwmChCprFQssiHu6vWsIdhwFTpQzxhTIKCThCpHu aLkP2B/u7LcoG3VwJu1tSYmYOTXyv9L7LriEZyr9cc54O89yg58h7j5ATjsxIx+5x6XIi61MjXn ADInbZ+aidihC+To4FYJSx6EKMgMkg6uK7HoU0wlATLdCNXMi+/X8W6iRQO730oGY96FV73/tX2 mNT5mBB1hrODPMvvylgnArNUaBvwKx1+/tIMekofYygy7xmMNPuA6/Xj+jiyWyGDiBIuzPbTxFs e2j3PxHueIQsPS1C54hOwGIY8AYesHpI6/ylViFcCIbLnYjOtW/x9afghUcehD/tAtXp/tkNHVp B0Fk8zpsbbqmp3XDPMfwbm/xMSKOKXef9Kz/U+rbySx/V7+qNFd+fufLrM5+L5KVcDAau0MH/tk f6ayv0a6mBjpDoNw893xtnRcLDuJSTXkZQud8g7EpAEXD8i/YakwRrES8QRTCN5MhaVNpcRv0b+ op1IWru87Hxz+/g== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The existing check_and_ack() function had unnecessary complexity. The logic could be streamlined to improve code readability and maintainability. The command update register needs to be updated in order to acknowledge the platform notification through type 4 channel. So it can be done unconditionally. Currently it is complicated just to make use of pcc_send_data() which also executes the same updation. In order to simplify, let us just ring the doorbell directly from check_and_ack() instead of calling into pcc_send_data(). While at it, rename it into pcc_chan_check_and_ack() to maintain consistency in the driver. Signed-off-by: Sudeep Holla Acked-by: Huisong Li tested-by: Adam Young --- drivers/mailbox/pcc.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index b3d133170aac7f8acfd1999564c69b7fe4f6d582..90d6f5e24df7e796f8c29705808eb6df2806c1f2 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -117,8 +117,6 @@ struct pcc_chan_info { static struct pcc_chan_info *chan_info; static int pcc_chan_count; -static int pcc_send_data(struct mbox_chan *chan, void *data); - /* * PCC can be used with perf critical drivers such as CPPC * So it makes sense to locally cache the virtual address and @@ -288,33 +286,24 @@ static int pcc_mbox_error_check_and_clear(struct pcc_chan_info *pchan) return 0; } -static void check_and_ack(struct pcc_chan_info *pchan, struct mbox_chan *chan) +static void pcc_chan_check_and_ack(struct pcc_chan_info *pchan) { - struct acpi_pcct_ext_pcc_shared_memory pcc_hdr; + struct acpi_pcct_ext_pcc_shared_memory __iomem *pcc_hdr; if (pchan->type != ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE) return; - /* If the memory region has not been mapped, we cannot - * determine if we need to send the message, but we still - * need to set the cmd_update flag before returning. - */ - if (pchan->chan.shmem == NULL) { - pcc_chan_reg_read_modify_write(&pchan->cmd_update); - return; - } - memcpy_fromio(&pcc_hdr, pchan->chan.shmem, - sizeof(struct acpi_pcct_ext_pcc_shared_memory)); + + pcc_chan_reg_read_modify_write(&pchan->cmd_update); + + pcc_hdr = pchan->chan.shmem; + /* - * The PCC slave subspace channel needs to set the command complete bit - * after processing message. If the PCC_ACK_FLAG is set, it should also - * ring the doorbell. - * - * The PCC master subspace channel clears chan_in_use to free channel. + * The PCC slave subspace channel needs to set the command + * complete bit after processing message. If the PCC_ACK_FLAG + * is set, it should also ring the doorbell. */ - if (pcc_hdr.flags & PCC_CMD_COMPLETION_NOTIFY) - pcc_send_data(chan, NULL); - else - pcc_chan_reg_read_modify_write(&pchan->cmd_update); + if (ioread32(&pcc_hdr->flags) & PCC_CMD_COMPLETION_NOTIFY) + pcc_chan_reg_read_modify_write(&pchan->db); } /** @@ -352,7 +341,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) pchan->chan_in_use = false; mbox_chan_received_data(chan, NULL); - check_and_ack(pchan, chan); + pcc_chan_check_and_ack(pchan); return IRQ_HANDLED; } From patchwork Wed Mar 5 16:38:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003010 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4321253F2C; Wed, 5 Mar 2025 16:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192753; cv=none; b=rDwY0bfPcZCZ15atPL5Z4oNw/GNA0QDFN4W0hWZEsF6D2oZljRQoL6vBNFzL1wKN+00yYNAPtgZSty79wz4vNTswqROEUpktqa0GOYfbiBYIS0aSath6VDSPVDlnTxFlRHzcodXxpyn/aFcbMqga305JkyTiWrQ1Hn2WkTL6nuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192753; c=relaxed/simple; bh=9UGEN/buW+rB+SNY16YtJWZHD/wQwocyB/zk8N1p+qs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ihoEhxomvO8xAlBivalLBUl/GVDzCxwSNFfv2W94ukI8uPJS1lwEJn0nSkO7nWafpmVpg0vdCW+Hnx/PtXofQzwnVu6hBHrYzU+D4aJdz2Uhsdzh7V43P0Wsm7MPB5r40USaY/6Fx9qQm4lEhLB4CUQtLMJVItP9KFokV+HDRzc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DC05C1713; Wed, 5 Mar 2025 08:39:24 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 749223F5A1; Wed, 5 Mar 2025 08:39:10 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:13 +0000 Subject: [PATCH v2 09/13] soc: hisilicon: kunpeng_hccs: Simplify PCC shared memory region handling Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-9-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6401; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=9UGEN/buW+rB+SNY16YtJWZHD/wQwocyB/zk8N1p+qs=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4fbNicEXX8dRnc3g4kt0HU6ujLG7YZH+NO5 iHP5Dp9vGyJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HwAKCRAAQbq8MX7i mMvmD/9VEP0bw8XE1ng3NGmPzUvmC5SQsFexTpgL0Im6UTnjAv+E8CVXQy7LQidjVtOZjvcaPZC lXzziGS4aN0tdljrf20xY7bwQZLOO0QvMCd20pKsU6kHizYnvG52ddD7oJx9f/E8hqGXDqHViLL +Ea5MtItT3RngR1SKomUiwSshzYSZxUTQmiwdDLfvWO3zHdO+7ouM/gbwH/RRep7zkF569rv3+l Y89q+xgS3DhOqffMwHZ2Zu5Vc+omI5sNo+xiPwpyDFRoU6rk8kdN1Ezk3FkRlkHg3LcLM96paaw +Ghf4EYonEBhMmeq3Dn1HpIQz7GzM3We76bcChavlSXZv7ImQv/wVFbX7RF7KKOsCv2f9x/X3Iu 2/frQTSPJtVnZ7o8WpS35iuroZJBg71CZWazAmr90uY31UaSZQvCiFU6TgNqHGjiBTldyisJeSG 4aq16eMeYspEL2cBHmLZFquI/QRHE6IfFT1/8+2mi+7wPM7DPgCuOvgyB68WFFXCXp9ZIEV+8uF wu8sRarYx++eGKedgBWSeDcT4z0AbmIfUaYRh+oei9XaravtncXtr5CZLu1amfnp8vsn0QC0gnJ f5aD5ASUUr82HMib6UVzSgEIH8bKd+awUSM+HIPZmSN6HMRuSpSs3J/uZkcMZ4mPy5F+YMrEPB6 N3gCHIyLV4AYnAQ== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The PCC driver now handles mapping and unmapping of shared memory areas as part of pcc_mbox_{request,free}_channel(). Without these before, this Kunpeng HCCS driver did handling of those mappings like several other PCC mailbox client drivers. There were redundant operations, leading to unnecessary code. Maintaining the consistency across these driver was harder due to scattered handling of shmem. Just use the mapped shmem and remove all redundant operations from this driver. Cc: Huisong Li Reviewed-by: Huisong Li Signed-off-by: Sudeep Holla --- drivers/soc/hisilicon/kunpeng_hccs.c | 42 +++++++++++++----------------------- drivers/soc/hisilicon/kunpeng_hccs.h | 2 -- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c index 8aa8dec14911cdcdc2a2d11606bf6159144e9489..02b2e5ce40b313c8c3cf462c5c2f1d0c53f612f6 100644 --- a/drivers/soc/hisilicon/kunpeng_hccs.c +++ b/drivers/soc/hisilicon/kunpeng_hccs.c @@ -167,10 +167,6 @@ static void hccs_pcc_rx_callback(struct mbox_client *cl, void *mssg) static void hccs_unregister_pcc_channel(struct hccs_dev *hdev) { - struct hccs_mbox_client_info *cl_info = &hdev->cl_info; - - if (cl_info->pcc_comm_addr) - iounmap(cl_info->pcc_comm_addr); pcc_mbox_free_channel(hdev->cl_info.pcc_chan); } @@ -179,6 +175,7 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev) struct hccs_mbox_client_info *cl_info = &hdev->cl_info; struct mbox_client *cl = &cl_info->client; struct pcc_mbox_chan *pcc_chan; + struct mbox_chan *mbox_chan; struct device *dev = hdev->dev; int rc; @@ -196,7 +193,7 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev) goto out; } cl_info->pcc_chan = pcc_chan; - cl_info->mbox_chan = pcc_chan->mchan; + mbox_chan = pcc_chan->mchan; /* * pcc_chan->latency is just a nominal value. In reality the remote @@ -206,34 +203,24 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev) cl_info->deadline_us = HCCS_PCC_CMD_WAIT_RETRIES_NUM * pcc_chan->latency; if (!hdev->verspec_data->has_txdone_irq && - cl_info->mbox_chan->mbox->txdone_irq) { + mbox_chan->mbox->txdone_irq) { dev_err(dev, "PCC IRQ in PCCT is enabled.\n"); rc = -EINVAL; goto err_mbx_channel_free; } else if (hdev->verspec_data->has_txdone_irq && - !cl_info->mbox_chan->mbox->txdone_irq) { + !mbox_chan->mbox->txdone_irq) { dev_err(dev, "PCC IRQ in PCCT isn't supported.\n"); rc = -EINVAL; goto err_mbx_channel_free; } - if (!pcc_chan->shmem_base_addr || - pcc_chan->shmem_size != HCCS_PCC_SHARE_MEM_BYTES) { - dev_err(dev, "The base address or size (%llu) of PCC communication region is invalid.\n", - pcc_chan->shmem_size); + if (pcc_chan->shmem_size != HCCS_PCC_SHARE_MEM_BYTES) { + dev_err(dev, "Base size (%llu) of PCC communication region must be %d bytes.\n", + pcc_chan->shmem_size, HCCS_PCC_SHARE_MEM_BYTES); rc = -EINVAL; goto err_mbx_channel_free; } - cl_info->pcc_comm_addr = ioremap(pcc_chan->shmem_base_addr, - pcc_chan->shmem_size); - if (!cl_info->pcc_comm_addr) { - dev_err(dev, "Failed to ioremap PCC communication region for channel-%u.\n", - hdev->chan_id); - rc = -ENOMEM; - goto err_mbx_channel_free; - } - return 0; err_mbx_channel_free: @@ -246,7 +233,7 @@ static int hccs_wait_cmd_complete_by_poll(struct hccs_dev *hdev) { struct hccs_mbox_client_info *cl_info = &hdev->cl_info; struct acpi_pcct_shared_memory __iomem *comm_base = - cl_info->pcc_comm_addr; + cl_info->pcc_chan->shmem; u16 status; int ret; @@ -289,7 +276,7 @@ static inline void hccs_fill_pcc_shared_mem_region(struct hccs_dev *hdev, .status = 0, }; - memcpy_toio(hdev->cl_info.pcc_comm_addr, (void *)&tmp, + memcpy_toio(hdev->cl_info.pcc_chan->shmem, (void *)&tmp, sizeof(struct acpi_pcct_shared_memory)); /* Copy the message to the PCC comm space */ @@ -309,7 +296,7 @@ static inline void hccs_fill_ext_pcc_shared_mem_region(struct hccs_dev *hdev, .command = cmd, }; - memcpy_toio(hdev->cl_info.pcc_comm_addr, (void *)&tmp, + memcpy_toio(hdev->cl_info.pcc_chan->shmem, (void *)&tmp, sizeof(struct acpi_pcct_ext_pcc_shared_memory)); /* Copy the message to the PCC comm space */ @@ -321,12 +308,13 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd, { const struct hccs_verspecific_data *verspec_data = hdev->verspec_data; struct hccs_mbox_client_info *cl_info = &hdev->cl_info; + struct mbox_chan *mbox_chan = cl_info->pcc_chan->mchan; struct hccs_fw_inner_head *fw_inner_head; void __iomem *comm_space; u16 space_size; int ret; - comm_space = cl_info->pcc_comm_addr + verspec_data->shared_mem_size; + comm_space = cl_info->pcc_chan->shmem + verspec_data->shared_mem_size; space_size = HCCS_PCC_SHARE_MEM_BYTES - verspec_data->shared_mem_size; verspec_data->fill_pcc_shared_mem(hdev, cmd, desc, comm_space, space_size); @@ -334,7 +322,7 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd, reinit_completion(&cl_info->done); /* Ring doorbell */ - ret = mbox_send_message(cl_info->mbox_chan, &cmd); + ret = mbox_send_message(mbox_chan, &cmd); if (ret < 0) { dev_err(hdev->dev, "Send PCC mbox message failed, ret = %d.\n", ret); @@ -356,9 +344,9 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd, end: if (verspec_data->has_txdone_irq) - mbox_chan_txdone(cl_info->mbox_chan, ret); + mbox_chan_txdone(mbox_chan, ret); else - mbox_client_txdone(cl_info->mbox_chan, ret); + mbox_client_txdone(mbox_chan, ret); return ret; } diff --git a/drivers/soc/hisilicon/kunpeng_hccs.h b/drivers/soc/hisilicon/kunpeng_hccs.h index dc267136919b7bf3ecc0deb8cf7291267dd91789..f0a9a5618d9735e959633059192449b10d5bbf16 100644 --- a/drivers/soc/hisilicon/kunpeng_hccs.h +++ b/drivers/soc/hisilicon/kunpeng_hccs.h @@ -60,10 +60,8 @@ struct hccs_chip_info { struct hccs_mbox_client_info { struct mbox_client client; - struct mbox_chan *mbox_chan; struct pcc_mbox_chan *pcc_chan; u64 deadline_us; - void __iomem *pcc_comm_addr; struct completion done; }; From patchwork Wed Mar 5 16:38:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003011 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C82825486F; Wed, 5 Mar 2025 16:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192755; cv=none; b=R1OBmHvisQoEAOUyIQ7pS49W/qC0XZQAH17mvEf+ZP4cpiU1b241PdipNiKDDHwNMt1DY0qFYJaZ6/tr9IyGvKWB2JOb8lgvQr9Ivmmf4bRHbQkPX49KbEM+sW2OVOYwFuqvYZubigzypgjU4eHWXXFbmkulpWu3jfPbuOqaG7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192755; c=relaxed/simple; bh=MfSTY+8Javma4iMKIMRIP5AOm3S32ksYO4b7JbopmcE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZKEcN2XFyYasAm0sjVH/mqOqhPVUuXz0tNCAJtKNwFn0Q3N6gfHLbaJQ30zybx7XnTP6VwB3fy+pzkUKZFAgp0JGUeyTuIp1awk3bME0zsmoue6k48EblEUo8VNeDH0DpWBxctCBMqAORP5+lDNZZlQPeJ+Q65mPqd0vWXZi8IY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A1AC51007; Wed, 5 Mar 2025 08:39:26 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E6B5E3F5A1; Wed, 5 Mar 2025 08:39:11 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:14 +0000 Subject: [PATCH v2 10/13] i2c: xgene-slimpro: Simplify PCC shared memory region handling Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-10-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King , Andi Shyti , linux-i2c@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3735; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=MfSTY+8Javma4iMKIMRIP5AOm3S32ksYO4b7JbopmcE=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4fuQ/p52TMxH4kREmbxc+kI+v0j0xs9/n7J 5SYxHwMSY+JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HwAKCRAAQbq8MX7i mEP2D/9cWzppq3ezDm0HK2NUFbba9LDVfpaeSSrXX3TJS9Ap4RFjYJp5LzBRGDHPRRP/lemSb7h szcfRa62vnzQ5GIewqbwjQ56SF7FevbCdRwlM72Uzji85XjFSaO/SxKUuhyL9ykO2CV1MZ4Mj7T WEkdR/uTqugGKZYc3HU6zQqrkLp+R5GTleH1uUZ/9wXa0XKzYUx1fi/IOXet6oKhGZFtdpjb51Q iLbNfMQHQJRr6P4ylIxqfoga2hkeAUN1+8qcznMYo5DYqJiBLKifBhXXegx6r9b9y/lmzB5geL7 slxVB80clkZD0m8sQ4PMXOmpHTE4bdy+Th0apQw54sIt2IZpXQo9qX8BJ9mLrMTZnAyDbhyw9FD TFHj9mIGIIRzVw0fkY8TGJfYDE0Pb0m1N/TBJyLeW7wXjKZp12YJ3aGl7KC063+NQ5eQXIrtevs l03USS6us51zDUA+Q+xwQ8mmofRtKFvs5iAWVLuhKiLr9utT2w0W1RAgDw4+dWCItt7+kHmpTX2 oCRiV9NTMUqT+6BZ/n7ln2ajXNdq3mj1lvjt34OJNR6G5TplSC+P6IZI9WyqW8K56x/Uf9evuND 8yv+T4JH9/pRBnjsGeft+4iq5dT4xNiXv+vpxaQlTf+BmKMkyc0b1pnGc+zuP1YBlR8ZP+na09s zXz3oGWOahB9T7w== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The PCC driver now handles mapping and unmapping of shared memory areas as part of pcc_mbox_{request,free}_channel(). Without these before, this xgene-slimpro I2C driver did handling of those mappings like several other PCC mailbox client drivers. There were redundant operations, leading to unnecessary code. Maintaining the consistency across these driver was harder due to scattered handling of shmem. Just use the mapped shmem and remove all redundant operations from this driver. Cc: Andi Shyti Cc: linux-i2c@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/i2c/busses/i2c-xgene-slimpro.c | 39 ++++------------------------------ 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c b/drivers/i2c/busses/i2c-xgene-slimpro.c index 663fe5604dd64b80e57f906e1f7430dcf6d5e95b..a0880f4a056d2b8abbac9f58416215a7fc9b130e 100644 --- a/drivers/i2c/busses/i2c-xgene-slimpro.c +++ b/drivers/i2c/busses/i2c-xgene-slimpro.c @@ -101,8 +101,6 @@ struct slimpro_i2c_dev { struct completion rd_complete; u8 dma_buffer[I2C_SMBUS_BLOCK_MAX + 1]; /* dma_buffer[0] is used for length */ u32 *resp_msg; - phys_addr_t comm_base_addr; - void *pcc_comm_addr; }; #define to_slimpro_i2c_dev(cl) \ @@ -148,7 +146,8 @@ static void slimpro_i2c_rx_cb(struct mbox_client *cl, void *mssg) static void slimpro_i2c_pcc_rx_cb(struct mbox_client *cl, void *msg) { struct slimpro_i2c_dev *ctx = to_slimpro_i2c_dev(cl); - struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr; + struct acpi_pcct_shared_memory __iomem *generic_comm_base = + ctx->pcc_chan->shmem; /* Check if platform sends interrupt */ if (!xgene_word_tst_and_clr(&generic_comm_base->status, @@ -169,7 +168,8 @@ static void slimpro_i2c_pcc_rx_cb(struct mbox_client *cl, void *msg) static void slimpro_i2c_pcc_tx_prepare(struct slimpro_i2c_dev *ctx, u32 *msg) { - struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr; + struct acpi_pcct_shared_memory __iomem *generic_comm_base = + ctx->pcc_chan->shmem; u32 *ptr = (void *)(generic_comm_base + 1); u16 status; int i; @@ -464,15 +464,12 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) } else { struct pcc_mbox_chan *pcc_chan; const struct acpi_device_id *acpi_id; - int version = XGENE_SLIMPRO_I2C_V1; acpi_id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); if (!acpi_id) return -EINVAL; - version = (int)acpi_id->driver_data; - if (device_property_read_u32(&pdev->dev, "pcc-channel", &ctx->mbox_idx)) ctx->mbox_idx = MAILBOX_I2C_INDEX; @@ -494,34 +491,6 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) goto mbox_err; } - /* - * This is the shared communication region - * for the OS and Platform to communicate over. - */ - ctx->comm_base_addr = pcc_chan->shmem_base_addr; - if (ctx->comm_base_addr) { - if (version == XGENE_SLIMPRO_I2C_V2) - ctx->pcc_comm_addr = memremap( - ctx->comm_base_addr, - pcc_chan->shmem_size, - MEMREMAP_WT); - else - ctx->pcc_comm_addr = memremap( - ctx->comm_base_addr, - pcc_chan->shmem_size, - MEMREMAP_WB); - } else { - dev_err(&pdev->dev, "Failed to get PCC comm region\n"); - rc = -ENOENT; - goto mbox_err; - } - - if (!ctx->pcc_comm_addr) { - dev_err(&pdev->dev, - "Failed to ioremap PCC comm region\n"); - rc = -ENOMEM; - goto mbox_err; - } } rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (rc) From patchwork Wed Mar 5 16:38:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003013 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D07425486F; Wed, 5 Mar 2025 16:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192759; cv=none; b=cHNqTv4we8pewKV03ixPNoLZMcQkPXfzWGBZ+NzX26qu29i7/o7Fe3ZyHTSyc28i/RC/z5lZBDfBpKPdnJ/qMabMuLwtuDbdVXRk2Na3hZ82fuU0A+PXUGCwWmq/tQCNuP13zWXALlYYOjXGCwlcrpmvq0+Jely3rkY/NhoZ6FU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192759; c=relaxed/simple; bh=VmwKuVvkYDG4YPm05QVYADtfrrgD8ss+7erDgcmSENk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f/z9YTD276YgqZYC9sSWX/Hpj9SXEiy9b6T8GF3o+aAoo85UmWjmAvVGhYvWZ85snSL/g4bE4cnM9bUuAXvtbPnaafBcT1RPViizwQn8OBC431ynTuuqe/osWEt7OjfsX5awBqTZX/sOM0Qfn2yLtE8XGEjuY3+UpYlfRJ38r9k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8B41F1713; Wed, 5 Mar 2025 08:39:28 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AC4D73F5A1; Wed, 5 Mar 2025 08:39:13 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:15 +0000 Subject: [PATCH v2 11/13] hwmon: (xgene-hwmon) Simplify PCC shared memory region handling Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-11-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3724; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=VmwKuVvkYDG4YPm05QVYADtfrrgD8ss+7erDgcmSENk=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4f1iOFe9jqRV3Bif+vaT+vxFyCxxBIBGGaM nOsG+DgzVKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HwAKCRAAQbq8MX7i mNTsD/0d19dmGO7lpCYSMLtxq1MAL7ZH3HvLtIuYVhTx3IwLIQI73MtgAliPWi3tOnoEaK0KzKK alOGT0IzCh5y2yjcLUJ5xhI6nbwvVbaziOfwL6akDNvlIhHeSOOc9eNFct3tD6ZgxOqcRIg+EYh eLE8lhUkd7+YtrY1Mhmnz2/TAhVsCupzCDjBmeSuNFBVgAHxuk7HznVHp8Ok6sKIe9V8siNFsqt wiKus4CBsI/hu7NA3NQBiU4H3gQYLeq76Tj/SBRrrzE8kFI92E0XQJ1uB1GPb3mo8nX5Z0CgGN+ 826fdsFQdFIQaoyPqYbRwrnWo7fylrUoHlwVOPqjV/dwp5CMUYHdNl6eviz1HxBsveKT6S4r5Wq B8h6IHBEtuxfrBmIjVk/WAVDVYm+S3ZAF6DZ5rFnY9IlbtrL2c8QiBOlS+1YRwzgsuSXvbeCnx/ hNyEVuthL7TnSGSxxSrxVxobj6Z3GJrKOzvNr9YRBjXU8adIgJ6Cf+S1/RDZhc5JXks5gKPaCku +JXXp4UciIecmZlDqA/e2u3SLLDG6P0whMlV/9kFAjtxPqOYVNBYgE6BKku/gGdfjDcQ9iNU8PE RXlKJwPFI59FgYyG4/NR5O4bobmYdSRqI131Ydwvt0jme3694e7iphq6PZmxQpUq1O3UuEwGW+Q SCC2W0vxMQOJxpQ== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The PCC driver now handles mapping and unmapping of shared memory areas as part of pcc_mbox_{request,free}_channel(). Without these before, this xgene hwmon driver did handling of those mappings like several other PCC mailbox client drivers. There were redundant operations, leading to unnecessary code. Maintaining the consistency across these driver was harder due to scattered handling of shmem. Just use the mapped shmem and remove all redundant operations from this driver. Cc: Jean Delvare Cc: Guenter Roeck Cc: linux-hwmon@vger.kernel.org Acked-by: Guenter Roeck Signed-off-by: Sudeep Holla --- drivers/hwmon/xgene-hwmon.c | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c index 1e3bd129a922d25ff25142d864503377773304a8..ea350d4de902c4e6fc4de1cd54a8b75edfad1119 100644 --- a/drivers/hwmon/xgene-hwmon.c +++ b/drivers/hwmon/xgene-hwmon.c @@ -102,9 +102,6 @@ struct xgene_hwmon_dev { struct device *hwmon_dev; bool temp_critical_alarm; - - phys_addr_t comm_base_addr; - void *pcc_comm_addr; u64 usecs_lat; }; @@ -125,7 +122,8 @@ static u16 xgene_word_tst_and_clr(u16 *addr, u16 mask) static int xgene_hwmon_pcc_rd(struct xgene_hwmon_dev *ctx, u32 *msg) { - struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr; + struct acpi_pcct_shared_memory __iomem *generic_comm_base = + ctx->pcc_chan->shmem; u32 *ptr = (void *)(generic_comm_base + 1); int rc, i; u16 val; @@ -523,7 +521,8 @@ static void xgene_hwmon_rx_cb(struct mbox_client *cl, void *msg) static void xgene_hwmon_pcc_rx_cb(struct mbox_client *cl, void *msg) { struct xgene_hwmon_dev *ctx = to_xgene_hwmon_dev(cl); - struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr; + struct acpi_pcct_shared_memory __iomem *generic_comm_base = + ctx->pcc_chan->shmem; struct slimpro_resp_msg amsg; /* @@ -649,7 +648,6 @@ static int xgene_hwmon_probe(struct platform_device *pdev) } else { struct pcc_mbox_chan *pcc_chan; const struct acpi_device_id *acpi_id; - int version; acpi_id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); @@ -658,8 +656,6 @@ static int xgene_hwmon_probe(struct platform_device *pdev) goto out_mbox_free; } - version = (int)acpi_id->driver_data; - if (device_property_read_u32(&pdev->dev, "pcc-channel", &ctx->mbox_idx)) { dev_err(&pdev->dev, "no pcc-channel property\n"); @@ -685,34 +681,6 @@ static int xgene_hwmon_probe(struct platform_device *pdev) goto out; } - /* - * This is the shared communication region - * for the OS and Platform to communicate over. - */ - ctx->comm_base_addr = pcc_chan->shmem_base_addr; - if (ctx->comm_base_addr) { - if (version == XGENE_HWMON_V2) - ctx->pcc_comm_addr = (void __force *)devm_ioremap(&pdev->dev, - ctx->comm_base_addr, - pcc_chan->shmem_size); - else - ctx->pcc_comm_addr = devm_memremap(&pdev->dev, - ctx->comm_base_addr, - pcc_chan->shmem_size, - MEMREMAP_WB); - } else { - dev_err(&pdev->dev, "Failed to get PCC comm region\n"); - rc = -ENODEV; - goto out; - } - - if (!ctx->pcc_comm_addr) { - dev_err(&pdev->dev, - "Failed to ioremap PCC comm region\n"); - rc = -ENOMEM; - goto out; - } - /* * pcc_chan->latency is just a Nominal value. In reality * the remote processor could be much slower to reply. From patchwork Wed Mar 5 16:38:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003012 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D00B24F5A6; Wed, 5 Mar 2025 16:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192759; cv=none; b=XHiz0TqYVu/FJIM4FEEyMoJmaM4wHbLlQgPqPuzjoA4s5nJC73TMzuKLDv0QjBILc2xZYqRj8oNEFE79kwOIMYd9PlaQRzc25i6TK4Quo+gEJzfV3rVu8qfj31pXzz5NB0NxZ8i9j+XB0SuBLWbXz3OPRP/2nriWrHu86pwXcSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192759; c=relaxed/simple; bh=tFkBXBO/atiCQgL+I5PaOZGXAVe1jBN5O3xNDo6yR1U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ByJPRs8PGFWtWq6eXh0uK571ANsnlRq40UHOho/5p1tTJ5kHv1IkYrqDH5JH/BNl4ByH3LL1XFJ0L5hOPFOge5bJlLh4AFA/NDbz3sVhSbpB0Oe73l3OT8y9Gpe+1EqgVOthDGJV47JYggtw1XHqtLeyEN4rSoz0MevuZFr+auc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D00E1007; Wed, 5 Mar 2025 08:39:30 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 95BC23F5A1; Wed, 5 Mar 2025 08:39:15 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:16 +0000 Subject: [PATCH v2 12/13] ACPI: PCC: Simplify PCC shared memory region handling Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-12-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King , "Rafael J. Wysocki" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2287; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=tFkBXBO/atiCQgL+I5PaOZGXAVe1jBN5O3xNDo6yR1U=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4fBs6KUn9ck2ci3zzCHWjTUV5jpju76ILak Mj7PGqwh6OJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+HwAKCRAAQbq8MX7i mGH2EACASilhQ00UNq1paOOrLBKFTnZALt72kTxJlFX/+vRI4ihGJsufAbyKpAB3bdUMfhlhUhq rOwTvRomIYPPAU+ysqHN2KeH5EZpKkr2k2Bk2u1iz7Ic8hhY7cn2B+WzHXkvEpeAZiEy2MPsmJr 1yp58cNVXxldEYc7MHbgBY1ztBDkkrdQs1mwCYD0JTYMxSvWgp11Om6CcdeOedqpBfdVBDxP1yJ uTrB6spoy1CXDvwiE8nTWeDkegyX2ifHzDsM10F+Eg2GDvBfvjBTb5DMJgfir0vXKoLaI/bhQWA YiQBAYOlnVepdmnYSxPG7Z4Z1FyNvei0mRxfruf6EScKbJzDet3NjuVz7GkxtYxYhqpgwAXjgOA 4OjISuYixUN/8ikNKw7UP9EsETVUIAFHAEcoiz4tQ1PynusQo1QaHyAHNtQXZidc+YRSSi7dJZJ s8RLG3eHfAF5NS54xvpZvwCLJt9mgCluoRCDuEqzIsFacfAj3n4pse13vfWdcl3ZtPxjjqDiFzB Y9NJ5oOZ6boSgOV9qAdtAY7rZeFqJ8Dbq4PfJzkOH34qhg4GAsyPzDpxxWpmXN2U/JhE496DQcr YgBxMmo40FRtQ3QB2E71v0BDnlc0Hajo1LDdXSecO1HNmV9spgnlaCODFHSAeqmN8qt+HXxKi5O F+nTyEf6UDZZUYg== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The PCC driver now handles mapping and unmapping of shared memory areas as part of pcc_mbox_{request,free}_channel(). Without these before, this ACPI PCC opregion driver did handling of those mappings like several other PCC mailbox client drivers. There were redundant operations, leading to unnecessary code. Maintaining the consistency across these driver was harder due to scattered handling of shmem. Just use the mapped shmem and remove all redundant operations from this driver. Cc: "Rafael J. Wysocki" Signed-off-by: Sudeep Holla --- drivers/acpi/acpi_pcc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/acpi_pcc.c b/drivers/acpi/acpi_pcc.c index 07a034a53acac1e8307265bcc5572054d34d971f..97064e943768ad9f1704effa13dddbc0876a9452 100644 --- a/drivers/acpi/acpi_pcc.c +++ b/drivers/acpi/acpi_pcc.c @@ -31,7 +31,6 @@ struct pcc_data { struct pcc_mbox_chan *pcc_chan; - void __iomem *pcc_comm_addr; struct completion done; struct mbox_client cl; struct acpi_pcc_info ctx; @@ -81,14 +80,6 @@ acpi_pcc_address_space_setup(acpi_handle region_handle, u32 function, ret = AE_SUPPORT; goto err_free_channel; } - data->pcc_comm_addr = acpi_os_ioremap(pcc_chan->shmem_base_addr, - pcc_chan->shmem_size); - if (!data->pcc_comm_addr) { - pr_err("Failed to ioremap PCC comm region mem for %d\n", - ctx->subspace_id); - ret = AE_NO_MEMORY; - goto err_free_channel; - } *region_context = data; return AE_OK; @@ -113,7 +104,7 @@ acpi_pcc_address_space_handler(u32 function, acpi_physical_address addr, reinit_completion(&data->done); /* Write to Shared Memory */ - memcpy_toio(data->pcc_comm_addr, (void *)value, data->ctx.length); + memcpy_toio(data->pcc_chan->shmem, (void *)value, data->ctx.length); ret = mbox_send_message(data->pcc_chan->mchan, NULL); if (ret < 0) @@ -134,7 +125,7 @@ acpi_pcc_address_space_handler(u32 function, acpi_physical_address addr, mbox_chan_txdone(data->pcc_chan->mchan, ret); - memcpy_fromio(value, data->pcc_comm_addr, data->ctx.length); + memcpy_fromio(value, data->pcc_chan->shmem, data->ctx.length); return AE_OK; } From patchwork Wed Mar 5 16:38:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 14003014 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CF4024FBFF; Wed, 5 Mar 2025 16:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192760; cv=none; b=Ru1ngJe7pSIKeD66TAuYnhq2TX2emBxlUPjlflFBVfiF0FQHY805C7WAkIsmHRCUZojN7/V/rkBBV3Sf7PqEwcUbg4w5kL0sjD73bJJco582jN8vyKOuEOw628UmHc+9FGvobzYmgW9S2IPvJgufJh6Dbwyltt9s+UC8FRDvShg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741192760; c=relaxed/simple; bh=aXg6RgwqMQoYUSR7L+4RvyibSNxPKGi4o12ZLke9smI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U5ZSm/M5zjd486O1rAcrLvuaydVEgKJB4EdDnm5A6K1216B15s39nQpLZC0QCtLUwnaMKXIxqZmRci0C/LShTGCN6e4M3DX9UTdLcXr6G7alXc/WwoY8bcxPjX/uROvGTkvR3uExqJ7a4+jyXqJFd8zdk3TLSW8q/WcTKhsr6QA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C2C351FC7; Wed, 5 Mar 2025 08:39:31 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 378763F5A1; Wed, 5 Mar 2025 08:39:17 -0800 (PST) From: Sudeep Holla Date: Wed, 05 Mar 2025 16:38:17 +0000 Subject: [PATCH v2 13/13] ACPI: CPPC: Simplify PCC shared memory region handling Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250305-pcc_fixes_updates-v2-13-1b1822bc8746@arm.com> References: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> In-Reply-To: <20250305-pcc_fixes_updates-v2-0-1b1822bc8746@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Robbie King , "Rafael J. Wysocki" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2920; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=aXg6RgwqMQoYUSR7L+4RvyibSNxPKGi4o12ZLke9smI=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnyH4gPx1dHylhzc+hzQAl1gZ4CiNIGIFYDC34D XwznlJ9Li2JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8h+IAAKCRAAQbq8MX7i mG8TD/9zfSb/B6KYlL7LRhNtJq+s3Ce5HgOBWOAO2dtKICkKodsRhwn35yzxng0UKCRVDVaJWI1 aWPKGpieOyK7UbsKeU0KtSDvLFEFRfFABybfp//g1pp8OA0Fx9Eju/BPGPSoq00auoKqQABU4P3 ejWFhD6+w1xzFIevXftMUWJFWx8aa4ow0+UkTm3Wrk4Ic0L+JQjQnmyPzn8dk9RUB+RXDifUNYd WTtQ9i9jq6dCm2sSjRduHqMsQvk0oWYc9nbXU5kVDew5PAVkhMidupu+FpYUOYMJ5NfNPozkN1+ nS8NLnBmy7qDH3b2wk2THWLttThfHDIRyXeAkWXc4rFp1mVIQAGvjU3uXH4Ix1Bw9/yco+Ao/bW lh/8jTKdqygp5SLmBMdNS3dwaIWhPjR8TBjKmprkPhfbcGzlX/dogjmd/CLhPjwbQ2K4ufJdVUO C/zyelFN2yUOv8l+B6iYFcJhF/mVfo7QDggxIt8jXVRm+eAEmvGMsjOoAXoaswf4uUSImFe76fk NLiK41ensv0XCR60TbaAQ8lMzcWdGv/DH7hdaFKttC1a/bZhApiCAGPFVZqwv8TT6ESbB4jByGn y7HxEdLak5Tr7zDirfUHIUoQMBZw00LccyvQAbndViIyBvSmwR1GEBsQXamK0+5tg2yYY/Y6EC9 1QKE0hcrxDwFzQA== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 The PCC driver now handles mapping and unmapping of shared memory areas as part of pcc_mbox_{request,free}_channel(). Without these before, this ACPI CPPC driver did handling of those mappings like several other PCC mailbox client drivers. There were redundant operations, leading to unnecessary code. Maintaining the consistency across these driver was harder due to scattered handling of shmem. Just use the mapped shmem and remove all redundant operations from this driver. Cc: Rafael J. Wysocki Acked-by: Rafael J. Wysocki Signed-off-by: Sudeep Holla --- drivers/acpi/cppc_acpi.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index f193e713825ac24203ece5f94d6cf99dd4724ce4..d972157a79b6ade2f3738c90128e8692141b3ee5 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -47,7 +47,6 @@ struct cppc_pcc_data { struct pcc_mbox_chan *pcc_channel; - void __iomem *pcc_comm_addr; bool pcc_channel_acquired; unsigned int deadline_us; unsigned int pcc_mpar, pcc_mrtt, pcc_nominal; @@ -95,7 +94,7 @@ static DEFINE_PER_CPU(int, cpu_pcc_subspace_idx); static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr); /* pcc mapped address + header size + offset within PCC subspace */ -#define GET_PCC_VADDR(offs, pcc_ss_id) (pcc_data[pcc_ss_id]->pcc_comm_addr + \ +#define GET_PCC_VADDR(offs, pcc_ss_id) (pcc_data[pcc_ss_id]->pcc_channel->shmem + \ 0x8 + (offs)) /* Check if a CPC register is in PCC */ @@ -223,7 +222,7 @@ static int check_pcc_chan(int pcc_ss_id, bool chk_err_bit) int ret, status; struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id]; struct acpi_pcct_shared_memory __iomem *generic_comm_base = - pcc_ss_data->pcc_comm_addr; + pcc_ss_data->pcc_channel->shmem; if (!pcc_ss_data->platform_owns_pcc) return 0; @@ -258,7 +257,7 @@ static int send_pcc_cmd(int pcc_ss_id, u16 cmd) int ret = -EIO, i; struct cppc_pcc_data *pcc_ss_data = pcc_data[pcc_ss_id]; struct acpi_pcct_shared_memory __iomem *generic_comm_base = - pcc_ss_data->pcc_comm_addr; + pcc_ss_data->pcc_channel->shmem; unsigned int time_delta; /* @@ -571,15 +570,6 @@ static int register_pcc_channel(int pcc_ss_idx) pcc_data[pcc_ss_idx]->pcc_mpar = pcc_chan->max_access_rate; pcc_data[pcc_ss_idx]->pcc_nominal = pcc_chan->latency; - pcc_data[pcc_ss_idx]->pcc_comm_addr = - acpi_os_ioremap(pcc_chan->shmem_base_addr, - pcc_chan->shmem_size); - if (!pcc_data[pcc_ss_idx]->pcc_comm_addr) { - pr_err("Failed to ioremap PCC comm region mem for %d\n", - pcc_ss_idx); - return -ENOMEM; - } - /* Set flag so that we don't come here for each CPU. */ pcc_data[pcc_ss_idx]->pcc_channel_acquired = true; }