All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ocxl: Fix endiannes bug in read_afu_name()
@ 2018-12-11 17:58 ` Greg Kurz
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kurz @ 2018-12-11 17:58 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Michael Ellerman, Frederic Barrat, Christophe Lombard,
	Andrew Donnellan, stable, Vaibhav Jain

The AFU Descriptor Template in the PCI config space has a Name Space
field which is a 24 Byte ASCII character string of descriptive name
space for the AFU. The OCXL driver read the string four characters at
a time with pci_read_config_dword().

This optimization is valid on a little-endian system since this is PCI,
but a big-endian system ends up with each subset of four characters in
reverse order.

This could be fixed by switching to read characters one by one. Another
option is to swap the bytes if we're big-endian.

Go for the latter with le32_to_cpu().

Cc: stable@vger.kernel.org      # v4.16
Signed-off-by: Greg Kurz <groug@kaod.org>
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
v2: - silence sparse with (__force __le32) cast
    - new changelog
---
 drivers/misc/ocxl/config.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
index 57a6bb1fd3c9..8f2c5d8bd2ee 100644
--- a/drivers/misc/ocxl/config.c
+++ b/drivers/misc/ocxl/config.c
@@ -318,7 +318,7 @@ static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
 		if (rc)
 			return rc;
 		ptr = (u32 *) &afu->name[i];
-		*ptr = val;
+		*ptr = le32_to_cpu((__force __le32) val);
 	}
 	afu->name[OCXL_AFU_NAME_SZ - 1] = '\0'; /* play safe */
 	return 0;

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

* [PATCH v2] ocxl: Fix endiannes bug in read_afu_name()
@ 2018-12-11 17:58 ` Greg Kurz
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kurz @ 2018-12-11 17:58 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Christophe Lombard, Vaibhav Jain, stable, Frederic Barrat,
	Andrew Donnellan

The AFU Descriptor Template in the PCI config space has a Name Space
field which is a 24 Byte ASCII character string of descriptive name
space for the AFU. The OCXL driver read the string four characters at
a time with pci_read_config_dword().

This optimization is valid on a little-endian system since this is PCI,
but a big-endian system ends up with each subset of four characters in
reverse order.

This could be fixed by switching to read characters one by one. Another
option is to swap the bytes if we're big-endian.

Go for the latter with le32_to_cpu().

Cc: stable@vger.kernel.org      # v4.16
Signed-off-by: Greg Kurz <groug@kaod.org>
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
v2: - silence sparse with (__force __le32) cast
    - new changelog
---
 drivers/misc/ocxl/config.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
index 57a6bb1fd3c9..8f2c5d8bd2ee 100644
--- a/drivers/misc/ocxl/config.c
+++ b/drivers/misc/ocxl/config.c
@@ -318,7 +318,7 @@ static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
 		if (rc)
 			return rc;
 		ptr = (u32 *) &afu->name[i];
-		*ptr = val;
+		*ptr = le32_to_cpu((__force __le32) val);
 	}
 	afu->name[OCXL_AFU_NAME_SZ - 1] = '\0'; /* play safe */
 	return 0;


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

* Re: [PATCH v2] ocxl: Fix endiannes bug in read_afu_name()
  2018-12-11 17:58 ` Greg Kurz
@ 2018-12-12  2:26   ` Andrew Donnellan
  -1 siblings, 0 replies; 7+ messages in thread
From: Andrew Donnellan @ 2018-12-12  2:26 UTC (permalink / raw)
  To: Greg Kurz, linuxppc-dev
  Cc: Michael Ellerman, Frederic Barrat, Christophe Lombard, stable,
	Vaibhav Jain

On 12/12/18 4:58 am, Greg Kurz wrote:
> The AFU Descriptor Template in the PCI config space has a Name Space
> field which is a 24 Byte ASCII character string of descriptive name
> space for the AFU. The OCXL driver read the string four characters at
> a time with pci_read_config_dword().
> 
> This optimization is valid on a little-endian system since this is PCI,
> but a big-endian system ends up with each subset of four characters in
> reverse order.
> 
> This could be fixed by switching to read characters one by one. Another
> option is to swap the bytes if we're big-endian.
> 
> Go for the latter with le32_to_cpu().
> 
> Cc: stable@vger.kernel.org      # v4.16
> Signed-off-by: Greg Kurz <groug@kaod.org>
> Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>

Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

