public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "lihuisong (C)" <lihuisong@huawei.com>
To: Sudeep Holla <sudeep.holla@arm.com>, <linux-acpi@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: Jassi Brar <jassisinghbrar@gmail.com>,
	Adam Young <admiyo@os.amperecomputing.com>,
	Robbie King <robbiek@xsightlabs.com>
Subject: Re: [PATCH v2 08/13] mailbox: pcc: Refactor and simplify check_and_ack()
Date: Tue, 11 Mar 2025 19:47:39 +0800	[thread overview]
Message-ID: <34bdfee2-4780-f45b-7891-e845b13fdd2f@huawei.com> (raw)
In-Reply-To: <20250305-pcc_fixes_updates-v2-8-1b1822bc8746@arm.com>


在 2025/3/6 0:38, Sudeep Holla 写道:
> 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.
LGTM except for some trivial,
Acked-by: Huisong Li <lihuisong@huawei.com>
>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>   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)
How about use pcc_chan_ack?
>   {
> -	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;

Should use the original code?

memcpy_fromio(&pcc_hdr, pchan->chan.shmem,
		      sizeof(struct acpi_pcct_ext_pcc_shared_memory));

> +
>   	/*
> -	 * 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;
>   }
>

  reply	other threads:[~2025-03-11 11:47 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05 16:38 [PATCH v2 00/13] mailbox: pcc: Fixes and cleanup/refactoring Sudeep Holla
2025-03-05 16:38 ` [PATCH v2 01/13] mailbox: pcc: Fix the possible race in updation of chan_in_use flag Sudeep Holla
2025-03-11 11:40   ` lihuisong (C)
2025-03-11 12:02     ` Sudeep Holla
2025-03-11 12:15       ` lihuisong (C)
2025-03-13 15:07   ` Robbie King
2025-03-05 16:38 ` [PATCH v2 02/13] mailbox: pcc: Always clear the platform ack interrupt first Sudeep Holla
2025-03-11 11:19   ` lihuisong (C)
2025-03-12 22:25   ` Adam Young
2025-03-13 15:08   ` Robbie King
2025-03-13 15:09     ` Sudeep Holla
2025-03-05 16:38 ` [PATCH v2 03/13] mailbox: pcc: Drop unnecessary endianness conversion of pcc_hdr.flags Sudeep Holla
2025-03-11 11:19   ` lihuisong (C)
2025-03-12 22:26   ` Adam Young
2025-03-05 16:38 ` [PATCH v2 04/13] mailbox: pcc: Return early if no GAS register from pcc_mbox_cmd_complete_check Sudeep Holla
2025-03-11 11:20   ` lihuisong (C)
2025-03-12 22:27   ` Adam Young
2025-03-05 16:38 ` [PATCH v2 05/13] mailbox: pcc: Use acpi_os_ioremap() instead of ioremap() Sudeep Holla
2025-03-11 11:21   ` lihuisong (C)
2025-03-12 22:27   ` Adam Young
2025-03-05 16:38 ` [PATCH v2 06/13] mailbox: pcc: Refactor error handling in irq handler into separate function Sudeep Holla
2025-03-11 11:23   ` lihuisong (C)
2025-03-12 22:28   ` Adam Young
2025-03-05 16:38 ` [PATCH v2 07/13] mailbox: pcc: Always map the shared memory communication address Sudeep Holla
2025-03-11 11:32   ` lihuisong (C)
2025-03-11 11:56     ` Sudeep Holla
2025-03-11 12:31       ` lihuisong (C)
2025-03-12 22:29   ` Adam Young
2025-03-05 16:38 ` [PATCH v2 08/13] mailbox: pcc: Refactor and simplify check_and_ack() Sudeep Holla
2025-03-11 11:47   ` lihuisong (C) [this message]
2025-03-11 12:08     ` Sudeep Holla
2025-03-11 12:19       ` lihuisong (C)
2025-03-11 12:25         ` Sudeep Holla
2025-03-12 22:29   ` Adam Young
2025-03-05 16:38 ` [PATCH v2 09/13] soc: hisilicon: kunpeng_hccs: Simplify PCC shared memory region handling Sudeep Holla
2025-03-05 16:38 ` [PATCH v2 10/13] i2c: xgene-slimpro: " Sudeep Holla
2025-03-05 16:38 ` [PATCH v2 11/13] hwmon: (xgene-hwmon) " Sudeep Holla
2025-03-05 16:38 ` [PATCH v2 12/13] ACPI: PCC: " Sudeep Holla
2025-03-05 16:38 ` [PATCH v2 13/13] ACPI: CPPC: " Sudeep Holla
2025-03-11 12:10 ` [PATCH v2 00/13] mailbox: pcc: Fixes and cleanup/refactoring Sudeep Holla
2025-03-12 18:04   ` Adam Young
2025-03-12 20:05     ` Sudeep Holla
2025-03-12 20:37       ` Adam Young
2025-03-13  9:38         ` Sudeep Holla

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=34bdfee2-4780-f45b-7891-e845b13fdd2f@huawei.com \
    --to=lihuisong@huawei.com \
    --cc=admiyo@os.amperecomputing.com \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robbiek@xsightlabs.com \
    --cc=sudeep.holla@arm.com \
    /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