[PATCH 1/3] pci: Add a generic, weakly-linked pcibios_fixup_bus

2017-06-23 Thread Palmer Dabbelt
Multiple architectures define this as an empty function, and I'm adding
another one as part of the RISC-V port.  This adds a __weak version of
pci_fixup_bios and deletes the now obselete ones in a handful of ports.

The only functional change should be that microblaze used to export
pcibios_fixup_bus.  None of the other architectures export this, so I
just dropped it.

Signed-off-by: Palmer Dabbelt 
---
 arch/arc/kernel/pcibios.c |  4 
 arch/arm64/kernel/pci.c   |  8 
 arch/cris/arch-v32/drivers/pci/bios.c |  4 
 arch/microblaze/pci/pci-common.c  |  6 --
 arch/s390/pci/pci.c   |  4 
 arch/sh/drivers/pci/pci.c |  8 
 arch/sparc/kernel/pci.c   |  4 
 arch/tile/kernel/pci.c|  8 
 arch/tile/kernel/pci_gx.c |  5 -
 drivers/pci/probe.c   | 10 ++
 10 files changed, 10 insertions(+), 51 deletions(-)

diff --git a/arch/arc/kernel/pcibios.c b/arch/arc/kernel/pcibios.c
index 72e1d73d0bd6..1c8df8fd5fed 100644
--- a/arch/arc/kernel/pcibios.c
+++ b/arch/arc/kernel/pcibios.c
@@ -16,7 +16,3 @@ resource_size_t pcibios_align_resource(void *data, const 
struct resource *res,
 {
return res->start;
 }
-
-void pcibios_fixup_bus(struct pci_bus *bus)
-{
-}
diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index c7e3e6387a49..4c7f451aca05 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -23,14 +23,6 @@
 #include 
 
 /*
- * Called after each bus is probed, but before its children are examined
- */
-void pcibios_fixup_bus(struct pci_bus *bus)
-{
-   /* nothing to do, expected to be removed in the future */
-}
-
-/*
  * We don't have to worry about legacy ISA devices, so nothing to do here
  */
 resource_size_t pcibios_align_resource(void *data, const struct resource *res,
diff --git a/arch/cris/arch-v32/drivers/pci/bios.c 
b/arch/cris/arch-v32/drivers/pci/bios.c
index 394c2a73d5e2..5cc622c0225e 100644
--- a/arch/cris/arch-v32/drivers/pci/bios.c
+++ b/arch/cris/arch-v32/drivers/pci/bios.c
@@ -2,10 +2,6 @@
 #include 
 #include 
 
-void pcibios_fixup_bus(struct pci_bus *b)
-{
-}
-
 void pcibios_set_master(struct pci_dev *dev)
 {
u8 lat;
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 404fb38d06b7..940f266e5d5c 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -810,12 +810,6 @@ void pcibios_setup_bus_devices(struct pci_bus *bus)
}
 }
 
-void pcibios_fixup_bus(struct pci_bus *bus)
-{
-   /* nothing to do */
-}
-EXPORT_SYMBOL(pcibios_fixup_bus);
-
 /*
  * We need to avoid collisions with `mirrored' VGA ports
  * and other strange ISA hardware, so we always want the
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 8051df109db3..98a54dd63483 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -234,10 +234,6 @@ static int zpci_cfg_store(struct zpci_dev *zdev, int 
offset, u32 val, u8 len)
return rc;
 }
 
-void pcibios_fixup_bus(struct pci_bus *bus)
-{
-}
-
 resource_size_t pcibios_align_resource(void *data, const struct resource *res,
   resource_size_t size,
   resource_size_t align)
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index c99ee286b69f..749642e1272e 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -155,14 +155,6 @@ static int __init pcibios_init(void)
 subsys_initcall(pcibios_init);
 
 /*
- *  Called after each bus is probed, but before its children
- *  are examined.
- */
-void pcibios_fixup_bus(struct pci_bus *bus)
-{
-}
-
-/*
  * We need to avoid collisions with `mirrored' VGA ports
  * and other strange ISA hardware, so we always want the
  * addresses to be allocated in the 0x000-0x0ff region
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 7eceaa10836f..78d3dc25e126 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -690,10 +690,6 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
return bus;
 }
 
-void pcibios_fixup_bus(struct pci_bus *pbus)
-{
-}
-
 resource_size_t pcibios_align_resource(void *data, const struct resource *res,
resource_size_t size, resource_size_t align)
 {
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index bc6656b5708b..3113d4d5c329 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -369,14 +369,6 @@ int __init pcibios_init(void)
 }
 subsys_initcall(pcibios_init);
 
-/*
- * No bus fixups needed.
- */
-void pcibios_fixup_bus(struct pci_bus *bus)
-{
-   /* Nothing needs to be done. */
-}
-
 void pcibios_set_master(struct pci_dev *dev)
 {
/* No special bus mastering setup handling. */
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b554a68eea1b..b89172b592cc 100644
--- 

[PATCH 3/3] arc: kernel/pcibios.c is empty, delete it

2017-06-23 Thread Palmer Dabbelt
Signed-off-by: Palmer Dabbelt 
---
 arch/arc/kernel/Makefile  | 1 -
 arch/arc/kernel/pcibios.c | 9 -
 2 files changed, 10 deletions(-)
 delete mode 100644 arch/arc/kernel/pcibios.c

diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile
index 8942c5c3b4c5..2dc5f4296d44 100644
--- a/arch/arc/kernel/Makefile
+++ b/arch/arc/kernel/Makefile
@@ -12,7 +12,6 @@ obj-y := arcksyms.o setup.o irq.o reset.o ptrace.o process.o 
devtree.o
 obj-y  += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o
 obj-$(CONFIG_ISA_ARCOMPACT)+= entry-compact.o intc-compact.o
 obj-$(CONFIG_ISA_ARCV2)+= entry-arcv2.o intc-arcv2.o
-obj-$(CONFIG_PCI)  += pcibios.o
 
 obj-$(CONFIG_MODULES)  += arcksyms.o module.o
 obj-$(CONFIG_SMP)  += smp.o
diff --git a/arch/arc/kernel/pcibios.c b/arch/arc/kernel/pcibios.c
deleted file mode 100644
index 05aba5a7b5d2..
--- a/arch/arc/kernel/pcibios.c
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Copyright (C) 2014-2015 Synopsys, Inc. (www.synopsys.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include 
-- 
2.13.0


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 2/3] pci: Add a generic, weakly-linked pcibios_align_resource

2017-06-23 Thread Palmer Dabbelt
Multiple architectures define this as trivial function, and I'm adding
another one as part of the RISC-V port.  This adds a __weak version of
pcibios_align_resource and deletes the now obselete ones in a handful of
ports.

The only functional change should be that a handful of ports used to
export pcibios_fixup_bus.  Only some architectures export this, so I
just dropped it.

Signed-off-by: Palmer Dabbelt 
---
 arch/arc/kernel/pcibios.c|  9 -
 arch/arm64/kernel/pci.c  |  9 -
 arch/ia64/pci/pci.c  |  7 ---
 arch/microblaze/pci/pci-common.c |  7 ---
 arch/sparc/kernel/leon_pci.c |  6 --
 arch/sparc/kernel/pci.c  |  6 --
 arch/sparc/kernel/pcic.c |  6 --
 arch/tile/kernel/pci.c   | 10 --
 arch/tile/kernel/pci_gx.c|  9 -
 drivers/pci/setup-res.c  | 12 
 10 files changed, 12 insertions(+), 69 deletions(-)

diff --git a/arch/arc/kernel/pcibios.c b/arch/arc/kernel/pcibios.c
index 1c8df8fd5fed..05aba5a7b5d2 100644
--- a/arch/arc/kernel/pcibios.c
+++ b/arch/arc/kernel/pcibios.c
@@ -7,12 +7,3 @@
  */
 
 #include 
-
-/*
- * We don't have to worry about legacy ISA devices, so nothing to do here
- */
-resource_size_t pcibios_align_resource(void *data, const struct resource *res,
-   resource_size_t size, resource_size_t align)
-{
-   return res->start;
-}
diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index 4c7f451aca05..9753ca23cfa1 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -23,15 +23,6 @@
 #include 
 
 /*
- * We don't have to worry about legacy ISA devices, so nothing to do here
- */
-resource_size_t pcibios_align_resource(void *data, const struct resource *res,
-   resource_size_t size, resource_size_t align)
-{
-   return res->start;
-}
-
-/*
  * Try to assign the IRQ number when probing a new device
  */
 int pcibios_alloc_irq(struct pci_dev *dev)
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 4068bde623dc..f5ec736100ee 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -411,13 +411,6 @@ pcibios_disable_device (struct pci_dev *dev)
acpi_pci_irq_disable(dev);
 }
 
-resource_size_t
-pcibios_align_resource (void *data, const struct resource *res,
-   resource_size_t size, resource_size_t align)
-{
-   return res->start;
-}
-
 /**
  * ia64_pci_get_legacy_mem - generic legacy mem routine
  * @bus: bus to get legacy memory base address for
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 940f266e5d5c..5835c09c6e26 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -823,13 +823,6 @@ void pcibios_setup_bus_devices(struct pci_bus *bus)
  * but we want to try to avoid allocating at 0x2900-0x2bff
  * which might have be mirrored at 0x0100-0x03ff..
  */
-resource_size_t pcibios_align_resource(void *data, const struct resource *res,
-   resource_size_t size, resource_size_t align)
-{
-   return res->start;
-}
-EXPORT_SYMBOL(pcibios_align_resource);
-
 int pcibios_add_device(struct pci_dev *dev)
 {
dev->irq = of_irq_parse_and_map_pci(dev, 0, 0);
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 4371f72ff025..0eafdf3d036d 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -94,9 +94,3 @@ void pcibios_fixup_bus(struct pci_bus *pbus)
}
}
 }
