mei: enable adding more IOCTL handlers
Subsystems (2)
PATCH 1/10 mei: enable adding more IOCTL handlers
Handle ioctls in a switch statement so we can
add more commands easily
--- drivers/misc/mei/main.c | 53 ++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 25 deletions(-)
drivers/misc/mei/main.c +28 -25
@@ -523,8 +523,6 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)struct mei_connect_client_data *connect_data =NULL ;int rets; -if (cmd !=IOCTL_MEI_CONNECT_CLIENT ) -return -EINVAL ;if (WARN_ON (!cl || !cl->dev))return -ENODEV ;
@@ -539,34 +537,39 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) goto out; } -dev_dbg (&dev->pdev->dev,": IOCTL_MEI_CONNECT_CLIENT.\n" ); - - connect_data =kzalloc (sizeof (struct mei_connect_client_data ), +switch (cmd) { +case IOCTL_MEI_CONNECT_CLIENT : +dev_dbg (&dev->pdev->dev,": IOCTL_MEI_CONNECT_CLIENT.\n" ); + connect_data =kzalloc (sizeof (struct mei_connect_client_data ),GFP_KERNEL ); -if (!connect_data) { - rets = -ENOMEM ; - goto out; - } -dev_dbg (&dev->pdev->dev,"copy connect data from user\n" ); -if (copy_from_user (connect_data, (char __user *)data, -sizeof (struct mei_connect_client_data ))) { -dev_dbg (&dev->pdev->dev,"failed to copy data from userland\n" ); - rets = -EFAULT ; - goto out; - } +if (!connect_data) { + rets = -ENOMEM ; + goto out; + } - rets =mei_ioctl_connect_client (file, connect_data); +if (copy_from_user (connect_data, (char __user *)data, +sizeof (struct mei_connect_client_data ))) { +dev_dbg (&dev->pdev->dev,"failed to copy data from userland\n" ); + rets = -EFAULT ; + goto out; + } -/* if all is ok, copying the data back to user. */ -if (rets) - goto out; + rets =mei_ioctl_connect_client (file, connect_data); +if (rets) + goto out; -dev_dbg (&dev->pdev->dev,"copy connect data to user\n" ); -if (copy_to_user ((char __user *)data, connect_data, +/* if all is ok, copying the data back to user. */ +if (copy_to_user ((char __user *)data, connect_data,sizeof (struct mei_connect_client_data ))) { -dev_dbg (&dev->pdev->dev,"failed to copy data to userland\n" ); - rets = -EFAULT ; - goto out; +dev_dbg (&dev->pdev->dev,"failed to copy data to userland\n" ); + rets = -EFAULT ; + goto out; + } + +break ; +default : +dev_err (&dev->pdev->dev,": unsupported ioctl %d.\n" , cmd); + rets = -ENOIOCTLCMD ; } out:
Signature · 1 line
1.9.3
PATCH 2/10 mei: use connect_data on the stack
There is no need for dynamic allocation for connect_data. We can use variable on the stack and make code less error prone and simple
--- drivers/misc/mei/main.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
drivers/misc/mei/main.c +5 -16
@@ -433,9 +433,6 @@ static int mei_ioctl_connect_client(struct file *file,int rets; cl = file->private_data; -if (WARN_ON (!cl || !cl->dev)) -return -ENODEV ; - dev = cl->dev;if (dev->dev_state !=MEI_DEV_ENABLED ) {
@@ -506,7 +503,6 @@ end:return rets; } -/** * mei_ioctl - the IOCTL function *
@@ -520,7 +516,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) {struct mei_device *dev;struct mei_cl *cl = file->private_data; -struct mei_connect_client_data *connect_data =NULL ; +struct mei_connect_client_data connect_data;int rets;
@@ -540,26 +536,19 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)switch (cmd) {case IOCTL_MEI_CONNECT_CLIENT :dev_dbg (&dev->pdev->dev,": IOCTL_MEI_CONNECT_CLIENT.\n" ); - connect_data =kzalloc (sizeof (struct mei_connect_client_data ), -GFP_KERNEL ); -if (!connect_data) { - rets = -ENOMEM ; - goto out; - } - -if (copy_from_user (connect_data, (char __user *)data, +if (copy_from_user (&connect_data, (char __user *)data,sizeof (struct mei_connect_client_data ))) {dev_dbg (&dev->pdev->dev,"failed to copy data from userland\n" ); rets = -EFAULT ; goto out; } - rets =mei_ioctl_connect_client (file, connect_data); + rets =mei_ioctl_connect_client (file, &connect_data);if (rets) goto out;/* if all is ok, copying the data back to user. */ -if (copy_to_user ((char __user *)data, connect_data, +if (copy_to_user ((char __user *)data, &connect_data,sizeof (struct mei_connect_client_data ))) {dev_dbg (&dev->pdev->dev,"failed to copy data to userland\n" ); rets = -EFAULT ;
@@ -567,13 +556,13 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) }break ; +default :dev_err (&dev->pdev->dev,": unsupported ioctl %d.\n" , cmd); rets = -ENOIOCTLCMD ; } out: -kfree (connect_data);mutex_unlock (&dev->device_lock);return rets; }
Signature · 1 line
1.9.3
PATCH 3/10 mei: add hbm and pg state in devstate debugfs print
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
Add hbm state, pg enablement and state to devstate file in debugfs (<debugfs>/mei/devstate)
--- drivers/misc/mei/debugfs.c | 7 ++++++- drivers/misc/mei/hbm.c | 16 ++++++++++++++++ drivers/misc/mei/hbm.h | 2 ++ drivers/misc/mei/init.c | 12 ++++++++++++ drivers/misc/mei/mei_dev.h | 2 ++ 5 files changed, 38 insertions(+), 1 deletion(-)
drivers/misc/mei/debugfs.c +6 -1
@@ -134,8 +134,13 @@ static ssize_t mei_dbgfs_read_devstate(struct file *fp, char __user *ubuf,if (!buf)return -ENOMEM ; - pos +=scnprintf (buf + pos, bufsz - pos,"%s\n" , + pos +=scnprintf (buf + pos, bufsz - pos,"dev: %s\n" ,mei_dev_state_str (dev->dev_state)); + pos +=scnprintf (buf + pos, bufsz - pos,"hbm: %s\n" , +mei_hbm_state_str (dev->hbm_state)); + pos +=scnprintf (buf + pos, bufsz - pos,"pg: %s, %s\n" , +mei_pg_is_enabled (dev) ?"ENABLED" :"DISABLED" , +mei_pg_state_str (mei_pg_state (dev))); ret =simple_read_from_buffer (ubuf, cnt, ppos, buf, pos);kfree (buf);return ret;
drivers/misc/mei/hbm.c +16 -0
@@ -56,6 +56,22 @@ static const char *mei_cl_conn_status_str(enum mei_cl_connect_status status)#undef MEI_CL_CCS } +const char *mei_hbm_state_str (enum mei_hbm_state state) +{ +#define MEI_HBM_STATE (state) case MEI_HBM_##state: return #state +switch (state) { +MEI_HBM_STATE (IDLE ); +MEI_HBM_STATE (STARTING ); +MEI_HBM_STATE (STARTED ); +MEI_HBM_STATE (ENUM_CLIENTS ); +MEI_HBM_STATE (CLIENT_PROPERTIES ); +MEI_HBM_STATE (STOPPED ); +default : +return "unknown" ; + } +#undef MEI_HBM_STATE +} +/** * mei_cl_conn_status_to_errno - convert client connect response * status to error code
drivers/misc/mei/hbm.h +2 -0
@@ -40,6 +40,8 @@ enum mei_hbm_state { MEI_HBM_STOPPED, }; +const char *mei_hbm_state_str (enum mei_hbm_state state); +int mei_hbm_dispatch (struct mei_device *dev,struct mei_msg_hdr *hdr);static inline void mei_hbm_hdr (struct mei_msg_hdr *hdr,size_t length)
drivers/misc/mei/init.c +12 -0
@@ -43,6 +43,18 @@ const char *mei_dev_state_str(int state)#undef MEI_DEV_STATE } +const char *mei_pg_state_str (enum mei_pg_state state) +{ +#define MEI_PG_STATE (state) case MEI_PG_##state: return #state +switch (state) { +MEI_PG_STATE (OFF ); +MEI_PG_STATE (ON ); +default : +return "unknown" ; + } +#undef MEI_PG_STATE +} +/** * mei_cancel_work. Cancel mei background jobs
drivers/misc/mei/mei_dev.h +2 -0
@@ -375,6 +375,8 @@ enum mei_pg_state { MEI_PG_ON = 1, }; +const char *mei_pg_state_str (enum mei_pg_state state); +/* * mei_cfg *
Signature · 1 line
1.9.3
PATCH 4/10 mei: debugfs: adjust print buffer
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
In case of many me clients (15 and more) 1K buffer is not enough for full information print. Calculate buffer size according to real clients number.
--- drivers/misc/mei/debugfs.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/misc/mei/debugfs.c +15 -7
@@ -29,20 +29,28 @@ static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf, {struct mei_device *dev = fp->private_data;struct mei_me_client *me_cl; -const size_t bufsz =1024 ; -char *buf =kzalloc (bufsz,GFP_KERNEL ); +size_t bufsz =1 ; +char *buf;int i =0 ;int pos =0 ;int ret; -if (!buf) -return -ENOMEM ; - - pos +=scnprintf (buf + pos, bufsz - pos, -" |id|addr| UUID |con|msg len|\n" ); +#define HDR " |id|addr| UUID |con|msg len|\n"mutex_lock (&dev->device_lock); +list_for_each_entry (me_cl, &dev->me_clients, list) + bufsz++; + + bufsz *=sizeof (HDR ) +1 ; + buf =kzalloc (bufsz,GFP_KERNEL ); +if (!buf) { +mutex_unlock (&dev->device_lock); +return -ENOMEM ; + } + + pos +=scnprintf (buf + pos, bufsz - pos,HDR ); +/* if the driver is not enabled the list won't be consistent */ if (dev->dev_state !=MEI_DEV_ENABLED ) goto out;
Signature · 1 line
1.9.3
PATCH 5/10 mei: debugfs: add single buffer indicator
In reply to Tomas WinklerAdd indication whether the client operates in single buffer mode
--- drivers/misc/mei/debugfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/misc/mei/debugfs.c +4 -3
@@ -35,7 +35,7 @@ static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf,int pos =0 ;int ret; -#define HDR " |id|addr| UUID |con|msg len|\n" +#define HDR " |id|addr| UUID |con|msg len|sb|\n"mutex_lock (&dev->device_lock);
@@ -62,12 +62,13 @@ static ssize_t mei_dbgfs_read_meclients(struct file *fp, char __user *ubuf,continue ; pos +=scnprintf (buf + pos, bufsz - pos, -"%2d|%2d|%4d|%pUl|%3d|%7d|\n" , +"%2d|%2d|%4d|%pUl|%3d|%7d|%2d|\n" , i++, me_cl->client_id, me_cl->props.fixed_address, &me_cl->props.protocol_name, me_cl->props.max_number_of_connections, - me_cl->props.max_msg_length); + me_cl->props.max_msg_length, + me_cl->props.single_recv_buf); } out:mutex_unlock (&dev->device_lock);
Signature · 1 line
1.9.3
PATCH 6/10 mei: pg: fix cat and paste error in comments
In reply to Tomas Winkler--- drivers/misc/mei/hw-me.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/mei/hw-me.c +2 -2
@@ -457,7 +457,7 @@ static int mei_me_read_slots(struct mei_device *dev, unsigned char *buffer, }/** -* mei_me_pg_enter - write pg enter register to mei device. +* mei_me_pg_enter - write pg enter register * * @dev: the device structure */
@@ -470,7 +470,7 @@ static void mei_me_pg_enter(struct mei_device *dev) }/** -* mei_me_pg_enter - write pg enter register to mei device. +* mei_me_pg_exit - write pg exit register * * @dev: the device structure */
Signature · 1 line
1.9.3
PATCH 7/10 mei: fix style warning: Missing a blank line after declarations
In reply to Tomas Winklerfix new style warning: Missing a blank line after declarations
--- drivers/misc/mei/amthif.c | 1 + drivers/misc/mei/client.c | 1 + drivers/misc/mei/debugfs.c | 1 + drivers/misc/mei/hbm.c | 5 +++++ drivers/misc/mei/hw-me.c | 12 ++++++++++++ drivers/misc/mei/hw-txe.c | 29 +++++++++++++++++++++++++---- drivers/misc/mei/init.c | 6 ++++-- drivers/misc/mei/nfc.c | 1 + drivers/misc/mei/pci-txe.c | 1 + 9 files changed, 51 insertions(+), 6 deletions(-)
drivers/misc/mei/amthif.c +1 -0
@@ -130,6 +130,7 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev, struct file *file) {struct mei_cl_cb *cb; +list_for_each_entry (cb, &dev->amthif_rd_complete_list.list, list)if (cb->file_object == file)return cb;
drivers/misc/mei/client.c +1 -0
@@ -1064,6 +1064,7 @@ void mei_cl_all_disconnect(struct mei_device *dev)void mei_cl_all_wakeup (struct mei_device *dev) {struct mei_cl *cl; +list_for_each_entry (cl, &dev->file_list, link) {if (waitqueue_active (&cl->rx_wait)) {cl_dbg (dev, cl,"Waking up reading client!\n" );
drivers/misc/mei/debugfs.c +1 -0
@@ -179,6 +179,7 @@ void mei_dbgfs_deregister(struct mei_device *dev)int mei_dbgfs_register (struct mei_device *dev,const char *name) {struct dentry *dir, *f; + dir =debugfs_create_dir (name,NULL );if (!dir)return -ENOMEM ;
drivers/misc/mei/hbm.c +5 -0
@@ -111,6 +111,7 @@ void mei_hbm_idle(struct mei_device *dev)static void mei_me_cl_remove_all (struct mei_device *dev) {struct mei_me_client *me_cl, *next; +list_for_each_entry_safe (me_cl, next, &dev->me_clients, list) {list_del (&me_cl->list);kfree (me_cl);
@@ -449,6 +450,7 @@ static int mei_hbm_stop_req(struct mei_device *dev)int mei_hbm_cl_flow_control_req (struct mei_device *dev,struct mei_cl *cl) {const size_t len =sizeof (struct hbm_flow_control ); +cl_dbg (dev, cl,"sending flow control\n" );return mei_hbm_cl_write (dev, cl,MEI_FLOW_CONTROL_CMD , len); }
@@ -520,6 +522,7 @@ static void mei_hbm_cl_flow_control_res(struct mei_device *dev,int mei_hbm_cl_disconnect_req (struct mei_device *dev,struct mei_cl *cl) {const size_t len =sizeof (struct hbm_client_connect_request ); +return mei_hbm_cl_write (dev, cl,CLIENT_DISCONNECT_REQ_CMD , len); }
@@ -534,6 +537,7 @@ int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)int mei_hbm_cl_disconnect_rsp (struct mei_device *dev,struct mei_cl *cl) {const size_t len =sizeof (struct hbm_client_connect_response ); +return mei_hbm_cl_write (dev, cl,CLIENT_DISCONNECT_RES_CMD , len); }
@@ -569,6 +573,7 @@ static void mei_hbm_cl_disconnect_res(struct mei_cl *cl,int mei_hbm_cl_connect_req (struct mei_device *dev,struct mei_cl *cl) {const size_t len =sizeof (struct hbm_client_connect_request ); +return mei_hbm_cl_write (dev, cl,CLIENT_CONNECT_REQ_CMD , len); }
drivers/misc/mei/hw-me.c +12 -0
@@ -127,6 +127,7 @@ static void mei_me_hw_config(struct mei_device *dev)static inline enum mei_pg_state mei_me_pg_state (struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev); +return hw->pg_state; }
@@ -139,6 +140,7 @@ static void mei_me_intr_clear(struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev);u32 hcsr =mei_hcsr_read (hw); +if ((hcsr &H_IS ) ==H_IS )mei_me_reg_write (hw,H_CSR , hcsr); }
@@ -151,6 +153,7 @@ static void mei_me_intr_enable(struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev);u32 hcsr =mei_hcsr_read (hw); + hcsr |=H_IE ;mei_hcsr_set (hw, hcsr); }
@@ -164,6 +167,7 @@ static void mei_me_intr_disable(struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev);u32 hcsr =mei_hcsr_read (hw); + hcsr &= ~H_IE ;mei_hcsr_set (hw, hcsr); }
@@ -234,6 +238,7 @@ static int mei_me_hw_reset(struct mei_device *dev, bool intr_enable)static void mei_me_host_set_ready (struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev); + hw->host_hw_state =mei_hcsr_read (hw); hw->host_hw_state |=H_IE |H_IG |H_RDY ;mei_hcsr_set (hw, hw->host_hw_state);
@@ -247,6 +252,7 @@ static void mei_me_host_set_ready(struct mei_device *dev)static bool mei_me_host_is_ready (struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev); + hw->host_hw_state =mei_hcsr_read (hw);return (hw->host_hw_state &H_RDY ) ==H_RDY ; }
@@ -260,6 +266,7 @@ static bool mei_me_host_is_ready(struct mei_device *dev)static bool mei_me_hw_is_ready (struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev); + hw->me_hw_state =mei_me_mecsr_read (hw);return (hw->me_hw_state &ME_RDY_HRA ) ==ME_RDY_HRA ; }
@@ -283,6 +290,7 @@ static int mei_me_hw_ready_wait(struct mei_device *dev)static int mei_me_hw_start (struct mei_device *dev) {int ret =mei_me_hw_ready_wait (dev); +if (ret)return ret;dev_dbg (&dev->pdev->dev,"hw is ready\n" );
@@ -390,6 +398,7 @@ static int mei_me_write_message(struct mei_device *dev, rem = length &0x3 ;if (rem >0 ) {u32 reg =0 ; +memcpy (®, &buf[length - rem], rem);mei_me_reg_write (hw,H_CB_WW , reg); }
@@ -448,6 +457,7 @@ static int mei_me_read_slots(struct mei_device *dev, unsigned char *buffer,if (buffer_length >0 ) {u32 reg =mei_me_mecbrw_read (dev); +memcpy (reg_buf, ®, buffer_length); }
@@ -465,6 +475,7 @@ static void mei_me_pg_enter(struct mei_device *dev) {struct mei_me_hw *hw =to_me_hw (dev);u32 reg =mei_me_reg_read (hw,H_HPG_CSR ); + reg |=H_HPG_CSR_PGI ;mei_me_reg_write (hw,H_HPG_CSR , reg); }
@@ -732,6 +743,7 @@ static const struct mei_hw_ops mei_me_hw_ops = {static bool mei_me_fw_type_nm (struct pci_dev *pdev) {u32 reg; +pci_read_config_dword (pdev,PCI_CFG_HFS_2 , ®);/* make sure that bit 9 (NM) is up and bit 10 (DM) is down */ return (reg &0x600 ) ==0x200 ;
drivers/misc/mei/hw-txe.c +25 -4
@@ -177,6 +177,7 @@ static u32 mei_txe_aliveness_req_get(struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev);u32 reg; + reg =mei_txe_br_reg_read (hw,SICR_HOST_ALIVENESS_REQ_REG );return reg &SICR_HOST_ALIVENESS_REQ_REQUESTED ; }
@@ -192,6 +193,7 @@ static u32 mei_txe_aliveness_get(struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev);u32 reg; + reg =mei_txe_br_reg_read (hw,HICR_HOST_ALIVENESS_RESP_REG );return reg &HICR_HOST_ALIVENESS_RESP_ACK ; }
@@ -307,6 +309,7 @@ static bool mei_txe_pg_is_enabled(struct mei_device *dev)static inline enum mei_pg_state mei_txe_pg_state (struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev); +return hw->aliveness ?MEI_PG_OFF :MEI_PG_ON ; }
@@ -358,6 +361,7 @@ static bool mei_txe_is_input_ready(struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev);u32 status; + status =mei_txe_sec_reg_read (hw,SEC_IPC_INPUT_STATUS_REG );return !!(SEC_IPC_INPUT_STATUS_RDY & status); }
@@ -370,6 +374,7 @@ static bool mei_txe_is_input_ready(struct mei_device *dev)static inline void mei_txe_intr_clear (struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev); +mei_txe_sec_reg_write_silent (hw,SEC_IPC_HOST_INT_STATUS_REG ,SEC_IPC_HOST_INT_STATUS_PENDING );mei_txe_br_reg_write (hw,HISR_REG ,HISR_INT_STS_MSK );
@@ -384,6 +389,7 @@ static inline void mei_txe_intr_clear(struct mei_device *dev)static void mei_txe_intr_disable (struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev); +mei_txe_br_reg_write (hw,HHIER_REG ,0 );mei_txe_br_reg_write (hw,HIER_REG ,0 ); }
@@ -395,6 +401,7 @@ static void mei_txe_intr_disable(struct mei_device *dev)static void mei_txe_intr_enable (struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev); +mei_txe_br_reg_write (hw,HHIER_REG ,IPC_HHIER_MSK );mei_txe_br_reg_write (hw,HIER_REG ,HIER_INT_EN_MSK ); }
@@ -440,6 +447,7 @@ static void mei_txe_input_payload_write(struct mei_device *dev, unsigned long idx, u32 value) {struct mei_txe_hw *hw =to_txe_hw (dev); +mei_txe_sec_reg_write (hw,SEC_IPC_INPUT_PAYLOAD_REG + (idx *sizeof (u32)), value); }
@@ -457,6 +465,7 @@ static u32 mei_txe_out_data_read(const struct mei_device *dev, unsigned long idx) {struct mei_txe_hw *hw =to_txe_hw (dev); +return mei_txe_br_reg_read (hw,BRIDGE_IPC_OUTPUT_PAYLOAD_REG + (idx *sizeof (u32))); }
@@ -471,6 +480,7 @@ static u32 mei_txe_out_data_read(const struct mei_device *dev,static void mei_txe_readiness_set_host_rdy (struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev); +mei_txe_br_reg_write (hw,SICR_HOST_IPC_READINESS_REQ_REG ,SICR_HOST_IPC_READINESS_HOST_RDY );
@@ -484,6 +494,7 @@ static void mei_txe_readiness_set_host_rdy(struct mei_device *dev)static void mei_txe_readiness_clear (struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev); +mei_txe_br_reg_write (hw,SICR_HOST_IPC_READINESS_REQ_REG ,SICR_HOST_IPC_READINESS_RDY_CLR ); }
@@ -496,6 +507,7 @@ static void mei_txe_readiness_clear(struct mei_device *dev)static u32 mei_txe_readiness_get (struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev); +return mei_txe_br_reg_read (hw,HICR_SEC_IPC_READINESS_REG ); }
@@ -519,6 +531,7 @@ static inline bool mei_txe_readiness_is_sec_rdy(u32 readiness)static bool mei_txe_hw_is_ready (struct mei_device *dev) {u32 readiness =mei_txe_readiness_get (dev); +return mei_txe_readiness_is_sec_rdy (readiness); }
@@ -531,6 +544,7 @@ static inline bool mei_txe_host_is_ready(struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev);u32 reg =mei_txe_br_reg_read (hw,HICR_SEC_IPC_READINESS_REG ); +return !!(reg &HICR_SEC_IPC_READINESS_HOST_RDY ); }
@@ -571,6 +585,7 @@ static void mei_txe_hw_config(struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev); +/* Doesn't change in runtime */ dev->hbuf_depth =PAYLOAD_SIZE /4 ;
@@ -621,6 +636,7 @@ static int mei_txe_write(struct mei_device *dev,if (!mei_txe_is_input_ready (dev)) {struct mei_fw_status fw_status; +mei_fw_status (dev, &fw_status);dev_err (&dev->pdev->dev,"Input is not ready " FW_STS_FMT "\n" ,FW_STS_PRM (fw_status));
@@ -635,6 +651,7 @@ static int mei_txe_write(struct mei_device *dev, rem = length &0x3 ;if (rem >0 ) {u32 reg =0 ; +memcpy (®, &buf[length - rem], rem);mei_txe_input_payload_write (dev, i +1 , reg); }
@@ -670,6 +687,7 @@ static size_t mei_txe_hbuf_max_len(const struct mei_device *dev)static int mei_txe_hbuf_empty_slots (struct mei_device *dev) {struct mei_txe_hw *hw =to_txe_hw (dev); +return hw->slots; }
@@ -712,26 +730,29 @@ static int mei_txe_read(struct mei_device *dev, {struct mei_txe_hw *hw =to_txe_hw (dev); +u32 *reg_buf, reg; +u32 rem;u32 i; -u32 *reg_buf = (u32 *)buf; -u32 rem = len &0x3 ;if (WARN_ON (!buf || !len))return -EINVAL ; + reg_buf = (u32 *)buf; + rem = len &0x3 ; +dev_dbg (&dev->pdev->dev,"buffer-length = %lu buf[0]0x%08X\n" , len,mei_txe_out_data_read (dev,0 ));for (i =0 ; i < len /4 ; i++) {/* skip header: index starts from 1 */ -u32 reg =mei_txe_out_data_read (dev, i +1 ); + reg =mei_txe_out_data_read (dev, i +1 );dev_dbg (&dev->pdev->dev,"buf[%d] = 0x%08X\n" , i, reg); *reg_buf++ = reg; }if (rem) { -u32 reg =mei_txe_out_data_read (dev, i +1 ); + reg =mei_txe_out_data_read (dev, i +1 );memcpy (reg_buf, ®, rem); }
drivers/misc/mei/init.c +4 -2
@@ -88,6 +88,7 @@ int mei_reset(struct mei_device *dev) state != MEI_DEV_POWER_DOWN && state != MEI_DEV_POWER_UP) {struct mei_fw_status fw_status; +mei_fw_status (dev, &fw_status); dev_warn(&dev->pdev->dev, "unexpected reset: dev_state = %s " FW_STS_FMT "\n",
@@ -180,6 +181,7 @@ EXPORT_SYMBOL_GPL(mei_reset);int mei_start (struct mei_device *dev) {int ret; +mutex_lock (&dev->device_lock);/* acknowledge interrupt and stop interrupts */
@@ -344,15 +346,15 @@ EXPORT_SYMBOL_GPL(mei_write_is_idle);int mei_fw_status (struct mei_device *dev,struct mei_fw_status *fw_status) { -int i;const struct mei_fw_status *fw_src = &dev->cfg->fw_status; +int ret; +int i;if (!fw_status)return -EINVAL ; fw_status->count = fw_src->count;for (i =0 ; i < fw_src->count && i <MEI_FW_STATUS_MAX ; i++) { -int ret; ret =pci_read_config_dword (dev->pdev, fw_src->status[i], &fw_status->status[i]);if (ret)
drivers/misc/mei/nfc.c +1 -0
@@ -550,6 +550,7 @@ err:void mei_nfc_host_exit (struct mei_device *dev) {struct mei_nfc_dev *ndev = &nfc_dev; +cancel_work_sync (&ndev->init_work); }
drivers/misc/mei/pci-txe.c +1 -0
@@ -52,6 +52,7 @@ static inline void mei_txe_unset_pm_domain(struct mei_device *dev) {}static void mei_txe_pci_iounmap (struct pci_dev *pdev,struct mei_txe_hw *hw) {int i; +for (i =SEC_BAR ; i <NUM_OF_MEM_BARS ; i++) {if (hw->mem_addr[i]) {pci_iounmap (pdev, hw->mem_addr[i]);
Signature · 1 line
1.9.3
PATCH 8/10 mei: nfc: fix style warning
In reply to Tomas Winklerfix style warning:
void function return statements are not generally useful
--- drivers/misc/mei/nfc.c | 1 - 1 file changed, 1 deletion(-)
drivers/misc/mei/nfc.c +0 -1
@@ -472,7 +472,6 @@ err:mei_nfc_free (ndev);mutex_unlock (&dev->device_lock); -return ; }
Signature · 1 line
1.9.3
PATCH 9/10 mei: kill error message for allocation failure
In reply to Tomas WinklerThere is no need to log memory allocation errors as this is already done by the memory subsystem.
--- drivers/misc/mei/amthif.c | 4 +--- drivers/misc/mei/interrupt.c | 1 - drivers/misc/mei/main.c | 1 - 3 files changed, 1 insertion(+), 5 deletions(-)
drivers/misc/mei/amthif.c +1 -3
@@ -96,10 +96,8 @@ int mei_amthif_host_init(struct mei_device *dev)/* allocate storage for ME message buffer */ msg_buf =kcalloc (dev->iamthif_mtu,sizeof (unsigned char ),GFP_KERNEL ); -if (!msg_buf) { -dev_err (&dev->pdev->dev,"amthif: memory allocation for ME message buffer failed.\n" ); +if (!msg_buf)return -ENOMEM ; - } dev->iamthif_msg_buf = msg_buf;
drivers/misc/mei/interrupt.c +0 -1
@@ -126,7 +126,6 @@ static int mei_cl_irq_read_msg(struct mei_device *dev, GFP_KERNEL);if (!buffer) { -cl_err (dev, cl,"allocation failed.\n" );list_del (&cb->list);return -ENOMEM ; }
drivers/misc/mei/main.c +0 -1
@@ -377,7 +377,6 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, write_cb =mei_io_cb_init (cl, file);if (!write_cb) { -dev_err (&dev->pdev->dev,"write cb allocation failed\n" ); rets = -ENOMEM ; goto out; }
Signature · 1 line
1.9.3
PATCH 10/10 mei: move mei_hbm_hdr function from hbm.h the hbm.c
In reply to Tomas Winklermei_hbm_hder helper function is only used in hbm.c so there is no need to define it in a header file
--- drivers/misc/mei/hbm.c | 16 ++++++++++++++++ drivers/misc/mei/hbm.h | 9 --------- 2 files changed, 16 insertions(+), 9 deletions(-)
drivers/misc/mei/hbm.c +16 -0
@@ -134,6 +134,22 @@ void mei_hbm_reset(struct mei_device *dev) }/** +* mei_hbm_dr - construct hbm header +* +* @hdr: client +* @length: payload lenght +*/ + +static inline void mei_hbm_hdr (struct mei_msg_hdr *hdr,size_t length) +{ + hdr->host_addr =0 ; + hdr->me_addr =0 ; + hdr->length = length; + hdr->msg_complete =1 ; + hdr->reserved =0 ; +} + +/** * mei_hbm_cl_hdr - construct client hbm header * * @cl: client
drivers/misc/mei/hbm.h +0 -9
@@ -44,15 +44,6 @@ const char *mei_hbm_state_str(enum mei_hbm_state state);int mei_hbm_dispatch (struct mei_device *dev,struct mei_msg_hdr *hdr); -static inline void mei_hbm_hdr (struct mei_msg_hdr *hdr,size_t length) -{ - hdr->host_addr =0 ; - hdr->me_addr =0 ; - hdr->length = length; - hdr->msg_complete =1 ; - hdr->reserved =0 ; -} -void mei_hbm_idle (struct mei_device *dev);void mei_hbm_reset (struct mei_device *dev);int mei_hbm_start_req (struct mei_device *dev);
Signature · 1 line
1.9.3
Greg KH
maintainerQuoted 7 lines · Tomas Winkler
Handle ioctls in a switch statement so we can
add more commands easilySigned-off-by Tomas Winkler <[email protected]>--- drivers/misc/mei/main.c | 53 ++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 25 deletions(-)
If you resend patches, put a "v2" or something in the subject, or a "RESEND" so I know to catch the newer series. I applied the older one without seeing this one. If that's wrong, please let me know what to do to fix it up.
thanks,
greg k-h