[v3,03/15] bus/pci: add fallback for out[lwb]_p for non GNU libc

Message ID 20190313170657.16688-4-ncopa@alpinelinux.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Build fixes for musl libc |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Natanael Copa March 13, 2019, 5:06 p.m. UTC
  Add a fallback for non-GNU libc systems like musl libc for the
non-standard functions  outl_p, outw_p and outb_p.

This ifixes the following buildtime errors when building with musl libc:
pci_uio.c:(.text+0xaa1): undefined reference to `outw_p'
pci_uio.c:(.text+0xac5): undefined reference to `outl_p'
pci_uio.c:(.text+0xadf): undefined reference to `outb_p'

fixes https://bugs.dpdk.org/show_bug.cgi?id=35

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
 drivers/bus/pci/linux/pci_uio.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
  

Comments

Thomas Monjalon March 30, 2019, 10:22 p.m. UTC | #1
13/03/2019 18:06, Natanael Copa:
> Add a fallback for non-GNU libc systems like musl libc for the
> non-standard functions  outl_p, outw_p and outb_p.
> 
> This ifixes the following buildtime errors when building with musl libc:
> pci_uio.c:(.text+0xaa1): undefined reference to `outw_p'
> pci_uio.c:(.text+0xac5): undefined reference to `outl_p'
> pci_uio.c:(.text+0xadf): undefined reference to `outb_p'
> 
> fixes https://bugs.dpdk.org/show_bug.cgi?id=35

Please use this syntax:
Bugzilla ID: 35

[...]
>  #if defined(RTE_ARCH_X86)
>  #include <sys/io.h>
> +#if defined(__GLIBC__)
> +#define pci_uio_outl_p outl_p
> +#define pci_uio_outw_p outw_p
> +#define pci_uio_outb_p outb_p
> +#else
> +static inline void
> +pci_uio_outl_p(unsigned int value, unsigned short int port)
> +{
> +	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
> +			      "Nd" (port));
> +}
> +
> +static inline void
> +pci_uio_outw_p(unsigned short int value, unsigned short int port)
> +{
> +	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
> +			      "Nd" (port));
> +}
> +
> +static inline void
> +pci_uio_outb_p(unsigned char value, unsigned short int port)
> +{
> +	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
> +			      "Nd" (port));
> +}
> +#endif
>  #endif
[...]
>  #if defined(RTE_ARCH_X86)
> -			outl_p(*(const uint32_t *)s, reg);
> +			pci_uio_outl_p(*(const uint32_t *)s, reg);
>  #else
>  			*(volatile uint32_t *)reg = *(const uint32_t *)s;
>  #endif

Could we manage non-x86 case in the macros pci_uio_out?

Thanks
  
Natanael Copa July 4, 2019, 12:16 p.m. UTC | #2
On Sat, 30 Mar 2019 23:22:27 +0100
Thomas Monjalon <thomas@monjalon.net> wrote:

> 13/03/2019 18:06, Natanael Copa:
> > Add a fallback for non-GNU libc systems like musl libc for the
> > non-standard functions  outl_p, outw_p and outb_p.
> > 
> > This ifixes the following buildtime errors when building with musl libc:
> > pci_uio.c:(.text+0xaa1): undefined reference to `outw_p'
> > pci_uio.c:(.text+0xac5): undefined reference to `outl_p'
> > pci_uio.c:(.text+0xadf): undefined reference to `outb_p'
> > 
> > fixes https://bugs.dpdk.org/show_bug.cgi?id=35  
> 
> Please use this syntax:
> Bugzilla ID: 35

Ok.

> 
> [...]
> >  #if defined(RTE_ARCH_X86)
> >  #include <sys/io.h>
> > +#if defined(__GLIBC__)
> > +#define pci_uio_outl_p outl_p
> > +#define pci_uio_outw_p outw_p
> > +#define pci_uio_outb_p outb_p
> > +#else
> > +static inline void
> > +pci_uio_outl_p(unsigned int value, unsigned short int port)
> > +{
> > +	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
> > +			      "Nd" (port));
> > +}
> > +
> > +static inline void
> > +pci_uio_outw_p(unsigned short int value, unsigned short int port)
> > +{
> > +	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
> > +			      "Nd" (port));
> > +}
> > +
> > +static inline void
> > +pci_uio_outb_p(unsigned char value, unsigned short int port)
> > +{
> > +	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
> > +			      "Nd" (port));
> > +}
> > +#endif
> >  #endif  
> [...]
> >  #if defined(RTE_ARCH_X86)
> > -			outl_p(*(const uint32_t *)s, reg);
> > +			pci_uio_outl_p(*(const uint32_t *)s, reg);
> >  #else
> >  			*(volatile uint32_t *)reg = *(const uint32_t *)s;
> >  #endif  
> 
> Could we manage non-x86 case in the macros pci_uio_out?

I did that in separate commit. Do you want do both in same commit?

> 
> Thanks
> 
>
  
Thomas Monjalon July 4, 2019, 1:20 p.m. UTC | #3
04/07/2019 14:16, Natanael Copa:
> On Sat, 30 Mar 2019 23:22:27 +0100
> Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > 13/03/2019 18:06, Natanael Copa:
> > > Add a fallback for non-GNU libc systems like musl libc for the
> > > non-standard functions  outl_p, outw_p and outb_p.
> > > 
> > > This ifixes the following buildtime errors when building with musl libc:
> > > pci_uio.c:(.text+0xaa1): undefined reference to `outw_p'
> > > pci_uio.c:(.text+0xac5): undefined reference to `outl_p'
> > > pci_uio.c:(.text+0xadf): undefined reference to `outb_p'
> > > 
> > > fixes https://bugs.dpdk.org/show_bug.cgi?id=35  
> > 
> > Please use this syntax:
> > Bugzilla ID: 35
> 
> Ok.
> 
> > 
> > [...]
> > >  #if defined(RTE_ARCH_X86)
> > >  #include <sys/io.h>
> > > +#if defined(__GLIBC__)
> > > +#define pci_uio_outl_p outl_p
> > > +#define pci_uio_outw_p outw_p
> > > +#define pci_uio_outb_p outb_p
> > > +#else
> > > +static inline void
> > > +pci_uio_outl_p(unsigned int value, unsigned short int port)
> > > +{
> > > +	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
> > > +			      "Nd" (port));
> > > +}
> > > +
> > > +static inline void
> > > +pci_uio_outw_p(unsigned short int value, unsigned short int port)
> > > +{
> > > +	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
> > > +			      "Nd" (port));
> > > +}
> > > +
> > > +static inline void
> > > +pci_uio_outb_p(unsigned char value, unsigned short int port)
> > > +{
> > > +	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
> > > +			      "Nd" (port));
> > > +}
> > > +#endif
> > >  #endif  
> > [...]
> > >  #if defined(RTE_ARCH_X86)
> > > -			outl_p(*(const uint32_t *)s, reg);
> > > +			pci_uio_outl_p(*(const uint32_t *)s, reg);
> > >  #else
> > >  			*(volatile uint32_t *)reg = *(const uint32_t *)s;
> > >  #endif  
> > 
> > Could we manage non-x86 case in the macros pci_uio_out?
> 
> I did that in separate commit. Do you want do both in same commit?

Maybe change the order of commits?
Anyway I think you need to rebase and resend this series :)
  