-
-resource_size_t pcibios_align_resource(void *data, const struct resource *res,
-   resource_size_t size, resource_size_t align)
-{
-   return res->start;
-}
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 78d3dc25e126..3f8670c92951 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -690,12 +690,6 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
return bus;
 }
 
-resource_size_t pcibios_align_resource(void *data, const struct resource *res,
-   resource_size_t size, resource_size_t align)
-{
-   return res->start;
-}
-
 int pcibios_enable_device(struct pci_dev *dev, int mask)
 {
u16 cmd, oldcmd;
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index a38787b84322..e038e343f2c1 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -746,12 +746,6 @@ static void watchdog_reset() {
 }
 #endif
 
-resource_size_t pcibios_align_resource(void *data, const struct resource *res,
-   resource_size_t size, resource_size_t align)
-{
-   return res->start;
-}
-
 int pcibios_enable_device(struct pci_dev *pdev, int mask)
 {
return 0;
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index 3113d4d5c329..8999a20ed9d1 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c

pci: Add generic pcibios_{fixup_bus,align_resource}

2017-06-23 Thread Palmer Dabbelt
While upstreaming the RISC-V port, it was pointed out that multiple
architectures have copied the mostly empty versions of at least one of these
functions.  This defines weakly bound versions of the common functions and
removes the now obselete functions from other ports.

This has been split out from the RISC-V submission so we can decouple all these
generic changes from our port review process.  There's some discussion on an
earlier version of the patch here

  https://lkml.org/lkml/2017/6/6/998

but I'm afraid a lot of this is really out of my wheelhouse (and I'm pretty
slammed trying to get the RISC-V port in better shape), so I'm afraid I'm not
going to be able to perform the full cleanup suggested.


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] pci: Add and use PCI_GENERIC_SETUP Kconfig entry

