summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason M. Bills <jason.m.bills@intel.com>2022-03-02 18:58:33 +0300
committerjmbills <jasonm.bills@yahoo.com>2022-03-11 00:27:19 +0300
commit246e36dba646e1fc5176e536bf9e80b2a3a6ba5f (patch)
tree048af9d31dc3be4ebf1f102f27264947b4573d6a
parentf99c8aa5142aaa83cb19aaacf2166dafbb3828aa (diff)
downloadlinux-246e36dba646e1fc5176e536bf9e80b2a3a6ba5f.tar.xz
peci: add msg_len to peci_command
To support the new domain ID, we need to include an extra byte from userspace. This adds a length to the peci_command function so we can detect when the domain ID is sent from userspace. Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
-rw-r--r--drivers/hwmon/peci-cputemp.c10
-rw-r--r--drivers/hwmon/peci-dimmtemp.c14
-rw-r--r--drivers/peci/peci-core.c6
-rw-r--r--drivers/peci/peci-dev.c4
-rw-r--r--include/linux/mfd/intel-peci-client.h4
-rw-r--r--include/linux/peci.h2
6 files changed, 20 insertions, 20 deletions
diff --git a/drivers/hwmon/peci-cputemp.c b/drivers/hwmon/peci-cputemp.c
index b628dbfff6b5..bac8db9a289a 100644
--- a/drivers/hwmon/peci-cputemp.c
+++ b/drivers/hwmon/peci-cputemp.c
@@ -115,7 +115,7 @@ static int get_temp_targets(struct peci_cputemp *priv)
re_msg.rx_len = 4;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_END_PT_CFG, &re_msg);
+ PECI_CMD_RD_END_PT_CFG, sizeof(re_msg), &re_msg);
if (ret || re_msg.cc != PECI_DEV_CC_SUCCESS)
ret = -EAGAIN;
if (ret)
@@ -164,7 +164,7 @@ static int get_die_temp(struct peci_cputemp *priv)
msg.addr = priv->mgr->client->addr;
- ret = peci_command(priv->mgr->client->adapter, PECI_CMD_GET_TEMP, &msg);
+ ret = peci_command(priv->mgr->client->adapter, PECI_CMD_GET_TEMP, sizeof(msg), &msg);
if (ret)
return ret;
@@ -381,7 +381,7 @@ static int check_resolved_cores(struct peci_cputemp *priv)
msg.rx_len = 4;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_PCI_CFG_LOCAL, &msg);
+ PECI_CMD_RD_PCI_CFG_LOCAL, sizeof(msg), &msg);
if (msg.cc != PECI_DEV_CC_SUCCESS)
ret = -EAGAIN;
if (ret)
@@ -393,7 +393,7 @@ static int check_resolved_cores(struct peci_cputemp *priv)
msg.reg = 0xd0;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_PCI_CFG_LOCAL, &msg);
+ PECI_CMD_RD_PCI_CFG_LOCAL, sizeof(msg), &msg);
if (msg.cc != PECI_DEV_CC_SUCCESS)
ret = -EAGAIN;
@@ -413,7 +413,7 @@ static int check_resolved_cores(struct peci_cputemp *priv)
msg.rx_len = 4;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_PCI_CFG_LOCAL, &msg);
+ PECI_CMD_RD_PCI_CFG_LOCAL, sizeof(msg), &msg);
if (msg.cc != PECI_DEV_CC_SUCCESS)
ret = -EAGAIN;
if (ret)
diff --git a/drivers/hwmon/peci-dimmtemp.c b/drivers/hwmon/peci-dimmtemp.c
index a50902ceb70a..e05d5961cbc1 100644
--- a/drivers/hwmon/peci-dimmtemp.c
+++ b/drivers/hwmon/peci-dimmtemp.c
@@ -91,7 +91,7 @@ static int get_dimm_temp(struct peci_dimmtemp *priv, int dimm_no)
re_msg.rx_len = 4;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_END_PT_CFG, &re_msg);
+ PECI_CMD_RD_END_PT_CFG, sizeof(re_msg), &re_msg);
if (ret || re_msg.cc != PECI_DEV_CC_SUCCESS)
ret = -EAGAIN;
if (ret)
@@ -123,7 +123,7 @@ static int get_dimm_temp(struct peci_dimmtemp *priv, int dimm_no)
re_msg.params.pci_cfg.reg = 0xd4;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_END_PT_CFG, &re_msg);
+ PECI_CMD_RD_END_PT_CFG, sizeof(re_msg), &re_msg);
if (ret || re_msg.cc != PECI_DEV_CC_SUCCESS ||
!(re_msg.data[3] & BIT(7))) {
/* Use default or previous value */
@@ -135,7 +135,7 @@ static int get_dimm_temp(struct peci_dimmtemp *priv, int dimm_no)
re_msg.params.pci_cfg.reg = 0xd0;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_END_PT_CFG, &re_msg);
+ PECI_CMD_RD_END_PT_CFG, sizeof(re_msg), &re_msg);
if (ret || re_msg.cc != PECI_DEV_CC_SUCCESS) {
/* Use default or previous value */
ret = 0;
@@ -168,7 +168,7 @@ static int get_dimm_temp(struct peci_dimmtemp *priv, int dimm_no)
re_msg.params.mmio.offset += 0x4000;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_END_PT_CFG, &re_msg);
+ PECI_CMD_RD_END_PT_CFG, sizeof(re_msg), &re_msg);
if (ret || re_msg.cc != PECI_DEV_CC_SUCCESS ||
re_msg.data[1] == 0 || re_msg.data[2] == 0) {
/* Use default or previous value */
@@ -197,7 +197,7 @@ static int get_dimm_temp(struct peci_dimmtemp *priv, int dimm_no)
rp_msg.rx_len = 4;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_PCI_CFG_LOCAL, &rp_msg);
+ PECI_CMD_RD_PCI_CFG_LOCAL, sizeof(rp_msg), &rp_msg);
if (ret || rp_msg.cc != PECI_DEV_CC_SUCCESS ||
rp_msg.pci_config[1] == 0 || rp_msg.pci_config[2] == 0) {
/* Use default or previous value */
@@ -223,7 +223,7 @@ static int get_dimm_temp(struct peci_dimmtemp *priv, int dimm_no)
rp_msg.rx_len = 4;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_PCI_CFG_LOCAL, &rp_msg);
+ PECI_CMD_RD_PCI_CFG_LOCAL, sizeof(rp_msg), &rp_msg);
if (ret || rp_msg.cc != PECI_DEV_CC_SUCCESS ||
rp_msg.pci_config[1] == 0 || rp_msg.pci_config[2] == 0) {
/* Use default or previous value */
@@ -254,7 +254,7 @@ static int get_dimm_temp(struct peci_dimmtemp *priv, int dimm_no)
rp_msg.rx_len = 4;
ret = peci_command(priv->mgr->client->adapter,
- PECI_CMD_RD_PCI_CFG_LOCAL, &rp_msg);
+ PECI_CMD_RD_PCI_CFG_LOCAL, sizeof(rp_msg), &rp_msg);
if (ret || rp_msg.cc != PECI_DEV_CC_SUCCESS ||
rp_msg.pci_config[1] == 0 || rp_msg.pci_config[2] == 0) {
/* Use default or previous value */
diff --git a/drivers/peci/peci-core.c b/drivers/peci/peci-core.c
index 72d9a909125b..2638a0f33610 100644
--- a/drivers/peci/peci-core.c
+++ b/drivers/peci/peci-core.c
@@ -1190,7 +1190,7 @@ static const peci_cmd_fn_type peci_cmd_fn[PECI_CMD_MAX] = {
*
* Return: zero on success, else a negative error code.
*/
-int peci_command(struct peci_adapter *adapter, enum peci_cmd cmd, void *vmsg)
+int peci_command(struct peci_adapter *adapter, enum peci_cmd cmd, uint msg_len, void *vmsg)
{
int ret;
@@ -1220,7 +1220,7 @@ static int peci_detect(struct peci_adapter *adapter, u8 addr)
msg.addr = addr;
- return peci_command(adapter, PECI_CMD_PING, &msg);
+ return peci_command(adapter, PECI_CMD_PING, sizeof(msg), &msg);
}
static const struct of_device_id *
@@ -1386,7 +1386,7 @@ int peci_get_cpu_id(struct peci_adapter *adapter, u8 addr, u32 *cpu_id)
msg.param = PECI_PKG_ID_CPU_ID;
msg.rx_len = 4;
- ret = peci_command(adapter, PECI_CMD_RD_PKG_CFG, &msg);
+ ret = peci_command(adapter, PECI_CMD_RD_PKG_CFG, sizeof(msg), &msg);
if (msg.cc != PECI_DEV_CC_SUCCESS)
ret = -EAGAIN;
if (ret)
diff --git a/drivers/peci/peci-dev.c b/drivers/peci/peci-dev.c
index 8104468864bf..f02666984ce7 100644
--- a/drivers/peci/peci-dev.c
+++ b/drivers/peci/peci-dev.c
@@ -143,7 +143,7 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg)
* either success or timeout to provide the completion code to
* the caller.
*/
- ret = peci_command(peci_dev->adapter, cmd, xmsg);
+ ret = peci_command(peci_dev->adapter, cmd, msg_len, xmsg);
if ((!ret || ret == -ETIMEDOUT) && xmsg->rx_len &&
copy_to_user((__u8 __user *)uxmsg.rx_buf, xmsg->rx_buf,
xmsg->rx_len))
@@ -163,7 +163,7 @@ static long peci_dev_ioctl(struct file *file, uint iocmd, ulong arg)
* either success or timeout to provide the completion code to
* the caller.
*/
- ret = peci_command(peci_dev->adapter, cmd, msg);
+ ret = peci_command(peci_dev->adapter, cmd, msg_len, msg);
if ((!ret || ret == -ETIMEDOUT) &&
copy_to_user(umsg, msg, msg_len))
ret = -EFAULT;
diff --git a/include/linux/mfd/intel-peci-client.h b/include/linux/mfd/intel-peci-client.h
index 31b869e058b7..79b6c94bc153 100644
--- a/include/linux/mfd/intel-peci-client.h
+++ b/include/linux/mfd/intel-peci-client.h
@@ -115,7 +115,7 @@ peci_client_read_package_config(struct peci_client_manager *priv,
msg.param = param;
msg.rx_len = 4;
- ret = peci_command(priv->client->adapter, PECI_CMD_RD_PKG_CFG, &msg);
+ ret = peci_command(priv->client->adapter, PECI_CMD_RD_PKG_CFG, sizeof(msg), &msg);
if (msg.cc != PECI_DEV_CC_SUCCESS)
ret = -EAGAIN;
if (ret)
@@ -149,7 +149,7 @@ peci_client_write_package_config(struct peci_client_manager *priv,
msg.tx_len = 4u;
msg.value = data;
- ret = peci_command(priv->client->adapter, PECI_CMD_WR_PKG_CFG, &msg);
+ ret = peci_command(priv->client->adapter, PECI_CMD_WR_PKG_CFG, sizeof(msg), &msg);
if (!ret) {
if (msg.cc != PECI_DEV_CC_SUCCESS)
ret = -EAGAIN;
diff --git a/include/linux/peci.h b/include/linux/peci.h
index 45cb77d1913c..5a707bbeb66d 100644
--- a/include/linux/peci.h
+++ b/include/linux/peci.h
@@ -145,7 +145,7 @@ struct peci_adapter *peci_verify_adapter(struct device *dev);
int peci_for_each_dev(void *data, int (*fn)(struct device *, void *));
struct peci_xfer_msg *peci_get_xfer_msg(u8 tx_len, u8 rx_len);
void peci_put_xfer_msg(struct peci_xfer_msg *msg);
-int peci_command(struct peci_adapter *adpater, enum peci_cmd cmd, void *vmsg);
+int peci_command(struct peci_adapter *adpater, enum peci_cmd cmd, uint msg_len, void *vmsg);
int peci_get_cpu_id(struct peci_adapter *adapter, u8 addr, u32 *cpu_id);
#endif /* __LINUX_PECI_H */