<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/pci/setup-bus.c, branch linux-6.15.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-04-18T13:23:22Z</updated>
<entry>
<title>PCI: Restore assigned resources fully after release</title>
<updated>2025-04-18T13:23:22Z</updated>
<author>
<name>Ilpo Järvinen</name>
</author>
<published>2025-04-03T09:31:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a34d74877c66ce484ad586d806002ceaedd58657'/>
<id>urn:sha1:a34d74877c66ce484ad586d806002ceaedd58657</id>
<content type='text'>
PCI resource fitting code in __assign_resources_sorted() runs in multiple
steps. A resource that was successfully assigned may have to be released
before the next step attempts assignment again. The assign+release cycle is
destructive to a start-aligned struct resource (bridge window or IOV
resource) because the start field is overwritten with the real address when
the resource got assigned.

One symptom:

  pci 0002:00:00.0: bridge window [mem size 0x00100000]: can't assign; bogus alignment

Properly restore the resource after releasing it. The start, end, and flags
fields must be stored into the related struct pci_dev_resource in order to
be able to restore the resource to its original state.

Fixes: 96336ec70264 ("PCI: Perform reset_resource() and build fail list in sync")
Reported-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Closes: https://lore.kernel.org/r/01eb7d40-f5b5-4ec5-b390-a5c042c30aff@roeck-us.net/
Reported-by: Nicolas Frattaroli &lt;nicolas.frattaroli@collabora.com&gt;
Closes: https://lore.kernel.org/r/3578030.5fSG56mABF@workhorse
Signed-off-by: Ilpo Järvinen &lt;ilpo.jarvinen@linux.intel.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Tested-by: Nicolas Frattaroli &lt;nicolas.frattaroli@collabora.com&gt;
Tested-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Tested-by: Ondrej Jirman &lt;megi@xff.cz&gt;
Link: https://patch.msgid.link/20250403093137.1481-1-ilpo.jarvinen@linux.intel.com
</content>
</entry>
<entry>
<title>Merge branch 'pci/misc'</title>
<updated>2025-03-27T18:15:05Z</updated>
<author>
<name>Bjorn Helgaas</name>
</author>
<published>2025-03-27T18:15:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dea140198b846f7432d78566b7b0b83979c72c2b'/>
<id>urn:sha1:dea140198b846f7432d78566b7b0b83979c72c2b</id>
<content type='text'>
- Remove unused tools 'pci' build target left over after moving tests to
  tools/testing/selftests/pci_endpoint (Jianfeng Liu)

- Fix typos and whitespace errors (Bjorn Helgaas)

* pci/misc:
  PCI: Fix typos
  tools/Makefile: Remove pci target

# Conflicts:
#	drivers/pci/endpoint/functions/pci-epf-test.c
</content>
</entry>
<entry>
<title>PCI: Make pci_setup_bridge() static</title>
<updated>2025-03-20T21:44:26Z</updated>
<author>
<name>Ilpo Järvinen</name>
</author>
<published>2025-03-11T17:47:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2f255e299c676cbae4b0d164a497a0553b86845a'/>
<id>urn:sha1:2f255e299c676cbae4b0d164a497a0553b86845a</id>
<content type='text'>
pci_setup_bridge() is only used within setup-bus.c. Therefore, make it a
static function.

Link: https://lore.kernel.org/r/20250311174701.3586-3-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen &lt;ilpo.jarvinen@linux.intel.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
</content>
</entry>
<entry>
<title>PCI: Fix typos</title>
<updated>2025-03-08T21:08:45Z</updated>
<author>
<name>Bjorn Helgaas</name>
</author>
<published>2025-03-07T23:17:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f4e026f454d7bb6aa84901a37641132961054735'/>
<id>urn:sha1:f4e026f454d7bb6aa84901a37641132961054735</id>
<content type='text'>
Fix typos and whitespace errors.

Link: https://lore.kernel.org/r/20250307231715.438518-1-helgaas@kernel.org
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
</content>
</entry>
<entry>
<title>PCI: Increase Resizable BAR support from 512 GB to 128 TB</title>
<updated>2025-03-07T17:23:34Z</updated>
<author>
<name>Zhiyuan Dai</name>
</author>
<published>2025-03-07T05:35:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5af473941b56189423a7d16c05efabaf77299847'/>
<id>urn:sha1:5af473941b56189423a7d16c05efabaf77299847</id>
<content type='text'>
Per PCIe r6.0, sec 7.8.6.2, devices can advertise Resizable BAR sizes up to
128 TB in the Resizable BAR Capability register.  Larger sizes can be
advertised via the Capability register, but that requires an API change.

