lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250305104215.zjvpoiniqxhld5u4@bogus>
Date: Wed, 5 Mar 2025 10:42:15 +0000
From: Sudeep Holla <sudeep.holla@....com>
To: "lihuisong (C)" <lihuisong@...wei.com>
Cc: linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
	Jassi Brar <jassisinghbrar@...il.com>,
	Adam Young <admiyo@...amperecomputing.com>
Subject: Re: [PATCH 06/14] mailbox: pcc: Refactor error handling in irq
 handler into separate function

On Wed, Mar 05, 2025 at 02:09:03PM +0800, lihuisong (C) wrote:
> 
> 在 2025/3/3 18:51, Sudeep Holla 写道:
> > 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 <sudeep.holla@....com>
> > ---
> >   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;
> 
> Here should be like below code, right? 0 on success.
> 
> if (pcc_mbox_error_check_and_clear(pchan))
>  		return IRQ_NONE;

Spot on, nice catch. Copied it from pcc_mbox_cmd_complete_check(), will fix
it.

-- 
Regards,
Sudeep

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