Thread View: muc.lists.freebsd.emulation
1 messages
1 total messages
Started by bugzilla-noreply
Mon, 26 Oct 2026 07:36
[Bug 300062] linuxkpi: pci_release_region() never removes pdev->mmio entries ("driver did not clean up; leaking mmio resources" ...
Author: bugzilla-noreply
Date: Mon, 26 Oct 2026 07:36
Date: Mon, 26 Oct 2026 07:36
52 lines
4722 bytes
4722 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300062
--- Comment #4 from Michal Kilijanek <michal+freebsd@kilijanek.pl> ---
Two related latent problems in the same code (linux_pci.c, main 175595ba6).
Neither is triggered by an in-tree driver today, as far as I can tell.
(a) linuxkpi_pcim_iomap() (line 985) stores the result of
linuxkpi_pci_iomap() (line 1000) via lkpi_set_pcim_iomap_devres(), and
that helper always treats its argument as a struct resource *:
dr->mmio_table[bar] = (void *)rman_get_bushandle(res); /* line 980
*/
dr->res_table[bar] = res;
linuxkpi_pci_iomap_range() returns a struct resource * only when
pdev->want_iomap_res is set (line 961); otherwise it returns
rman_get_bushandle(res) + off. For a pcim_iomap() user without
want_iomap_res, rman_get_bushandle() would therefore read device MMIO
as if it were a struct resource. The only in-tree pcim_iomap() user,
iwlwifi, calls linuxkpi_pcim_want_to_use_bus_functions(), and
linuxkpi_pcim_iomap_regions() (used by mt76) calls _lkpi_pci_iomap()
directly, which always returns the resource. So this path is
currently unused, but it is easy to hit with a new driver.
(b) lkpi_pcim_iomap_table_release() calls
pci_iounmap(pdev, dr->mmio_table[bar]) (line 1097), i.e. with the
bus-space handle. With want_iomap_res set, linuxkpi_pci_iounmap()
compares the argument against mmio->res, a struct resource *
(lines 1020-1021), so it never matches and does nothing. That is
what the DTrace run above showed for iwlwifi:
pci_iounmap(0xfffff800fd700000) with no release.
Today (b) happens to be harmless and even protective. For iwlwifi
the region request and the iomap share one pdev->mmio entry (the
"duplicate mapping" path in _lkpi_pci_iomap()), and with the fix
attached here that entry is released exactly once by
pci_release_region(). If (b) were fixed on its own, for example by
passing res_table[bar] to pci_iounmap() or by also matching on the
bus handle, BAR 0 would be released twice: once in pci_iounmap() and
again in pci_release_region(). So fixing (b) needs ownership or
reference counting for entries shared between pci(m)_request_region(s)
and pci(m)_iomap().
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads