All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: cavium-octeon: fix I/O space setup on non-PCI systems
@ 2013-07-20 17:38 Aaro Koskinen
  2013-07-22 17:14 ` David Daney
  0 siblings, 1 reply; 2+ messages in thread
From: Aaro Koskinen @ 2013-07-20 17:38 UTC (permalink / raw)
  To: Ralf Baechle, David Daney, Faidon Liambotis, linux-mips; +Cc: Aaro Koskinen

Fix I/O space setup, so that on non-PCI systems using inb()/outb()
won't crash the system. Some drivers may try to probe I/O space and for
that purpose we can just allocate some normal memory. Drivers trying to
reserve a region will fail early as we set the size to 0.

Tested with EdgeRouter Lite by enabling CONFIG_SERIO_I8042 that caused
the originally reported crash.

Reported-by: Faidon Liambotis <paravoid@debian.org>
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
---
 arch/mips/pci/pci-octeon.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/mips/pci/pci-octeon.c b/arch/mips/pci/pci-octeon.c
index 95c2ea8..1bfdcc8c 100644
--- a/arch/mips/pci/pci-octeon.c
+++ b/arch/mips/pci/pci-octeon.c
@@ -8,6 +8,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/vmalloc.h>
 #include <linux/interrupt.h>
 #include <linux/time.h>
 #include <linux/delay.h>
@@ -587,13 +588,16 @@ static int __init octeon_pci_setup(void)
 		octeon_dma_bar_type = OCTEON_DMA_BAR_TYPE_BIG;
 
 	/* PCI I/O and PCI MEM values */
-	set_io_port_base(OCTEON_PCI_IOSPACE_BASE);
-	ioport_resource.start = 0;
-	ioport_resource.end = OCTEON_PCI_IOSPACE_SIZE - 1;
 	if (!octeon_is_pci_host()) {
 		pr_notice("Not in host mode, PCI Controller not initialized\n");
+		set_io_port_base((unsigned long)vzalloc(IO_SPACE_LIMIT));
+		ioport_resource.start = MAX_RESOURCE;
+		ioport_resource.end = 0;
 		return 0;
 	}
+	set_io_port_base(OCTEON_PCI_IOSPACE_BASE);
+	ioport_resource.start = 0;
+	ioport_resource.end = OCTEON_PCI_IOSPACE_SIZE - 1;
 
 	pr_notice("%s Octeon big bar support\n",
 		  (octeon_dma_bar_type ==
-- 
1.8.3.2

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

* Re: [PATCH] MIPS: cavium-octeon: fix I/O space setup on non-PCI systems
  2013-07-20 17:38 [PATCH] MIPS: cavium-octeon: fix I/O space setup on non-PCI systems Aaro Koskinen
@ 2013-07-22 17:14 ` David Daney
  0 siblings, 0 replies; 2+ messages in thread
From: David Daney @ 2013-07-22 17:14 UTC (permalink / raw)
  To: Aaro Koskinen, Ralf Baechle; +Cc: David Daney, Faidon Liambotis, linux-mips

On 07/20/2013 10:38 AM, Aaro Koskinen wrote:
> Fix I/O space setup, so that on non-PCI systems using inb()/outb()
> won't crash the system. Some drivers may try to probe I/O space and for
> that purpose we can just allocate some normal memory. Drivers trying to
> reserve a region will fail early as we set the size to 0.
>
> Tested with EdgeRouter Lite by enabling CONFIG_SERIO_I8042 that caused
> the originally reported crash.
>
> Reported-by: Faidon Liambotis <paravoid@debian.org>
> Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>

NACK.

This doesn't handle the following cases:

1) CONFIG_PCI=n

2) SoCs with PCIe


I think we need to move the 'if (!octeon_is_pci_host())' block to a 
place where it will always run.

David Daney

> ---
>   arch/mips/pci/pci-octeon.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/arch/mips/pci/pci-octeon.c b/arch/mips/pci/pci-octeon.c
> index 95c2ea8..1bfdcc8c 100644
> --- a/arch/mips/pci/pci-octeon.c
> +++ b/arch/mips/pci/pci-octeon.c
> @@ -8,6 +8,7 @@
>   #include <linux/kernel.h>
>   #include <linux/init.h>
>   #include <linux/pci.h>
> +#include <linux/vmalloc.h>
>   #include <linux/interrupt.h>
>   #include <linux/time.h>
>   #include <linux/delay.h>
> @@ -587,13 +588,16 @@ static int __init octeon_pci_setup(void)
>   		octeon_dma_bar_type = OCTEON_DMA_BAR_TYPE_BIG;
>
>   	/* PCI I/O and PCI MEM values */
> -	set_io_port_base(OCTEON_PCI_IOSPACE_BASE);
> -	ioport_resource.start = 0;
> -	ioport_resource.end = OCTEON_PCI_IOSPACE_SIZE - 1;
>   	if (!octeon_is_pci_host()) {
>   		pr_notice("Not in host mode, PCI Controller not initialized\n");
> +		set_io_port_base((unsigned long)vzalloc(IO_SPACE_LIMIT));
> +		ioport_resource.start = MAX_RESOURCE;
> +		ioport_resource.end = 0;
>   		return 0;
>   	}
> +	set_io_port_base(OCTEON_PCI_IOSPACE_BASE);
> +	ioport_resource.start = 0;
> +	ioport_resource.end = OCTEON_PCI_IOSPACE_SIZE - 1;
>
>   	pr_notice("%s Octeon big bar support\n",
>   		  (octeon_dma_bar_type ==
>

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

end of thread, other threads:[~2013-07-22 17:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-20 17:38 [PATCH] MIPS: cavium-octeon: fix I/O space setup on non-PCI systems Aaro Koskinen
2013-07-22 17:14 ` David Daney

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.