linux-mips
[Top] [All Lists]

Re: [PATCH] MIPS: cavium-octeon: fix I/O space setup on non-PCI systems

To: Aaro Koskinen <aaro.koskinen@iki.fi>, Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH] MIPS: cavium-octeon: fix I/O space setup on non-PCI systems
From: David Daney <ddaney.cavm@gmail.com>
Date: Mon, 22 Jul 2013 10:14:14 -0700
Cc: David Daney <david.daney@cavium.com>, Faidon Liambotis <paravoid@debian.org>, linux-mips@linux-mips.org
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=F/SeiZsMDudGY0KK63pAj9pDh7ExM904xMMAQRw1KEg=; b=Z+WsL4rDhHNEmFiHp+F0uTdjzHPe6W7RdCMPjRwJSH9iZ0+TfkbunFvnXiY0jNv/rC eQT+NLXGyW5hNL/U5GlB4XF0z1n2zLB7OJUNNOxvmu4lTIKGWBuitHZ2hB2udYCSe+he DdkEB8EgdVVH93l6LxQ25aUbgtR+zF/R+4JQsE9JM5H6dzdpToj849uEGsgE7emdYmTz kO6P4lnFKHRhTZwz3GKaFNGEEM2TSqijRYGfy2OKGXTjXcH38pmZcStXyOkY9I+Z5XIi MIgaBHM0dSsoX+doLZtlzWRXRViwzExidlZLCiMqoNRrsrOmVK9yBfYchHM+cja5eVc+ +LNw==
In-reply-to: <1374341931-10591-1-git-send-email-aaro.koskinen@iki.fi>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1374341931-10591-1-git-send-email-aaro.koskinen@iki.fi>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7
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 ==



<Prev in Thread] Current Thread [Next in Thread>