2017-06-23 Thread Palmer Dabbelt
On Fri, 23 Jun 2017 15:01:04 PDT (-0700), james.ho...@imgtec.com wrote:
> On Fri, Jun 23, 2017 at 02:45:38PM -0700, Palmer Dabbelt wrote:
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index 4c1a35f15838..86872246951c 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -96,6 +96,7 @@ config ARM
>>  select PERF_USE_VMALLOC
>>  select RTC_LIB
>>  select SYS_SUPPORTS_APM_EMULATION
>> +select PCI_GENERIC_SETUP
>>  # Above selects are sorted alphabetically; please add new ones
>>  # according to that.  Thanks.
>
> This comment seems to suggest PCI_GENERIC_SETUP should be added a few
> lines up to preserve the alphabetical sorting.
>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index b2024db225a9..6c684d8c8816 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -115,6 +115,7 @@ config ARM64
>>  select SPARSE_IRQ
>>  select SYSCTL_EXCEPTION_TRACE
>>  select THREAD_INFO_IN_TASK
>> +select PCI_GENERIC_SETUP
>
> Here too.
>
>> diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
>> index 4583c0320059..6679af85a882 100644
>> --- a/arch/tile/Kconfig
>> +++ b/arch/tile/Kconfig
>> @@ -33,6 +33,7 @@ config TILE
>>  select USER_STACKTRACE_SUPPORT
>>  select USE_PMC if PERF_EVENTS
>>  select VIRT_TO_BUS
>> +select PCI_GENERIC_SETUP
>
> and here
>
> Otherwise
> Reviewed-by: James Hogan 

Whoops -- I guess I was just on autopilot after seeing the first one not be
alphabetized.  A fixed patch is in a threaded message.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] pci: Add and use PCI_GENERIC_SETUP Kconfig entry

2017-06-23 Thread James Hogan
On Fri, Jun 23, 2017 at 02:45:38PM -0700, Palmer Dabbelt wrote:
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 4c1a35f15838..86872246951c 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -96,6 +96,7 @@ config ARM
>   select PERF_USE_VMALLOC
>   select RTC_LIB
>   select SYS_SUPPORTS_APM_EMULATION
> + select PCI_GENERIC_SETUP
>   # Above selects are sorted alphabetically; please add new ones
>   # according to that.  Thanks.

This comment seems to suggest PCI_GENERIC_SETUP should be added a few
lines up to preserve the alphabetical sorting.

> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index b2024db225a9..6c684d8c8816 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -115,6 +115,7 @@ config ARM64
>   select SPARSE_IRQ
>   select SYSCTL_EXCEPTION_TRACE
>   select THREAD_INFO_IN_TASK
> + select PCI_GENERIC_SETUP

Here too.

> diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
> index 4583c0320059..6679af85a882 100644
> --- a/arch/tile/Kconfig
> +++ b/arch/tile/Kconfig
> @@ -33,6 +33,7 @@ config TILE
>   select USER_STACKTRACE_SUPPORT
>   select USE_PMC if PERF_EVENTS
>   select VIRT_TO_BUS
> + select PCI_GENERIC_SETUP

and here

Otherwise
Reviewed-by: James Hogan 

Cheers
James


signature.asc
Description: Digital signature
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

[PATCH] pci: Add and use PCI_GENERIC_SETUP Kconfig entry

2017-06-23 Thread Palmer Dabbelt
We wanted to add RISC-V to the list of architectures that used the
generic PCI setup-irq.o inside the Makefile and it was suggested that
instead we define a Kconfig entry and use that.

I've done very minimal testing on this: I just checked to see that
an aarch64 defconfig still build setup-irq.o with the patch applied.
The intention is that this patch doesn't change the behavior of any
build.

Signed-off-by: Palmer Dabbelt 
---
 arch/alpha/Kconfig |  1 +
 arch/arc/Kconfig   |  1 +
 arch/arm/Kconfig   |  1 +
 arch/arm64/Kconfig |  1 +
 arch/m68k/Kconfig  |  1 +
 arch/mips/Kconfig  |  1 +
 arch/sh/Kconfig|  1 +
 arch/sparc/Kconfig |  1 +
 arch/tile/Kconfig  |  1 +
 arch/unicore32/Kconfig |  1 +
 drivers/pci/Kconfig|  3 +++
 drivers/pci/Makefile   | 11 +--
 12 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 0e49d39ea74a..30f4e711f681 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -26,6 +26,7 @@ config ALPHA
select ODD_RT_SIGACTION
select OLD_SIGSUSPEND
select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67
+   select PCI_GENERIC_SETUP
help
  The Alpha is a 64-bit general-purpose processor designed and
  marketed by the Digital Equipment Corporation of blessed memory,
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index a5459698f0ee..dd1f64858118 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -44,6 +44,7 @@ config ARC
select HAVE_GENERIC_DMA_COHERENT
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZMA
+   select PCI_GENERIC_SETUP
 
 config MIGHT_HAVE_PCI
bool
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4c1a35f15838..86872246951c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -96,6 +96,7 @@ config ARM
select PERF_USE_VMALLOC
select RTC_LIB
select SYS_SUPPORTS_APM_EMULATION
+   select PCI_GENERIC_SETUP
# Above selects are sorted alphabetically; please add new ones
# according to that.  Thanks.
help
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b2024db225a9..6c684d8c8816 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -115,6 +115,7 @@ config ARM64
select SPARSE_IRQ
select SYSCTL_EXCEPTION_TRACE
select THREAD_INFO_IN_TASK
+   select PCI_GENERIC_SETUP
help
  ARM 64-bit (AArch64) Linux support.
 
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index d140206d5d29..c16214344f1c 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -22,6 +22,7 @@ config M68K
select MODULES_USE_ELF_RELA
select OLD_SIGSUSPEND3
select OLD_SIGACTION
+   select PCI_GENERIC_SETUP
 
 config RWSEM_GENERIC_SPINLOCK
bool
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 2828ecde133d..474a7c710686 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -70,6 +70,7 @@ config MIPS
select HAVE_EXIT_THREAD
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_COPY_THREAD_TLS
+   select PCI_GENERIC_SETUP
 
 menu "Machine selection"
 
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index ee086958b2b2..90a98ac526fb 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -48,6 +48,7 @@ config SUPERH
select HAVE_ARCH_AUDITSYSCALL
select HAVE_FUTEX_CMPXCHG if FUTEX
select HAVE_NMI
+   select PCI_GENERIC_SETUP
help
  The SuperH is a RISC processor targeted for use in embedded systems
  and consumer electronics; it was also used in the Sega Dreamcast
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 5639c9fe5b55..24cea64104bd 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -424,6 +424,7 @@ config SPARC_LEON
depends on SPARC32
select USB_EHCI_BIG_ENDIAN_MMIO
select USB_EHCI_BIG_ENDIAN_DESC
+   select PCI_GENERIC_SETUP
---help---
  If you say Y here if you are running on a SPARC-LEON processor.
  The LEON processor is a synthesizable VHDL model of the
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 4583c0320059..6679af85a882 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -33,6 +33,7 @@ config TILE
select USER_STACKTRACE_SUPPORT
select USE_PMC if PERF_EVENTS
select VIRT_TO_BUS
+   select PCI_GENERIC_SETUP
 
 config MMU
def_bool y
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index 0769066929c6..162a7d3def0c 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -18,6 +18,7 @@ config UNICORE32
select ARCH_WANT_FRAME_POINTERS
select GENERIC_IOMAP
select MODULES_USE_ELF_REL
+   select PCI_GENERIC_SETUP
help
  UniCore-32 is 32-bit Instruction Set Architecture,
  including a series of low-power-consumption RISC chip
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig

[PATCH 0/3 v5] hsdk: initial port for HSDK board

2017-06-23 Thread Eugeniy Paltsev
This series introduces some required preparations and initial
port of ARC HS Development Kit board with some basic features such
as serial port, USB, SD/MMC and Ethernet.

Essentially we run Linux kernel on all 4 cores (i.e. utilize SMP) and
heavily use IO Coherency for speeding-up DMA-aware peripherals.

Note as opposed to other ARC boards we link Linux kernel to
0x9000_ intentionally because cores 1 and 3 configured with DCCM
situated at our more usual link base 0x8000_.

Note that two patches of this series ("ARC: Decouple linux kernel memory
address and link address" and "ARC: Set IO-coherency aperture base to 
LINUX_LINK_BASE") are prerequisites for HDSK support as its hardware
configuration differs quite a bit from what we used to have on other
ARC boards.

Alexey Brodkin (1):
  ARC: hsdk: initial port for HSDK board

Eugeniy Paltsev (2):
  ARC: Set IO-coherency aperture base to LINUX_LINK_BASE
  ARC: Decouple linux kernel memory address and link address

Changes v4 -> v5:
 * Move DCCM outside of 0x8000_ adress at kernel boot time.
 * Decouple linux kernel memory address and link address.
 * Remove hardcoding of IO-coherency aperture base.
 * Remove reseting CREG_PAE bits as default value is suitable for us.

Changes v3 -> v4:
 * Removed senseless "ranges" property from "memory" node in .dts
 * Refined early-boot code:
- ICCM relocation should be done on each and every core that sports ICCM
  so we leave it in init_per_cpu(). Even though init_per_cpu() gets called
  on the master core pretty late still it is way much earlier than that
  moment when it might affect us - as it only huts us when addresses in
  0x7z-0x7fff_ range are used, i.e. virtual addresses that we don't
  use during init. This also makes code much cleaner compared to
  additional check in case of master etc.

Changes v2 -> v3:
 * Added Rob to Cc-list for DT binding approval
 * Removed mention of prerequsite patch from commit message
 * Removed hsdk_early_init() as hsdk_init_per_cpu() is executed on
   all cores anyways including master
 * Cleaned-up board's .dts a little bit
 * Removed CONFIG_DP83867_PHY from defconfig as it was only used on
   FPGA prototype, on real board we use MICREL PHY which is still selected

Changes v1 -> v2:
 * Update copyright year from 2016 to more up to date 2017
 * Merge early UART clock with AXS10x as in both cases that's 33.3 MHz
 * Bump memory to 1Gb, we don't use more for now because it requires
   trickier IOC setup and usage
 * Update early platform init code:
- Added missing fixup_pae_regs() to per-cpu init
- Mark most of functions as "static __init"
- Use writel_relaxed() for setting CREG_PAE, CREG_PAE_UPDATE is still
  written with stronger writel() since we don't want reordering to happen,
  otherwise value written to CREG_PAE won't be applied

 Documentation/devicetree/bindings/arc/hsdk.txt |   7 ++
 arch/arc/Kconfig   |   6 +
 arch/arc/Makefile  |   1 +
 arch/arc/boot/dts/hsdk.dts | 150 +
 arch/arc/boot/dts/include/dt-bindings  |   1 +
 arch/arc/configs/hsdk_defconfig|  72 
 arch/arc/include/asm/page.h|   2 +-
 arch/arc/kernel/devtree.c  |   5 +-
 arch/arc/mm/cache.c|  33 --
 arch/arc/mm/init.c |   6 +-
 arch/arc/plat-hsdk/Kconfig |  12 ++
 arch/arc/plat-hsdk/Makefile|   9 ++
 arch/arc/plat-hsdk/platform.c  |  77 +
 13 files changed, 366 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arc/hsdk.txt
 create mode 100644 arch/arc/boot/dts/hsdk.dts
 create mode 12 arch/arc/boot/dts/include/dt-bindings
 create mode 100644 arch/arc/configs/hsdk_defconfig
 create mode 100644 arch/arc/plat-hsdk/Kconfig
 create mode 100644 arch/arc/plat-hsdk/Makefile
 create mode 100644 arch/arc/plat-hsdk/platform.c

-- 
2.9.3

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 3/3 v5] ARC: hsdk: initial port for HSDK board

