Page MenuHomeFreeBSD

D57432.id.diff
No OneTemporary

D57432.id.diff

diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -291,10 +291,6 @@
int number;
};
-extern struct list_head pci_drivers;
-extern struct list_head pci_devices;
-extern spinlock_t pci_lock;
-
#define __devexit_p(x) x
#define module_pci_driver(_drv) \
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -155,9 +155,6 @@
struct kobject linux_class_root;
struct device linux_root_device;
struct class linux_class_misc;
-struct list_head pci_drivers;
-struct list_head pci_devices;
-spinlock_t pci_lock;
struct uts_namespace init_uts_ns;
unsigned long linux_timer_hz_mask;
@@ -2894,9 +2891,6 @@
linux_root_device.bsddev = root_bus;
linux_class_misc.name = "misc";
class_register(&linux_class_misc);
- INIT_LIST_HEAD(&pci_drivers);
- INIT_LIST_HEAD(&pci_devices);
- spin_lock_init(&pci_lock);
init_waitqueue_head(&linux_bit_waitq);
init_waitqueue_head(&linux_var_waitq);
@@ -3007,7 +3001,6 @@
free(__cpu_data, M_KMALLOC);
#endif
- spin_lock_destroy(&pci_lock);
rw_destroy(&linux_vma_lock);
}
SYSUNINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_uninit, NULL);
diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -29,12 +29,10 @@
*/
/*
- * We have two ways to create a pci_dev (pdev):
- * (1) coming from the device_attach DEVMETHOD, and
- * (2) from manual creation via lkpinew_pci_dev(), in which case
- * we have no driver (pdev->pdrv).
- *
- * Only devices from (1) end up on our LinuxKPI global pci_devices list.
+ * This file contains multiple parts:
+ * (1) PCI
+ * (2) DMA
+ * (3) Backlight
*/
#include <sys/param.h>
@@ -85,6 +83,17 @@
#include "backlight_if.h"
#include "pcib_if.h"
+/* -------------------------------------------------------------------------- */
+/*
+ * For PCI:
+ * we have two ways to create a pci_dev (pdev):
+ * (1) coming from the device_attach DEVMETHOD, and
+ * (2) from manual creation via lkpinew_pci_dev(), in which case
+ * we have no driver (pdev->pdrv).
+ *
+ * Only devices from (1) end up on our LinuxKPI global lkpi_pci_devices list.
+ */
+
/* Undef the linux function macro defined in linux/pci.h */
#undef pci_get_class
@@ -110,6 +119,15 @@
static int linux_backlight_get_info(device_t dev, struct backlight_info *info);
static void lkpi_pcim_iomap_table_release(struct device *, void *);
+static struct list_head lkpi_pci_drivers;
+static struct list_head lkpi_pci_devices;
+static spinlock_t lkpi_pci_lock;
+
+#define LKPI_PCI_LOCK_INIT() spin_lock_init(&lkpi_pci_lock)
+#define LKPI_PCI_LOCK_DESTROY() spin_lock_destroy(&lkpi_pci_lock)
+#define LKPI_PCI_LOCK() spin_lock(&lkpi_pci_lock)
+#define LKPI_PCI_UNLOCK() spin_unlock(&lkpi_pci_lock)
+
static device_method_t pci_methods[] = {
DEVMETHOD(device_probe, linux_pci_probe),
DEVMETHOD(device_attach, linux_pci_attach),
@@ -297,20 +315,20 @@
subvendor = pci_get_subvendor(dev);
subdevice = pci_get_subdevice(dev);
- spin_lock(&pci_lock);
- list_for_each_entry(pdrv, &pci_drivers, node) {
+ LKPI_PCI_LOCK();
+ list_for_each_entry(pdrv, &lkpi_pci_drivers, node) {
for (id = pdrv->id_table; id->vendor != 0; id++) {
if (vendor == id->vendor &&
(PCI_ANY_ID == id->device || device == id->device) &&
(PCI_ANY_ID == id->subvendor || subvendor == id->subvendor) &&
(PCI_ANY_ID == id->subdevice || subdevice == id->subdevice)) {
*idp = id;
- spin_unlock(&pci_lock);
+ LKPI_PCI_UNLOCK();
return (pdrv);
}
}
}
- spin_unlock(&pci_lock);
+ LKPI_PCI_UNLOCK();
return (NULL);
}
@@ -321,8 +339,8 @@
odev0 = odev;
found = NULL;
- spin_lock(&pci_lock);
- list_for_each_entry(pdev, &pci_devices, links) {
+ LKPI_PCI_LOCK();
+ list_for_each_entry(pdev, &lkpi_pci_devices, links) {
/* Walk until we find odev. */
if (odev != NULL) {
if (pdev == odev)
@@ -337,7 +355,7 @@
}
}
pci_dev_get(found);
- spin_unlock(&pci_lock);
+ LKPI_PCI_UNLOCK();
pci_dev_put(odev0);
return (found);
@@ -426,9 +444,9 @@
/* Clear the hierarchy recursively to root. */
lkpi_pci_dev_bus_release(pdev);
- spin_lock(&pci_lock);
+ LKPI_PCI_LOCK();
list_del(&pdev->links);
- spin_unlock(&pci_lock);
+ LKPI_PCI_UNLOCK();
linux_pdev_dma_uninit(pdev);
@@ -719,9 +737,9 @@
if (error)
goto err_dma_init;
- spin_lock(&pci_lock);
- list_add(&pdev->links, &pci_devices);
- spin_unlock(&pci_lock);
+ LKPI_PCI_LOCK();
+ list_add(&pdev->links, &lkpi_pci_devices);
+ LKPI_PCI_UNLOCK();
/*
* Create the hierarchy now as we cannot on demand later.
@@ -769,9 +787,9 @@
pdev->root = NULL;
}
err_list_add:
- spin_lock(&pci_lock);
+ LKPI_PCI_LOCK();
list_del(&pdev->links);
- spin_unlock(&pci_lock);
+ LKPI_PCI_UNLOCK();
linux_pdev_dma_uninit(pdev);
err_dma_init:
/*
@@ -1286,9 +1304,9 @@
int error;
linux_set_current(curthread);
- spin_lock(&pci_lock);
- list_add(&pdrv->node, &pci_drivers);
- spin_unlock(&pci_lock);
+ LKPI_PCI_LOCK();
+ list_add(&pdrv->node, &lkpi_pci_drivers);
+ LKPI_PCI_UNLOCK();
if (pdrv->bsddriver.name == NULL)
pdrv->bsddriver.name = pdrv->name;
pdrv->bsddriver.methods = pci_methods;
@@ -1332,15 +1350,15 @@
struct device *found;
found = NULL;
- spin_lock(&pci_lock);
- list_for_each_entry(pdev, &pci_devices, links) {
+ LKPI_PCI_LOCK();
+ list_for_each_entry(pdev, &lkpi_pci_devices, links) {
if (irq == pdev->dev.irq ||
(irq >= pdev->dev.irq_start && irq < pdev->dev.irq_end)) {
found = &pdev->dev;
break;
}
}
- spin_unlock(&pci_lock);
+ LKPI_PCI_UNLOCK();
return (found);
}
@@ -1532,9 +1550,9 @@
bus = devclass_find(pdrv->isdrm ? "vgapci" : "pci");
- spin_lock(&pci_lock);
+ LKPI_PCI_LOCK();
list_del(&pdrv->node);
- spin_unlock(&pci_lock);
+ LKPI_PCI_UNLOCK();
bus_topo_lock();
if (bus != NULL)
devclass_delete_driver(bus, &pdrv->bsddriver);
@@ -1548,9 +1566,9 @@
bus = devclass_find("vgapci");
- spin_lock(&pci_lock);
+ LKPI_PCI_LOCK();
list_del(&pdrv->node);
- spin_unlock(&pci_lock);
+ LKPI_PCI_UNLOCK();
bus_topo_lock();
if (bus != NULL)
devclass_delete_driver(bus, &pdrv->bsddriver);
@@ -1713,6 +1731,25 @@
return (bus_child_present(dev));
}
+static void
+lkpi_pci_init(void *arg __unused)
+{
+ INIT_LIST_HEAD(&lkpi_pci_drivers);
+ INIT_LIST_HEAD(&lkpi_pci_devices);
+ LKPI_PCI_LOCK_INIT();
+}
+SYSINIT(lkpi_pci_init, SI_SUB_DRIVERS, SI_ORDER_SECOND, lkpi_pci_init, NULL);
+
+static void
+lkpi_pci_uninit(void *arg __unused)
+{
+ LKPI_PCI_LOCK_DESTROY();
+}
+SYSUNINIT(lkpi_pci_uninit, SI_SUB_DRIVERS, SI_ORDER_SECOND, lkpi_pci_uninit, NULL);
+
+/* -------------------------------------------------------------------------- */
+/* DMA */
+
CTASSERT(sizeof(dma_addr_t) <= sizeof(uint64_t));
struct linux_dma_obj {
@@ -2339,6 +2376,9 @@
uma_zfree_arg(pool->pool_zone, obj, pool);
}
+/* -------------------------------------------------------------------------- */
+/* Backlight. */
+
static int
linux_backlight_get_status(device_t dev, struct backlight_props *props)
{

File Metadata

Mime Type
text/plain
Expires
Sat, Jun 13, 10:50 PM (6 m, 47 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33935479
Default Alt Text
D57432.id.diff (7 KB)

Event Timeline