More thermal control updates for 5.16-rc1

- Replace pr_warn() with pr_warn_once() in user_space_bind() to
    reduce kernel log noise (Rafael Wysocki).
 
  - Extend the RFIM mailbox interface in the int340x thermal driver
    to return 64 bit values to allow all values returned by the
    hardware to be handled correctly (Srinivas Pandruvada).
 
  - Fix possible NULL pointer dereferences in the of_thermal_ family
    of functions (Subbaraman Narayanamurthy).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmGL1H8SHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxvLcP/jdIL2e92WnF9oOTqEfuZLpvkpL7r3Wj
 D09P0ooGUNV6esCF3d5iLMM0GR+MHyX3AVj6NaZAZmbWnud+/QiXi6zUT/kG9AmQ
 R2/YoeadTcaYESGPPaNZvVKvYfGQaNABg5mJoZz0OmOYG5sNoWamv9h38lb/Lr/q
 +vBAgTm6rxME4GMLdrcxFHUUP+tQTjZLvQOphE+jcLhaPT6rRU/4yndx412HhraM
 7VuBcyOO/RbCF/cyDtZusB6tMyW+IE2ROEaBBtHNx0Tb7/bg3RIhR9pMOfL9bUx3
 0RDZUY9QYLRmGtNMvdvjM5Vvq+3tUZere2LiEUToPNoVdy3u5VoAdBSvzdiqSMpi
 JKlopfzhSizZ/+r+VIffbVBUETVrSKI+mT+4KYE8Pt26tUm+TQfCnf4jdFy67yFH
 JOPPRRV2w5vidR5QvoD986OdgEH+GDvFhhT230OT4uJsB2Kf9oZDaxa/4l55T2R/
 OFBrUFdprXmuLeMWahJvONpwCxi0GXCDFI3fhZ/T1Iz2Sqydpj+5haMS2QX0lOse
 ISDWZLCBDd/HRayVygMm6QRSlI+3A2x7cdl5GjgtCY+bZUwJwQ+N1eeGxfFc/P8R
 fEQaHqOOpb0yewcY3DHd7NHzy/cRFV7ZnNun8g899Ya2YvEvsbhkKc6FeLYLQQmX
 egONP0zmCiNv
 =z49n
 -----END PGP SIGNATURE-----

Merge tag 'thermal-5.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more thermal control updates from Rafael Wysocki:
 "These fix two issues in the thermal core and one in the int340x
  thermal driver.

  Specifics:

   - Replace pr_warn() with pr_warn_once() in user_space_bind() to
     reduce kernel log noise (Rafael Wysocki).

   - Extend the RFIM mailbox interface in the int340x thermal driver to
     return 64 bit values to allow all values returned by the hardware
     to be handled correctly (Srinivas Pandruvada).

   - Fix possible NULL pointer dereferences in the of_thermal_ family of
     functions (Subbaraman Narayanamurthy)"

* tag 'thermal-5.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  thermal: Replace pr_warn() with pr_warn_once() in user_space_bind()
  thermal: Fix NULL pointer dereferences in of_thermal_ functions
  thermal/drivers/int340x: processor_thermal: Suppot 64 bit RFIM responses
This commit is contained in:
Linus Torvalds 2021-11-10 12:07:22 -08:00
commit 881007522c
5 changed files with 27 additions and 20 deletions

View file

@ -17,8 +17,8 @@
static int user_space_bind(struct thermal_zone_device *tz)
{
pr_warn("Userspace governor deprecated: use thermal netlink " \
"notification instead\n");
pr_warn_once("Userspace governor deprecated: use thermal netlink " \
"notification instead\n");
return 0;
}

View file

@ -80,7 +80,7 @@ void proc_thermal_rfim_remove(struct pci_dev *pdev);
int proc_thermal_mbox_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
void proc_thermal_mbox_remove(struct pci_dev *pdev);
int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cmd_resp);
int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u64 *cmd_resp);
int proc_thermal_add(struct device *dev, struct proc_thermal_device *priv);
void proc_thermal_remove(struct proc_thermal_device *proc_priv);
int proc_thermal_suspend(struct device *dev);

View file

