mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Sudeep Holla <sudeep.holla@arm.com>,
	 Jassi Brar <jassisinghbrar@gmail.com>,
	Huisong Li <lihuisong@huawei.com>,
	 Adam Young <admiyo@os.amperecomputing.com>
Subject: [PATCH 09/14] mailbox: pcc: Refactor and simplify check_and_ack()
Date: Mon, 03 Mar 2025 10:51:44 +0000	[thread overview]
Message-ID: <20250303-pcc_fixes_updates-v1-9-3b44f3d134b1@arm.com> (raw)
In-Reply-To: <20250303-pcc_fixes_updates-v1-0-3b44f3d134b1@arm.com>

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 <sudeep.holla@arm.com>
---
 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;
 }

-- 
2.34.1


  parent reply	other threads:[~2025-03-03 10:53 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-03 10:51 [PATCH 00/14] mailbox: pcc: Fixes and cleanup/refactoring Sudeep Holla
2025-03-03 10:51 ` [PATCH 01/14] mailbox: pcc: Fix the possible race in updation of chan_in_use flag Sudeep Holla
2025-03-03 10:51 ` [PATCH 02/14] mailbox: pcc: Always clear the platform ack interrupt first Sudeep Holla
2025-03-05  3:45   ` lihuisong (C)
2025-03-05 14:29     ` Sudeep Holla
2025-03-06  3:44       ` lihuisong (C)
2025-03-03 10:51 ` [PATCH 03/14] mailbox: pcc: Drop unnecessary endianness conversion of pcc_hdr.flags Sudeep Holla
2025-03-05  4:02   ` lihuisong (C)
2025-03-05 10:34     ` Sudeep Holla
2025-03-05 10:36     ` Sudeep Holla
2025-03-06  3:50       ` lihuisong (C)
2025-03-03 10:51 ` [PATCH 04/14] mailbox: pcc: Return early if no GAS register from pcc_mbox_cmd_complete_check Sudeep Holla
2025-03-05  5:57   ` lihuisong (C)
2025-03-03 10:51 ` [PATCH 05/14] mailbox: pcc: Use acpi_os_ioremap() instead of ioremap() Sudeep Holla
2025-03-03 10:51 ` [PATCH 06/14] mailbox: pcc: Refactor error handling in irq handler into separate function Sudeep Holla
2025-03-05  6:09   ` lihuisong (C)
2025-03-05 10:42     ` Sudeep Holla
2025-03-03 10:51 ` [PATCH 07/14] mailbox: pcc: Move pcc_mbox_ioremap() before pcc_mbox_request_channel() Sudeep Holla
2025-03-05  6:48   ` lihuisong (C)
2025-03-05 10:56     ` Sudeep Holla
2025-03-05 13:37       ` Sudeep Holla
2025-03-03 10:51 ` [PATCH 08/14] mailbox: pcc: Always map the shared memory communication address Sudeep Holla
2025-03-05  6:54   ` lihuisong (C)
2025-03-05 11:31     ` Sudeep Holla
2025-03-03 10:51 ` Sudeep Holla [this message]
2025-03-03 10:51 ` [PATCH 10/14] soc: hisilicon: kunpeng_hccs: Simplify PCC shared memory region handling Sudeep Holla
2025-03-05  7:14   ` lihuisong (C)
2025-03-05 11:34     ` Sudeep Holla
2025-03-06  3:55       ` lihuisong (C)
2025-03-06  9:31         ` Sudeep Holla
2025-03-03 10:51 ` [PATCH 11/14] i2c: xgene-slimpro: " Sudeep Holla
2025-03-03 10:51 ` [PATCH 12/14] hwmon: (xgene-hwmon) " Sudeep Holla
2025-03-03 13:55   ` Guenter Roeck
2025-03-03 15:05     ` Sudeep Holla
2025-03-03 10:51 ` [PATCH 13/14] ACPI: PCC: " Sudeep Holla
2025-03-03 10:51 ` [PATCH 14/14] ACPI: CPPC: " Sudeep Holla
2025-03-03 12:06   ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250303-pcc_fixes_updates-v1-9-3b44f3d134b1@arm.com \
    --to=sudeep.holla@arm.com \
    --cc=admiyo@os.amperecomputing.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=lihuisong@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®