Skip to contentSkip to conversation

i3c: mipi-i3c-hci-pci: Add LTR support for Intel controllers

PATCH Superseded Adrian Hunter 2 participants 33 messages Nov 14, 2025 – Nov 17, 2025 I3C

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#1 lore raw

PATCH v2 1/13 i3c: mipi-i3c-hci-pci: Set 64-bit DMA mask for Intel controllers

In reply to Adrian Hunter

All Intel controllers support 64-bit DMA. Set the DMA mask accordingly.

This is needed only if there is no IOMMU configured, which is not recommended, but possible.

---

Changes in V2:

	No need to check error from dma_set_mask_and_coherent() with a
	64-bit mask
 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -0
index dd4484eff2f0..3cd15ca7d391 100644
@@ -36,6 +36,8 @@ static int mipi_i3c_hci_pci_intel_init(struct pci_dev *pci)
 	if (!priv)
 		return -ENOMEM;
 
+	dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64));
+
 	/* Assert reset, wait for completion and release reset */
 	writel(0, priv + INTEL_PRIV_RESETS);
 	timeout = jiffies + msecs_to_jiffies(10);
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#0 lore raw

v2 cover i3c: mipi-i3c-hci-pci: Add LTR support for Intel controllers

Hi

Here are V2 patches primarily to add support for Latency Tolerance Reporting (LTR) for Intel controllers. Most patches are small tidy-ups or preparation for the main change.

Changes in V2:
i3c: mipi-i3c-hci-pci: Set 64-bit DMA mask for Intel controllers
No need to check error from dma_set_mask_and_coherent() with a 64-bit mask

i3c: mipi-i3c-hci-pci: Rename some Intel-related identifiers
Rename 'intel_init' to 'intel_i3c_init'
More explanation in commit message

i3c: mipi-i3c-hci-pci: Use readl_poll_timeout()
Change 10000 to (10 * USEC_PER_MSEC)

i3c: mipi-i3c-hci-pci: Constify driver data
Add Frank's Rev'd-by

i3c: mipi-i3c-hci-pci: Factor out intel_reset()
Move location of intel_reset() to get a prettier diff

i3c: mipi-i3c-hci-pci: Allocate a structure for mipi_i3c_hci_pci device information
Add Frank's Rev'd-by

i3c: mipi-i3c-hci-pci: Add LTR support for Intel controllers
Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

Adrian Hunter (13):
i3c: mipi-i3c-hci-pci: Set 64-bit DMA mask for Intel controllers
i3c: mipi-i3c-hci-pci: Move all Intel-related definitions together
i3c: mipi-i3c-hci-pci: Rename some Intel-related identifiers
i3c: mipi-i3c-hci-pci: Use readl_poll_timeout()
i3c: mipi-i3c-hci-pci: Constify driver data
i3c: mipi-i3c-hci-pci: Factor out private registers ioremapping
i3c: mipi-i3c-hci-pci: Factor out intel_reset()
i3c: mipi-i3c-hci-pci: Allocate a structure for mipi_i3c_hci_pci device information
i3c: mipi-i3c-hci-pci: Change callback parameter
i3c: mipi-i3c-hci-pci: Add exit callback
i3c: mipi-i3c-hci-pci: Allocate a structure for Intel controller information
i3c: mipi-i3c-hci-pci: Add LTR support for Intel controllers
i3c: mipi-i3c-hci-pci: Set d3cold_delay to 0 for Intel controllers

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 238 +++++++++++++++++----
 1 file changed, 200 insertions(+), 38 deletions(-)

Regards
Adrian

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#3 lore raw

PATCH v2 2/13 i3c: mipi-i3c-hci-pci: Move all Intel-related definitions together

Move all Intel-related definitions together, to tidy the code slightly.

---

Changes in V2:

None

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -2
index 3cd15ca7d391..3d854cee05df 100644
@@ -17,14 +17,14 @@ struct mipi_i3c_hci_pci_info {
 	int (*init)(struct pci_dev *pci);
 };
 
+static DEFINE_IDA(mipi_i3c_hci_pci_ida);
+
 #define INTEL_PRIV_OFFSET		0x2b0
 #define INTEL_PRIV_SIZE			0x28
 #define INTEL_PRIV_RESETS		0x04
 #define INTEL_PRIV_RESETS_RESET		BIT(0)
 #define INTEL_PRIV_RESETS_RESET_DONE	BIT(1)
 
-static DEFINE_IDA(mipi_i3c_hci_pci_ida);
-
 static int mipi_i3c_hci_pci_intel_init(struct pci_dev *pci)
 {
 	unsigned long timeout;
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#4 lore raw

PATCH v2 3/13 i3c: mipi-i3c-hci-pci: Rename some Intel-related identifiers

In reply to Adrian Hunter

Rename some Intel-related identifiers to ensure Intel-related identifiers begin "intel_" or INTEL_, and for brevity removing purposeless "PRIV" in preparation to add more register definitions.

---

Changes in V2:

Rename 'intel_init' to 'intel_i3c_init'
More explanation in commit message

 .../i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +9 -9
index 3d854cee05df..d434e2962740 100644
@@ -21,11 +21,11 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 
 #define INTEL_PRIV_OFFSET		0x2b0
 #define INTEL_PRIV_SIZE			0x28
-#define INTEL_PRIV_RESETS		0x04
-#define INTEL_PRIV_RESETS_RESET		BIT(0)
-#define INTEL_PRIV_RESETS_RESET_DONE	BIT(1)
+#define INTEL_RESETS			0x04
+#define INTEL_RESETS_RESET		BIT(0)
+#define INTEL_RESETS_RESET_DONE		BIT(1)
 
-static int mipi_i3c_hci_pci_intel_init(struct pci_dev *pci)
+static int intel_i3c_init(struct pci_dev *pci)
 {
 	unsigned long timeout;
 	void __iomem *priv;
@@ -39,21 +39,21 @@ static int mipi_i3c_hci_pci_intel_init(struct pci_dev *pci)
 	dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64));
 
 	/* Assert reset, wait for completion and release reset */
-	writel(0, priv + INTEL_PRIV_RESETS);
+	writel(0, priv + INTEL_RESETS);
 	timeout = jiffies + msecs_to_jiffies(10);
-	while (!(readl(priv + INTEL_PRIV_RESETS) &
-		 INTEL_PRIV_RESETS_RESET_DONE)) {
+	while (!(readl(priv + INTEL_RESETS) &
+		 INTEL_RESETS_RESET_DONE)) {
 		if (time_after(jiffies, timeout))
 			break;
 		cpu_relax();
 	}
-	writel(INTEL_PRIV_RESETS_RESET, priv + INTEL_PRIV_RESETS);
+	writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
 
 	return 0;
 }
 
 static struct mipi_i3c_hci_pci_info intel_info = {
-	.init = mipi_i3c_hci_pci_intel_init,
+	.init = intel_i3c_init,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#6 lore raw

PATCH v2 4/13 i3c: mipi-i3c-hci-pci: Use readl_poll_timeout()

In reply to Adrian Hunter

Use readl_poll_timeout() instead of open-coding the polling loop.

---

Changes in V2:

	Change 10000 to (10 * USEC_PER_MSEC)
 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +6 -8
index d434e2962740..30915d78045e 100644
@@ -8,6 +8,7 @@
  */
 #include <linux/acpi.h>
 #include <linux/idr.h>
+#include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -24,11 +25,12 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 #define INTEL_RESETS			0x04
 #define INTEL_RESETS_RESET		BIT(0)
 #define INTEL_RESETS_RESET_DONE		BIT(1)
+#define INTEL_RESETS_TIMEOUT_US		(10 * USEC_PER_MSEC)
 
 static int intel_i3c_init(struct pci_dev *pci)
 {
-	unsigned long timeout;
 	void __iomem *priv;
+	u32 reg;
 
 	priv = devm_ioremap(&pci->dev,
 			    pci_resource_start(pci, 0) + INTEL_PRIV_OFFSET,
@@ -40,13 +42,9 @@ static int intel_i3c_init(struct pci_dev *pci)
 
 	/* Assert reset, wait for completion and release reset */
 	writel(0, priv + INTEL_RESETS);
-	timeout = jiffies + msecs_to_jiffies(10);
-	while (!(readl(priv + INTEL_RESETS) &
-		 INTEL_RESETS_RESET_DONE)) {
-		if (time_after(jiffies, timeout))
-			break;
-		cpu_relax();
-	}
+	readl_poll_timeout(priv + INTEL_RESETS, reg,
+			   reg & INTEL_RESETS_RESET_DONE, 0,
+			   INTEL_RESETS_TIMEOUT_US);
 	writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
 
 	return 0;
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#8 lore raw

PATCH v2 5/13 i3c: mipi-i3c-hci-pci: Constify driver data

In reply to Adrian Hunter

Add const qualifier to driver data because it is constant.

---

Changes in V2:

Add Frank's Rev'd-by

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +3 -3
index 30915d78045e..abc7bad5e069 100644
@@ -50,14 +50,14 @@ static int intel_i3c_init(struct pci_dev *pci)
 	return 0;
 }
 
-static struct mipi_i3c_hci_pci_info intel_info = {
+static const struct mipi_i3c_hci_pci_info intel_info = {
 	.init = intel_i3c_init,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 				  const struct pci_device_id *id)
 {
-	struct mipi_i3c_hci_pci_info *info;
+	const struct mipi_i3c_hci_pci_info *info;
 	struct platform_device *pdev;
 	struct resource res[2];
 	int dev_id, ret;
@@ -93,7 +93,7 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (ret)
 		goto err;
 
-	info = (struct mipi_i3c_hci_pci_info *)id->driver_data;
+	info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
 	if (info && info->init) {
 		ret = info->init(pci);
 		if (ret)
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#9 lore raw

PATCH v2 6/13 i3c: mipi-i3c-hci-pci: Factor out private registers ioremapping

In reply to Adrian Hunter

For neatness, factor out private registers ioremapping.

---

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +8 -4
index abc7bad5e069..1e1f2c42bd74 100644
@@ -27,14 +27,18 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 #define INTEL_RESETS_RESET_DONE		BIT(1)
 #define INTEL_RESETS_TIMEOUT_US		(10 * USEC_PER_MSEC)
 
+static void __iomem *intel_priv(struct pci_dev *pci)
+{
+	resource_size_t base = pci_resource_start(pci, 0);
+
+	return devm_ioremap(&pci->dev, base + INTEL_PRIV_OFFSET, INTEL_PRIV_SIZE);
+}
+
 static int intel_i3c_init(struct pci_dev *pci)
 {
-	void __iomem *priv;
+	void __iomem *priv = intel_priv(pci);
 	u32 reg;
 
-	priv = devm_ioremap(&pci->dev,
-			    pci_resource_start(pci, 0) + INTEL_PRIV_OFFSET,
-			    INTEL_PRIV_SIZE);
 	if (!priv)
 		return -ENOMEM;
 
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#10 lore raw

PATCH v2 7/13 i3c: mipi-i3c-hci-pci: Factor out intel_reset()

In reply to Adrian Hunter

For neatness, factor out intel_reset().

---

Changes in V2:

Move location of intel_reset() to get a prettier diff

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 20 ++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +13 -7
index 1e1f2c42bd74..b9794212b2fb 100644
@@ -27,6 +27,18 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 #define INTEL_RESETS_RESET_DONE		BIT(1)
 #define INTEL_RESETS_TIMEOUT_US		(10 * USEC_PER_MSEC)
 
+static void intel_reset(void __iomem *priv)
+{
+	u32 reg;
+
+	/* Assert reset, wait for completion and release reset */
+	writel(0, priv + INTEL_RESETS);
+	readl_poll_timeout(priv + INTEL_RESETS, reg,
+			   reg & INTEL_RESETS_RESET_DONE, 0,
+			   INTEL_RESETS_TIMEOUT_US);
+	writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
+}
+
 static void __iomem *intel_priv(struct pci_dev *pci)
 {
 	resource_size_t base = pci_resource_start(pci, 0);
@@ -37,19 +49,13 @@ static void __iomem *intel_priv(struct pci_dev *pci)
 static int intel_i3c_init(struct pci_dev *pci)
 {
 	void __iomem *priv = intel_priv(pci);
-	u32 reg;
 
 	if (!priv)
 		return -ENOMEM;
 
 	dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64));
 
-	/* Assert reset, wait for completion and release reset */
-	writel(0, priv + INTEL_RESETS);
-	readl_poll_timeout(priv + INTEL_RESETS, reg,
-			   reg & INTEL_RESETS_RESET_DONE, 0,
-			   INTEL_RESETS_TIMEOUT_US);
-	writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
+	intel_reset(priv);
 
 	return 0;
 }
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#12 lore raw

PATCH v2 8/13 i3c: mipi-i3c-hci-pci: Allocate a structure for mipi_i3c_hci_pci device information

In reply to Adrian Hunter

Allocate a structure for mipi_i3c_hci_pci device information, in preparation for additional changes that need to store mipi_i3c_hci_pci device-specific information.

---

Changes in V2:

Add Frank's Rev'd-by

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 29 ++++++++++++-------
 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +19 -10
index b9794212b2fb..8936e50eddf7 100644
@@ -14,6 +14,10 @@
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 
+struct mipi_i3c_hci_pci {
+	struct platform_device *pdev;
+};
+
 struct mipi_i3c_hci_pci_info {
 	int (*init)(struct pci_dev *pci);
 };
@@ -68,10 +72,14 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 				  const struct pci_device_id *id)
 {
 	const struct mipi_i3c_hci_pci_info *info;
-	struct platform_device *pdev;
+	struct mipi_i3c_hci_pci *hci;
 	struct resource res[2];
 	int dev_id, ret;
 
+	hci = devm_kzalloc(&pci->dev, sizeof(*hci), GFP_KERNEL);
+	if (!hci)
+		return -ENOMEM;
+
 	ret = pcim_enable_device(pci);
 	if (ret)
 		return ret;
@@ -92,14 +100,14 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (dev_id < 0)
 		return dev_id;
 
-	pdev = platform_device_alloc("mipi-i3c-hci", dev_id);
-	if (!pdev)
+	hci->pdev = platform_device_alloc("mipi-i3c-hci", dev_id);
+	if (!hci->pdev)
 		return -ENOMEM;
 
-	pdev->dev.parent = &pci->dev;
-	device_set_node(&pdev->dev, dev_fwnode(&pci->dev));
+	hci->pdev->dev.parent = &pci->dev;
+	device_set_node(&hci->pdev->dev, dev_fwnode(&pci->dev));
 
-	ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res));
+	ret = platform_device_add_resources(hci->pdev, res, ARRAY_SIZE(res));
 	if (ret)
 		goto err;
 
@@ -110,23 +118,24 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 			goto err;
 	}
 
-	ret = platform_device_add(pdev);
+	ret = platform_device_add(hci->pdev);
 	if (ret)
 		goto err;
 
-	pci_set_drvdata(pci, pdev);
+	pci_set_drvdata(pci, hci);
 
 	return 0;
 
 err:
-	platform_device_put(pdev);
+	platform_device_put(hci->pdev);
 	ida_free(&mipi_i3c_hci_pci_ida, dev_id);
 	return ret;
 }
 
 static void mipi_i3c_hci_pci_remove(struct pci_dev *pci)
 {
-	struct platform_device *pdev = pci_get_drvdata(pci);
+	struct mipi_i3c_hci_pci *hci = pci_get_drvdata(pci);
+	struct platform_device *pdev = hci->pdev;
 	int dev_id = pdev->id;
 
 	platform_device_unregister(pdev);
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#13 lore raw

PATCH v2 9/13 i3c: mipi-i3c-hci-pci: Change callback parameter

In reply to Adrian Hunter

Change ->init() callback parameter from a pointer to the PCI device to a pointer to the locally defined mipi_i3c_hci_pci_info device information. This is in preparation for consistency when adding more callbacks that will need struct mipi_i3c_hci_pci_info.

---

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +8 -5
index 8936e50eddf7..7bfb9fe337b6 100644
@@ -15,11 +15,12 @@
 #include <linux/platform_device.h>
 
 struct mipi_i3c_hci_pci {
+	struct pci_dev *pci;
 	struct platform_device *pdev;
 };
 
 struct mipi_i3c_hci_pci_info {
-	int (*init)(struct pci_dev *pci);
+	int (*init)(struct mipi_i3c_hci_pci *hci);
 };
 
 static DEFINE_IDA(mipi_i3c_hci_pci_ida);
@@ -50,14 +51,14 @@ static void __iomem *intel_priv(struct pci_dev *pci)
 	return devm_ioremap(&pci->dev, base + INTEL_PRIV_OFFSET, INTEL_PRIV_SIZE);
 }
 
-static int intel_i3c_init(struct pci_dev *pci)
+static int intel_i3c_init(struct mipi_i3c_hci_pci *hci)
 {
-	void __iomem *priv = intel_priv(pci);
+	void __iomem *priv = intel_priv(hci->pci);
 
 	if (!priv)
 		return -ENOMEM;
 
-	dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64));
+	dma_set_mask_and_coherent(&hci->pci->dev, DMA_BIT_MASK(64));
 
 	intel_reset(priv);
 
@@ -80,6 +81,8 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (!hci)
 		return -ENOMEM;
 
+	hci->pci = pci;
+
 	ret = pcim_enable_device(pci);
 	if (ret)
 		return ret;
@@ -113,7 +116,7 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 
 	info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
 	if (info && info->init) {
-		ret = info->init(pci);
+		ret = info->init(hci);
 		if (ret)
 			goto err;
 	}
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#15 lore raw

PATCH v2 10/13 i3c: mipi-i3c-hci-pci: Add exit callback

In reply to Adrian Hunter

Add ->exit() callback as a counterpart to ->init(). This is in preparation for adding device-specific features that require cleanup upon driver removal.

---

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +8 -4
index 7bfb9fe337b6..b962d3c2d510 100644
@@ -17,10 +17,12 @@
 struct mipi_i3c_hci_pci {
 	struct pci_dev *pci;
 	struct platform_device *pdev;
+	const struct mipi_i3c_hci_pci_info *info;
 };
 
 struct mipi_i3c_hci_pci_info {
 	int (*init)(struct mipi_i3c_hci_pci *hci);
+	void (*exit)(struct mipi_i3c_hci_pci *hci);
 };
 
 static DEFINE_IDA(mipi_i3c_hci_pci_ida);
@@ -72,7 +74,6 @@ static const struct mipi_i3c_hci_pci_info intel_info = {
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 				  const struct pci_device_id *id)
 {
-	const struct mipi_i3c_hci_pci_info *info;
 	struct mipi_i3c_hci_pci *hci;
 	struct resource res[2];
 	int dev_id, ret;
@@ -114,9 +115,9 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (ret)
 		goto err;
 
-	info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
-	if (info && info->init) {
-		ret = info->init(hci);
+	hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
+	if (hci->info && hci->info->init) {
+		ret = hci->info->init(hci);
 		if (ret)
 			goto err;
 	}
@@ -141,6 +142,9 @@ static void mipi_i3c_hci_pci_remove(struct pci_dev *pci)
 	struct platform_device *pdev = hci->pdev;
 	int dev_id = pdev->id;
 
+	if (hci->info && hci->info->exit)
+		hci->info->exit(hci);
+
 	platform_device_unregister(pdev);
 	ida_free(&mipi_i3c_hci_pci_ida, dev_id);
 }
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#19 lore raw

PATCH v2 11/13 i3c: mipi-i3c-hci-pci: Allocate a structure for Intel controller information

In reply to Adrian Hunter

Allocate a structure for Intel controller information, in preparation additional changes that need to store Intel device-specific information.

---

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +10 -1
index b962d3c2d510..3f391b0854ae 100644
@@ -18,6 +18,7 @@ struct mipi_i3c_hci_pci {
 	struct pci_dev *pci;
 	struct platform_device *pdev;
 	const struct mipi_i3c_hci_pci_info *info;
+	void *private;
 };
 
 struct mipi_i3c_hci_pci_info {
@@ -34,6 +35,10 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 #define INTEL_RESETS_RESET_DONE		BIT(1)
 #define INTEL_RESETS_TIMEOUT_US		(10 * USEC_PER_MSEC)
 
+struct intel_host {
+	void __iomem	*priv;
+};
+
 static void intel_reset(void __iomem *priv)
 {
 	u32 reg;
@@ -55,13 +60,17 @@ static void __iomem *intel_priv(struct pci_dev *pci)
 
 static int intel_i3c_init(struct mipi_i3c_hci_pci *hci)
 {
+	struct intel_host *host = devm_kzalloc(&hci->pci->dev, sizeof(*host), GFP_KERNEL);
 	void __iomem *priv = intel_priv(hci->pci);
 
-	if (!priv)
+	if (!host || !priv)
 		return -ENOMEM;
 
 	dma_set_mask_and_coherent(&hci->pci->dev, DMA_BIT_MASK(64));
 
+	hci->private = host;
+	host->priv = priv;
+
 	intel_reset(priv);
 
 	return 0;
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#21 lore raw

PATCH v2 12/13 i3c: mipi-i3c-hci-pci: Add LTR support for Intel controllers

In reply to Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +125 -0
index 3f391b0854ae..2c827e877d29 100644
@@ -7,12 +7,15 @@
  * Author: Jarkko Nikula <[email protected]>
  */
 #include <linux/acpi.h>
+#include <linux/bitfield.h>
+#include <linux/debugfs.h>
 #include <linux/idr.h>
 #include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/pm_qos.h>
 
 struct mipi_i3c_hci_pci {
 	struct pci_dev *pci;
@@ -35,10 +38,122 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 #define INTEL_RESETS_RESET_DONE		BIT(1)
 #define INTEL_RESETS_TIMEOUT_US		(10 * USEC_PER_MSEC)
 
+#define INTEL_ACTIVELTR			0x0c
+#define INTEL_IDLELTR			0x10
+
+#define INTEL_LTR_REQ			BIT(15)
+#define INTEL_LTR_SCALE_MASK		GENMASK(11, 10)
+#define INTEL_LTR_SCALE_1US		FIELD_PREP(INTEL_LTR_SCALE_MASK, 2)
+#define INTEL_LTR_SCALE_32US		FIELD_PREP(INTEL_LTR_SCALE_MASK, 3)
+#define INTEL_LTR_VALUE_MASK		GENMASK(9, 0)
+
 struct intel_host {
 	void __iomem	*priv;
+	u32		active_ltr;
+	u32		idle_ltr;
+	struct dentry	*debugfs_root;
 };
 
+static void intel_cache_ltr(struct intel_host *host)
+{
+	host->active_ltr = readl(host->priv + INTEL_ACTIVELTR);
+	host->idle_ltr = readl(host->priv + INTEL_IDLELTR);
+}
+
+static void intel_ltr_set(struct device *dev, s32 val)
+{
+	struct mipi_i3c_hci_pci *hci = dev_get_drvdata(dev);
+	struct intel_host *host = hci->private;
+	u32 ltr;
+
+	/*
+	 * Program latency tolerance (LTR) accordingly what has been asked
+	 * by the PM QoS layer or disable it in case we were passed
+	 * negative value or PM_QOS_LATENCY_ANY.
+	 */
+	ltr = readl(host->priv + INTEL_ACTIVELTR);
+
+	if (val == PM_QOS_LATENCY_ANY || val < 0) {
+		ltr &= ~INTEL_LTR_REQ;
+	} else {
+		ltr |= INTEL_LTR_REQ;
+		ltr &= ~INTEL_LTR_SCALE_MASK;
+		ltr &= ~INTEL_LTR_VALUE_MASK;
+
+		if (val > INTEL_LTR_VALUE_MASK) {
+			val >>= 5;
+			if (val > INTEL_LTR_VALUE_MASK)
+				val = INTEL_LTR_VALUE_MASK;
+			ltr |= INTEL_LTR_SCALE_32US | val;
+		} else {
+			ltr |= INTEL_LTR_SCALE_1US | val;
+		}
+	}
+
+	if (ltr == host->active_ltr)
+		return;
+
+	writel(ltr, host->priv + INTEL_ACTIVELTR);
+	writel(ltr, host->priv + INTEL_IDLELTR);
+
+	/* Cache the values into intel_host structure */
+	intel_cache_ltr(host);
+}
+
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);
+	} else {
+		debugfs_remove(debugfs_root);
+		debugfs_root = NULL;
+	}
+
+	return debugfs_root;
+}
+
+static void intel_add_debugfs(struct mipi_i3c_hci_pci *hci)
+{
+	struct dentry *debugfs_root = intel_actualize_debugfs_root(true);
+	struct dentry *dir = debugfs_create_dir(dev_name(&hci->pci->dev), debugfs_root);
+	struct intel_host *host = hci->private;
+
+	intel_cache_ltr(host);
+
+	host->debugfs_root = dir;
+	debugfs_create_x32("active_ltr", 0444, dir, &host->active_ltr);
+	debugfs_create_x32("idle_ltr", 0444, dir, &host->idle_ltr);
+}
+
+static void intel_remove_debugfs(struct mipi_i3c_hci_pci *hci)
+{
+	struct intel_host *host = hci->private;
+
+	debugfs_remove_recursive(host->debugfs_root);
+	intel_actualize_debugfs_root(false);
+}
+
 static void intel_reset(void __iomem *priv)
 {
 	u32 reg;
@@ -73,11 +188,21 @@ static int intel_i3c_init(struct mipi_i3c_hci_pci *hci)
 
 	intel_reset(priv);
 
+	intel_ltr_expose(&hci->pci->dev);
+	intel_add_debugfs(hci);
+
 	return 0;
 }
 
+static void intel_exit(struct mipi_i3c_hci_pci *hci)
+{
+	intel_remove_debugfs(hci);
+	intel_ltr_hide(&hci->pci->dev);
+}
+
 static const struct mipi_i3c_hci_pci_info intel_info = {
 	.init = intel_i3c_init,
+	.exit = intel_exit,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#31 lore raw

PATCH v2 13/13 i3c: mipi-i3c-hci-pci: Set d3cold_delay to 0 for Intel controllers

In reply to Adrian Hunter

Set d3cold_delay to 0 for Intel controllers because a delay is not needed.

---

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -0
index 2c827e877d29..58e00301e5db 100644
@@ -183,6 +183,8 @@ static int intel_i3c_init(struct mipi_i3c_hci_pci *hci)
 
 	dma_set_mask_and_coherent(&hci->pci->dev, DMA_BIT_MASK(64));
 
+	hci->pci->d3cold_delay = 0;
+
 	hci->private = host;
 	host->priv = priv;
 
Signature · 7 lines
2.51.0


-- 
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#2 lore raw

Re: [PATCH V2 01/13] i3c: mipi-i3c-hci-pci: Set 64-bit DMA mask for Intel controllers

In reply to Adrian Hunter
Quoted 4 lines · Adrian Hunter

All Intel controllers support 64-bit DMA. Set the DMA mask accordingly.

This is needed only if there is no IOMMU configured, which is not recommended, but possible.

I think DMA mask is not related IOMMU at all, It indicates your DMA's address widith. So this sentence is reduntant and confused. Suggest remove it if no specific reason.

Frank

Quoted 34 lines

---

Changes in V2:

	No need to check error from dma_set_mask_and_coherent() with a
	64-bit mask
 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
index dd4484eff2f0..3cd15ca7d391 100644
@@ -36,6 +36,8 @@ static int mipi_i3c_hci_pci_intel_init(struct pci_dev *pci)
 	if (!priv)
 		return -ENOMEM;
 
+	dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64));
+
 	/* Assert reset, wait for completion and release reset */
 	writel(0, priv + INTEL_PRIV_RESETS);
 	timeout = jiffies + msecs_to_jiffies(10);
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer Reviewed-by on v2 3/13
#5 lore raw

Re: [PATCH V2 03/13] i3c: mipi-i3c-hci-pci: Rename some Intel-related identifiers

In reply to Adrian Hunter
Quoted 6 lines · Adrian Hunter

Rename some Intel-related identifiers to ensure Intel-related identifiers begin "intel_" or INTEL_, and for brevity removing purposeless "PRIV" in preparation to add more register definitions.

---

Quoted 66 lines

Changes in V2:

Rename 'intel_init' to 'intel_i3c_init'
More explanation in commit message

 .../i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +9 -10
index 3d854cee05df..d434e2962740 100644
@@ -21,11 +21,11 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 
 #define INTEL_PRIV_OFFSET		0x2b0
 #define INTEL_PRIV_SIZE			0x28
-#define INTEL_PRIV_RESETS		0x04
-#define INTEL_PRIV_RESETS_RESET		BIT(0)
-#define INTEL_PRIV_RESETS_RESET_DONE	BIT(1)
+#define INTEL_RESETS			0x04
+#define INTEL_RESETS_RESET		BIT(0)
+#define INTEL_RESETS_RESET_DONE		BIT(1)
 
-static int mipi_i3c_hci_pci_intel_init(struct pci_dev *pci)
+static int intel_i3c_init(struct pci_dev *pci)
 {
 	unsigned long timeout;
 	void __iomem *priv;
@@ -39,21 +39,21 @@ static int mipi_i3c_hci_pci_intel_init(struct pci_dev *pci)
 	dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64));
 
 	/* Assert reset, wait for completion and release reset */
