* [PATCH AUTOSEL 6.14 016/642] iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability
[not found] <20250505221419.2672473-1-sashal@kernel.org>
@ 2025-05-05 22:03 ` Sasha Levin
2025-05-05 22:04 ` [PATCH AUTOSEL 6.14 052/642] PCI: dwc: ep: Ensure proper iteration over outbound map windows Sasha Levin
` (12 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:03 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Yi Liu, Bjorn Helgaas, Kevin Tian, Jason Gunthorpe, Zhangfei Gao,
Nicolin Chen, Sasha Levin, joro, will, iommu, linux-pci
From: Yi Liu <yi.l.liu@intel.com>
[ Upstream commit 803f97298e7de9242eb677a1351dcafbbcc9117e ]
PASID usage requires PASID support in both device and IOMMU. Since the
iommu drivers always enable the PASID capability for the device if it
is supported, this extends the IOMMU_GET_HW_INFO to report the PASID
capability to userspace. Also, enhances the selftest accordingly.
Link: https://patch.msgid.link/r/20250321180143.8468-5-yi.l.liu@intel.com
Cc: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org> #aarch64 platform
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iommu/iommufd/device.c | 34 +++++++++++++++++++++++++++++++++-
drivers/pci/ats.c | 33 +++++++++++++++++++++++++++++++++
include/linux/pci-ats.h | 3 +++
include/uapi/linux/iommufd.h | 14 +++++++++++++-
4 files changed, 82 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 3c7800d4ab622..66a6b7466820d 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -3,6 +3,7 @@
*/
#include <linux/iommu.h>
#include <linux/iommufd.h>
+#include <linux/pci-ats.h>
#include <linux/slab.h>
#include <uapi/linux/iommufd.h>
@@ -1304,7 +1305,8 @@ int iommufd_get_hw_info(struct iommufd_ucmd *ucmd)
void *data;
int rc;
- if (cmd->flags || cmd->__reserved)
+ if (cmd->flags || cmd->__reserved[0] || cmd->__reserved[1] ||
+ cmd->__reserved[2])
return -EOPNOTSUPP;
idev = iommufd_get_device(ucmd, cmd->dev_id);
@@ -1361,6 +1363,36 @@ int iommufd_get_hw_info(struct iommufd_ucmd *ucmd)
if (device_iommu_capable(idev->dev, IOMMU_CAP_DIRTY_TRACKING))
cmd->out_capabilities |= IOMMU_HW_CAP_DIRTY_TRACKING;
+ cmd->out_max_pasid_log2 = 0;
+ /*
+ * Currently, all iommu drivers enable PASID in the probe_device()
+ * op if iommu and device supports it. So the max_pasids stored in
+ * dev->iommu indicates both PASID support and enable status. A
+ * non-zero dev->iommu->max_pasids means PASID is supported and
+ * enabled. The iommufd only reports PASID capability to userspace
+ * if it's enabled.
+ */
+ if (idev->dev->iommu->max_pasids) {
+ cmd->out_max_pasid_log2 = ilog2(idev->dev->iommu->max_pasids);
+
+ if (dev_is_pci(idev->dev)) {
+ struct pci_dev *pdev = to_pci_dev(idev->dev);
+ int ctrl;
+
+ ctrl = pci_pasid_status(pdev);
+
+ WARN_ON_ONCE(ctrl < 0 ||
+ !(ctrl & PCI_PASID_CTRL_ENABLE));
+
+ if (ctrl & PCI_PASID_CTRL_EXEC)
+ cmd->out_capabilities |=
+ IOMMU_HW_CAP_PCI_PASID_EXEC;
+ if (ctrl & PCI_PASID_CTRL_PRIV)
+ cmd->out_capabilities |=
+ IOMMU_HW_CAP_PCI_PASID_PRIV;
+ }
+ }
+
rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd));
out_free:
kfree(data);
diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
index c6b266c772c81..ec6c8dbdc5e9c 100644
--- a/drivers/pci/ats.c
+++ b/drivers/pci/ats.c
@@ -538,4 +538,37 @@ int pci_max_pasids(struct pci_dev *pdev)
return (1 << FIELD_GET(PCI_PASID_CAP_WIDTH, supported));
}
EXPORT_SYMBOL_GPL(pci_max_pasids);
+
+/**
+ * pci_pasid_status - Check the PASID status
+ * @pdev: PCI device structure
+ *
+ * Returns a negative value when no PASID capability is present.
+ * Otherwise the value of the control register is returned.
+ * Status reported are:
+ *
+ * PCI_PASID_CTRL_ENABLE - PASID enabled
+ * PCI_PASID_CTRL_EXEC - Execute permission enabled
+ * PCI_PASID_CTRL_PRIV - Privileged mode enabled
+ */
+int pci_pasid_status(struct pci_dev *pdev)
+{
+ int pasid;
+ u16 ctrl;
+
+ if (pdev->is_virtfn)
+ pdev = pci_physfn(pdev);
+
+ pasid = pdev->pasid_cap;
+ if (!pasid)
+ return -EINVAL;
+
+ pci_read_config_word(pdev, pasid + PCI_PASID_CTRL, &ctrl);
+
+ ctrl &= PCI_PASID_CTRL_ENABLE | PCI_PASID_CTRL_EXEC |
+ PCI_PASID_CTRL_PRIV;
+
+ return ctrl;
+}
+EXPORT_SYMBOL_GPL(pci_pasid_status);
#endif /* CONFIG_PCI_PASID */
diff --git a/include/linux/pci-ats.h b/include/linux/pci-ats.h
index 0e8b74e63767a..75c6c86cf09dc 100644
--- a/include/linux/pci-ats.h
+++ b/include/linux/pci-ats.h
@@ -42,6 +42,7 @@ int pci_enable_pasid(struct pci_dev *pdev, int features);
void pci_disable_pasid(struct pci_dev *pdev);
int pci_pasid_features(struct pci_dev *pdev);
int pci_max_pasids(struct pci_dev *pdev);
+int pci_pasid_status(struct pci_dev *pdev);
#else /* CONFIG_PCI_PASID */
static inline int pci_enable_pasid(struct pci_dev *pdev, int features)
{ return -EINVAL; }
@@ -50,6 +51,8 @@ static inline int pci_pasid_features(struct pci_dev *pdev)
{ return -EINVAL; }
static inline int pci_max_pasids(struct pci_dev *pdev)
{ return -EINVAL; }
+static inline int pci_pasid_status(struct pci_dev *pdev)
+{ return -EINVAL; }
#endif /* CONFIG_PCI_PASID */
#endif /* LINUX_PCI_ATS_H */
diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h
index 78747b24bd0fb..9495604e40b06 100644
--- a/include/uapi/linux/iommufd.h
+++ b/include/uapi/linux/iommufd.h
@@ -608,9 +608,17 @@ enum iommu_hw_info_type {
* IOMMU_HWPT_GET_DIRTY_BITMAP
* IOMMU_HWPT_SET_DIRTY_TRACKING
*
+ * @IOMMU_HW_CAP_PCI_PASID_EXEC: Execute Permission Supported, user ignores it
+ * when the struct
+ * iommu_hw_info::out_max_pasid_log2 is zero.
+ * @IOMMU_HW_CAP_PCI_PASID_PRIV: Privileged Mode Supported, user ignores it
+ * when the struct
+ * iommu_hw_info::out_max_pasid_log2 is zero.
*/
enum iommufd_hw_capabilities {
IOMMU_HW_CAP_DIRTY_TRACKING = 1 << 0,
+ IOMMU_HW_CAP_PCI_PASID_EXEC = 1 << 1,
+ IOMMU_HW_CAP_PCI_PASID_PRIV = 1 << 2,
};
/**
@@ -626,6 +634,9 @@ enum iommufd_hw_capabilities {
* iommu_hw_info_type.
* @out_capabilities: Output the generic iommu capability info type as defined
* in the enum iommu_hw_capabilities.
+ * @out_max_pasid_log2: Output the width of PASIDs. 0 means no PASID support.
+ * PCI devices turn to out_capabilities to check if the
+ * specific capabilities is supported or not.
* @__reserved: Must be 0
*
* Query an iommu type specific hardware information data from an iommu behind
@@ -649,7 +660,8 @@ struct iommu_hw_info {
__u32 data_len;
__aligned_u64 data_uptr;
__u32 out_data_type;
- __u32 __reserved;
+ __u8 out_max_pasid_log2;
+ __u8 __reserved[3];
__aligned_u64 out_capabilities;
};
#define IOMMU_GET_HW_INFO _IO(IOMMUFD_TYPE, IOMMUFD_CMD_GET_HW_INFO)
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 052/642] PCI: dwc: ep: Ensure proper iteration over outbound map windows
[not found] <20250505221419.2672473-1-sashal@kernel.org>
2025-05-05 22:03 ` [PATCH AUTOSEL 6.14 016/642] iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability Sasha Levin
@ 2025-05-05 22:04 ` Sasha Levin
2025-05-05 22:04 ` [PATCH AUTOSEL 6.14 055/642] PCI: xilinx-cpm: Add cpm_csr register mapping for CPM5_HOST1 variant Sasha Levin
` (11 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:04 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Frank Li, Bjorn Helgaas, Sasha Levin, jingoohan1,
manivannan.sadhasivam, lpieralisi, kw, linux-pci
From: Frank Li <Frank.Li@nxp.com>
[ Upstream commit f3e1dccba0a0833fc9a05fb838ebeb6ea4ca0e1a ]
Most systems' PCIe outbound map windows have non-zero physical addresses,
but the possibility of encountering zero increased after following commit
("PCI: dwc: Use parent_bus_offset").
'ep->outbound_addr[n]', representing 'parent_bus_address', might be 0 on
some hardware, which trims high address bits through bus fabric before
sending to the PCIe controller.
Replace the iteration logic with 'for_each_set_bit()' to ensure only
allocated map windows are iterated when determining the ATU index from a
given address.
Link: https://lore.kernel.org/r/20250315201548.858189-12-helgaas@kernel.org
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/controller/dwc/pcie-designware-ep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index e41479a9ca027..c91d095024689 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -282,7 +282,7 @@ static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr,
u32 index;
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
- for (index = 0; index < pci->num_ob_windows; index++) {
+ for_each_set_bit(index, ep->ob_window_map, pci->num_ob_windows) {
if (ep->outbound_addr[index] != addr)
continue;
*atu_index = index;
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 055/642] PCI: xilinx-cpm: Add cpm_csr register mapping for CPM5_HOST1 variant
[not found] <20250505221419.2672473-1-sashal@kernel.org>
2025-05-05 22:03 ` [PATCH AUTOSEL 6.14 016/642] iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability Sasha Levin
2025-05-05 22:04 ` [PATCH AUTOSEL 6.14 052/642] PCI: dwc: ep: Ensure proper iteration over outbound map windows Sasha Levin
@ 2025-05-05 22:04 ` Sasha Levin
2025-05-05 22:04 ` [PATCH AUTOSEL 6.14 063/642] PCI: vmd: Disable MSI remapping bypass under Xen Sasha Levin
` (10 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:04 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Thippeswamy Havalige, Krzysztof Wilczyński, Sasha Levin,
bharat.kumar.gogada, michal.simek, lpieralisi, kw,
manivannan.sadhasivam, bhelgaas, linux-pci, linux-arm-kernel
From: Thippeswamy Havalige <thippeswamy.havalige@amd.com>
[ Upstream commit 9e141923cf86b2e1c83d21b87fb4de3d14a20c99 ]
Update the CPM5 check to include CPM5_HOST1 variant. Previously, only
CPM5 was considered when mapping the "cpm_csr" register.
With this change, CPM5_HOST1 is also supported, ensuring proper
resource mapping for this variant.
Signed-off-by: Thippeswamy Havalige <thippeswamy.havalige@amd.com>
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Link: https://lore.kernel.org/r/20250317124136.1317723-1-thippeswamy.havalige@amd.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/controller/pcie-xilinx-cpm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/pcie-xilinx-cpm.c b/drivers/pci/controller/pcie-xilinx-cpm.c
index dc8ecdbee56c8..163d805673d6d 100644
--- a/drivers/pci/controller/pcie-xilinx-cpm.c
+++ b/drivers/pci/controller/pcie-xilinx-cpm.c
@@ -538,7 +538,8 @@ static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port,
if (IS_ERR(port->cfg))
return PTR_ERR(port->cfg);
- if (port->variant->version == CPM5) {
+ if (port->variant->version == CPM5 ||
+ port->variant->version == CPM5_HOST1) {
port->reg_base = devm_platform_ioremap_resource_byname(pdev,
"cpm_csr");
if (IS_ERR(port->reg_base))
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 063/642] PCI: vmd: Disable MSI remapping bypass under Xen
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (2 preceding siblings ...)
2025-05-05 22:04 ` [PATCH AUTOSEL 6.14 055/642] PCI: xilinx-cpm: Add cpm_csr register mapping for CPM5_HOST1 variant Sasha Levin
@ 2025-05-05 22:04 ` Sasha Levin
2025-05-05 22:05 ` [PATCH AUTOSEL 6.14 128/642] PCI: dwc: Use resource start as ioremap() input in dw_pcie_pme_turn_off() Sasha Levin
` (9 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:04 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Roger Pau Monne, Bjorn Helgaas, Juergen Gross, Sasha Levin,
nirmal.patel, lpieralisi, kw, manivannan.sadhasivam, linux-pci
From: Roger Pau Monne <roger.pau@citrix.com>
[ Upstream commit 6c4d5aadf5df31ea0ac025980670eee9beaf466b ]
MSI remapping bypass (directly configuring MSI entries for devices on the
VMD bus) won't work under Xen, as Xen is not aware of devices in such bus,
and hence cannot configure the entries using the pIRQ interface in the PV
case, and in the PVH case traps won't be setup for MSI entries for such
devices.
Until Xen is aware of devices in the VMD bus prevent the
VMD_FEAT_CAN_BYPASS_MSI_REMAP capability from being used when running as
any kind of Xen guest.
The MSI remapping bypass is an optional feature of VMD bridges, and hence
when running under Xen it will be masked and devices will be forced to
redirect its interrupts from the VMD bridge. That mode of operation must
always be supported by VMD bridges and works when Xen is not aware of
devices behind the VMD bridge.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Message-ID: <20250219092059.90850-3-roger.pau@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/controller/vmd.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index 94ceec50a2b94..8df064b62a2ff 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -17,6 +17,8 @@
#include <linux/rculist.h>
#include <linux/rcupdate.h>
+#include <xen/xen.h>
+
#include <asm/irqdomain.h>
#define VMD_CFGBAR 0
@@ -970,6 +972,24 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
struct vmd_dev *vmd;
int err;
+ if (xen_domain()) {
+ /*
+ * Xen doesn't have knowledge about devices in the VMD bus
+ * because the config space of devices behind the VMD bridge is
+ * not known to Xen, and hence Xen cannot discover or configure
+ * them in any way.
+ *
+ * Bypass of MSI remapping won't work in that case as direct
+ * write by Linux to the MSI entries won't result in functional
+ * interrupts, as Xen is the entity that manages the host
+ * interrupt controller and must configure interrupts. However
+ * multiplexing of interrupts by the VMD bridge will work under
+ * Xen, so force the usage of that mode which must always be
+ * supported by VMD bridges.
+ */
+ features &= ~VMD_FEAT_CAN_BYPASS_MSI_REMAP;
+ }
+
if (resource_size(&dev->resource[VMD_CFGBAR]) < (1 << 20))
return -ENOMEM;
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 128/642] PCI: dwc: Use resource start as ioremap() input in dw_pcie_pme_turn_off()
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (3 preceding siblings ...)
2025-05-05 22:04 ` [PATCH AUTOSEL 6.14 063/642] PCI: vmd: Disable MSI remapping bypass under Xen Sasha Levin
@ 2025-05-05 22:05 ` Sasha Levin
2025-05-05 22:07 ` [PATCH AUTOSEL 6.14 213/642] PCI: endpoint: pci-epf-test: Fix double free that causes kernel to oops Sasha Levin
` (8 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:05 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Frank Li, Bjorn Helgaas, Sasha Levin, jingoohan1,
manivannan.sadhasivam, lpieralisi, kw, linux-pci
From: Frank Li <Frank.Li@nxp.com>
[ Upstream commit 8f4a489b370e6612700aa16b9e4373b2d85d7503 ]
The msg_res region translates writes into PCIe Message TLPs. Previously we
mapped this region using atu.cpu_addr, the input address programmed into
the ATU.
"cpu_addr" is a misnomer because when a bus fabric translates addresses
between the CPU and the ATU, the ATU input address is different from the
CPU address. A future patch will rename "cpu_addr" and correct the value
to be the ATU input address instead of the CPU physical address.
Map the msg_res region before writing to it using the msg_res resource
start, a CPU physical address.
Link: https://lore.kernel.org/r/20250315201548.858189-2-helgaas@kernel.org
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/controller/dwc/pcie-designware-host.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index ffaded8f2df7b..ae3fd2a5dbf85 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -908,7 +908,7 @@ static int dw_pcie_pme_turn_off(struct dw_pcie *pci)
if (ret)
return ret;
- mem = ioremap(atu.cpu_addr, pci->region_align);
+ mem = ioremap(pci->pp.msg_res->start, pci->region_align);
if (!mem)
return -ENOMEM;
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 213/642] PCI: endpoint: pci-epf-test: Fix double free that causes kernel to oops
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (4 preceding siblings ...)
2025-05-05 22:05 ` [PATCH AUTOSEL 6.14 128/642] PCI: dwc: Use resource start as ioremap() input in dw_pcie_pme_turn_off() Sasha Levin
@ 2025-05-05 22:07 ` Sasha Levin
2025-05-05 22:07 ` [PATCH AUTOSEL 6.14 214/642] misc: pci_endpoint_test: Give disabled BARs a distinct error code Sasha Levin
` (7 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Christian Bruel, Niklas Cassel, Manivannan Sadhasivam,
Krzysztof Wilczyński, Sasha Levin, kw, bhelgaas, Frank.Li,
dlemoal, linux-pci
From: Christian Bruel <christian.bruel@foss.st.com>
[ Upstream commit 934e9d137d937706004c325fa1474f9e3f1ba10a ]
Fix a kernel oops found while testing the stm32_pcie Endpoint driver
with handling of PERST# deassertion:
During EP initialization, pci_epf_test_alloc_space() allocates all BARs,
which are further freed if epc_set_bar() fails (for instance, due to no
free inbound window).
However, when pci_epc_set_bar() fails, the error path:
pci_epc_set_bar() ->
pci_epf_free_space()
does not clear the previous assignment to epf_test->reg[bar].
Then, if the host reboots, the PERST# deassertion restarts the BAR
allocation sequence with the same allocation failure (no free inbound
window), creating a double free situation since epf_test->reg[bar] was
deallocated and is still non-NULL.
Thus, make sure that pci_epf_alloc_space() and pci_epf_free_space()
invocations are symmetric, and as such, set epf_test->reg[bar] to NULL
when memory is freed.
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
Link: https://lore.kernel.org/r/20250124123043.96112-1-christian.bruel@foss.st.com
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/endpoint/functions/pci-epf-test.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 2409787cf56d9..bce3ae2c0f652 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -738,6 +738,7 @@ static int pci_epf_test_set_bar(struct pci_epf *epf)
if (ret) {
pci_epf_free_space(epf, epf_test->reg[bar], bar,
PRIMARY_INTERFACE);
+ epf_test->reg[bar] = NULL;
dev_err(dev, "Failed to set BAR%d\n", bar);
if (bar == test_reg_bar)
return ret;
@@ -929,6 +930,7 @@ static void pci_epf_test_free_space(struct pci_epf *epf)
pci_epf_free_space(epf, epf_test->reg[bar], bar,
PRIMARY_INTERFACE);
+ epf_test->reg[bar] = NULL;
}
}
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 214/642] misc: pci_endpoint_test: Give disabled BARs a distinct error code
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (5 preceding siblings ...)
2025-05-05 22:07 ` [PATCH AUTOSEL 6.14 213/642] PCI: endpoint: pci-epf-test: Fix double free that causes kernel to oops Sasha Levin
@ 2025-05-05 22:07 ` Sasha Levin
2025-05-05 22:07 ` [PATCH AUTOSEL 6.14 215/642] selftests: pci_endpoint: Skip disabled BARs Sasha Levin
` (6 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Niklas Cassel, Manivannan Sadhasivam, Krzysztof Wilczyński,
Sasha Levin, kw, gregkh, linux-pci
From: Niklas Cassel <cassel@kernel.org>
[ Upstream commit 7e80bbef1d697dbce7a39cfad0df770880fe3f29 ]
The current code returns -ENOMEM if test->bar[barno] is NULL.
There can be two reasons why test->bar[barno] is NULL:
1) The pci_ioremap_bar() call in pci_endpoint_test_probe() failed.
2) The BAR was skipped, because it is disabled by the endpoint.
Many PCI endpoint controller drivers will disable all BARs in their
init function. A disabled BAR will have a size of 0.
A PCI endpoint function driver will be able to enable any BAR that
is not marked as BAR_RESERVED (which means that the BAR should not
be touched by the EPF driver).
Thus, perform check if the size is 0, before checking if
test->bar[barno] is NULL, such that we can return different errors.
This will allow the selftests to return SKIP instead of FAIL for
disabled BARs.
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20250123120147.3603409-3-cassel@kernel.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/misc/pci_endpoint_test.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 4c0f37ad0281b..8a7e860c06812 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -295,11 +295,13 @@ static int pci_endpoint_test_bar(struct pci_endpoint_test *test,
struct pci_dev *pdev = test->pdev;
int buf_size;
+ bar_size = pci_resource_len(pdev, barno);
+ if (!bar_size)
+ return -ENODATA;
+
if (!test->bar[barno])
return -ENOMEM;
- bar_size = pci_resource_len(pdev, barno);
-
if (barno == test->test_reg_bar)
bar_size = 0x4;
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 215/642] selftests: pci_endpoint: Skip disabled BARs
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (6 preceding siblings ...)
2025-05-05 22:07 ` [PATCH AUTOSEL 6.14 214/642] misc: pci_endpoint_test: Give disabled BARs a distinct error code Sasha Levin
@ 2025-05-05 22:07 ` Sasha Levin
2025-05-05 22:08 ` [PATCH AUTOSEL 6.14 293/642] PCI: brcmstb: Expand inbound window size up to 64GB Sasha Levin
` (5 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Niklas Cassel, Manivannan Sadhasivam, Krzysztof Wilczyński,
Sasha Levin, kw, shuah, linux-pci, linux-kselftest
From: Niklas Cassel <cassel@kernel.org>
[ Upstream commit af1451b6738ec7cf91f2914f53845424959ec4ee ]
Currently BARs that have been disabled by the endpoint controller driver
will result in a test FAIL.
Returning FAIL for a BAR that is disabled seems overly pessimistic.
There are EPC that disables one or more BARs intentionally.
One reason for this is that there are certain EPCs that are hardwired to
expose internal PCIe controller registers over a certain BAR, so the EPC
driver disables such a BAR, such that the host will not overwrite random
registers during testing.
Such a BAR will be disabled by the EPC driver's init function, and the
BAR will be marked as BAR_RESERVED, such that it will be unavailable to
endpoint function drivers.
Let's return FAIL only for BARs that are actually enabled and failed the
test, and let's return skip for BARs that are not even enabled.
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20250123120147.3603409-4-cassel@kernel.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/pci_endpoint/pci_endpoint_test.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
index c267b822c1081..576c590b277b1 100644
--- a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
+++ b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c
@@ -65,6 +65,8 @@ TEST_F(pci_ep_bar, BAR_TEST)
int ret;
pci_ep_ioctl(PCITEST_BAR, variant->barno);
+ if (ret == -ENODATA)
+ SKIP(return, "BAR is disabled");
EXPECT_FALSE(ret) TH_LOG("Test failed for BAR%d", variant->barno);
}
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 293/642] PCI: brcmstb: Expand inbound window size up to 64GB
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (7 preceding siblings ...)
2025-05-05 22:07 ` [PATCH AUTOSEL 6.14 215/642] selftests: pci_endpoint: Skip disabled BARs Sasha Levin
@ 2025-05-05 22:08 ` Sasha Levin
2025-05-05 22:08 ` [PATCH AUTOSEL 6.14 294/642] PCI: brcmstb: Add a softdep to MIP MSI-X driver Sasha Levin
` (4 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:08 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Stanimir Varbanov, Florian Fainelli, Jim Quinlan, Ivan T . Ivanov,
Krzysztof Wilczyński, Sasha Levin, jim2101024, nsaenz,
lpieralisi, kw, manivannan.sadhasivam, bhelgaas, linux-pci,
linux-rpi-kernel, linux-arm-kernel
From: Stanimir Varbanov <svarbanov@suse.de>
[ Upstream commit 25a98c727015638baffcfa236e3f37b70cedcf87 ]
The BCM2712 memory map can support up to 64GB of system memory, thus
expand the inbound window size in calculation helper function.
The change is safe for the currently supported SoCs that have smaller
inbound window sizes.
Signed-off-by: Stanimir Varbanov <svarbanov@suse.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Jim Quinlan <james.quinlan@broadcom.com>
Tested-by: Ivan T. Ivanov <iivanov@suse.de>
Link: https://lore.kernel.org/r/20250224083559.47645-7-svarbanov@suse.de
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/controller/pcie-brcmstb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index 1a3bdc01b0747..ff217a0b80ad3 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -309,8 +309,8 @@ static int brcm_pcie_encode_ibar_size(u64 size)
if (log2_in >= 12 && log2_in <= 15)
/* Covers 4KB to 32KB (inclusive) */
return (log2_in - 12) + 0x1c;
- else if (log2_in >= 16 && log2_in <= 35)
- /* Covers 64KB to 32GB, (inclusive) */
+ else if (log2_in >= 16 && log2_in <= 36)
+ /* Covers 64KB to 64GB, (inclusive) */
return log2_in - 15;
/* Something is awry so disable */
return 0;
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 294/642] PCI: brcmstb: Add a softdep to MIP MSI-X driver
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (8 preceding siblings ...)
2025-05-05 22:08 ` [PATCH AUTOSEL 6.14 293/642] PCI: brcmstb: Expand inbound window size up to 64GB Sasha Levin
@ 2025-05-05 22:08 ` Sasha Levin
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 348/642] x86/kaslr: Reduce KASLR entropy on most x86 systems Sasha Levin
` (3 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:08 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Stanimir Varbanov, Florian Fainelli, Ivan T . Ivanov,
Krzysztof Wilczyński, Sasha Levin, jim2101024, nsaenz,
lpieralisi, kw, manivannan.sadhasivam, bhelgaas, linux-pci,
linux-rpi-kernel, linux-arm-kernel
From: Stanimir Varbanov <svarbanov@suse.de>
[ Upstream commit 2294059118c550464dd8906286324d90c33b152b ]
Then the brcmstb PCIe driver and MIP MSI-X interrupt controller
drivers are built as modules there could be a race in probing.
To avoid this, add a softdep to MIP driver to guarantee that
MIP driver will be load first.
Signed-off-by: Stanimir Varbanov <svarbanov@suse.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Ivan T. Ivanov <iivanov@suse.de>
Link: https://lore.kernel.org/r/20250224083559.47645-5-svarbanov@suse.de
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/controller/pcie-brcmstb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index ff217a0b80ad3..bae226c779a50 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -1947,3 +1947,4 @@ module_platform_driver(brcm_pcie_driver);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Broadcom STB PCIe RC driver");
MODULE_AUTHOR("Broadcom");
+MODULE_SOFTDEP("pre: irq_bcm2712_mip");
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 348/642] x86/kaslr: Reduce KASLR entropy on most x86 systems
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (9 preceding siblings ...)
2025-05-05 22:08 ` [PATCH AUTOSEL 6.14 294/642] PCI: brcmstb: Add a softdep to MIP MSI-X driver Sasha Levin
@ 2025-05-05 22:09 ` Sasha Levin
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 362/642] PCI: epf-mhi: Update device ID for SA8775P Sasha Levin
` (2 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:09 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Balbir Singh, Ingo Molnar, Kees Cook, Bjorn Helgaas,
Linus Torvalds, Peter Zijlstra, Andy Lutomirski, Sasha Levin,
dave.hansen, tglx, mingo, bp, x86, linux-pci
From: Balbir Singh <balbirs@nvidia.com>
[ Upstream commit 7ffb791423c7c518269a9aad35039ef824a40adb ]
When CONFIG_PCI_P2PDMA=y (which is basically enabled on all
large x86 distros), it maps the PFN's via a ZONE_DEVICE
mapping using devm_memremap_pages(). The mapped virtual
address range corresponds to the pci_resource_start()
of the BAR address and size corresponding to the BAR length.
When KASLR is enabled, the direct map range of the kernel is
reduced to the size of physical memory plus additional padding.
If the BAR address is beyond this limit, PCI peer to peer DMA
mappings fail.
Fix this by not shrinking the size of the direct map when
CONFIG_PCI_P2PDMA=y.
This reduces the total available entropy, but it's better than
the current work around of having to disable KASLR completely.
[ mingo: Clarified the changelog to point out the broad impact ... ]
Signed-off-by: Balbir Singh <balbirs@nvidia.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com> # drivers/pci/Kconfig
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Link: https://lore.kernel.org/lkml/20250206023201.1481957-1-balbirs@nvidia.com/
Link: https://lore.kernel.org/r/20250206234234.1912585-1-balbirs@nvidia.com
--
arch/x86/mm/kaslr.c | 10 ++++++++--
drivers/pci/Kconfig | 6 ++++++
2 files changed, 14 insertions(+), 2 deletions(-)
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/mm/kaslr.c | 10 ++++++++--
drivers/pci/Kconfig | 6 ++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
index 11a93542d1983..3c306de52fd4d 100644
--- a/arch/x86/mm/kaslr.c
+++ b/arch/x86/mm/kaslr.c
@@ -113,8 +113,14 @@ void __init kernel_randomize_memory(void)
memory_tb = DIV_ROUND_UP(max_pfn << PAGE_SHIFT, 1UL << TB_SHIFT) +
CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING;
- /* Adapt physical memory region size based on available memory */
- if (memory_tb < kaslr_regions[0].size_tb)
+ /*
+ * Adapt physical memory region size based on available memory,
+ * except when CONFIG_PCI_P2PDMA is enabled. P2PDMA exposes the
+ * device BAR space assuming the direct map space is large enough
+ * for creating a ZONE_DEVICE mapping in the direct map corresponding
+ * to the physical BAR address.
+ */
+ if (!IS_ENABLED(CONFIG_PCI_P2PDMA) && (memory_tb < kaslr_regions[0].size_tb))
kaslr_regions[0].size_tb = memory_tb;
/*
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 2fbd379923fd1..5c3054aaec8c1 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -203,6 +203,12 @@ config PCI_P2PDMA
P2P DMA transactions must be between devices behind the same root
port.
+ Enabling this option will reduce the entropy of x86 KASLR memory
+ regions. For example - on a 46 bit system, the entropy goes down
+ from 16 bits to 15 bits. The actual reduction in entropy depends
+ on the physical address bits, on processor features, kernel config
+ (5 level page table) and physical memory present on the system.
+
If unsure, say N.
config PCI_LABEL
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 362/642] PCI: epf-mhi: Update device ID for SA8775P
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (10 preceding siblings ...)
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 348/642] x86/kaslr: Reduce KASLR entropy on most x86 systems Sasha Levin
@ 2025-05-05 22:09 ` Sasha Levin
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 382/642] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev() Sasha Levin
2025-05-05 22:10 ` [PATCH AUTOSEL 6.14 397/642] PCI: Fix old_size lower bound in calculate_iosize() too Sasha Levin
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:09 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Mrinmay Sarkar, Krzysztof Wilczyński, Sasha Levin,
manivannan.sadhasivam, kw, bhelgaas, mhi, linux-arm-msm,
linux-pci
From: Mrinmay Sarkar <quic_msarkar@quicinc.com>
[ Upstream commit 4f13dd9e2b1d2b317bb36704f8a7bd1d3017f7a2 ]
Update device ID for the Qcom SA8775P SoC.
Signed-off-by: Mrinmay Sarkar <quic_msarkar@quicinc.com>
Link: https://lore.kernel.org/r/20241205065422.2515086-3-quic_msarkar@quicinc.com
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/endpoint/functions/pci-epf-mhi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
index 54286a40bdfbf..6643a88c7a0ce 100644
--- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
+++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
@@ -125,7 +125,7 @@ static const struct pci_epf_mhi_ep_info sm8450_info = {
static struct pci_epf_header sa8775p_header = {
.vendorid = PCI_VENDOR_ID_QCOM,
- .deviceid = 0x0306, /* FIXME: Update deviceid for sa8775p EP */
+ .deviceid = 0x0116,
.baseclass_code = PCI_CLASS_OTHERS,
.interrupt_pin = PCI_INTERRUPT_INTA,
};
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 382/642] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev()
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (11 preceding siblings ...)
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 362/642] PCI: epf-mhi: Update device ID for SA8775P Sasha Levin
@ 2025-05-05 22:09 ` Sasha Levin
2025-05-06 8:06 ` Lukas Wunner
2025-05-05 22:10 ` [PATCH AUTOSEL 6.14 397/642] PCI: Fix old_size lower bound in calculate_iosize() too Sasha Levin
13 siblings, 1 reply; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:09 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Manivannan Sadhasivam, Lukas Wunner, Bartosz Golaszewski,
Krzysztof Wilczyński, Sasha Levin, bhelgaas, linux-pci
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
[ Upstream commit 2d923930f2e3fe1ecf060169f57980da819a191f ]
The PCI core will try to access the devices even after pci_stop_dev()
for things like Data Object Exchange (DOE), ASPM, etc.
So, move pci_pwrctrl_unregister() to the near end of pci_destroy_dev()
to make sure that the devices are powered down only after the PCI core
is done with them.
Suggested-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Tested-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20250116-pci-pwrctrl-slot-v3-2-827473c8fbf4@linaro.org
[kwilczynski: commit log]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/remove.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index efc37fcb73e24..58859f9d92f73 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -41,7 +41,6 @@ static void pci_stop_dev(struct pci_dev *dev)
if (!pci_dev_test_and_clear_added(dev))
return;
- pci_pwrctrl_unregister(&dev->dev);
device_release_driver(&dev->dev);
pci_proc_detach_device(dev);
pci_remove_sysfs_dev_files(dev);
@@ -64,6 +63,7 @@ static void pci_destroy_dev(struct pci_dev *dev)
pci_doe_destroy(dev);
pcie_aspm_exit_link_state(dev);
pci_bridge_d3_update(dev);
+ pci_pwrctrl_unregister(&dev->dev);
pci_free_resources(dev);
put_device(&dev->dev);
}
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH AUTOSEL 6.14 397/642] PCI: Fix old_size lower bound in calculate_iosize() too
[not found] <20250505221419.2672473-1-sashal@kernel.org>
` (12 preceding siblings ...)
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 382/642] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev() Sasha Levin
@ 2025-05-05 22:10 ` Sasha Levin
13 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-05 22:10 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Ilpo Järvinen, Bjorn Helgaas, Xiaochun Lee, Sasha Levin,
linux-pci
From: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
[ Upstream commit ff61f380de5652e723168341480cc7adf1dd6213 ]
Commit 903534fa7d30 ("PCI: Fix resource double counting on remove &
rescan") fixed double counting of mem resources because of old_size being
applied too early.
Fix a similar counting bug on the io resource side.
Link: https://lore.kernel.org/r/20241216175632.4175-6-ilpo.jarvinen@linux.intel.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Xiaochun Lee <lixc17@lenovo.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/pci/setup-bus.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 8707c5b08cf34..477eb07bfbca9 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -814,11 +814,9 @@ static resource_size_t calculate_iosize(resource_size_t size,
size = (size & 0xff) + ((size & ~0xffUL) << 2);
#endif
size = size + size1;
- if (size < old_size)
- size = old_size;
- size = ALIGN(max(size, add_size) + children_add_size, align);
- return size;
+ size = max(size, add_size) + children_add_size;
+ return ALIGN(max(size, old_size), align);
}
static resource_size_t calculate_memsize(resource_size_t size,
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH AUTOSEL 6.14 382/642] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev()
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 382/642] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev() Sasha Levin
@ 2025-05-06 8:06 ` Lukas Wunner
2025-05-10 6:31 ` Manivannan Sadhasivam
0 siblings, 1 reply; 17+ messages in thread
From: Lukas Wunner @ 2025-05-06 8:06 UTC (permalink / raw)
To: Sasha Levin
Cc: linux-kernel, stable, Manivannan Sadhasivam, Bartosz Golaszewski,
Krzysztof Wilczy??ski, bhelgaas, linux-pci
On Mon, May 05, 2025 at 06:09:58PM -0400, Sasha Levin wrote:
> From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>
> [ Upstream commit 2d923930f2e3fe1ecf060169f57980da819a191f ]
>
> The PCI core will try to access the devices even after pci_stop_dev()
> for things like Data Object Exchange (DOE), ASPM, etc.
>
> So, move pci_pwrctrl_unregister() to the near end of pci_destroy_dev()
> to make sure that the devices are powered down only after the PCI core
> is done with them.
The above was patch [2/5] in this series:
https://lore.kernel.org/r/20250116-pci-pwrctrl-slot-v3-0-827473c8fbf4@linaro.org/
... so I think the preceding patch [1/5] is a prerequisite and would
need to be cherry-picked as well. Upstream commit id is:
957f40d039a98d630146f74f94b3f60a40a449e4
That said, I'm not sure this is really a fix that merits backporting
to stable. Mani may have more comments whether it makes sense.
Thanks,
Lukas
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH AUTOSEL 6.14 382/642] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev()
2025-05-06 8:06 ` Lukas Wunner
@ 2025-05-10 6:31 ` Manivannan Sadhasivam
2025-05-20 14:12 ` Sasha Levin
0 siblings, 1 reply; 17+ messages in thread
From: Manivannan Sadhasivam @ 2025-05-10 6:31 UTC (permalink / raw)
To: Lukas Wunner
Cc: Sasha Levin, linux-kernel, stable, Bartosz Golaszewski,
Krzysztof Wilczy??ski, bhelgaas, linux-pci
On Tue, May 06, 2025 at 10:06:59AM +0200, Lukas Wunner wrote:
> On Mon, May 05, 2025 at 06:09:58PM -0400, Sasha Levin wrote:
> > From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> >
> > [ Upstream commit 2d923930f2e3fe1ecf060169f57980da819a191f ]
> >
> > The PCI core will try to access the devices even after pci_stop_dev()
> > for things like Data Object Exchange (DOE), ASPM, etc.
> >
> > So, move pci_pwrctrl_unregister() to the near end of pci_destroy_dev()
> > to make sure that the devices are powered down only after the PCI core
> > is done with them.
>
> The above was patch [2/5] in this series:
>
> https://lore.kernel.org/r/20250116-pci-pwrctrl-slot-v3-0-827473c8fbf4@linaro.org/
>
> ... so I think the preceding patch [1/5] is a prerequisite and would
> need to be cherry-picked as well. Upstream commit id is:
> 957f40d039a98d630146f74f94b3f60a40a449e4
>
Yes, thanks for spotting it Lukas, appreciated!
> That said, I'm not sure this is really a fix that merits backporting
> to stable. Mani may have more comments whether it makes sense.
>
Both this commit and the one corresponding to patch 1/5 are not bug fixes that
warrants backporting. So please drop this one from the queue.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH AUTOSEL 6.14 382/642] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev()
2025-05-10 6:31 ` Manivannan Sadhasivam
@ 2025-05-20 14:12 ` Sasha Levin
0 siblings, 0 replies; 17+ messages in thread
From: Sasha Levin @ 2025-05-20 14:12 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: Lukas Wunner, linux-kernel, stable, Bartosz Golaszewski,
Krzysztof Wilczy??ski, bhelgaas, linux-pci
On Sat, May 10, 2025 at 12:01:31PM +0530, Manivannan Sadhasivam wrote:
>On Tue, May 06, 2025 at 10:06:59AM +0200, Lukas Wunner wrote:
>> On Mon, May 05, 2025 at 06:09:58PM -0400, Sasha Levin wrote:
>> > From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>> >
>> > [ Upstream commit 2d923930f2e3fe1ecf060169f57980da819a191f ]
>> >
>> > The PCI core will try to access the devices even after pci_stop_dev()
>> > for things like Data Object Exchange (DOE), ASPM, etc.
>> >
>> > So, move pci_pwrctrl_unregister() to the near end of pci_destroy_dev()
>> > to make sure that the devices are powered down only after the PCI core
>> > is done with them.
>>
>> The above was patch [2/5] in this series:
>>
>> https://lore.kernel.org/r/20250116-pci-pwrctrl-slot-v3-0-827473c8fbf4@linaro.org/
>>
>> ... so I think the preceding patch [1/5] is a prerequisite and would
>> need to be cherry-picked as well. Upstream commit id is:
>> 957f40d039a98d630146f74f94b3f60a40a449e4
>>
>
>Yes, thanks for spotting it Lukas, appreciated!
>
>> That said, I'm not sure this is really a fix that merits backporting
>> to stable. Mani may have more comments whether it makes sense.
>>
>
>Both this commit and the one corresponding to patch 1/5 are not bug fixes that
>warrants backporting. So please drop this one from the queue.
I'll drop it, thanks!
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2025-05-20 14:12 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250505221419.2672473-1-sashal@kernel.org>
2025-05-05 22:03 ` [PATCH AUTOSEL 6.14 016/642] iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability Sasha Levin
2025-05-05 22:04 ` [PATCH AUTOSEL 6.14 052/642] PCI: dwc: ep: Ensure proper iteration over outbound map windows Sasha Levin
2025-05-05 22:04 ` [PATCH AUTOSEL 6.14 055/642] PCI: xilinx-cpm: Add cpm_csr register mapping for CPM5_HOST1 variant Sasha Levin
2025-05-05 22:04 ` [PATCH AUTOSEL 6.14 063/642] PCI: vmd: Disable MSI remapping bypass under Xen Sasha Levin
2025-05-05 22:05 ` [PATCH AUTOSEL 6.14 128/642] PCI: dwc: Use resource start as ioremap() input in dw_pcie_pme_turn_off() Sasha Levin
2025-05-05 22:07 ` [PATCH AUTOSEL 6.14 213/642] PCI: endpoint: pci-epf-test: Fix double free that causes kernel to oops Sasha Levin
2025-05-05 22:07 ` [PATCH AUTOSEL 6.14 214/642] misc: pci_endpoint_test: Give disabled BARs a distinct error code Sasha Levin
2025-05-05 22:07 ` [PATCH AUTOSEL 6.14 215/642] selftests: pci_endpoint: Skip disabled BARs Sasha Levin
2025-05-05 22:08 ` [PATCH AUTOSEL 6.14 293/642] PCI: brcmstb: Expand inbound window size up to 64GB Sasha Levin
2025-05-05 22:08 ` [PATCH AUTOSEL 6.14 294/642] PCI: brcmstb: Add a softdep to MIP MSI-X driver Sasha Levin
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 348/642] x86/kaslr: Reduce KASLR entropy on most x86 systems Sasha Levin
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 362/642] PCI: epf-mhi: Update device ID for SA8775P Sasha Levin
2025-05-05 22:09 ` [PATCH AUTOSEL 6.14 382/642] PCI/pwrctrl: Move pci_pwrctrl_unregister() to pci_destroy_dev() Sasha Levin
2025-05-06 8:06 ` Lukas Wunner
2025-05-10 6:31 ` Manivannan Sadhasivam
2025-05-20 14:12 ` Sasha Levin
2025-05-05 22:10 ` [PATCH AUTOSEL 6.14 397/642] PCI: Fix old_size lower bound in calculate_iosize() too Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox