Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/src/linux_pci.c
| Show First 20 Lines • Show All 1,217 Lines • ▼ Show 20 Lines | lkpi_pci_request_region(struct pci_dev *pdev, int bar, const char *res_name, | ||||
| struct pci_devres *dr; | struct pci_devres *dr; | ||||
| struct pci_mmio_region *mmio; | struct pci_mmio_region *mmio; | ||||
| int rid; | int rid; | ||||
| int type; | int type; | ||||
| if (!lkpi_pci_bar_id_valid(bar)) | if (!lkpi_pci_bar_id_valid(bar)) | ||||
| return (-EINVAL); | return (-EINVAL); | ||||
| /* | |||||
| * If the bar is not valid, return success without adding the BAR; | |||||
| * otherwise linuxkpi_pcim_request_all_regions() will error. | |||||
| */ | |||||
| if (pci_resource_len(pdev, bar) == 0) | |||||
| return (0); | |||||
| /* Likewise if it is neither IO nor MEM, nothing to do for us. */ | |||||
| type = pci_resource_type(pdev, bar); | type = pci_resource_type(pdev, bar); | ||||
| if (type < 0) | if (type < 0) | ||||
| return (0); | return (-ENODEV); | ||||
bz: As a matter of fact this should be 0 for linuxkpi_pci_request_region(). | |||||
| rid = PCIR_BAR(bar); | rid = PCIR_BAR(bar); | ||||
| res = bus_alloc_resource_any(pdev->dev.bsddev, type, &rid, | res = bus_alloc_resource_any(pdev->dev.bsddev, type, &rid, | ||||
| RF_ACTIVE|RF_SHAREABLE); | RF_ACTIVE|RF_SHAREABLE); | ||||
| if (res == NULL) { | if (res == NULL) { | ||||
| device_printf(pdev->dev.bsddev, "%s: failed to alloc " | device_printf(pdev->dev.bsddev, "%s: failed to alloc " | ||||
| "bar %d type %d rid %d\n", | "bar %d type %d rid %d\n", | ||||
| __func__, bar, type, PCIR_BAR(bar)); | __func__, bar, type, PCIR_BAR(bar)); | ||||
| return (-ENODEV); | return (-ENODEV); | ||||
bzAuthorUnsubmitted Done Inline ActionsAnd this should be -EBUSY and the callers should equally check -EBUSY. bz: And this should be -EBUSY and the callers should equally check -EBUSY. | |||||
| } | } | ||||
| /* | /* | ||||
| * It seems there is an implicit devres tracking on these if the device | * It seems there is an implicit devres tracking on these if the device | ||||
| * is managed (lkpi_pci_devres_find() case); otherwise the resources are | * is managed (lkpi_pci_devres_find() case); otherwise the resources are | ||||
| * not automatically freed on FreeBSD/LinuxKPI though they should be/are | * not automatically freed on FreeBSD/LinuxKPI though they should be/are | ||||
| * expected to be by Linux drivers. | * expected to be by Linux drivers. | ||||
| * Otherwise if we are called from a pcim-function with the managed | * Otherwise if we are called from a pcim-function with the managed | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
| int | int | ||||
| linuxkpi_pcim_request_all_regions(struct pci_dev *pdev, const char *res_name) | linuxkpi_pcim_request_all_regions(struct pci_dev *pdev, const char *res_name) | ||||
| { | { | ||||
| int bar, error; | int bar, error; | ||||
| for (bar = 0; bar <= PCIR_MAX_BAR_0; bar++) { | for (bar = 0; bar <= PCIR_MAX_BAR_0; bar++) { | ||||
| error = lkpi_pci_request_region(pdev, bar, res_name, true); | error = lkpi_pci_request_region(pdev, bar, res_name, true); | ||||
| if (error != 0) { | if (error != 0 && error != -ENODEV) { | ||||
| device_printf(pdev->dev.bsddev, "%s: bar %d res_name '%s': " | device_printf(pdev->dev.bsddev, "%s: bar %d res_name '%s': " | ||||
| "lkpi_pci_request_region returned %d\n", __func__, | "lkpi_pci_request_region returned %d\n", __func__, | ||||
| bar, res_name, error); | bar, res_name, error); | ||||
| pci_release_regions(pdev); | pci_release_regions(pdev); | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| } | } | ||||
| return (0); | return (0); | ||||
| ▲ Show 20 Lines • Show All 889 Lines • Show Last 20 Lines | |||||
As a matter of fact this should be 0 for linuxkpi_pci_request_region().