Re: [PATCH 2/5] platform/x86/intel: Move intel_pmt from MFD to Auxiliary Bus

From: Leon Romanovsky
Date: Wed Oct 06 2021 - 04:59:07 EST


On Thu, Sep 30, 2021 at 06:28:12PM -0700, David E. Box wrote:
> Intel Platform Monitoring Technology (PMT) support is indicated by presence
> of an Intel defined PCIe DVSEC structure with a PMT ID. However DVSEC
> structures may also be used by Intel to indicate support for other
> capabilities unrelated to PMT. The Out Of Band Management Services Module
> (OOBMSM) is an example of a device that can have both PMT and non-PMT
> capabilities. In order to support these capabilities it is necessary to
> modify the intel_pmt driver to handle the creation of platform devices more
> generically. To that end the following changes are made.
>
> Convert the driver and child drivers from MFD to the Auxiliary Bus. This
> architecture is more suitable anyway since the driver partitions a
> multifunctional PCIe device. This also moves the driver out of the MFD
> subsystem and into platform/x86/intel.
>
> Before, devices were named by their capability (e.g. pmt_telemetry).
> Instead, generically name them by their capability ID (e.g.
> intel_extended_cap.2). This allows the IDs to be created automatically,
> minimizing the code needed to support future capabilities. However, to
> ensure that unsupported devices aren't created, use an allow list to
> specify supported capabilities. Along these lines, rename the driver from
> intel_pmt to intel_extended_caps to better reflect the purpose.
>
> Signed-off-by: David E. Box <david.e.box@xxxxxxxxxxxxxxx>
> ---
>
> V1: New patch. However incorporates some elements of [1] which was
> dropped. Namely enumerating features generically and creating an
> allow list. Also cleans up probe by moving some code to functions
> and using a bool instead of an int to track whether a device was
> added.
>
> [1] https://lore.kernel.org/all/20210922213007.2738388-3-david.e.box@xxxxxxxxxxxxxxx/

<...>

> +static int extended_caps_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> +{
> + struct extended_caps_platform_info *info;
> + bool have_devices = false;
> + unsigned long quirks = 0;
> + int ret;
> +
> + ret = pcim_enable_device(pdev);
> + if (ret)
> + return ret;
> +
> + info = (struct extended_caps_platform_info *)id->driver_data;

pci_get_drvdata() in all places and no need to cast void *.

> + if (info)
> + quirks = info->quirks;
> +
> + have_devices |= extended_caps_walk_dvsec(pdev, quirks);
> +
> + if (info && (info->quirks & EXT_CAPS_QUIRK_NO_DVSEC))
> + have_devices |= extended_caps_walk_header(pdev, quirks, info->capabilities);
> +
> + if (!have_devices)
> + return -ENODEV;
> +
> + return 0;
> +}

<...>

> -static struct platform_driver pmt_telem_driver = {
> - .driver = {
> - .name = TELEM_DEV_NAME,
> - },
> - .remove = pmt_telem_remove,
> - .probe = pmt_telem_probe,
> +static const struct auxiliary_device_id pmt_telem_aux_id_table[] = {
> + { .name = "intel_extended_caps.2", },

Why "2" in the name?

Thanks

> + {},
> +};
> +MODULE_DEVICE_TABLE(auxiliary, pmt_telem_aux_id_table);
> +
> +static struct auxiliary_driver pmt_telem_aux_driver = {
> + .id_table = pmt_telem_aux_id_table,
> + .remove = pmt_telem_remove,
> + .probe = pmt_telem_probe,
> };
>