aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/mei/client.c
AgeCommit message (Collapse)AuthorFilesLines
2014-09-29mei: fix kernel-doc warningsAlexander Usyskin1-0/+6
Add missed parameters descriptions and return values descriptions Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-29mei: fix KDoc documentation formattingAlexander Usyskin1-29/+41
Fix Kdoc documentation formatting warnings genertaed by ./scripts/kernel-doc Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-29mei: trivial: fix errors in prints in commentsAlexander Usyskin1-1/+1
Fix misspellings and wrong print texts Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-29mei: remove include to pci header from mei module filesTomas Winkler1-1/+1
Remove inclusion of linux/pci.h in mei layer however we need to include the headers that before got included implicitly from linux/pci.h. Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-29mei: get rid of most of the pci dependencies in meiTomas Winkler1-23/+23
For purpose of adding testing HW we would like to get rid of pci dependency in generic mei code This patch provides only straight forward changes FW status and prob quirks need to be handled separately Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-29mei: fix style warning: Missing a blank line after declarationsTomas Winkler1-0/+1
fix new style warning: Missing a blank line after declarations Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-23mei: revamp connect and disconnect response handlingTomas Winkler1-2/+2
Both responses have same flow only the client status update is different. We introduce handler mei_hbm_cl_res() that handles both responses Also we use per client wait queue (cl->wait) rather then global dev->wait_recvd_msg Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-23mei: use disconnect name consistentlyTomas Winkler1-1/+2
Rename mei_cl_irq_close to mei_cl_irq_disconnect and MEI_FOP_CLOSE to MEI_FOP_DISCONNECT Remove unused MEI_FOP_OPEN Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-23mei: add mei_me_cl_by_uuid_id functionTomas Winkler1-1/+13
When handling dynamic clients there might be a race scenario in which two me clients with the same me address would be linked in the me clients list, therefore we need to search by both uuid and me address. Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-23mei: add me client remove functionsTomas Winkler1-1/+21
To support dynamic addition/remove we add wrappers for removal of me clients Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-23mei: use list for me clients book keepingTomas Winkler1-19/+15
To support dynamic addition/remove of clients it is more convenient to use list instead of static array Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-23mei: me_client lookup function to return me_client objectTomas Winkler1-23/+20
For support of dynamic addition and removal of me clients it is more convenient to use a list instead of static array as is use now. As the first step of the transition to the new data structure we change the lookup function so it returns me client address instead of an index. Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-09-23mei: amthif: use service function to flush amthif queueAlexander Usyskin1-1/+1
Replace open coded loop with an existing service function: mei_io_list_flush Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-08-25mei: reset client state on queued connect requestAlexander Usyskin1-0/+1
If connect request is queued (e.g. device in pg) set client state to initializing, thus avoid preliminary exit in wait if current state is disconnected. This is regression from: commit e4d8270e604c3202131bac607969605ac397b893 Author: Alexander Usyskin <[email protected]> mei: set connecting state just upon connection request is sent to the fw CC: [email protected] # 3.15+ Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-07-17mei: fix return value on disconnect timeoutAlexander Usyskin1-10/+5
wait_event_timeout can return 0 or the remaining jiffies so return -ETIME if disconnected state not reached. Cc: [email protected] # 3.10+ Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-07-17mei: start disconnect request timer consistentlyAlexander Usyskin1-0/+1
Link must be reset in case the fw doesn't respond to client disconnect request. We did charge the timer only in irq path from mei_cl_irq_close and not in mei_cl_disconnect Cc: [email protected] # 3.10+ Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-07-17mei: reset client connection state on timeoutAlexander Usyskin1-0/+1
On connection timeout we leave the connecting client in connecting state. Since a new connection is stalled till previous connection is completed in this case no new connection is possible till the user space does release the file handle. Therefore on timeout we move the client to disconnected state. Cc: [email protected] # 3.15+ Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-05-03mei: set connecting state just upon connection request is sent to the fwAlexander Usyskin1-0/+1
Adding power gating introduced new waiting state for client also during connection attempt, a connection request can be queued for later either due device is power gated or due to other on going connection. We setting client connection state before start of full connect procedure so in both cased the client state will be MEI_FILE_CONNECTING which create interlock between the two connection attempts, both detecting that another connection is in progress. The interlock is resolved by moving client to connecting state only upon connection request transmission, so the first cb in queue can be processed. Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-05-03mei: make return values consistent across the driverAlexander Usyskin1-3/+2
Follow-up for bits missed in commit 7ca96aa278f8b9983184e318b06a0ed9ad0297b8 mei: make return values consistent across the driver Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-05-03mei: use runtime pm in write and read flowTomas Winkler1-13/+71
Take rpm token on operation start to initiate rpm resume if needed. Mark last busy time, release token and advice rpm framework to try to autosuspend on operation end. Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-03-17mei: fix memory leak of pending write cb objectsTomas Winkler1-21/+55
Write callbacks are released on the write completed path but when file handler is closed before the writes are completed those are left dangling on write and write_waiting queues. We add mei_io_list_free function to perform this task Also move static functions to client.c form client.h Cc: stable <[email protected]> # 3.11+ Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-28mei: make return values consistent across the driverAlexander Usyskin1-12/+14
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 Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-28mei: revamp writing slot countingTomas Winkler1-10/+9
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 Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-28mei: add mei_hbuf_acquire wrapperTomas Winkler1-20/+36
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; Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-19Merge branch 'char-misc-linus' into char-misc-nextGreg Kroah-Hartman1-1/+3
We want the mei change here to allow future mei patches to apply properly. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-18mei: set client's read_cb to NULL when flow control failsChao Bi1-1/+3
In mei_cl_read_start(), if it fails to send flow control request, it will release "cl->read_cb" but forget to set pointer to NULL, leaving "cl->read_cb" still pointing to random memory, next time this client is operated like mei_release(), it has chance to refer to this wrong pointer. Fixes: PANIC at kfree in mei_release() [228781.826904] Call Trace: [228781.829737] [<c16249b8>] ? mei_cl_unlink+0x48/0xa0 [228781.835283] [<c1624487>] mei_io_cb_free+0x17/0x30 [228781.840733] [<c16265d8>] mei_release+0xa8/0x180 [228781.845989] [<c135c610>] ? __fsnotify_parent+0xa0/0xf0 [228781.851925] [<c1325a69>] __fput+0xd9/0x200 [228781.856696] [<c1325b9d>] ____fput+0xd/0x10 [228781.861467] [<c125cae1>] task_work_run+0x81/0xb0 [228781.866821] [<c1242e53>] do_exit+0x283/0xa00 [228781.871786] [<c1a82b36>] ? kprobe_flush_task+0x66/0xc0 [228781.877722] [<c124eeb8>] ? __dequeue_signal+0x18/0x1a0 [228781.883657] [<c124f072>] ? dequeue_signal+0x32/0x190 [228781.889397] [<c1243744>] do_group_exit+0x34/0xa0 [228781.894750] [<c12517b6>] get_signal_to_deliver+0x206/0x610 [228781.901075] [<c12018d8>] do_signal+0x38/0x100 [228781.906136] [<c1626d1c>] ? mei_read+0x42c/0x4e0 [228781.911393] [<c12600a0>] ? wake_up_bit+0x30/0x30 [228781.916745] [<c16268f0>] ? mei_poll+0x120/0x120 [228781.922001] [<c1324be9>] ? vfs_read+0x89/0x160 [228781.927158] [<c16268f0>] ? mei_poll+0x120/0x120 [228781.932414] [<c133ca34>] ? fget_light+0x44/0xe0 [228781.937670] [<c1324e58>] ? SyS_read+0x68/0x80 [228781.942730] [<c12019f5>] do_notify_resume+0x55/0x70 [228781.948376] [<c1a7de5d>] work_notifysig+0x29/0x30 [228781.953827] [<c1a70000>] ? bad_area+0x5/0x3e Cc: stable <[email protected]> # 3.9+ Signed-off-by: Chao Bi <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-18mei: don't of list_for_each_entry_safe when not deletingTomas Winkler1-12/+11
We can use simply list_for_each_entry if there is no entry removal Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-18mei: use helper function to find me client by idAlexander Usyskin1-31/+31
We already have a helper to find me client by id, let's use it in all relevant places. Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-18mei: fix potential read outside of array boundsAlexander Usyskin1-13/+10
Drop not-very-useful check and with this fix read on index that can be after array end. Cleanup search function as byproduct. Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-18mei: hbm: revamp client connect and disconnection statusAlexander Usyskin1-6/+7
1. Return -ENOTTY on client connect if the requested client was not found on the enumeration list or the client was internally disabled, in the later case FW will return NOT_FOUND. 2. Return -EBUSY if the client cannot be connected because of resource contention 3. Change response status enum to have MEI_CL_ prefix 4. Add function to translate response status to a string for more readable logging Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-18Merge 3.14-rc3 into char-misc-nextGreg Kroah-Hartman1-2/+9
We need the fixes here for future mei and other patches. Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-14mei: rename MEI_FOP_IOCTL to MEI_FOP_CONNECTTomas Winkler1-1/+1
This operation actually only support connection and not a generic ioctl Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-07mei: don't unset read cb ptr on resetAlexander Usyskin1-1/+0
Don't set read callback to NULL during reset as this leads to memory leak of both cb and its buffer. The memory is correctly freed during mei_release. The memory leak is detectable by kmemleak if application has open read call while system is going through suspend/resume. unreferenced object 0xecead780 (size 64): comm "AsyncTask #1", pid 1018, jiffies 4294949621 (age 152.440s) hex dump (first 32 bytes): 00 01 10 00 00 02 20 00 00 bf 30 f1 00 00 00 00 ...... ...0..... 00 00 00 00 00 00 00 00 36 01 00 00 00 70 da e2 ........6....p.. backtrace: [<c1a60aec>] kmemleak_alloc+0x3c/0xa0 [<c131ed56>] kmem_cache_alloc_trace+0xc6/0x190 [<c16243c9>] mei_io_cb_init+0x29/0x50 [<c1625722>] mei_cl_read_start+0x102/0x360 [<c16268f3>] mei_read+0x103/0x4e0 [<c1324b09>] vfs_read+0x89/0x160 [<c1324d5f>] SyS_read+0x4f/0x80 [<c1a7b318>] syscall_call+0x7/0xb [<ffffffff>] 0xffffffff unreferenced object 0xe2da7000 (size 512): comm "AsyncTask #1", pid 1018, jiffies 4294949621 (age 152.440s) hex dump (first 32 bytes): 00 6c da e2 7c 00 00 00 00 00 00 00 c0 eb 0c 59 .l..|..........Y 1b 00 00 00 01 00 00 00 02 10 00 00 01 00 00 00 ................ backtrace: [<c1a60aec>] kmemleak_alloc+0x3c/0xa0 [<c131f127>] __kmalloc+0xe7/0x1d0 [<c162447e>] mei_io_cb_alloc_resp_buf+0x2e/0x60 [<c162574c>] mei_cl_read_start+0x12c/0x360 [<c16268f3>] mei_read+0x103/0x4e0 [<c1324b09>] vfs_read+0x89/0x160 [<c1324d5f>] SyS_read+0x4f/0x80 [<c1a7b318>] syscall_call+0x7/0xb [<ffffffff>] 0xffffffff Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-02-07mei: clear write cb from waiting list on resetAlexander Usyskin1-1/+9
Clear write callbacks sitting in write_waiting list on reset. Otherwise these callbacks are left dangling and cause memory leak. Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-01-13mei: limit the number of consecutive resetsTomas Winkler1-0/+1
give up reseting after 3 unsuccessful tries Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2014-01-08mei: fix syntax in comments and debug outputAlexander Usyskin1-11/+11
Fix syntax errors in comments and debug strings Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-12-18mei: enable marking internal commandsTomas Winkler1-0/+2
Set hbm header bit 30 for internal commands This mark commands that are generated by the device driver Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-11-27mei: drop redundant list_del_initAlexander Usyskin1-2/+0
list_del_init appears twice in row in mei_cl_unlink, drop one. Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-10-29mei: mei_cl_link remove duplicated check for open_handle_countTomas Winkler1-6/+0
Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-10-19mei: move host_clients_map cleanup to device initAlexander Usyskin1-9/+0
Move host_clients_map cleanup from host client init to device init. This fixes bug where we cleaned up the bitmask that servers as pool for host client ids while file descriptors are kept open during suspend. On resume a new connection will be assigned id that is already taken by opened file descriptor. Consequently read/write will fail due to mismatched book keeping. Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-10-03mei: revamp open handler countsTomas Winkler1-4/+15
Make open counter to be incremented and decremented from mei_cl_link and mei_cl_unlik function respectively Nfc was assuming symmetric linking API and thus open handler count was never decreased. This patch fixes that. We need to add separate open hander count for amthif which is handled out of link/unlink functions and doesn't break the symmetric API. Last we do not waste clients slots if amthif or wd are not present in the device. we don't need to allocates slots ahead it is all covered by link/unlink before the devices is responding to user space connection and thus not racing on allocation Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-10-03mei: simplify mei_open error handlingTomas Winkler1-1/+7
1. Perform simple checks first and only then attempt to allocate cl structure. 2. Remove open_handler_count test, this is already checked in mei_cl_link function 3. return -EMFILE instead of -ENOENT as expected by user space Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-26mei: mei_cl_unlink: no need to loop over dev listTomas Winkler1-9/+4
we can call list_del_init regardless the client is linked or not it is always properly initialized Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-26mei: push credentials inside the irq write handlerTomas Winkler1-5/+25
this eventually allows as use a single write queue both for control and data messages and removing possible race Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-26mei: propagate error from write routines instead of ENODEVTomas Winkler1-8/+9
ENODEV will cause application to try to reconnect since it assumes that device went through the reset write errors are not always fatal it can happen due to resource contention Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-26mei: prefix client log messages with client me and host idsAlexander Usyskin1-21/+22
define cl_dbg and cl_err macros that add me and host id prefix for debug and error log messages so we can track for the client context of the flow. Signed-off-by: Alexander Usyskin <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-09-26mei: mei_cl_link protect open_handle_count from overflowTomas Winkler1-0/+6
mei_cl_link is called both from mei_open and also from in-kernel drivers so we need to protect open_handle_count from overflow Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-07-26mei: don't get stuck in select during resetTomas Winkler1-4/+1
Clear pending connection after hw reset but before hw start and wake up the waiting task in poll. Signal POLLERR in select when device went through reset. Add wrapper mei_cl_is_connected for checking if the device and client are connected. Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-07-24mei: wake also writers on resetTomas Winkler1-3/+7
wake writers otherwise might have processes waiting endlessly on wait_tx during reset Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
2013-06-24mei: mei_cl_connect: don't multiply the timeout twiceFrode Isaksen1-2/+1
MEI_CL_CONNECT_TIMEOUT is the timeout in seconds to wait for a response in mei_cl_connect. The value was converted to jiffies using mei_secs_to_jiffies helper function and assigned to a local variable which is by mistake again multiplied by HZ Signed-off-by: Frode Isaksen <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>