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: 870605 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 --- 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: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: 870604 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 --- 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: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: 870603 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 --- 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: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: 870602 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 --- 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: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: 870601 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: 870600 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.