-	writel(0, priv + INTEL_PRIV_RESETS);
+	writel(0, priv + INTEL_RESETS);
 	timeout = jiffies + msecs_to_jiffies(10);
-	while (!(readl(priv + INTEL_PRIV_RESETS) &
-		 INTEL_PRIV_RESETS_RESET_DONE)) {
+	while (!(readl(priv + INTEL_RESETS) &
+		 INTEL_RESETS_RESET_DONE)) {
 		if (time_after(jiffies, timeout))
 			break;
 		cpu_relax();
 	}
-	writel(INTEL_PRIV_RESETS_RESET, priv + INTEL_PRIV_RESETS);
+	writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
 
 	return 0;
 }
 
 static struct mipi_i3c_hci_pci_info intel_info = {
-	.init = mipi_i3c_hci_pci_intel_init,
+	.init = intel_i3c_init,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer Reviewed-by on v2 4/13
#7 lore raw

Re: [PATCH V2 04/13] i3c: mipi-i3c-hci-pci: Use readl_poll_timeout()

In reply to Adrian Hunter
Quoted 4 lines · Adrian Hunter

Use readl_poll_timeout() instead of open-coding the polling loop.

---

Quoted 61 lines

Changes in V2:

	Change 10000 to (10 * USEC_PER_MSEC)
 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +6 -9
index d434e2962740..30915d78045e 100644
@@ -8,6 +8,7 @@
  */
 #include <linux/acpi.h>
 #include <linux/idr.h>
+#include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -24,11 +25,12 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 #define INTEL_RESETS			0x04
 #define INTEL_RESETS_RESET		BIT(0)
 #define INTEL_RESETS_RESET_DONE		BIT(1)
+#define INTEL_RESETS_TIMEOUT_US		(10 * USEC_PER_MSEC)
 
 static int intel_i3c_init(struct pci_dev *pci)
 {
-	unsigned long timeout;
 	void __iomem *priv;
+	u32 reg;
 
 	priv = devm_ioremap(&pci->dev,
 			    pci_resource_start(pci, 0) + INTEL_PRIV_OFFSET,
@@ -40,13 +42,9 @@ static int intel_i3c_init(struct pci_dev *pci)
 
 	/* Assert reset, wait for completion and release reset */
 	writel(0, priv + INTEL_RESETS);
-	timeout = jiffies + msecs_to_jiffies(10);
-	while (!(readl(priv + INTEL_RESETS) &
-		 INTEL_RESETS_RESET_DONE)) {
-		if (time_after(jiffies, timeout))
-			break;
-		cpu_relax();
-	}
+	readl_poll_timeout(priv + INTEL_RESETS, reg,
+			   reg & INTEL_RESETS_RESET_DONE, 0,
+			   INTEL_RESETS_TIMEOUT_US);
 	writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
 
 	return 0;
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer Reviewed-by on v2 7/13
#11 lore raw

Re: [PATCH V2 07/13] i3c: mipi-i3c-hci-pci: Factor out intel_reset()

In reply to Adrian Hunter
Quoted 4 lines · Adrian Hunter

For neatness, factor out intel_reset().

---

Quoted 62 lines

Changes in V2:

Move location of intel_reset() to get a prettier diff

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 20 ++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +13 -8
index 1e1f2c42bd74..b9794212b2fb 100644
@@ -27,6 +27,18 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 #define INTEL_RESETS_RESET_DONE		BIT(1)
 #define INTEL_RESETS_TIMEOUT_US		(10 * USEC_PER_MSEC)
 
+static void intel_reset(void __iomem *priv)
+{
+	u32 reg;
+
+	/* Assert reset, wait for completion and release reset */
+	writel(0, priv + INTEL_RESETS);
+	readl_poll_timeout(priv + INTEL_RESETS, reg,
+			   reg & INTEL_RESETS_RESET_DONE, 0,
+			   INTEL_RESETS_TIMEOUT_US);
+	writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
+}
+
 static void __iomem *intel_priv(struct pci_dev *pci)
 {
 	resource_size_t base = pci_resource_start(pci, 0);
@@ -37,19 +49,13 @@ static void __iomem *intel_priv(struct pci_dev *pci)
 static int intel_i3c_init(struct pci_dev *pci)
 {
 	void __iomem *priv = intel_priv(pci);
-	u32 reg;
 
 	if (!priv)
 		return -ENOMEM;
 
 	dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64));
 
-	/* Assert reset, wait for completion and release reset */
-	writel(0, priv + INTEL_RESETS);
-	readl_poll_timeout(priv + INTEL_RESETS, reg,
-			   reg & INTEL_RESETS_RESET_DONE, 0,
-			   INTEL_RESETS_TIMEOUT_US);
-	writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
+	intel_reset(priv);
 
 	return 0;
 }
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#14 lore raw

Re: [PATCH V2 09/13] i3c: mipi-i3c-hci-pci: Change callback parameter

In reply to Adrian Hunter
Quoted 2 lines · Adrian Hunter

Change ->init() callback parameter from a pointer to the PCI device to a pointer to the locally defined mipi_i3c_hci_pci_info device information.

from PCI device pointer to mipi_i3c_hci_pci_info device pointer.

Quoted 2 lines

This is in preparation for consistency when adding more callbacks that will need struct mipi_i3c_hci_pci_info.

Prepare to add more callbacks in mipi_i3c_hci_pci_info.

Quoted 75 lines

---

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +8 -6
index 8936e50eddf7..7bfb9fe337b6 100644
@@ -15,11 +15,12 @@
 #include <linux/platform_device.h>
 
 struct mipi_i3c_hci_pci {
+	struct pci_dev *pci;
 	struct platform_device *pdev;
 };
 
 struct mipi_i3c_hci_pci_info {
-	int (*init)(struct pci_dev *pci);
+	int (*init)(struct mipi_i3c_hci_pci *hci);
 };
 
 static DEFINE_IDA(mipi_i3c_hci_pci_ida);
@@ -50,14 +51,14 @@ static void __iomem *intel_priv(struct pci_dev *pci)
 	return devm_ioremap(&pci->dev, base + INTEL_PRIV_OFFSET, INTEL_PRIV_SIZE);
 }
 
-static int intel_i3c_init(struct pci_dev *pci)
+static int intel_i3c_init(struct mipi_i3c_hci_pci *hci)
 {
-	void __iomem *priv = intel_priv(pci);
+	void __iomem *priv = intel_priv(hci->pci);
 
 	if (!priv)
 		return -ENOMEM;
 
-	dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64));
+	dma_set_mask_and_coherent(&hci->pci->dev, DMA_BIT_MASK(64));
 
 	intel_reset(priv);
 
