public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: "Jingoo Han" <jingoohan1@gmail.com>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Frank Li" <Frank.Li@nxp.com>,
	"Randolph Lin" <randolph@andestech.com>,
	"Samuel Holland" <samuel.holland@sifive.com>,
	"Charles Mirabile" <cmirabil@redhat.com>,
	tim609@andestech.com,
	"Krishna Chaitanya Chundru" <krishna.chundru@oss.qualcomm.com>,
	"Maciej W. Rozycki" <macro@orcam.me.uk>,
	"Shawn Lin" <shawn.lin@rock-chips.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 2/4] PCI: dwc: Improve msg_atu_index error handling
Date: Tue, 27 Jan 2026 16:03:15 +0100	[thread overview]
Message-ID: <aXjTs9ji-2ZUspBG@fedora> (raw)
In-Reply-To: <45ed56fb-15b2-455a-bdac-a208ee93a7da@kernel.org>

On Sat, Jan 24, 2026 at 05:50:06AM +1100, Damien Le Moal wrote:
> On 2026/01/24 5:28, Niklas Cassel wrote:
> > Only try to dedicate an outbound iATU to MSG TLP if use_atu_msg is set.
> > If use_atu_msg is not set, it is completely useless to bump the index.
> > 
> > Additionally, if use_atu_msg is set, and there is no outbound iATU
> > available, return an error.
> > 
> > Fixes: e1a4ec1a9520 ("PCI: dwc: Add generic MSG TLP support for sending PME_Turn_Off when system suspend")
> > Reviewed-by: Frank Li <Frank.Li@nxp.com>
> > Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> > Signed-off-by: Niklas Cassel <cassel@kernel.org>
> > ---
> >  drivers/pci/controller/dwc/pcie-designware-host.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> > index ae5f2d8a3857..d7f57d77bdf5 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> > @@ -982,7 +982,14 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)
> >  		dev_warn(pci->dev, "Ranges exceed outbound iATU size (%d)\n",
> >  			 pci->num_ob_windows);
> >  
> > -	pp->msg_atu_index = ++i;
> > +	if (pp->use_atu_msg) {
> > +		if (pci->num_ob_windows > ++i) {
> 
> 	if (pp->use_atu_msg) {
> 		i++;
> 		if (pci->num_ob_windows > i) {
> 
> is far more readable in my opinion.

Yes, I agree that it is more readable.

However, in patch 3/4 in series, I'm do a cleanup of this whole function,
not just this statement.

This patch changes the code in a way that is consistent with the existing
coding style of this function, see e.g.:
https://github.com/torvalds/linux/blob/v6.19-rc7/drivers/pci/controller/dwc/pcie-designware-host.c#L932-L934

Then patch 3/4 modifies the whole function to be more readable.

So I prefer to still keep this patch as is, such the code is always in a
"consistent coding style".

And then do all cleanups in the cleanup patch.


> 
> > +			pp->msg_atu_index = i;
> > +		} else {
> > +			dev_err(pci->dev, "Cannot add outbound window for MSG TLP\n");
> > +			return -ENOMEM;
> > +		}
> > +	}
> 
> Seeing this, I do not really see the point of the previous patch since you
> completely nuke that change here. So maybe drop patch 1 ?

My thinking was that the previous patch has
CC: stable, so I wanted the smallest viable backportable fix.

But, I guess that the "if (pp->use_atu_msg) {" guard makes sense even for a
backported fix, as it is pointless to increment the counter if use_atu_msg
is not set, so sure, I can squash patch 1 and 2.


Kind regards,
Niklas

  reply	other threads:[~2026-01-27 15:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-23 18:28 [PATCH v4 0/4] PCI: dwc: Clean up iATU index mess Niklas Cassel
2026-01-23 18:28 ` [PATCH v4 1/4] PCI: dwc: Fix msg_atu_index assignment Niklas Cassel
2026-01-23 18:46   ` Damien Le Moal
2026-01-23 18:28 ` [PATCH v4 2/4] PCI: dwc: Improve msg_atu_index error handling Niklas Cassel
2026-01-23 18:50   ` Damien Le Moal
2026-01-27 15:03     ` Niklas Cassel [this message]
2026-01-23 18:28 ` [PATCH v4 3/4] PCI: dwc: Clean up iATU index usage in dw_pcie_iatu_setup() Niklas Cassel
2026-01-23 18:28 ` [PATCH v4 4/4] PCI: dwc: Fix missing iATU setup when ECAM is enabled Niklas Cassel
2026-01-23 18:53   ` Damien Le Moal
2026-01-27 15:02     ` Niklas Cassel

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=aXjTs9ji-2ZUspBG@fedora \
    --to=cassel@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=cmirabil@redhat.com \
    --cc=dlemoal@kernel.org \
    --cc=jingoohan1@gmail.com \
    --cc=krishna.chundru@oss.qualcomm.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=mani@kernel.org \
    --cc=randolph@andestech.com \
    --cc=robh@kernel.org \
    --cc=samuel.holland@sifive.com \
    --cc=shawn.lin@rock-chips.com \
    --cc=tim609@andestech.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