@ -23,7 +23,7 @@
static DEFINE_MUTEX(mbox_lock);
static int send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cmd_resp)
static int send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u64 *cmd_resp)
{
struct proc_thermal_device *proc_priv;
u32 retries, data;
@ -68,12 +68,16 @@ static int send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cm
goto unlock_mbox;
}
if (cmd_id == MBOX_CMD_WORKLOAD_TYPE_READ) {
data = readl((void __iomem *) (proc_priv->mmio_base + MBOX_OFFSET_DATA));
*cmd_resp = data & 0xff;
}
ret = 0;
if (!cmd_resp)
break;
if (cmd_id == MBOX_CMD_WORKLOAD_TYPE_READ)
*cmd_resp = readl((void __iomem *) (proc_priv->mmio_base + MBOX_OFFSET_DATA));
else
*cmd_resp = readq((void __iomem *) (proc_priv->mmio_base + MBOX_OFFSET_DATA));
break;
} while (--retries);
@ -82,7 +86,7 @@ static int send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cm
return ret;
}
int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cmd_resp)
int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u64 *cmd_resp)
{
return send_mbox_cmd(pdev, cmd_id, cmd_data, cmd_resp);
}
@ -153,7 +157,7 @@ static ssize_t workload_type_show(struct device *dev,
char *buf)
{
struct pci_dev *pdev = to_pci_dev(dev);
u32 cmd_resp;
u64 cmd_resp;
int ret;
ret = send_mbox_cmd(pdev, MBOX_CMD_WORKLOAD_TYPE_READ, 0, &cmd_resp);
@ -187,7 +191,7 @@ static bool workload_req_created;
int proc_thermal_mbox_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv)
{
u32 cmd_resp;
u64 cmd_resp;
int ret;
/* Check if there is a mailbox support, if fails return success */

View file

@ -195,7 +195,7 @@ static ssize_t rfi_restriction_store(struct device *dev,
const char *buf, size_t count)
{
u16 cmd_id = 0x0008;
u32 cmd_resp;
u64 cmd_resp;
u32 input;
int ret;
@ -215,14 +215,14 @@ static ssize_t rfi_restriction_show(struct device *dev,
char *buf)
{
u16 cmd_id = 0x0007;
u32 cmd_resp;
u64 cmd_resp;
int ret;
ret = processor_thermal_send_mbox_cmd(to_pci_dev(dev), cmd_id, 0, &cmd_resp);
if (ret)
return ret;
return sprintf(buf, "%u\n", cmd_resp);
return sprintf(buf, "%llu\n", cmd_resp);
}
static ssize_t ddr_data_rate_show(struct device *dev,
@ -230,14 +230,14 @@ static ssize_t ddr_data_rate_show(struct device *dev,
char *buf)
{
u16 cmd_id = 0x0107;
u32 cmd_resp;
u64 cmd_resp;
int ret;
ret = processor_thermal_send_mbox_cmd(to_pci_dev(dev), cmd_id, 0, &cmd_resp);
if (ret)
return ret;
return sprintf(buf, "%u\n", cmd_resp);
return sprintf(buf, "%llu\n", cmd_resp);
}
static DEVICE_ATTR_RW(rfi_restriction);

View file

@ -89,7 +89,7 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz,
{
struct __thermal_zone *data = tz->devdata;
if (!data->ops->get_temp)
if (!data->ops || !data->ops->get_temp)
return -EINVAL;
return data->ops->get_temp(data->sensor_data, temp);
@ -186,6 +186,9 @@ static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
{
struct __thermal_zone *data = tz->devdata;
if (!data->ops || !data->ops->set_emul_temp)
return -EINVAL;
return data->ops->set_emul_temp(data->sensor_data, temp);
}
@ -194,7 +197,7 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
{
struct __thermal_zone *data = tz->devdata;
if (!data->ops->get_trend)
if (!data->ops || !data->ops->get_trend)
return -EINVAL;
return data->ops->get_trend(data->sensor_data, trip, trend);
@ -301,7 +304,7 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
if (trip >= data->ntrips || trip < 0)
return -EDOM;
if (data->ops->set_trip_temp) {
if (data->ops && data->ops->set_trip_temp) {
int ret;
ret = data->ops->set_trip_temp(data->sensor_data, trip, temp);