* [RFC PATCH] PCI: rcar: Fix incorrect programming of OB windows
@ 2019-10-04 13:29 Andrew Murray
2019-12-16 12:06 ` Andrew Murray
2020-04-24 11:50 ` Lorenzo Pieralisi
0 siblings, 2 replies; 6+ messages in thread
From: Andrew Murray @ 2019-10-04 13:29 UTC (permalink / raw)
To: Simon Horman, Lorenzo Pieralisi, Phil Edworthy
Cc: linux-pci, linux-renesas-soc
The outbound windows (PCIEPAUR(x), PCIEPALR(x)) describe a mapping between
a CPU address (which is determined by the window number 'x') and a
programmed PCI address - Thus allowing the controller to translate CPU
accesses into PCI accesses.
However the existing code incorrectly writes the CPU address - lets fix
this by writing the PCI address instead.
For memory transactions, existing DT users describe a 1:1 identity mapping
and thus this change should have no effect. However the same isn't true for
I/O.
Fixes: c25da4778803 ("PCI: rcar: Add Renesas R-Car PCIe driver")
Signed-off-by: Andrew Murray <andrew.murray@arm.com>
---
This hasn't been tested, so keen for someone to give it a try.
Also keen for someone to confirm my understanding that the RCar windows
expect PCI addresses and that res->start refers to CPU addresses. If this
is correct then it's possible the I/O doesn't work correctly.
---
drivers/pci/controller/pcie-rcar.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
index f6a669a9af41..b28d726b4aba 100644
--- a/drivers/pci/controller/pcie-rcar.c
+++ b/drivers/pci/controller/pcie-rcar.c
@@ -332,11 +332,12 @@ static struct pci_ops rcar_pcie_ops = {
};
static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
- struct resource *res)
+ struct resource_entry *window)
{
/* Setup PCIe address space mappings for each resource */
resource_size_t size;
resource_size_t res_start;
+ struct resource *res = window->res;
u32 mask;
rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
@@ -350,9 +351,9 @@ static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
if (res->flags & IORESOURCE_IO)
- res_start = pci_pio_to_address(res->start);
+ res_start = pci_pio_to_address(res->start) - window->offset;
else
- res_start = res->start;
+ res_start = res->start - window->offset;
rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win));
rcar_pci_write_reg(pcie, lower_32_bits(res_start) & ~0x7F,
@@ -381,7 +382,7 @@ static int rcar_pcie_setup(struct list_head *resource, struct rcar_pcie *pci)
switch (resource_type(res)) {
case IORESOURCE_IO:
case IORESOURCE_MEM:
- rcar_pcie_setup_window(i, pci, res);
+ rcar_pcie_setup_window(i, pci, win);
i++;
break;
case IORESOURCE_BUS:
--
2.21.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] PCI: rcar: Fix incorrect programming of OB windows
2019-10-04 13:29 [RFC PATCH] PCI: rcar: Fix incorrect programming of OB windows Andrew Murray
@ 2019-12-16 12:06 ` Andrew Murray
2020-02-08 9:46 ` Marek Vasut
2020-04-24 11:50 ` Lorenzo Pieralisi
1 sibling, 1 reply; 6+ messages in thread
From: Andrew Murray @ 2019-12-16 12:06 UTC (permalink / raw)
To: Simon Horman, Lorenzo Pieralisi, Phil Edworthy, Marek Vasut,
Yoshihiro Shimoda
Cc: linux-pci, linux-renesas-soc
On Fri, Oct 04, 2019 at 02:29:41PM +0100, Andrew Murray wrote:
> The outbound windows (PCIEPAUR(x), PCIEPALR(x)) describe a mapping between
> a CPU address (which is determined by the window number 'x') and a
> programmed PCI address - Thus allowing the controller to translate CPU
> accesses into PCI accesses.
>
> However the existing code incorrectly writes the CPU address - lets fix
> this by writing the PCI address instead.
>
> For memory transactions, existing DT users describe a 1:1 identity mapping
> and thus this change should have no effect. However the same isn't true for
> I/O.
>
> Fixes: c25da4778803 ("PCI: rcar: Add Renesas R-Car PCIe driver")
> Signed-off-by: Andrew Murray <andrew.murray@arm.com>
>
> ---
> This hasn't been tested, so keen for someone to give it a try.
>
> Also keen for someone to confirm my understanding that the RCar windows
> expect PCI addresses and that res->start refers to CPU addresses. If this
> is correct then it's possible the I/O doesn't work correctly.
Marek/Yoshihiro - any feedback on this?
Thanks,
Andrew Murray
> ---
> drivers/pci/controller/pcie-rcar.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
> index f6a669a9af41..b28d726b4aba 100644
> --- a/drivers/pci/controller/pcie-rcar.c
> +++ b/drivers/pci/controller/pcie-rcar.c
> @@ -332,11 +332,12 @@ static struct pci_ops rcar_pcie_ops = {
> };
>
> static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
> - struct resource *res)
> + struct resource_entry *window)
> {
> /* Setup PCIe address space mappings for each resource */
> resource_size_t size;
> resource_size_t res_start;
> + struct resource *res = window->res;
> u32 mask;
>
> rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
> @@ -350,9 +351,9 @@ static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
> rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
>
> if (res->flags & IORESOURCE_IO)
> - res_start = pci_pio_to_address(res->start);
> + res_start = pci_pio_to_address(res->start) - window->offset;
> else
> - res_start = res->start;
> + res_start = res->start - window->offset;
>
> rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win));
> rcar_pci_write_reg(pcie, lower_32_bits(res_start) & ~0x7F,
> @@ -381,7 +382,7 @@ static int rcar_pcie_setup(struct list_head *resource, struct rcar_pcie *pci)
> switch (resource_type(res)) {
> case IORESOURCE_IO:
> case IORESOURCE_MEM:
> - rcar_pcie_setup_window(i, pci, res);
> + rcar_pcie_setup_window(i, pci, win);
> i++;
> break;
> case IORESOURCE_BUS:
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] PCI: rcar: Fix incorrect programming of OB windows
2019-12-16 12:06 ` Andrew Murray
@ 2020-02-08 9:46 ` Marek Vasut
2020-02-08 18:41 ` Andrew Murray
0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2020-02-08 9:46 UTC (permalink / raw)
To: Andrew Murray, Simon Horman, Lorenzo Pieralisi, Phil Edworthy,
Marek Vasut, Yoshihiro Shimoda
Cc: linux-pci, linux-renesas-soc
On 12/16/19 1:06 PM, Andrew Murray wrote:
> On Fri, Oct 04, 2019 at 02:29:41PM +0100, Andrew Murray wrote:
>> The outbound windows (PCIEPAUR(x), PCIEPALR(x)) describe a mapping between
>> a CPU address (which is determined by the window number 'x') and a
>> programmed PCI address - Thus allowing the controller to translate CPU
>> accesses into PCI accesses.
>>
>> However the existing code incorrectly writes the CPU address - lets fix
>> this by writing the PCI address instead.
>>
>> For memory transactions, existing DT users describe a 1:1 identity mapping
>> and thus this change should have no effect. However the same isn't true for
>> I/O.
>>
>> Fixes: c25da4778803 ("PCI: rcar: Add Renesas R-Car PCIe driver")
>> Signed-off-by: Andrew Murray <andrew.murray@arm.com>
>>
>> ---
>> This hasn't been tested, so keen for someone to give it a try.
>>
>> Also keen for someone to confirm my understanding that the RCar windows
>> expect PCI addresses and that res->start refers to CPU addresses. If this
>> is correct then it's possible the I/O doesn't work correctly.
>
> Marek/Yoshihiro - any feedback on this?
It does indeed look correct,
Reviewed-by: Marek Vasut <marek.vasut+renesas@gmail.com>
# On R8A77951 Salvator-XS with Intel 8086:f1a5 600P SSD
# On R8A77965 Salvator-XS with Intel 8086:10d3 82574L NIC
Tested-by: Marek Vasut <marek.vasut+renesas@gmail.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] PCI: rcar: Fix incorrect programming of OB windows
2020-02-08 9:46 ` Marek Vasut
@ 2020-02-08 18:41 ` Andrew Murray
2020-04-11 17:27 ` Marek Vasut
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Murray @ 2020-02-08 18:41 UTC (permalink / raw)
To: Marek Vasut
Cc: Andrew Murray, Simon Horman, Lorenzo Pieralisi, Phil Edworthy,
Marek Vasut, Yoshihiro Shimoda, linux-pci, linux-renesas-soc
On Sat, Feb 08, 2020 at 10:46:25AM +0100, Marek Vasut wrote:
> On 12/16/19 1:06 PM, Andrew Murray wrote:
> > On Fri, Oct 04, 2019 at 02:29:41PM +0100, Andrew Murray wrote:
> >> The outbound windows (PCIEPAUR(x), PCIEPALR(x)) describe a mapping between
> >> a CPU address (which is determined by the window number 'x') and a
> >> programmed PCI address - Thus allowing the controller to translate CPU
> >> accesses into PCI accesses.
> >>
> >> However the existing code incorrectly writes the CPU address - lets fix
> >> this by writing the PCI address instead.
> >>
> >> For memory transactions, existing DT users describe a 1:1 identity mapping
> >> and thus this change should have no effect. However the same isn't true for
> >> I/O.
> >>
> >> Fixes: c25da4778803 ("PCI: rcar: Add Renesas R-Car PCIe driver")
> >> Signed-off-by: Andrew Murray <andrew.murray@arm.com>
> >>
> >> ---
> >> This hasn't been tested, so keen for someone to give it a try.
> >>
> >> Also keen for someone to confirm my understanding that the RCar windows
> >> expect PCI addresses and that res->start refers to CPU addresses. If this
> >> is correct then it's possible the I/O doesn't work correctly.
> >
> > Marek/Yoshihiro - any feedback on this?
>
> It does indeed look correct,
> Reviewed-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> # On R8A77951 Salvator-XS with Intel 8086:f1a5 600P SSD
> # On R8A77965 Salvator-XS with Intel 8086:10d3 82574L NIC
> Tested-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Thanks for testing - much appreciated!
Andrew Murray
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] PCI: rcar: Fix incorrect programming of OB windows
2020-02-08 18:41 ` Andrew Murray
@ 2020-04-11 17:27 ` Marek Vasut
0 siblings, 0 replies; 6+ messages in thread
From: Marek Vasut @ 2020-04-11 17:27 UTC (permalink / raw)
To: Andrew Murray
Cc: Andrew Murray, Simon Horman, Lorenzo Pieralisi, Phil Edworthy,
Marek Vasut, Yoshihiro Shimoda, linux-pci, linux-renesas-soc,
Bjorn Helgaas
On 2/8/20 7:41 PM, Andrew Murray wrote:
> On Sat, Feb 08, 2020 at 10:46:25AM +0100, Marek Vasut wrote:
>> On 12/16/19 1:06 PM, Andrew Murray wrote:
>>> On Fri, Oct 04, 2019 at 02:29:41PM +0100, Andrew Murray wrote:
>>>> The outbound windows (PCIEPAUR(x), PCIEPALR(x)) describe a mapping between
>>>> a CPU address (which is determined by the window number 'x') and a
>>>> programmed PCI address - Thus allowing the controller to translate CPU
>>>> accesses into PCI accesses.
>>>>
>>>> However the existing code incorrectly writes the CPU address - lets fix
>>>> this by writing the PCI address instead.
>>>>
>>>> For memory transactions, existing DT users describe a 1:1 identity mapping
>>>> and thus this change should have no effect. However the same isn't true for
>>>> I/O.
>>>>
>>>> Fixes: c25da4778803 ("PCI: rcar: Add Renesas R-Car PCIe driver")
>>>> Signed-off-by: Andrew Murray <andrew.murray@arm.com>
>>>>
>>>> ---
>>>> This hasn't been tested, so keen for someone to give it a try.
>>>>
>>>> Also keen for someone to confirm my understanding that the RCar windows
>>>> expect PCI addresses and that res->start refers to CPU addresses. If this
>>>> is correct then it's possible the I/O doesn't work correctly.
>>>
>>> Marek/Yoshihiro - any feedback on this?
>>
>> It does indeed look correct,
>> Reviewed-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>>
>> # On R8A77951 Salvator-XS with Intel 8086:f1a5 600P SSD
>> # On R8A77965 Salvator-XS with Intel 8086:10d3 82574L NIC
>> Tested-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> Thanks for testing - much appreciated!
>
> Andrew Murray
Can this be applied then ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] PCI: rcar: Fix incorrect programming of OB windows
2019-10-04 13:29 [RFC PATCH] PCI: rcar: Fix incorrect programming of OB windows Andrew Murray
2019-12-16 12:06 ` Andrew Murray
@ 2020-04-24 11:50 ` Lorenzo Pieralisi
1 sibling, 0 replies; 6+ messages in thread
From: Lorenzo Pieralisi @ 2020-04-24 11:50 UTC (permalink / raw)
To: Andrew Murray; +Cc: Simon Horman, Phil Edworthy, linux-pci, linux-renesas-soc
On Fri, Oct 04, 2019 at 02:29:41PM +0100, Andrew Murray wrote:
> The outbound windows (PCIEPAUR(x), PCIEPALR(x)) describe a mapping between
> a CPU address (which is determined by the window number 'x') and a
> programmed PCI address - Thus allowing the controller to translate CPU
> accesses into PCI accesses.
>
> However the existing code incorrectly writes the CPU address - lets fix
> this by writing the PCI address instead.
>
> For memory transactions, existing DT users describe a 1:1 identity mapping
> and thus this change should have no effect. However the same isn't true for
> I/O.
>
> Fixes: c25da4778803 ("PCI: rcar: Add Renesas R-Car PCIe driver")
> Signed-off-by: Andrew Murray <andrew.murray@arm.com>
>
> ---
> This hasn't been tested, so keen for someone to give it a try.
>
> Also keen for someone to confirm my understanding that the RCar windows
> expect PCI addresses and that res->start refers to CPU addresses. If this
> is correct then it's possible the I/O doesn't work correctly.
> ---
> drivers/pci/controller/pcie-rcar.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
Applied to pci/rcar, thanks !
Lorenzo
> diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
> index f6a669a9af41..b28d726b4aba 100644
> --- a/drivers/pci/controller/pcie-rcar.c
> +++ b/drivers/pci/controller/pcie-rcar.c
> @@ -332,11 +332,12 @@ static struct pci_ops rcar_pcie_ops = {
> };
>
> static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
> - struct resource *res)
> + struct resource_entry *window)
> {
> /* Setup PCIe address space mappings for each resource */
> resource_size_t size;
> resource_size_t res_start;
> + struct resource *res = window->res;
> u32 mask;
>
> rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
> @@ -350,9 +351,9 @@ static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie,
> rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
>
> if (res->flags & IORESOURCE_IO)
> - res_start = pci_pio_to_address(res->start);
> + res_start = pci_pio_to_address(res->start) - window->offset;
> else
> - res_start = res->start;
> + res_start = res->start - window->offset;
>
> rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win));
> rcar_pci_write_reg(pcie, lower_32_bits(res_start) & ~0x7F,
> @@ -381,7 +382,7 @@ static int rcar_pcie_setup(struct list_head *resource, struct rcar_pcie *pci)
> switch (resource_type(res)) {
> case IORESOURCE_IO:
> case IORESOURCE_MEM:
> - rcar_pcie_setup_window(i, pci, res);
> + rcar_pcie_setup_window(i, pci, win);
> i++;
> break;
> case IORESOURCE_BUS:
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-04-24 11:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 13:29 [RFC PATCH] PCI: rcar: Fix incorrect programming of OB windows Andrew Murray
2019-12-16 12:06 ` Andrew Murray
2020-02-08 9:46 ` Marek Vasut
2020-02-08 18:41 ` Andrew Murray
2020-04-11 17:27 ` Marek Vasut
2020-04-24 11:50 ` Lorenzo Pieralisi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).