public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: "Rob Herring (Arm)" <robh@kernel.org>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: mvebu: Use for_each_of_range() iterator for parsing "ranges"
Date: Sun, 16 Feb 2025 17:54:06 +0100	[thread overview]
Message-ID: <20250216165406.jp2dzfwdfucklt5b@pali> (raw)
In-Reply-To: <20241115073104.gsgf3xfbv4gg67ut@thinkpad>

On Friday 15 November 2024 13:01:04 Manivannan Sadhasivam wrote:
> On Thu, Nov 07, 2024 at 09:32:55AM -0600, Rob Herring (Arm) wrote:
> > The mvebu "ranges" is a bit unusual with its own encoding of addresses,
> > but it's still just normal "ranges" as far as parsing is concerned.
> > Convert mvebu_get_tgt_attr() to use the for_each_of_range() iterator
> > instead of open coding the parsing.
> > 
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> 
> LGTM!
> 
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> 
> Could someone please verify it on mvebu machine?
> 
> - Mani

That is mostly impossible as pci-mvebu is broken. Bjorn and Krzysztof in
past already refused to take patches which would fix the driver or
extend it for other platforms.

So I do not understand why you are rewriting something which worked,
instead of fixing something which is broken. The only point can be to
make driver even more broken...

> > ---
> > Compile tested only.
> > ---
> >  drivers/pci/controller/pci-mvebu.c | 26 +++++++++-----------------
> >  1 file changed, 9 insertions(+), 17 deletions(-)
> > 
> > diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c
> > index 29fe09c99e7d..d4e3f1e76f84 100644
> > --- a/drivers/pci/controller/pci-mvebu.c
> > +++ b/drivers/pci/controller/pci-mvebu.c
> > @@ -1179,37 +1179,29 @@ static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
> >  			      unsigned int *tgt,
> >  			      unsigned int *attr)
> >  {
> > -	const int na = 3, ns = 2;
> > -	const __be32 *range;
> > -	int rlen, nranges, rangesz, pna, i;
> > +	struct of_range range;
> > +	struct of_range_parser parser;
> >  
> >  	*tgt = -1;
> >  	*attr = -1;
> >  
> > -	range = of_get_property(np, "ranges", &rlen);
> > -	if (!range)
> > +	if (of_pci_range_parser_init(&parser, np))
> >  		return -EINVAL;
> >  
> > -	pna = of_n_addr_cells(np);
> > -	rangesz = pna + na + ns;
> > -	nranges = rlen / sizeof(__be32) / rangesz;
> > -
> > -	for (i = 0; i < nranges; i++, range += rangesz) {
> > -		u32 flags = of_read_number(range, 1);
> > -		u32 slot = of_read_number(range + 1, 1);
> > -		u64 cpuaddr = of_read_number(range + na, pna);
> > +	for_each_of_range(&parser, &range) {
> >  		unsigned long rtype;
> > +		u32 slot = upper_32_bits(range.bus_addr);
> >  
> > -		if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_IO)
> > +		if (DT_FLAGS_TO_TYPE(range.flags) == DT_TYPE_IO)
> >  			rtype = IORESOURCE_IO;
> > -		else if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_MEM32)
> > +		else if (DT_FLAGS_TO_TYPE(range.flags) == DT_TYPE_MEM32)
> >  			rtype = IORESOURCE_MEM;
> >  		else
> >  			continue;
> >  
> >  		if (slot == PCI_SLOT(devfn) && type == rtype) {
> > -			*tgt = DT_CPUADDR_TO_TARGET(cpuaddr);
> > -			*attr = DT_CPUADDR_TO_ATTR(cpuaddr);
> > +			*tgt = DT_CPUADDR_TO_TARGET(range.cpu_addr);
> > +			*attr = DT_CPUADDR_TO_ATTR(range.cpu_addr);
> >  			return 0;
> >  		}
> >  	}
> > -- 
> > 2.45.2
> > 
> 
> -- 
> மணிவண்ணன் சதாசிவம்

  reply	other threads:[~2025-02-16 16:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 15:32 [PATCH] PCI: mvebu: Use for_each_of_range() iterator for parsing "ranges" Rob Herring (Arm)
2024-11-07 17:00 ` Pali Rohár
2024-11-07 21:19   ` Rob Herring
2024-11-15  7:31 ` Manivannan Sadhasivam
2025-02-16 16:54   ` Pali Rohár [this message]
2025-02-18 22:32     ` Rob Herring
2025-04-19  6:03 ` Manivannan Sadhasivam

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=20250216165406.jp2dzfwdfucklt5b@pali \
    --to=pali@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.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