All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cxl: use correct operator when writing pcie config space values
@ 2015-11-04  2:24 Andrew Donnellan
  2015-11-04  4:07 ` Ian Munsie
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Andrew Donnellan @ 2015-11-04  2:24 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mikey, imunsie

When writing a value to config space, cxl_pcie_write_config() calls
cxl_pcie_config_info() to obtain a mask and shift value, shifts the new
value accordingly, then uses the mask to combine the shifted value with the
existing value at the address as part of a read-modify-write pattern.

Currently, we use a logical OR operator rather than a bitwise OR operator,
which means any use of this function results in an incorrect value being
written. Replace the logical OR operator with a bitwise OR operator so the
value is written correctly.

Reported-by: Michael Ellerman <mpe@ellerman.id.au>
Cc: stable@vger.kernel.org
Fixes: 6f7f0b3df6d4 ("cxl: Add AFU virtual PHB and kernel API")
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---
 drivers/misc/cxl/vphb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
index 94b5208..9be09bb 100644
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -203,7 +203,7 @@ static int cxl_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
 	mask <<= shift;
 	val <<= shift;
 
-	v = (in_le32(ioaddr) & ~mask) || (val & mask);
+	v = (in_le32(ioaddr) & ~mask) | (val & mask);
 
 	out_le32(ioaddr, v);
 	return PCIBIOS_SUCCESSFUL;
-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] cxl: use correct operator when writing pcie config space values
  2015-11-04  2:24 [PATCH] cxl: use correct operator when writing pcie config space values Andrew Donnellan
@ 2015-11-04  4:07 ` Ian Munsie
  2015-11-05 23:05 ` Daniel Axtens
  2015-11-26 12:15 ` Michael Ellerman
  2 siblings, 0 replies; 9+ messages in thread
From: Ian Munsie @ 2015-11-04  4:07 UTC (permalink / raw)
  To: andrew.donnellan; +Cc: linuxppc-dev, mikey

Acked-by: Ian Munsie <imunsie@au1.ibm.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] cxl: use correct operator when writing pcie config space values
  2015-11-04  2:24 [PATCH] cxl: use correct operator when writing pcie config space values Andrew Donnellan
  2015-11-04  4:07 ` Ian Munsie
@ 2015-11-05 23:05 ` Daniel Axtens
  2015-11-05 23:17   ` Michael Neuling
                     ` (2 more replies)
  2015-11-26 12:15 ` Michael Ellerman
  2 siblings, 3 replies; 9+ messages in thread
From: Daniel Axtens @ 2015-11-05 23:05 UTC (permalink / raw)
  To: Andrew Donnellan, linuxppc-dev; +Cc: mikey, imunsie

[-- Attachment #1: Type: text/plain, Size: 1944 bytes --]

Andrew Donnellan <andrew.donnellan@au1.ibm.com> writes:

> When writing a value to config space, cxl_pcie_write_config() calls
> cxl_pcie_config_info() to obtain a mask and shift value, shifts the new
> value accordingly, then uses the mask to combine the shifted value with the
> existing value at the address as part of a read-modify-write pattern.
>
> Currently, we use a logical OR operator rather than a bitwise OR operator,
> which means any use of this function results in an incorrect value being
> written. Replace the logical OR operator with a bitwise OR operator so the
> value is written correctly.
>
> Reported-by: Michael Ellerman <mpe@ellerman.id.au>
> Cc: stable@vger.kernel.org

Given that there are no current users of this function, does this need
to go to stable? Does it actually fix a real (as opposed to theoretical)
bug?

Regards,
Daniel

> Fixes: 6f7f0b3df6d4 ("cxl: Add AFU virtual PHB and kernel API")
> Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> ---
>  drivers/misc/cxl/vphb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
> index 94b5208..9be09bb 100644
> --- a/drivers/misc/cxl/vphb.c
> +++ b/drivers/misc/cxl/vphb.c
> @@ -203,7 +203,7 @@ static int cxl_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
>  	mask <<= shift;
>  	val <<= shift;
>  
> -	v = (in_le32(ioaddr) & ~mask) || (val & mask);
> +	v = (in_le32(ioaddr) & ~mask) | (val & mask);
>  
>  	out_le32(ioaddr, v);
>  	return PCIBIOS_SUCCESSFUL;
> -- 
> Andrew Donnellan              Software Engineer, OzLabs
> andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
> +61 2 6201 8874 (work)        IBM Australia Limited
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 859 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] cxl: use correct operator when writing pcie config space values
  2015-11-05 23:05 ` Daniel Axtens
