Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Klaus Kudielka <klaus.kudielka@gmail.com>
To: Jan Palus <jpalus@fastmail.com>
Cc: "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Pali Rohár" <pali@kernel.org>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Bjorn Helgaas" <helgaas@kernel.org>
Subject: Re: [PATCH] PCI: mvebu: Fix the use of the for_each_of_range() iterator
Date: Sun, 07 Sep 2025 11:28:04 +0200	[thread overview]
Message-ID: <34a23816bf125c577a03ba68f251e7a77db9805b.camel@gmail.com> (raw)
In-Reply-To: <hiu2ouj4f7zak2ovtwtigf6fylz4c7fdyyqiqezsddoouzr4n5@bfs7kudjfnp5>

On Wed, 2025-09-03 at 14:44 +0200, Jan Palus wrote:
> 
> Thanks for the patch Klaus! While it does improve situation we're not
> quite there yet. It appears that what used to be stored in `cpuaddr` var
> is also very different from `range.cpu_addr` value so the results
> in both `*tgt` and `*attr` are both wrong.
> 
> Previously `cpuaddr` had a value like ie 0x8e8000000000000 or
> 0x4d0000000000000. Now `range.cpu_addr` is always 0xffffffffffffffff.
> Luckily what used to be stored in `cpuaddr`:
> 
> u64 cpuaddr = of_read_number(range + na, pna)
> 
> appears to be stored in range.pci_bus_addr now. I can't make any
> informed comment about this discrepancy however I can confirm following
> change (in addition to your patch) makes mvebu driver work again (or at
> least like it used to work in 6.15, it still needs Pali's patches to
> have some devices working):
> 
> -			*tgt = DT_CPUADDR_TO_TARGET(range.cpu_addr);
> -			*attr = DT_CPUADDR_TO_ATTR(range.cpu_addr);
> +			*tgt = DT_CPUADDR_TO_TARGET(range.parent_bus_addr);
> +			*attr = DT_CPUADDR_TO_ATTR(range.parent_bus_addr);


Oh well, a CPU address that is not a CPU address....

Looking again at of_range_parser_one() - which I assume to be "correct" here:

	range->flags = parser->bus->get_flags(parser->range);

	range->bus_addr = of_read_number(parser->range + busflag_na, na - busflag_na);

	if (parser->dma)
		range->cpu_addr = of_translate_dma_address(parser->node,
				parser->range + na);
	else
		range->cpu_addr = of_translate_address(parser->node,
				parser->range + na);

	range->parent_bus_addr = of_read_number(parser->range + na, parser->pna);

Indeed, range.cpu_addr is a translated version of range.parent_bus_addr, and does
not seem to be relevant to pci-mvebu.

The driver previously interpreted the raw part of the "/soc/pcie/ranges" resource
(storing it in a local variable called cpuaddr).

To restore the behavior completely, we thus can use range.parent_bus_addr ---
confirming your test.

I'll prepare a patch version 2, including this second fix.

  parent reply	other threads:[~2025-09-07  9:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 15:13 [PATCH] PCI: mvebu: Fix the use of the for_each_of_range() iterator Klaus Kudielka
2025-09-03  1:38 ` Rob Herring
2025-09-03 12:44 ` Jan Palus
2025-09-03 15:29   ` Rob Herring
2025-09-03 17:31     ` Jan Palus
2025-09-07  9:28   ` Klaus Kudielka [this message]
2025-09-03 17:33 ` Jan Palus

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=34a23816bf125c577a03ba68f251e7a77db9805b.camel@gmail.com \
    --to=klaus.kudielka@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=jpalus@fastmail.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=pali@kernel.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