mei: add mei_hbuf_acquire wrapper
Subsystems (2)
PATCH RESEND 1/5 mei: add mei_hbuf_acquire wrapper
A client has to acquire host buffer
before writing, we add lock like wrapper
to replace the code snippet
if (dev->hbuf_is_ready)
dev->hbuf_is_ready = false;
--- drivers/misc/mei/amthif.c | 7 +----- drivers/misc/mei/client.c | 56 ++++++++++++++++++++++++++++---------------- drivers/misc/mei/hw-me.c | 2 ++ drivers/misc/mei/hw-txe.c | 17 +++++--------- drivers/misc/mei/interrupt.c | 6 ++--- drivers/misc/mei/mei_dev.h | 2 ++ drivers/misc/mei/wd.c | 14 +++++------ 7 files changed, 57 insertions(+), 47 deletions(-)
drivers/misc/mei/amthif.c +1 -6
@@ -296,9 +296,8 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)if (ret <0 )return ret; -if (ret && dev->hbuf_is_ready) { +if (ret &&mei_hbuf_acquire (dev)) { ret =0 ; - dev->hbuf_is_ready = false;if (cb->request_buffer.size >mei_hbuf_max_len (dev)) { mei_hdr.length =mei_hbuf_max_len (dev); mei_hdr.msg_complete =0 ;
@@ -330,10 +329,6 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)list_add_tail (&cb->list, &dev->write_list.list); } }else { -if (!dev->hbuf_is_ready) -dev_dbg (&dev->pdev->dev,"host buffer is not empty" ); - -dev_dbg (&dev->pdev->dev,"No flow control credentials, so add iamthif cb to write list.\n" );list_add_tail (&cb->list, &dev->write_list.list); }return 0 ;
drivers/misc/mei/client.c +36 -20
100 lines not on this page · raw message
drivers/misc/mei/hw-me.c +2 -0
@@ -513,6 +513,8 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id) } } + dev->hbuf_is_ready =mei_hbuf_is_ready (dev); + rets =mei_irq_write_handler (dev, &complete_list); dev->hbuf_is_ready =mei_hbuf_is_ready (dev);
drivers/misc/mei/hw-txe.c +6 -11
@@ -604,7 +604,6 @@ static int mei_txe_write(struct mei_device *dev,mei_txe_input_payload_write (dev, i +1 , reg); } - dev->hbuf_is_ready = false;/* Set Input-Doorbell */ mei_txe_input_doorbell_set (hw);
@@ -982,20 +981,16 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, void *dev_id) dev->hbuf_is_ready = true;if (hw->aliveness && dev->hbuf_is_ready) { -/* if SeC did not complete reading the written data by host */ -if (!mei_txe_is_input_ready (dev)) { -dev_dbg (&dev->pdev->dev,"got Input Ready Int, but SEC_IPC_INPUT_STATUS_RDY is 0.\n" ); - goto end; - } +/* get the real register value */ + dev->hbuf_is_ready =mei_hbuf_is_ready (dev); rets =mei_irq_write_handler (dev, &complete_list); -if (rets) -dev_err (&dev->pdev->dev, -"mei_irq_write_handler ret = %d.\n" , rets); +if (rets && rets != -EMSGSIZE ) +dev_err (&dev->pdev->dev,"mei_irq_write_handler ret = %d.\n" , + rets); + dev->hbuf_is_ready =mei_hbuf_is_ready (dev); } - -mei_irq_compl_handler (dev, &complete_list); end:
drivers/misc/mei/interrupt.c +3 -3
@@ -446,10 +446,10 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)s32 slots;int ret; -if (!mei_hbuf_is_ready (dev)) { -dev_dbg (&dev->pdev->dev,"host buffer is not empty.\n" ); + +if (!mei_hbuf_acquire (dev))return 0 ; - } + slots =mei_hbuf_empty_slots (dev);if (slots <=0 )return -EMSGSIZE ;
drivers/misc/mei/mei_dev.h +2 -0
@@ -630,6 +630,8 @@ static inline int mei_count_full_read_slots(struct mei_device *dev)return dev->ops->rdbuf_full_slots (dev); } +bool mei_hbuf_acquire (struct mei_device *dev); +#if IS_ENABLED (CONFIG_DEBUG_FS )int mei_dbgfs_register (struct mei_device *dev,const char *name);void mei_dbgfs_deregister (struct mei_device *dev);
drivers/misc/mei/wd.c +7 -7
@@ -158,9 +158,8 @@ int mei_wd_stop(struct mei_device *dev)if (ret <0 ) goto out; -if (ret && dev->hbuf_is_ready) { +if (ret &&mei_hbuf_acquire (dev)) { ret =0 ; - dev->hbuf_is_ready = false;if (!mei_wd_send (dev)) { ret =mei_cl_flow_ctrl_reduce (&dev->wd_cl);
@@ -265,8 +264,8 @@ static int mei_wd_ops_stop(struct watchdog_device *wd_dev)*/ static int mei_wd_ops_ping (struct watchdog_device *wd_dev) { -int ret =0 ;struct mei_device *dev; +int ret; dev =watchdog_get_drvdata (wd_dev);if (!dev)
@@ -282,10 +281,12 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev) dev->wd_state =MEI_WD_RUNNING ; + ret =mei_cl_flow_ctrl_creds (&dev->wd_cl); +if (ret <0 ) + goto end;/* Check if we can send the ping to HW*/ -if (dev->hbuf_is_ready &&mei_cl_flow_ctrl_creds (&dev->wd_cl) >0 ) { +if (ret &&mei_hbuf_acquire (dev)) { - dev->hbuf_is_ready = false;dev_dbg (&dev->pdev->dev,"wd: sending ping\n" );if (mei_wd_send (dev)) {
@@ -295,8 +296,7 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev) }if (mei_cl_flow_ctrl_reduce (&dev->wd_cl)) { -dev_err (&dev->pdev->dev, -"wd: mei_cl_flow_ctrl_reduce() failed.\n" ); +dev_err (&dev->pdev->dev,"wd: mei_cl_flow_ctrl_reduce() failed.\n" ); ret = -EIO ; goto end; }
Signature · 1 line
1.8.5.3
PATCH RESEND 2/5 mei: revamp writing slot counting
Since txe use doorbell and not circular buffer
we have to cheat in write slot counting, txe always consume all the slots upon write. In order for it to work we need to track slots using mei_hbuf_empty_slots() instead of tracking it in mei layer
--- drivers/misc/mei/amthif.c | 19 ++++++----- drivers/misc/mei/client.c | 19 +++++------ drivers/misc/mei/client.h | 4 +-- drivers/misc/mei/hw-me.c | 2 +- drivers/misc/mei/hw-txe.c | 21 +++++++----- drivers/misc/mei/hw-txe.h | 1 + drivers/misc/mei/interrupt.c | 78 +++++++++++++++++--------------------------- drivers/misc/mei/mei_dev.h | 4 +-- 8 files changed, 68 insertions(+), 80 deletions(-)
drivers/misc/mei/amthif.c +10 -9
@@ -436,23 +436,23 @@ unsigned int mei_amthif_poll(struct mei_device *dev,/** -* mei_amthif_irq_write_completed - processes completed iamthif operation. +* mei_amthif_irq_write - write iamthif command in irq thread context. * * @dev: the device structure. -* @slots: free slots. * @cb_pos: callback block. * @cl: private data of the file object. * @cmpl_list: complete list. * * returns 0, OK; otherwise, error. */ -int mei_amthif_irq_write_complete (struct mei_cl *cl,struct mei_cl_cb *cb, -s32 *slots,struct mei_cl_cb *cmpl_list) +int mei_amthif_irq_write (struct mei_cl *cl,struct mei_cl_cb *cb, +struct mei_cl_cb *cmpl_list) {struct mei_device *dev = cl->dev;struct mei_msg_hdr mei_hdr;size_t len = dev->iamthif_msg_buf_size - dev->iamthif_msg_buf_index;u32 msg_slots =mei_data2slots (len); +int slots;int rets; rets =mei_cl_flow_ctrl_creds (cl);
@@ -469,13 +469,15 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb, mei_hdr.reserved =0 ; mei_hdr.internal =0 ; -if (*slots >= msg_slots) { + slots =mei_hbuf_empty_slots (dev); + +if (slots >= msg_slots) { mei_hdr.length = len; mei_hdr.msg_complete =1 ;/* Split the message only if we can write the whole host buffer */ - }else if (*slots == dev->hbuf_depth) { - msg_slots = *slots; - len = (*slots *sizeof (u32)) -sizeof (struct mei_msg_hdr ); + }else if (slots == dev->hbuf_depth) { + msg_slots = slots; + len = (slots *sizeof (u32)) -sizeof (struct mei_msg_hdr ); mei_hdr.length = len; mei_hdr.msg_complete =0 ; }else {
@@ -485,7 +487,6 @@ int mei_amthif_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,dev_dbg (&dev->pdev->dev,MEI_HDR_FMT ,MEI_HDR_PRM (&mei_hdr)); - *slots -= msg_slots; rets =mei_write_message (dev, &mei_hdr, dev->iamthif_msg_buf + dev->iamthif_msg_buf_index);if (rets) {
drivers/misc/mei/client.c +9 -10
@@ -698,27 +698,26 @@ err: }/** -* mei_cl_irq_write_complete - write a message to device +* mei_cl_irq_write - write a message to device * from the interrupt thread context * * @cl: client * @cb: callback block. -* @slots: free slots. * @cmpl_list: complete list. * * returns 0, OK; otherwise error. */ -int mei_cl_irq_write_complete (struct mei_cl *cl,struct mei_cl_cb *cb, -s32 *slots,struct mei_cl_cb *cmpl_list) +int mei_cl_irq_write (struct mei_cl *cl,struct mei_cl_cb *cb, +struct mei_cl_cb *cmpl_list) {struct mei_device *dev;struct mei_msg_data *buf;struct mei_msg_hdr mei_hdr;size_t len;u32 msg_slots; +int slots;int rets; -if (WARN_ON (!cl || !cl->dev))return -ENODEV ;
@@ -735,6 +734,7 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,return 0 ; } + slots =mei_hbuf_empty_slots (dev); len = buf->size - cb->buf_idx; msg_slots =mei_data2slots (len);
@@ -743,13 +743,13 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb, mei_hdr.reserved =0 ; mei_hdr.internal = cb->internal; -if (*slots >= msg_slots) { +if (slots >= msg_slots) { mei_hdr.length = len; mei_hdr.msg_complete =1 ;/* Split the message only if we can write the whole host buffer */ - }else if (*slots == dev->hbuf_depth) { - msg_slots = *slots; - len = (*slots *sizeof (u32)) -sizeof (struct mei_msg_hdr ); + }else if (slots == dev->hbuf_depth) { + msg_slots = slots; + len = (slots *sizeof (u32)) -sizeof (struct mei_msg_hdr ); mei_hdr.length = len; mei_hdr.msg_complete =0 ; }else {
@@ -760,7 +760,6 @@ int mei_cl_irq_write_complete(struct mei_cl *cl, struct mei_cl_cb *cb,cl_dbg (dev, cl,"buf: size = %d idx = %lu\n" , cb->request_buffer.size, cb->buf_idx); - *slots -= msg_slots; rets =mei_write_message (dev, &mei_hdr, buf->data + cb->buf_idx);if (rets) { cl->status = rets;
drivers/misc/mei/client.h +2 -2
@@ -102,8 +102,8 @@ int mei_cl_disconnect(struct mei_cl *cl);int mei_cl_connect (struct mei_cl *cl,struct file *file);int mei_cl_read_start (struct mei_cl *cl,size_t length);int mei_cl_write (struct mei_cl *cl,struct mei_cl_cb *cb,bool blocking); -int mei_cl_irq_write_complete (struct mei_cl *cl,struct mei_cl_cb *cb, -s32 *slots,struct mei_cl_cb *cmpl_list); +int mei_cl_irq_write (struct mei_cl *cl,struct mei_cl_cb *cb, +struct mei_cl_cb *cmpl_list);void mei_cl_complete (struct mei_cl *cl,struct mei_cl_cb *cb);
drivers/misc/mei/hw-me.c +1 -1
@@ -354,7 +354,7 @@ static int mei_me_write_message(struct mei_device *dev, dw_cnt =mei_data2slots (length);if (empty_slots <0 || dw_cnt > empty_slots) -return -EIO ; +return -EMSGSIZE ;mei_me_reg_write (hw,H_CB_WW , *((u32 *) header));
drivers/misc/mei/hw-txe.c +13 -8
@@ -565,7 +565,9 @@ static int mei_txe_write(struct mei_device *dev,struct mei_txe_hw *hw =to_txe_hw (dev);unsigned long rem;unsigned long length; +int slots = dev->hbuf_depth;u32 *reg_buf = (u32 *)buf; +u32 dw_cnt;int i;if (WARN_ON (!header || !buf))
@@ -575,11 +577,9 @@ static int mei_txe_write(struct mei_device *dev,dev_dbg (&dev->pdev->dev,MEI_HDR_FMT ,MEI_HDR_PRM (header)); -if ((length +sizeof (struct mei_msg_hdr )) >PAYLOAD_SIZE ) { -dev_err (&dev->pdev->dev,"write length exceeded = %ld > %d\n" , - length +sizeof (struct mei_msg_hdr ),PAYLOAD_SIZE ); -return -ERANGE ; - } + dw_cnt =mei_data2slots (length); +if (dw_cnt > slots) +return -EMSGSIZE ;if (WARN (!hw->aliveness,"txe write: aliveness not asserted\n" ))return -EAGAIN ;
@@ -604,6 +604,9 @@ static int mei_txe_write(struct mei_device *dev,mei_txe_input_payload_write (dev, i +1 , reg); } +/* after each write the whole buffer is consumed */ + hw->slots =0 ; +/* Set Input-Doorbell */ mei_txe_input_doorbell_set (hw);
@@ -631,7 +634,8 @@ static size_t mei_txe_hbuf_max_len(const struct mei_device *dev)*/ static int mei_txe_hbuf_empty_slots (struct mei_device *dev) { -return dev->hbuf_depth; +struct mei_txe_hw *hw =to_txe_hw (dev); +return hw->slots; }/**
@@ -977,11 +981,12 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, void *dev_id) } }/* Input Ready: Detection if host can write to SeC */ -if (test_and_clear_bit (TXE_INTR_IN_READY_BIT , &hw->intr_cause)) +if (test_and_clear_bit (TXE_INTR_IN_READY_BIT , &hw->intr_cause)) { dev->hbuf_is_ready = true; + hw->slots = dev->hbuf_depth; + }if (hw->aliveness && dev->hbuf_is_ready) { -/* get the real register value */ dev->hbuf_is_ready =mei_hbuf_is_ready (dev); rets =mei_irq_write_handler (dev, &complete_list);
drivers/misc/mei/hw-txe.h +1 -0
@@ -44,6 +44,7 @@ struct mei_txe_hw {void __iomem *mem_addr[NUM_OF_MEM_BARS ];u32 aliveness;u32 readiness; +u32 slots;wait_queue_head_t wait_aliveness;bool recvd_aliveness;
drivers/misc/mei/interrupt.c +30 -48
188 lines not on this page · raw message
drivers/misc/mei/mei_dev.h +2 -2
@@ -515,8 +515,8 @@ struct mei_cl_cb *mei_amthif_find_read_list_entry(struct mei_device *dev,void mei_amthif_run_next_cmd (struct mei_device *dev); -int mei_amthif_irq_write_complete (struct mei_cl *cl,struct mei_cl_cb *cb, -s32 *slots,struct mei_cl_cb *cmpl_list); +int mei_amthif_irq_write (struct mei_cl *cl,struct mei_cl_cb *cb, +struct mei_cl_cb *cmpl_list);void mei_amthif_complete (struct mei_device *dev,struct mei_cl_cb *cb); int mei_amthif_irq_read_msg(struct mei_device *dev,
Signature · 1 line
1.8.5.3
PATCH RESEND 3/5 mei: make return values consistent across the driver
In reply to Tomas WinklerFrom: Alexander Usyskin <[email protected]>
1. Propagate ENOTTY to user space if the client is not present in the system
2. Use ETIME consistently on timeouts
3. Return EIO on write failures
4. Return ENODEV on recoverable device failures such as resets
--- drivers/misc/mei/amthif.c | 12 +++++------- drivers/misc/mei/client.c | 26 ++++++++++++++------------ drivers/misc/mei/hbm.c | 2 +- drivers/misc/mei/hw-me.c | 8 ++++---- drivers/misc/mei/interrupt.c | 4 ++-- drivers/misc/mei/main.c | 2 +- drivers/misc/mei/nfc.c | 6 +++--- drivers/misc/mei/wd.c | 6 +++--- 8 files changed, 33 insertions(+), 33 deletions(-)
drivers/misc/mei/amthif.c +5 -7
@@ -78,10 +78,9 @@ int mei_amthif_host_init(struct mei_device *dev) i =mei_me_cl_by_uuid (dev, &mei_amthif_guid);if (i <0 ) { - ret = i;dev_info (&dev->pdev->dev, -"amthif: failed to find the client %d\n" , ret); -return ret; +"amthif: failed to find the client %d\n" , i); +return -ENOTTY ; } cl->me_client_id = dev->me_clients[i].client_id;
@@ -174,14 +173,13 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,/* Only possible if we are in timeout */ if (!cl || cl != &dev->iamthif_cl) {dev_dbg (&dev->pdev->dev,"bad file ext.\n" ); -return -ETIMEDOUT ; +return -ETIME ; } i =mei_me_cl_by_id (dev, dev->iamthif_cl.me_client_id); -if (i <0 ) {dev_dbg (&dev->pdev->dev,"amthif client not found.\n" ); -return -ENODEV ; +return -ENOTTY ; }dev_dbg (&dev->pdev->dev,"checking amthif data\n" ); cb =mei_amthif_find_read_list_entry (dev, file);
@@ -222,7 +220,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,dev_dbg (&dev->pdev->dev,"amthif Time out\n" );/* 15 sec for the message has expired */ list_del (&cb->list); - rets = -ETIMEDOUT ; + rets = -ETIME ; goto free; } }
drivers/misc/mei/client.c +14 -12
@@ -664,7 +664,7 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length) i =mei_me_cl_by_id (dev, cl->me_client_id);if (i <0 ) {cl_err (dev, cl,"no such me client %d\n" , cl->me_client_id); -return -ENODEV ; +return -ENOTTY ; } cb =mei_io_cb_init (cl,NULL );
@@ -852,13 +852,12 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking) cl->writing_state =MEI_WRITING ; cb->buf_idx = mei_hdr.length; - rets = buf->size; out:if (mei_hdr.msg_complete) { -if (mei_cl_flow_ctrl_reduce (cl)) { - rets = -ENODEV ; + rets =mei_cl_flow_ctrl_reduce (cl); +if (rets <0 ) goto err; - } +list_add_tail (&cb->list, &dev->write_waiting_list.list); }else {list_add_tail (&cb->list, &dev->write_list.list);
@@ -868,15 +867,18 @@ out:if (blocking && cl->writing_state !=MEI_WRITE_COMPLETE ) {mutex_unlock (&dev->device_lock); -if (wait_event_interruptible (cl->tx_wait, - cl->writing_state ==MEI_WRITE_COMPLETE )) { -if (signal_pending (current)) - rets = -EINTR ; -else - rets = -ERESTARTSYS ; - } + rets =wait_event_interruptible (cl->tx_wait, + cl->writing_state ==MEI_WRITE_COMPLETE );mutex_lock (&dev->device_lock); +/* wait_event_interruptible returns -ERESTARTSYS */ +if (rets) { +if (signal_pending (current)) + rets = -EINTR ; + goto err; + } } + + rets = buf->size; err:return rets; }
drivers/misc/mei/hbm.c +1 -1
@@ -161,7 +161,7 @@ int mei_hbm_start_wait(struct mei_device *dev)if (ret <=0 && (dev->hbm_state <=MEI_HBM_START )) { dev->hbm_state =MEI_HBM_IDLE ;dev_err (&dev->pdev->dev,"waiting for mei start failed\n" ); -return -ETIMEDOUT ; +return -ETIME ; }return 0 ; }
drivers/misc/mei/hw-me.c +4 -4
@@ -244,7 +244,7 @@ static int mei_me_hw_ready_wait(struct mei_device *dev)mutex_lock (&dev->device_lock);if (!err && !dev->recvd_hw_ready) {if (!err) - err = -ETIMEDOUT ; + err = -ETIME ;dev_err (&dev->pdev->dev,"wait hw ready failed. status = %d\n" , err);return err;
@@ -303,7 +303,7 @@ static bool mei_me_hbuf_is_empty(struct mei_device *dev)* * @dev: the device structure * -* returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count +* returns -EOVERFLOW if overflow, otherwise empty slots count */ static int mei_me_hbuf_empty_slots (struct mei_device *dev) {
@@ -326,7 +326,7 @@ static size_t mei_me_hbuf_max_len(const struct mei_device *dev)/** -* mei_write_message - writes a message to mei device. +* mei_me_write_message - writes a message to mei device. * * @dev: the device structure * @header: mei HECI header of message
@@ -381,7 +381,7 @@ static int mei_me_write_message(struct mei_device *dev,* * @dev: the device structure * -* returns -1(ESLOTS_OVERFLOW) if overflow, otherwise filled slots count +* returns -EOVERFLOW if overflow, otherwise filled slots count */ static int mei_me_count_full_read_slots (struct mei_device *dev) {
drivers/misc/mei/interrupt.c +2 -2
@@ -350,7 +350,7 @@ int mei_irq_read_handler(struct mei_device *dev,dev_err (&dev->pdev->dev,"less data available than length=%08x.\n" , *slots);/* we can't read the message */ - ret = -ERANGE ; + ret = -EBADMSG ; goto end; }
@@ -483,7 +483,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)if (mei_wd_send (dev))dev_dbg (&dev->pdev->dev,"wd send failed.\n" );else if (mei_cl_flow_ctrl_reduce (&dev->wd_cl)) -return -ENODEV ; +return -EIO ; dev->wd_pending = false; } }
drivers/misc/mei/main.c +1 -1
@@ -340,7 +340,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, id =mei_me_cl_by_id (dev, cl->me_client_id);if (id <0 ) { - rets = -ENODEV ; + rets = -ENOTTY ; goto out; }
drivers/misc/mei/nfc.c +3 -3
@@ -364,7 +364,7 @@ static int mei_nfc_send(struct mei_cl_device *cldev, u8 *buf, size_t length)if (!wait_event_interruptible_timeout (ndev->send_wq, ndev->recv_req_id == ndev->req_id,HZ )) {dev_err (&dev->pdev->dev,"NFC MEI command timeout\n" ); - err = -ETIMEDOUT ; + err = -ETIME ; }else { ndev->req_id++; }
@@ -502,7 +502,7 @@ int mei_nfc_host_init(struct mei_device *dev) i =mei_me_cl_by_uuid (dev, &mei_nfc_info_guid);if (i <0 ) {dev_info (&dev->pdev->dev,"nfc: failed to find the client\n" ); - ret = -ENOENT ; + ret = -ENOTTY ; goto err; }
@@ -520,7 +520,7 @@ int mei_nfc_host_init(struct mei_device *dev) i =mei_me_cl_by_uuid (dev, &mei_nfc_guid);if (i <0 ) {dev_info (&dev->pdev->dev,"nfc: failed to find the client\n" ); - ret = -ENOENT ; + ret = -ENOTTY ; goto err; }
drivers/misc/mei/wd.c +3 -3
@@ -53,7 +53,7 @@ static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)* * @dev: the device structure * -* returns -ENENT if wd client cannot be found +* returns -ENOTTY if wd client cannot be found * -EIO if write has failed * 0 on success */
@@ -73,7 +73,7 @@ int mei_wd_host_init(struct mei_device *dev) id =mei_me_cl_by_uuid (dev, &mei_wd_guid);if (id <0 ) {dev_info (&dev->pdev->dev,"wd: failed to find the client\n" ); -return id; +return -ENOTTY ; } cl->me_client_id = dev->me_clients[id].client_id;
@@ -185,7 +185,7 @@ int mei_wd_stop(struct mei_device *dev) ret =0 ; }else {if (!ret) - ret = -ETIMEDOUT ; + ret = -ETIME ;dev_warn (&dev->pdev->dev,"wd: stop failed to complete ret=%d.\n" , ret); }
Signature · 1 line
1.8.5.3
PATCH RESEND 4/5 mei: wd: simplify wd_send command
In reply to Tomas WinklerAdd reduce credits to wd_send to remove code
repetition and simplify error handling
--- drivers/misc/mei/interrupt.c | 7 +++--- drivers/misc/mei/wd.c | 52 +++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 29 deletions(-)
drivers/misc/mei/interrupt.c +3 -4
@@ -480,10 +480,9 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)if (mei_cl_is_connected (&dev->wd_cl)) {if (dev->wd_pending &&mei_cl_flow_ctrl_creds (&dev->wd_cl) >0 ) { -if (mei_wd_send (dev)) -dev_dbg (&dev->pdev->dev,"wd send failed.\n" ); -else if (mei_cl_flow_ctrl_reduce (&dev->wd_cl)) -return -EIO ; + ret =mei_wd_send (dev); +if (ret) +return ret; dev->wd_pending = false; } }
drivers/misc/mei/wd.c +27 -25
84 lines not on this page · raw message
Signature · 1 line
1.8.5.3
PATCH RESEND 5/5 mei: wd: fix stop completion failure
In reply to Tomas WinklerWhile running Documentation/watchdog/src/watchdog-simple.c and quiting by Ctrl-C, fallowing error is displayed:mei_me 0000:00:16.0: wd: stop failed to complete ret=-512.
The whatchdog core framework is not able to propagate -ESYSRESTART or -EINTR. Also There is no much sense in restarting the close system call so instead of using wait_event_interruptible_timeout we can use wait_event_timeout with reasonable 10 msecs timeout.
--- drivers/misc/mei/interrupt.c | 2 +- drivers/misc/mei/wd.c | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-)
drivers/misc/mei/interrupt.c +1 -1
@@ -474,7 +474,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)if (dev->wd_state ==MEI_WD_STOPPING ) { dev->wd_state =MEI_WD_IDLE ; -wake_up_interruptible (&dev->wait_stop_wd); +wake_up (&dev->wait_stop_wd); }if (mei_cl_is_connected (&dev->wd_cl)) {
drivers/misc/mei/wd.c +17 -15
@@ -155,9 +155,11 @@ int mei_wd_send(struct mei_device *dev)* @dev: the device structure * @preserve: indicate if to keep the timeout value * -* returns 0 if success, -* -EIO when message send fails +* returns 0 if success +* on error: +* -EIO when message send fails * -EINVAL when invalid message is to be sent +* -ETIME on message timeout */ int mei_wd_stop (struct mei_device *dev) {
@@ -173,12 +175,12 @@ int mei_wd_stop(struct mei_device *dev) ret =mei_cl_flow_ctrl_creds (&dev->wd_cl);if (ret <0 ) - goto out; + goto err;if (ret &&mei_hbuf_acquire (dev)) { ret =mei_wd_send (dev);if (ret) - goto out; + goto err; dev->wd_pending = false; }else { dev->wd_pending = true;
@@ -186,21 +188,21 @@ int mei_wd_stop(struct mei_device *dev)mutex_unlock (&dev->device_lock); - ret =wait_event_interruptible_timeout (dev->wait_stop_wd, - dev->wd_state ==MEI_WD_IDLE , -msecs_to_jiffies (MEI_WD_STOP_TIMEOUT )); + ret =wait_event_timeout (dev->wait_stop_wd, + dev->wd_state ==MEI_WD_IDLE , +msecs_to_jiffies (MEI_WD_STOP_TIMEOUT ));mutex_lock (&dev->device_lock); -if (dev->wd_state ==MEI_WD_IDLE ) { -dev_dbg (&dev->pdev->dev,"wd: stop completed ret=%d.\n" , ret); - ret =0 ; - }else { -if (!ret) - ret = -ETIME ; +if (dev->wd_state !=MEI_WD_IDLE ) { +/* timeout */ + ret = -ETIME ;dev_warn (&dev->pdev->dev,"wd: stop failed to complete ret=%d.\n" , ret); + goto err; } - -out: +dev_dbg (&dev->pdev->dev,"wd: stop completed after %u msec\n" , +MEI_WD_STOP_TIMEOUT -jiffies_to_msecs (ret)); +return 0 ; +err:return ret; }
Signature · 1 line
1.8.5.3