From patchwork Mon Mar 3 10:51:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 869854 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B0F21F17E5; Mon, 3 Mar 2025 10:53:26 +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=1740999208; cv=none; b=HUiJFEMDuPHahmqg3a8rEEIwQm78sWFHRPpOO7AaE66G1U84rWl9Zhmi5D+TlDkQa8NZoYHBV2e4J693f920ju5/YpUvROG+TIooe6lPkEbFc9FVxdj+wyGetmvvDSzz9li3epHHgdfeRR6kONyhWDzSc6VrQ+q0I47wg+ntyU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999208; c=relaxed/simple; bh=g9voXRH9b5scUtRJQUT9IkYk1Q1woAlbAN5ZVwPOsw0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lVbb4pRTYdVQk2h0cf8LK3AyuA4Zt4UjCRrPQYjtPU2yIqyQeQRw0e5wtQIJAPqs0SaqJtftbXDOvDY3mZft0R9qwA0G2+3WT0LR1SPpifHj/s4QnYqAMKlPytpk+0p3KJRHBgWjR242tq7/P0nYTYSRt7hqmtQNE88nT+OG14Q= 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 5AE5712FC; Mon, 3 Mar 2025 02:53:40 -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 3EAAE3F673; Mon, 3 Mar 2025 02:53:25 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:36 +0000 Subject: [PATCH 01/14] 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: <20250303-pcc_fixes_updates-v1-1-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young 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/ZANAwAIAQBBurwxfuKYAcsmYgBnxYohU2Ovtmr4qvaGn/sgdbGVNgixC3C3wyS5+ sJABEakylCJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIQAKCRAAQbq8MX7i mCSvEAC0jkjX+3Pbc642V3BITLszz4Xj/lsxjE5pyY+biE7BNcQ+yBxWT6R+fFxQbNas1oXn5M2 m+7c5iWayb+5jX1Yg2VNccrheMh2vWg2gHZ4az1yEcBlS5jKzA+qpr/n1hkzgr9CDiTC4hj3keF swXlvbX4zpGvLllzGtaEm70e5LJbP2mcxTGAUFEl9XGNiV0dW9N56WAFx2WmF2wAcdprrPghamP UcKk6M6/OGIk7OYNC7hPQgZL8saJCbXCq+ixgt5QsfuAw8htPDPQ5J3d64Ow4j4UzikxAjoxWoe SbdNkgSzirtS+0R/xEcyb0mRfwtSIO9jyrlda1RmgeQ3MbIiL9pRVxjx/v9rzhUX/uQMeJbwONF Wj0P6IqZs4K16fARRmTOqHxiHumt+j2aMdgNWysfMHybHjUKk+4chmLFe3Hob2G44hqMt384LIl KDWdsVoDEm58GOrlQc7CkLb8uS1Xy+Q9peY8l1CIaOC3Ouc9LdtOIjs0aO4V84dUMG50VCr13zQ NWsrhz2mKgsrOEs6TrKYPcs0ahPO2yGjRvuxKgxMSxzOSV/K3S2kFZLinaexKk81jLDFEHgduyY 58+i4VRcqcm+0QOTuuKj7pj0IB7yXlYFFY0oWK5IVp+6XcSK+QSqCeSQV3tXABBtmEPDgL3o8i7 jdesBPic4vi6pbg== 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 --- 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 Mon Mar 3 10:51:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 870170 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 874B91F37C3; Mon, 3 Mar 2025 10:53:28 +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=1740999210; cv=none; b=Gd6M8mEkMe78rr51JFmg0YLP773KvBhDnErhsW5tM5FFA3XAVjur2r2cqZBalzx/T3hIXEFhMLgACGxFuUIC34Byln7IV+m7z7myRvPGYui8tupXN7Ta536SzFqvCakdcqlgiKUaVVZZn1xAts+o22vaa/FAeW+b1ZeMHch9LJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999210; c=relaxed/simple; bh=ya1Jrm60aOw5PBdsWiepbv15t4GIYWfri5Jp+tE1yVE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UJtAlIcXgCqayj4jWi1zlplWKwcMsVd5bwlyONajEg5Vz87BaL8GMg3CC+GjziX0dfKHslMVKI7y7iMyQadZuISPe1qdl/woPLrXDRvFXqbDQr4s6h9SutSiC9fqmkt9X30BKpULK0vOX10srv4VUGa5DkYW+cXwGBMa4Ra5RW0= 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 CC83B1FCD; Mon, 3 Mar 2025 02:53:41 -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 8CB103F673; Mon, 3 Mar 2025 02:53:26 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:37 +0000 Subject: [PATCH 02/14] 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: <20250303-pcc_fixes_updates-v1-2-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@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=3887; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=ya1Jrm60aOw5PBdsWiepbv15t4GIYWfri5Jp+tE1yVE=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYohPuaxjsJrjuOasFqvT0SAC+ARa0woaE+BG a4mOM2fsSyJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIQAKCRAAQbq8MX7i mNaJD/wJbb2JBJ0hwZzY9nejOrjiXz2YuNZ/CKbx5JlK20WUwgaNVKxawpc90uGXtkIDfBdiXRB MzALhafutliezmH+l+OATG6g4HCCKGK1nUXWFkE6jOYTTLiwDDL8nOcB4iDXk48DFavpm/LbcPP rL5xw7wIQ+2XqNC5RKr0sj2kcwMn3gCS8CsI1lYXFUpFUxJkRXDNqv1VBjemyPSWGjFqfnx30od Iiob+ui1z2pLfUtES9Kbs1mOBw1oe0Xf6RK250RT9XIeBi+H53N7QzSOuUpuPa7NxCanThdrphC TsTC/V73nbhRkY/2Q15xo4462fj56BnsLOexbpP0uDafX2rM3hIBb6hUShWNC3e9yGmV0JTiDQT K4lRI6J8yaXUAfiiE+BW97I7plht5loUhzNan/3ie2jkQOwsbDLgmApCtBWEatLoZhd9pmPwC48 zwyWFQRsCvmRkSnNgDeWGA6kmte1EFWO3NysGkDUN8zevUt0ws6dqfg5Mg7FGV05hhowetZhIn0 ZMc+Ika9t0Tbr4inLFL6XmLTwZvniQT1kQYeCUFZYzweqnzO4ROpeRcPD4wDMzL27Y+XgbT0++o P+xW5V4o7Uic1P0TW/oQgLAmU3qjGHkuIUCV4y0DlscLzYD9jV8qAr2aOCU59KP1UWX0WNYOSj7 OGl3VUotqBe51sw== 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. Platform Firmware OSPM/Linux PCC driver ------------------------------------------------------------------------ build message in shmem ring type3 channel doorbell receives the doorbell interrupt process the message from OSPM build response for the message ring the platform ack interrupt to OSPM ---> build notification in type4 channel start processing in pcc_mbox_irq() enter pcc handler for type4 chan command complete cleared read the notification <--- clear platform ack irq * no effect from above as platform ack irq * * not yet triggered on this channel * ring the platform ack irq on type4 channel ---> leave pcc handler for type4 chan enter pcc handler for type3 chan command complete set read the response <--- clear platform ack irq leave pcc handler for type3 chan leave pcc_mbox_irq() handler start processing in pcc_mbox_irq() enter pcc handler for type4 chan leave pcc handler for type4 chan enter pcc handler for type3 chan leave pcc handler for type3 chan 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 Signed-off-by: Sudeep Holla Reviewed-by: Huisong Li --- 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 Mon Mar 3 10:51:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 869853 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD1EE1F4171; Mon, 3 Mar 2025 10:53:29 +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=1740999211; cv=none; b=JtyUrvuOSn2y1jwCuZDVGLeMchvB75nCV6rmP3ko/0vlbMzYIcc3dB0Ga1ohAZo72RlYVBPTR5nN2lPGL34zar4mNj1TnNNpS+e6D3yJsfYNqN9iJwRKl6xcm6lzioGo+3Qpfrw+XZruwN/F7NFTJxuAw5x5CrvFtKNHDBlrSe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999211; c=relaxed/simple; bh=200nn/4JF4ubELss3QLL7p1PASyuP4e2PWPIQkroDkE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Oylh+Zs1xJ6BRP5NozjqgBYjSks6IjeQ5q3BnERTy0bGbs1QutYNQPAlDoB0utAm3HdAWIbms19XMKPqIxgV2/vb3fLRjbSLBahXXjLrBU43yN8R5WgjQbBEa6/jdce6FpjDOLUB9q6Kw/Tay8NmLGgJi4tImYLr5sOQmtLSTco= 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 264082008; Mon, 3 Mar 2025 02:53:43 -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 0A3FA3F673; Mon, 3 Mar 2025 02:53:27 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:38 +0000 Subject: [PATCH 03/14] 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: <20250303-pcc_fixes_updates-v1-3-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1458; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=200nn/4JF4ubELss3QLL7p1PASyuP4e2PWPIQkroDkE=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYohZmJ3X0WGWizJXAMHN4xUhfGZueR0Z07Dj q7KIRpPjESJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIQAKCRAAQbq8MX7i mJStD/4xFv05gSx16Q02HplCWvd9xj+wDUj8h5sm5XDXHkL47PmV6wfQGqVrrPdvQUbKgPFAT3u xQUmYrtSHKyjkh+cXL2545LmxLm6HUw4qVa+wMWMaIL2YWY5qZeIq3DabKRwTQkL1f0AtHSuLH8 gD0vMKUkAAUdfyA/XtHTxkVfLJv9YIOwAFDh+yYLLPzWc2I0rdfay8w53362zAlYG3j6CYP6Bso g/L1ggHB33nm16pUpsNH/NFxZci1p6wtnhmTcPd/gimQqtTHlmcf/qmCP8p+6NC/qnkwkXLy+Vk du3mM5JUTuaD/WCxK334tmlxr8zY3Umm9jHPzgnqyRyQ1AiFA6zYQqq8gljiMrkhKcFV8EWae+u tbUv6BCvm/fMOCtZUXuG7M22/hzfjLlt7w+ge+lV9u8Awhzo4sWE90SlS1O7IitmKbns4C9fJk5 iFjNmH4WdCFsTrBXsSUcvEwBFdfV8el4kamxeE/cB1ASzqqERqYlBNDbsiuJ/6UrRuniHLR1cWg oyOQSEtxRAEUVdbkGHuf8hS09nkXl5txSgkQ8BwSRusNbOb0GizkTy87xjyxz+7Opg/PPIn2Wtm NFJxScB3+X1PLuYMiPuHNPQz3Gl/5+Agn/8D/oOnTyHZ3/3B58gj6uMCb2braCN+YqaCvHn5+g5 gueITME3C6hscpA== 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. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 4c582fa2b8bf4c9a9368dba8220f567555dba963..c87a5b7fa6eaf7bcabe0d55f844961c499376938 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_ACK_FLAG_MASK) pcc_send_data(chan, NULL); else pcc_chan_reg_read_modify_write(&pchan->cmd_update); From patchwork Mon Mar 3 10:51:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 870169 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED3E61F4612; Mon, 3 Mar 2025 10:53:30 +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=1740999212; cv=none; b=BAx7WJS2zpaiJ+eqviDU00xls/mXGbYJBdIr/lbBLTNvCPaUljjLCfhwdwRq3g+OKOIBcLl5yJHIXhEF5CDqaGJxUv/b8naCykDR2tyAQWT++bCN36Pi103WHfgfHji6vd7fChsXcK04+CjuD5+lmkfTj7sXLGNRLGrpyTLOQJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999212; c=relaxed/simple; bh=O8K+rZOv1/Prumcjvh4fIrLAL9Wzi6vTqYxlPROPsC8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JIWBL2sdqhR6cNKz2f8k5artyDjCHOr58P1ZWzyLFWPY12z3TRghgRkM0glgChzRQBeMV/v8yD9euXj96JeL7MW2/bTcQiIT2W/c14WZgCehKd9TfFJZCMKKHtNYe9f1/JtT/I880dippXuO4Bh6WrCyB6djgWaUGUxV1Prn4vs= 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 73C2F201B; Mon, 3 Mar 2025 02:53:44 -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 57F153F673; Mon, 3 Mar 2025 02:53:29 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:39 +0000 Subject: [PATCH 04/14] 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: <20250303-pcc_fixes_updates-v1-4-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1095; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=O8K+rZOv1/Prumcjvh4fIrLAL9Wzi6vTqYxlPROPsC8=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYohO+Y6RtnbnszCpmHOp8UFVnodS2rsHRvYM HTmA3B9HtWJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIQAKCRAAQbq8MX7i mHIvD/4vfequNLXQsT0Ebinanwzr8OlF/wCGk2cGB1OiydeQsGkbOBvPoCfxpEZhH6b7LG4WUIT yFEOMkEKFjns9ebcm+uFinsMnY88q4HibgxCxEGhaUN1jNMrvSvXjAzPp00wPQySLghHdlAQ/Iz 3L1gizJt+y71i/tDp5rW8iB+lxExyu4hylHyzkX3i6lk+J9mHJVnSVrYcArcZHzNC9KUm1Jbheq Bu7vi1YIy75IT9X+3qAKtUTx6Lo0BL71Lfw9UOP14cEu3LiP+n4K/UXG37W23YcB3s+JeV43kJG Sd5QvxVWwHkh6ClRdwnzsz8qbRnAF3lEEtRdNdsZndmoPAJwVqlnHeYdy+kndtlsUvK6+6honR4 CTdqauqTowjYp5wxwYz6/7qgWreL5yU2zwgNmRgam/sWJn4aXrbM96nsAQwn4fASuXnaeUlwr/m 4Z0/w6207EKxkvGDnu21Tmm31G2t0l6/ndHfqTgxnVID/saf+kWx0tsx+BDeB8LGNXzm0wcPzQX VOZ25vMo8lP5ptJhQ6ihXmseviriBpuPMrCThMPfCaty7LEv9Xc/MPVNM0FI1WjVfVit2/1JXkL soagGw8OQozYaLdtpcPhh0UqeLl65SXkvrZykj6cIMvoX2qQ3a511VmsNlRby4VKEmkVk63GP8r bhj1hkLsIXjlabg== 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. Signed-off-by: Sudeep Holla Acked-by: Huisong Li --- 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 c87a5b7fa6eaf7bcabe0d55f844961c499376938..98c99f0e24c4a654a8f4835063f5a479a433c9a0 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 Mon Mar 3 10:51:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 869852 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2A971F4635; Mon, 3 Mar 2025 10:53:31 +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=1740999213; cv=none; b=M0vFo8qR70DfOR3BY1DwU/z+LFQ6iztcSj7OoYL9FsEDetOXVHpCO317u1JzkqQB15nr+ywZt780Z4MD5WmseK1Fb0BYGNQLRHWt4ZPmVPnc/wxZ61K7HcLQ+WhaeCKPUWT/t6P4amqVnaWAbQoyh/mcvfl2rXCdEvOguCav2TQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999213; c=relaxed/simple; bh=UbmacZHuc0rkrUhM8NEGGe2sjhxY+p2kFyDwy7F6O9g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SilJqwpSOgytkAkuKO8hXoJmvwC0PwFHuz8S/D4JXUx2x5E9WeaZ3lfI07etQGzHDjpfTqzMOhCsgvV4/24NN9j7MEd8ggpm2MZQ7JxB6EYNpbQk82/G9mZGb2k8Mh7vGqz043GCHUz74Xbr74ExnDfKCRYgsnZ+SEh9k1sM37w= 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 C16C31FC7; Mon, 3 Mar 2025 02:53:45 -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 A57CF3F673; Mon, 3 Mar 2025 02:53:30 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:40 +0000 Subject: [PATCH 05/14] 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: <20250303-pcc_fixes_updates-v1-5-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young 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=UbmacZHuc0rkrUhM8NEGGe2sjhxY+p2kFyDwy7F6O9g=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYohDnfLle7CFfvs0cbGHG+605WgQHE8GV+YO iXyfhUuk1+JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIQAKCRAAQbq8MX7i mCJTD/9tHPMsmYiCLgOELz0+VsOIsbtVXK06UOdVm5UAe+fTPWEd0bNLOlxhr2w6NdQ+bbuM3QW UE7/33ijae/yOzWqWRFTi2MIKj0BOtOg+Msox9oGXEkPz7o6P3WVs/s+PHWiKFaJ/O85kqnKtAX puwQeVseE+8P0h0J4h/4i8QlSi+Gi+Za7z7UhMwZPsGmWqoTu6jg42wvPCVyMmU+PSOlAeA+9Uo Lad0W1JTpz33WArz/7ZtnTkr4XdgqgyMJkIB1lZHNEnMDiqWF/6o5BcFdRS2c+ysBAF/rxRYIdr E0/vAzokYXFxB6cHYhgB3bqB1R6P0E/fUuIFwqg7vOHUuVX21AyO/STjH+kJ7ilvVnL28mr4yMQ A4iNv+XhT0x68wYCZteEVJiaz/CT1AlqbguP8RuhPVFUu+v8arjs/nKf0YzTX2sWVQv9YTjGIPz oSV+YtbVoHgO5Mm34oO6Lm95SLIuEB8JcUlAyyPrB+qwqHTb5Q5WG8lfe7q5nJuGFbn91lE6M+X 1Pf3ermNqu6zTi6TKvKb+gRM22CkScIHt/5kYUo/OKeND2zdDRlzUTZFfpd9hX+y9/mJMy8gvuR bDdh8u7b8wzj9P92LEq9j4eyWgnNexvj4i89DUepJgsMM3EX/6ah71HHNaVfme2b1YSsANyx2JQ fioy0b8vkC72yaQ== 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 --- 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 98c99f0e24c4a654a8f4835063f5a479a433c9a0..a0fdafc3ef71d20c73ff58ef065201e6dc911396 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 Mon Mar 3 10:51:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 870168 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 353051F5424; Mon, 3 Mar 2025 10:53:33 +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=1740999214; cv=none; b=RG//Cg3cj0CICpAZ6CzBG6cK4p6lClHy+2z4C0odWS05V44XugGqjGlnO1WshyaSlkBpnQG89fJrdek2RfflmJCLC+uoud/AO3NSIGfr6/pL0T1b7T9rxjfCad2hW35TKjG3iTrtBywaW2vdbIXqgYedj2RafoC0+tqL3mj4bZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999214; c=relaxed/simple; bh=hI4KFNGqi6KDUZUIDZyqHSLYmiqQIHbxM+e+qaBmu6M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZcIIq876/hSNIIcdHxrTSkMnNyvZwKUZ6to84iTpdLPkl0wCNpfGWB9nLNzZG3l8Clj0cYBhXjm/y+UU0egEclPvBBmLydhiOaHflG9Gi7Ar3j9dZmFsp2CiWHwvqbhoWUWYBqqmjCxp8NwBdmv0ErWXE3BxWDGGtxrnFEWLzg4= 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 1A7FB202C; Mon, 3 Mar 2025 02:53:47 -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 F2D223F673; Mon, 3 Mar 2025 02:53:31 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:41 +0000 Subject: [PATCH 06/14] 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: <20250303-pcc_fixes_updates-v1-6-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2269; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=hI4KFNGqi6KDUZUIDZyqHSLYmiqQIHbxM+e+qaBmu6M=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYohtMjw/FViW2/BmGmcZM6r2Ctg0hMbgjmJp lWUQ+GR7emJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIQAKCRAAQbq8MX7i mEJBEADBTxKSEQ8UnGWF5bl9tmRpwqAHrj63Pn/Ls2i/ZdUdyRFDmHIFg0MQpbxP24Fx2zJ0wyh P8KG8InGCuT9AVXf4Mq8+AUNoe5guBi3OfD0j7ssyz5QZybfg40MU1qIk7MZ+7c8gjbZIm34ZWP OXUuPLoQ3V5NjH6uqOXS7Rnq7Wtte+l/6dXayvuZH/Zs4DMEhAmuqG+0lh5EcWQ1maNGlDZJiJl kK5Uikz/t2eU4rEW2jhF6fMlo8Icu/oB849BBUey3RyCi1yRG2QUCC4nvnkDEXQkw858jmwq+YT 7oIC5hyz749QjpUc2308OWNUr1aZsslTXJx6ccoDsQVoP634/lEve4AnKRCqLx59J8c/mPcq7Cd 5z5CoIcDo1VPzLdTKnnPWQ0n66iqiqmCLWAgEJRkKi+h3UanlPTeKBKmlqOAglWtgg5f3rgfxOH hcb3HBDv1DKGcXua83DPyoAIpq5mtsyqGramMBR016iaiwdnmiLJFObIjhKBuVb7VvLJZlZ2Xkv tA+Q9OTF/d/NGhLD6hcSyBF5/BdWwca6nhMNFGRIEUZ+bj6eB2n5eCyxVAn63SgxNoykLMn2nS7 PVqgdaV/vxfaxNHHLHpW0S51Lh9+hjeFZaOSYmDDLP2QFNUBJm+x5b9g73W6T6P8FSr3GNZ9b3m ZEOAreGcddvjsww== 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 --- 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 a0fdafc3ef71d20c73ff58ef065201e6dc911396..e693675ce1fbd8d01d0640b3053a5c1882bdbce7 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 Mon Mar 3 10:51:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 869851 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85F9A1F5831; Mon, 3 Mar 2025 10:53:34 +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=1740999216; cv=none; b=Z1WYI3qIJXLz0BuD+CBvdnULX7dNM3cliSAc9HMlCx/cqWf6C6sNzM8193QdMWPn2mO2r56cNVi2UII/peLiNNRHo8uZpke2HCVdkcX3HvSnKD9K1VFdS7GliULwsu9qUJKxq3Go03gm7M4JPqGJMTt3/9qdpldwT/6XqBV96Ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999216; c=relaxed/simple; bh=u3wVE/ZfoE0JWVqpIaNDPrdp1FRUoL1ftJi5ZNONaTk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z4Y39QhYXFQ31Q7GPbpOTDaGIoxiFakklpUC75e5zAlRsNRiO1QTeQ/x5FzIQXC5xh7DO0wXxgKEHjMYQ1eH3K3KSbTUL/ra7cZE6uGz3XCLwGQT+QWeMYAELf5WU6qK/b/5VW16n/j+CUkg4TADTDPjuO2pdfAcZmHm2urWGkw= 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 6976E204C; Mon, 3 Mar 2025 02:53:48 -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 4C27D3F673; Mon, 3 Mar 2025 02:53:33 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:42 +0000 Subject: [PATCH 07/14] mailbox: pcc: Move pcc_mbox_ioremap() before pcc_mbox_request_channel() Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250303-pcc_fixes_updates-v1-7-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2094; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=u3wVE/ZfoE0JWVqpIaNDPrdp1FRUoL1ftJi5ZNONaTk=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYoh25UXY+l7xb9TXLNxAznPkKfBn4zemN8E8 acTboQdllaJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIQAKCRAAQbq8MX7i mJgnD/95AZ0+SFqGInKhDg71UUdviLxFz0go4EkfWDZ+L0XOJfU+TvLZPpWZoQ4Sz2ThyRudlSW o+3taV1QdQ9wHd+bs2ILbELpm/ybpxaPlVB5hbirgQgmx4njkhJNbhNyiec8Z+HnjXewVwmbZan KKIU/cjuEdj3sreZecwlGdW9jW5njnfSqMzWu5G2GHOlIf3jtYL+VuxPI8Sg/SjsvJNv7a/cJVN ABQAkGgbUWmB7gF7PJJrDoXGHLWAcAizzVJlWXPtXRG6Q3Gig8lgjqpbg5nRW5OVL+obP0Zlhbi uu4RsCLimRGfyCxAaohkg0h3E+Zdf2NXwIRO0BtwntdGWzgdX/Jwt651xQFhyEwaIDmC0iAPiD9 YX357Qyko3JaNk3VuvgFiHpkZQaZ88taDkBYrSzEahFKsAZos23fBsRvQ07vU+KMowIeUag/QYB pPIXt7jghmRThAp7Fadcm+xZaKyVo+gI5URS/BDYaGKE47z0Fo7Earu4rtAU9im91zXII7PAcsM 7k2SLQGhZQdxZYh0Cx8/IM+NFRoJm3eWHBStUA1r04H49kU9oUG0OpsdV2KnrOo/+dlgSgpmIAi qUTC/bk7Q1g5SCyw8ikgRJ9rCNEpWBWS9QgerEeYolAyLnLrdPwrGu45dh2y/tzZ2QRmMTTHTsA XA2tPhwdrJeFSlw== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 In order to add support of mapping the generic communication shared memory region in the PCC mailbox driver when the PCC channel is requested, we need to move pcc_mbox_ioremap() before pcc_mbox_request_channel(). No functional change. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index e693675ce1fbd8d01d0640b3053a5c1882bdbce7..f230e512c29b79fc03e429145180ff049a250d2d 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -357,6 +357,25 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) return IRQ_HANDLED; } +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_mbox_request_channel - PCC clients call this function to * request a pointer to their PCC subspace, from which they @@ -419,25 +438,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 From patchwork Mon Mar 3 10:51:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 870167 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF7CC1F63DD; Mon, 3 Mar 2025 10:53:35 +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=1740999217; cv=none; b=IC66tP1wrbnpTA4TgGVXD6dzt3equOJPGctoUzP6Ca5/y+a7czy3U0Ridny1Yxv2fRPjT5P9SYQI5cVyE/TSxPuh6Szkl0LxsO5BUhfnBUITvy1Tmv5oKWH6KAYL/RlAu4PdGtEzYLG7QZhkQV+g9x4ejPMPWHtG4c9bKU6NBs8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999217; c=relaxed/simple; bh=u/6pDnj8GfpGPxOvBmX+S5++Zzp9jiVA6YkVnv/RF7w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=vAVmJqJ4djFx4kNuiSXGogjHbwipeU3mwNpBVmw0zTHeN1tKOSV8KGiGGdHdpe9jhcnPIpkWmZe2Y3oBG/LG2WUg2ENer45lFJmrKb1hkh8Ye3zt/2QiB9SOvpHWkR+aZ9KucLUHsgPA9oQKcKqZhqsA71BzcKcBmYCdfPQ7oes= 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 B59052050; Mon, 3 Mar 2025 02:53:49 -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 999CF3F673; Mon, 3 Mar 2025 02:53:34 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:43 +0000 Subject: [PATCH 08/14] 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: <20250303-pcc_fixes_updates-v1-8-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2829; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=u/6pDnj8GfpGPxOvBmX+S5++Zzp9jiVA6YkVnv/RF7w=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYohv0tbYJUI9NBdgz6trA4YrihHK9pvMOqaW iekSWMGbJOJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIQAKCRAAQbq8MX7i mN9DEACmnhnEl+a/7SPtIdCrcfL9HFOkAree8/iMwdErsgYhZZeIKr4EzujhoNPxqnFEnNxRReQ pZ9C/G+vL2HZcYyhOKpgDmsKuC1bZfGZUvj4yc0IMUUNoCrnwMSIyzAXLFdRS0/LtHhnhB1TU3m tSslNs4OIY8TzozNl4DhqObXHFR5uUJHif/DTUf+OB/SM53WTXHnGzTosINQbpRW3aar8dOjbh1 SC+x9onWUT7Fcsc8yaM3IMRJHRotdlbqgBbYox/BnGBEKDzAvMsRnTJVJWvPZQoplismugucYk0 kBVvhVM+Yskr4i9t5N+H7XEreaxnn/iXk1i6Hca5Oj1rEogQxQ151Fc/YYg4Q3sgkOg2wZ6eCkF eTuzkDWVRCjOje0wVBnzW88Xuv+NGPyXOArDJN6fAhFqptXY5S+WFkX7qM7/hxEwPaDhNTAelBw GKx12zL8/KCMQ5VMHk0cClrAkMIDtheoiXG4N62HofNiu1PKY7vsvgI2pvVL9wQ/ygyYTgFKbn9 0pGWKgM3UDcgeawnArentODV/spALgxmhRXq6T0QN8kRkuERmH2EVpb+eJERfEoEfZ9o3+fP1lO lPyq5z5Nul+noTXW7vN9GhC1E+v6wdZNYh+NpmSCflz42+8yJFNsBJapb5MCUmxhwbISSzh74VY RkURlvzUACEr2rQ== 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 headers in those memory to manage the transport. Since there are no users of pcc_chan_ioremap() and also it is mapped by default, we can stop exporting it and make it static function. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 10 +++++++--- include/acpi/pcc.h | 5 ----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index f230e512c29b79fc03e429145180ff049a250d2d..5f2e2b727d99f07c44e87e44c11ba0aefe3a2318 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -357,7 +357,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) return IRQ_HANDLED; } -int pcc_mbox_ioremap(struct mbox_chan *chan) +static int pcc_mbox_ioremap(struct mbox_chan *chan) { struct pcc_chan_info *pchan_info; struct pcc_mbox_chan *pcc_mbox_chan; @@ -374,7 +374,6 @@ int pcc_mbox_ioremap(struct mbox_chan *chan) return 0; } -EXPORT_SYMBOL_GPL(pcc_mbox_ioremap); /** * pcc_mbox_request_channel - PCC clients call this function to @@ -409,7 +408,12 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) if (rc) return ERR_PTR(rc); - return &pchan->chan; + rc = pcc_mbox_ioremap(chan); + if (!rc) + return &pchan->chan; + + mbox_free_channel(chan); + return ERR_PTR(rc); } EXPORT_SYMBOL_GPL(pcc_mbox_request_channel); diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h index 699c1a37b8e7846362bae35477eb5736be15d79e..0462bb9da6513a241f3b652b8e203299a1d990c7 100644 --- a/include/acpi/pcc.h +++ b/include/acpi/pcc.h @@ -38,7 +38,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) @@ -46,10 +45,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 Mon Mar 3 10:51:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 869850 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AC471F76A8; Mon, 3 Mar 2025 10:53:37 +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=1740999218; cv=none; b=vEYFZ2BEpUWq4THomZMVQmGx4bA/XWgOZPmdvJryl8co0j4CL79vSC6gNfeIZ0uDMzzBG3GqDcDG7unxGRCqbd4RU3eQNMsgKYGUz97UmgZs6TqcYuWZ6W09w/uoEb5nMLc8lGR082cSm0ARMzWw/fJS2b9bdsT3ojSiSIOyj6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999218; c=relaxed/simple; bh=ZHQsw9JxtEtWCNtTod+FBGG8c1aDXetOsMB/Gq2BJcg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZE89FdAb8lc0lPtRgtRXlB25QRO+JzFYQVCRRttYQIsgDCL6rLWDZ+WezuAHgtyIsfoqaMXj9pdHFRbtSfc/uVwBnJo/uMgzxAuO5dXbx7m5jCwQYlkDkYEv7JjwP7tgyAtu7WfDIKFtesTlMgXO7UUVSDwoAYMH9qA3TWuXrRE= 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 0F20012FC; Mon, 3 Mar 2025 02:53:51 -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 E749E3F673; Mon, 3 Mar 2025 02:53:35 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:44 +0000 Subject: [PATCH 09/14] 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: <20250303-pcc_fixes_updates-v1-9-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3243; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=ZHQsw9JxtEtWCNtTod+FBGG8c1aDXetOsMB/Gq2BJcg=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYoiRklIW0oglv683T42D8WPodP5k/f1q9Eff bTWohLZyPSJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIgAKCRAAQbq8MX7i mLeIEADUI/vKVRKk1CquSAGR2zhz9eRH/k7AjwBgDLyr/beQc/92U8vdcykP/NlpdhC9qGerAdO iksgfayzpUE0R8K4Tk7unsvk3TvCVY8cw0BAnrA4dILaKRxqlMBTRCShB+UzdO9JyBSYMd7ctbA 93aKKmjf0310RSYH1Znf7KrPTZf+FuGZrd5THdq2pT5fYuhw4YT+/RiUvUxccuTGmyDJfYky2Hz 4yqxyL4301KTqUKh0kMn/WFwQBMvpIVFTMopuRLdoQfrW93SpPmJmZeETA+WROwaTV1iVqin1yg CJyZgYIBVfyytVz3xch0YOdYYP0yKOSoeGkYt2BvyXG+u4zspD1Gf5Z74Q6E//j7so15Bsc6flJ F0omSfAlWhDqDYUS9gjOGTLyCrM61mv2hIRNpwtYE85t/Q4vceQQoSPZdQKH5lf4UMoPXdbD1Rq QKhHXQ0iUDFYKN9/HEBTtfo51nAQgPgrvqUNuve+a2KOginyGtrAbMsM2YIFzRwPMRmqhd9T4Pg 4/YVSWjObUUy7gG/KGfiW38pz/23u4sqyQkSWY7ZYGIQMDCXrCQzL4eIo5lRP6UD5DEz3eKEEER tDh/pkj1bEj/KBFf4QWWpju2LwQr8r+v32nXJvLjydL9Z3h7rxcd/rGGEzMyllPoz2dHwogBJ+m 0uxUQ+n1q+ANsGA== 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 --- drivers/mailbox/pcc.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 5f2e2b727d99f07c44e87e44c11ba0aefe3a2318..17500d4122af3194011eb47bc91efa4317cd8a32 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,25 @@ 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_ACK_FLAG_MASK) - pcc_send_data(chan, NULL); - else - pcc_chan_reg_read_modify_write(&pchan->cmd_update); + if (ioread32(&pcc_hdr->flags) & PCC_ACK_FLAG_MASK) + pcc_chan_reg_read_modify_write(&pchan->db); + } /** @@ -352,7 +342,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 Mon Mar 3 10:51:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 870166 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E1261F791E; Mon, 3 Mar 2025 10:53:38 +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=1740999220; cv=none; b=pSo8/KS4a3qumypdk+9/tuKlWTkAtWXeh5UJKzw7NY5FJFgHvmx6x/1vNXhIlHo5V7qcqe9qYJ3dRk5ySgosNl7Ve3d2Dk6UrzcBkEGYTehLI/jiJ///TkTEmaZ//QoVbL3LXDzhNl0mnzqOgNP/EYd2UX422lV+gjxYswYTppc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999220; c=relaxed/simple; bh=/1idv0gKwQTkta21Z/N8pYBowlvpzsLMWC0CYxTJA3w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d6NNfSOfefOE3PfH4Qr3eVFgQti7gP7glEV1uGSEfLHonD/Ab5/ei4DHFfMCBW+gysVnTJXbf9eFg5twYypUVxK0c1gDm/SYoJ0aTkZLo/DwZWrtds4H7PQUFOj687564zGNXVDBTSg/27ZqWs7MVCxCIv8IfLwTCccSSrqBITM= 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 5CFA21FCD; Mon, 3 Mar 2025 02:53:52 -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 40E673F673; Mon, 3 Mar 2025 02:53:37 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:45 +0000 Subject: [PATCH 10/14] 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: <20250303-pcc_fixes_updates-v1-10-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6214; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=/1idv0gKwQTkta21Z/N8pYBowlvpzsLMWC0CYxTJA3w=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYoi6vcxSZaG0sHVa3JebeebwsbybmU5fCbyH T/XmpEJ6YKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIgAKCRAAQbq8MX7i mMxpEACJXHy//3/3BmXe6VvvQZvTJq4wJfOUxF5DHytYxtWoj0jYx22WD0amQvU/bJriWU2D7ho NZiSts/WBUVNN6bdL92y3Nl0iIFXDqriFccJ42aqcK6q0VTtUavbmSVaV+f/I6Wa4kcZcgER016 pPgJZbGlXxss0LSR9ekmkbLzlD37D+dQ0tHur/OsrPfLG4uZ4LB8mEYAx4hbBchkJYmPXz0y8QJ mjPFtKBvQFJFa/gRNpH5IANall/qTuK5zGFlf5ZjL/bQMZs5rbAVXZZRTUN317aaCDbK9AE5yyE I+TfVBp2LkWAiuSjOjU9QkwTPRpa4AGBHVnqmOSth9J/iiGOf/MQlgjNVYpQ3oMBSFHqHBNNjyB 6Y5drensEICn21biT6PQK2lK2Owe+SZMpHHmx77rDX3yMl5Nka8qSjrMiyb9tpqaLUU0lNZ4gtH CKNfD/KdBURFI9pGUhAOwHRfrqWHP6lrP02qrpfXQrLeLrQ0fdJRNXlWzLf5w6ZTDkF3dC/ocLP o5DkvNrBZtKanD4C0GeeeXCkBEyTEZPgSc6DHPmxCZk6If0K2XNE4RAMCTflngqM4LV7LZ32el4 SDha47gE3k+2tZPcZzgl54QYjojHcyGANPtdq8PorsCkFr1Iz3FUInaKdgYhXxsFm+odWzeDvn5 NVs43S8A7eZKYkw== 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 Signed-off-by: Sudeep Holla Reviewed-by: Huisong Li --- drivers/soc/hisilicon/kunpeng_hccs.c | 38 ++++++++++++------------------------ drivers/soc/hisilicon/kunpeng_hccs.h | 2 -- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c index 8aa8dec14911cdcdc2a2d11606bf6159144e9489..3b57189cd778f507afaa89bf47f0fa834043c244 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) { + if (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); 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 Mon Mar 3 10:51:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 869849 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 346E01F875B; Mon, 3 Mar 2025 10:53:40 +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=1740999221; cv=none; b=nJ0DldH+Er4DnwywR1QZQFQg3NeFcT2ust0M2aSiHXAGEkYPUIGZY111AuKePvW9NTEztoGYwsvRBJm/rGjT7mscDAYqo7IT9ToCtdm9lPhNxGU81VYdOlT5vr7reUJYHJ/uHDprOSPlWVBy+EkuUMvinQ9u/FND92hwvgGQVLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999221; c=relaxed/simple; bh=MfSTY+8Javma4iMKIMRIP5AOm3S32ksYO4b7JbopmcE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Nj31qmXKISMpI7migibu2U0Ct3Wf5XKbreLzDRDw0v4RI6MWCyCiexUmya0LItvac2zLovhDMMmUKL1thynFe3Ty8pXHd13jt9q9jlnDBClLDSDp4NBqr64pjvB9lRWeGHXXsGbF0bmwK/Pvf5+D/5aGY43OD10xva92htvNMGM= 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 F20D62008; Mon, 3 Mar 2025 02:53:53 -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 8ECEC3F673; Mon, 3 Mar 2025 02:53:38 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:46 +0000 Subject: [PATCH 11/14] 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: <20250303-pcc_fixes_updates-v1-11-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , 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/ZANAwAIAQBBurwxfuKYAcsmYgBnxYoi2nHgqkxUHTt758cixVVE8QA/rlgDBWi/d T7INXNU0HuJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIgAKCRAAQbq8MX7i mB+GEAC3iW/TRhSK3y8Krc/xktnm/Hfa1Tc/bl2PMFdgfLqbDRKR6bXC0V7m3HMXalYHqOsa0qT rMvYPKrdrUxTCeJyO0WIlrpRSsGLZ/GKgNWtWni1zVNoY1jrh6LjofUFMcmDYTVOPSdIA+Ykv3j Hkb/3MFb2TM+IuKjy8bcZBqJ0ER6a7K/so90OFPwZL7ju65vVLA0uAdA/2eioym+K/jG0B3fxaJ SO+f7mFRQSI9ys7zJo66abPTWDJ+F/ZEncQBzOs00asQdJWLNSAuMPJp292BnCxF5R0uWygi7DH 2YBo+7y9tBFPr20XN0l4w9nrgS9YrekrB15Aws82VWGexu2DP5UhBItQTM16hRpDd1+v69vjgZ+ n4l19dI9fGiIvGZ2/vXvrIU1/2jvoI4JR40Pd7JhcTEjmJTCbJD5lz2eBs/UKulnpOALUk/2f+u kXRkaIm2BvKMioRRzmd+j60OEyTekpt6TsuowOGZ4bxjxvNFo/0eLkIoiHqdlbbRA+Sy6dsBUhd vsGEXBf7vFJSCOhGFFazsJQlAkiIdRMMrnlZnF6vBz4x7X2pW8Dp34kQjduCQ/Mw05T0UoQWeTJ jvpVOV87Rk9KlAMlSzQW51wTUkSeuJngr9PSyhaOzkHlGFtC3RgcpsO6Rj0eDTBAslWJlAhMeaj NWURpMEQxip2LSg== 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 Mon Mar 3 10:51:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 870165 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C80FC1F8AE2; Mon, 3 Mar 2025 10:53:41 +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=1740999223; cv=none; b=AChXIWWbSGvoKjtkDj36sZe1V6IVHEXjDCU06bRvarqzxI7jMptQvjk6RkpOUPX/PUIJLp/XVYqU+vDQf2mWm/Fg5OTo5YPYzbxTURBlVDZUSJzSQ+17sIRE93zfRAQvIHf659gbBk9P6cWftLdGlvtBcV6gilgJql8bh7BCoF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999223; c=relaxed/simple; bh=qKYQ/RpHnPPi0xz+U1dihMeF/+HcwhhzvfPtYWgkvCg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H+ivxV4DBbdDdINjB7PqEYgBjbfdqKGRJdq6+Ok/g2ok+c28Sv+aNk6wy2/ZOtFwIuHj0YaCjZKOa9VeT7Nmj7VGFtGEZ5ZxIIa82LHMTm+gdEChnYAu5ObPCYDM1aO+O95wtT1vO1W+qqA2LwIJHYz7HqeIRYNI9bO+EPzaqcI= 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 B6B6C113E; Mon, 3 Mar 2025 02:53:55 -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 2FC6A3F673; Mon, 3 Mar 2025 02:53:40 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:47 +0000 Subject: [PATCH 12/14] 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: <20250303-pcc_fixes_updates-v1-12-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3678; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=qKYQ/RpHnPPi0xz+U1dihMeF/+HcwhhzvfPtYWgkvCg=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYoiJfyJ15B7dZMCKbfDh7KWMxlk1zX1nXbFZ DSDENvulASJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIgAKCRAAQbq8MX7i mOOJEACk8HwhoV/kf4yQTtXA0+Bt6TAgAQcmvhIbnJbmQo6uNeuyvNtO6AJ4hp2bBhQshaQw/O5 EJ/zNcpbsEojllwwlLTXEySe3nChK24CyD5Hz/DbGKOrZNTE6ZPI2nN7d7ids2MfY3gnpJRe+EY JSuME2353lxcPdMkxQD0SU5auKiZJzQJXZNsmwCII+ibzjmokrbjDIdDnmi5gG9SZ/3Z3MYOAb+ UjqklBafICGSMLwE+zmaIYwtt1v0RZ7swQHGkNMHAc/Q6HyQCR9tM8DMeGq9ezKkV7S7cU3eApR bVJmjqNa7Tz2U9z59MMvtfCS5uYcSY5hNk5s0asxqgQA/sW32EdUvI1AUj9jo6jEzjqBYzSLTm7 UbnG/UCJYSDSZqThECQuw3zhvwCdiSwC4593JGU4SIDWuZ3KxGAybmi2T4YsBgKg7FoI5YuDs7F 0x5PH5nD26+wtjhRIfYcvHDjZzFQJrUFcee3epOIiPYflGlKgS6Gdx8ymxUhcfIc+LXV0e0fjrv iFrgf7J3PAs2slBNxdLJ+VCtUxx6s147rt9O1XarZ4TDmRDTh751OhsGFsqJeF5cEK6H3Yqs7br PrEnT+KfL563qBk10DtcNPuQ9fTiK9gLXm1SrbF6MDC9ZdpbqwFGVtUVNzlPm0iYt1S4wgdnR0j Wb96Xqm4w4wZD3g== 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 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 Mon Mar 3 10:51:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 869848 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE49A1F3D31; Mon, 3 Mar 2025 10:53:43 +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=1740999225; cv=none; b=mkyxuUmVCz2mRb/Q5QVLHRK0Hx3WY2RKCqXde1k0UWfpcv1xc8tAmoAR5FBgVOZkX3k1I27N+9d/j32WIhF2EnUQLml2clREuakcQppl3vmk044J0emObHtisg7yXENWdLam/YcKgqXOQ4qm9DV9A0yzNSu84KlBrjJEjc/lltU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999225; c=relaxed/simple; bh=tFkBXBO/atiCQgL+I5PaOZGXAVe1jBN5O3xNDo6yR1U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iMd1wbZUosYdSxt1KmR35JCPICHLIBgwokxiyUzYMNox2cm1bLzBAk6rlvWzHjg3uYIesF6SJj5Cd9tsR7d1YgQm7QRZmhDpXiYTJdyqXXrm7CbaCFlg0QPby303gjKoB+H4ATz/U0jcAZAnYWIHZw06Wu4VP1etiXd7Z1LdwfA= 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 33A0512FC; Mon, 3 Mar 2025 02:53:57 -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 E84E63F673; Mon, 3 Mar 2025 02:53:41 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:48 +0000 Subject: [PATCH 13/14] 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: <20250303-pcc_fixes_updates-v1-13-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , "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/ZANAwAIAQBBurwxfuKYAcsmYgBnxYoi9kbIIwhM7SN4/rMMClfDqLF6rC6WBUHLg wObMXTYtF+JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIgAKCRAAQbq8MX7i mL7QEACM8MCcc67ol1zd5JF6UmlSojZjf1D0hsEF5O5ueNd7RHwsyUMli77cfb2ZmtSf6TTCUY3 rRbFCmJkN+1Ly5iIXTJgoD701eEa2b0qD97DH9rAlWmBQqTGvxq55XlKcrvAyb0J72oBafzTY7L SQ3Z0ZpixC1zZW/6aFM8QeS2Hx8BaZbiBYxCUl8yld4fg4xWf5jX2x6j2hwhENWIUi/NmOUh4iH Dq+uXh/4EGtyADRInM/R84QSqJOqd41NNdoOx4StYzwrV5xBVtdnGOl0U/TGdE/2bwRircAWphv x2s1t4cH//+KjbAD972Rzio/kVgFq6Y1Y6dVJovGcRvYkbN63BdlJ34tDDatZ3lhF0tTaqX7HRJ FA4zoJc7ZoIenI649M/41bS31adFEyl0uora+DMw+C0DGn26B6cSAX7rKQv7YPkmq8GC1sZ87NQ Z1NfMObNVVYbSjyNmda7mCiHFOl58igJ2/atrZXhZ6bpxn/0k0PR91+HmM9C2yygbmm6rwgXA0B JDeK5O7n+IwPkFh0GDDWa4fY6TXLOwU/8EoZS+kFmJ+/74ir6xTVMyYQphGF4OeHa3t9av4UwVH 9j4l4oKNC0paEJjPq1yM+x4bxahMTbJiEB2ImH16YY2jtEBK81V/dnREKM7AjOthoD44R481mct vhmWxWSTKAoGHGg== 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 Mon Mar 3 10:51:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 870164 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEA911F3D3E; Mon, 3 Mar 2025 10:53:44 +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=1740999226; cv=none; b=IirKDGzTjljvRQ+RvebVNzGPd8huXbM5bpcYfGDj9EMniwOp1pOt9/riWLJArvCVEDClU/Jaoogzm2N+wQ1pDIXDQ+fMUHOgGRaxIYDNMe03feTmvokNBn01f+ipz/tT4Y5+u9XDiC3vq7RkpFQiuLX+zDsRPC/rX48M+rdxGgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740999226; c=relaxed/simple; bh=iFUeJHey5yoWOaCDwHA/+dkaY+Qb1DUk7Ye5n0Pdfn4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gycejg/2vrx/5M7kBSzhDdGXZGO3iHaDEv2q5RGFy8aV5/EbiJQGxLrIbNmKZzS7t1zGjI2rF0v8FoFQnodY629zwHv3Dc6HTf5EWnqWUgATy+a2PQN/RonouSdCu+K+s3mbAeUTdoWNRFRxKTCUcHalE+t5cKh9XeeGfBp+YY4= 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 A562B2008; Mon, 3 Mar 2025 02:53:58 -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 656AA3F673; Mon, 3 Mar 2025 02:53:43 -0800 (PST) From: Sudeep Holla Date: Mon, 03 Mar 2025 10:51:49 +0000 Subject: [PATCH 14/14] 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: <20250303-pcc_fixes_updates-v1-14-3b44f3d134b1@arm.com> References: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Jassi Brar , Huisong Li , Adam Young , "Rafael J. Wysocki" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2873; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=iFUeJHey5yoWOaCDwHA/+dkaY+Qb1DUk7Ye5n0Pdfn4=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnxYoi9kDd5Yg50QoICLz/87VFVMCqajuK2k4tJ ee/kfospo6JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ8WKIgAKCRAAQbq8MX7i mNPlD/wKs0oZNESqFnya6yAPNwWVMvlz3wPn6ZiOKWmC3VxPb41oPR1y68g5ncSeExZdRDrhrdh QtevZRzzRb1uQXWRXJzs1ICTZwL15hnTW9NVPH3quCAyuuY5azDIShgaz0LpKFrcamRtm73Vlwv dFhRy71zXvY8qBUeB/6j6LzAIKpaAwKeJUmBsGxoQh6kZDIF+gvmQtsC82Bxzwr9muvlfYr6N3V MsF6cQsDC6tWfZBRDtFXk/skwFfUl0cxiNkAeSvUEfAE9+BuAtyqMs4fwf3yIJkgCQvF4R9+fY8 tGkqpnwXbZKE6BTN0AW+b/wp1DzaHCVOME7CHU9eJjydv8+2QGCmDBEnMuyrG6XMqNRvGcze8F+ rn90+zknT2u5NToFaT2u3wIEGwKO1lSEwlquXceyT/w7zB5NaE81zo5x0bRhFsp7OCvDWe1ZIoa 7ALoQ4DcsUipXjI0gJ0myKhPuoQYdN0GEalSiu8Qc6UBA212ieACoH/JJJP4XtnbrRyIh4v/dXw ATuNcrPUuMqnW+CmLa+Dl4CPrdwSvSz5KXsfKHOjGAXpxN0HKKPo4OzLdKBWX/Qw/lzSJ29BYrU CQqNrwUumAgzHrphmxDk+Qb62b/OMc/eXqi6l5IKbQlRLyl7wLgh+Lhbb8j09ksjzx2yF2RUq7U FyFH4ZS2lU5XZYg== 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" 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; }