@ 2015-11-05 23:17   ` Michael Neuling
  2015-11-05 23:17   ` Andrew Donnellan
  2015-11-05 23:43   ` Michael Ellerman
  2 siblings, 0 replies; 9+ messages in thread
From: Michael Neuling @ 2015-11-05 23:17 UTC (permalink / raw)
  To: Daniel Axtens, Andrew Donnellan, linuxppc-dev; +Cc: imunsie

On Fri, 2015-11-06 at 10:05 +1100, Daniel Axtens wrote:
> Andrew Donnellan <andrew.donnellan@au1.ibm.com> writes:
>=20
> > When writing a value to config space, cxl_pcie_write_config() calls
> > cxl_pcie_config_info() to obtain a mask and shift value, shifts the
> > new
> > value accordingly, then uses the mask to combine the shifted value
> > with the
> > existing value at the address as part of a read-modify-write
> > pattern.
> >=20
> > Currently, we use a logical OR operator rather than a bitwise OR
> > operator,
> > which means any use of this function results in an incorrect value
> > being
> > written. Replace the logical OR operator with a bitwise OR operator
> > so the
> > value is written correctly.
> >=20
> > Reported-by: Michael Ellerman <mpe@ellerman.id.au>
> > Cc: stable@vger.kernel.org
>=20
> Given that there are no current users of this function, does this
> need
> to go to stable? Does it actually fix a real (as opposed to
> theoretical)
> bug?

Agreed.  Not really needed in stable.

Mikey

>=20
> Regards,
> Daniel
>=20
> > Fixes: 6f7f0b3df6d4 ("cxl: Add AFU virtual PHB and kernel API")
> > Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> > ---
> >  drivers/misc/cxl/vphb.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >=20
> > diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
> > index 94b5208..9be09bb 100644
> > --- a/drivers/misc/cxl/vphb.c
> > +++ b/drivers/misc/cxl/vphb.c
> > @@ -203,7 +203,7 @@ static int cxl_pcie_write_config(struct pci_bus
> > *bus, unsigned int devfn,
> >  	mask <<=3D shift;
> >  	val <<=3D shift;
> > =20
> > -	v =3D (in_le32(ioaddr) & ~mask) || (val & mask);
> > +	v =3D (in_le32(ioaddr) & ~mask) | (val & mask);
> > =20
> >  	out_le32(ioaddr, v);
> >  	return PCIBIOS_SUCCESSFUL;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] cxl: use correct operator when writing pcie config space values
  2015-11-05 23:05 ` Daniel Axtens
  2015-11-05 23:17   ` Michael Neuling
@ 2015-11-05 23:17   ` Andrew Donnellan
  2015-11-05 23:43   ` Michael Ellerman
  2 siblings, 0 replies; 9+ messages in thread
From: Andrew Donnellan @ 2015-11-05 23:17 UTC (permalink / raw)
  To: Daniel Axtens, linuxppc-dev; +Cc: mikey, imunsie

On 06/11/15 10:05, Daniel Axtens wrote:
> Given that there are no current users of this function, does this need
> to go to stable? Does it actually fix a real (as opposed to theoretical)
> bug?

I tagged it for stable on mpe's request - I'm not fussed either way.


Andrew

-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] cxl: use correct operator when writing pcie config space values
  2015-11-05 23:05 ` Daniel Axtens
  2015-11-05 23:17   ` Michael Neuling
  2015-11-05 23:17   ` Andrew Donnellan
@ 2015-11-05 23:43   ` Michael Ellerman
  2015-11-09  6:45     ` Andrew Donnellan
  2 siblings, 1 reply; 9+ messages in thread
From: Michael Ellerman @ 2015-11-05 23:43 UTC (permalink / raw)
  To: Daniel Axtens, Andrew Donnellan, linuxppc-dev; +Cc: mikey, imunsie

On Fri, 2015-11-06 at 10:05 +1100, Daniel Axtens wrote:

> Andrew Donnellan <andrew.donnellan@au1.ibm.com> writes:
> 

> > When writing a value to config space, cxl_pcie_write_config() calls
> > cxl_pcie_config_info() to obtain a mask and shift value, shifts the new
> > value accordingly, then uses the mask to combine the shifted value with the
> > existing value at the address as part of a read-modify-write pattern.
> > 
> > Currently, we use a logical OR operator rather than a bitwise OR operator,
> > which means any use of this function results in an incorrect value being
> > written. Replace the logical OR operator with a bitwise OR operator so the
> > value is written correctly.
> > 
> > Reported-by: Michael Ellerman <mpe@ellerman.id.au>
> > Cc: stable@vger.kernel.org
> 
> Given that there are no current users of this function, does this need
> to go to stable? Does it actually fix a real (as opposed to theoretical)
> bug?