Natanael Copa July 4, 2019, 3:30 p.m. UTC | #4
On Thu, 04 Jul 2019 15:20:55 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> 04/07/2019 14:16, Natanael Copa:
> > On Sat, 30 Mar 2019 23:22:27 +0100
> > Thomas Monjalon <thomas@monjalon.net> wrote:
> >   
> > > 13/03/2019 18:06, Natanael Copa:  
> > > > Add a fallback for non-GNU libc systems like musl libc for the
> > > > non-standard functions  outl_p, outw_p and outb_p.
> > > > 
> > > > This ifixes the following buildtime errors when building with musl libc:
> > > > pci_uio.c:(.text+0xaa1): undefined reference to `outw_p'
> > > > pci_uio.c:(.text+0xac5): undefined reference to `outl_p'
> > > > pci_uio.c:(.text+0xadf): undefined reference to `outb_p'
> > > > 
> > > > fixes https://bugs.dpdk.org/show_bug.cgi?id=35    
> > > 
> > > Please use this syntax:
> > > Bugzilla ID: 35  
> > 
> > Ok.
> >   
> > > 
> > > [...]  
> > > >  #if defined(RTE_ARCH_X86)
> > > >  #include <sys/io.h>
> > > > +#if defined(__GLIBC__)
> > > > +#define pci_uio_outl_p outl_p
> > > > +#define pci_uio_outw_p outw_p
> > > > +#define pci_uio_outb_p outb_p
> > > > +#else
> > > > +static inline void
> > > > +pci_uio_outl_p(unsigned int value, unsigned short int port)
> > > > +{
> > > > +	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
> > > > +			      "Nd" (port));
> > > > +}
> > > > +
> > > > +static inline void
> > > > +pci_uio_outw_p(unsigned short int value, unsigned short int port)
> > > > +{
> > > > +	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
> > > > +			      "Nd" (port));
> > > > +}
> > > > +
> > > > +static inline void
> > > > +pci_uio_outb_p(unsigned char value, unsigned short int port)
> > > > +{
> > > > +	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
> > > > +			      "Nd" (port));
> > > > +}
> > > > +#endif
> > > >  #endif    
> > > [...]  
> > > >  #if defined(RTE_ARCH_X86)
> > > > -			outl_p(*(const uint32_t *)s, reg);
> > > > +			pci_uio_outl_p(*(const uint32_t *)s, reg);
> > > >  #else
> > > >  			*(volatile uint32_t *)reg = *(const uint32_t *)s;
> > > >  #endif    
> > > 
> > > Could we manage non-x86 case in the macros pci_uio_out?  
> > 
> > I did that in separate commit. Do you want do both in same commit?  
> 
> Maybe change the order of commits?

That would mean that first commit would use a define or inline that is
not yet introduced :)

> Anyway I think you need to rebase and resend this series :)

I'm on it. Thanks for your feedback.

-nc
  

Patch

diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index 09ecbb7aa..e1dd8c875 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -14,6 +14,32 @@ 
 
 #if defined(RTE_ARCH_X86)
 #include <sys/io.h>
+#if defined(__GLIBC__)
+#define pci_uio_outl_p outl_p
+#define pci_uio_outw_p outw_p
+#define pci_uio_outb_p outb_p
+#else
+static inline void
+pci_uio_outl_p(unsigned int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outw_p(unsigned short int value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+
+static inline void
+pci_uio_outb_p(unsigned char value, unsigned short int port)
+{
+	__asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80" : : "a" (value),
+			      "Nd" (port));
+}
+#endif
 #endif
 
 #include <rte_log.h>
@@ -527,21 +553,21 @@  pci_uio_ioport_write(struct rte_pci_ioport *p,
 		if (len >= 4) {
 			size = 4;
 #if defined(RTE_ARCH_X86)
-			outl_p(*(const uint32_t *)s, reg);
+			pci_uio_outl_p(*(const uint32_t *)s, reg);
 #else
 			*(volatile uint32_t *)reg = *(const uint32_t *)s;
 #endif
 		} else if (len >= 2) {
 			size = 2;
 #if defined(RTE_ARCH_X86)
-			outw_p(*(const uint16_t *)s, reg);
+			pci_uio_outw_p(*(const uint16_t *)s, reg);
 #else
 			*(volatile uint16_t *)reg = *(const uint16_t *)s;
 #endif
 		} else {
 			size = 1;
 #if defined(RTE_ARCH_X86)
-			outb_p(*s, reg);
+			pci_uio_outb_p(*s, reg);
 #else
 			*(volatile uint8_t *)reg = *s;
 #endif