@@ -80,6 +81,8 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (!hci)
 		return -ENOMEM;
 
+	hci->pci = pci;
+
 	ret = pcim_enable_device(pci);
 	if (ret)
 		return ret;
@@ -113,7 +116,7 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 
 	info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
 	if (info && info->init) {
-		ret = info->init(pci);
+		ret = info->init(hci);
 		if (ret)
 			goto err;
 	}
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#16 lore raw

Re: [PATCH V2 10/13] i3c: mipi-i3c-hci-pci: Add exit callback

In reply to Adrian Hunter
Quoted 3 lines · Adrian Hunter

Add ->exit() callback as a counterpart to ->init(). This is in preparation for adding device-specific features that require cleanup upon driver removal.

Prepare to add device-specific features ...

Quoted 39 lines

---

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
index 7bfb9fe337b6..b962d3c2d510 100644
@@ -17,10 +17,12 @@
 struct mipi_i3c_hci_pci {
 	struct pci_dev *pci;
 	struct platform_device *pdev;
+	const struct mipi_i3c_hci_pci_info *info;
 };
 
 struct mipi_i3c_hci_pci_info {
 	int (*init)(struct mipi_i3c_hci_pci *hci);
+	void (*exit)(struct mipi_i3c_hci_pci *hci);
 };
 
 static DEFINE_IDA(mipi_i3c_hci_pci_ida);
