Page MenuHomeFreeBSD

D34754.id104513.diff
No OneTemporary

D34754.id104513.diff

Index: sys/compat/linuxkpi/common/include/linux/pci.h
===================================================================
--- sys/compat/linuxkpi/common/include/linux/pci.h
+++ sys/compat/linuxkpi/common/include/linux/pci.h
@@ -229,15 +229,33 @@
devclass_t bsdclass;
struct device_driver driver;
const struct pci_error_handlers *err_handler;
- bool isdrm;
+ int bsd_probe_return;
int (*bsd_iov_init)(device_t dev, uint16_t num_vfs,
const nvlist_t *pf_config);
void (*bsd_iov_uninit)(device_t dev);
int (*bsd_iov_add_vf)(device_t dev, uint16_t vfnum,
const nvlist_t *vf_config);
- int bsd_probe_return;
+ uintptr_t _spare[8];
};
+/*
+ * Pseudo-stable KPI. In 13.0 we neglected to include any spare fields to allow
+ * for growth in struct pci_driver. Those were added in 13.1, but can't be used
+ * until 13.1 is the oldest supported release so that packages built in 13.0
+ * will continue to work on stable/13 and 13.1 release. The 13.0 driver was 92
+ * or 182 bytes on 32 or 64 bit systems (respectively). We added 64 or 32 bytes
+ * of padding, hence the math below (which shouldn't be changed as spare fields
+ * are used up).
+ */
+#ifdef __LP64__
+#define __PCI_DRIVER_SIZE (184 + 64)
+#else
+#define __PCI_DRIVER_SIZE (92 + 32)
+#endif
+_Static_assert(sizeof(struct pci_driver) == __PCI_DRIVER_SIZE,
+ "linuxkpi struct pci_driver: Bad size");
+#undef __PCI_DRIVER_SIZE
+
struct pci_bus {
struct pci_dev *self;
int domain;
Index: sys/compat/linuxkpi/common/src/linux_pci.c
===================================================================
--- sys/compat/linuxkpi/common/src/linux_pci.c
+++ sys/compat/linuxkpi/common/src/linux_pci.c
@@ -119,6 +119,12 @@
#define DMA_PRIV_LOCK(priv) mtx_lock(&(priv)->lock)
#define DMA_PRIV_UNLOCK(priv) mtx_unlock(&(priv)->lock)
+static bool
+linux_is_drm(struct pci_driver *pdrv)
+{
+ return (pdrv->name != NULL && strcmp(pdrv->name, "drmn"));
+}
+
static int
linux_pdev_dma_uninit(struct pci_dev *pdev)
{
@@ -405,7 +411,7 @@
linux_set_current(curthread);
parent = device_get_parent(dev);
- isdrm = pdrv != NULL && pdrv->isdrm;
+ isdrm = pdrv != NULL && linux_is_drm(pdrv);
if (isdrm) {
struct pci_devinfo *dinfo;
@@ -674,7 +680,6 @@
dc = devclass_find("pci");
if (dc == NULL)
return (-ENXIO);
- pdrv->isdrm = false;
return (_linux_pci_register_driver(pdrv, dc));
}
@@ -688,7 +693,7 @@
KASSERT(type == SYS_RES_IOPORT || type == SYS_RES_MEMORY,
("trying to reserve non-BAR type %d", type));
- dev = pdev->pdrv != NULL && pdev->pdrv->isdrm ?
+ dev = pdev->pdrv != NULL && linux_is_drm(pdev->pdrv) ?
device_get_parent(pdev->dev.bsddev) : pdev->dev.bsddev;
res = pci_reserve_map(device_get_parent(dev), dev, type, &rid, 0, ~0,
1, 1, 0);
@@ -706,7 +711,7 @@
if ((rle = linux_pci_get_bar(pdev, bar, true)) == NULL)
return (0);
- dev = pdev->pdrv != NULL && pdev->pdrv->isdrm ?
+ dev = pdev->pdrv != NULL && linux_is_drm(pdev->pdrv) ?
device_get_parent(pdev->dev.bsddev) : pdev->dev.bsddev;
if (BUS_TRANSLATE_RESOURCE(dev, rle->type, rle->start, &newstart)) {
device_printf(pdev->dev.bsddev, "translate of %#jx failed\n",
@@ -734,7 +739,6 @@
dc = devclass_create("vgapci");
if (dc == NULL)
return (-ENXIO);
- pdrv->isdrm = true;
pdrv->name = "drmn";
return (_linux_pci_register_driver(pdrv, dc));
}

File Metadata

Mime Type
text/plain
Expires
Thu, Aug 27, 12:11 PM (11 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37383005
Default Alt Text
D34754.id104513.diff (3 KB)

Event Timeline