* [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups
@ 2023-06-14 15:55 daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 1/8] PCI: microchip: Correct the DED and SEC interrupt bit offsets daire.mcnamara
` (7 more replies)
0 siblings, 8 replies; 14+ messages in thread
From: daire.mcnamara @ 2023-06-14 15:55 UTC (permalink / raw)
To: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
Cc: Daire McNamara
From: Daire McNamara <daire.mcnamara@microchip.com>
This patch series contains fixes and clean-ups for the Microchip PolarFire SoC PCIe driver
These patches are extracted from the link below to separate them from the outbound and inbound
range handling which is taking considerable time.
These patches are regenerated on v6.4-rc6.
Link: https://lore.kernel.org/linux-riscv/Y8p16kaddL+Ot2Oa@wendy/
Daire McNamara (8):
PCI: microchip: Correct the DED and SEC interrupt bit offsets
PCI: microchip: Remove cast warning for devm_add_action_or_reset() arg
PCI: microchip: enable building this driver as a module
PCI: microchip: Align register, offset, and mask names with hw docs
PCI: microchip: Enable event handlers to access bridge and ctrl ptrs
PCI: microchip: Clean up initialisation of interrupts
PCI: microchip: Gather MSI information from hardware config registers
PCI: microchip: Re-partition code between probe() and init()
drivers/pci/controller/Kconfig | 2 +-
drivers/pci/controller/pcie-microchip-host.c | 412 +++++++++++--------
2 files changed, 246 insertions(+), 168 deletions(-)
base-commit: 858fd168a95c5b9669aac8db6c14a9aeab446375
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v1 1/8] PCI: microchip: Correct the DED and SEC interrupt bit offsets
2023-06-14 15:55 [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups daire.mcnamara
@ 2023-06-14 15:55 ` daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 2/8] PCI: microchip: Remove cast warning for devm_add_action_or_reset() arg daire.mcnamara
` (6 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: daire.mcnamara @ 2023-06-14 15:55 UTC (permalink / raw)
To: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
Cc: Daire McNamara
From: Daire McNamara <daire.mcnamara@microchip.com>
The SEC and DED interrupt bits were the wrong way round so the SEC
interrupt handler attempted to mask, unmask, and clear the DED interrupt
and vice versa. Correct the bit offsets so each interrupt handler
operates properly.
Fixes: 6f15a9c9f941 ("PCI: microchip: Add Microchip PolarFire PCIe controller driver")
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/pci/controller/pcie-microchip-host.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
index 5e710e485464..dd5245904c87 100644
--- a/drivers/pci/controller/pcie-microchip-host.c
+++ b/drivers/pci/controller/pcie-microchip-host.c
@@ -167,12 +167,12 @@
#define EVENT_PCIE_DLUP_EXIT 2
#define EVENT_SEC_TX_RAM_SEC_ERR 3
#define EVENT_SEC_RX_RAM_SEC_ERR 4
-#define EVENT_SEC_AXI2PCIE_RAM_SEC_ERR 5
-#define EVENT_SEC_PCIE2AXI_RAM_SEC_ERR 6
+#define EVENT_SEC_PCIE2AXI_RAM_SEC_ERR 5
+#define EVENT_SEC_AXI2PCIE_RAM_SEC_ERR 6
#define EVENT_DED_TX_RAM_DED_ERR 7
#define EVENT_DED_RX_RAM_DED_ERR 8
-#define EVENT_DED_AXI2PCIE_RAM_DED_ERR 9
-#define EVENT_DED_PCIE2AXI_RAM_DED_ERR 10
+#define EVENT_DED_PCIE2AXI_RAM_DED_ERR 9
+#define EVENT_DED_AXI2PCIE_RAM_DED_ERR 10
#define EVENT_LOCAL_DMA_END_ENGINE_0 11
#define EVENT_LOCAL_DMA_END_ENGINE_1 12
#define EVENT_LOCAL_DMA_ERROR_ENGINE_0 13
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 2/8] PCI: microchip: Remove cast warning for devm_add_action_or_reset() arg
2023-06-14 15:55 [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 1/8] PCI: microchip: Correct the DED and SEC interrupt bit offsets daire.mcnamara
@ 2023-06-14 15:55 ` daire.mcnamara
2023-06-24 18:34 ` Krzysztof Wilczyński
2023-06-14 15:55 ` [PATCH v1 3/8] PCI: microchip: enable building this driver as a module daire.mcnamara
` (5 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: daire.mcnamara @ 2023-06-14 15:55 UTC (permalink / raw)
To: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
Cc: Daire McNamara
From: Daire McNamara <daire.mcnamara@microchip.com>
The kernel test robot reported that the ugly cast from
void(*)(struct clk *) to void (*)(void *) converts to incompatible
function type. This commit adopts the common convention of creating a
trivial stub function that takes a void * and passes it to the
underlying function that expects the more specific type.
Fixes: 6f15a9c9f941 ("PCI: microchip: Add Microchip PolarFire PCIe controller driver")
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/pci/controller/pcie-microchip-host.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
index dd5245904c87..73046bad1521 100644
--- a/drivers/pci/controller/pcie-microchip-host.c
+++ b/drivers/pci/controller/pcie-microchip-host.c
@@ -848,6 +848,13 @@ static const struct irq_domain_ops event_domain_ops = {
.map = mc_pcie_event_map,
};
+static inline void mc_pcie_chip_off_action(void *data)
+{
+ struct clk *clk = data;
+
+ clk_disable_unprepare(clk);
+}
+
static inline struct clk *mc_pcie_init_clk(struct device *dev, const char *id)
{
struct clk *clk;
@@ -863,8 +870,7 @@ static inline struct clk *mc_pcie_init_clk(struct device *dev, const char *id)
if (ret)
return ERR_PTR(ret);
- devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare,
- clk);
+ devm_add_action_or_reset(dev, mc_pcie_chip_off_action, clk);
return clk;
}
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 3/8] PCI: microchip: enable building this driver as a module
2023-06-14 15:55 [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 1/8] PCI: microchip: Correct the DED and SEC interrupt bit offsets daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 2/8] PCI: microchip: Remove cast warning for devm_add_action_or_reset() arg daire.mcnamara
@ 2023-06-14 15:55 ` daire.mcnamara
2023-06-14 19:53 ` Uwe Kleine-König
2023-06-19 10:00 ` Lorenzo Pieralisi
2023-06-14 15:55 ` [PATCH v1 4/8] PCI: microchip: Align register, offset, and mask names with hw docs daire.mcnamara
` (4 subsequent siblings)
7 siblings, 2 replies; 14+ messages in thread
From: daire.mcnamara @ 2023-06-14 15:55 UTC (permalink / raw)
To: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
Cc: Daire McNamara, Uwe Kleine-König
From: Daire McNamara <daire.mcnamara@microchip.com>
Enable building this driver as a module. The expected use case is the
driver is built as a module, is installed when needed, and cannot be
removed once installed.
The remove() callback is not implemented as removing a driver with
INTx and MSI interrupt handling is inherently unsafe.
Link: https://lore.kernel.org/linux-pci/87y1wgbah8.wl-maz@kernel.org/
Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/pci/controller/Kconfig | 2 +-
drivers/pci/controller/pcie-microchip-host.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 8d49bad7f847..f4ad0e9cca45 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -217,7 +217,7 @@ config PCIE_MT7621
This selects a driver for the MediaTek MT7621 PCIe Controller.
config PCIE_MICROCHIP_HOST
- bool "Microchip AXI PCIe controller"
+ tristate "Microchip AXI PCIe controller"
depends on PCI_MSI && OF
select PCI_HOST_COMMON
help
diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
index 73046bad1521..5efd480e42fa 100644
--- a/drivers/pci/controller/pcie-microchip-host.c
+++ b/drivers/pci/controller/pcie-microchip-host.c
@@ -1141,5 +1141,6 @@ static struct platform_driver mc_pcie_driver = {
};
builtin_platform_driver(mc_pcie_driver);
+MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Microchip PCIe host controller driver");
MODULE_AUTHOR("Daire McNamara <daire.mcnamara@microchip.com>");
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 4/8] PCI: microchip: Align register, offset, and mask names with hw docs
2023-06-14 15:55 [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups daire.mcnamara
` (2 preceding siblings ...)
2023-06-14 15:55 ` [PATCH v1 3/8] PCI: microchip: enable building this driver as a module daire.mcnamara
@ 2023-06-14 15:55 ` daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 5/8] PCI: microchip: Enable event handlers to access bridge and ctrl ptrs daire.mcnamara
` (3 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: daire.mcnamara @ 2023-06-14 15:55 UTC (permalink / raw)
To: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
Cc: Daire McNamara
From: Daire McNamara <daire.mcnamara@microchip.com>
Minor re-organisation so that macros representing registers ascend in
numerical order and use the same names as their hardware documentation.
Removed registers not used by the driver.
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/pci/controller/pcie-microchip-host.c | 122 +++++++++----------
1 file changed, 60 insertions(+), 62 deletions(-)
diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
index 5efd480e42fa..2efd48ef79d8 100644
--- a/drivers/pci/controller/pcie-microchip-host.c
+++ b/drivers/pci/controller/pcie-microchip-host.c
@@ -30,66 +30,7 @@
#define MC_PCIE_BRIDGE_ADDR (MC_PCIE1_BRIDGE_ADDR)
#define MC_PCIE_CTRL_ADDR (MC_PCIE1_CTRL_ADDR)
-/* PCIe Controller Phy Regs */
-#define SEC_ERROR_CNT 0x20
-#define DED_ERROR_CNT 0x24
-#define SEC_ERROR_INT 0x28
-#define SEC_ERROR_INT_TX_RAM_SEC_ERR_INT GENMASK(3, 0)
-#define SEC_ERROR_INT_RX_RAM_SEC_ERR_INT GENMASK(7, 4)
-#define SEC_ERROR_INT_PCIE2AXI_RAM_SEC_ERR_INT GENMASK(11, 8)
-#define SEC_ERROR_INT_AXI2PCIE_RAM_SEC_ERR_INT GENMASK(15, 12)
-#define NUM_SEC_ERROR_INTS (4)
-#define SEC_ERROR_INT_MASK 0x2c
-#define DED_ERROR_INT 0x30
-#define DED_ERROR_INT_TX_RAM_DED_ERR_INT GENMASK(3, 0)
-#define DED_ERROR_INT_RX_RAM_DED_ERR_INT GENMASK(7, 4)
-#define DED_ERROR_INT_PCIE2AXI_RAM_DED_ERR_INT GENMASK(11, 8)
-#define DED_ERROR_INT_AXI2PCIE_RAM_DED_ERR_INT GENMASK(15, 12)
-#define NUM_DED_ERROR_INTS (4)
-#define DED_ERROR_INT_MASK 0x34
-#define ECC_CONTROL 0x38
-#define ECC_CONTROL_TX_RAM_INJ_ERROR_0 BIT(0)
-#define ECC_CONTROL_TX_RAM_INJ_ERROR_1 BIT(1)
-#define ECC_CONTROL_TX_RAM_INJ_ERROR_2 BIT(2)
-#define ECC_CONTROL_TX_RAM_INJ_ERROR_3 BIT(3)
-#define ECC_CONTROL_RX_RAM_INJ_ERROR_0 BIT(4)
-#define ECC_CONTROL_RX_RAM_INJ_ERROR_1 BIT(5)
-#define ECC_CONTROL_RX_RAM_INJ_ERROR_2 BIT(6)
-#define ECC_CONTROL_RX_RAM_INJ_ERROR_3 BIT(7)
-#define ECC_CONTROL_PCIE2AXI_RAM_INJ_ERROR_0 BIT(8)
-#define ECC_CONTROL_PCIE2AXI_RAM_INJ_ERROR_1 BIT(9)
-#define ECC_CONTROL_PCIE2AXI_RAM_INJ_ERROR_2 BIT(10)
-#define ECC_CONTROL_PCIE2AXI_RAM_INJ_ERROR_3 BIT(11)
-#define ECC_CONTROL_AXI2PCIE_RAM_INJ_ERROR_0 BIT(12)
-#define ECC_CONTROL_AXI2PCIE_RAM_INJ_ERROR_1 BIT(13)
-#define ECC_CONTROL_AXI2PCIE_RAM_INJ_ERROR_2 BIT(14)
-#define ECC_CONTROL_AXI2PCIE_RAM_INJ_ERROR_3 BIT(15)
-#define ECC_CONTROL_TX_RAM_ECC_BYPASS BIT(24)
-#define ECC_CONTROL_RX_RAM_ECC_BYPASS BIT(25)
-#define ECC_CONTROL_PCIE2AXI_RAM_ECC_BYPASS BIT(26)
-#define ECC_CONTROL_AXI2PCIE_RAM_ECC_BYPASS BIT(27)
-#define LTSSM_STATE 0x5c
-#define LTSSM_L0_STATE 0x10
-#define PCIE_EVENT_INT 0x14c
-#define PCIE_EVENT_INT_L2_EXIT_INT BIT(0)
-#define PCIE_EVENT_INT_HOTRST_EXIT_INT BIT(1)
-#define PCIE_EVENT_INT_DLUP_EXIT_INT BIT(2)
-#define PCIE_EVENT_INT_MASK GENMASK(2, 0)
-#define PCIE_EVENT_INT_L2_EXIT_INT_MASK BIT(16)
-#define PCIE_EVENT_INT_HOTRST_EXIT_INT_MASK BIT(17)
-#define PCIE_EVENT_INT_DLUP_EXIT_INT_MASK BIT(18)
-#define PCIE_EVENT_INT_ENB_MASK GENMASK(18, 16)
-#define PCIE_EVENT_INT_ENB_SHIFT 16
-#define NUM_PCIE_EVENTS (3)
-
/* PCIe Bridge Phy Regs */
-#define PCIE_PCI_IDS_DW1 0x9c
-
-/* PCIe Config space MSI capability structure */
-#define MC_MSI_CAP_CTRL_OFFSET 0xe0u
-#define MC_MSI_MAX_Q_AVAIL (MC_NUM_MSI_IRQS_CODED << 1)
-#define MC_MSI_Q_SIZE (MC_NUM_MSI_IRQS_CODED << 4)
-
#define IMASK_LOCAL 0x180
#define DMA_END_ENGINE_0_MASK 0x00000000u
#define DMA_END_ENGINE_0_SHIFT 0
@@ -137,7 +78,8 @@
#define ISTATUS_LOCAL 0x184
#define IMASK_HOST 0x188
#define ISTATUS_HOST 0x18c
-#define MSI_ADDR 0x190
+#define IMSI_ADDR 0x190
+#define MSI_ADDR 0x190
#define ISTATUS_MSI 0x194
/* PCIe Master table init defines */
@@ -162,6 +104,62 @@
#define ATR_ENTRY_SIZE 32
+/* PCIe Controller Phy Regs */
+#define SEC_ERROR_EVENT_CNT 0x20
+#define DED_ERROR_EVENT_CNT 0x24
+#define SEC_ERROR_INT 0x28
+#define SEC_ERROR_INT_TX_RAM_SEC_ERR_INT GENMASK(3, 0)
+#define SEC_ERROR_INT_RX_RAM_SEC_ERR_INT GENMASK(7, 4)
+#define SEC_ERROR_INT_PCIE2AXI_RAM_SEC_ERR_INT GENMASK(11, 8)
+#define SEC_ERROR_INT_AXI2PCIE_RAM_SEC_ERR_INT GENMASK(15, 12)
+#define NUM_SEC_ERROR_INTS (4)
+#define SEC_ERROR_INT_MASK 0x2c
+#define DED_ERROR_INT 0x30
+#define DED_ERROR_INT_TX_RAM_DED_ERR_INT GENMASK(3, 0)
+#define DED_ERROR_INT_RX_RAM_DED_ERR_INT GENMASK(7, 4)
+#define DED_ERROR_INT_PCIE2AXI_RAM_DED_ERR_INT GENMASK(11, 8)
+#define DED_ERROR_INT_AXI2PCIE_RAM_DED_ERR_INT GENMASK(15, 12)
+#define NUM_DED_ERROR_INTS (4)
+#define DED_ERROR_INT_MASK 0x34
+#define ECC_CONTROL 0x38
+#define ECC_CONTROL_TX_RAM_INJ_ERROR_0 BIT(0)
+#define ECC_CONTROL_TX_RAM_INJ_ERROR_1 BIT(1)
+#define ECC_CONTROL_TX_RAM_INJ_ERROR_2 BIT(2)
+#define ECC_CONTROL_TX_RAM_INJ_ERROR_3 BIT(3)
+#define ECC_CONTROL_RX_RAM_INJ_ERROR_0 BIT(4)
+#define ECC_CONTROL_RX_RAM_INJ_ERROR_1 BIT(5)
+#define ECC_CONTROL_RX_RAM_INJ_ERROR_2 BIT(6)
+#define ECC_CONTROL_RX_RAM_INJ_ERROR_3 BIT(7)
+#define ECC_CONTROL_PCIE2AXI_RAM_INJ_ERROR_0 BIT(8)
+#define ECC_CONTROL_PCIE2AXI_RAM_INJ_ERROR_1 BIT(9)
+#define ECC_CONTROL_PCIE2AXI_RAM_INJ_ERROR_2 BIT(10)
+#define ECC_CONTROL_PCIE2AXI_RAM_INJ_ERROR_3 BIT(11)
+#define ECC_CONTROL_AXI2PCIE_RAM_INJ_ERROR_0 BIT(12)
+#define ECC_CONTROL_AXI2PCIE_RAM_INJ_ERROR_1 BIT(13)
+#define ECC_CONTROL_AXI2PCIE_RAM_INJ_ERROR_2 BIT(14)
+#define ECC_CONTROL_AXI2PCIE_RAM_INJ_ERROR_3 BIT(15)
+#define ECC_CONTROL_TX_RAM_ECC_BYPASS BIT(24)
+#define ECC_CONTROL_RX_RAM_ECC_BYPASS BIT(25)
+#define ECC_CONTROL_PCIE2AXI_RAM_ECC_BYPASS BIT(26)
+#define ECC_CONTROL_AXI2PCIE_RAM_ECC_BYPASS BIT(27)
+#define PCIE_EVENT_INT 0x14c
+#define PCIE_EVENT_INT_L2_EXIT_INT BIT(0)
+#define PCIE_EVENT_INT_HOTRST_EXIT_INT BIT(1)
+#define PCIE_EVENT_INT_DLUP_EXIT_INT BIT(2)
+#define PCIE_EVENT_INT_MASK GENMASK(2, 0)
+#define PCIE_EVENT_INT_L2_EXIT_INT_MASK BIT(16)
+#define PCIE_EVENT_INT_HOTRST_EXIT_INT_MASK BIT(17)
+#define PCIE_EVENT_INT_DLUP_EXIT_INT_MASK BIT(18)
+#define PCIE_EVENT_INT_ENB_MASK GENMASK(18, 16)
+#define PCIE_EVENT_INT_ENB_SHIFT 16
+#define NUM_PCIE_EVENTS (3)
+
+/* PCIe Config space MSI capability structure */
+#define MC_MSI_CAP_CTRL_OFFSET 0xe0u
+#define MC_MSI_MAX_Q_AVAIL (MC_NUM_MSI_IRQS_CODED << 1)
+#define MC_MSI_Q_SIZE (MC_NUM_MSI_IRQS_CODED << 4)
+
+/* Events */
#define EVENT_PCIE_L2_EXIT 0
#define EVENT_PCIE_HOTRST_EXIT 1
#define EVENT_PCIE_DLUP_EXIT 2
@@ -1092,7 +1090,7 @@ static int mc_platform_init(struct pci_config_window *cfg)
SEC_ERROR_INT_AXI2PCIE_RAM_SEC_ERR_INT;
writel_relaxed(val, ctrl_base_addr + SEC_ERROR_INT);
writel_relaxed(0, ctrl_base_addr + SEC_ERROR_INT_MASK);
- writel_relaxed(0, ctrl_base_addr + SEC_ERROR_CNT);
+ writel_relaxed(0, ctrl_base_addr + SEC_ERROR_EVENT_CNT);
val = DED_ERROR_INT_TX_RAM_DED_ERR_INT |
DED_ERROR_INT_RX_RAM_DED_ERR_INT |
@@ -1100,7 +1098,7 @@ static int mc_platform_init(struct pci_config_window *cfg)
DED_ERROR_INT_AXI2PCIE_RAM_DED_ERR_INT;
writel_relaxed(val, ctrl_base_addr + DED_ERROR_INT);
writel_relaxed(0, ctrl_base_addr + DED_ERROR_INT_MASK);
- writel_relaxed(0, ctrl_base_addr + DED_ERROR_CNT);
+ writel_relaxed(0, ctrl_base_addr + DED_ERROR_EVENT_CNT);
writel_relaxed(0, bridge_base_addr + IMASK_HOST);
writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST);
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 5/8] PCI: microchip: Enable event handlers to access bridge and ctrl ptrs
2023-06-14 15:55 [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups daire.mcnamara
` (3 preceding siblings ...)
2023-06-14 15:55 ` [PATCH v1 4/8] PCI: microchip: Align register, offset, and mask names with hw docs daire.mcnamara
@ 2023-06-14 15:55 ` daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 6/8] PCI: microchip: Clean up initialisation of interrupts daire.mcnamara
` (2 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: daire.mcnamara @ 2023-06-14 15:55 UTC (permalink / raw)
To: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
Cc: Daire McNamara
From: Daire McNamara <daire.mcnamara@microchip.com>
Minor re-organisation so that event handlers can access both a pointer
to the bridge area of the PCIe Root Port and the ctrl area of the PCIe
Root Port.
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/pci/controller/pcie-microchip-host.c | 31 ++++++++++----------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
index 2efd48ef79d8..444ba99b070b 100644
--- a/drivers/pci/controller/pcie-microchip-host.c
+++ b/drivers/pci/controller/pcie-microchip-host.c
@@ -654,9 +654,10 @@ static inline u32 reg_to_event(u32 reg, struct event_map field)
return (reg & field.reg_mask) ? BIT(field.event_bit) : 0;
}
-static u32 pcie_events(void __iomem *addr)
+static u32 pcie_events(struct mc_pcie *port)
{
- u32 reg = readl_relaxed(addr);
+ void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR;
+ u32 reg = readl_relaxed(ctrl_base_addr + PCIE_EVENT_INT);
u32 val = 0;
int i;
@@ -666,9 +667,10 @@ static u32 pcie_events(void __iomem *addr)
return val;
}
-static u32 sec_errors(void __iomem *addr)
+static u32 sec_errors(struct mc_pcie *port)
{
- u32 reg = readl_relaxed(addr);
+ void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR;
+ u32 reg = readl_relaxed(ctrl_base_addr + SEC_ERROR_INT);
u32 val = 0;
int i;
@@ -678,9 +680,10 @@ static u32 sec_errors(void __iomem *addr)
return val;
}
-static u32 ded_errors(void __iomem *addr)
+static u32 ded_errors(struct mc_pcie *port)
{
- u32 reg = readl_relaxed(addr);
+ void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR;
+ u32 reg = readl_relaxed(ctrl_base_addr + DED_ERROR_INT);
u32 val = 0;
int i;
@@ -690,9 +693,10 @@ static u32 ded_errors(void __iomem *addr)
return val;
}
-static u32 local_events(void __iomem *addr)
+static u32 local_events(struct mc_pcie *port)
{
- u32 reg = readl_relaxed(addr);
+ void __iomem *bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
+ u32 reg = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL);
u32 val = 0;
int i;
@@ -704,15 +708,12 @@ static u32 local_events(void __iomem *addr)
static u32 get_events(struct mc_pcie *port)
{
- void __iomem *bridge_base_addr =
- port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
- void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR;
u32 events = 0;
- events |= pcie_events(ctrl_base_addr + PCIE_EVENT_INT);
- events |= sec_errors(ctrl_base_addr + SEC_ERROR_INT);
- events |= ded_errors(ctrl_base_addr + DED_ERROR_INT);
- events |= local_events(bridge_base_addr + ISTATUS_LOCAL);
+ events |= pcie_events(port);
+ events |= sec_errors(port);
+ events |= ded_errors(port);
+ events |= local_events(port);
return events;
}
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 6/8] PCI: microchip: Clean up initialisation of interrupts
2023-06-14 15:55 [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups daire.mcnamara
` (4 preceding siblings ...)
2023-06-14 15:55 ` [PATCH v1 5/8] PCI: microchip: Enable event handlers to access bridge and ctrl ptrs daire.mcnamara
@ 2023-06-14 15:55 ` daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 7/8] PCI: microchip: Gather MSI information from hardware config registers daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 8/8] PCI: microchip: Re-partition code between probe() and init() daire.mcnamara
7 siblings, 0 replies; 14+ messages in thread
From: daire.mcnamara @ 2023-06-14 15:55 UTC (permalink / raw)
To: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
Cc: Daire McNamara
From: Daire McNamara <daire.mcnamara@microchip.com>
Refactor interrupt handling in _init() function into
disable_interrupts(), init_interrupts(), clear_sec_errors() and clear
ded_errors(). It was unwieldy and prone to bugs. Then clearly disable
interrupts as soon as possible and only enable interrupts after address
translation is setup to prevent spurious axi2pcie and pcie2axi
translation errors being reported
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/pci/controller/pcie-microchip-host.c | 156 ++++++++++++-------
1 file changed, 100 insertions(+), 56 deletions(-)
diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
index 444ba99b070b..751f0243deb4 100644
--- a/drivers/pci/controller/pcie-microchip-host.c
+++ b/drivers/pci/controller/pcie-microchip-host.c
@@ -112,6 +112,7 @@
#define SEC_ERROR_INT_RX_RAM_SEC_ERR_INT GENMASK(7, 4)
#define SEC_ERROR_INT_PCIE2AXI_RAM_SEC_ERR_INT GENMASK(11, 8)
#define SEC_ERROR_INT_AXI2PCIE_RAM_SEC_ERR_INT GENMASK(15, 12)
+#define SEC_ERROR_INT_ALL_RAM_SEC_ERR_INT GENMASK(15, 0)
#define NUM_SEC_ERROR_INTS (4)
#define SEC_ERROR_INT_MASK 0x2c
#define DED_ERROR_INT 0x30
@@ -119,6 +120,7 @@
#define DED_ERROR_INT_RX_RAM_DED_ERR_INT GENMASK(7, 4)
#define DED_ERROR_INT_PCIE2AXI_RAM_DED_ERR_INT GENMASK(11, 8)
#define DED_ERROR_INT_AXI2PCIE_RAM_DED_ERR_INT GENMASK(15, 12)
+#define DED_ERROR_INT_ALL_RAM_DED_ERR_INT GENMASK(15, 0)
#define NUM_DED_ERROR_INTS (4)
#define DED_ERROR_INT_MASK 0x34
#define ECC_CONTROL 0x38
@@ -992,39 +994,73 @@ static int mc_pcie_setup_windows(struct platform_device *pdev,
return 0;
}
-static int mc_platform_init(struct pci_config_window *cfg)
+static inline void mc_clear_secs(struct mc_pcie *port)
{
- struct device *dev = cfg->parent;
- struct platform_device *pdev = to_platform_device(dev);
- struct mc_pcie *port;
- void __iomem *bridge_base_addr;
- void __iomem *ctrl_base_addr;
- int ret;
- int irq;
- int i, intx_irq, msi_irq, event_irq;
+ void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR;
+
+ writel_relaxed(SEC_ERROR_INT_ALL_RAM_SEC_ERR_INT, ctrl_base_addr +
+ SEC_ERROR_INT);
+ writel_relaxed(0, ctrl_base_addr + SEC_ERROR_EVENT_CNT);
+}
+
+static inline void mc_clear_deds(struct mc_pcie *port)
+{
+ void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR;
+
+ writel_relaxed(DED_ERROR_INT_ALL_RAM_DED_ERR_INT, ctrl_base_addr +
+ DED_ERROR_INT);
+ writel_relaxed(0, ctrl_base_addr + DED_ERROR_EVENT_CNT);
+}
+
+static void mc_disable_interrupts(struct mc_pcie *port)
+{
+ void __iomem *bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
+ void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR;
u32 val;
- int err;
- port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
- if (!port)
- return -ENOMEM;
- port->dev = dev;
+ /* Ensure ECC bypass is enabled */
+ val = ECC_CONTROL_TX_RAM_ECC_BYPASS |
+ ECC_CONTROL_RX_RAM_ECC_BYPASS |
+ ECC_CONTROL_PCIE2AXI_RAM_ECC_BYPASS |
+ ECC_CONTROL_AXI2PCIE_RAM_ECC_BYPASS;
+ writel_relaxed(val, ctrl_base_addr + ECC_CONTROL);
- ret = mc_pcie_init_clks(dev);
- if (ret) {
- dev_err(dev, "failed to get clock resources, error %d\n", ret);
- return -ENODEV;
- }
+ /* Disable SEC errors and clear any outstanding */
+ writel_relaxed(SEC_ERROR_INT_ALL_RAM_SEC_ERR_INT, ctrl_base_addr +
+ SEC_ERROR_INT_MASK);
+ mc_clear_secs(port);
- port->axi_base_addr = devm_platform_ioremap_resource(pdev, 1);
- if (IS_ERR(port->axi_base_addr))
- return PTR_ERR(port->axi_base_addr);
+ /* Disable DED errors and clear any outstanding */
+ writel_relaxed(DED_ERROR_INT_ALL_RAM_DED_ERR_INT, ctrl_base_addr +
+ DED_ERROR_INT_MASK);
+ mc_clear_deds(port);
- bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
- ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR;
+ /* Disable local interrupts and clear any outstanding */
+ writel_relaxed(0, bridge_base_addr + IMASK_LOCAL);
+ writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_LOCAL);
+ writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_MSI);
+
+ /* Disable PCIe events and clear any outstanding */
+ val = PCIE_EVENT_INT_L2_EXIT_INT |
+ PCIE_EVENT_INT_HOTRST_EXIT_INT |
+ PCIE_EVENT_INT_DLUP_EXIT_INT |
+ PCIE_EVENT_INT_L2_EXIT_INT_MASK |
+ PCIE_EVENT_INT_HOTRST_EXIT_INT_MASK |
+ PCIE_EVENT_INT_DLUP_EXIT_INT_MASK;
+ writel_relaxed(val, ctrl_base_addr + PCIE_EVENT_INT);
+
+ /* Disable host interrupts and clear any outstanding */
+ writel_relaxed(0, bridge_base_addr + IMASK_HOST);
+ writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST);
+}
+
+static int mc_init_interrupts(struct platform_device *pdev, struct mc_pcie *port)
+{
+ struct device *dev = &pdev->dev;
+ int irq;
+ int i, intx_irq, msi_irq, event_irq;
+ int ret;
- port->msi.vector_phy = MSI_ADDR;
- port->msi.num_vectors = MC_NUM_MSI_IRQS;
ret = mc_pcie_init_irq_domains(port);
if (ret) {
dev_err(dev, "failed creating IRQ domains\n");
@@ -1042,11 +1078,11 @@ static int mc_platform_init(struct pci_config_window *cfg)
return -ENXIO;
}
- err = devm_request_irq(dev, event_irq, mc_event_handler,
+ ret = devm_request_irq(dev, event_irq, mc_event_handler,
0, event_cause[i].sym, port);
- if (err) {
+ if (ret) {
dev_err(dev, "failed to request IRQ %d\n", event_irq);
- return err;
+ return ret;
}
}
@@ -1071,44 +1107,52 @@ static int mc_platform_init(struct pci_config_window *cfg)
/* Plug the main event chained handler */
irq_set_chained_handler_and_data(irq, mc_handle_event, port);
- /* Hardware doesn't setup MSI by default */
- mc_pcie_enable_msi(port, cfg->win);
+ return 0;
+}
- val = readl_relaxed(bridge_base_addr + IMASK_LOCAL);
- val |= PM_MSI_INT_INTX_MASK;
- writel_relaxed(val, bridge_base_addr + IMASK_LOCAL);
+static int mc_platform_init(struct pci_config_window *cfg)
+{
+ struct device *dev = cfg->parent;
+ struct platform_device *pdev = to_platform_device(dev);
+ struct mc_pcie *port;
+ void __iomem *bridge_base_addr;
+ int ret;
- writel_relaxed(val, ctrl_base_addr + ECC_CONTROL);
+ port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
+ if (!port)
+ return -ENOMEM;
+ port->dev = dev;
- val = PCIE_EVENT_INT_L2_EXIT_INT |
- PCIE_EVENT_INT_HOTRST_EXIT_INT |
- PCIE_EVENT_INT_DLUP_EXIT_INT;
- writel_relaxed(val, ctrl_base_addr + PCIE_EVENT_INT);
+ ret = mc_pcie_init_clks(dev);
+ if (ret) {
+ dev_err(dev, "failed to get clock resources, error %d\n", ret);
+ return -ENODEV;
+ }
- val = SEC_ERROR_INT_TX_RAM_SEC_ERR_INT |
- SEC_ERROR_INT_RX_RAM_SEC_ERR_INT |
- SEC_ERROR_INT_PCIE2AXI_RAM_SEC_ERR_INT |
- SEC_ERROR_INT_AXI2PCIE_RAM_SEC_ERR_INT;
- writel_relaxed(val, ctrl_base_addr + SEC_ERROR_INT);
- writel_relaxed(0, ctrl_base_addr + SEC_ERROR_INT_MASK);
- writel_relaxed(0, ctrl_base_addr + SEC_ERROR_EVENT_CNT);
+ port->axi_base_addr = devm_platform_ioremap_resource(pdev, 1);
+ if (IS_ERR(port->axi_base_addr))
+ return PTR_ERR(port->axi_base_addr);
- val = DED_ERROR_INT_TX_RAM_DED_ERR_INT |
- DED_ERROR_INT_RX_RAM_DED_ERR_INT |
- DED_ERROR_INT_PCIE2AXI_RAM_DED_ERR_INT |
- DED_ERROR_INT_AXI2PCIE_RAM_DED_ERR_INT;
- writel_relaxed(val, ctrl_base_addr + DED_ERROR_INT);
- writel_relaxed(0, ctrl_base_addr + DED_ERROR_INT_MASK);
- writel_relaxed(0, ctrl_base_addr + DED_ERROR_EVENT_CNT);
+ mc_disable_interrupts(port);
- writel_relaxed(0, bridge_base_addr + IMASK_HOST);
- writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST);
+ bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
+
+ port->msi.vector_phy = MSI_ADDR;
+ port->msi.num_vectors = MC_NUM_MSI_IRQS;
+
+ /* Hardware doesn't setup MSI by default */
+ mc_pcie_enable_msi(port, cfg->win);
/* Configure Address Translation Table 0 for PCIe config space */
mc_pcie_setup_window(bridge_base_addr, 0, cfg->res.start & 0xffffffff,
cfg->res.start, resource_size(&cfg->res));
- return mc_pcie_setup_windows(pdev, port);
+ ret = mc_pcie_setup_windows(pdev, port);
+ if (ret)
+ return ret;
+
+ /* Address translation is up; safe to enable interrupts */
+ return mc_init_interrupts(pdev, port);
}
static const struct pci_ecam_ops mc_ecam_ops = {
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 7/8] PCI: microchip: Gather MSI information from hardware config registers
2023-06-14 15:55 [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups daire.mcnamara
` (5 preceding siblings ...)
2023-06-14 15:55 ` [PATCH v1 6/8] PCI: microchip: Clean up initialisation of interrupts daire.mcnamara
@ 2023-06-14 15:55 ` daire.mcnamara
2023-06-19 10:20 ` Lorenzo Pieralisi
2023-06-14 15:55 ` [PATCH v1 8/8] PCI: microchip: Re-partition code between probe() and init() daire.mcnamara
7 siblings, 1 reply; 14+ messages in thread
From: daire.mcnamara @ 2023-06-14 15:55 UTC (permalink / raw)
To: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
Cc: Daire McNamara
From: Daire McNamara <daire.mcnamara@microchip.com>
The PCIe Root Complex on PolarFire SoC is configured at bitstream creation
time using Libero. Key MSI-related parameters include the number of
MSIs (1/2/4/8/16/32) and the MSI address. In the device driver, extract
this information from hw registers at init time, and use it to configure
MSI system, including configuring MSI capability structure correctly in
configuration space.
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/pci/controller/pcie-microchip-host.c | 73 +++++++++++---------
1 file changed, 40 insertions(+), 33 deletions(-)
diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
index 751f0243deb4..9ff0fb04b953 100644
--- a/drivers/pci/controller/pcie-microchip-host.c
+++ b/drivers/pci/controller/pcie-microchip-host.c
@@ -20,8 +20,7 @@
#include "../pci.h"
/* Number of MSI IRQs */
-#define MC_NUM_MSI_IRQS 32
-#define MC_NUM_MSI_IRQS_CODED 5
+#define MC_MAX_NUM_MSI_IRQS 32
/* PCIe Bridge Phy and Controller Phy offsets */
#define MC_PCIE1_BRIDGE_ADDR 0x00008000u
@@ -31,6 +30,11 @@
#define MC_PCIE_CTRL_ADDR (MC_PCIE1_CTRL_ADDR)
/* PCIe Bridge Phy Regs */
+#define PCIE_PCI_IRQ_DW0 0xa8
+#define MSIX_CAP_MASK BIT(31)
+#define NUM_MSI_MSGS_MASK GENMASK(6, 4)
+#define NUM_MSI_MSGS_SHIFT 4
+
#define IMASK_LOCAL 0x180
#define DMA_END_ENGINE_0_MASK 0x00000000u
#define DMA_END_ENGINE_0_SHIFT 0
@@ -79,7 +83,6 @@
#define IMASK_HOST 0x188
#define ISTATUS_HOST 0x18c
#define IMSI_ADDR 0x190
-#define MSI_ADDR 0x190
#define ISTATUS_MSI 0x194
/* PCIe Master table init defines */
@@ -158,8 +161,6 @@
/* PCIe Config space MSI capability structure */
#define MC_MSI_CAP_CTRL_OFFSET 0xe0u
-#define MC_MSI_MAX_Q_AVAIL (MC_NUM_MSI_IRQS_CODED << 1)
-#define MC_MSI_Q_SIZE (MC_NUM_MSI_IRQS_CODED << 4)
/* Events */
#define EVENT_PCIE_L2_EXIT 0
@@ -259,7 +260,7 @@ struct mc_msi {
struct irq_domain *dev_domain;
u32 num_vectors;
u64 vector_phy;
- DECLARE_BITMAP(used, MC_NUM_MSI_IRQS);
+ DECLARE_BITMAP(used, MC_MAX_NUM_MSI_IRQS);
};
struct mc_pcie {
@@ -382,25 +383,29 @@ static struct {
static char poss_clks[][5] = { "fic0", "fic1", "fic2", "fic3" };
-static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *base)
+static void mc_pcie_fixup_ecam(struct mc_pcie *port, void __iomem *ecam)
{
struct mc_msi *msi = &port->msi;
- u32 cap_offset = MC_MSI_CAP_CTRL_OFFSET;
- u16 msg_ctrl = readw_relaxed(base + cap_offset + PCI_MSI_FLAGS);
-
- msg_ctrl |= PCI_MSI_FLAGS_ENABLE;
- msg_ctrl &= ~PCI_MSI_FLAGS_QMASK;
- msg_ctrl |= MC_MSI_MAX_Q_AVAIL;
- msg_ctrl &= ~PCI_MSI_FLAGS_QSIZE;
- msg_ctrl |= MC_MSI_Q_SIZE;
- msg_ctrl |= PCI_MSI_FLAGS_64BIT;
-
- writew_relaxed(msg_ctrl, base + cap_offset + PCI_MSI_FLAGS);
-
+ u16 reg;
+ u8 queue_size;
+
+ /* Fixup MSI enable flag */
+ reg = readw_relaxed(ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_FLAGS);
+ reg |= PCI_MSI_FLAGS_ENABLE;
+ writew_relaxed(reg, ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_FLAGS);
+
+ /* Fixup PCI MSI queue flags */
+ queue_size = reg & PCI_MSI_FLAGS_QMASK;
+ queue_size >>= 1;
+ reg &= ~PCI_MSI_FLAGS_QSIZE;
+ reg |= queue_size << 4;
+ writew_relaxed(reg, ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_FLAGS);
+
+ /* Fixup MSI addr fields */
writel_relaxed(lower_32_bits(msi->vector_phy),
- base + cap_offset + PCI_MSI_ADDRESS_LO);
+ ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_LO);
writel_relaxed(upper_32_bits(msi->vector_phy),
- base + cap_offset + PCI_MSI_ADDRESS_HI);
+ ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_HI);
}
static void mc_handle_msi(struct irq_desc *desc)
@@ -473,10 +478,7 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
{
struct mc_pcie *port = domain->host_data;
struct mc_msi *msi = &port->msi;
- void __iomem *bridge_base_addr =
- port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
unsigned long bit;
- u32 val;
mutex_lock(&msi->lock);
bit = find_first_zero_bit(msi->used, msi->num_vectors);
@@ -490,11 +492,6 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
irq_domain_set_info(domain, virq, bit, &mc_msi_bottom_irq_chip,
domain->host_data, handle_edge_irq, NULL, NULL);
- /* Enable MSI interrupts */
- val = readl_relaxed(bridge_base_addr + IMASK_LOCAL);
- val |= PM_MSI_INT_MSI_MASK;
- writel_relaxed(val, bridge_base_addr + IMASK_LOCAL);
-
mutex_unlock(&msi->lock);
return 0;
@@ -1117,6 +1114,7 @@ static int mc_platform_init(struct pci_config_window *cfg)
struct mc_pcie *port;
void __iomem *bridge_base_addr;
int ret;
+ u32 val;
port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
if (!port)
@@ -1137,11 +1135,20 @@ static int mc_platform_init(struct pci_config_window *cfg)
bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
- port->msi.vector_phy = MSI_ADDR;
- port->msi.num_vectors = MC_NUM_MSI_IRQS;
+ /* Allow enabling MSI by disabling MSI-X */
+ val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0);
+ val &= ~MSIX_CAP_MASK;
+ writel(val, bridge_base_addr + PCIE_PCI_IRQ_DW0);
+
+ /* Pick num vectors from bitfile programmed onto FPGA fabric */
+ val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0);
+ val &= NUM_MSI_MSGS_MASK;
+ val >>= NUM_MSI_MSGS_SHIFT;
+
+ port->msi.num_vectors = 1 << val;
- /* Hardware doesn't setup MSI by default */
- mc_pcie_enable_msi(port, cfg->win);
+ /* Pick vector address from design */
+ port->msi.vector_phy = readl_relaxed(bridge_base_addr + IMSI_ADDR);
/* Configure Address Translation Table 0 for PCIe config space */
mc_pcie_setup_window(bridge_base_addr, 0, cfg->res.start & 0xffffffff,
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 8/8] PCI: microchip: Re-partition code between probe() and init()
2023-06-14 15:55 [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups daire.mcnamara
` (6 preceding siblings ...)
2023-06-14 15:55 ` [PATCH v1 7/8] PCI: microchip: Gather MSI information from hardware config registers daire.mcnamara
@ 2023-06-14 15:55 ` daire.mcnamara
7 siblings, 0 replies; 14+ messages in thread
From: daire.mcnamara @ 2023-06-14 15:55 UTC (permalink / raw)
To: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
Cc: Daire McNamara
From: Daire McNamara <daire.mcnamara@microchip.com>
Continuing to use pci_host_common_probe() for the PCIe Root Complex on
PolarFire SoC was leading to an extremely large _init() function and
some unnatural code flow. Re-partition so some tasks are done in
a _probe() routine, which calls pci_host_common_probe() and then use a
much smaller _init() function, mainly to enable interrupts after address
translation tables are set up.
Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/pci/controller/pcie-microchip-host.c | 55 ++++++++++++++------
1 file changed, 38 insertions(+), 17 deletions(-)
diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
index 9ff0fb04b953..c55911c48ec6 100644
--- a/drivers/pci/controller/pcie-microchip-host.c
+++ b/drivers/pci/controller/pcie-microchip-host.c
@@ -383,6 +383,8 @@ static struct {
static char poss_clks[][5] = { "fic0", "fic1", "fic2", "fic3" };
+static struct mc_pcie *port;
+
static void mc_pcie_fixup_ecam(struct mc_pcie *port, void __iomem *ecam)
{
struct mc_msi *msi = &port->msi;
@@ -1111,7 +1113,34 @@ static int mc_platform_init(struct pci_config_window *cfg)
{
struct device *dev = cfg->parent;
struct platform_device *pdev = to_platform_device(dev);
- struct mc_pcie *port;
+ void __iomem *bridge_base_addr =
+ port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
+ int ret;
+
+ /* Configure address translation table 0 for PCIe config space */
+ mc_pcie_setup_window(bridge_base_addr, 0, cfg->res.start,
+ cfg->res.start,
+ resource_size(&cfg->res));
+
+ /* Need some fixups in config space */
+ mc_pcie_fixup_ecam(port, cfg->win);
+
+ /* Configure non-config space outbound ranges */
+ ret = mc_pcie_setup_windows(pdev, port);
+ if (ret)
+ return ret;
+
+ /* Address translation is up; safe to enable interrupts */
+ ret = mc_init_interrupts(pdev, port);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int mc_host_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
void __iomem *bridge_base_addr;
int ret;
u32 val;
@@ -1119,13 +1148,8 @@ static int mc_platform_init(struct pci_config_window *cfg)
port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
if (!port)
return -ENOMEM;
- port->dev = dev;
- ret = mc_pcie_init_clks(dev);
- if (ret) {
- dev_err(dev, "failed to get clock resources, error %d\n", ret);
- return -ENODEV;
- }
+ port->dev = dev;
port->axi_base_addr = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(port->axi_base_addr))
@@ -1150,16 +1174,13 @@ static int mc_platform_init(struct pci_config_window *cfg)
/* Pick vector address from design */
port->msi.vector_phy = readl_relaxed(bridge_base_addr + IMSI_ADDR);
- /* Configure Address Translation Table 0 for PCIe config space */
- mc_pcie_setup_window(bridge_base_addr, 0, cfg->res.start & 0xffffffff,
- cfg->res.start, resource_size(&cfg->res));
-
- ret = mc_pcie_setup_windows(pdev, port);
- if (ret)
- return ret;
+ ret = mc_pcie_init_clks(dev);
+ if (ret) {
+ dev_err(dev, "failed to get clock resources, error %d\n", ret);
+ return -ENODEV;
+ }
- /* Address translation is up; safe to enable interrupts */
- return mc_init_interrupts(pdev, port);
+ return pci_host_common_probe(pdev);
}
static const struct pci_ecam_ops mc_ecam_ops = {
@@ -1182,7 +1203,7 @@ static const struct of_device_id mc_pcie_of_match[] = {
MODULE_DEVICE_TABLE(of, mc_pcie_of_match);
static struct platform_driver mc_pcie_driver = {
- .probe = pci_host_common_probe,
+ .probe = mc_host_probe,
.driver = {
.name = "microchip-pcie",
.of_match_table = mc_pcie_of_match,
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v1 3/8] PCI: microchip: enable building this driver as a module
2023-06-14 15:55 ` [PATCH v1 3/8] PCI: microchip: enable building this driver as a module daire.mcnamara
@ 2023-06-14 19:53 ` Uwe Kleine-König
2023-06-19 10:00 ` Lorenzo Pieralisi
1 sibling, 0 replies; 14+ messages in thread
From: Uwe Kleine-König @ 2023-06-14 19:53 UTC (permalink / raw)
To: daire.mcnamara
Cc: conor.dooley, lpieralisi, kw, robh, bhelgaas, linux-pci,
linux-riscv
[-- Attachment #1.1: Type: text/plain, Size: 883 bytes --]
Hello Daire,
On Wed, Jun 14, 2023 at 04:55:51PM +0100, daire.mcnamara@microchip.com wrote:
> From: Daire McNamara <daire.mcnamara@microchip.com>
>
> Enable building this driver as a module. The expected use case is the
> driver is built as a module, is installed when needed, and cannot be
> removed once installed.
>
> The remove() callback is not implemented as removing a driver with
> INTx and MSI interrupt handling is inherently unsafe.
The relevant thing here is not that there is no .remove callback (which
doesn't make the driver non-removable) but that the driver has
.suppress_bind_attrs = true.
With that properly mentioned in the changelog, the patch is fine for me.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 3/8] PCI: microchip: enable building this driver as a module
2023-06-14 15:55 ` [PATCH v1 3/8] PCI: microchip: enable building this driver as a module daire.mcnamara
2023-06-14 19:53 ` Uwe Kleine-König
@ 2023-06-19 10:00 ` Lorenzo Pieralisi
1 sibling, 0 replies; 14+ messages in thread
From: Lorenzo Pieralisi @ 2023-06-19 10:00 UTC (permalink / raw)
To: daire.mcnamara
Cc: conor.dooley, kw, robh, bhelgaas, linux-pci, linux-riscv,
Uwe Kleine-König
Nit: "Enable building driver as a module"
Capital "E" and removed "this" as that's obvious.
On Wed, Jun 14, 2023 at 04:55:51PM +0100, daire.mcnamara@microchip.com wrote:
> From: Daire McNamara <daire.mcnamara@microchip.com>
>
> Enable building this driver as a module. The expected use case is the
> driver is built as a module, is installed when needed, and cannot be
> removed once installed.
>
> The remove() callback is not implemented as removing a driver with
> INTx and MSI interrupt handling is inherently unsafe.
Other than Uwe's comment, that I will integrate, the sentence above
should be linked to the Link: below otherwise it is not easy to
parse - it requires some context.
I will do it.
Lorenzo
>
> Link: https://lore.kernel.org/linux-pci/87y1wgbah8.wl-maz@kernel.org/
> Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> ---
> drivers/pci/controller/Kconfig | 2 +-
> drivers/pci/controller/pcie-microchip-host.c | 1 +
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> index 8d49bad7f847..f4ad0e9cca45 100644
> --- a/drivers/pci/controller/Kconfig
> +++ b/drivers/pci/controller/Kconfig
> @@ -217,7 +217,7 @@ config PCIE_MT7621
> This selects a driver for the MediaTek MT7621 PCIe Controller.
>
> config PCIE_MICROCHIP_HOST
> - bool "Microchip AXI PCIe controller"
> + tristate "Microchip AXI PCIe controller"
> depends on PCI_MSI && OF
> select PCI_HOST_COMMON
> help
> diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
> index 73046bad1521..5efd480e42fa 100644
> --- a/drivers/pci/controller/pcie-microchip-host.c
> +++ b/drivers/pci/controller/pcie-microchip-host.c
> @@ -1141,5 +1141,6 @@ static struct platform_driver mc_pcie_driver = {
> };
>
> builtin_platform_driver(mc_pcie_driver);
> +MODULE_LICENSE("GPL");
> MODULE_DESCRIPTION("Microchip PCIe host controller driver");
> MODULE_AUTHOR("Daire McNamara <daire.mcnamara@microchip.com>");
> --
> 2.25.1
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 7/8] PCI: microchip: Gather MSI information from hardware config registers
2023-06-14 15:55 ` [PATCH v1 7/8] PCI: microchip: Gather MSI information from hardware config registers daire.mcnamara
@ 2023-06-19 10:20 ` Lorenzo Pieralisi
0 siblings, 0 replies; 14+ messages in thread
From: Lorenzo Pieralisi @ 2023-06-19 10:20 UTC (permalink / raw)
To: daire.mcnamara; +Cc: conor.dooley, kw, robh, bhelgaas, linux-pci, linux-riscv
On Wed, Jun 14, 2023 at 04:55:55PM +0100, daire.mcnamara@microchip.com wrote:
> From: Daire McNamara <daire.mcnamara@microchip.com>
>
> The PCIe Root Complex on PolarFire SoC is configured at bitstream creation
> time using Libero. Key MSI-related parameters include the number of
> MSIs (1/2/4/8/16/32) and the MSI address. In the device driver, extract
> this information from hw registers at init time, and use it to configure
> MSI system, including configuring MSI capability structure correctly in
> configuration space.
>
> Signed-off-by: Daire McNamara <daire.mcnamara@microchip.com>
> Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
> ---
> drivers/pci/controller/pcie-microchip-host.c | 73 +++++++++++---------
> 1 file changed, 40 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/pcie-microchip-host.c
> index 751f0243deb4..9ff0fb04b953 100644
> --- a/drivers/pci/controller/pcie-microchip-host.c
> +++ b/drivers/pci/controller/pcie-microchip-host.c
> @@ -20,8 +20,7 @@
> #include "../pci.h"
>
> /* Number of MSI IRQs */
> -#define MC_NUM_MSI_IRQS 32
> -#define MC_NUM_MSI_IRQS_CODED 5
> +#define MC_MAX_NUM_MSI_IRQS 32
>
> /* PCIe Bridge Phy and Controller Phy offsets */
> #define MC_PCIE1_BRIDGE_ADDR 0x00008000u
> @@ -31,6 +30,11 @@
> #define MC_PCIE_CTRL_ADDR (MC_PCIE1_CTRL_ADDR)
>
> /* PCIe Bridge Phy Regs */
> +#define PCIE_PCI_IRQ_DW0 0xa8
> +#define MSIX_CAP_MASK BIT(31)
> +#define NUM_MSI_MSGS_MASK GENMASK(6, 4)
> +#define NUM_MSI_MSGS_SHIFT 4
> +
> #define IMASK_LOCAL 0x180
> #define DMA_END_ENGINE_0_MASK 0x00000000u
> #define DMA_END_ENGINE_0_SHIFT 0
> @@ -79,7 +83,6 @@
> #define IMASK_HOST 0x188
> #define ISTATUS_HOST 0x18c
> #define IMSI_ADDR 0x190
> -#define MSI_ADDR 0x190
> #define ISTATUS_MSI 0x194
>
> /* PCIe Master table init defines */
> @@ -158,8 +161,6 @@
>
> /* PCIe Config space MSI capability structure */
> #define MC_MSI_CAP_CTRL_OFFSET 0xe0u
> -#define MC_MSI_MAX_Q_AVAIL (MC_NUM_MSI_IRQS_CODED << 1)
> -#define MC_MSI_Q_SIZE (MC_NUM_MSI_IRQS_CODED << 4)
>
> /* Events */
> #define EVENT_PCIE_L2_EXIT 0
> @@ -259,7 +260,7 @@ struct mc_msi {
> struct irq_domain *dev_domain;
> u32 num_vectors;
> u64 vector_phy;
> - DECLARE_BITMAP(used, MC_NUM_MSI_IRQS);
> + DECLARE_BITMAP(used, MC_MAX_NUM_MSI_IRQS);
> };
>
> struct mc_pcie {
> @@ -382,25 +383,29 @@ static struct {
>
> static char poss_clks[][5] = { "fic0", "fic1", "fic2", "fic3" };
>
> -static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *base)
> +static void mc_pcie_fixup_ecam(struct mc_pcie *port, void __iomem *ecam)
> {
> struct mc_msi *msi = &port->msi;
> - u32 cap_offset = MC_MSI_CAP_CTRL_OFFSET;
> - u16 msg_ctrl = readw_relaxed(base + cap_offset + PCI_MSI_FLAGS);
> -
> - msg_ctrl |= PCI_MSI_FLAGS_ENABLE;
> - msg_ctrl &= ~PCI_MSI_FLAGS_QMASK;
> - msg_ctrl |= MC_MSI_MAX_Q_AVAIL;
> - msg_ctrl &= ~PCI_MSI_FLAGS_QSIZE;
> - msg_ctrl |= MC_MSI_Q_SIZE;
> - msg_ctrl |= PCI_MSI_FLAGS_64BIT;
> -
> - writew_relaxed(msg_ctrl, base + cap_offset + PCI_MSI_FLAGS);
> -
> + u16 reg;
> + u8 queue_size;
> +
> + /* Fixup MSI enable flag */
> + reg = readw_relaxed(ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_FLAGS);
> + reg |= PCI_MSI_FLAGS_ENABLE;
> + writew_relaxed(reg, ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_FLAGS);
> +
> + /* Fixup PCI MSI queue flags */
> + queue_size = reg & PCI_MSI_FLAGS_QMASK;
> + queue_size >>= 1;
> + reg &= ~PCI_MSI_FLAGS_QSIZE;
> + reg |= queue_size << 4;
> + writew_relaxed(reg, ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_FLAGS);
> +
> + /* Fixup MSI addr fields */
> writel_relaxed(lower_32_bits(msi->vector_phy),
> - base + cap_offset + PCI_MSI_ADDRESS_LO);
> + ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_LO);
> writel_relaxed(upper_32_bits(msi->vector_phy),
> - base + cap_offset + PCI_MSI_ADDRESS_HI);
> + ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_HI);
This hunk is just code refactoring that has nothing to do AFAICS with
the commit log purpose, a patch must have a single logical purpose.
> }
>
> static void mc_handle_msi(struct irq_desc *desc)
> @@ -473,10 +478,7 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
> {
> struct mc_pcie *port = domain->host_data;
> struct mc_msi *msi = &port->msi;
> - void __iomem *bridge_base_addr =
> - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
> unsigned long bit;
> - u32 val;
>
> mutex_lock(&msi->lock);
> bit = find_first_zero_bit(msi->used, msi->num_vectors);
> @@ -490,11 +492,6 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
> irq_domain_set_info(domain, virq, bit, &mc_msi_bottom_irq_chip,
> domain->host_data, handle_edge_irq, NULL, NULL);
>
> - /* Enable MSI interrupts */
> - val = readl_relaxed(bridge_base_addr + IMASK_LOCAL);
> - val |= PM_MSI_INT_MSI_MASK;
> - writel_relaxed(val, bridge_base_addr + IMASK_LOCAL);
> -
> mutex_unlock(&msi->lock);
>
> return 0;
> @@ -1117,6 +1114,7 @@ static int mc_platform_init(struct pci_config_window *cfg)
> struct mc_pcie *port;
> void __iomem *bridge_base_addr;
> int ret;
> + u32 val;
>
> port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
> if (!port)
> @@ -1137,11 +1135,20 @@ static int mc_platform_init(struct pci_config_window *cfg)
>
> bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR;
>
> - port->msi.vector_phy = MSI_ADDR;
> - port->msi.num_vectors = MC_NUM_MSI_IRQS;
> + /* Allow enabling MSI by disabling MSI-X */
Mmm..see above. It is not clear to me what this patch does overall, for
certain it does more that what's stated in the commit log and this ought
to be fixed.
Lorenzo
> + val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0);
> + val &= ~MSIX_CAP_MASK;
> + writel(val, bridge_base_addr + PCIE_PCI_IRQ_DW0);
> +
> + /* Pick num vectors from bitfile programmed onto FPGA fabric */
> + val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0);
> + val &= NUM_MSI_MSGS_MASK;
> + val >>= NUM_MSI_MSGS_SHIFT;
> +
> + port->msi.num_vectors = 1 << val;
>
> - /* Hardware doesn't setup MSI by default */
> - mc_pcie_enable_msi(port, cfg->win);
> + /* Pick vector address from design */
> + port->msi.vector_phy = readl_relaxed(bridge_base_addr + IMSI_ADDR);
>
> /* Configure Address Translation Table 0 for PCIe config space */
> mc_pcie_setup_window(bridge_base_addr, 0, cfg->res.start & 0xffffffff,
> --
> 2.25.1
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 2/8] PCI: microchip: Remove cast warning for devm_add_action_or_reset() arg
2023-06-14 15:55 ` [PATCH v1 2/8] PCI: microchip: Remove cast warning for devm_add_action_or_reset() arg daire.mcnamara
@ 2023-06-24 18:34 ` Krzysztof Wilczyński
2023-06-24 19:03 ` Simon Horman
0 siblings, 1 reply; 14+ messages in thread
From: Krzysztof Wilczyński @ 2023-06-24 18:34 UTC (permalink / raw)
To: daire.mcnamara
Cc: conor.dooley, lpieralisi, robh, bhelgaas, linux-pci, linux-riscv,
Simon Horman
[+CC Simon]
Hello,
> The kernel test robot reported that the ugly cast from
> void(*)(struct clk *) to void (*)(void *) converts to incompatible
> function type. This commit adopts the common convention of creating a
> trivial stub function that takes a void * and passes it to the
> underlying function that expects the more specific type.
This is a nice change, but it seems it has been carried along a few other
series and through their different revisions. Simon also found the problem
and addressed it independently per:
https://lore.kernel.org/linux-pci/20230511-pci-microchip-clk-cast-v1-1-7674f4d4e218@kernel.org
However, we have a few other drivers where we could take care of this, per:
drivers/pci/controller/pcie-microchip-host.c
864- return ERR_PTR(ret);
865-
866: devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare,
867- clk);
868-
drivers/pci/controller/dwc/pcie-keembay.c
170-
171- ret = devm_add_action_or_reset(dev,
172: (void(*)(void *))clk_disable_unprepare,
173- clk);
174- if (ret)
drivers/pci/controller/dwc/pci-meson.c
189-
190- devm_add_action_or_reset(dev,
191: (void (*) (void *))clk_disable_unprepare,
192- clk);
193-
If neither you nor Simon has objections, I can send a small series to
address these in a single take. You could then drop this particular patch
from v2 of this series, should you send a second revision at some point.
Thoughts?
Krzysztof
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 2/8] PCI: microchip: Remove cast warning for devm_add_action_or_reset() arg
2023-06-24 18:34 ` Krzysztof Wilczyński
@ 2023-06-24 19:03 ` Simon Horman
0 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2023-06-24 19:03 UTC (permalink / raw)
To: Krzysztof Wilczyński
Cc: daire.mcnamara, conor.dooley, lpieralisi, robh, bhelgaas,
linux-pci, linux-riscv
On Sun, Jun 25, 2023 at 03:34:28AM +0900, Krzysztof Wilczyński wrote:
> [+CC Simon]
>
> Hello,
>
> > The kernel test robot reported that the ugly cast from
> > void(*)(struct clk *) to void (*)(void *) converts to incompatible
> > function type. This commit adopts the common convention of creating a
> > trivial stub function that takes a void * and passes it to the
> > underlying function that expects the more specific type.
>
> This is a nice change, but it seems it has been carried along a few other
> series and through their different revisions. Simon also found the problem
> and addressed it independently per:
>
> https://lore.kernel.org/linux-pci/20230511-pci-microchip-clk-cast-v1-1-7674f4d4e218@kernel.org
>
> However, we have a few other drivers where we could take care of this, per:
>
> drivers/pci/controller/pcie-microchip-host.c
> 864- return ERR_PTR(ret);
> 865-
> 866: devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare,
> 867- clk);
> 868-
>
> drivers/pci/controller/dwc/pcie-keembay.c
> 170-
> 171- ret = devm_add_action_or_reset(dev,
> 172: (void(*)(void *))clk_disable_unprepare,
> 173- clk);
> 174- if (ret)
>
> drivers/pci/controller/dwc/pci-meson.c
> 189-
> 190- devm_add_action_or_reset(dev,
> 191: (void (*) (void *))clk_disable_unprepare,
> 192- clk);
> 193-
>
> If neither you nor Simon has objections, I can send a small series to
> address these in a single take. You could then drop this particular patch
> from v2 of this series, should you send a second revision at some point.
Hi Krzysztof,
Sure, that is fine my me.
My 2c worth, is that it would be nice to have a common
helper for these cases. But I don't feel strongly about it.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2023-06-24 19:03 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-14 15:55 [PATCH v1 0/8] PCI: microchip: Fixes and clean-ups daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 1/8] PCI: microchip: Correct the DED and SEC interrupt bit offsets daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 2/8] PCI: microchip: Remove cast warning for devm_add_action_or_reset() arg daire.mcnamara
2023-06-24 18:34 ` Krzysztof Wilczyński
2023-06-24 19:03 ` Simon Horman
2023-06-14 15:55 ` [PATCH v1 3/8] PCI: microchip: enable building this driver as a module daire.mcnamara
2023-06-14 19:53 ` Uwe Kleine-König
2023-06-19 10:00 ` Lorenzo Pieralisi
2023-06-14 15:55 ` [PATCH v1 4/8] PCI: microchip: Align register, offset, and mask names with hw docs daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 5/8] PCI: microchip: Enable event handlers to access bridge and ctrl ptrs daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 6/8] PCI: microchip: Clean up initialisation of interrupts daire.mcnamara
2023-06-14 15:55 ` [PATCH v1 7/8] PCI: microchip: Gather MSI information from hardware config registers daire.mcnamara
2023-06-19 10:20 ` Lorenzo Pieralisi
2023-06-14 15:55 ` [PATCH v1 8/8] PCI: microchip: Re-partition code between probe() and init() daire.mcnamara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).