@@ -72,7 +74,6 @@ static const struct mipi_i3c_hci_pci_info intel_info = {
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 				  const struct pci_device_id *id)
 {
-	const struct mipi_i3c_hci_pci_info *info;
 	struct mipi_i3c_hci_pci *hci;
 	struct resource res[2];
 	int dev_id, ret;

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c static int mipi_i3c_hci_pci_probe(struct pci_dev *pci, · line 120

Quoted 9 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +3 -3
@@ -114,9 +115,9 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (ret)
 		goto err;
 
-	info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
-	if (info && info->init) {
-		ret = info->init(hci);
+	hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
+	if (hci->info && hci->info->init) {
+		ret = hci->info->init(hci);

This part's change does not belong to this patch.

Frank

Quoted 21 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +3 -1
 		if (ret)
 			goto err;
 	}
@@ -141,6 +142,9 @@ static void mipi_i3c_hci_pci_remove(struct pci_dev *pci)
 	struct platform_device *pdev = hci->pdev;
 	int dev_id = pdev->id;
 
+	if (hci->info && hci->info->exit)
+		hci->info->exit(hci);
+
 	platform_device_unregister(pdev);
 	ida_free(&mipi_i3c_hci_pci_ida, dev_id);
 }
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#17 lore raw

Re: [PATCH V2 10/13] i3c: mipi-i3c-hci-pci: Add exit callback

Quoted 49 lines · Frank Li
Quoted 3 lines · Adrian Hunter

Add ->exit() callback as a counterpart to ->init(). This is in preparation for adding device-specific features that require cleanup upon driver removal.

Prepare to add device-specific features ...

Quoted 42 lines

---

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
index 7bfb9fe337b6..b962d3c2d510 100644
@@ -17,10 +17,12 @@
 struct mipi_i3c_hci_pci {
 	struct pci_dev *pci;
 	struct platform_device *pdev;
+	const struct mipi_i3c_hci_pci_info *info;
 };
 
 struct mipi_i3c_hci_pci_info {
 	int (*init)(struct mipi_i3c_hci_pci *hci);
+	void (*exit)(struct mipi_i3c_hci_pci *hci);
 };
 
 static DEFINE_IDA(mipi_i3c_hci_pci_ida);
@@ -72,7 +74,6 @@ static const struct mipi_i3c_hci_pci_info intel_info = {
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 				  const struct pci_device_id *id)
 {
-	const struct mipi_i3c_hci_pci_info *info;
 	struct mipi_i3c_hci_pci *hci;
 	struct resource res[2];
 	int dev_id, ret;
@@ -114,9 +115,9 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (ret)
 		goto err;
 
Quoted 8 lines

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c static int mipi_i3c_hci_pci_probe(struct pci_dev *pci, · line 120

Quoted 6 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +3 -3
-	info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
-	if (info && info->init) {
-		ret = info->init(hci);
+	hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
+	if (hci->info && hci->info->init) {
+		ret = hci->info->init(hci);

This part's change does not belong to this patch.

hci->info is used in mipi_i3c_hci_pci_remove(). It has to be assigned.

Quoted 24 lines

Frank

Quoted 21 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +3 -1
 		if (ret)
 			goto err;
 	}
@@ -141,6 +142,9 @@ static void mipi_i3c_hci_pci_remove(struct pci_dev *pci)
 	struct platform_device *pdev = hci->pdev;
 	int dev_id = pdev->id;
 
+	if (hci->info && hci->info->exit)
+		hci->info->exit(hci);
+
 	platform_device_unregister(pdev);
 	ida_free(&mipi_i3c_hci_pci_ida, dev_id);
 }
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#22 lore raw
In reply to Adrian Hunter
Quoted 18 lines · Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)

...

Quoted 15 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +15 -0
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c static DEFINE_IDA(mipi_i3c_hci_pci_ida); · line 127

Quoted 10 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +10 -0
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);

I think it'd better to create common "i3c" debugfs root. So your device use debugfs_create_dir(dev_name(&hci->pci->dev), ...) under this common root.

Frank

...

Quoted 15 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
+
 static const struct mipi_i3c_hci_pci_info intel_info = {
 	.init = intel_i3c_init,
+	.exit = intel_exit,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer Reviewed-by on v2 13/13
#32 lore raw

Re: [PATCH V2 13/13] i3c: mipi-i3c-hci-pci: Set d3cold_delay to 0 for Intel controllers

In reply to Adrian Hunter
Quoted 4 lines · Adrian Hunter

Set d3cold_delay to 0 for Intel controllers because a delay is not needed.

---

Quoted 31 lines

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
index 2c827e877d29..58e00301e5db 100644
@@ -183,6 +183,8 @@ static int intel_i3c_init(struct mipi_i3c_hci_pci *hci)
 
 	dma_set_mask_and_coherent(&hci->pci->dev, DMA_BIT_MASK(64));
 
+	hci->pci->d3cold_delay = 0;
+
 	hci->private = host;
 	host->priv = priv;
 
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#20 lore raw

Re: [PATCH V2 11/13] i3c: mipi-i3c-hci-pci: Allocate a structure for Intel controller information

In reply to Adrian Hunter
Quoted 5 lines · Adrian Hunter

Allocate a structure for Intel controller information, in preparation additional changes that need to store Intel device-specific information.

---

I think this patch help less, you can direct squash to next one.

Frank

Quoted 60 lines

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +10 -2
index b962d3c2d510..3f391b0854ae 100644
@@ -18,6 +18,7 @@ struct mipi_i3c_hci_pci {
 	struct pci_dev *pci;
 	struct platform_device *pdev;
 	const struct mipi_i3c_hci_pci_info *info;
+	void *private;
 };
 
 struct mipi_i3c_hci_pci_info {
@@ -34,6 +35,10 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
 #define INTEL_RESETS_RESET_DONE		BIT(1)
 #define INTEL_RESETS_TIMEOUT_US		(10 * USEC_PER_MSEC)
 
+struct intel_host {
+	void __iomem	*priv;
+};
+
 static void intel_reset(void __iomem *priv)
 {
 	u32 reg;
@@ -55,13 +60,17 @@ static void __iomem *intel_priv(struct pci_dev *pci)
 
 static int intel_i3c_init(struct mipi_i3c_hci_pci *hci)
 {
+	struct intel_host *host = devm_kzalloc(&hci->pci->dev, sizeof(*host), GFP_KERNEL);
 	void __iomem *priv = intel_priv(hci->pci);
 
-	if (!priv)
+	if (!host || !priv)
 		return -ENOMEM;
 
 	dma_set_mask_and_coherent(&hci->pci->dev, DMA_BIT_MASK(64));
 
+	hci->private = host;
+	host->priv = priv;
+
 	intel_reset(priv);
 
 	return 0;
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#23 lore raw
In reply to Frank Li
Quoted 41 lines · Frank Li
Quoted 18 lines · Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)

...

Quoted 21 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +21 -0
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
Quoted 8 lines

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c static DEFINE_IDA(mipi_i3c_hci_pci_ida); · line 127

Quoted 4 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +4 -0
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);

I think it'd better to create common "i3c" debugfs root. So your device use debugfs_create_dir(dev_name(&hci->pci->dev), ...) under this common root.

The debugfs files are being created for the PCI device to contain PCI LTR information. The i3c module has nothing to do with that.

Also, currently, there is no module dependency between this PCI driver and i3c, but a dependency would be necessary to coordinate the creation and deletion of an 'i3c' debugfs directory.

The extra complexity can't be justified.

Quoted 18 lines

...

Quoted 15 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
+
 static const struct mipi_i3c_hci_pci_info intel_info = {
 	.init = intel_i3c_init,
+	.exit = intel_exit,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
--

2.51.0

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#18 lore raw

Re: [PATCH V2 10/13] i3c: mipi-i3c-hci-pci: Add exit callback

In reply to Adrian Hunter
Quoted 59 lines · Adrian Hunter
Quoted 49 lines · Frank Li
Quoted 3 lines · Adrian Hunter

Add ->exit() callback as a counterpart to ->init(). This is in preparation for adding device-specific features that require cleanup upon driver removal.

Prepare to add device-specific features ...

Quoted 42 lines

---

Changes in V2:

Re-based

 drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
index 7bfb9fe337b6..b962d3c2d510 100644
@@ -17,10 +17,12 @@
 struct mipi_i3c_hci_pci {
 	struct pci_dev *pci;
 	struct platform_device *pdev;
+	const struct mipi_i3c_hci_pci_info *info;
 };
 
 struct mipi_i3c_hci_pci_info {
 	int (*init)(struct mipi_i3c_hci_pci *hci);
+	void (*exit)(struct mipi_i3c_hci_pci *hci);
 };
 
 static DEFINE_IDA(mipi_i3c_hci_pci_ida);
@@ -72,7 +74,6 @@ static const struct mipi_i3c_hci_pci_info intel_info = {
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 				  const struct pci_device_id *id)
 {
-	const struct mipi_i3c_hci_pci_info *info;
 	struct mipi_i3c_hci_pci *hci;
 	struct resource res[2];
 	int dev_id, ret;
@@ -114,9 +115,9 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 	if (ret)
 		goto err;
 
Quoted 8 lines

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c static int mipi_i3c_hci_pci_probe(struct pci_dev *pci, · line 120

Quoted 6 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +3 -3
-	info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
-	if (info && info->init) {
-		ret = info->init(hci);
+	hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
+	if (hci->info && hci->info->init) {
+		ret = hci->info->init(hci);

This part's change does not belong to this patch.

Quoted 1 line

hci->info is used in mipi_i3c_hci_pci_remove(). It has to be assigned.

Okay!

Frank

Quoted 31 lines
Quoted 21 lines

Frank

Quoted 17 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +3 -1
 		if (ret)
 			goto err;
 	}
@@ -141,6 +142,9 @@ static void mipi_i3c_hci_pci_remove(struct pci_dev *pci)
 	struct platform_device *pdev = hci->pdev;
 	int dev_id = pdev->id;
 
+	if (hci->info && hci->info->exit)
+		hci->info->exit(hci);
+
 	platform_device_unregister(pdev);
 	ida_free(&mipi_i3c_hci_pci_ida, dev_id);
 }
--

2.51.0

Quoted 4 lines
Quoted 4 lines

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#24 lore raw
In reply to Adrian Hunter
Quoted 51 lines · Adrian Hunter
Quoted 41 lines · Frank Li
Quoted 18 lines · Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)

...

Quoted 21 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +21 -0
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
Quoted 8 lines

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c static DEFINE_IDA(mipi_i3c_hci_pci_ida); · line 127

Quoted 4 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +4 -0
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);

I think it'd better to create common "i3c" debugfs root. So your device use debugfs_create_dir(dev_name(&hci->pci->dev), ...) under this common root.

Quoted 8 lines

The debugfs files are being created for the PCI device to contain PCI LTR information. The i3c module has nothing to do with that.

Also, currently, there is no module dependency between this PCI driver and i3c, but a dependency would be necessary to coordinate the creation and deletion of an 'i3c' debugfs directory.

The extra complexity can't be justified.

Don't post new versin before we close open discussion. I see your post patch before this message.

So, I think not necessary to create to root, which cause complex, (need lock, and refer counter).

Frank

Quoted 25 lines
Quoted 15 lines

...

Quoted 11 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
+
 static const struct mipi_i3c_hci_pci_info intel_info = {
 	.init = intel_i3c_init,
+	.exit = intel_exit,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
--

2.51.0

Quoted 4 lines
Quoted 4 lines

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#25 lore raw
Quoted 55 lines · Frank Li
Quoted 54 lines · Adrian Hunter
Quoted 41 lines · Frank Li
Quoted 18 lines · Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)

...

Quoted 21 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +21 -0
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
Quoted 8 lines

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c static DEFINE_IDA(mipi_i3c_hci_pci_ida); · line 127

Quoted 4 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +4 -0
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);

I think it'd better to create common "i3c" debugfs root. So your device use debugfs_create_dir(dev_name(&hci->pci->dev), ...) under this common root.

The debugfs files are being created for the PCI device to contain PCI LTR information. The i3c module has nothing to do with that.

Quoted 8 lines
Quoted 5 lines

Also, currently, there is no module dependency between this PCI driver and i3c, but a dependency would be necessary to coordinate the creation and deletion of an 'i3c' debugfs directory.

The extra complexity can't be justified.

Don't post new versin before we close open discussion. I see your post patch before this message.

Sorry, but it is late in the release cycle, and it saves time when we are in different time zones.

Quoted 3 lines

So, I think not necessary to create to root, which cause complex, (need lock, and refer counter).

So you are OK with V3?

Quoted 28 lines

Frank

Quoted 25 lines
Quoted 15 lines

...

Quoted 11 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
+
 static const struct mipi_i3c_hci_pci_info intel_info = {
 	.init = intel_i3c_init,
+	.exit = intel_exit,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
--

2.51.0

Quoted 4 lines
Quoted 4 lines

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#26 lore raw
Quoted 65 lines · Adrian Hunter
Quoted 55 lines · Frank Li
Quoted 54 lines · Adrian Hunter
Quoted 41 lines · Frank Li
Quoted 18 lines · Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)

...

Quoted 21 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +21 -0
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
Quoted 8 lines

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c static DEFINE_IDA(mipi_i3c_hci_pci_ida); · line 127

Quoted 4 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +4 -0
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);

I think it'd better to create common "i3c" debugfs root. So your device use debugfs_create_dir(dev_name(&hci->pci->dev), ...) under this common root.

The debugfs files are being created for the PCI device to contain PCI LTR information. The i3c module has nothing to do with that.

Quoted 8 lines
Quoted 5 lines

Also, currently, there is no module dependency between this PCI driver and i3c, but a dependency would be necessary to coordinate the creation and deletion of an 'i3c' debugfs directory.

The extra complexity can't be justified.

Don't post new versin before we close open discussion. I see your post patch before this message.

Quoted 8 lines

Sorry, but it is late in the release cycle, and it saves time when we are in different time zones.

Quoted 3 lines

So, I think not necessary to create to root, which cause complex, (need lock, and refer counter).

So you are OK with V3?

In v3, still create "intel_i3c" root dir, how about direct create dev under root

	debugfs_create_dir(dev_name(&hci->pci->dev), NULL);

to reduce unneccesary complex, (like mutex lock and ref counter).

Frank

Quoted 35 lines
Quoted 29 lines

Frank

Quoted 25 lines
Quoted 15 lines

...

Quoted 11 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
+
 static const struct mipi_i3c_hci_pci_info intel_info = {
 	.init = intel_i3c_init,
+	.exit = intel_exit,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
--

2.51.0

Quoted 4 lines
Quoted 4 lines

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#27 lore raw
Quoted 73 lines · Frank Li
Quoted 72 lines · Adrian Hunter
Quoted 55 lines · Frank Li
Quoted 54 lines · Adrian Hunter
Quoted 41 lines · Frank Li
Quoted 18 lines · Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)

...

Quoted 21 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +21 -0
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
Quoted 8 lines

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c static DEFINE_IDA(mipi_i3c_hci_pci_ida); · line 127

Quoted 4 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +4 -0
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);

I think it'd better to create common "i3c" debugfs root. So your device use debugfs_create_dir(dev_name(&hci->pci->dev), ...) under this common root.

The debugfs files are being created for the PCI device to contain PCI LTR information. The i3c module has nothing to do with that.

Quoted 8 lines
Quoted 5 lines

Also, currently, there is no module dependency between this PCI driver and i3c, but a dependency would be necessary to coordinate the creation and deletion of an 'i3c' debugfs directory.

The extra complexity can't be justified.

Don't post new versin before we close open discussion. I see your post patch before this message.

Sorry, but it is late in the release cycle, and it saves time when we are in different time zones.

Quoted 3 lines

So, I think not necessary to create to root, which cause complex, (need lock, and refer counter).

Quoted 8 lines
Quoted 1 line

So you are OK with V3?

In v3, still create "intel_i3c" root dir, how about direct create dev under root

	debugfs_create_dir(dev_name(&hci->pci->dev), NULL);

to reduce unneccesary complex, (like mutex lock and ref counter).

Could do. I added intel_i3c to match intel_lpss which is also PCI devices with LTR e.g.

# tree /sys/kernel/debug/intel_lpss
/sys/kernel/debug/intel_lpss
|-- 0000:00:19.0
|   |-- active_ltr
|   |-- capabilities
|   `-- idle_ltr
`-- 0000:00:19.1
    |-- active_ltr
    |-- capabilities
    `-- idle_ltr

3 directories, 6 files

# tree /sys/kernel/debug/intel_i3c
/sys/kernel/debug/intel_i3c
|-- 0000:00:11.0
|   |-- active_ltr
|   `-- idle_ltr
`-- 0000:00:11.1
    |-- active_ltr
    `-- idle_ltr

3 directories, 4 files
#

Quoted 38 lines

Frank

Quoted 35 lines
Quoted 29 lines

Frank

Quoted 25 lines
Quoted 15 lines

...

Quoted 11 lines
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +2 -1
+
 static const struct mipi_i3c_hci_pci_info intel_info = {
 	.init = intel_i3c_init,
+	.exit = intel_exit,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
--

2.51.0

Quoted 4 lines
Quoted 4 lines

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#28 lore raw
Quoted 79 lines · Adrian Hunter
Quoted 78 lines · Frank Li
Quoted 65 lines · Adrian Hunter
Quoted 55 lines · Frank Li
Quoted 54 lines · Adrian Hunter
Quoted 41 lines · Frank Li
Quoted 18 lines · Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)

...

Quoted 21 lines
(quoted diff) +21 -0
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);

I think it'd better to create common "i3c" debugfs root. So your device use debugfs_create_dir(dev_name(&hci->pci->dev), ...) under this common root.

The debugfs files are being created for the PCI device to contain PCI LTR information. The i3c module has nothing to do with that.

Quoted 8 lines
Quoted 5 lines

Also, currently, there is no module dependency between this PCI driver and i3c, but a dependency would be necessary to coordinate the creation and deletion of an 'i3c' debugfs directory.

The extra complexity can't be justified.

Don't post new versin before we close open discussion. I see your post patch before this message.

Quoted 8 lines

Sorry, but it is late in the release cycle, and it saves time when we are in different time zones.

Quoted 3 lines

So, I think not necessary to create to root, which cause complex, (need lock, and refer counter).

So you are OK with V3?

In v3, still create "intel_i3c" root dir, how about direct create dev under root

Quoted 6 lines
Quoted 3 lines
	debugfs_create_dir(dev_name(&hci->pci->dev), NULL);

to reduce unneccesary complex, (like mutex lock and ref counter).

Could do. I added intel_i3c to match intel_lpss which is also PCI devices with LTR e.g.

You can use similar method to create root at module_init.

static int __init intel_lpss_init(void)

{
        intel_lpss_debugfs = debugfs_create_dir("intel_lpss", NULL);
        return 0;
}

module_init(intel_lpss_init);

Frank

Quoted 70 lines
# tree /sys/kernel/debug/intel_lpss
/sys/kernel/debug/intel_lpss
|-- 0000:00:19.0
|   |-- active_ltr
|   |-- capabilities
|   `-- idle_ltr
`-- 0000:00:19.1
    |-- active_ltr
    |-- capabilities
    `-- idle_ltr

3 directories, 6 files

# tree /sys/kernel/debug/intel_i3c
/sys/kernel/debug/intel_i3c
|-- 0000:00:11.0
|   |-- active_ltr
|   `-- idle_ltr
`-- 0000:00:11.1
    |-- active_ltr
    `-- idle_ltr

3 directories, 4 files
#

Quoted 38 lines

Frank

Quoted 35 lines
Quoted 29 lines

Frank

Quoted 25 lines
Quoted 15 lines

...

Quoted 11 lines
(quoted diff) +2 -1
+
 static const struct mipi_i3c_hci_pci_info intel_info = {
 	.init = intel_i3c_init,
+	.exit = intel_exit,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
--

2.51.0

Quoted 4 lines
Quoted 4 lines

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
#29 lore raw
Quoted 87 lines · Frank Li
Quoted 79 lines · Adrian Hunter
Quoted 78 lines · Frank Li
Quoted 65 lines · Adrian Hunter
Quoted 55 lines · Frank Li
Quoted 54 lines · Adrian Hunter
Quoted 41 lines · Frank Li
Quoted 18 lines · Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)

...

Quoted 21 lines
(quoted diff) +21 -0
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);

