Message ID | 20240105112547.7301-1-ilpo.jarvinen@linux.intel.com |
---|---|
Headers | show |
Series | Add PCIe bandwidth controller | expand |
Le 05/01/2024 à 12:25, Ilpo Järvinen a écrit : > Add a thermal cooling driver to provide path to access PCIe bandwidth > controller using the usual thermal interfaces. > > A cooling device is instantiated for controllable PCIe Ports from the > bwctrl service driver. > > The thermal side state 0 means no throttling, i.e., maximum supported > PCIe Link Speed. > > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> > Acked-by: Rafael J. Wysocki <rafael@kernel.org> # From the cooling device interface perspective > --- ... > +struct thermal_cooling_device *pcie_cooling_device_register(struct pci_dev *port, > + struct pcie_device *pdev) > +{ > + struct pcie_cooling_device *pcie_cdev; > + struct thermal_cooling_device *cdev; > + size_t name_len; > + char *name; > + > + pcie_cdev = kzalloc(sizeof(*pcie_cdev), GFP_KERNEL); > + if (!pcie_cdev) > + return ERR_PTR(-ENOMEM); > + > + pcie_cdev->port = port; > + pcie_cdev->pdev = pdev; > + > + name_len = strlen(COOLING_DEV_TYPE_PREFIX) + strlen(pci_name(port)) + 1; > + name = kzalloc(name_len, GFP_KERNEL); > + if (!name) { > + kfree(pcie_cdev); > + return ERR_PTR(-ENOMEM); > + } > + > + snprintf(name, name_len, COOLING_DEV_TYPE_PREFIX "%s", pci_name(port)); Nit: kasprintf() ? > + cdev = thermal_cooling_device_register(name, pcie_cdev, &pcie_cooling_ops); > + kfree(name); > + > + return cdev; > +}