Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pchb@acpi again



Hi! all,


I supported pchb@acpi again for ia64.
This is a driver of RootBridge in the table of ACPI.  This driver
assigns IRQ of a PCI device from PRT (PCI Routing Table) of ACPI.
However, this patch may influence amd64 and i386.  And I do not own
the 'real' PC/AT machine now.

I would like to commit this patch at last next week. 
OK?

Thanks,
--
kiyohara
? pchb_acpi.c
? pchb_acpivar.h
Index: acpi.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.255
diff -u -r1.255 acpi.c
--- acpi.c      23 Sep 2012 00:31:06 -0000      1.255
+++ acpi.c      7 Apr 2013 07:55:53 -0000
@@ -449,6 +449,8 @@
 
        sc->sc_iot = aa->aa_iot;
        sc->sc_memt = aa->aa_memt;
+       sc->sc_dmat = aa->aa_dmat;
+       sc->sc_dmat64 = aa->aa_dmat64;
        sc->sc_pc = aa->aa_pc;
        sc->sc_pciflags = aa->aa_pciflags;
        sc->sc_ic = aa->aa_ic;
@@ -919,6 +921,8 @@
                aa.aa_node = ad;
                aa.aa_iot = sc->sc_iot;
                aa.aa_memt = sc->sc_memt;
+               aa.aa_dmat = sc->sc_dmat;
+               aa.aa_dmat64 = sc->sc_dmat64;
                aa.aa_pc = sc->sc_pc;
                aa.aa_pciflags = sc->sc_pciflags;
                aa.aa_ic = sc->sc_ic;
Index: acpi_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpi_pci.c,v
retrieving revision 1.18
diff -u -r1.18 acpi_pci.c
--- acpi_pci.c  31 Dec 2010 10:56:39 -0000      1.18
+++ acpi_pci.c  7 Apr 2013 07:55:53 -0000
@@ -225,24 +225,16 @@
 
                ap->ap_flags |= ACPI_PCI_INFO_BRIDGE;
 
-               /*
-                * This ACPI node denotes a PCI root bridge, but it may also
-                * denote a PCI device on the bridge's downstream bus segment.
-                */
-               if (ad->ad_devinfo->Valid & ACPI_VALID_ADR) {
-                       ap->ap_bus = ap->ap_downbus;
-                       ap->ap_device =
-                           ACPI_HILODWORD(ad->ad_devinfo->Address);
-                       ap->ap_function =
-                           ACPI_LOLODWORD(ad->ad_devinfo->Address);
-
-                       if (ap->ap_device > 31 ||
-                           (ap->ap_function > 7 && ap->ap_function != 0xFFFF))
-                               aprint_error_dev(ad->ad_root,
-                                   "invalid PCI address for %s\n", 
ad->ad_name);
-                       else
-                               ap->ap_flags |= ACPI_PCI_INFO_DEVICE;
-               }
+               ap->ap_bus = ap->ap_downbus;
+               ap->ap_device = ACPI_HILODWORD(ad->ad_devinfo->Address);
+               ap->ap_function = ACPI_LOLODWORD(ad->ad_devinfo->Address);
+
+               if (ap->ap_device > 31 ||
+                   (ap->ap_function > 7 && ap->ap_function != 0xFFFF))
+                       aprint_error_dev(ad->ad_root,
+                           "invalid PCI address for %s\n", ad->ad_name);
+               else
+                       ap->ap_flags |= ACPI_PCI_INFO_DEVICE;
 
                ad->ad_pciinfo = ap;
 