Update pci_rebar_get_possible_sizes() and pbus_size_mem() to increase the
sizes we currently support from 512 GB to 128 TB.

Link: https://lore.kernel.org/r/20250307053535.44918-1-daizhiyuan@phytium.com.cn
Signed-off-by: Zhiyuan Dai &lt;daizhiyuan@phytium.com.cn&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
</content>
</entry>
<entry>
<title>PCI: Rework optional resource handling</title>
<updated>2025-02-18T21:40:54Z</updated>
<author>
<name>Ilpo Järvinen</name>
</author>
<published>2024-12-16T17:56:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2499f53484314303f1b90f86424d9ec1bef9119d'/>
<id>urn:sha1:2499f53484314303f1b90f86424d9ec1bef9119d</id>
<content type='text'>
Remove and rescan cycle can result in failure to assign a bridge window if
it becomes larger than before the remove. The bridge window size will
include space for disabled Expansion ROM, which can causes the bridge
window to not fit anymore into the same address space slot on rescan if the
Expansion ROM resource was not assigned before the remove. In addition, the
optional resource handling is not internally consistent.

The resource fitting logic supports three main types of optional resources:

  - IOV BARs
  - Expansion ROMs
  - Bridge window size variation due to optional resources

In addition to the above, resizable BARs beyond their current size will
require handling optional variation in resource sizes within the resource
fitting algorithm (not yet done by the resource fitting code).

There are multiple inconsistencies related to optional resource handling:

a) The allocation failure of disabled expansion ROM requires special case
   inside assign_requested_resources_sorted().

b) The optionality of disabled expansion ROM is not considered during
   bridge window sizing in pbus_size_mem().

c) Setting resource size to zero for optional resource in pbus_size_mem()
   is problematic because it makes also the alignment invalid, which is
   checked by pdev_sort_resources().

   Optional IOV resources have their size set to zero by pbus_size_mem()
   but the information about size is stored externally in struct pci_sriov
   and complex call-chain trickery in pci_resource_alignment() ensures IOV
   resources return a valid alignment despite having zero resource size. A
   solution that is specific to IOV resources makes it hard to use the same
   solution for other types of resources such as expansion ROM.

Simply changing pbus_size_mem() is not sufficient to fully address the main
issue because it would introduce disparity between bridge window sizing and
resource allocation. Due to size-based ordering of the resource list during
assignment loop, an Expansion ROM resource could steal space from some
other resource and make the other resource not fit if the Expansion ROM is
larger than the other resource. Thus, the resource assignment functions
need to be changed as well.

Make optional resource handling more straightforward. Use
pci_resource_is_optional() to determine if a resource is optional in both
bridge window sizing and assignment failure classification to ensure they
always align. Indicate with a parameter to
assign_requested_resources_sorted() whether it should attempt to allocate
optional resources or not.

Always try first to assign all resources (also when realloc_head is not
provided). This is required for calls from
pci_assign_unassigned_root_bus_resources() that provide realloc_head only
with some of its iterations.

Non-bridge-window optional resources in realloc_head now have add_size 0.
This condition has to be detected in reassign_resources_sorted() before
reassigning them (which would fail as there is no size change).  Removing
add_size=0 optional resources entirely from realloc_head might eventually
be doable but further rework in __assign_resources_sorted() is needed first
to support such a change.

Link: https://lore.kernel.org/r/20241216175632.4175-26-ilpo.jarvinen@linux.intel.com
Reported-by: Jia Yao &lt;jia.yao@intel.com&gt;
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219547
Signed-off-by: Ilpo Järvinen &lt;ilpo.jarvinen@linux.intel.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Tested-by: Jia Yao &lt;jia.yao@intel.com&gt;
Tested-by: Xiaochun Lee &lt;lixc17@lenovo.com&gt;
</content>
</entry>
<entry>
<title>PCI: Perform reset_resource() and build fail list in sync</title>
<updated>2025-02-18T21:40:54Z</updated>
<author>
<name>Ilpo Järvinen</name>
</author>
<published>2024-12-16T17:56:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=96336ec702643aec2addb3b1cdb81d687fe362f0'/>
<id>urn:sha1:96336ec702643aec2addb3b1cdb81d687fe362f0</id>
<content type='text'>
Resetting a resource is problematic as it prevents attempting to allocate
the resource later, unless something in between restores the resource.
Similarly, if fail_head does not contain all resources that were reset,
those resources cannot be restored later.

The entire reset/restore cycle adds complexity and leaving resources in the
reset state causes issues to other code such as for checks done in
pci_enable_resources(). Take a small step towards not resetting resources
by delaying reset until the end of resource assignment and build failure
list (fail_head) in sync with the reset to avoid leaving behind resources
that cannot be restored (for the case where the caller provides fail_head
in the first place to allow restore somewhere in the callchain, as is not
all callers pass non-NULL fail_head).

Leave the Expansion ROM check temporarily in place while building the
failure list until an upcoming change that reworks optional resource
handling.

Ideally, whole resource reset could be removed but doing that in one step
would be non-tractable due to complexity of all related code.

Link: https://lore.kernel.org/r/20241216175632.4175-25-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen &lt;ilpo.jarvinen@linux.intel.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Tested-by: Xiaochun Lee &lt;lixc17@lenovo.com&gt;
</content>
</entry>
<entry>
<title>PCI: Use res-&gt;parent to check if resource is assigned</title>
<updated>2025-02-18T21:40:54Z</updated>
<author>
<name>Ilpo Järvinen</name>
</author>
<published>2024-12-16T17:56:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e89df6d2beae847e931d84a190b192dfac41eba7'/>
<id>urn:sha1:e89df6d2beae847e931d84a190b192dfac41eba7</id>
<content type='text'>
reassign_resources_sorted() uses resource_size() to select between
pci_assign_resource() and pci_reassign_resource(). Due to twisted way
bridge window sizing in pbus_size_mem() sets resource sizes to 0, it works
to match into IOV resources but that is going to be changed by an upcoming
change.

Replace resource_size() check with res-&gt;parent check that is the true
dividing line in between whether assign or reassign function should be used
for the resource.

Link: https://lore.kernel.org/r/20241216175632.4175-24-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen &lt;ilpo.jarvinen@linux.intel.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Tested-by: Xiaochun Lee &lt;lixc17@lenovo.com&gt;
</content>
</entry>
<entry>
<title>PCI: Add debug print when releasing resources before retry</title>
<updated>2025-02-18T21:40:54Z</updated>
<author>
<name>Ilpo Järvinen</name>
</author>
<published>2024-12-16T17:56:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8884b5637b794ae541e8d6fb72102b1d8dba2b8d'/>
<id>urn:sha1:8884b5637b794ae541e8d6fb72102b1d8dba2b8d</id>
<content type='text'>
PCI resource fitting is somewhat hard to track because it performs many
actions without logging them. In the case inside
__assign_resources_sorted(), the resources are released before resource
assignment is going to be retried in a different order. That is just one
level of retries the resource fitting performs overall so tracking it
through repeated assignments or failures of a resource gets messy rather
quickly.

Simply announce the release explicitly using pci_dbg() so it is clear what
is going on with each resource.

Link: https://lore.kernel.org/r/20241216175632.4175-23-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen &lt;ilpo.jarvinen@linux.intel.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Tested-by: Xiaochun Lee &lt;lixc17@lenovo.com&gt;
</content>
</entry>
<entry>
<title>PCI: Indicate optional resource assignment failures</title>
<updated>2025-02-18T21:40:54Z</updated>
<author>
<name>Ilpo Järvinen</name>
</author>
<published>2024-12-16T17:56:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=07854e08cdf3e2c294ca7941a8958830d880eaf7'/>
<id>urn:sha1:07854e08cdf3e2c294ca7941a8958830d880eaf7</id>
<content type='text'>
Add pci_dbg() to note that an assignment failure was for an optional
resource and reword existing message about resource resize to say the
change was optional.

Link: https://lore.kernel.org/r/20241216175632.4175-22-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen &lt;ilpo.jarvinen@linux.intel.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Tested-by: Xiaochun Lee &lt;lixc17@lenovo.com&gt;
</content>
</entry>
</feed>