> ---
> v2: - silence sparse with (__force __le32) cast
>      - new changelog
> ---
>   drivers/misc/ocxl/config.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
> index 57a6bb1fd3c9..8f2c5d8bd2ee 100644
> --- a/drivers/misc/ocxl/config.c
> +++ b/drivers/misc/ocxl/config.c
> @@ -318,7 +318,7 @@ static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
>   		if (rc)
>   			return rc;
>   		ptr = (u32 *) &afu->name[i];
> -		*ptr = val;
> +		*ptr = le32_to_cpu((__force __le32) val);
>   	}
>   	afu->name[OCXL_AFU_NAME_SZ - 1] = '\0'; /* play safe */
>   	return 0;
> 

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

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

* Re: [PATCH v2] ocxl: Fix endiannes bug in read_afu_name()
@ 2018-12-12  2:26   ` Andrew Donnellan
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Donnellan @ 2018-12-12  2:26 UTC (permalink / raw)
  To: Greg Kurz, linuxppc-dev
  Cc: stable, Christophe Lombard, Frederic Barrat, Vaibhav Jain

On 12/12/18 4:58 am, Greg Kurz wrote:
> The AFU Descriptor Template in the PCI config space has a Name Space
> field which is a 24 Byte ASCII character string of descriptive name
> space for the AFU. The OCXL driver read the string four characters at
> a time with pci_read_config_dword().
> 
> This optimization is valid on a little-endian system since this is PCI,
> but a big-endian system ends up with each subset of four characters in
> reverse order.
> 
> This could be fixed by switching to read characters one by one. Another
> option is to swap the bytes if we're big-endian.
> 
> Go for the latter with le32_to_cpu().
> 
> Cc: stable@vger.kernel.org      # v4.16
> Signed-off-by: Greg Kurz <groug@kaod.org>
> Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>

Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

> ---
> v2: - silence sparse with (__force __le32) cast
>      - new changelog
> ---
>   drivers/misc/ocxl/config.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
> index 57a6bb1fd3c9..8f2c5d8bd2ee 100644
> --- a/drivers/misc/ocxl/config.c
> +++ b/drivers/misc/ocxl/config.c
> @@ -318,7 +318,7 @@ static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
>   		if (rc)
>   			return rc;
>   		ptr = (u32 *) &afu->name[i];
> -		*ptr = val;
> +		*ptr = le32_to_cpu((__force __le32) val);
>   	}
>   	afu->name[OCXL_AFU_NAME_SZ - 1] = '\0'; /* play safe */
>   	return 0;
> 

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited


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

* Re: [PATCH v2] ocxl: Fix endiannes bug in read_afu_name()
  2018-12-12  2:26   ` Andrew Donnellan
@ 2018-12-20 14:53     ` Greg Kurz
  -1 siblings, 0 replies; 7+ messages in thread
From: Greg Kurz @ 2018-12-20 14:53 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linuxppc-dev, stable, Christophe Lombard, Frederic Barrat,
	Vaibhav Jain, Andrew Donnellan

On Wed, 12 Dec 2018 13:26:10 +1100
Andrew Donnellan <andrew.donnellan@au1.ibm.com> wrote:

> On 12/12/18 4:58 am, Greg Kurz wrote:
> > The AFU Descriptor Template in the PCI config space has a Name Space
> > field which is a 24 Byte ASCII character string of descriptive name
> > space for the AFU. The OCXL driver read the string four characters at
> > a time with pci_read_config_dword().
> > 
> > This optimization is valid on a little-endian system since this is PCI,
> > but a big-endian system ends up with each subset of four characters in
> > reverse order.
> > 
> > This could be fixed by switching to read characters one by one. Another
> > option is to swap the bytes if we're big-endian.
> > 
> > Go for the latter with le32_to_cpu().
> > 
> > Cc: stable@vger.kernel.org      # v4.16
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>  
> 
> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> 

Friendly ping before Xmas break :)

> > ---
> > v2: - silence sparse with (__force __le32) cast
> >      - new changelog
> > ---
> >   drivers/misc/ocxl/config.c |    2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
> > index 57a6bb1fd3c9..8f2c5d8bd2ee 100644
> > --- a/drivers/misc/ocxl/config.c
> > +++ b/drivers/misc/ocxl/config.c
> > @@ -318,7 +318,7 @@ static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
> >   		if (rc)
> >   			return rc;
> >   		ptr = (u32 *) &afu->name[i];
> > -		*ptr = val;
> > +		*ptr = le32_to_cpu((__force __le32) val);
> >   	}
> >   	afu->name[OCXL_AFU_NAME_SZ - 1] = '\0'; /* play safe */
> >   	return 0;
> >   
> 

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

* Re: [PATCH v2] ocxl: Fix endiannes bug in read_afu_name()
@ 2018-12-20 14:53     ` Greg Kurz
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kurz @ 2018-12-20 14:53 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Christophe Lombard, Vaibhav Jain, Frederic Barrat, stable,
	Andrew Donnellan, linuxppc-dev

