MEI restructuring
Subsystems (2)
cover MEI restructuring
This series contains some initial restructuring of the MEI driver. It tries to make cleaner lines between ME hardware, Host Bust Messaging, and Client Management layers. For sake of that we have moved functions around and renamed some files.
Tomas Winkler (21):
mei: add new hbm.h header to export hbm protocol
mei: move client functions to client.c
mei: fix client functions names
mei: implement mei_cl_connect function
mei: move watchdog prototypes to mei_dev.h from interface.h
mei: rename interface to hw-me
mei: drop read_pending member form struct mei_cl
mei: move me client storage allocation to hbm.c
mei: mei_dev.h - remove prototypes of dropped functions
mei: rename remaining amthi strings to amthif
mei: normalize me host client linking routines
mei: move MEI_IAMTHIF_IDLE to amthif host init function
mei: hw-me.c fix kernel doc
mei: remove write only need_reset member of struct mei_device
mei: remove mei_csr_clear_his prototype
mei: don't use cached value for hcsr in mei_hw_reset
mei: use non cached hcsr for interrupt enablement
mei: abstract host and device readieness
mei: reenable mei_hcsr_set abstraction
mei: make host csr and me csr internal to hw-me
mei: move work initialization to mei_device_init
drivers/misc/mei/Makefile | 4 +-
drivers/misc/mei/amthif.c | 112 +++--
drivers/misc/mei/client.c | 678 +++++++++++++++++++++++++++++
drivers/misc/mei/client.h | 97 ++++
drivers/misc/mei/hbm.c | 42 ++-
drivers/misc/mei/hbm.h | 39 ++
drivers/misc/mei/hw-me-regs.h | 167 +++++++
drivers/misc/mei/{interface.c => hw-me.c} | 241 +++++------
drivers/misc/mei/hw-me.h | 181 ++-------
drivers/misc/mei/init.c | 405 ++----------------
drivers/misc/mei/interface.h | 83 ----
drivers/misc/mei/interrupt.c | 37 +-
drivers/misc/mei/iorw.c | 366 ----------------
drivers/misc/mei/main.c | 184 ++++++---
drivers/misc/mei/mei_dev.h | 115 ++----
drivers/misc/mei/wd.c | 49 ++-
16 files changed, 1468 insertions(+), 1332 deletions(-)
create mode 100644 drivers/misc/mei/client.c
create mode 100644 drivers/misc/mei/client.h
create mode 100644 drivers/misc/mei/hbm.h
create mode 100644 drivers/misc/mei/hw-me-regs.h
rename drivers/misc/mei/{interface.c => hw-me.c} (68%)
delete mode 100644 drivers/misc/mei/interface.h
delete mode 100644 drivers/misc/mei/iorw.cSignature · 1 line
1.7.4.4
PATCH 1/21 mei: add new hbm.h header to export hbm protocol
hbm.h provides access host bus messaging functionality for other MEI layers
--- drivers/misc/mei/amthif.c | 1 + drivers/misc/mei/hbm.c | 1 + drivers/misc/mei/hbm.h | 39 +++++++++++++++++++++++++++++++++++++++ drivers/misc/mei/init.c | 1 + drivers/misc/mei/interface.h | 7 ++----- drivers/misc/mei/interrupt.c | 1 + drivers/misc/mei/iorw.c | 1 + drivers/misc/mei/mei_dev.h | 10 ---------- drivers/misc/mei/wd.c | 1 + 9 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 drivers/misc/mei/hbm.h
drivers/misc/mei/amthif.c +1 -0
@@ -34,6 +34,7 @@#include <linux/mei.h> #include "mei_dev.h" +#include "hbm.h" #include "interface.h" const uuid_le mei_amthi_guid = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac,
drivers/misc/mei/hbm.c +1 -0
@@ -20,6 +20,7 @@#include <linux/mei.h> #include "mei_dev.h" +#include "hbm.h" #include "interface.h" /**
drivers/misc/mei/hbm.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* +* Intel Management Engine Interface (Intel MEI) Linux driver +* Copyright (c) 2003-2012, Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +*/ + +#ifndef _MEI_HBM_H_ +#define _MEI_HBM_H_ + +void 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_start_req (struct mei_device *dev); + +int mei_hbm_cl_flow_control_req (struct mei_device *dev,struct mei_cl *cl); +int mei_hbm_cl_disconnect_req (struct mei_device *dev,struct mei_cl *cl); +int mei_hbm_cl_connect_req (struct mei_device *dev,struct mei_cl *cl); + + +#endif /* _MEI_HBM_H_ */ +
drivers/misc/mei/init.c +1 -0
@@ -22,6 +22,7 @@#include <linux/mei.h> #include "mei_dev.h" +#include "hbm.h" #include "interface.h" const char *mei_dev_state_str (int state)
drivers/misc/mei/interface.h +2 -5
@@ -72,12 +72,9 @@ void mei_watchdog_unregister(struct mei_device *dev);int mei_other_client_is_connecting (struct mei_device *dev,struct mei_cl *cl);int mei_flow_ctrl_reduce (struct mei_device *dev,struct mei_cl *cl); -void mei_hbm_start_req (struct mei_device *dev); +void mei_host_client_init (struct work_struct *work); + -int mei_hbm_cl_flow_control_req (struct mei_device *dev,struct mei_cl *cl); -int mei_hbm_cl_disconnect_req (struct mei_device *dev,struct mei_cl *cl); -int mei_hbm_cl_connect_req (struct mei_device *dev,struct mei_cl *cl); -void mei_host_client_init (struct work_struct *work);#endif /* _MEI_INTERFACE_H_ */
drivers/misc/mei/interrupt.c +1 -0
@@ -24,6 +24,7 @@#include <linux/mei.h> #include "mei_dev.h" +#include "hbm.h" #include "interface.h"
drivers/misc/mei/iorw.c +1 -0
@@ -36,6 +36,7 @@#include <linux/mei.h> #include "mei_dev.h" +#include "hbm.h" #include "interface.h" /**
drivers/misc/mei/mei_dev.h +0 -10
@@ -445,16 +445,6 @@ void mei_enable_interrupts(struct mei_device *dev);void mei_disable_interrupts (struct mei_device *dev); -void 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 ; -}#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d comp=%1d"#define MEI_HDR_PRM (hdr) \
drivers/misc/mei/wd.c +1 -0
@@ -24,6 +24,7 @@#include <linux/mei.h> #include "mei_dev.h" +#include "hbm.h" #include "interface.h" static const u8 mei_start_wd_params[] = {0x02 ,0x12 ,0x13 ,0x10 };
Signature · 1 line
1.7.4.4
PATCH 2/21 mei: move client functions to client.c
In reply to Tomas WinklerThis file now contains me and host client functions and also io callback helpers
We also kill iorw.c which is no longer needed
---
drivers/misc/mei/Makefile | 2 +-
drivers/misc/mei/{iorw.c => client.c} | 377 +++++++++++++++++++++++++++++++--
drivers/misc/mei/init.c | 252 ----------------------
drivers/misc/mei/interface.c | 96 ---------
4 files changed, 361 insertions(+), 366 deletions(-)
rename drivers/misc/mei/{iorw.c => client.c} (50%)drivers/misc/mei/Makefile +1 -1
@@ -7,7 +7,7 @@ mei-objs := init.o mei-objs += hbm.o mei-objs += interrupt.o mei-objs += interface.o -mei-objs += iorw.o mei-objs += main.o mei-objs += amthif.o mei-objs += wd.o +mei-objs += client.o
drivers/misc/mei/client.c renamed from drivers/misc/mei/iorw.c +360 -17
415 lines not on this page · raw message
drivers/misc/mei/init.c +0 -252
269 lines not on this page · raw message
drivers/misc/mei/interface.c +0 -96
99 lines not on this page · raw message
Signature · 1 line
1.7.4.4
PATCH 3/21 mei: fix client functions names
In reply to Tomas WinklerUse common prefix for function names:
mei_cl_ - for host clients mei_me_ - for me clients mei_io_ - for io callback functions
Because mei_cl holds mei_device back pointer
we can also drop the dev argument from the client
functions
add client.h header to export the clients API
--- drivers/misc/mei/amthif.c | 9 +- drivers/misc/mei/client.c | 221 ++++++++++++++++++++++++++---------------- drivers/misc/mei/client.h | 97 ++++++++++++++++++ drivers/misc/mei/init.c | 6 +- drivers/misc/mei/interface.h | 8 -- drivers/misc/mei/interrupt.c | 11 +- drivers/misc/mei/main.c | 47 +++------- drivers/misc/mei/mei_dev.h | 53 ---------- drivers/misc/mei/wd.c | 13 ++- 9 files changed, 267 insertions(+), 198 deletions(-) create mode 100644 drivers/misc/mei/client.h
drivers/misc/mei/amthif.c +5 -4
@@ -36,6 +36,7 @@#include "mei_dev.h" #include "hbm.h" #include "interface.h" +#include "client.h" const uuid_le mei_amthi_guid = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac, 0xa8, 0x46, 0xe0, 0xff, 0x65,
@@ -73,7 +74,7 @@ void mei_amthif_host_init(struct mei_device *dev) dev->iamthif_cl.state =MEI_FILE_DISCONNECTED ;/* find ME amthi client */ - i =mei_me_cl_link (dev, &dev->iamthif_cl, + i =mei_cl_link_me (&dev->iamthif_cl, &mei_amthi_guid,MEI_IAMTHIF_HOST_CLIENT_ID );if (i <0 ) {dev_info (&dev->pdev->dev,"failed to find iamthif client.\n" );
@@ -280,7 +281,7 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)memcpy (dev->iamthif_msg_buf, cb->request_buffer.data, cb->request_buffer.size); - ret =mei_flow_ctrl_creds (dev, &dev->iamthif_cl); + ret =mei_cl_flow_ctrl_creds (&dev->iamthif_cl);if (ret <0 )return ret;
@@ -304,7 +305,7 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)return -ENODEV ;if (mei_hdr.msg_complete) { -if (mei_flow_ctrl_reduce (dev, &dev->iamthif_cl)) +if (mei_cl_flow_ctrl_reduce (&dev->iamthif_cl))return -ENODEV ; dev->iamthif_flow_control_pending = true; dev->iamthif_state =MEI_IAMTHIF_FLOW_CONTROL ;
@@ -467,7 +468,7 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,return -ENODEV ; } -if (mei_flow_ctrl_reduce (dev, cl)) +if (mei_cl_flow_ctrl_reduce (cl))return -ENODEV ; dev->iamthif_msg_buf_index += mei_hdr.length;
drivers/misc/mei/client.c +136 -85
366 lines not on this page · raw message
drivers/misc/mei/client.h new file +97 -0
97 lines not on this page · raw message
drivers/misc/mei/init.c +3 -3
@@ -23,6 +23,7 @@#include "mei_dev.h" #include "interface.h" +#include "client.h" const char *mei_dev_state_str (int state) {
@@ -241,9 +242,8 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) }/* remove entry if already in list */ dev_dbg (&dev->pdev->dev,"remove iamthif and wd from the file list.\n" ); -mei_me_cl_unlink (dev, &dev->wd_cl); - -mei_me_cl_unlink (dev, &dev->iamthif_cl); +mei_cl_unlink (&dev->wd_cl); +mei_cl_unlink (&dev->iamthif_cl);mei_amthif_reset_params (dev);memset (&dev->wr_ext_msg,0 ,sizeof (dev->wr_ext_msg));
drivers/misc/mei/interface.h +0 -8
@@ -50,7 +50,6 @@ static inline unsigned char mei_data2slots(size_t length)int mei_count_full_read_slots (struct mei_device *dev); -int mei_flow_ctrl_creds (struct mei_device *dev,struct mei_cl *cl);
@@ -69,12 +68,5 @@ void mei_watchdog_register(struct mei_device *dev);*/ void mei_watchdog_unregister (struct mei_device *dev); -int mei_other_client_is_connecting (struct mei_device *dev,struct mei_cl *cl); -int mei_flow_ctrl_reduce (struct mei_device *dev,struct mei_cl *cl); - -void mei_host_client_init (struct work_struct *work); - - -#endif /* _MEI_INTERFACE_H_ */
drivers/misc/mei/interrupt.c +6 -5
@@ -26,6 +26,7 @@#include "mei_dev.h" #include "hbm.h" #include "interface.h" +#include "client.h" /**
@@ -297,7 +298,7 @@ static int mei_irq_thread_write_complete(struct mei_device *dev, s32 *slots,return -ENODEV ; } -if (mei_flow_ctrl_reduce (dev, cl)) +if (mei_cl_flow_ctrl_reduce (cl))return -ENODEV ; cl->status =0 ;
@@ -478,10 +479,10 @@ static int mei_irq_thread_write_handler(struct mei_device *dev, }if (dev->dev_state ==MEI_DEV_ENABLED ) {if (dev->wd_pending && -mei_flow_ctrl_creds (dev, &dev->wd_cl) >0 ) { +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_flow_ctrl_reduce (dev, &dev->wd_cl)) +else if (mei_cl_flow_ctrl_reduce (&dev->wd_cl))return -ENODEV ; dev->wd_pending = false;
@@ -520,7 +521,7 @@ static int mei_irq_thread_write_handler(struct mei_device *dev,break ;case MEI_FOP_IOCTL :/* connect message */ -if (mei_other_client_is_connecting (dev, cl)) +if (mei_cl_is_other_connecting (cl))continue ; ret =_mei_irq_thread_ioctl (dev, &slots, pos, cl, cmpl_list);
@@ -540,7 +541,7 @@ static int mei_irq_thread_write_handler(struct mei_device *dev, cl = pos->cl;if (cl ==NULL )continue ; -if (mei_flow_ctrl_creds (dev, cl) <=0 ) { +if (mei_cl_flow_ctrl_creds (cl) <=0 ) {dev_dbg (&dev->pdev->dev,"No flow control credentials for client %d, not sending.\n" , cl->host_client_id);
drivers/misc/mei/main.c +13 -34
120 lines not on this page · raw message
drivers/misc/mei/mei_dev.h +0 -53
68 lines not on this page · raw message
drivers/misc/mei/wd.c +7 -6
@@ -26,6 +26,7 @@#include "mei_dev.h" #include "hbm.h" #include "interface.h" +#include "client.h" static const u8 mei_start_wd_params[] = {0x02 ,0x12 ,0x13 ,0x10 };static const u8 mei_stop_wd_params[] = {0x02 ,0x02 ,0x14 ,0x10 };
@@ -72,7 +73,7 @@ int mei_wd_host_init(struct mei_device *dev) dev->wd_state =MEI_WD_IDLE ;/* Connect WD ME client to the host client */ - id =mei_me_cl_link (dev, &dev->wd_cl, + id =mei_cl_link_me (&dev->wd_cl, &mei_wd_guid,MEI_WD_HOST_CLIENT_ID );if (id <0 ) {
@@ -141,7 +142,7 @@ int mei_wd_stop(struct mei_device *dev) dev->wd_state =MEI_WD_STOPPING ; - ret =mei_flow_ctrl_creds (dev, &dev->wd_cl); + ret =mei_cl_flow_ctrl_creds (&dev->wd_cl);if (ret <0 ) goto out;
@@ -150,7 +151,7 @@ int mei_wd_stop(struct mei_device *dev) dev->mei_host_buffer_is_empty = false;if (!mei_wd_send (dev)) { - ret =mei_flow_ctrl_reduce (dev, &dev->wd_cl); + ret =mei_cl_flow_ctrl_reduce (&dev->wd_cl);if (ret) goto out; }else {
@@ -271,7 +272,7 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev)/* Check if we can send the ping to HW*/ if (dev->mei_host_buffer_is_empty && -mei_flow_ctrl_creds (dev, &dev->wd_cl) >0 ) { +mei_cl_flow_ctrl_creds (&dev->wd_cl) >0 ) { dev->mei_host_buffer_is_empty = false;dev_dbg (&dev->pdev->dev,"wd: sending ping\n" );
@@ -282,9 +283,9 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev) goto end; } -if (mei_flow_ctrl_reduce (dev, &dev->wd_cl)) { +if (mei_cl_flow_ctrl_reduce (&dev->wd_cl)) {dev_err (&dev->pdev->dev, -"wd: mei_flow_ctrl_reduce() failed.\n" ); +"wd: mei_cl_flow_ctrl_reduce() failed.\n" ); ret = -EIO ; goto end; }
Signature · 1 line
1.7.4.4
PATCH 4/21 mei: implement mei_cl_connect function
In reply to Tomas WinklerImplement mei_cl_connect that warps host client parts of the connection and leave the ioctl specifics in the mei_ioctl_connect_client function. Move mei_ioctl_connect_client to main.c where it belongs
--- drivers/misc/mei/client.c | 219 +++++++++++++------------------------------- drivers/misc/mei/main.c | 98 ++++++++++++++++++++ drivers/misc/mei/mei_dev.h | 5 - 3 files changed, 163 insertions(+), 159 deletions(-)
drivers/misc/mei/client.c +65 -154
@@ -461,6 +461,71 @@ bool mei_cl_is_other_connecting(struct mei_cl *cl) }/** +* mei_cl_connect - connect host clinet to the me one +* +* @cl: host client +* +* Locking: called under "dev->device_lock" lock +* +* returns 0 on success, <0 on failure. +*/ +int mei_cl_connect (struct mei_cl *cl,struct file *file) +{ +struct mei_device *dev; +struct mei_cl_cb *cb; +long timeout =mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT ); +int rets; + +if (WARN_ON (!cl || !cl->dev)) +return -ENODEV ; + + dev = cl->dev; + + cb =mei_io_cb_init (cl, file); +if (!cb) { + rets = -ENOMEM ; + goto out; + } + + cb->fop_type =MEI_FOP_IOCTL ; + +if (dev->mei_host_buffer_is_empty && + !mei_cl_is_other_connecting (cl)) { + dev->mei_host_buffer_is_empty = false; + +if (mei_hbm_cl_connect_req (dev, cl)) { + rets = -ENODEV ; + goto out; + } + cl->timer_count =MEI_CONNECT_TIMEOUT ; +list_add_tail (&cb->list, &dev->ctrl_rd_list.list); + }else { +list_add_tail (&cb->list, &dev->ctrl_wr_list.list); + } + +mutex_unlock (&dev->device_lock); + rets =wait_event_timeout (dev->wait_recvd_msg, + (cl->state ==MEI_FILE_CONNECTED || + cl->state ==MEI_FILE_DISCONNECTED ), + timeout *HZ ); +mutex_lock (&dev->device_lock); + +if (cl->state !=MEI_FILE_CONNECTED ) { + rets = -EFAULT ; + +mei_io_list_flush (&dev->ctrl_rd_list, cl); +mei_io_list_flush (&dev->ctrl_wr_list, cl); + goto out; + } + + rets = cl->status; + +out: +mei_io_cb_free (cb); +return rets; +} + +/** * mei_cl_flow_ctrl_creds - checks flow_control credits for cl. * * @dev: the device structure
@@ -542,160 +607,6 @@ int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)return -ENOENT ; } - - -/** -* mei_ioctl_connect_client - the connect to fw client IOCTL function -* -* @dev: the device structure -* @data: IOCTL connect data, input and output parameters -* @file: private data of the file object -* -* Locking: called under "dev->device_lock" lock -* -* returns 0 on success, <0 on failure. -*/ -int mei_ioctl_connect_client (struct file *file, -struct mei_connect_client_data *data) -{ -struct mei_device *dev; -struct mei_cl_cb *cb; -struct mei_client *client; -struct mei_cl *cl; -long timeout =mei_secs_to_jiffies (MEI_CL_CONNECT_TIMEOUT ); -int i; -int err; -int rets; - - cl = file->private_data; -if (WARN_ON (!cl || !cl->dev)) -return -ENODEV ; - - dev = cl->dev; - -dev_dbg (&dev->pdev->dev,"mei_ioctl_connect_client() Entry\n" ); - -/* buffered ioctl cb */ - cb =mei_io_cb_init (cl, file); -if (!cb) { - rets = -ENOMEM ; - goto end; - } - - cb->fop_type =MEI_FOP_IOCTL ; - -if (dev->dev_state !=MEI_DEV_ENABLED ) { - rets = -ENODEV ; - goto end; - } -if (cl->state !=MEI_FILE_INITIALIZING && - cl->state !=MEI_FILE_DISCONNECTED ) { - rets = -EBUSY ; - goto end; - } - -/* find ME client we're trying to connect to */ - i =mei_me_cl_by_uuid (dev, &data->in_client_uuid); -if (i >=0 && !dev->me_clients[i].props.fixed_address) { - cl->me_client_id = dev->me_clients[i].client_id; - cl->state =MEI_FILE_CONNECTING ; - } - -dev_dbg (&dev->pdev->dev,"Connect to FW Client ID = %d\n" , - cl->me_client_id); -dev_dbg (&dev->pdev->dev,"FW Client - Protocol Version = %d\n" , - dev->me_clients[i].props.protocol_version); -dev_dbg (&dev->pdev->dev,"FW Client - Max Msg Len = %d\n" , - dev->me_clients[i].props.max_msg_length); - -/* if we're connecting to amthi client then we will use the -* existing connection -*/ -if (uuid_le_cmp (data->in_client_uuid, mei_amthi_guid) ==0 ) { -dev_dbg (&dev->pdev->dev,"FW Client is amthi\n" ); -if (dev->iamthif_cl.state !=MEI_FILE_CONNECTED ) { - rets = -ENODEV ; - goto end; - } -clear_bit (cl->host_client_id, dev->host_clients_map); -mei_cl_unlink (cl); - -kfree (cl); - cl =NULL ; - file->private_data = &dev->iamthif_cl; - - client = &data->out_client_properties; - client->max_msg_length = - dev->me_clients[i].props.max_msg_length; - client->protocol_version = - dev->me_clients[i].props.protocol_version; - rets = dev->iamthif_cl.status; - - goto end; - } - -if (cl->state !=MEI_FILE_CONNECTING ) { - rets = -ENODEV ; - goto end; - } - - -/* prepare the output buffer */ - client = &data->out_client_properties; - client->max_msg_length = dev->me_clients[i].props.max_msg_length; - client->protocol_version = dev->me_clients[i].props.protocol_version; -dev_dbg (&dev->pdev->dev,"Can connect?\n" ); -if (dev->mei_host_buffer_is_empty && - !mei_cl_is_other_connecting (cl)) { -dev_dbg (&dev->pdev->dev,"Sending Connect Message\n" ); - dev->mei_host_buffer_is_empty = false; -if (mei_hbm_cl_connect_req (dev, cl)) { -dev_dbg (&dev->pdev->dev,"Sending connect message - failed\n" ); - rets = -ENODEV ; - goto end; - }else { -dev_dbg (&dev->pdev->dev,"Sending connect message - succeeded\n" ); - cl->timer_count =MEI_CONNECT_TIMEOUT ; -list_add_tail (&cb->list, &dev->ctrl_rd_list.list); - } - - - }else { -dev_dbg (&dev->pdev->dev,"Queuing the connect request due to device busy\n" ); -dev_dbg (&dev->pdev->dev,"add connect cb to control write list.\n" ); -list_add_tail (&cb->list, &dev->ctrl_wr_list.list); - } -mutex_unlock (&dev->device_lock); - err =wait_event_timeout (dev->wait_recvd_msg, - (MEI_FILE_CONNECTED == cl->state || -MEI_FILE_DISCONNECTED == cl->state), timeout); - -mutex_lock (&dev->device_lock); -if (MEI_FILE_CONNECTED == cl->state) { -dev_dbg (&dev->pdev->dev,"successfully connected to FW client.\n" ); - rets = cl->status; - goto end; - }else { -dev_dbg (&dev->pdev->dev,"failed to connect to FW client.cl->state = %d.\n" , - cl->state); -if (!err) { -dev_dbg (&dev->pdev->dev, -"wait_event_interruptible_timeout failed on client" -" connect message fw response message.\n" ); - } - rets = -EFAULT ; - -mei_io_list_flush (&dev->ctrl_rd_list, cl); -mei_io_list_flush (&dev->ctrl_wr_list, cl); - goto end; - } - rets =0 ; -end: -dev_dbg (&dev->pdev->dev,"free connect cb memory." ); -mei_io_cb_free (cb); -return rets; -} -/** * mei_cl_start_read - the start read client message function. *
drivers/misc/mei/main.c +98 -0
110 lines not on this page · raw message
drivers/misc/mei/mei_dev.h +0 -5
@@ -341,11 +341,6 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id);void mei_timer (struct work_struct *work);/* -* MEI input output function prototype -*/ -int mei_ioctl_connect_client (struct file *file, -struct mei_connect_client_data *data); -/* * AMTHIF - AMT Host Interface Functions */ void mei_amthif_reset_params (struct mei_device *dev);
Signature · 1 line
1.7.4.4
PATCH 5/21 mei: move watchdog prototypes to mei_dev.h from interface.h
In reply to Tomas Winklerinterface.h contains lower layer functionality
--- drivers/misc/mei/interface.h | 20 -------------------- drivers/misc/mei/mei_dev.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 20 deletions(-)
drivers/misc/mei/interface.h +0 -20
@@ -49,24 +49,4 @@ static inline unsigned char mei_data2slots(size_t length)int mei_count_full_read_slots (struct mei_device *dev); - - - - -int mei_wd_send (struct mei_device *dev); -int mei_wd_stop (struct mei_device *dev); -int mei_wd_host_init (struct mei_device *dev); -/* -* mei_watchdog_register - Registering watchdog interface -* once we got connection to the WD Client -* @dev - mei device -*/ -void mei_watchdog_register (struct mei_device *dev); -/* -* mei_watchdog_unregister - Unregistering watchdog interface -* @dev - mei device -*/ -void mei_watchdog_unregister (struct mei_device *dev); - -#endif /* _MEI_INTERFACE_H_ */
drivers/misc/mei/mei_dev.h +17 -0
@@ -371,6 +371,23 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list, struct mei_device *dev, struct mei_msg_hdr *mei_hdr);int mei_amthif_irq_read (struct mei_device *dev,s32 *slots); + +int mei_wd_send (struct mei_device *dev); +int mei_wd_stop (struct mei_device *dev); +int mei_wd_host_init (struct mei_device *dev); +/* +* mei_watchdog_register - Registering watchdog interface +* once we got connection to the WD Client +* @dev - mei device +*/ +void mei_watchdog_register (struct mei_device *dev); +/* +* mei_watchdog_unregister - Unregistering watchdog interface +* @dev - mei device +*/ +void mei_watchdog_unregister (struct mei_device *dev); + +/* * Register Access Function */
Signature · 1 line
1.7.4.4
PATCH 6/21 mei: rename interface to hw-me
In reply to Tomas WinklerRename hw-me.h to hw-me-regs.h as this file
contains only register definitions.
Files hw-me.[ch] now contains ME hw dependant
functionality
---
drivers/misc/mei/Makefile | 2 +-
drivers/misc/mei/amthif.c | 2 +-
drivers/misc/mei/client.c | 1 -
drivers/misc/mei/hbm.c | 2 +-
drivers/misc/mei/hw-me-regs.h | 167 ++++++++++++++++++++++++++
drivers/misc/mei/{interface.c => hw-me.c} | 2 +-
drivers/misc/mei/hw-me.h | 181 +++++-----------------------
drivers/misc/mei/init.c | 1 -
drivers/misc/mei/interface.h | 52 --------
drivers/misc/mei/interrupt.c | 2 +-
drivers/misc/mei/main.c | 2 +-
drivers/misc/mei/mei_dev.h | 2 +-
drivers/misc/mei/wd.c | 2 +-
13 files changed, 208 insertions(+), 210 deletions(-)
create mode 100644 drivers/misc/mei/hw-me-regs.h
rename drivers/misc/mei/{interface.c => hw-me.c} (99%)
delete mode 100644 drivers/misc/mei/interface.hdrivers/misc/mei/Makefile +1 -1
@@ -6,7 +6,7 @@ obj-$(CONFIG_INTEL_MEI) += mei.o mei-objs := init.o mei-objs += hbm.o mei-objs += interrupt.o -mei-objs += interface.o +mei-objs += hw-me.o mei-objs += main.o mei-objs += amthif.o mei-objs += wd.o
drivers/misc/mei/amthif.c +1 -1
@@ -35,7 +35,7 @@#include "mei_dev.h" #include "hbm.h" -#include "interface.h" +#include "hw-me.h" #include "client.h" const uuid_le mei_amthi_guid = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac,
drivers/misc/mei/client.c +0 -1
@@ -23,7 +23,6 @@#include "mei_dev.h" #include "hbm.h" -#include "interface.h" #include "client.h" /**
drivers/misc/mei/hbm.c +1 -1
@@ -21,7 +21,7 @@#include "mei_dev.h" #include "hbm.h" -#include "interface.h" +#include "hw-me.h" /** * mei_hbm_cl_hdr - construct client hbm header
drivers/misc/mei/hw-me-regs.h new file +167 -0
167 lines not on this page · raw message
drivers/misc/mei/hw-me.c renamed from drivers/misc/mei/interface.c +1 -1
@@ -18,7 +18,7 @@#include <linux/mei.h> #include "mei_dev.h" -#include "interface.h" +#include "hw-me.h" /** * mei_reg_read - Reads 32bit data from the mei device
drivers/misc/mei/hw-me.h +33 -148
200 lines not on this page · raw message
drivers/misc/mei/init.c +0 -1
@@ -22,7 +22,6 @@#include <linux/mei.h> #include "mei_dev.h" -#include "interface.h" #include "client.h" const char *mei_dev_state_str (int state)
drivers/misc/mei/interface.h deleted +0 -52
52 lines not on this page · raw message
drivers/misc/mei/interrupt.c +1 -1
@@ -25,7 +25,7 @@#include "mei_dev.h" #include "hbm.h" -#include "interface.h" +#include "hw-me.h" #include "client.h"
drivers/misc/mei/main.c +1 -1
@@ -40,7 +40,7 @@#include <linux/mei.h> #include "mei_dev.h" -#include "interface.h" +#include "hw-me.h" #include "client.h" /* AMT device is a singleton on the platform */
drivers/misc/mei/mei_dev.h +1 -1
@@ -23,7 +23,7 @@#include <linux/mei.h> #include "hw.h" -#include "hw-me.h" +#include "hw-me-regs.h" /* * watch dog definition
drivers/misc/mei/wd.c +1 -1
@@ -25,7 +25,7 @@#include "mei_dev.h" #include "hbm.h" -#include "interface.h" +#include "hw-me.h" #include "client.h" static const u8 mei_start_wd_params[] = {0x02 ,0x12 ,0x13 ,0x10 };
Signature · 1 line
1.7.4.4
PATCH 7/21 mei: drop read_pending member form struct mei_cl
In reply to Tomas Winklerread_pending never changes, it is a leftover from the old code.
--- drivers/misc/mei/client.c | 2 +- drivers/misc/mei/main.c | 4 +--- drivers/misc/mei/mei_dev.h | 1 - 3 files changed, 2 insertions(+), 5 deletions(-)
drivers/misc/mei/client.c +1 -1
@@ -631,7 +631,7 @@ int mei_cl_read_start(struct mei_cl *cl)if (dev->dev_state !=MEI_DEV_ENABLED )return -ENODEV ; -if (cl->read_pending || cl->read_cb) { +if (cl->read_cb) {dev_dbg (&dev->pdev->dev,"read is pending.\n" );return -EBUSY ; }
drivers/misc/mei/main.c +1 -3
@@ -380,7 +380,6 @@ free:mei_io_cb_free (cb); cl->reading_state =MEI_IDLE ; cl->read_cb =NULL ; - cl->read_pending =0 ; out:dev_dbg (&dev->pdev->dev,"end mei read rets= %d\n" , rets);mutex_unlock (&dev->device_lock);
@@ -462,9 +461,8 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf, write_cb =NULL ; cl->reading_state =MEI_IDLE ; cl->read_cb =NULL ; - cl->read_pending =0 ; } - }else if (cl->reading_state ==MEI_IDLE && !cl->read_pending) + }else if (cl->reading_state ==MEI_IDLE ) *offset =0 ;
drivers/misc/mei/mei_dev.h +0 -1
@@ -199,7 +199,6 @@ struct mei_cl {wait_queue_head_t tx_wait;wait_queue_head_t rx_wait;wait_queue_head_t wait; -int read_pending;int status;/* ID of client connected */ u8 host_client_id;
Signature · 1 line
1.7.4.4
PATCH 8/21 mei: move me client storage allocation to hbm.c
In reply to Tomas Winklerrename function to mei_me_cl_allocate to match the current names convention: mei_hbm_me_cl_allocate
--- drivers/misc/mei/hbm.c | 39 ++++++++++++++++++++++++++++++++++++++- drivers/misc/mei/init.c | 39 --------------------------------------- drivers/misc/mei/mei_dev.h | 1 - 3 files changed, 38 insertions(+), 41 deletions(-)
drivers/misc/mei/hbm.c +38 -1
@@ -24,6 +24,43 @@#include "hw-me.h" /** +* mei_hbm_me_cl_allocate - allocates storage for me clients +* +* @dev: the device structure +* +* returns none. +*/ +static void mei_hbm_me_cl_allocate (struct mei_device *dev) +{ +struct mei_me_client *clients; +int b; + +/* count how many ME clients we have */ +for_each_set_bit (b, dev->me_clients_map,MEI_CLIENTS_MAX ) + dev->me_clients_num++; + +if (dev->me_clients_num <=0 ) +return ; + +kfree (dev->me_clients); + dev->me_clients =NULL ; + +dev_dbg (&dev->pdev->dev,"memory allocation for ME clients size=%zd.\n" , + dev->me_clients_num *sizeof (struct mei_me_client )); +/* allocate storage for ME clients representation */ + clients =kcalloc (dev->me_clients_num, +sizeof (struct mei_me_client ),GFP_KERNEL ); +if (!clients) { +dev_err (&dev->pdev->dev,"memory allocation for ME clients failed.\n" ); + dev->dev_state =MEI_DEV_RESETING ; +mei_reset (dev,1 ); +return ; + } + dev->me_clients = clients; +return ; +} + +/** * mei_hbm_cl_hdr - construct client hbm header * @cl: - client * @hbm_cmd: host bus message command
@@ -593,7 +630,7 @@ void mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) dev->init_clients_timer =0 ; dev->me_client_presentation_num =0 ; dev->me_client_index =0 ; -mei_allocate_me_clients_storage (dev); +mei_hbm_me_cl_allocate (dev); dev->init_clients_state =MEI_CLIENT_PROPERTIES_MESSAGE ;
drivers/misc/mei/init.c +0 -39
@@ -278,44 +278,5 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) } -/** -* allocate_me_clients_storage - allocates storage for me clients -* -* @dev: the device structure -* -* returns none. -*/ -void mei_allocate_me_clients_storage (struct mei_device *dev) -{ -struct mei_me_client *clients; -int b; - -/* count how many ME clients we have */ -for_each_set_bit (b, dev->me_clients_map,MEI_CLIENTS_MAX ) - dev->me_clients_num++; - -if (dev->me_clients_num <=0 ) -return ; - - -if (dev->me_clients !=NULL ) { -kfree (dev->me_clients); - dev->me_clients =NULL ; - } -dev_dbg (&dev->pdev->dev,"memory allocation for ME clients size=%zd.\n" , - dev->me_clients_num *sizeof (struct mei_me_client )); -/* allocate storage for ME clients representation */ - clients =kcalloc (dev->me_clients_num, -sizeof (struct mei_me_client ),GFP_KERNEL ); -if (!clients) { -dev_dbg (&dev->pdev->dev,"memory allocation for ME clients failed.\n" ); - dev->dev_state =MEI_DEV_RESETING ; -mei_reset (dev,1 ); -return ; - } - dev->me_clients = clients; -return ; -} -
drivers/misc/mei/mei_dev.h +0 -1
@@ -328,7 +328,6 @@ void mei_reset(struct mei_device *dev, int interrupts);int mei_hw_init (struct mei_device *dev);int mei_task_initialize_clients (void *data);int mei_initialize_clients (struct mei_device *dev); -void mei_allocate_me_clients_storage (struct mei_device *dev);
Signature · 1 line
1.7.4.4
PATCH 9/21 mei: mei_dev.h - remove prototypes of dropped functions
In reply to Tomas Winklermei_task_initialize_clients and mei_initialize_clients are no longer among us
--- drivers/misc/mei/mei_dev.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/misc/mei/mei_dev.h +0 -4
@@ -326,10 +326,6 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec)struct mei_device *mei_device_init (struct pci_dev *pdev);void mei_reset (struct mei_device *dev,int interrupts);int mei_hw_init (struct mei_device *dev); -int mei_task_initialize_clients (void *data); -int mei_initialize_clients (struct mei_device *dev); - -/* * MEI interrupt functions prototype
Signature · 1 line
1.7.4.4
PATCH 10/21 mei: rename remaining amthi strings to amthif
In reply to Tomas Winklerthe only real thing that left was mei_amthi_guid
the rest was in the strings and comments
--- drivers/misc/mei/amthif.c | 62 ++++++++++++++++++++++---------------------- drivers/misc/mei/client.c | 2 +- drivers/misc/mei/main.c | 6 ++-- drivers/misc/mei/mei_dev.h | 2 +- 4 files changed, 36 insertions(+), 36 deletions(-)
drivers/misc/mei/amthif.c +31 -31
@@ -38,9 +38,9 @@#include "hw-me.h" #include "client.h" -const uuid_le mei_amthi_guid =UUID_LE (0x12f80028 ,0xb4b7 ,0x4b2d ,0xac , -0xa8 ,0x46 ,0xe0 ,0xff ,0x65 , -0x81 ,0x4c ); +const uuid_le mei_amthif_guid =UUID_LE (0x12f80028 ,0xb4b7 ,0x4b2d , +0xac ,0xa8 ,0x46 ,0xe0 , +0xff ,0x65 ,0x81 ,0x4c );/** * mei_amthif_reset_params - initializes mei device iamthif
@@ -73,9 +73,9 @@ void mei_amthif_host_init(struct mei_device *dev)mei_cl_init (&dev->iamthif_cl, dev); dev->iamthif_cl.state =MEI_FILE_DISCONNECTED ; -/* find ME amthi client */ +/* find ME amthif client */ i =mei_cl_link_me (&dev->iamthif_cl, - &mei_amthi_guid,MEI_IAMTHIF_HOST_CLIENT_ID ); + &mei_amthif_guid,MEI_IAMTHIF_HOST_CLIENT_ID );if (i <0 ) {dev_info (&dev->pdev->dev,"failed to find iamthif client.\n" );return ;
@@ -169,10 +169,10 @@ int mei_amthif_read(struct mei_device *dev, struct file *file, i =mei_me_cl_by_id (dev, dev->iamthif_cl.me_client_id);if (i <0 ) { -dev_dbg (&dev->pdev->dev,"amthi client not found.\n" ); +dev_dbg (&dev->pdev->dev,"amthif client not found.\n" );return -ENODEV ; } -dev_dbg (&dev->pdev->dev,"checking amthi data\n" ); +dev_dbg (&dev->pdev->dev,"checking amthif data\n" ); cb =mei_amthif_find_read_list_entry (dev, file);/* Check for if we can block or not*/
@@ -180,7 +180,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,return -EAGAIN ; -dev_dbg (&dev->pdev->dev,"waiting for amthi data\n" ); +dev_dbg (&dev->pdev->dev,"waiting for amthif data\n" );while (cb ==NULL ) {/* unlock the Mutex */ mutex_unlock (&dev->device_lock);
@@ -198,17 +198,17 @@ int mei_amthif_read(struct mei_device *dev, struct file *file, } -dev_dbg (&dev->pdev->dev,"Got amthi data\n" ); +dev_dbg (&dev->pdev->dev,"Got amthif data\n" ); dev->iamthif_timer =0 ;if (cb) { timeout = cb->read_time +mei_secs_to_jiffies (MEI_IAMTHIF_READ_TIMER ); -dev_dbg (&dev->pdev->dev,"amthi timeout = %lud\n" , +dev_dbg (&dev->pdev->dev,"amthif timeout = %lud\n" , timeout);if (time_after (jiffies, timeout)) { -dev_dbg (&dev->pdev->dev,"amthi Time out\n" ); +dev_dbg (&dev->pdev->dev,"amthif Time out\n" );/* 15 sec for the message has expired */ list_del (&cb->list); rets = -ETIMEDOUT ;
@@ -228,9 +228,9 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,* remove message from deletion list */ -dev_dbg (&dev->pdev->dev,"amthi cb->response_buffer size - %d\n" , +dev_dbg (&dev->pdev->dev,"amthif cb->response_buffer size - %d\n" , cb->response_buffer.size); -dev_dbg (&dev->pdev->dev,"amthi cb->buf_idx - %lu\n" , cb->buf_idx); +dev_dbg (&dev->pdev->dev,"amthif cb->buf_idx - %lu\n" , cb->buf_idx);/* length is being turncated to PAGE_SIZE, however, * the buf_idx may point beyond */
@@ -246,7 +246,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file, } } free: -dev_dbg (&dev->pdev->dev,"free amthi cb memory.\n" ); +dev_dbg (&dev->pdev->dev,"free amthif cb memory.\n" ); *offset =0 ;mei_io_cb_free (cb); out:
@@ -270,7 +270,7 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)if (!dev || !cb)return -ENODEV ; -dev_dbg (&dev->pdev->dev,"write data to amthi client.\n" ); +dev_dbg (&dev->pdev->dev,"write data to amthif client.\n" ); dev->iamthif_state =MEI_IAMTHIF_WRITING ; dev->iamthif_current_cb = cb;
@@ -309,12 +309,12 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)return -ENODEV ; dev->iamthif_flow_control_pending = true; dev->iamthif_state =MEI_IAMTHIF_FLOW_CONTROL ; -dev_dbg (&dev->pdev->dev,"add amthi cb to write waiting list\n" ); +dev_dbg (&dev->pdev->dev,"add amthif cb to write waiting list\n" ); dev->iamthif_current_cb = cb; dev->iamthif_file_object = cb->file_object;list_add_tail (&cb->list, &dev->write_waiting_list.list); }else { -dev_dbg (&dev->pdev->dev,"message does not complete, so add amthi cb to write list.\n" ); +dev_dbg (&dev->pdev->dev,"message does not complete, so add amthif cb to write list.\n" );list_add_tail (&cb->list, &dev->write_list.list); } }else {
@@ -383,7 +383,7 @@ void mei_amthif_run_next_cmd(struct mei_device *dev) dev->iamthif_timer =0 ; dev->iamthif_file_object =NULL ; -dev_dbg (&dev->pdev->dev,"complete amthi cmd_list cb.\n" ); +dev_dbg (&dev->pdev->dev,"complete amthif cmd_list cb.\n" );list_for_each_entry_safe (pos, next, &dev->amthif_cmd_list.list, list) {list_del (&pos->list);
@@ -392,7 +392,7 @@ void mei_amthif_run_next_cmd(struct mei_device *dev) status =mei_amthif_send_cmd (dev, pos);if (status) {dev_dbg (&dev->pdev->dev, -"amthi write failed status = %d\n" , +"amthif write failed status = %d\n" , status);return ; }
@@ -412,7 +412,7 @@ unsigned int mei_amthif_poll(struct mei_device *dev,if (dev->iamthif_state ==MEI_IAMTHIF_READ_COMPLETE && dev->iamthif_file_object == file) { mask |= (POLLIN |POLLRDNORM ); -dev_dbg (&dev->pdev->dev,"run next amthi cb\n" ); +dev_dbg (&dev->pdev->dev,"run next amthif cb\n" );mei_amthif_run_next_cmd (dev); }return mask;
@@ -478,7 +478,7 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots, dev->iamthif_state =MEI_IAMTHIF_FLOW_CONTROL ; dev->iamthif_flow_control_pending = true; -/* save iamthif cb sent to amthi client */ +/* save iamthif cb sent to amthif client */ cb->buf_idx = dev->iamthif_msg_buf_index; dev->iamthif_current_cb = cb;
@@ -491,11 +491,11 @@ int mei_amthif_irq_write_complete(struct mei_device *dev, s32 *slots,/** * mei_amthif_irq_read_message - read routine after ISR to -* handle the read amthi message +* handle the read amthif message * * @complete_list: An instance of our list structure * @dev: the device structure -* @mei_hdr: header of amthi message +* @mei_hdr: header of amthif message * * returns 0 on success, <0 on failure. */
@@ -519,10 +519,10 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list,return 0 ;dev_dbg (&dev->pdev->dev, -"amthi_message_buffer_index =%d\n" , +"amthif_message_buffer_index =%d\n" , mei_hdr->length); -dev_dbg (&dev->pdev->dev,"completed amthi read.\n " ); +dev_dbg (&dev->pdev->dev,"completed amthif read.\n " );if (!dev->iamthif_current_cb)return -ENODEV ;
@@ -537,8 +537,8 @@ int mei_amthif_irq_read_message(struct mei_cl_cb *complete_list, cb->read_time = jiffies;if (dev->iamthif_ioctl && cb->cl == &dev->iamthif_cl) {/* found the iamthif cb */ -dev_dbg (&dev->pdev->dev,"complete the amthi read cb.\n " ); -dev_dbg (&dev->pdev->dev,"add the amthi read cb to complete.\n " ); +dev_dbg (&dev->pdev->dev,"complete the amthif read cb.\n " ); +dev_dbg (&dev->pdev->dev,"add the amthif read cb to complete.\n " );list_add_tail (&cb->list, &complete_list->list); }return 0 ;
@@ -590,7 +590,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb) dev->iamthif_msg_buf, dev->iamthif_msg_buf_index);list_add_tail (&cb->list, &dev->amthif_rd_complete_list.list); -dev_dbg (&dev->pdev->dev,"amthi read completed\n" ); +dev_dbg (&dev->pdev->dev,"amthif read completed\n" ); dev->iamthif_timer = jiffies;dev_dbg (&dev->pdev->dev,"dev->iamthif_timer = %ld\n" , dev->iamthif_timer);
@@ -598,7 +598,7 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)mei_amthif_run_next_cmd (dev); } -dev_dbg (&dev->pdev->dev,"completing amthi call back.\n" ); +dev_dbg (&dev->pdev->dev,"completing amthif call back.\n" );wake_up_interruptible (&dev->iamthif_cl.wait); }
@@ -704,11 +704,11 @@ int mei_amthif_release(struct mei_device *dev, struct file *file)if (dev->iamthif_file_object == file && dev->iamthif_state !=MEI_IAMTHIF_IDLE ) { -dev_dbg (&dev->pdev->dev,"amthi canceled iamthif state %d\n" , +dev_dbg (&dev->pdev->dev,"amthif canceled iamthif state %d\n" , dev->iamthif_state); dev->iamthif_canceled = true;if (dev->iamthif_state ==MEI_IAMTHIF_READ_COMPLETE ) { -dev_dbg (&dev->pdev->dev,"run next amthi iamthif cb\n" ); +dev_dbg (&dev->pdev->dev,"run next amthif iamthif cb\n" );mei_amthif_run_next_cmd (dev); } }
drivers/misc/mei/client.c +1 -1
@@ -345,7 +345,7 @@ void mei_host_client_init(struct work_struct *work)for (i =0 ; i < dev->me_clients_num; i++) { client_props = &dev->me_clients[i].props; -if (!uuid_le_cmp (client_props->protocol_name, mei_amthi_guid)) +if (!uuid_le_cmp (client_props->protocol_name, mei_amthif_guid))mei_amthif_host_init (dev);else if (!uuid_le_cmp (client_props->protocol_name, mei_wd_guid))mei_wd_host_init (dev);
drivers/misc/mei/main.c +3 -3
@@ -497,7 +497,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,if (rets) {dev_err (&dev->pdev->dev, -"amthi write failed with status = %d\n" , rets); +"amthif write failed with status = %d\n" , rets); goto err; }mutex_unlock (&dev->device_lock);
@@ -611,10 +611,10 @@ static int mei_ioctl_connect_client(struct file *file,dev_dbg (&dev->pdev->dev,"FW Client - Max Msg Len = %d\n" , dev->me_clients[i].props.max_msg_length); -/* if we're connecting to amthi client then we will use the +/* if we're connecting to amthif client then we will use the * existing connection */ -if (uuid_le_cmp (data->in_client_uuid, mei_amthi_guid) ==0 ) { +if (uuid_le_cmp (data->in_client_uuid, mei_amthif_guid) ==0 ) {dev_dbg (&dev->pdev->dev,"FW Client is amthi\n" );if (dev->iamthif_cl.state !=MEI_FILE_CONNECTED ) { rets = -ENODEV ;
drivers/misc/mei/mei_dev.h +1 -1
@@ -46,7 +46,7 @@/* * AMTHI Client UUID */ -extern const uuid_le mei_amthi_guid; +extern const uuid_le mei_amthif_guid;/* * Watchdog Client UUID
Signature · 1 line
1.7.4.4
PATCH 11/21 mei: normalize me host client linking routines
In reply to Tomas WinklerIn order we can use the same code pattern for in-kernel and user space host clients we replace mei_cl_link_to_me with mei_cl_link function.
We then have to keep me client lookupout of the new link function.
The unlinking cannot be yet symetric due to amthif connection handling
--- drivers/misc/mei/amthif.c | 42 +++++++++++++++++++++------------- drivers/misc/mei/client.c | 53 ++++++++++++++++++++++++------------------- drivers/misc/mei/client.h | 2 +- drivers/misc/mei/init.c | 4 +++ drivers/misc/mei/main.c | 27 +++++++--------------- drivers/misc/mei/mei_dev.h | 10 ++++---- drivers/misc/mei/wd.c | 35 +++++++++++++++++++---------- 7 files changed, 98 insertions(+), 75 deletions(-)
drivers/misc/mei/amthif.c +26 -16
@@ -65,22 +65,22 @@ void mei_amthif_reset_params(struct mei_device *dev)* @dev: the device structure * */ -void mei_amthif_host_init (struct mei_device *dev) +int mei_amthif_host_init (struct mei_device *dev) { -int i; +struct mei_cl *cl = &dev->iamthif_cl;unsigned char *msg_buf; +int ret, i; -mei_cl_init (&dev->iamthif_cl, dev); - dev->iamthif_cl.state =MEI_FILE_DISCONNECTED ; +mei_cl_init (cl, dev); -/* find ME amthif client */ - i =mei_cl_link_me (&dev->iamthif_cl, - &mei_amthif_guid,MEI_IAMTHIF_HOST_CLIENT_ID ); + i =mei_me_cl_by_uuid (dev, &mei_amthif_guid);if (i <0 ) { -dev_info (&dev->pdev->dev,"failed to find iamthif client.\n" ); -return ; +dev_info (&dev->pdev->dev,"amthif: failed to find the client\n" ); +return -ENOENT ; } + cl->me_client_id = dev->me_clients[i].client_id; +/* Assign iamthif_mtu to the value received from ME */ dev->iamthif_mtu = dev->me_clients[i].props.max_msg_length;
@@ -94,19 +94,29 @@ void mei_amthif_host_init(struct mei_device *dev) msg_buf =kcalloc (dev->iamthif_mtu,sizeof (unsigned char ),GFP_KERNEL );if (!msg_buf) { -dev_dbg (&dev->pdev->dev,"memory allocation for ME message buffer failed.\n" ); -return ; +dev_err (&dev->pdev->dev,"amthif: memory allocation for ME message buffer failed.\n" ); +return -ENOMEM ; } dev->iamthif_msg_buf = msg_buf; -if (mei_hbm_cl_connect_req (dev, &dev->iamthif_cl)) { -dev_dbg (&dev->pdev->dev,"Failed to connect to AMTHI client\n" ); - dev->iamthif_cl.state =MEI_FILE_DISCONNECTED ; - dev->iamthif_cl.host_client_id =0 ; + ret =mei_cl_link (cl,MEI_IAMTHIF_HOST_CLIENT_ID ); + +if (ret <0 ) { +dev_err (&dev->pdev->dev,"amthif: failed link client\n" ); +return -ENOENT ; + } + + cl->state =MEI_FILE_CONNECTING ; + +if (mei_hbm_cl_connect_req (dev, cl)) { +dev_dbg (&dev->pdev->dev,"amthif: Failed to connect to ME client\n" ); + cl->state =MEI_FILE_DISCONNECTED ; + cl->host_client_id =0 ; }else { - dev->iamthif_cl.timer_count =MEI_CONNECT_TIMEOUT ; + cl->timer_count =MEI_CONNECT_TIMEOUT ; } +return 0 ; }/**
drivers/misc/mei/client.c +30 -23
84 lines not on this page · raw message
drivers/misc/mei/client.h +1 -1
@@ -55,7 +55,7 @@ struct mei_cl *mei_cl_allocate(struct mei_device *dev);void mei_cl_init (struct mei_cl *cl,struct mei_device *dev); -int mei_cl_link_me (struct mei_cl *cl,const uuid_le *uuid,u8 host_cl_id); +int mei_cl_link (struct mei_cl *cl,int id);int mei_cl_unlink (struct mei_cl *cl);int mei_cl_flush_queues (struct mei_cl *cl);
drivers/misc/mei/init.c +4 -0
@@ -242,7 +242,11 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)/* remove entry if already in list */ dev_dbg (&dev->pdev->dev,"remove iamthif and wd from the file list.\n" );mei_cl_unlink (&dev->wd_cl); +if (dev->open_handle_count >0 ) + dev->open_handle_count--;mei_cl_unlink (&dev->iamthif_cl); +if (dev->open_handle_count >0 ) + dev->open_handle_count--;mei_amthif_reset_params (dev);memset (&dev->wr_ext_msg,0 ,sizeof (dev->wr_ext_msg));
drivers/misc/mei/main.c +9 -18
@@ -103,7 +103,6 @@ static int mei_open(struct inode *inode, struct file *file) {struct mei_cl *cl;struct mei_device *dev; -unsigned long cl_id;int err; err = -ENODEV ;
@@ -133,24 +132,9 @@ static int mei_open(struct inode *inode, struct file *file) goto out_unlock; } - cl_id =find_first_zero_bit (dev->host_clients_map,MEI_CLIENTS_MAX ); -if (cl_id >=MEI_CLIENTS_MAX ) { -dev_err (&dev->pdev->dev,"client_id exceded %d" , -MEI_CLIENTS_MAX ) ; + err =mei_cl_link (cl,MEI_HOST_CLIENT_ID_ANY ); +if (err) goto out_unlock; - } - - cl->host_client_id = cl_id; - -dev_dbg (&dev->pdev->dev,"client_id = %d\n" , cl->host_client_id); - - dev->open_handle_count++; - -list_add_tail (&cl->link, &dev->file_list); - -set_bit (cl->host_client_id, dev->host_clients_map); - cl->state =MEI_FILE_INITIALIZING ; - cl->sm_state =0 ; file->private_data = cl;mutex_unlock (&dev->device_lock);
@@ -209,6 +193,7 @@ static int mei_release(struct inode *inode, struct file *file) }mei_cl_unlink (cl); +/* free read cb */ cb =NULL ;if (cl->read_cb) {
@@ -991,7 +976,13 @@ static void mei_remove(struct pci_dev *pdev)/* remove entry if already in list */ dev_dbg (&pdev->dev,"list del iamthif and wd file list.\n" ); + +if (dev->open_handle_count >0 ) + dev->open_handle_count--;mei_cl_unlink (&dev->wd_cl); + +if (dev->open_handle_count >0 ) + dev->open_handle_count--;mei_cl_unlink (&dev->iamthif_cl); dev->iamthif_current_cb =NULL ;
drivers/misc/mei/mei_dev.h +5 -5
@@ -67,16 +67,16 @@ extern const u8 mei_wd_state_independence_msg[3][4];* Number of File descriptors/handles * that can be opened to the driver. * -* Limit to 253: 256 Total Clients +* Limit to 255: 256 Total Clients * minus internal client for MEI Bus Messags -* minus internal client for AMTHI -* minus internal client for Watchdog */ -#define MEI_MAX_OPEN_HANDLE_COUNT (MEI_CLIENTS_MAX - 3) +#define MEI_MAX_OPEN_HANDLE_COUNT (MEI_CLIENTS_MAX - 1)/* * Internal Clients Number */ +#define MEI_HOST_CLIENT_ID_ANY (-1) +#define MEI_HBM_HOST_CLIENT_ID 0/* not used, just for documentation */ #define MEI_WD_HOST_CLIENT_ID 1#define MEI_IAMTHIF_HOST_CLIENT_ID 2
@@ -339,7 +339,7 @@ void mei_timer(struct work_struct *work);*/ void mei_amthif_reset_params (struct mei_device *dev); -void mei_amthif_host_init (struct mei_device *dev); +int mei_amthif_host_init (struct mei_device *dev);int mei_amthif_write (struct mei_device *dev,struct mei_cl_cb *priv_cb);
drivers/misc/mei/wd.c +23 -12
@@ -64,30 +64,41 @@ static void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)*/ int mei_wd_host_init (struct mei_device *dev) { -int id; -mei_cl_init (&dev->wd_cl, dev); +struct mei_cl *cl = &dev->wd_cl; +int i; +int ret; + +mei_cl_init (cl, dev); -/* look for WD client and connect to it */ - dev->wd_cl.state =MEI_FILE_DISCONNECTED ; dev->wd_timeout =MEI_WD_DEFAULT_TIMEOUT ; dev->wd_state =MEI_WD_IDLE ; -/* Connect WD ME client to the host client */ - id =mei_cl_link_me (&dev->wd_cl, - &mei_wd_guid,MEI_WD_HOST_CLIENT_ID ); -if (id <0 ) { +/* check for valid client id */ + i =mei_me_cl_by_uuid (dev, &mei_wd_guid); +if (i <0 ) {dev_info (&dev->pdev->dev,"wd: failed to find the client\n" );return -ENOENT ; } -if (mei_hbm_cl_connect_req (dev, &dev->wd_cl)) { + cl->me_client_id = dev->me_clients[i].client_id; + + ret =mei_cl_link (cl,MEI_WD_HOST_CLIENT_ID ); + +if (ret <0 ) { +dev_info (&dev->pdev->dev,"wd: failed link client\n" ); +return -ENOENT ; + } + + cl->state =MEI_FILE_CONNECTING ; + +if (mei_hbm_cl_connect_req (dev, cl)) {dev_err (&dev->pdev->dev,"wd: failed to connect to the client\n" ); - dev->wd_cl.state =MEI_FILE_DISCONNECTED ; - dev->wd_cl.host_client_id =0 ; + cl->state =MEI_FILE_DISCONNECTED ; + cl->host_client_id =0 ;return -EIO ; } - dev->wd_cl.timer_count =MEI_CONNECT_TIMEOUT ; + cl->timer_count =MEI_CONNECT_TIMEOUT ;return 0 ; }
Signature · 1 line
1.7.4.4
PATCH 12/21 mei: move MEI_IAMTHIF_IDLE to amthif host init function
In reply to Tomas WinklerSince the amthif state is not examined until amthif is connected we can safely move it to the amthif host init function
--- drivers/misc/mei/amthif.c | 2 ++ drivers/misc/mei/init.c | 1 - 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/misc/mei/amthif.c +2 -0
@@ -71,6 +71,8 @@ int mei_amthif_host_init(struct mei_device *dev)unsigned char *msg_buf;int ret, i; + dev->iamthif_state =MEI_IAMTHIF_IDLE ; +mei_cl_init (cl, dev); i =mei_me_cl_by_uuid (dev, &mei_amthif_guid);
drivers/misc/mei/init.c +0 -1
@@ -68,7 +68,6 @@ struct mei_device *mei_device_init(struct pci_dev *pdev)init_waitqueue_head (&dev->wait_recvd_msg);init_waitqueue_head (&dev->wait_stop_wd); dev->dev_state =MEI_DEV_INITIALIZING ; - dev->iamthif_state =MEI_IAMTHIF_IDLE ;mei_io_list_init (&dev->read_list);mei_io_list_init (&dev->write_list);
Signature · 1 line
1.7.4.4
PATCH 13/21 mei: hw-me.c fix kernel doc
In reply to Tomas WinklerFix the kernel doc for the functions in hw-me.c
--- drivers/misc/mei/hw-me.c | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-)
drivers/misc/mei/hw-me.c +18 -9
@@ -49,17 +49,13 @@ static inline void mei_reg_write(const struct mei_device *dev, }/** -* mei_hcsr_read - Reads 32bit data from the host CSR +* mei_mecbrw_read - Reads 32bit data from ME circular buffer +* read window register * * @dev: the device structure * -* returns the byte read. +* returns ME_CB_RW register value (u32) */ -u32 mei_hcsr_read (const struct mei_device *dev) -{ -return mei_reg_read (dev,H_CSR ); -} -u32 mei_mecbrw_read (const struct mei_device *dev) {return mei_reg_read (dev,ME_CB_RW );
@@ -77,13 +73,26 @@ u32 mei_mecsr_read(const struct mei_device *dev) }/** -* mei_set_csr_register - writes H_CSR register to the mei device, +* mei_hcsr_read - Reads 32bit data from the host CSR +* +* @dev: the device structure +* +* returns H_CSR register value (u32) +*/ +u32 mei_hcsr_read (const struct mei_device *dev) +{ +return mei_reg_read (dev,H_CSR ); +} + +/** +* mei_hcsr_set - writes H_CSR register to the mei device, * and ignores the H_IS bit for it is write-one-to-zero. * * @dev: the device structure */ void mei_hcsr_set (struct mei_device *dev) { +if ((dev->host_hw_state &H_IS ) ==H_IS ) dev->host_hw_state &= ~H_IS ;mei_reg_write (dev,H_CSR , dev->host_hw_state);
@@ -91,7 +100,7 @@ void mei_hcsr_set(struct mei_device *dev) }/** -* mei_enable_interrupts - clear and stop interrupts +* mei_clear_interrupts - clear and stop interrupts * * @dev: the device structure */
Signature · 1 line
1.7.4.4
PATCH 14/21 mei: remove write only need_reset member of struct mei_device
In reply to Tomas Winklerneed_reset is not used anymore
--- drivers/misc/mei/init.c | 6 +----- drivers/misc/mei/mei_dev.h | 1 - 2 files changed, 1 insertions(+), 6 deletions(-)
drivers/misc/mei/init.c +1 -5
@@ -199,10 +199,8 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)struct mei_cl_cb *cb_next =NULL ;bool unexpected; -if (dev->dev_state ==MEI_DEV_RECOVERING_FROM_RESET ) { - dev->need_reset = true; +if (dev->dev_state ==MEI_DEV_RECOVERING_FROM_RESET )return ; - } unexpected = (dev->dev_state != MEI_DEV_INITIALIZING && dev->dev_state != MEI_DEV_DISABLED &&
@@ -224,8 +222,6 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled)dev_dbg (&dev->pdev->dev,"currently saved host_hw_state = 0x%08x.\n" , dev->host_hw_state); - dev->need_reset = false; -if (dev->dev_state !=MEI_DEV_INITIALIZING ) {if (dev->dev_state !=MEI_DEV_DISABLED && dev->dev_state !=MEI_DEV_POWER_DOWN )
drivers/misc/mei/mei_dev.h +0 -1
@@ -260,7 +260,6 @@ struct mei_device {enum mei_dev_state dev_state;enum mei_init_clients_states init_clients_state;u16 init_clients_timer; -bool need_reset;unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE ];/* control messages */ u32 rd_msg_hdr;
Signature · 1 line
1.7.4.4
PATCH 15/21 mei: remove mei_csr_clear_his prototype
In reply to Tomas WinklerThe function mei_csr_clear_his is not implemented
--- drivers/misc/mei/mei_dev.h | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/misc/mei/mei_dev.h +1 -2
@@ -386,11 +386,10 @@ void mei_watchdog_unregister(struct mei_device *dev);*/ u32 mei_hcsr_read (const struct mei_device *dev); +void mei_hcsr_set (struct mei_device *dev);u32 mei_mecsr_read (const struct mei_device *dev);u32 mei_mecbrw_read (const struct mei_device *dev); -void mei_hcsr_set (struct mei_device *dev); -void mei_csr_clear_his (struct mei_device *dev);void mei_clear_interrupts (struct mei_device *dev);void mei_enable_interrupts (struct mei_device *dev);
Signature · 1 line
1.7.4.4
PATCH 16/21 mei: don't use cached value for hcsr in mei_hw_reset
In reply to Tomas WinklerOpen code mei_hw_reset to avoid using cached hcsr. Using cached hcsr can cause unwanted side effects.
Move mei_hw_restet function to hw-me.c as it is hw dependent
--- drivers/misc/mei/hw-me.c | 35 +++++++++++++++++++++++++++++++++++ drivers/misc/mei/init.c | 28 ---------------------------- drivers/misc/mei/mei_dev.h | 1 + 3 files changed, 36 insertions(+), 28 deletions(-)
drivers/misc/mei/hw-me.c +35 -0
@@ -132,6 +132,41 @@ void mei_disable_interrupts(struct mei_device *dev)mei_hcsr_set (dev); } +/** +* mei_hw_reset - resets fw via mei csr register. +* +* @dev: the device structure +* @interrupts_enabled: if interrupt should be enabled after reset. +*/ +void mei_hw_reset (struct mei_device *dev,bool intr_enable) +{ +u32 hcsr =mei_hcsr_read (dev); + +dev_dbg (&dev->pdev->dev,"before reset HCSR = 0x%08x.\n" , hcsr); + + hcsr |= (H_RST |H_IG ); + +if (intr_enable) + hcsr |=H_IE ; +else + hcsr &= ~H_IE ; + + hcsr &= ~H_IS ; + +mei_reg_write (dev,H_CSR , hcsr); + hcsr =mei_hcsr_read (dev); + + hcsr &= ~H_RST ; + hcsr |=H_IG ; + hcsr &= ~H_IS ; + +mei_reg_write (dev,H_CSR , hcsr); + + hcsr =mei_hcsr_read (dev); + +dev_dbg (&dev->pdev->dev,"current HCSR = 0x%08x.\n" , hcsr); +} +/** * mei_interrupt_quick_handler - The ISR of the MEI device
drivers/misc/mei/init.c +0 -28
@@ -170,22 +170,6 @@ out: }/** -* mei_hw_reset - resets fw via mei csr register. -* -* @dev: the device structure -* @interrupts_enabled: if interrupt should be enabled after reset. -*/ -static void mei_hw_reset (struct mei_device *dev,int interrupts_enabled) -{ - dev->host_hw_state |= (H_RST |H_IG ); - -if (interrupts_enabled) -mei_enable_interrupts (dev); -else -mei_disable_interrupts (dev); -} - -/** * mei_reset - resets host and fw. * * @dev: the device structure
@@ -207,20 +191,8 @@ void mei_reset(struct mei_device *dev, int interrupts_enabled) dev->dev_state !=MEI_DEV_POWER_DOWN && dev->dev_state != MEI_DEV_POWER_UP); - dev->host_hw_state =mei_hcsr_read (dev); - -dev_dbg (&dev->pdev->dev,"before reset host_hw_state = 0x%08x.\n" , - dev->host_hw_state); -mei_hw_reset (dev, interrupts_enabled); - dev->host_hw_state &= ~H_RST ; - dev->host_hw_state |=H_IG ; - -mei_hcsr_set (dev); - -dev_dbg (&dev->pdev->dev,"currently saved host_hw_state = 0x%08x.\n" , - dev->host_hw_state);if (dev->dev_state !=MEI_DEV_INITIALIZING ) { if (dev->dev_state != MEI_DEV_DISABLED &&
drivers/misc/mei/mei_dev.h +1 -0
@@ -385,6 +385,7 @@ void mei_watchdog_unregister(struct mei_device *dev);* Register Access Function */ +void mei_hw_reset (struct mei_device *dev,bool intr_enable);u32 mei_hcsr_read (const struct mei_device *dev);void mei_hcsr_set (struct mei_device *dev);u32 mei_mecsr_read (const struct mei_device *dev);
Signature · 1 line
1.7.4.4
PATCH 17/21 mei: use non cached hcsr for interrupt enablement
In reply to Tomas Winkler--- drivers/misc/mei/hw-me.c | 17 +++++++++++------ drivers/misc/mei/interrupt.c | 2 +- drivers/misc/mei/main.c | 2 -- 3 files changed, 12 insertions(+), 9 deletions(-)
drivers/misc/mei/hw-me.c +11 -6
@@ -106,8 +106,9 @@ void mei_hcsr_set(struct mei_device *dev)*/ void mei_clear_interrupts (struct mei_device *dev) { -if ((dev->host_hw_state &H_IS ) ==H_IS ) -mei_reg_write (dev,H_CSR , dev->host_hw_state); +u32 hcsr =mei_hcsr_read (dev); +if ((hcsr &H_IS ) ==H_IS ) +mei_reg_write (dev,H_CSR , hcsr); }/**
@@ -117,8 +118,10 @@ void mei_clear_interrupts(struct mei_device *dev)*/ void mei_enable_interrupts (struct mei_device *dev) { - dev->host_hw_state |=H_IE ; -mei_hcsr_set (dev); +u32 hcsr =mei_hcsr_read (dev); + hcsr |=H_IE ; + hcsr &= ~H_IS ; +mei_reg_write (dev,H_CSR , hcsr); }/**
@@ -128,8 +131,10 @@ void mei_enable_interrupts(struct mei_device *dev)*/ void mei_disable_interrupts (struct mei_device *dev) { - dev->host_hw_state &= ~H_IE ; -mei_hcsr_set (dev); +u32 hcsr =mei_hcsr_read (dev); + hcsr &= ~H_IE ; + hcsr &= ~H_IS ; +mei_reg_write (dev,H_CSR , hcsr); }/**
drivers/misc/mei/interrupt.c +1 -1
@@ -691,7 +691,6 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)/* initialize our complete list */ mutex_lock (&dev->device_lock);mei_io_list_init (&complete_list); - dev->host_hw_state =mei_hcsr_read (dev);/* Ack the interrupt here * In case of MSI we don't go through the quick handler */
@@ -710,6 +709,7 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)return IRQ_HANDLED ; } + dev->host_hw_state =mei_hcsr_read (dev);/* check if we need to start the dev */ if ((dev->host_hw_state &H_RDY ) ==0 ) {if ((dev->me_hw_state &ME_RDY_HRA ) ==ME_RDY_HRA ) {
drivers/misc/mei/main.c +0 -2
@@ -915,8 +915,6 @@ static int mei_probe(struct pci_dev *pdev,return 0 ; release_irq: -/* disable interrupts */ - dev->host_hw_state =mei_hcsr_read (dev);mei_disable_interrupts (dev);flush_scheduled_work ();free_irq (pdev->irq, dev);
Signature · 1 line
1.7.4.4
PATCH 18/21 mei: abstract host and device readieness
In reply to Tomas WinklerAdd mei_host_set_ready function to enable the device and is_ready function to query the host and me readiness
--- drivers/misc/mei/hw-me.c | 35 ++++++++++++++++++++++++++++++++++- drivers/misc/mei/init.c | 14 ++++++-------- drivers/misc/mei/interrupt.c | 19 ++++++++++--------- drivers/misc/mei/mei_dev.h | 4 ++++ 4 files changed, 54 insertions(+), 18 deletions(-)
drivers/misc/mei/hw-me.c +34 -1
@@ -172,6 +172,39 @@ void mei_hw_reset(struct mei_device *dev, bool intr_enable)dev_dbg (&dev->pdev->dev,"current HCSR = 0x%08x.\n" , hcsr); } +/** +* mei_host_set_ready - enable device +* +* @dev - mei device +* returns bool +*/ + +void mei_host_set_ready (struct mei_device *dev) +{ + dev->host_hw_state |=H_IE |H_IG |H_RDY ; +mei_hcsr_set (dev); +} +/** +* mei_host_is_ready - check whether the host has turned ready +* +* @dev - mei device +* returns bool +*/ +bool mei_host_is_ready (struct mei_device *dev) +{ +return (dev->host_hw_state &H_RDY ) ==H_RDY ; +} + +/** +* mei_me_is_ready - check whether the me has turned ready +* +* @dev - mei device +* returns bool +*/ +bool mei_me_is_ready (struct mei_device *dev) +{ +return (dev->me_hw_state &ME_RDY_HRA ) ==ME_RDY_HRA ; +}/** * mei_interrupt_quick_handler - The ISR of the MEI device
@@ -290,7 +323,7 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, dev->host_hw_state |=H_IG ;mei_hcsr_set (dev); dev->me_hw_state =mei_mecsr_read (dev); -if ((dev->me_hw_state &ME_RDY_HRA ) !=ME_RDY_HRA ) +if (!mei_me_is_ready (dev))return -EIO ;return 0 ;
drivers/misc/mei/init.c +6 -8
@@ -131,18 +131,18 @@ int mei_hw_init(struct mei_device *dev) goto out; } -if (!(((dev->host_hw_state &H_RDY ) ==H_RDY ) && - ((dev->me_hw_state &ME_RDY_HRA ) ==ME_RDY_HRA ))) { +if (!(mei_host_is_ready (dev) &&mei_me_is_ready (dev))) { dev->dev_state =MEI_DEV_DISABLED ; +dev_dbg (&dev->pdev->dev,"host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n" , dev->host_hw_state, dev->me_hw_state); -if (!(dev->host_hw_state &H_RDY )) -dev_dbg (&dev->pdev->dev,"host turn off H_RDY.\n" ); +if (!mei_host_is_ready (dev)) +dev_dbg (&dev->pdev->dev,"host is not ready.\n" ); -if (!(dev->me_hw_state &ME_RDY_HRA )) -dev_dbg (&dev->pdev->dev,"ME turn off ME_RDY.\n" ); +if (!mei_me_is_ready (dev)) +dev_dbg (&dev->pdev->dev,"ME is not ready.\n" );dev_err (&dev->pdev->dev,"link layer initialization failed.\n" ); ret = -ENODEV ;
@@ -159,9 +159,7 @@ int mei_hw_init(struct mei_device *dev) dev->recvd_msg = false;dev_dbg (&dev->pdev->dev,"host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n" , dev->host_hw_state, dev->me_hw_state); -dev_dbg (&dev->pdev->dev,"ME turn on ME_RDY and host turn on H_RDY.\n" );dev_dbg (&dev->pdev->dev,"link layer has been established.\n" ); -dev_dbg (&dev->pdev->dev,"MEI start success.\n" ); ret =0 ; out:
drivers/misc/mei/interrupt.c +10 -9
@@ -700,7 +700,7 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id) dev->me_hw_state =mei_mecsr_read (dev);/* check if ME wants a reset */ -if ((dev->me_hw_state &ME_RDY_HRA ) ==0 && +if (!mei_me_is_ready (dev) && dev->dev_state !=MEI_DEV_RESETING && dev->dev_state !=MEI_DEV_INITIALIZING ) {dev_dbg (&dev->pdev->dev,"FW not ready.\n" );
@@ -711,16 +711,17 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id) dev->host_hw_state =mei_hcsr_read (dev);/* check if we need to start the dev */ -if ((dev->host_hw_state &H_RDY ) ==0 ) { -if ((dev->me_hw_state &ME_RDY_HRA ) ==ME_RDY_HRA ) { +if (!mei_host_is_ready (dev)) { +if (mei_me_is_ready (dev)) {dev_dbg (&dev->pdev->dev,"we need to start the dev.\n" ); - dev->host_hw_state |= (H_IE |H_IG |H_RDY ); -mei_hcsr_set (dev); - dev->dev_state =MEI_DEV_INIT_CLIENTS ; + +mei_host_set_ready (dev); +dev_dbg (&dev->pdev->dev,"link is established start sending messages.\n" ); -/* link is established -* start sending messages. -*/ +/* link is established * start sending messages. */ + + dev->dev_state =MEI_DEV_INIT_CLIENTS ; +mei_hbm_start_req (dev);mutex_unlock (&dev->device_lock);return IRQ_HANDLED ;
drivers/misc/mei/mei_dev.h +4 -0
@@ -396,6 +396,10 @@ void mei_clear_interrupts(struct mei_device *dev);void mei_enable_interrupts (struct mei_device *dev);void mei_disable_interrupts (struct mei_device *dev); +void mei_host_set_ready (struct mei_device *dev); +bool mei_host_is_ready (struct mei_device *dev); +bool mei_me_is_ready (struct mei_device *dev); +#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d comp=%1d"
Signature · 1 line
1.7.4.4
PATCH 19/21 mei: reenable mei_hcsr_set abstraction
In reply to Tomas WinklerNow when mei_hcsr_set is local to hw-me.c
we can benefit form the fact that it wrapsH_IS removal from the host csr.
--- drivers/misc/mei/hw-me.c | 38 +++++++++++++++----------------------- drivers/misc/mei/mei_dev.h | 1 - 2 files changed, 15 insertions(+), 24 deletions(-)
drivers/misc/mei/hw-me.c +15 -23
@@ -90,13 +90,10 @@ u32 mei_hcsr_read(const struct mei_device *dev)* * @dev: the device structure */ -void mei_hcsr_set (struct mei_device *dev) +static inline void mei_hcsr_set (struct mei_device *dev,u32 hcsr) { - -if ((dev->host_hw_state &H_IS ) ==H_IS ) - dev->host_hw_state &= ~H_IS ; -mei_reg_write (dev,H_CSR , dev->host_hw_state); - dev->host_hw_state =mei_hcsr_read (dev); + hcsr &= ~H_IS ; +mei_reg_write (dev,H_CSR , hcsr); }/**
@@ -120,8 +117,7 @@ void mei_enable_interrupts(struct mei_device *dev) {u32 hcsr =mei_hcsr_read (dev); hcsr |=H_IE ; - hcsr &= ~H_IS ; -mei_reg_write (dev,H_CSR , hcsr); +mei_hcsr_set (dev, hcsr); }/**
@@ -133,8 +129,7 @@ void mei_disable_interrupts(struct mei_device *dev) {u32 hcsr =mei_hcsr_read (dev); hcsr &= ~H_IE ; - hcsr &= ~H_IS ; -mei_reg_write (dev,H_CSR , hcsr); +mei_hcsr_set (dev, hcsr); }/**
@@ -156,16 +151,12 @@ void mei_hw_reset(struct mei_device *dev, bool intr_enable)else hcsr &= ~H_IE ; - hcsr &= ~H_IS ; - -mei_reg_write (dev,H_CSR , hcsr); - hcsr =mei_hcsr_read (dev); +mei_hcsr_set (dev, hcsr); + hcsr =mei_hcsr_read (dev) |H_IG ; hcsr &= ~H_RST ; - hcsr |=H_IG ; - hcsr &= ~H_IS ; -mei_reg_write (dev,H_CSR , hcsr); +mei_hcsr_set (dev, hcsr); hcsr =mei_hcsr_read (dev);
@@ -182,7 +173,7 @@ void mei_hw_reset(struct mei_device *dev, bool intr_enable)void mei_host_set_ready (struct mei_device *dev) { dev->host_hw_state |=H_IE |H_IG |H_RDY ; -mei_hcsr_set (dev); +mei_hcsr_set (dev, dev->host_hw_state); }/** * mei_host_is_ready - check whether the host has turned ready
@@ -295,6 +286,7 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header,unsigned long rem, dw_cnt;unsigned long length = header->length;u32 *reg_buf = (u32 *)buf; +u32 hcsr;int i;int empty_slots;
@@ -319,9 +311,8 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header,mei_reg_write (dev,H_CB_WW , reg); } - dev->host_hw_state =mei_hcsr_read (dev); - dev->host_hw_state |=H_IG ; -mei_hcsr_set (dev); + hcsr =mei_hcsr_read (dev) |H_IG ; +mei_hcsr_set (dev, hcsr); dev->me_hw_state =mei_mecsr_read (dev);if (!mei_me_is_ready (dev))return -EIO ;
@@ -366,6 +357,7 @@ void mei_read_slots(struct mei_device *dev, unsigned char *buffer, unsigned long buffer_length) {u32 *reg_buf = (u32 *)buffer; +u32 hcsr;for (; buffer_length >=sizeof (u32); buffer_length -=sizeof (u32)) *reg_buf++ =mei_mecbrw_read (dev);
@@ -375,7 +367,7 @@ void mei_read_slots(struct mei_device *dev, unsigned char *buffer,memcpy (reg_buf, ®, buffer_length); } - dev->host_hw_state |=H_IG ; -mei_hcsr_set (dev); + hcsr =mei_hcsr_read (dev) |H_IG ; +mei_hcsr_set (dev, hcsr); }
drivers/misc/mei/mei_dev.h +0 -1
@@ -387,7 +387,6 @@ void mei_watchdog_unregister(struct mei_device *dev);void mei_hw_reset (struct mei_device *dev,bool intr_enable);u32 mei_hcsr_read (const struct mei_device *dev); -void mei_hcsr_set (struct mei_device *dev);u32 mei_mecsr_read (const struct mei_device *dev);u32 mei_mecbrw_read (const struct mei_device *dev);
Signature · 1 line
1.7.4.4
PATCH 20/21 mei: make host csr and me csr internal to hw-me
In reply to Tomas WinklerMove csr reading into me hardware functional calls.
Since we gave up on registers caching we remove some of the unnecessary queries in mei_hw_init ane mei_reset functions.
We add mei_hw_config function to wrap up host buffer depth configuration.
--- drivers/misc/mei/hw-me.c | 19 ++++++++++-- drivers/misc/mei/init.c | 63 ++++++++++++----------------------------- drivers/misc/mei/interrupt.c | 4 -- drivers/misc/mei/mei_dev.h | 4 +- 4 files changed, 37 insertions(+), 53 deletions(-)
drivers/misc/mei/hw-me.c +16 -3
@@ -67,7 +67,7 @@ u32 mei_mecbrw_read(const struct mei_device *dev)* * returns ME_CSR_HA register value (u32) */ -u32 mei_mecsr_read (const struct mei_device *dev) +static inline u32 mei_mecsr_read (const struct mei_device *dev) {return mei_reg_read (dev,ME_CSR_HA ); }
@@ -79,7 +79,7 @@ u32 mei_mecsr_read(const struct mei_device *dev)* * returns H_CSR register value (u32) */ -u32 mei_hcsr_read (const struct mei_device *dev) +static inline u32 mei_hcsr_read (const struct mei_device *dev) {return mei_reg_read (dev,H_CSR ); }
@@ -96,6 +96,18 @@ static inline void mei_hcsr_set(struct mei_device *dev, u32 hcsr)mei_reg_write (dev,H_CSR , hcsr); } + +/** +* me_hw_config - configure hw dependent settings +* +* @dev: mei device +*/ +void mei_hw_config (struct mei_device *dev) +{ +u32 hcsr =mei_hcsr_read (dev); +/* Doesn't change in runtime */ + dev->hbuf_depth = (hcsr &H_CBD ) >>24 ; +}/** * mei_clear_interrupts - clear and stop interrupts *
@@ -183,6 +195,7 @@ void mei_host_set_ready(struct mei_device *dev)*/ bool mei_host_is_ready (struct mei_device *dev) { + dev->host_hw_state =mei_hcsr_read (dev);return (dev->host_hw_state &H_RDY ) ==H_RDY ; }
@@ -194,6 +207,7 @@ bool mei_host_is_ready(struct mei_device *dev)*/ bool mei_me_is_ready (struct mei_device *dev) { + dev->me_hw_state =mei_mecsr_read (dev);return (dev->me_hw_state &ME_RDY_HRA ) ==ME_RDY_HRA ; }
@@ -313,7 +327,6 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, hcsr =mei_hcsr_read (dev) |H_IG ;mei_hcsr_set (dev, hcsr); - dev->me_hw_state =mei_mecsr_read (dev);if (!mei_me_is_ready (dev))return -EIO ;
drivers/misc/mei/init.c +19 -44
114 lines not on this page · raw message
drivers/misc/mei/interrupt.c +0 -4
@@ -697,8 +697,6 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)if (pci_dev_msi_enabled (dev->pdev))mei_clear_interrupts (dev); - dev->me_hw_state =mei_mecsr_read (dev); -/* check if ME wants a reset */ if (!mei_me_is_ready(dev) && dev->dev_state != MEI_DEV_RESETING &&
@@ -709,7 +707,6 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)return IRQ_HANDLED ; } - dev->host_hw_state =mei_hcsr_read (dev);/* check if we need to start the dev */ if (!mei_host_is_ready (dev)) {if (mei_me_is_ready (dev)) {
@@ -746,7 +743,6 @@ irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id) rets =mei_irq_thread_write_handler (dev, &complete_list); end:dev_dbg (&dev->pdev->dev,"end of bottom half function.\n" ); - dev->host_hw_state =mei_hcsr_read (dev); dev->mei_host_buffer_is_empty =mei_hbuf_is_empty (dev); bus_message_received = false;
drivers/misc/mei/mei_dev.h +2 -2
@@ -385,12 +385,12 @@ void mei_watchdog_unregister(struct mei_device *dev);* Register Access Function */ +void mei_hw_config (struct mei_device *dev);void mei_hw_reset (struct mei_device *dev,bool intr_enable); -u32 mei_hcsr_read (const struct mei_device *dev); -u32 mei_mecsr_read (const struct mei_device *dev);u32 mei_mecbrw_read (const struct mei_device *dev); +void mei_clear_interrupts (struct mei_device *dev);void mei_enable_interrupts (struct mei_device *dev);void mei_disable_interrupts (struct mei_device *dev);
Signature · 1 line
1.7.4.4
PATCH 21/21 mei: move work initialization to mei_device_init
In reply to Tomas WinklerLet mei_device_init initialize all the software constructs.
--- drivers/misc/mei/init.c | 4 ++++ drivers/misc/mei/main.c | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/misc/mei/init.c +4 -0
@@ -76,6 +76,10 @@ struct mei_device *mei_device_init(struct pci_dev *pdev)mei_io_list_init (&dev->ctrl_rd_list);mei_io_list_init (&dev->amthif_cmd_list);mei_io_list_init (&dev->amthif_rd_complete_list); + +INIT_DELAYED_WORK (&dev->timer_work, mei_timer); +INIT_WORK (&dev->init_work, mei_host_client_init); + dev->pdev = pdev;return dev; }
drivers/misc/mei/main.c +0 -2
@@ -889,8 +889,6 @@ static int mei_probe(struct pci_dev *pdev, pdev->irq); goto disable_msi; } -INIT_DELAYED_WORK (&dev->timer_work, mei_timer); -INIT_WORK (&dev->init_work, mei_host_client_init);if (mei_hw_init (dev)) {dev_err (&pdev->dev,"init hw failure.\n" );
Signature · 1 line
1.7.4.4