summaryrefslogtreecommitdiff
path: root/drivers/misc/mei/interrupt.c
AgeCommit message (Collapse)Author
2017-06-13mei: validate the message header only in first fragment.Tomas Winkler
RX message header is received in the first fragment of the message and saved side and it is not modified after that, we don't need to validate it upon each fragment. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08mei: drop amthif internal clientAlexander Usyskin
AMTHIF has special support in the mei drive, it handles multiplexing multiple user space connection above single me client connection. Since there is no additional addressing information there is a strict requirement on the traffic order on each connection and on the "read after write" order within the connection. This creates a lot of complexity mostly because the other client types do not necessarily fall under the same restriction. After carefully studying the use of the AMTHIF client, we came to conclusion that the multiplexing is not really utilized by any application and we may safely remove that support and significantly simplify the driver. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-31mei: replace callback structures used as list head by list_headAlexander Usyskin
mei_dev structure used struct mei_cl_cb type variables as for holding callbacks list heads. Replace them by the actual struct list_head as there is no other info that is handled. This slims down the mei_dev structure and mostly streamline the code. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-11-15mei: consolidate repeating code in mei_cl_irq_read_msgTomas Winkler
A cb is always placed on the completion queue during discarding queue. Hence this can be performed upon discard. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-27mei: stop the stall timer worker if not neededAlexander Usyskin
The stall timer worker checks periodically if there is a stalled i/o transaction. The issue with the current implementation is that the timer is ticking also when there is no pending i/o transaction. This patch provides a simple change that prevents rescheduling of the delayed work when there is no pending i/o. Cc: Andy Lutomirski <luto@kernel.org> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30mei: enqueue consecutive readsAlexander Usyskin
The FW supports only one pending read per host client, in order to support issuing of consecutive reads the driver queues read requests internally and send them to the firmware after pending one has completed. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30mei: drop redundant krealloc and checks in irq readAlexander Usyskin
The read callback is always prepared with MTU-sized buffer and the FW can't send more than the MTU in one message. Checking for buffer existence and krealloc to increase receive buffer size are redundant and may be safely discarded. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30mei: add read callback on demand for fixed_address clientsAlexander Usyskin
The Fixed address clients do not work with the flow control, and the packet RX callback was allocated upon TX with anticipation of a following RX. This won't work if the clients with unsolicited Rx. Rather than preparing read callback upon a write we allocate one directly on the reciev path if one doesn't exists. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30mei: add file pointer to the host client structureAlexander Usyskin
Store the file associated with a client in the host client structure, this enables dropping the special amthif client file pointer from struct mei_device, and this is also a preparation for changing the way rx packet allocation for fixed_address clients Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30mei: move read cb to complete queue if not connectedAlexander Usyskin
Move read cb to the completion queue if a read finds out that client is not connected. This expedite user space reader wake on error condition. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30mei: amthif: drop iamthif_current_cbAlexander Usyskin
iamthif_current_cb was used in request cancel in amthif code. Now a canceled request is discarded only at the end of the processing and the variable lost its purpose and can be safely removed. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30mei: amthif: fix request cancelAlexander Usyskin
Currently, all requests cancelled by the user are immediately removed from the queues. Such removal can cause unexpected behavior in the case when a request is partially written or a reply is received after the request is cancelled. To resolve this a request is always fully processed and the result is discarded in case the request was canceled. This completes the partial fix in commit: 9d04ee1 ("mei: amthif: discard not read messages") Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30mei: amthif: discard not read messagesAlexander Usyskin
When a message is received and amthif client is not in reading state the message is ignored and left dangling in the queue. This may happen after one of the amthif host connections is closed w/o completing the reading. Another client will pick up a wrong message on next read attempt which will lead to link reset. To prevent this the driver has to properly discard the message when amthif client is not in reading state. Cc: <stable@vger.kernel.org> #4.2+ Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-30mei: fix NULL dereferencing during FW initiated disconnectionAlexander Usyskin
In the case when disconnection is initiated from the FW the driver is flushing items from the write control list while iterating over it: mei_irq_write_handler() list_for_each_entry_safe(ctrl_wr_list) <-- outer loop mei_cl_irq_disconnect_rsp() mei_cl_set_disconnected() mei_io_list_flush(ctrl_wr_list) <-- destorying list We move the list flushing to the completion routine. Cc: <stable@vger.kernel.org> #4.2+ Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-20mei: fix format string in debug printsAlexander Usyskin
buf_idx type was changed to size_t, and few places missed out to change the print format from %ld to %zu. Use also uz for buf.size which is also of size_t Fixes: commit 56988f22e097 ("mei: fix possible integer overflow issue")' Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07mei: discard replies from unconnected fixed address clientsAlexander Usyskin
A fixed address client in the FW doesn't have a notion of connection and can send message after the file associated with it was already closed. Silently discard such messages. Add inline helpers to detect whether a message is hbm or intended for a fixed address client Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07mei: amthif: replace amthif_rd_complete_list with rd_completedTomas Winkler
Now when we have per client rd_completed list we can remove the amthif specific amthif_rd_complete_list. In addition in the function mei_amthif_read do not loop over the rd_completed list like the original code as the code path is unlocked. Reviewed-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07mei: rename variable names 'file_object' to fpTomas Winkler
The driver uses three names file, fp, and file_object for struct file type. To improve code clarity and adjust to my taste rename file_object to more common and shorter fp. Reviewed-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07mei: amthif: don't drop read packets on timeoutAlexander Usyskin
Since the driver now uses a list for storing read packets instead of single variable a pending read is no longer blocking other connections. A pending read will be discarded up the file closure. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-07mei: fix possible integer overflow issueTomas Winkler
There is a possible integer overflow following by a buffer overflow when accumulating messages coming from the FW to compose a full payload. Occurrence of wrap around has to be prevented for next message size calculation. For unsigned integer the addition overflow has occurred when the result is smaller than one of the arguments. To simplify the fix, the types of buf.size and buf_idx are set to the same width, namely size_t also to be aligned with the type of length parameter in file read/write ops. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-06mei: wd: drop the watchdog code from the core mei driverAlexander Usyskin
Instead of integrating the iAMT watchdog in the mei core driver we will create a watchdog device on the mei client bus and create a driver for it. This patch removes the watchdog code from the mei core driver. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-17mei: keep the device awake during reads in chunksAlexander Usyskin
Long messages are read in chunks, to prevent trashing runtime pm between the reading of the chunks we call pm_runtime_mark_last_busy() on non-final chunk message as the next chunk of the same message will be received immediately in the next interrupt with high probablity. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-03mei: add mei_cl_notify_request commandTomas Winkler
Add per client notification request infrastructure that allows client to enable or disable async event notification. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-08-03mei: disconnect on connection request timeoutAlexander Usyskin
For the FW with HBM version >= 2.0 we don't need to reset the whole device in case of a particular client failing to connect, it is enough to send disconnect a request to bring the device to the stable state. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-24mei: support for fixed address clientsAlexander Usyskin
Fixed address is simplified FW client that doesn't require connection and doesn't support flow control. So it can be only one host client per fixed FW client. Fixed client access is available only for drivers on mei bus, connection from user-space is blocked. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-24mei: add a reference from the host client to the me clientAlexander Usyskin
Keep a pointer to associated me client in the host client object to eliminate me client searches. Check if the me client is active in the firmware by checking if its is linked on the me clients list Add accessors for the me client properties from host client. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-24mei: revamp client connectionTomas Winkler
Simplify connect state machine by changing the logic around Connection request in progress - only check if we have a callback in relevant queue. Extract common code into mei_cl_send_connect() function Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-24mei: revamp client disconnection flowTomas Winkler
Split disconnected state into two parts first reception disconnect response from the firmware and second actually setting of disconnected state. Book keeping data are needed for processing and after firmware disconnected the client and are cleaned when setting the disconnected state in mei_cl_set_disconneted() function. Add mei_cl_send_disconnect to reduce code duplication. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-04-03mei: use mei_cl_is_connected consistentlyTomas Winkler
Replace open coded check for cl->state !=/== MEI_FILE_CONNECTED with mei_cl_is_connected function. Note that cl->state != MEI_FILE_CONNECTED is not the same as cl->state == MEI_FILE_DISCONNECTED Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-01mei: allow read concurrencyTomas Winkler
Replace clunky read state machine with read stack implemented as per client read list, this is important mostly for mei drivers with unsolicited reads Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-01mei: simplify io callback disposalTomas Winkler
Simplify disposal of io callback by removing the callback implicitly from its lookup list inside mei_io_cb_free Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-01mei: use only one buffer in callbackTomas Winkler
The callback structure is used exclusively for reading or writing therefore there is no reason to hold both response and request buffers in the callback structure Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-01mei: iamthif: use regular client read functionsTomas Winkler
Reduce code duplication in amthif by reusing regular client read functions. The change also removes the need for amthif own buffering Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-01mei: iamthif: send flow control as a regular clientTomas Winkler
Reuse common client mechanism for sending flow control hbm message. Add new function mei_amthif_read_start similar to mei_cl_read_start that puts control flow request onto the control write queue and drop mei_amthif_irq_read function Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-01mei: iamthif: remove useless iamthif_ioctl variableTomas Winkler
iamthif_ioctl is obsolete and can be safely dropped Currently it is set to true during driver runtime Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-01mei: iamthif: fix device reset on mei_amthif_irq_read_msgTomas Winkler
On failure mei_amthif_irq_read_msg returns an error that will cause device reset but the issue is software one so instead we should propagate error to caller and just clean the read queues. As a side effect also removes useless BUG_ONs Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-01mei: fix device reset on mei_cl_irq_read_msg allocation failureTomas Winkler
On memory allocation failure mei_cl_irq_read_msg will return with error that will cause device reset. Instead we should propagate error to caller and just clean the read queues. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-03mei: drop unneeded client NULL check in cb structureAlexander Usyskin
The pointer to client in the callback structure (cb->cl) can't be NULL with current locking. We can drop check and warnings as in some cases this just uselessly complicates the code flow. Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-29mei: fix kernel-doc warningsAlexander Usyskin
Add missed parameters descriptions and return values descriptions Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-29mei: fix KDoc documentation formattingAlexander Usyskin
Fix Kdoc documentation formatting warnings genertaed by ./scripts/kernel-doc Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-29mei: remove include to pci header from mei module filesTomas Winkler
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 <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-29mei: get rid of most of the pci dependencies in meiTomas Winkler
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 <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-29mei: kill error message for allocation failureTomas Winkler
There is no need to log memory allocation errors as this is already done by the memory subsystem. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-23mei: use disconnect name consistentlyTomas Winkler
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 <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-23mei: amthif: use service function to flush amthif queueAlexander Usyskin
Replace open coded loop with an existing service function: mei_io_list_flush Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-04-16mei: ignore client writing state during cb completionAlexander Usyskin
Ignore client writing state during cb completion to fix a memory leak. When moving cbs to the completion list we should not look at writing_state as this state can be already overwritten by next write, the fact that a cb is on the write waiting list means that it was already written to the HW and we can safely complete it. Same pays for wait in poll handler, we do not have to check the state wake is done after completion list processing. Cc: stable@vger.kernel.org Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-17mei: make me hw headers private to me hw.Tomas Winkler
Remove includes of me-hw.h and me-hw-regs.h headers from the mei generic code. The mei layer should not depend on hw specific headers Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-17mei: me: do not reset when less than expected data is receivedTomas Winkler
There is a race in ME hardware between data copy for host and interrupt delivery. An interrupt can be delivered prior to whole data copied for the host to read but rather then going trough the reset we just merely need to wait for the next interrupt. The bug is visible in read/write stress with multiple connections per client This is a regression caused as a side effect of the commit: commit 544f94601409653f07ae6e22d4a39e3a90dceead mei: do not run reset flow from the interrupt thread Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Cc: stable <stable@vger.kernel.org> # 3.14 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-08mei: fix regressions caused by removing ext_msgAlexander Usyskin
1. Delete cb from list before freeing it 2. Fix missed break that leads to switch case fall-through and BUG invocation. Regression from: commit 6bb948c9e500d24321c36c67c81daf8d1a7e561e mei: get rid of ext_msg Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-28mei: wd: fix stop completion failureTomas Winkler
While running Documentation/watchdog/src/watchdog-simple.c and quiting by Ctrl-C, fallowing error is displayed: mei_me 0000:00:16.0: wd: stop failed to complete ret=-512. The whatchdog core framework is not able to propagate -ESYSRESTART or -EINTR. Also There is no much sense in restarting the close system call so instead of using wait_event_interruptible_timeout we can use wait_event_timeout with reasonable 10 msecs timeout. Reported-by: Prarit Bhargava <prarit@redhat.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>