2017-06-23 Thread Eugeniy Paltsev
From: Alexey Brodkin 

This initial port adds support of ARC HS Development Kit board with some
basic features such serial port, USB, SD/MMC and Ethernet.

Essentially we run Linux kernel on all 4 cores (i.e. utilize SMP) and
heavily use IO Coherency for speeding-up DMA-aware peripherals.

Note as opposed to other ARC boards we link Linux kernel to
0x9000_ intentionally because cores 1 and 3 configured with DCCM
situated at our more usual link base 0x8000_. We still can use
memory region starting at 0x8000_ as we reallocate DCCM in our
platform code.

Signed-off-by: Alexey Brodkin 
Signed-off-by: Eugeniy Paltsev 
---
 Documentation/devicetree/bindings/arc/hsdk.txt |   7 ++
 arch/arc/Kconfig   |   1 +
 arch/arc/Makefile  |   1 +
 arch/arc/boot/dts/hsdk.dts | 150 +
 arch/arc/configs/hsdk_defconfig|  72 
 arch/arc/kernel/devtree.c  |   5 +-
 arch/arc/plat-hsdk/Kconfig |  12 ++
 arch/arc/plat-hsdk/Makefile|   9 ++
 arch/arc/plat-hsdk/platform.c  |  53 +
 9 files changed, 308 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arc/hsdk.txt
 create mode 100644 arch/arc/boot/dts/hsdk.dts
 create mode 100644 arch/arc/configs/hsdk_defconfig
 create mode 100644 arch/arc/plat-hsdk/Kconfig
 create mode 100644 arch/arc/plat-hsdk/Makefile
 create mode 100644 arch/arc/plat-hsdk/platform.c

diff --git a/Documentation/devicetree/bindings/arc/hsdk.txt 
b/Documentation/devicetree/bindings/arc/hsdk.txt
new file mode 100644
index 000..be50654
--- /dev/null
+++ b/Documentation/devicetree/bindings/arc/hsdk.txt
@@ -0,0 +1,7 @@
+Synopsys DesignWare ARC HS Development Kit Device Tree Bindings
+---
+
+ARC HSDK Board with quad-core ARC HS38x4 in silicon.
+
+Required root node properties:
+- compatible = "snps,hsdk";
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 75e5276..825a112 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -101,6 +101,7 @@ source "arch/arc/plat-tb10x/Kconfig"
 source "arch/arc/plat-axs10x/Kconfig"
 #New platform adds here
 source "arch/arc/plat-eznps/Kconfig"
+source "arch/arc/plat-hsdk/Kconfig"
 
 endmenu
 
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 44ef35d..55ca925 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -111,6 +111,7 @@ core-$(CONFIG_ARC_PLAT_SIM) += arch/arc/plat-sim/
 core-$(CONFIG_ARC_PLAT_TB10X)  += arch/arc/plat-tb10x/
 core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/
 core-$(CONFIG_ARC_PLAT_EZNPS)  += arch/arc/plat-eznps/
+core-$(CONFIG_ARC_PLAT_HSDK)   += arch/arc/plat-hsdk/
 
 ifdef CONFIG_ARC_PLAT_EZNPS
 KBUILD_CPPFLAGS += -I$(srctree)/arch/arc/plat-eznps/include
