[PATCH V3 11/12] i3c: mipi-i3c-hci-pci: Add LTR support for Intel controllers

Frank Li Frank.li at nxp.com
Mon Nov 17 07:44:47 PST 2025


On Mon, Nov 17, 2025 at 03:16:07PM +0200, Adrian Hunter wrote:
> 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.
>
> Signed-off-by: Adrian Hunter <adrian.hunter at intel.com>
> ---
>
>
...
> +
> +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);

You may omit pervious my review comments.

I suggest create common i3c debugfs root at common master.c.

like drivers/dma/dmaengine.c:static void __init dmaengine_debugfs_init(void)

so you use similar API

drivers/dma/dmaengine.h:dmaengine_get_debugfs_root(struct dma_device *dma_dev)

to get root at your intel_add_debugfs().

Frank

> +	} 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;
> @@ -55,20 +175,34 @@ 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);
>
> +	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,
> --
> 2.51.0
>
>
> --
> linux-i3c mailing list
> linux-i3c at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c



More information about the linux-i3c mailing list