2020-02-08 18:37:52

by Prabhakar

[permalink] [raw]
Subject: [PATCH v4 2/6] PCI: rcar: Fix calculating mask for PCIEPAMR register

The mask value was calculated incorrectly for PCIEPAMR register if the
size was less the 128bytes, this patch fixes the above by adding a check
on size.

Signed-off-by: Lad Prabhakar <[email protected]>
---
drivers/pci/controller/pcie-rcar.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
index d5568db..c76a92a 100644
--- a/drivers/pci/controller/pcie-rcar.c
+++ b/drivers/pci/controller/pcie-rcar.c
@@ -71,7 +71,7 @@ void rcar_pcie_set_outbound(int win, void __iomem *base,
/* Setup PCIe address space mappings for each resource */
resource_size_t res_start;
resource_size_t size;
- u32 mask;
+ u32 mask = 0x0;

rcar_pci_write_reg(base, 0x00000000, PCIEPTCTLR(win));

@@ -80,7 +80,8 @@ void rcar_pcie_set_outbound(int win, void __iomem *base,
* keeps things pretty simple.
*/
size = resource_size(res);
- mask = (roundup_pow_of_two(size) / SZ_128) - 1;
+ if (size > 128)
+ mask = (roundup_pow_of_two(size) / SZ_128) - 1;
rcar_pci_write_reg(base, mask << 7, PCIEPAMR(win));

if (!host) {
--
2.7.4


2020-02-08 19:08:00

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH v4 2/6] PCI: rcar: Fix calculating mask for PCIEPAMR register

Hello!

On 02/08/2020 09:36 PM, Lad Prabhakar wrote:

> The mask value was calculated incorrectly for PCIEPAMR register if the
> size was less the 128bytes, this patch fixes the above by adding a check

Less than, perhaps?

> on size.
>
> Signed-off-by: Lad Prabhakar <[email protected]>
[...]

MBR, Sergei

2020-02-08 19:17:28

by Prabhakar

[permalink] [raw]
Subject: Re: [PATCH v4 2/6] PCI: rcar: Fix calculating mask for PCIEPAMR register

Hi Sergei,

Thank you for the review.

On Sat, Feb 8, 2020 at 7:07 PM Sergei Shtylyov
<[email protected]> wrote:
>
> Hello!
>
> On 02/08/2020 09:36 PM, Lad Prabhakar wrote:
>
> > The mask value was calculated incorrectly for PCIEPAMR register if the
> > size was less the 128bytes, this patch fixes the above by adding a check
>
> Less than, perhaps?
>
Oops shall fix that.

Cheers,
--Prabhakar Lad

> > on size.
> >
> > Signed-off-by: Lad Prabhakar <[email protected]>
> [...]
>
> MBR, Sergei

2020-02-12 14:06:11

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH v4 2/6] PCI: rcar: Fix calculating mask for PCIEPAMR register

On Sat, Feb 08, 2020 at 06:36:37PM +0000, Lad Prabhakar wrote:
> The mask value was calculated incorrectly for PCIEPAMR register if the
> size was less the 128bytes, this patch fixes the above by adding a check
> on size.

s/less the/less than/
s/128bytes,/128 bytes./
s/this patch fixes the above/Fix this issue/

> Signed-off-by: Lad Prabhakar <[email protected]>
> ---
> drivers/pci/controller/pcie-rcar.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
> index d5568db..c76a92a 100644
> --- a/drivers/pci/controller/pcie-rcar.c
> +++ b/drivers/pci/controller/pcie-rcar.c
> @@ -71,7 +71,7 @@ void rcar_pcie_set_outbound(int win, void __iomem *base,
> /* Setup PCIe address space mappings for each resource */
> resource_size_t res_start;
> resource_size_t size;
> - u32 mask;
> + u32 mask = 0x0;
>
> rcar_pci_write_reg(base, 0x00000000, PCIEPTCTLR(win));
>
> @@ -80,7 +80,8 @@ void rcar_pcie_set_outbound(int win, void __iomem *base,
> * keeps things pretty simple.
> */
> size = resource_size(res);
> - mask = (roundup_pow_of_two(size) / SZ_128) - 1;
> + if (size > 128)
> + mask = (roundup_pow_of_two(size) / SZ_128) - 1;

I would put the "mask = 0x0" right here so it's all in one place,
i.e.,

if (size > 128)
mask = (roundup_pow_of_two(size) / SZ_128) - 1;
else
mask = 0x0;

> rcar_pci_write_reg(base, mask << 7, PCIEPAMR(win));
>
> if (!host) {
> --
> 2.7.4
>

2020-02-19 08:48:33

by Prabhakar

[permalink] [raw]
Subject: Re: [PATCH v4 2/6] PCI: rcar: Fix calculating mask for PCIEPAMR register

Hi Bjorn,

Thank you for the review.

On Wed, Feb 12, 2020 at 2:04 PM Bjorn Helgaas <[email protected]> wrote:
>
> On Sat, Feb 08, 2020 at 06:36:37PM +0000, Lad Prabhakar wrote:
> > The mask value was calculated incorrectly for PCIEPAMR register if the
> > size was less the 128bytes, this patch fixes the above by adding a check
> > on size.
>
> s/less the/less than/
> s/128bytes,/128 bytes./
> s/this patch fixes the above/Fix this issue/
>
My bad will fix that.

> > Signed-off-by: Lad Prabhakar <[email protected]>
> > ---
> > drivers/pci/controller/pcie-rcar.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c
> > index d5568db..c76a92a 100644
> > --- a/drivers/pci/controller/pcie-rcar.c
> > +++ b/drivers/pci/controller/pcie-rcar.c
> > @@ -71,7 +71,7 @@ void rcar_pcie_set_outbound(int win, void __iomem *base,
> > /* Setup PCIe address space mappings for each resource */
> > resource_size_t res_start;
> > resource_size_t size;
> > - u32 mask;
> > + u32 mask = 0x0;
> >
> > rcar_pci_write_reg(base, 0x00000000, PCIEPTCTLR(win));
> >
> > @@ -80,7 +80,8 @@ void rcar_pcie_set_outbound(int win, void __iomem *base,
> > * keeps things pretty simple.
> > */
> > size = resource_size(res);
> > - mask = (roundup_pow_of_two(size) / SZ_128) - 1;
> > + if (size > 128)
> > + mask = (roundup_pow_of_two(size) / SZ_128) - 1;
>
> I would put the "mask = 0x0" right here so it's all in one place,
> i.e.,
>
> if (size > 128)
> mask = (roundup_pow_of_two(size) / SZ_128) - 1;
> else
> mask = 0x0;
>
Sure will change that.

Cheers,
--Prabhakar Lad

> > rcar_pci_write_reg(base, mask << 7, PCIEPAMR(win));
> >
> > if (!host) {
> > --
> > 2.7.4
> >