On Thu, Jan 08, 2026 at 01:11:15PM +0200, Edward Srouji wrote:
> +static int phys_addr_to_bar(struct pci_dev *pdev, phys_addr_t pa)
> +{
> +     resource_size_t start, end;
> +     int bar;
> +
> +     for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
> +             /* Skip BARs not present or not memory-mapped */
> +             if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
> +                     continue;
> +
> +             start = pci_resource_start(pdev, bar);
> +             end = pci_resource_end(pdev, bar);
> +
> +             if (!start || !end)
> +                     continue;
> +
> +             if (pa >= start && pa <= end)
> +                     return bar;
> +     }

Don't we know which of the two BARs the mmap entry came from based on
its type? This seems like overkill..

Jason

Reply via email to