Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/pci.h
Show First 20 Lines • Show All 305 Lines • ▼ Show 20 Lines | if (!pm) | ||||
return (-1); | return (-1); | ||||
if (PCI_BAR_IO(pm->pm_value)) | if (PCI_BAR_IO(pm->pm_value)) | ||||
return (SYS_RES_IOPORT); | return (SYS_RES_IOPORT); | ||||
else | else | ||||
return (SYS_RES_MEMORY); | return (SYS_RES_MEMORY); | ||||
} | } | ||||
struct resource_list_entry *linux_pci_reserve_bar(struct pci_dev *pdev, | |||||
struct resource_list *rl, int type, int rid); | |||||
static inline struct resource_list_entry * | static inline struct resource_list_entry * | ||||
linux_pci_get_rle(struct pci_dev *pdev, int type, int rid) | linux_pci_get_rle(struct pci_dev *pdev, int type, int rid, bool reserve_bar) | ||||
hselasky: With regards to MFC-ing it would be better to make two different inline functions for getting… | |||||
Not Done Inline ActionsNevermind. This is apparently all inline functions. hselasky: Nevermind. This is apparently all inline functions. | |||||
{ | { | ||||
struct pci_devinfo *dinfo; | struct pci_devinfo *dinfo; | ||||
struct resource_list *rl; | struct resource_list *rl; | ||||
struct resource_list_entry *rle; | |||||
dinfo = device_get_ivars(pdev->dev.bsddev); | dinfo = device_get_ivars(pdev->dev.bsddev); | ||||
rl = &dinfo->resources; | rl = &dinfo->resources; | ||||
return resource_list_find(rl, type, rid); | rle = resource_list_find(rl, type, rid); | ||||
/* Reserve resources for this BAR if needed. */ | |||||
if (rle == NULL && reserve_bar) | |||||
rle = linux_pci_reserve_bar(pdev, rl, type, rid); | |||||
return (rle); | |||||
} | } | ||||
static inline struct resource_list_entry * | static inline struct resource_list_entry * | ||||
linux_pci_get_bar(struct pci_dev *pdev, int bar) | linux_pci_get_bar(struct pci_dev *pdev, int bar, bool reserve) | ||||
{ | { | ||||
int type; | int type; | ||||
type = pci_resource_type(pdev, bar); | type = pci_resource_type(pdev, bar); | ||||
if (type < 0) | if (type < 0) | ||||
return (NULL); | return (NULL); | ||||
bar = PCIR_BAR(bar); | bar = PCIR_BAR(bar); | ||||
return (linux_pci_get_rle(pdev, type, bar)); | return (linux_pci_get_rle(pdev, type, bar, reserve)); | ||||
} | } | ||||
static inline struct device * | static inline struct device * | ||||
linux_pci_find_irq_dev(unsigned int irq) | linux_pci_find_irq_dev(unsigned int irq) | ||||
{ | { | ||||
struct pci_dev *pdev; | struct pci_dev *pdev; | ||||
struct device *found; | struct device *found; | ||||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | |||||
static inline void | static inline void | ||||
pci_release_region(struct pci_dev *pdev, int bar) | pci_release_region(struct pci_dev *pdev, int bar) | ||||
{ | { | ||||
struct resource_list_entry *rle; | struct resource_list_entry *rle; | ||||
struct pci_devres *dr; | struct pci_devres *dr; | ||||
struct pci_mmio_region *mmio, *p; | struct pci_mmio_region *mmio, *p; | ||||
if ((rle = linux_pci_get_bar(pdev, bar)) == NULL) | if ((rle = linux_pci_get_bar(pdev, bar, false)) == NULL) | ||||
return; | return; | ||||
/* | /* | ||||
* As we implicitly track the requests we also need to clear them on | * As we implicitly track the requests we also need to clear them on | ||||
* release. Do clear before resource release. | * release. Do clear before resource release. | ||||
*/ | */ | ||||
dr = lkpi_pci_devres_find(pdev); | dr = lkpi_pci_devres_find(pdev); | ||||
if (dr != NULL) { | if (dr != NULL) { | ||||
▲ Show 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int nreq) | ||||
/* | /* | ||||
* Handle case where "pci_alloc_msix()" may allocate less | * Handle case where "pci_alloc_msix()" may allocate less | ||||
* interrupts than available and return with no error: | * interrupts than available and return with no error: | ||||
*/ | */ | ||||
if (avail < nreq) { | if (avail < nreq) { | ||||
pci_release_msi(pdev->dev.bsddev); | pci_release_msi(pdev->dev.bsddev); | ||||
return avail; | return avail; | ||||
} | } | ||||
rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1); | rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1, false); | ||||
pdev->dev.irq_start = rle->start; | pdev->dev.irq_start = rle->start; | ||||
pdev->dev.irq_end = rle->start + avail; | pdev->dev.irq_end = rle->start + avail; | ||||
for (i = 0; i < nreq; i++) | for (i = 0; i < nreq; i++) | ||||
entries[i].vector = pdev->dev.irq_start + i; | entries[i].vector = pdev->dev.irq_start + i; | ||||
pdev->msix_enabled = true; | pdev->msix_enabled = true; | ||||
return (0); | return (0); | ||||
} | } | ||||
Show All 36 Lines | pci_enable_msi(struct pci_dev *pdev) | ||||
avail = pci_msi_count(pdev->dev.bsddev); | avail = pci_msi_count(pdev->dev.bsddev); | ||||
if (avail < 1) | if (avail < 1) | ||||
return -EINVAL; | return -EINVAL; | ||||
avail = 1; /* this function only enable one MSI IRQ */ | avail = 1; /* this function only enable one MSI IRQ */ | ||||
if ((error = -pci_alloc_msi(pdev->dev.bsddev, &avail)) != 0) | if ((error = -pci_alloc_msi(pdev->dev.bsddev, &avail)) != 0) | ||||
return error; | return error; | ||||
rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1); | rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1, false); | ||||
pdev->dev.irq_start = rle->start; | pdev->dev.irq_start = rle->start; | ||||
pdev->dev.irq_end = rle->start + avail; | pdev->dev.irq_end = rle->start + avail; | ||||
pdev->irq = rle->start; | pdev->irq = rle->start; | ||||
pdev->msi_enabled = true; | pdev->msi_enabled = true; | ||||
return (0); | return (0); | ||||
} | } | ||||
static inline int | static inline int | ||||
▲ Show 20 Lines • Show All 737 Lines • Show Last 20 Lines |
With regards to MFC-ing it would be better to make two different inline functions for getting the "rle". One as-is, and one with reserve_bar always set true. Then you don't change any existing APIs!