I think it'd better to create common "i3c" debugfs root. So your device use debugfs_create_dir(dev_name(&hci->pci->dev), ...) under this common root.

The debugfs files are being created for the PCI device to contain PCI LTR information. The i3c module has nothing to do with that.

Quoted 8 lines
Quoted 5 lines

Also, currently, there is no module dependency between this PCI driver and i3c, but a dependency would be necessary to coordinate the creation and deletion of an 'i3c' debugfs directory.

The extra complexity can't be justified.

Don't post new versin before we close open discussion. I see your post patch before this message.

Quoted 8 lines

Sorry, but it is late in the release cycle, and it saves time when we are in different time zones.

Quoted 3 lines

So, I think not necessary to create to root, which cause complex, (need lock, and refer counter).

So you are OK with V3?

In v3, still create "intel_i3c" root dir, how about direct create dev under root

Quoted 6 lines
Quoted 3 lines
	debugfs_create_dir(dev_name(&hci->pci->dev), NULL);

to reduce unneccesary complex, (like mutex lock and ref counter).

Could do. I added intel_i3c to match intel_lpss which is also PCI devices with LTR e.g.

Quoted 8 lines

You can use similar method to create root at module_init.

static int __init intel_lpss_init(void)

{
        intel_lpss_debugfs = debugfs_create_dir("intel_lpss", NULL);
        return 0;
}

module_init(intel_lpss_init);

mipi-i3c-hci-pci is not an Intel driver. It can be used for any PCI device that supports MIPI I3C.

At module init, the driver does not know whether there are any Intel PCI devices, so it does not know whether to create "intel_i3c". Nor does it know whether other (non-Intel) devices need debugfs.

It would be preferable to use either the current approach, or as you already suggested debugfs_create_dir(dev_name(&hci->pci->dev), NULL)

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
reviewer
#30 lore raw
Quoted 100 lines · Adrian Hunter
Quoted 87 lines · Frank Li
Quoted 79 lines · Adrian Hunter
Quoted 78 lines · Frank Li
Quoted 65 lines · Adrian Hunter
Quoted 55 lines · Frank Li
Quoted 54 lines · Adrian Hunter
Quoted 41 lines · Frank Li
Quoted 18 lines · Adrian Hunter

Add support for Latency Tolerance Reporting (LTR) for Intel controllers.

Implement PM ->set_latency_tolerance() callback to set LTR register values. Also expose LTR register values via debugfs.

---

Changes in V2:

Make use of FIELD_PREP()
Improve handling of values that exceed the maximum

 .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c    | 125 ++++++++++++++++++
 1 file changed, 125 insertions(+)

...

Quoted 21 lines
(quoted diff) +21 -0
+static void intel_ltr_expose(struct device *dev)
+{
+	dev->power.set_latency_tolerance = intel_ltr_set;
+	dev_pm_qos_expose_latency_tolerance(dev);
+}
+
+static void intel_ltr_hide(struct device *dev)
+{
+	dev_pm_qos_hide_latency_tolerance(dev);
+	dev->power.set_latency_tolerance = NULL;
+}
+
+static struct dentry *intel_actualize_debugfs_root(bool add)
+{
+	static struct dentry *debugfs_root;
+	static DEFINE_MUTEX(lock);
+	static int ref_cnt;
+
+	guard(mutex)(&lock);
+
+	ref_cnt += add ? 1 : -1;
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+
+	if (ref_cnt) {
+		if (IS_ERR_OR_NULL(debugfs_root))
+			debugfs_root = debugfs_create_dir("intel_i3c", NULL);

I think it'd better to create common "i3c" debugfs root. So your device use debugfs_create_dir(dev_name(&hci->pci->dev), ...) under this common root.

The debugfs files are being created for the PCI device to contain PCI LTR information. The i3c module has nothing to do with that.

Quoted 8 lines
Quoted 5 lines

Also, currently, there is no module dependency between this PCI driver and i3c, but a dependency would be necessary to coordinate the creation and deletion of an 'i3c' debugfs directory.

The extra complexity can't be justified.

Don't post new versin before we close open discussion. I see your post patch before this message.

Quoted 8 lines

Sorry, but it is late in the release cycle, and it saves time when we are in different time zones.

Quoted 3 lines

So, I think not necessary to create to root, which cause complex, (need lock, and refer counter).

So you are OK with V3?

In v3, still create "intel_i3c" root dir, how about direct create dev under root

Quoted 6 lines
Quoted 3 lines
	debugfs_create_dir(dev_name(&hci->pci->dev), NULL);

to reduce unneccesary complex, (like mutex lock and ref counter).

Could do. I added intel_i3c to match intel_lpss which is also PCI devices with LTR e.g.

Quoted 8 lines

You can use similar method to create root at module_init.

static int __init intel_lpss_init(void)

{
        intel_lpss_debugfs = debugfs_create_dir("intel_lpss", NULL);
        return 0;
}

module_init(intel_lpss_init);

mipi-i3c-hci-pci is not an Intel driver. It can be used for any PCI device that supports MIPI I3C.

Quoted 6 lines

At module init, the driver does not know whether there are any Intel PCI devices, so it does not know whether to create "intel_i3c". Nor does it know whether other (non-Intel) devices need debugfs.

It would be preferable to use either the current approach, or as you already suggested debugfs_create_dir(dev_name(&hci->pci->dev), NULL)

Okay use Debugfs_create_dir(dev_name(&hci->pci->dev), NULL).

Frank

Quoted 6 lines

--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c

Signature · 3 lines
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c