* [PATCH 0/5] PCI: Convert pci_resource_to_user() to a weak function
@ 2019-07-28 20:22 Denis Efremov
2019-07-28 20:22 ` [PATCH 1/5] PCI: Convert pci_resource_to_user " Denis Efremov
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Denis Efremov @ 2019-07-28 20:22 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Denis Efremov, David S. Miller, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, Ralf Baechle, Paul Burton,
James Hogan, Michal Simek, linux-mips, linuxppc-dev, sparclinux,
linux-pci, linux-kernel
Architectures currently define HAVE_ARCH_PCI_RESOURCE_TO_USER if they want
to provide their own pci_resource_to_user() implementation. This could be
simplified if we make the generic version a weak function. Thus,
architecture specific versions will automatically override the generic one.
Denis Efremov (5):
PCI: Convert pci_resource_to_user to a weak function
microblaze/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
powerpc/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
spark/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
arch/microblaze/include/asm/pci.h | 2 --
arch/mips/include/asm/pci.h | 1 -
arch/powerpc/include/asm/pci.h | 2 --
arch/sparc/include/asm/pci.h | 2 --
drivers/pci/pci.c | 8 ++++++++
include/linux/pci.h | 18 +++---------------
6 files changed, 11 insertions(+), 22 deletions(-)
--
2.21.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/5] PCI: Convert pci_resource_to_user to a weak function
2019-07-28 20:22 [PATCH 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
@ 2019-07-28 20:22 ` Denis Efremov
2019-07-28 22:49 ` [EXTERNAL][PATCH " Paul Burton
2019-07-28 20:22 ` [PATCH 2/5] microblaze/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER Denis Efremov
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Denis Efremov @ 2019-07-28 20:22 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Denis Efremov, David S. Miller, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, Ralf Baechle, Paul Burton,
James Hogan, Michal Simek, linux-mips, linuxppc-dev, sparclinux,
linux-pci, linux-kernel
The patch turns pci_resource_to_user() to a weak function. Thus,
architecture-specific versions will automatically override the generic
one. This allows to remove the HAVE_ARCH_PCI_RESOURCE_TO_USER macro and
avoid the conditional compilation for this single function.
Signed-off-by: Denis Efremov <efremov@linux.com>
---
drivers/pci/pci.c | 8 ++++++++
include/linux/pci.h | 18 +++---------------
2 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 29ed5ec1ac27..f9dc7563a8b9 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5932,6 +5932,14 @@ resource_size_t __weak pcibios_default_alignment(void)
return 0;
}
+void __weak pci_resource_to_user(const struct pci_dev *dev, int bar,
+ const struct resource *rsrc, resource_size_t *start,
+ resource_size_t *end)
+{
+ *start = rsrc->start;
+ *end = rsrc->end;
+}
+
#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
static DEFINE_SPINLOCK(resource_alignment_lock);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9e700d9f9f28..1a19d0151b0a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1870,25 +1870,13 @@ static inline const char *pci_name(const struct pci_dev *pdev)
return dev_name(&pdev->dev);
}
-
/*
* Some archs don't want to expose struct resource to userland as-is
* in sysfs and /proc
*/
-#ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER
-void pci_resource_to_user(const struct pci_dev *dev, int bar,
- const struct resource *rsrc,
- resource_size_t *start, resource_size_t *end);
-#else
-static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
- const struct resource *rsrc, resource_size_t *start,
- resource_size_t *end)
-{
- *start = rsrc->start;
- *end = rsrc->end;
-}
-#endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */
-
+void __weak pci_resource_to_user(const struct pci_dev *dev, int bar,
+ const struct resource *rsrc,
+ resource_size_t *start, resource_size_t *end);
/*
* The world is not perfect and supplies us with broken PCI devices.
--
2.21.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/5] microblaze/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
2019-07-28 20:22 [PATCH 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
2019-07-28 20:22 ` [PATCH 1/5] PCI: Convert pci_resource_to_user " Denis Efremov
@ 2019-07-28 20:22 ` Denis Efremov
2019-07-28 20:22 ` [PATCH 3/5] mips/PCI: " Denis Efremov
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Denis Efremov @ 2019-07-28 20:22 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: Denis Efremov, Michal Simek, linux-pci, linux-kernel
The function pci_resource_to_user() was turned to a weak one. Thus,
microblase-specific version will automatically override the generic
one and the HAVE_ARCH_PCI_RESOURCE_TO_USER macro should be removed.
Signed-off-by: Denis Efremov <efremov@linux.com>
---
arch/microblaze/include/asm/pci.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h
index 21ddba9188b2..7c4dc5d85f53 100644
--- a/arch/microblaze/include/asm/pci.h
+++ b/arch/microblaze/include/asm/pci.h
@@ -66,8 +66,6 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file,
unsigned long size,
pgprot_t prot);
-#define HAVE_ARCH_PCI_RESOURCE_TO_USER
-
/* This part of code was originally in xilinx-pci.h */
#ifdef CONFIG_PCI_XILINX
extern void __init xilinx_pci_init(void);
--
2.21.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/5] mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
2019-07-28 20:22 [PATCH 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
2019-07-28 20:22 ` [PATCH 1/5] PCI: Convert pci_resource_to_user " Denis Efremov
2019-07-28 20:22 ` [PATCH 2/5] microblaze/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER Denis Efremov
@ 2019-07-28 20:22 ` Denis Efremov
2019-07-28 20:22 ` [PATCH 4/5] powerpc/PCI: " Denis Efremov
2019-07-28 20:22 ` [PATCH 5/5] spark/PCI: " Denis Efremov
4 siblings, 0 replies; 11+ messages in thread
From: Denis Efremov @ 2019-07-28 20:22 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Denis Efremov, Ralf Baechle, Paul Burton, James Hogan,
linux-mips, linux-pci, linux-kernel
The function pci_resource_to_user() was turned to a weak one. Thus,
mips-specific version will automatically override the generic one
and the HAVE_ARCH_PCI_RESOURCE_TO_USER macro should be removed.
Signed-off-by: Denis Efremov <efremov@linux.com>
---
arch/mips/include/asm/pci.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 436099883022..6f48649201c5 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -108,7 +108,6 @@ extern unsigned long PCIBIOS_MIN_MEM;
#define HAVE_PCI_MMAP
#define ARCH_GENERIC_PCI_MMAP_RESOURCE
-#define HAVE_ARCH_PCI_RESOURCE_TO_USER
/*
* Dynamic DMA mapping stuff.
--
2.21.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/5] powerpc/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
2019-07-28 20:22 [PATCH 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
` (2 preceding siblings ...)
2019-07-28 20:22 ` [PATCH 3/5] mips/PCI: " Denis Efremov
@ 2019-07-28 20:22 ` Denis Efremov
2019-07-28 20:22 ` [PATCH 5/5] spark/PCI: " Denis Efremov
4 siblings, 0 replies; 11+ messages in thread
From: Denis Efremov @ 2019-07-28 20:22 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Denis Efremov, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, linuxppc-dev, linux-pci, linux-kernel
The function pci_resource_to_user() was turned to a weak one. Thus,
powerpc-specific version will automatically override the generic one
and the HAVE_ARCH_PCI_RESOURCE_TO_USER macro should be removed.
Signed-off-by: Denis Efremov <efremov@linux.com>
---
arch/powerpc/include/asm/pci.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index 2372d35533ad..327567b8f7d6 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -112,8 +112,6 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file,
unsigned long size,
pgprot_t prot);
-#define HAVE_ARCH_PCI_RESOURCE_TO_USER
-
extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose);
extern void pcibios_setup_bus_devices(struct pci_bus *bus);
extern void pcibios_setup_bus_self(struct pci_bus *bus);
--
2.21.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/5] spark/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
2019-07-28 20:22 [PATCH 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
` (3 preceding siblings ...)
2019-07-28 20:22 ` [PATCH 4/5] powerpc/PCI: " Denis Efremov
@ 2019-07-28 20:22 ` Denis Efremov
2019-07-28 20:25 ` John Paul Adrian Glaubitz
4 siblings, 1 reply; 11+ messages in thread
From: Denis Efremov @ 2019-07-28 20:22 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Denis Efremov, David S. Miller, sparclinux, linux-pci, linux-kernel
The function pci_resource_to_user() was turned to a weak one. Thus,
spark-specific version will automatically override the generic one
and the HAVE_ARCH_PCI_RESOURCE_TO_USER macro should be removed.
Signed-off-by: Denis Efremov <efremov@linux.com>
---
arch/sparc/include/asm/pci.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/sparc/include/asm/pci.h b/arch/sparc/include/asm/pci.h
index cfec79bb1831..4deddf430e5d 100644
--- a/arch/sparc/include/asm/pci.h
+++ b/arch/sparc/include/asm/pci.h
@@ -38,8 +38,6 @@ static inline int pci_proc_domain(struct pci_bus *bus)
#define arch_can_pci_mmap_io() 1
#define HAVE_ARCH_PCI_GET_UNMAPPED_AREA
#define get_pci_unmapped_area get_fb_unmapped_area
-
-#define HAVE_ARCH_PCI_RESOURCE_TO_USER
#endif /* CONFIG_SPARC64 */
#if defined(CONFIG_SPARC64) || defined(CONFIG_LEON_PCI)
--
2.21.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] spark/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
2019-07-28 20:22 ` [PATCH 5/5] spark/PCI: " Denis Efremov
@ 2019-07-28 20:25 ` John Paul Adrian Glaubitz
2019-07-28 21:17 ` Denis Efremov
0 siblings, 1 reply; 11+ messages in thread
From: John Paul Adrian Glaubitz @ 2019-07-28 20:25 UTC (permalink / raw)
To: Denis Efremov, Bjorn Helgaas
Cc: David S. Miller, sparclinux, linux-pci, linux-kernel
Hi Denis!
On 7/28/19 10:22 PM, Denis Efremov wrote:
> The function pci_resource_to_user() was turned to a weak one. Thus,
> spark-specific version will automatically override the generic one
> and the HAVE_ARCH_PCI_RESOURCE_TO_USER macro should be removed.
Typo, it should be "sparc/PCI" in the subject and "sparc-specific"
in the commit description.
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer - glaubitz@debian.org
`. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] spark/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
2019-07-28 20:25 ` John Paul Adrian Glaubitz
@ 2019-07-28 21:17 ` Denis Efremov
0 siblings, 0 replies; 11+ messages in thread
From: Denis Efremov @ 2019-07-28 21:17 UTC (permalink / raw)
To: John Paul Adrian Glaubitz, Bjorn Helgaas
Cc: David S. Miller, sparclinux, linux-pci, linux-kernel
Hi!
> Typo, it should be "sparc/PCI" in the subject and "sparc-specific"
> in the commit description.
Oh, sorry. I'm from the area of formal methods and mechanically typed
spark (ada language) instead of sparc. I will fix this in v2 after all
comments. Thank you!
Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [EXTERNAL][PATCH 1/5] PCI: Convert pci_resource_to_user to a weak function
2019-07-28 20:22 ` [PATCH 1/5] PCI: Convert pci_resource_to_user " Denis Efremov
@ 2019-07-28 22:49 ` Paul Burton
2019-07-29 6:31 ` Joe Perches
2019-07-29 10:06 ` Denis Efremov
0 siblings, 2 replies; 11+ messages in thread
From: Paul Burton @ 2019-07-28 22:49 UTC (permalink / raw)
To: Denis Efremov
Cc: Bjorn Helgaas, David S. Miller, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, Ralf Baechle, James Hogan,
Michal Simek, linux-mips, linuxppc-dev, sparclinux, linux-pci,
linux-kernel
Hi Denis,
On Sun, Jul 28, 2019 at 11:22:09PM +0300, Denis Efremov wrote:
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 9e700d9f9f28..1a19d0151b0a 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1870,25 +1870,13 @@ static inline const char *pci_name(const struct pci_dev *pdev)
> return dev_name(&pdev->dev);
> }
>
> -
> /*
> * Some archs don't want to expose struct resource to userland as-is
> * in sysfs and /proc
> */
> -#ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER
> -void pci_resource_to_user(const struct pci_dev *dev, int bar,
> - const struct resource *rsrc,
> - resource_size_t *start, resource_size_t *end);
> -#else
> -static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
> - const struct resource *rsrc, resource_size_t *start,
> - resource_size_t *end)
> -{
> - *start = rsrc->start;
> - *end = rsrc->end;
> -}
> -#endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */
> -
> +void __weak pci_resource_to_user(const struct pci_dev *dev, int bar,
> + const struct resource *rsrc,
> + resource_size_t *start, resource_size_t *end);
>
> /*
> * The world is not perfect and supplies us with broken PCI devices.
This is wrong - using __weak on the declaration in a header will cause
the weak attribute to be applied to all implementations too (presuming
the C files containing the implementations include the header). You then
get whichever impleentation the linker chooses, which isn't necessarily
the one you wanted.
checkpatch.pl should produce an error about this - see the
WEAK_DECLARATION error introduced in commit 619a908aa334 ("checkpatch:
add error on use of attribute((weak)) or __weak declarations").
Thanks,
Paul
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [EXTERNAL][PATCH 1/5] PCI: Convert pci_resource_to_user to a weak function
2019-07-28 22:49 ` [EXTERNAL][PATCH " Paul Burton
@ 2019-07-29 6:31 ` Joe Perches
2019-07-29 10:06 ` Denis Efremov
1 sibling, 0 replies; 11+ messages in thread
From: Joe Perches @ 2019-07-29 6:31 UTC (permalink / raw)
To: Paul Burton, Denis Efremov
Cc: Bjorn Helgaas, David S. Miller, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, Ralf Baechle, James Hogan,
Michal Simek, linux-mips, linuxppc-dev, sparclinux, linux-pci,
linux-kernel
On Sun, 2019-07-28 at 22:49 +0000, Paul Burton wrote:
> Hi Denis,
>
> On Sun, Jul 28, 2019 at 11:22:09PM +0300, Denis Efremov wrote:
> > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > index 9e700d9f9f28..1a19d0151b0a 100644
> > --- a/include/linux/pci.h
> > +++ b/include/linux/pci.h
> > @@ -1870,25 +1870,13 @@ static inline const char *pci_name(const struct pci_dev *pdev)
> > return dev_name(&pdev->dev);
> > }
> >
> > -
> > /*
> > * Some archs don't want to expose struct resource to userland as-is
> > * in sysfs and /proc
> > */
> > -#ifdef HAVE_ARCH_PCI_RESOURCE_TO_USER
> > -void pci_resource_to_user(const struct pci_dev *dev, int bar,
> > - const struct resource *rsrc,
> > - resource_size_t *start, resource_size_t *end);
> > -#else
> > -static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
> > - const struct resource *rsrc, resource_size_t *start,
> > - resource_size_t *end)
> > -{
> > - *start = rsrc->start;
> > - *end = rsrc->end;
> > -}
> > -#endif /* HAVE_ARCH_PCI_RESOURCE_TO_USER */
> > -
> > +void __weak pci_resource_to_user(const struct pci_dev *dev, int bar,
> > + const struct resource *rsrc,
> > + resource_size_t *start, resource_size_t *end);
> >
> > /*
> > * The world is not perfect and supplies us with broken PCI devices.
>
> This is wrong - using __weak on the declaration in a header will cause
> the weak attribute to be applied to all implementations too (presuming
> the C files containing the implementations include the header). You then
> get whichever impleentation the linker chooses, which isn't necessarily
> the one you wanted.
>
> checkpatch.pl should produce an error about this - see the
> WEAK_DECLARATION error introduced in commit 619a908aa334 ("checkpatch:
> add error on use of attribute((weak)) or __weak declarations").
Unfortunately, checkpatch is pretty stupid and only emits
this on single line declarations.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [EXTERNAL][PATCH 1/5] PCI: Convert pci_resource_to_user to a weak function
2019-07-28 22:49 ` [EXTERNAL][PATCH " Paul Burton
2019-07-29 6:31 ` Joe Perches
@ 2019-07-29 10:06 ` Denis Efremov
1 sibling, 0 replies; 11+ messages in thread
From: Denis Efremov @ 2019-07-29 10:06 UTC (permalink / raw)
To: Paul Burton
Cc: Bjorn Helgaas, David S. Miller, Benjamin Herrenschmidt,
Paul Mackerras, Michael Ellerman, Ralf Baechle, James Hogan,
Michal Simek, linux-mips, linuxppc-dev, sparclinux, linux-pci,
linux-kernel
Hi Paul,
On 29.07.2019 01:49, Paul Burton wrote:
> Hi Denis,
>
> This is wrong - using __weak on the declaration in a header will cause
> the weak attribute to be applied to all implementations too (presuming
> the C files containing the implementations include the header). You then
> get whichever impleentation the linker chooses, which isn't necessarily
> the one you wanted.
Thank you for pointing me on that. I will prepare the v2.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-07-29 10:06 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-28 20:22 [PATCH 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
2019-07-28 20:22 ` [PATCH 1/5] PCI: Convert pci_resource_to_user " Denis Efremov
2019-07-28 22:49 ` [EXTERNAL][PATCH " Paul Burton
2019-07-29 6:31 ` Joe Perches
2019-07-29 10:06 ` Denis Efremov
2019-07-28 20:22 ` [PATCH 2/5] microblaze/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER Denis Efremov
2019-07-28 20:22 ` [PATCH 3/5] mips/PCI: " Denis Efremov
2019-07-28 20:22 ` [PATCH 4/5] powerpc/PCI: " Denis Efremov
2019-07-28 20:22 ` [PATCH 5/5] spark/PCI: " Denis Efremov
2019-07-28 20:25 ` John Paul Adrian Glaubitz
2019-07-28 21:17 ` Denis Efremov
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).