On Wed, 12 Dec 2018 13:26:10 +1100
Andrew Donnellan <andrew.donnellan@au1.ibm.com> wrote:

> On 12/12/18 4:58 am, Greg Kurz wrote:
> > The AFU Descriptor Template in the PCI config space has a Name Space
> > field which is a 24 Byte ASCII character string of descriptive name
> > space for the AFU. The OCXL driver read the string four characters at
> > a time with pci_read_config_dword().
> > 
> > This optimization is valid on a little-endian system since this is PCI,
> > but a big-endian system ends up with each subset of four characters in
> > reverse order.
> > 
> > This could be fixed by switching to read characters one by one. Another
> > option is to swap the bytes if we're big-endian.
> > 
> > Go for the latter with le32_to_cpu().
> > 
> > Cc: stable@vger.kernel.org      # v4.16
> > Signed-off-by: Greg Kurz <groug@kaod.org>
> > Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>  
> 
> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> 

Friendly ping before Xmas break :)

> > ---
> > v2: - silence sparse with (__force __le32) cast
> >      - new changelog
> > ---
> >   drivers/misc/ocxl/config.c |    2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
> > index 57a6bb1fd3c9..8f2c5d8bd2ee 100644
> > --- a/drivers/misc/ocxl/config.c
> > +++ b/drivers/misc/ocxl/config.c
> > @@ -318,7 +318,7 @@ static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
> >   		if (rc)
> >   			return rc;
> >   		ptr = (u32 *) &afu->name[i];
> > -		*ptr = val;
> > +		*ptr = le32_to_cpu((__force __le32) val);
> >   	}
> >   	afu->name[OCXL_AFU_NAME_SZ - 1] = '\0'; /* play safe */
> >   	return 0;
> >   
> 


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

* Re: [v2] ocxl: Fix endiannes bug in read_afu_name()
  2018-12-11 17:58 ` Greg Kurz
  (?)
  (?)
@ 2018-12-23 13:28 ` Michael Ellerman
  -1 siblings, 0 replies; 7+ messages in thread
From: Michael Ellerman @ 2018-12-23 13:28 UTC (permalink / raw)
  To: Greg Kurz, linuxppc-dev
  Cc: Andrew Donnellan, Frederic Barrat, Christophe Lombard, stable,
	Vaibhav Jain

On Tue, 2018-12-11 at 17:58:21 UTC, Greg Kurz wrote:
> The AFU Descriptor Template in the PCI config space has a Name Space
> field which is a 24 Byte ASCII character string of descriptive name
> space for the AFU. The OCXL driver read the string four characters at
> a time with pci_read_config_dword().
> 
> This optimization is valid on a little-endian system since this is PCI,
> but a big-endian system ends up with each subset of four characters in
> reverse order.
> 
> This could be fixed by switching to read characters one by one. Another
> option is to swap the bytes if we're big-endian.
> 
> Go for the latter with le32_to_cpu().
> 
> Cc: stable@vger.kernel.org      # v4.16
> Signed-off-by: Greg Kurz <groug@kaod.org>
> Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/2f07229f02d4c55affccd11a61af4f

cheers

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

end of thread, other threads:[~2018-12-23 13:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-11 17:58 [PATCH v2] ocxl: Fix endiannes bug in read_afu_name() Greg Kurz
2018-12-11 17:58 ` Greg Kurz
2018-12-12  2:26 ` Andrew Donnellan
2018-12-12  2:26   ` Andrew Donnellan
2018-12-20 14:53   ` Greg Kurz
2018-12-20 14:53     ` Greg Kurz
2018-12-23 13:28 ` [v2] " 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.