diff --git a/arch/arc/boot/dts/hsdk.dts b/arch/arc/boot/dts/hsdk.dts
new file mode 100644
index 000..6a4e471
--- /dev/null
+++ b/arch/arc/boot/dts/hsdk.dts
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2017 Synopsys, Inc. (www.synopsys.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * Device Tree for ARC HS Development Kit
+ */
+/dts-v1/;
+
+/include/ "skeleton_hs_idu.dtsi"
+
+#include 
+
+/ {
+   model = "snps,hsdk";
+   compatible = "snps,hsdk";
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   chosen {
+   bootargs = "earlycon=uart8250,mmio32,0xf0005000,115200n8 
console=ttyS0,115200n8 debug print-fatal-signals=1";
+   };
+
+   cpu {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   interrupt-parent = <_intc>;
+
+   core_clk: core_clk {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <10>;
+   };
+
+   core_intc: archs-intc@cpu {
+   compatible = "snps,archs-intc";
+   interrupt-controller;
+   #interrupt-cells = <1>;
+   };
+
+   idu_intc: idu-interrupt-controller {
+   compatible = "snps,archs-idu-intc";
+   interrupt-controller;
+   #interrupt-cells = <1>;
+   };
+
+   arcpct0: pct {
+   compatible = "snps,archs-pct";
+   };
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   interrupt-parent = <_intc>;
+
+   ranges = <0x 0xf000 

[PATCH 2/3 v5] ARC: Decouple linux kernel memory address and link address

2017-06-23 Thread Eugeniy Paltsev
We faced with problem when we tried to utilize 1G DRAM by linux on
HSDK.

We can't use our usual kernel memory address (0x8000) like on
AXS103 because of DCCM memory bank located at exactly same
address (0x8000)
But we can't simply move kernel memory address to another address (like
0x9000) because IOC base address must be aligned to the
size of the aperture as specified in the IOC size register.

So we had to use 1G aligned address for kernel memory.

We can't use 0x or 0x4000 addresses because addresses
lover then 0x8000 are MMU-translated.
We can't use 0xB000 address because we can define a volatile
uncached region only from AUX_NON_VOLATILE_LIMIT to the
0x. (the end of region is hardcoded)

So, the decision is to link kernel to 0x9000, but use
0x8000-0xBFFF memory region and reallocate DCCM in our platform
code.
This patch only makes possible to set kernel memory address not equal to
kernel link address.

Signed-off-by: Eugeniy Paltsev 
---
 arch/arc/Kconfig| 5 +
 arch/arc/include/asm/page.h | 2 +-
 arch/arc/mm/cache.c | 2 +-
 arch/arc/mm/init.c  | 6 +++---
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index a545969..75e5276 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -430,6 +430,11 @@ config LINUX_LINK_BASE
  However some customers have peripherals mapped at this addr, so
  Linux needs to be scooted a bit.
  If you don't know what the above means, leave this setting alone.
+
+config KERNEL_RAM_BASE_ADDRESS
+   hex "Linux ram base address"
+   default LINUX_LINK_BASE
+   help
  This needs to match memory start address specified in Device Tree
 
 config HIGHMEM
diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h
index 296c342..777f676 100644
--- a/arch/arc/include/asm/page.h
+++ b/arch/arc/include/asm/page.h
@@ -85,7 +85,7 @@ typedef pte_t * pgtable_t;
  */
 #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
 
-#define ARCH_PFN_OFFSETvirt_to_pfn(CONFIG_LINUX_LINK_BASE)
+#define ARCH_PFN_OFFSET
virt_to_pfn(CONFIG_KERNEL_RAM_BASE_ADDRESS)
 
 #ifdef CONFIG_FLATMEM
 #define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
index 383ff77..f303274 100644
--- a/arch/arc/mm/cache.c
+++ b/arch/arc/mm/cache.c
@@ -1113,7 +1113,7 @@ noinline void __init arc_ioc_setup(void)
 * For now we assume IOC aperture to cover all the memory used by the
 * kernel.
 */
-   ap_base = CONFIG_LINUX_LINK_BASE;
+   ap_base = CONFIG_KERNEL_RAM_BASE_ADDRESS;
 
if (ap_base % ap_size != 0)
panic("IOC Aperture start must be aligned to the size of the 
aperture");
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index 8c9415e..f84cba2 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -26,7 +26,7 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __aligned(PAGE_SIZE);
 char empty_zero_page[PAGE_SIZE] __aligned(PAGE_SIZE);
 EXPORT_SYMBOL(empty_zero_page);
 
-static const unsigned long low_mem_start = CONFIG_LINUX_LINK_BASE;
+static const unsigned long low_mem_start = CONFIG_KERNEL_RAM_BASE_ADDRESS;
 static unsigned long low_mem_sz;
 
 #ifdef CONFIG_HIGHMEM
@@ -63,7 +63,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
 
if (!low_mem_sz) {
if (base != low_mem_start)
-   panic("CONFIG_LINUX_LINK_BASE != DT memory { }");
+   panic("CONFIG_KERNEL_RAM_BASE_ADDRESS != DT memory { 
}");
 
low_mem_sz = size;
in_use = 1;
@@ -161,7 +161,7 @@ void __init setup_arch_memory(void)
 * We can't use the helper free_area_init(zones[]) because it uses
 * PAGE_OFFSET to compute the @min_low_pfn which would be wrong
 * when our kernel doesn't start at PAGE_OFFSET, i.e.
-* PAGE_OFFSET != CONFIG_LINUX_LINK_BASE
+* PAGE_OFFSET != CONFIG_KERNEL_RAM_BASE_ADDRESS
 */
free_area_init_node(0,  /* node-id */
zones_size, /* num pages per zone */
-- 
2.9.3


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 1/3 v5] ARC: Set IO-coherency aperture base to LINUX_LINK_BASE

2017-06-23 Thread Eugeniy Paltsev
Most of the time we indeed use the one and only LINUX_LINK_BASE
set to 0x8000_. But there might be good reasons to move
the kernel to another location like 0x9z etc.

And we want IOC aperture to cover entire area used by the kernel,
so let's make its base matching link base and add required asserts:
checking IOC aperture base address and size to be supported by IOC.

Signed-off-by: Eugeniy Paltsev 
---
 arch/arc/mm/cache.c | 33 -
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
index a867575..383ff77 100644
--- a/arch/arc/mm/cache.c
+++ b/arch/arc/mm/cache.c
@@ -1083,7 +1083,8 @@ SYSCALL_DEFINE3(cacheflush, uint32_t, start, uint32_t, 
sz, uint32_t, flags)
  */
 noinline void __init arc_ioc_setup(void)
 {
-   unsigned int ap_sz;
+   unsigned int ap_base;
+   long ap_size;
 
/* Flush + invalidate + disable L1 dcache */
__dc_disable();
@@ -1092,18 +1093,32 @@ noinline void __init arc_ioc_setup(void)
if (read_aux_reg(ARC_REG_SLC_BCR))
slc_entire_op(OP_FLUSH_N_INV);
 
-   /* IOC Aperture start: TDB: handle non default CONFIG_LINUX_LINK_BASE */
-   write_aux_reg(ARC_REG_IO_COH_AP0_BASE, 0x8);
-
/*
-* IOC Aperture size:
-*   decoded as 2 ^ (SIZE + 2) KB: so setting 0x11 implies 512M
-* TBD: fix for PGU + 1GB of low mem
+* IOC Aperture size is equal to memory size.
+* TBD: fix for PGU + 1GiB of low mem
 * TBD: fix for PAE
 */
-   ap_sz = order_base_2(arc_get_mem_sz()/1024) - 2;
-   write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, ap_sz);
+   ap_size = arc_get_mem_sz();
+
+   if (!is_power_of_2(ap_size) || ap_size < 4096)
+   panic("IOC Aperture size must be power of 2 larger than 4KiB");
+
+   /*
+* IOC Aperture size decoded as 2 ^ (SIZE + 2) KiB,
+* so setting 0x11 implies 512MiB, 0x12 implies 1G...
+*/
+   write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, order_base_2(ap_size / 1024) - 
2);
+
+   /*
+* For now we assume IOC aperture to cover all the memory used by the
+* kernel.
+*/
+   ap_base = CONFIG_LINUX_LINK_BASE;
+
+   if (ap_base % ap_size != 0)
+   panic("IOC Aperture start must be aligned to the size of the 
aperture");
 
+   write_aux_reg(ARC_REG_IO_COH_AP0_BASE, ap_base >> 12);
write_aux_reg(ARC_REG_IO_COH_PARTIAL, 1);
write_aux_reg(ARC_REG_IO_COH_ENABLE, 1);
 
-- 
2.9.3


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 1/1] futex: remove duplicated code and fix UB

2017-06-23 Thread Thomas Gleixner
On Wed, 21 Jun 2017, Jiri Slaby wrote:
> diff --git a/arch/arm64/include/asm/futex.h b/arch/arm64/include/asm/futex.h
> index f32b42e8725d..5bb2fd4674e7 100644
> --- a/arch/arm64/include/asm/futex.h
> +++ b/arch/arm64/include/asm/futex.h
> @@ -48,20 +48,10 @@ do {  
> \
>  } while (0)
>  
>  static inline int
> -futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr)

That unsigned int seems to be a change from the arm64 tree in next. It's
not upstream and it'll cause a (easy to resolve) conflict.

> +static int futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr)
> +{
> + int op = (encoded_op >> 28) & 7;
> + int cmp = (encoded_op >> 24) & 15;
> + int oparg = (int)(encoded_op << 8) >> 20;
> + int cmparg = (int)(encoded_op << 20) >> 20;

So this is really bad. We have implicit and explicit type casting to
int. And while we are at it can we please stop proliferating the existing
mess.

'op' and 'cmp' definitly can be unsigned int. There is no reason to cast
them to int.

oparg, cmparg and oldval are more interesting.

The logic here is "documented" in uapi/linux/futex.h

/* FUTEX_WAKE_OP will perform atomically
   int oldval = *(int *)UADDR2;
   *(int *)UADDR2 = oldval OP OPARG;
   if (oldval CMP CMPARG)
   wake UADDR2;  */

Now the FUTEX_OP macro which is supposed to compose the encoded_up does:

#define FUTEX_OP(op, oparg, cmp, cmparg) \
  (((op & 0xf) << 28) | ((cmp & 0xf) << 24) \
   | ((oparg & 0xfff) << 12) | (cmparg & 0xfff))

Of course this all is not typed, undocumented and completely ill
defined.

> + int oparg = (int)(encoded_op << 8) >> 20;
> + int cmparg = (int)(encoded_op << 20) >> 20;

So in fact we sign expand the 12 bits of oparg and cmparg. Really
intuitive.

Yes, we probably can't change that anymore, but at least we should make it
very explicit and add a comment to that effect.

Thanks,

tglx

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc