Re: [PATCH v7 9/9] PCI/TSM: Report active IDE streams

Jonathan Cameron
2025-10-29T16:34:42Z

On Thu, 23 Oct 2025 19:04:18 -0700
Dan Williams <dan.j.williams@intel.com> wrote:

> Given that the platform TSM owns IDE Stream ID allocation, report the
> active streams via the TSM class device. Establish a symlink from the
> class device to the PCI endpoint device consuming the stream, named by
> the Stream ID.
>
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Couple of trivial things noticed whilst refreshing my memory.

> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---

> diff --git a/drivers/virt/coco/tsm-core.c b/drivers/virt/coco/tsm-core.c
> index 4499803cf20d..c0dae531b64f 100644
> --- a/drivers/virt/coco/tsm-core.c
> +++ b/drivers/virt/coco/tsm-core.c
> @@ -2,14 +2,17 @@
> /* Copyright(c) 2024 Intel Corporation. All rights reserved. */
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +#define dev_fmt(fmt) KBUILD_MODNAME ": " fmt

Why is this dev_fmt() in this patch (which doesn't seem to introduce
anything that would use it)?

>
> #include <linux/tsm.h>
> #include <linux/idr.h>
> +#include <linux/pci.h>
> #include <linux/rwsem.h>
> #include <linux/device.h>
> #include <linux/module.h>
> #include <linux/cleanup.h>
> #include <linux/pci-tsm.h>
> +#include <linux/pci-ide.h>
>
> static struct class *tsm_class;
> static DECLARE_RWSEM(tsm_rwsem);
> @@ -106,6 +109,32 @@ void tsm_unregister(struct tsm_dev *tsm_dev)
> }
> EXPORT_SYMBOL_GPL(tsm_unregister);
>
> +/* must be invoked between tsm_register / tsm_unregister */
> +int tsm_ide_stream_register(struct pci_ide *ide)
> +{
> + struct pci_dev *pdev = ide->pdev;
> + struct pci_tsm *tsm = pdev->tsm;
> + struct tsm_dev *tsm_dev = tsm->tsm_dev;
> + int rc;
> +
> + rc = sysfs_create_link(&tsm_dev->dev.kobj, &pdev->dev.kobj, ide->name);
> + if (rc)
> + return rc;
> +
> + ide->tsm_dev = tsm_dev;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(tsm_ide_stream_register);
> +
> +void tsm_ide_stream_unregister(struct pci_ide *ide)
> +{
> + struct tsm_dev *tsm_dev = ide->tsm_dev;
> +
> + sysfs_remove_link(&tsm_dev->dev.kobj, ide->name);
> + ide->tsm_dev = NULL;

Trivial preference for reverse order of register. That means
setting this NULL before removing the link.

> +}
> +EXPORT_SYMBOL_GPL(tsm_ide_stream_unregister);
> +
> static void tsm_release(struct device *dev)
> {
> struct tsm_dev *tsm_dev = container_of(dev, typeof(*tsm_dev), dev);