If it's unused *and* broken then we should just remove it.

cheers

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] cxl: use correct operator when writing pcie config space values
  2015-11-05 23:43   ` Michael Ellerman
@ 2015-11-09  6:45     ` Andrew Donnellan
  2015-11-12  2:26       ` Daniel Axtens
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Donnellan @ 2015-11-09  6:45 UTC (permalink / raw)
  To: Michael Ellerman, Daniel Axtens, linuxppc-dev; +Cc: mikey, imunsie

On 06/11/15 10:43, Michael Ellerman wrote:
> If it's unused *and* broken then we should just remove it.

Following some discussion with Ian and Vaibhav, we'd like to keep it at 
this stage - while there are no current AFUs which write to AFU config 
space, it would be reasonable for an AFU developer to assume that AFU 
config space is writable, and I am led to believe there is nothing in 
the publicly available documentation that would suggest otherwise.

Ian is working on obtaining a test AFU with support for this, at which 
point we will add it to our internal test suite.

As such I'd like to continue with the patch as is, I'm happy to drop the 
stable Cc though.


Andrew

-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] cxl: use correct operator when writing pcie config space values
  2015-11-09  6:45     ` Andrew Donnellan
@ 2015-11-12  2:26       ` Daniel Axtens
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Axtens @ 2015-11-12  2:26 UTC (permalink / raw)
  To: Andrew Donnellan, Michael Ellerman, linuxppc-dev; +Cc: mikey, imunsie

Andrew Donnellan <andrew.donnellan@au1.ibm.com> writes:

> On 06/11/15 10:43, Michael Ellerman wrote:
>> If it's unused *and* broken then we should just remove it.
>
> Following some discussion with Ian and Vaibhav, we'd like to keep it at 
> this stage - while there are no current AFUs which write to AFU config 
> space, it would be reasonable for an AFU developer to assume that AFU 
> config space is writable, and I am led to believe there is nothing in 
> the publicly available documentation that would suggest otherwise.
>
> Ian is working on obtaining a test AFU with support for this, at which 
> point we will add it to our internal test suite.
>
> As such I'd like to continue with the patch as is, I'm happy to drop the 
> stable Cc though.

Sounds good to me.

Regards,
Daniel

>
>
> Andrew
>
> -- 
> Andrew Donnellan              Software Engineer, OzLabs
> andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
> +61 2 6201 8874 (work)        IBM Australia Limited

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: cxl: use correct operator when writing pcie config space values
  2015-11-04  2:24 [PATCH] cxl: use correct operator when writing pcie config space values Andrew Donnellan
  2015-11-04  4:07 ` Ian Munsie
  2015-11-05 23:05 ` Daniel Axtens
@ 2015-11-26 12:15 ` Michael Ellerman
  2 siblings, 0 replies; 9+ messages in thread
From: Michael Ellerman @ 2015-11-26 12:15 UTC (permalink / raw)
  To: Andrew Donnellan, linuxppc-dev; +Cc: mikey, imunsie

On Wed, 2015-04-11 at 02:24:09 UTC, Andrew Donnellan wrote:
> When writing a value to config space, cxl_pcie_write_config() calls
> cxl_pcie_config_info() to obtain a mask and shift value, shifts the new
> value accordingly, then uses the mask to combine the shifted value with the
> existing value at the address as part of a read-modify-write pattern.
> 
> Currently, we use a logical OR operator rather than a bitwise OR operator,
> which means any use of this function results in an incorrect value being
> written. Replace the logical OR operator with a bitwise OR operator so the
> value is written correctly.
> 
> Reported-by: Michael Ellerman <mpe@ellerman.id.au>
> Cc: stable@vger.kernel.org
> Fixes: 6f7f0b3df6d4 ("cxl: Add AFU virtual PHB and kernel API")
> Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> Acked-by: Ian Munsie <imunsie@au1.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/48f0f6b717e314a30be121b6

cheers

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-11-26 12:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-04  2:24 [PATCH] cxl: use correct operator when writing pcie config space values Andrew Donnellan
2015-11-04  4:07 ` Ian Munsie
2015-11-05 23:05 ` Daniel Axtens
2015-11-05 23:17   ` Michael Neuling
2015-11-05 23:17   ` Andrew Donnellan
2015-11-05 23:43   ` Michael Ellerman
2015-11-09  6:45     ` Andrew Donnellan
2015-11-12  2:26       ` Daniel Axtens
2015-11-26 12:15 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.