Index: acpivar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/acpivar.h,v
retrieving revision 1.73
diff -u -r1.73 acpivar.h
--- acpivar.h   1 Aug 2011 11:25:59 -0000       1.73
+++ acpivar.h   7 Apr 2013 07:55:54 -0000
@@ -59,6 +59,8 @@
 struct acpibus_attach_args {
        bus_space_tag_t          aa_iot;        /* PCI I/O space tag */
        bus_space_tag_t          aa_memt;       /* PCI MEM space tag */
+       bus_dma_tag_t            aa_dmat;       /* PCI DMA tag */
+       bus_dma_tag_t            aa_dmat64;     /* PCI 64bit DMA tag */
        pci_chipset_tag_t        aa_pc;         /* PCI chipset */
        int                      aa_pciflags;   /* PCI bus flags */
        isa_chipset_tag_t        aa_ic;         /* ISA chipset */
@@ -156,6 +158,8 @@
 
        bus_space_tag_t          sc_iot;        /* PCI I/O space tag */
        bus_space_tag_t          sc_memt;       /* PCI MEM space tag */
+       bus_dma_tag_t            sc_dmat;       /* PCI DMA tag */
+       bus_dma_tag_t            sc_dmat64;     /* PCI 64bit DMA tag */
        pci_chipset_tag_t        sc_pc;         /* PCI chipset tag */
        int                      sc_pciflags;   /* PCI bus flags */
        int                      sc_pci_bus;    /* internal PCI fixup */
@@ -182,6 +186,8 @@
        struct acpi_devnode *aa_node;   /* ACPI device node */
        bus_space_tag_t aa_iot;         /* PCI I/O space tag */
        bus_space_tag_t aa_memt;        /* PCI MEM space tag */
+       bus_dma_tag_t aa_dmat;          /* PCI DMA tag */
+       bus_dma_tag_t aa_dmat64;        /* PCI 64bit DMA tag */
        pci_chipset_tag_t aa_pc;        /* PCI chipset tag */
        int aa_pciflags;                /* PCI bus flags */
        isa_chipset_tag_t aa_ic;        /* ISA chipset */
Index: files.acpi
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/files.acpi,v
retrieving revision 1.93
diff -u -r1.93 files.acpi
--- files.acpi  22 Jan 2012 06:44:28 -0000      1.93
+++ files.acpi  7 Apr 2013 07:55:54 -0000
@@ -206,4 +206,8 @@
 attach fujhk at acpinodebus
 file   dev/acpi/fujhk_acpi.c           fujhk
 
+# PCI Root Bridge
+attach pchb at acpinodebus with pchb_acpi
+file   dev/acpi/pchb_acpi.c            pchb_acpi
+
 include        "dev/acpi/wmi/files.wmi"
--- pchb_acpi.c.orig    1970-01-01 09:00:00.000000000 +0900
+++ pchb_acpi.c 2013-03-23 12:04:39.000000000 +0900
@@ -0,0 +1,141 @@
+/*     $NetBSD$        */
+/*
+ * Copyright (c) 2010, 2013 KIYOHARA Takashi
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+
+#include <dev/pci/pcivar.h>
+
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/pchb_acpivar.h>
+
+
+struct pchb_acpi_softc {
+       device_t sc_dev;
+
+       pcitag_t sc_tag;
+       ACPI_BUFFER sc_prt;
+};
+
+
+static int pchb_acpi_match(device_t, struct cfdata *, void *);
+static void pchb_acpi_attach(device_t, device_t, void *);
+
+
+CFATTACH_DECL_NEW(pchb_acpi, sizeof(struct pchb_acpi_softc),
+    pchb_acpi_match, pchb_acpi_attach, NULL, NULL);
+
+/*
+ * Supported device IDs
+ */
+static const char * const pchb_acpi_ids[] = {
+       "PNP0A03",      /* PCI/PCI-X Host Bridge */
+       "PNP0A08",      /* PCI Express/PCI-X Mode-2 Host Bridge */
+       NULL
+};
+
+
+/* ARGSUSED */
+static int
+pchb_acpi_match(device_t parent, struct cfdata *match, void *aux)
+{
+       struct acpi_attach_args *aa = aux;
+       struct acpi_devnode *ad = aa->aa_node;
+
+       if (ad->ad_type != ACPI_TYPE_DEVICE)
+               return 0;
+
+       if (ad->ad_devinfo->Flags & ACPI_PCI_ROOT_BRIDGE)
+               /* If we are ACPI_PCI_ROOT_BRIDGE, it is always the truth. */
+               return acpi_match_hid(ad->ad_devinfo, pchb_acpi_ids);
+       return 0;
+}
+
+/* ARGSUSED */
+static void
+pchb_acpi_attach(device_t parent, device_t self, void *aux)
+{
+       struct pchb_acpi_softc *sc = device_private(self);
+       struct acpi_attach_args *aa = aux;
+       struct acpi_devnode *ad = aa->aa_node;
+       struct acpi_pci_info *ap = ad->ad_pciinfo;
+       struct pcibus_attach_args pba;
+       pci_chipset_tag_t pc = aa->aa_pc;
+       ACPI_HANDLE prt;
+       ACPI_STATUS rv;
+
+       aprint_naive("\n");
+       aprint_normal(": ACPI Host-PCI Bridge\n");
+
+       sc->sc_dev = self;
+       sc->sc_tag =
+           pci_make_tag(pc, ap->ap_bus, ap->ap_device, ap->ap_function);
+
+       rv = AcpiGetHandle(ad->ad_handle, "_PRT", &prt);
+       if (ACPI_FAILURE(rv)) {
+               aprint_error_dev(self, "Can't get _PRT\n");
+               return;
+       }
+       sc->sc_prt.Pointer = NULL;
+       sc->sc_prt.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+       rv = AcpiGetIrqRoutingTable(ad->ad_handle, &sc->sc_prt);
+       if (ACPI_FAILURE(rv)) {
+               aprint_error_dev(self, "Can't get PCI Routing Table\n");
+               return;
+       }
+
+       pba.pba_iot = aa->aa_iot;
+       pba.pba_memt = aa->aa_memt;
+       pba.pba_dmat = aa->aa_dmat;
+       pba.pba_dmat64 = aa->aa_dmat64;
+       pba.pba_pc = aa->aa_pc;
+       pba.pba_flags = aa->aa_pciflags;
+       pba.pba_bus = ap->ap_bus;
+       pba.pba_bridgetag = NULL;
+       config_found_ia(self, "pcibus", &pba, pcibusprint);
+}
+
+int
+pchb_acpi_assign_irq(device_t dev, const struct pci_attach_args *pa)
+{
+       struct pchb_acpi_softc *sc = device_private(dev);
+       ACPI_PCI_ROUTING_TABLE *entry;
+
+       entry= sc->sc_prt.Pointer;
+       while (entry && entry->Length > 0) {
+               if (((entry->Address >> 16) & 0xffff) == pa->pa_device &&
+                   entry->Pin + PCI_INTERRUPT_PIN_A == pa->pa_intrpin)
+                       return entry->SourceIndex;
+               entry =
+                   ACPI_ADD_PTR(ACPI_PCI_ROUTING_TABLE, entry, entry->Length);
+       }
+
+       return -1;
+}
--- pchb_acpivar.h.orig 1970-01-01 09:00:00.000000000 +0900
+++ pchb_acpivar.h      2013-03-10 15:31:55.000000000 +0900
@@ -0,0 +1,28 @@
+/*     $NetBSD$        */
+/*
+ * Copyright (c) 2013 KIYOHARA Takashi
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+int pchb_acpi_assign_irq(device_t, const struct pci_attach_args *);


Home | Main Index | Thread Index | Old Index