Linux-MIPS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 0/5] PCI: Convert pci_resource_to_user() to a weak function
@ 2019-07-29 10:13 Denis Efremov
  2019-07-29 10:13 ` [PATCH v2 1/5] PCI: Convert pci_resource_to_user " Denis Efremov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Denis Efremov @ 2019-07-29 10:13 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.

Changes in v2:
1. Removed __weak from pci_resource_to_user() declaration
2. Fixed typo s/spark/sparc/g

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
  sparc/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               | 12 ------------
 6 files changed, 8 insertions(+), 19 deletions(-)

-- 
2.21.0


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

* [PATCH v2 1/5] PCI: Convert pci_resource_to_user to a weak function
  2019-07-29 10:13 [PATCH v2 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
@ 2019-07-29 10:13 ` " Denis Efremov
  2019-07-29 10:13 ` [PATCH v2 3/5] mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER Denis Efremov
  2019-07-30 18:25 ` [PATCH v2 0/5] PCI: Convert pci_resource_to_user() to a weak function Bjorn Helgaas
  2 siblings, 0 replies; 5+ messages in thread
From: Denis Efremov @ 2019-07-29 10:13 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 | 12 ------------
 2 files changed, 8 insertions(+), 12 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..dbdfdab1027b 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 */
-
 
 /*
  * The world is not perfect and supplies us with broken PCI devices.
-- 
2.21.0


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

* [PATCH v2 3/5] mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
  2019-07-29 10:13 [PATCH v2 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
  2019-07-29 10:13 ` [PATCH v2 1/5] PCI: Convert pci_resource_to_user " Denis Efremov
@ 2019-07-29 10:13 ` Denis Efremov
  2019-07-29 18:54   ` Paul Burton
  2019-07-30 18:25 ` [PATCH v2 0/5] PCI: Convert pci_resource_to_user() to a weak function Bjorn Helgaas
  2 siblings, 1 reply; 5+ messages in thread
From: Denis Efremov @ 2019-07-29 10:13 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	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 3/5] mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER
  2019-07-29 10:13 ` [PATCH v2 3/5] mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER Denis Efremov
@ 2019-07-29 18:54   ` Paul Burton
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Burton @ 2019-07-29 18:54 UTC (permalink / raw)
  To: Denis Efremov
  Cc: Bjorn Helgaas, Ralf Baechle, James Hogan, linux-mips, linux-pci,
	linux-kernel

Hi Denis,

On Mon, Jul 29, 2019 at 01:13:59PM +0300, Denis Efremov wrote:
> 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>

Assuming this is the way Bjorn wants to go:

    Acked-by: Paul Burton <paul.burton@mips.com>

Thanks,
    Paul

> ---
>  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	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/5] PCI: Convert pci_resource_to_user() to a weak function
  2019-07-29 10:13 [PATCH v2 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
  2019-07-29 10:13 ` [PATCH v2 1/5] PCI: Convert pci_resource_to_user " Denis Efremov
  2019-07-29 10:13 ` [PATCH v2 3/5] mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER Denis Efremov
@ 2019-07-30 18:25 ` Bjorn Helgaas
  2 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2019-07-30 18:25 UTC (permalink / raw)
  To: Denis Efremov
  Cc: 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

On Mon, Jul 29, 2019 at 01:13:56PM +0300, Denis Efremov wrote:
> 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.
> 
> Changes in v2:
> 1. Removed __weak from pci_resource_to_user() declaration
> 2. Fixed typo s/spark/sparc/g
> 
> 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
>   sparc/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               | 12 ------------
>  6 files changed, 8 insertions(+), 19 deletions(-)

Thanks, I added Paul's ack, squashed into a single patch since I think
it's easier to see what's going on then, and applied to pci/misc for
v4.5.

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 10:13 [PATCH v2 0/5] PCI: Convert pci_resource_to_user() to a weak function Denis Efremov
2019-07-29 10:13 ` [PATCH v2 1/5] PCI: Convert pci_resource_to_user " Denis Efremov
2019-07-29 10:13 ` [PATCH v2 3/5] mips/PCI: Remove HAVE_ARCH_PCI_RESOURCE_TO_USER Denis Efremov
2019-07-29 18:54   ` Paul Burton
2019-07-30 18:25 ` [PATCH v2 0/5] PCI: Convert pci_resource_to_user() to a weak function Bjorn Helgaas

Linux-MIPS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mips/0 linux-mips/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mips linux-mips/ https://lore.kernel.org/linux-mips \
		linux-mips@vger.kernel.org linux-mips@archiver.kernel.org
	public-inbox-index linux-mips


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mips


AGPL code for this site: git clone https://public-inbox.org/ public-inbox