History log of /linux-master/drivers/misc/mei/main.c
Revision Date Author Comments
# 3b54a111 11-Oct-2023 Randy Dunlap <rdunlap@infradead.org>

misc: mei: main.c: fix kernel-doc warnings

Fix kernel-doc warnings in main.c:

main.c:465: warning: contents before sections
main.c:590: warning: missing initial short description on line:
* mei_ioctl_client_notify_request -

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20231012024845.29169-8-rdunlap@infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# df8e2c3e 11-Aug-2023 Ivan Orlov <ivan.orlov0322@gmail.com>

mei: make mei_class a static const structure

Now that the driver core allows for struct class to be in read-only
memory, move the mei_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230811213052.85044-1-ivan.orlov0322@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1fb1ea0d 10-Mar-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

mei: Move uuid.h to the MEI namespace

There is only a single user of the UUID uAPI, let's make it
part of that user.

The way it's done is to prevent compilation time breakage for
the user space that does

#include <linux/uuid.h>

In the future MEI user space tools can switch over to use mei_uuid.h.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230310170747.22782-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1aaba11d 13-Mar-2023 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

driver core: class: remove module * from class_create()

The module pointer in class_create() never actually did anything, and it
shouldn't have been requred to be set as a parameter even if it did
something. So just remove it and fix up all callers of the function in
the kernel tree at the same time.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20230313181843.1207845-4-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 83f47eea 16-Nov-2022 Alexander Usyskin <alexander.usyskin@intel.com>

mei: add timeout to send

When driver wakes up the firmware from the low power state,
it is sending a memory ready message.
The send is done via synchronous/blocking function to ensure
that firmware is in ready state. However, in case of firmware
undergoing reset send might be block forever.
To address this issue a timeout is added to blocking
write command on the internal bus.

Introduce the __mei_cl_send_timeout function to use instead of
__mei_cl_send in cases where timeout is required.
The mei_cl_write has only two callers and there is no need to split
it into two functions.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Link: https://lore.kernel.org/r/20221116124735.2493847-2-alexander.usyskin@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 95953618 07-Sep-2022 Alexander Usyskin <alexander.usyskin@intel.com>

mei: extend timeouts on slow devices

Parametrize operational timeouts in order
to support slow firmware on some graphics devices.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220907215113.1596567-9-tomas.winkler@intel.com
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>


# 09f8c33a 21-Jun-2021 Tamar Mashiah <tamar.mashiah@intel.com>

mei: fix kdoc in the driver

Over time the functions were renamed,
but this was not always reflected in kdoc, fix that.

Signed-off-by: Tamar Mashiah <tamar.mashiah@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20210621193756.134027-1-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ca263dd8 10-May-2021 Guenter Roeck <linux@roeck-us.net>

mei: Drop unnecessary NULL check after container_of

The result of container_of() operations is never NULL unless the embedded
element is the first element of the data structure, which is not the case
here. The NULL check is therefore unnecessary and misleading. Remove it.

This change was made automatically with the following Coccinelle script.

@@
type t;
identifier v;
statement s;
@@

<+...
(
t v = container_of(...);
|
v = container_of(...);
)
...
when != v
- if (\( !v \| v == NULL \) ) s
...+>

Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210511045512.2376580-1-linux@roeck-us.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e666b79e 08-Feb-2021 Tomas Winkler <tomas.winkler@intel.com>

mei: use sysfs_emit() in tx_queue_limit_show sysfs

Using of snprintf is discouraged in sysfs use the new sysfs_emit() API.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20210208150649.141358-2-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# aa207a05 18-Aug-2020 Alexander Usyskin <alexander.usyskin@intel.com>

mei: add connect with vtag ioctl

This IOCTL is used to associate the current file descriptor
with a FW Client (given by UUID), and virtual tag (vtag).
The IOCTL opens a communication channel between a host client
and a FW client on a tagged channel. From this point on,
every reader and write will communicate with the associated
FW client on the tagged channel. Upon close() the communication
is terminated.

The IOCTL argument is a struct with a union that contains
the input parameter and the output parameter for this IOCTL.

The input parameter is UUID of the FW Client, a vtag [0,255]
The output parameter is the properties of the FW client

Clients that do not support tagged connection
will respond with -EOPNOTSUPP

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20200818115147.2567012-12-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f35fe5f4 18-Aug-2020 Alexander Usyskin <alexander.usyskin@intel.com>

mei: add a vtag map for each client

Vtag map is a list of tuples of vtag and file pointer (struct
mei_cl_vtag) associated with a particular me host client.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20200818115147.2567012-8-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d1376f3d 18-Aug-2020 Alexander Usyskin <alexander.usyskin@intel.com>

mei: add a spin lock to protect rd_completed queue

In order to support vtags we need to access read completed
queue out of driver big lock.
Add a spin lock to protect rd_completed queue.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20200818115147.2567012-7-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2f79d3d1 28-Jul-2020 Alexander Usyskin <alexander.usyskin@intel.com>

mei: add device kind to sysfs

Some of the mei device heads are not generic and have
a specific purpose, we need to announce it to the user space
so it is possible to detect the correct device node via
matching attributes.

Generic heads are marked as 'mei' while special purpose heads
have their own names. Currently we are adding 'itouch' string
for Intel IPTS 1.0, 2.0 devices.

This is done via new sysfs attribute 'kind'.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20200728192242.3117779-1-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b4a6700c 23-Jul-2020 Tomas Winkler <tomas.winkler@intel.com>

mei: ioctl: use sizeof of variable instead of struct type

Use sizeof(connect_data))) instead of
sizeof(struct mei_connect_client_data) when copying data
between user space and kernel.

There is a possibility of bug when variable type has changed but
corresponding struct passed to the sizeof has not.

Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20200723145927.882743-3-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 52f6efdf 06-Nov-2019 Alexander Usyskin <alexander.usyskin@intel.com>

mei: add trc detection register to sysfs

The glitch detection HW (TRC) save it status information into
TRC status register.
Make it available to user-space via read-only sysfs file.
The TRC register is availab for PCH15 gen and newer, for older
platforms reading the sysfs file will fail with EOPNOTSUPP.

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Link: https://lore.kernel.org/r/20191107104445.19101-1-tomas.winkler@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 407e9ef7 11-Sep-2018 Arnd Bergmann <arnd@arndb.de>

compat_ioctl: move drivers to compat_ptr_ioctl

Each of these drivers has a copy of the same trivial helper function to
convert the pointer argument and then call the native ioctl handler.

We now have a generic implementation of that, so use it.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Jiri Kosina <jkosina@suse.cz>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>


# 4495dfdd 23-Jul-2019 Suzuki K Poulose <suzuki.poulose@arm.com>

drivers: Introduce device lookup variants by device type

Add a helper to match a device by its type and provide wrappers
for {bus/class/driver}_find_device() APIs.

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-usb@vger.kernel.org
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20190723221838.12024-5-suzuki.poulose@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5666d896 11-Jun-2019 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

mei: no need to check return value of debugfs_create functions

When calling debugfs functions, there is no need to ever check the
return value. The function can work or not, but the code logic should
never do something different based on this.

Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 43b8a7ed 22-Apr-2019 Alexander Usyskin <alexander.usyskin@intel.com>

mei: expose device state in sysfs

Expose mei device state to user-space through sysfs.
This gives indication to applications that driver is in transition,
usefully mostly to detect link reset 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>


# 1e55b609 11-Mar-2019 Tomas Winkler <tomas.winkler@intel.com>

mei: adjust the copyright notice in the files.

Use unified version of the copyright notice in the files
Update copyright years according the year the files
were touched, except this patch and SPDX conversions.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9fff0425 11-Mar-2019 Tomas Winkler <tomas.winkler@intel.com>

mei: convert to SPDX license tags

Replace boiler plate licenses texts with the SPDX license
identifiers in the mei files header.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 03b2cbb6 28-Sep-2018 Tomas Winkler <tomas.winkler@intel.com>

mei: replace POLL* with EPOLL* for write queues.

Looks like during merging the bulk POLL* -> EPOLL* replacement
missed the patch
'commit af336cabe083 ("mei: limit the number of queued writes")'

Fix sparse warning:
drivers/misc/mei/main.c:602:13: warning: restricted __poll_t degrades to integer
drivers/misc/mei/main.c:605:30: warning: invalid assignment: |=
drivers/misc/mei/main.c:605:30: left side has type restricted __poll_t
drivers/misc/mei/main.c:605:30: right side has type int

Fixes: af336cabe083 ("mei: limit the number of queued writes")
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5151e2b5 12-Jul-2018 Tomas Winkler <tomas.winkler@intel.com>

mei: fix ssize_t to int assignment in read and write ops.

Use ssize_t for rets variables in mei_write(), mei_read(), and
mei_cl_write() as well as change the return type of mei_cl_write()
to ssize_t, to prevent assignment of possible 64bit size_t
to int 32 bit variable.

As by product also eliminate warning
drivers/misc/mei/client.c:1702:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a103af1b 08-Jul-2018 Alexander Usyskin <alexander.usyskin@intel.com>

mei: don't update offset in write

MEI enables writes of complete messages only
while read can be performed in parts, hence
write should not update the file offset to
not break interleaving partial reads with writes.

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>


# 3cfaeb33 24-Jun-2018 Alexander Usyskin <alexander.usyskin@intel.com>

mei: expose fw version to sysfs

The ME FW version is constantly used by detection and update tools.
To improve the reliability and simplify these tools provide
a sysfs interface to access version of the platform ME firmware
in the following format:
<platform>:<major>.<minor>.<milestone>.<build>.
There can be up to three such blocks for different FW components.

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>


# bb0829a7 27-Feb-2018 Colin Ian King <colin.king@canonical.com>

mei: remove dev_err message on an unsupported ioctl

Currently the driver spams the kernel log on unsupported ioctls which is
unnecessary as the ioctl returns -ENOIOCTLCMD to indicate this anyway.
I suspect this was originally for debugging purposes but it really is not
required so remove it.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# af336cab 25-Feb-2018 Alexander Usyskin <alexander.usyskin@intel.com>

mei: limit the number of queued writes

Limit the number of queued writes per client.
Writes above this threshold are blocked till place
in the transmit queue is available.
The limit is configurable via sysfs and defaults to 50.
The implementation should provide blocking I/O behavior.
Prior to this change one would end up in the hands of OOM.

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>


# a9a08845 11-Feb-2018 Linus Torvalds <torvalds@linux-foundation.org>

vfs: do bulk POLL* -> EPOLL* replacement

This is the mindless scripted replacement of kernel use of POLL*
variables as described by Al, done by this script:

for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
done

with de-mangling cleanups yet to come.

NOTE! On almost all architectures, the EPOLL* constants have the same
values as the POLL* constants do. But they keyword here is "almost".
For various bad reasons they aren't the same, and epoll() doesn't
actually work quite correctly in some cases due to this on Sparc et al.

The next patch from Al will sort out the final differences, and we
should be all done.

Scripted-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# afc9a42b 03-Jul-2017 Al Viro <viro@zeniv.linux.org.uk>

the rest of drivers/*: annotate ->poll() instances

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 01699437 03-Jul-2017 Al Viro <viro@zeniv.linux.org.uk>

annotate poll_table_struct ->_key

Only POLL... bitmaps ever end up there and their only use is checking
for POLL... bits in them.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 58cde1a6 20-Mar-2017 Alexander Usyskin <alexander.usyskin@intel.com>

mei: implement fsync

When write() returns successfully, it is only assumed that a message
was successfully queued. Add fsync syscall implementation to help
user-space ensure that all data is written.

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>


# 394a77d0 20-Mar-2017 Alexander Usyskin <alexander.usyskin@intel.com>

mei: drop amthif internal client

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>


# 174cd4b1 02-Feb-2017 Ingo Molnar <mingo@kernel.org>

sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h>

Fix up affected files that include this signal functionality via sched.h.

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# cb97fbbc 07-Feb-2017 Alexander Usyskin <alexander.usyskin@intel.com>

mei: remove support for broken parallel read

Parallel reads from multiple threads on a file descriptor
are not well defined and racy. It is safer to return to original
behavior and simply fail the additional read.
The solution is to remove request for next read credit.

Cc: <stable@vger.kernel.org> #4.9
Fixes: ff1586a7ea57 ("mei: enqueue consecutive reads")
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>


# e0cb6b2f 08-Nov-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: enable to set the internal flag for client write

Prepare the client write functions to set the internal flag in message
header. Carry both blocking and internal modes inside the transmit cb,
and call internal bus function __mei_cl_send() with send mode bit mask.
The Internal flag should be added only on messages generated by 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>


# 88d1bece 29-Oct-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: show the HBM protocol versions in the device attributes

The HBM protocol version is negotiated during the setup phase, then settled
on a highest possible common version of the driver and the firmware.
The sysfs API advertises both negotiated and driver supported versions
in the device attributes.

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>


# 9d27e73c 25-Jul-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: amthif: drop mei_amthif_read

mei_amthif_read have only one difference from mei_read, it is not
calling mei_read_start().
Make mei_read_start return immediately for amthif client and drop the
special mei_amthif_read function.

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>


# ff1586a7 25-Jul-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: enqueue consecutive reads

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>


# 3030dc05 25-Jul-2016 Tomas Winkler <tomas.winkler@intel.com>

mei: add wrapper for queuing control commands.

Enclose the boiler plate code of allocating a control/hbm command cb
and enqueueing it onto ctrl_wr.list in a convenient wrapper
mei_cl_enqueue_ctrl_wr_cb().

This is a preparatory patch for enabling consecutive reads.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 97d549b4 16-Jun-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: add file pointer to the host client structure

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>


# 2d4d5481 22-Jun-2016 Tomas Winkler <tomas.winkler@intel.com>

mei: fix return value on disconnection

Correct errno on client disconnection is -ENODEV not -EBUSY

Cc: <stable@vger.kernel.org> #4.3+
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>


# 1eb5bd4d 16-Jun-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: drop read complete queue emptiness check

In the course of the read flow we want to wait for read completion only
if the read queue is empty.
However the calling list_empty(&cl->rd_completed) is a duplication as the
same check was performed by mei_cl_read_cb() and the waiting is skipped
if it returns not NULL.

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>


# 9fa0be8b 24-May-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: amthif: enable poll for async events

Currently the poll function is bailing early for amthif client and
ignores requests for async events notifications.
Move async event processing before amthif to enable async events
notifications on amthif 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>


# ca455faf 24-May-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: amthif: drop READ_COMPLETE state

AMTHIF code now uses read completed queue to store replies from the FW.
It is possible to send the next request as soon as a read from the FW is
completed. With these changes we don't need the READ_COMPLETE 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>


# 35bf7692 17-Feb-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: fix format string in debug prints

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>


# 6cbb097f 10-Feb-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: fix double freeing of a cb during link reset

Fix double freeing of the cb that can happen if link reset kicks in the
middle of blocked write from a device on the cl bus.

Free cb inside mei_cl_write function on failure and drop cb free
operation from callers, during a link reset the mei_cl_write function
returns with an error, but the caller doesn't know if the cb was
already queued or not so it doesn't know if the cb will be freed upon
queue reclaim or it has to free it itself.

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>


# 7851e008 07-Feb-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: drop reserved host client ids

The reserved host clients can be obsoleted now, a portion of the
platforms is shipped without iAMT enabled, where the reservation is not
relevant and for platforms with iAMT dynamic allocation is sufficient.
Dropping reserved ids makes enumeration more flexible and generic

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>


# f4e06246 07-Feb-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: fixed address clients for the new platforms

Enable by default connection to fixed address clients
from user-space for skylake and newer platform.

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>


# 06ee536b 07-Feb-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: fill file pointer in read cb for fixed address client

The read callback created from a flow control request for
a fixed address client have NULL in the file pointer.
Fill the file pointer using a data from a write callback.

This allows us to drop workaround introduced in:
commit eeabfcf5a92a ("mei: connection to fixed address clients from user-space")

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>


# f23e2cc4 07-Feb-2016 Tomas Winkler <tomas.winkler@intel.com>

mei: constify struct file pointer

The struct file file pointer is used as an opaque handle to for a
connected client, for this part the pointer should be immutable and
should be set to count.

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>


# d0df8dfb 07-Feb-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: amthif: don't drop read packets on timeout

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>


# f862b6b2 07-Feb-2016 Tomas Winkler <tomas.winkler@intel.com>

mei: fix possible integer overflow issue

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>


# 7326fffb 16-Jan-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: validate request value in client notify request ioctl

This patch address a possible security issue:

The request field in client notify request ioctl comes from user space
as u32 and is downcasted to u8 with out validation.
Check request field to have approved values
MEI_HBM_NOTIFICATION_STAR/STOP

Cc: <stable@vger.kernel.org> #4.3+
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>


# 8b2458f4 07-Jan-2016 Alexander Usyskin <alexander.usyskin@intel.com>

mei: always copy the read buffer if data is ready

Copy completed callback content to the user space
if we have such callback ready in the beginning of the read.
Simplify offset processing logic as byproduct.

This is a refinement for:
commit 139aacf757fc ("mei: fix read after read scenario")

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>


# ed6dc538 07-Jan-2016 Tomas Winkler <tomas.winkler@intel.com>

mei: fix fasync return value on error

fasync should return a negative value on error
and not poll mask POLLERR.

Cc: <stable@vger.kernel.org> # 4.3+
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 237092bf 26-Jul-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: implement fasync for event notification

A process can be informed about client notification also via
SIGIO with POLL_PRI event.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2c84c297 26-Jul-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: support polling for event notification

Polling on priority events is translated on waiting for event
notification. One need to enable notification prior for
calling select or poll system call otherwise process
will not wait.

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>


# 3c7c8468 26-Jul-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: add async event notification ioctls

Add ioctl IOCTL_MEI_NOTIFY_SET for enabling and disabling
async event notification.
Add ioctl IOCTL_MEI_NOTIFY_GET for receiving and acking
an 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>


# 154322f4 18-Jun-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: prevent unloading mei hw modules while the device is opened.

chrdev_open() increases reference counter on cdev->owner. Instead of
assigning the owner to mei subsystem, the owner has to be set to the
underlaying HW module (mei_me or mei_txe), so once the device is opened
the HW module cannot be unloaded.

Cc: <stable@vger.kernel.org> #3.17+
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>


# 292f82c8 04-May-2015 Alexander Usyskin <alexander.usyskin@intel.com>

mei: debug prints with client info in read

Add client info to debug prints in the read function to
ease on debugging efforts.

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>


# eeabfcf5 04-May-2015 Alexander Usyskin <alexander.usyskin@intel.com>

mei: connection to fixed address clients from user-space

This should be used for debug only.
The feaure is gated by "allow_fixed_address" control exposed in debugfs.

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>


# d49ed64a 04-May-2015 Alexander Usyskin <alexander.usyskin@intel.com>

mei: add a reference from the host client to the me client

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>


# 3c666182 04-May-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: revamp client disconnection flow

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>


# 6a84d63d 26-Mar-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: replace check for connection instead of transitioning

The function mei_cl_is_transitioning is just opposite
of mei_cl_is_connected. What we actually wanted to
check is if we lost connection so we can discard
the check for transition and check for 'not connected'

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f3de9b63 26-Mar-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: use mei_cl_is_connected consistently

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>


# 1d9013f0 26-Mar-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: fix mei_poll operation

mei_poll returned with POLLIN w/o checking whether the operation
has really completed.
remove redundant check and locking in amthif specific handler

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e2e40f2c 22-Feb-2015 Christoph Hellwig <hch@lst.de>

fs: move struct kiocb to fs.h

struct kiocb now is a generic I/O container, so move it to fs.h.
Also do a #include diet for aio.h while we're at it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# a9bed610 10-Feb-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: allow read concurrency

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>


# 928fa666 10-Feb-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: simplify io callback disposal

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>


# 03b8d341 10-Feb-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: add mei_cl_alloc_linked function

Add convenient wrapper mei_cl_alloc_linked
to simplify error handling

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bca67d68 10-Feb-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: always initialize the callback with the intended operation type

We set the operation type at initialization time as each cb is used only
for a single type of operation

As a byproduct we add a convenient wrapper for allocating cb with
the data buffer.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 5db7514d 10-Feb-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: use only one buffer in callback

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>


# 8660172e 10-Feb-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: iamthif: use client write functions

Reduce code duplication in amthif code by reusing
regular client write functions.
Add completed flag to cb so amthif client can add
rx credits on write completion

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3d33ff24 10-Feb-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: fix device reset on mei_cl_irq_read_msg allocation failure

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>


# 79563db9 10-Jan-2015 Tomas Winkler <tomas.winkler@intel.com>

mei: add reference counting for me clients

To support dynamic addition and removal of
me clients we add reference counter.

Update kdoc with locking requirements.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 55c4e640 19-Nov-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: export fw status registers through sysfs

The interface is for applications that monitor
the fw health.

We use device_create_with_groups interface
to register attribute with the mei class device

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a8605ea2 29-Sep-2014 Alexander Usyskin <alexander.usyskin@intel.com>

mei: fix KDoc documentation formatting

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>


# 1f180359 29-Sep-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: remove include to pci header from mei module files

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>


# 2bf94cab 29-Sep-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: get rid of most of the pci dependencies in mei

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>


# 2628118b 29-Sep-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: kill error message for allocation failure

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>


# 154eb18f 21-Aug-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: use connect_data on the stack

There is no need for dynamic allocation for connect_data.
We can use variable on the stack and make code less
error prone and simple

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4f046e7b 21-Aug-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: enable adding more IOCTL handlers

Handle ioctls in a switch statement so we can
add more commands easily

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d880f329 21-Aug-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: add mei_me_cl_by_uuid_id function

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 <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d320832f 23-Aug-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: me_client lookup function to return me_client object

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 <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# f3d8e878 23-Jun-2014 Alexander Usyskin <alexander.usyskin@intel.com>

mei: move from misc to char device

We need to support more then one mei interface
hence the simple misc devices is not longer an option

In order not break the user space a device with pci function 0
need to be linked to /dev/mei

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>


# e4d8270e 27-Apr-2014 Alexander Usyskin <alexander.usyskin@intel.com>

mei: set connecting state just upon connection request is sent to the fw

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 <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 34ec4366 01-Apr-2014 Alexander Usyskin <alexander.usyskin@intel.com>

mei: ignore client writing state during cb completion

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>


# 46922186 16-Mar-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: use cl_dbg where appropriate

use cl_dbg for debug log messages in cl context

this also removes checkpatch warning:
quoted string split across lines

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# dbac4745 12-Mar-2014 Alexander Usyskin <alexander.usyskin@intel.com>

mei: report consistently copy_from/to_user failures

Consistently display error on possible copy_from/to_user failures
use dev_dbg so it cannot be abused to flood the kernel log

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>


# 80260f23 11-Mar-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: drop pr_fmt macros

we are using dev_ logging facility so we don't need pr_fmt macros

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Reviewed-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6e4cd27a 11-Mar-2014 Tomas Winkler <tomas.winkler@intel.com>

mei: make me hw headers private to me hw.

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>


# 7ca96aa2 19-Feb-2014 Alexander Usyskin <alexander.usyskin@intel.com>

mei: make return values consistent across the driver

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 <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 285e2996 17-Feb-2014 Alexander Usyskin <alexander.usyskin@intel.com>

mei: hbm: revamp client connect and disconnection status

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 <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 83ce0741 08-Jan-2014 Alexander Usyskin <alexander.usyskin@intel.com>

mei: fix syntax in comments and debug output

Fix syntax errors in comments and debug strings

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>


# 22f96a0e 16-Sep-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: revamp open handler counts

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 <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e036cc57 16-Sep-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: simplify mei_open error handling

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 <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e2b31644 02-Sep-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: bus: stop wait for read during cl state transition

Bus layer omitted check for client state transition while waiting
for read completion
The client state transition may occur for example as result
of firmware initiated reset

Add mei_cl_is_transitioning wrapper to reduce the code
repetition.:

Cc: <stable@vger.kernel.org> # 3.9+
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a9c8a17a 15-Sep-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: mei_release: drop redundant check if cb is NULL

mei_io_cb_free follows kfree design and check for NULL internally

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# dd5de1f1 01-Sep-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: revamp read and write length checks

1. Return zero on zero length read and writes
2. For a too large write return -EFBIG as defined in man write(2)
EFBIG An attempt was made to write a file that
exceeds the implementation-defined maximum
file size or the process's file size limit,
or to write at a position past the maximum
allowed offset.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d8b29efa 01-Sep-2013 Alexander Usyskin <alexander.usyskin@intel.com>

mei: mei_write correct checks for copy_from_user

1. return -EFUALT when copy_from_user fails
2. display error message on failure in error level

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>


# b950ac1d 25-Jul-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: don't get stuck in select during reset

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 <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 139aacf7 29-May-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: fix read after read scenario

mei read always has to be preceded by write but
'write write read read' scenario should work as well.
In this case the offset is not zero but new read should
be initiated

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 7131799b 23-May-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: deprecate the mei_wd_state_independence_msg

wd independence is deprecated, remove it.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 80fe6361 07-May-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: fix out of array access to me clients array

The patch 9f81abdac362: "mei: implement mei_cl_connect function"
from Jan 8, 2013, leads to the following static checker warning:
"drivers/misc/mei/main.c:522 mei_ioctl_connect_client()
warn: check 'dev->me_clients[]' for negative offsets (-2)"

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 46e0cd87 07-May-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: fix out of array access to me clients array

The patch 9f81abdac362: "mei: implement mei_cl_connect function"
from Jan 8, 2013, leads to the following static checker warning:
"drivers/misc/mei/main.c:522 mei_ioctl_connect_client()
warn: check 'dev->me_clients[]' for negative offsets (-2)"

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# fcb136e1 19-Apr-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: fix reading large reposnes

While writting to device is limitted to max_msg_length advertized
in client properites the read can be much longer delivered consequiting chunks.

We use krealloc to enlarge the buffer when needed.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9b0d5efc 18-Apr-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: revamp hbm state machine

1. Rename init_clients_state to hbm_state and use
MEI_HBM_ prefix for HBM states

2. Remove recvd_msg and use hbm state for synchronizing
hbm protocol has successful start.
We can wake up the hbm event from start response handler
and remove the hack from the interrupt thread

3. mei_hbm_start_wait function encapsulate start completion
waiting

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4234a6de 08-Apr-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: add mei_cl_write function

consolidate write code to a specific me client in mei_cl_write function
the function is called from mei device write handler and from
mei_cl bus send function

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 30e53bb8 05-Apr-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: add debugfs hooks

debugfs exposes device state and list of me clients and their
properties

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# cf3baefb 27-Mar-2013 Samuel Ortiz <sameo@linux.intel.com>

mei: bus: Call bus routines from the core code

Register the MEI bus type against the kernel core bus APIs and
call the bus Rx handler from interrupt.c

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 40e0b67b 27-Mar-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: move mei-me to separate module

mei layer provides host bus message layer, client management,
and os interface

mei-me - provides access to ME hardware through
the pci bus

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 330dd7da 06-Feb-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: rename to mei_host_buffer_is_empty to hbuf_is_ready

we rename the mei_host_buffer_is_empty to keep naming
convention of hbuf and also make the query more generic
to be correct also for other under laying hardware

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 827eef51 06-Feb-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: separate compilation of the ME hardware specifics

We add struct mei_hw_ops to virtualize access to hw specific
configurations. This allows us to separate the compilation
of the ME interface from the ME hardware specifics

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 2703d4b2 06-Feb-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: sperate interface and pci code into two files

leave misc file operations in the main
and move PCI related code into pci-me

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 627ca757 08-Jan-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: move work initialization to mei_device_init

Let mei_device_init initialize all the software constructs.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9ea73ddd 08-Jan-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: use non cached hcsr for interrupt enablement

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 781d0d89 08-Jan-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: normalize me host client linking routines

In 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

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1a1aca42 08-Jan-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: rename remaining amthi strings to amthif

the only real thing that left was mei_amthi_guid
the rest was in the strings and comments

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d91aaed3 08-Jan-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: drop read_pending member form struct mei_cl

read_pending never changes, it is a leftover from the old code.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9dc64d6a 08-Jan-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: rename interface to hw-me

Rename 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

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9f81abda 08-Jan-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: implement mei_cl_connect function

Implement 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

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 90e0b5f1 08-Jan-2013 Tomas Winkler <tomas.winkler@intel.com>

mei: fix client functions names

Use 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

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 47a73801 25-Dec-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: include local headers after the system ones

first include linux/mei.h then only local headers
to avoid possible false dependencies

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 15d4acc5 25-Dec-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: use unified format for printing mei message header

Introduce MEI_HDR_FMT and MEI_HDR_PRM macros.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 438763f3 25-Dec-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: drop redundant length parameter from mei_write_message function

The length is already part of the message header and it is validated
before the function call

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 486a5c28 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

misc: remove use of __devexit

CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Eric Piel <eric.piel@tremplin-utc.net>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 80c8ae28 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

misc: remove use of __devinit

CONFIG_HOTPLUG is going away as an option so __devinit is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Eric Piel <eric.piel@tremplin-utc.net>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9306a8b0 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

mei: remove use of __devexit_p

CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c1174c0e 18-Nov-2012 Samuel Ortiz <sameo@linux.intel.com>

mei: Simplify the ME client enumeration code

After enumerating all ME clients we call the client init functions for
all matching UUIDs from a separate context.
This remove the hackish cascading client initialisation process that was
interleaving properties and connection command replies.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ff8b2f4e 11-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: use link and unlink terms for connecting ME and HOST client

1. rename mei_me_cl_update_filext to mei_me_cl_link
2. rename mei_remove_client_from_file_list to mei_me_cl_unlink

Code style, documenation, and usage of both function is updated

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 744f0f2f 11-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: extract amthif specific code from mei_poll to mei_amthif_poll

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a562d5c2 11-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: move amthif specific release code to amithif

Move amthif code part into separate function
mei_amthif_release.
Also helper functions mei_clear_list and mei_clear_lists
are moved along

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4b8960b4 11-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: rename enum mei_cb_major_types to enum mei_cb_file_ops

1. Rename mei_cb_major_types to more understandable mei_cb_file_ops
2. Rename member struct mei_cl_cb of this type to simple 'fop_type'
3. Add kernel doc for the type

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# db3ed431 11-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: use type struct mei_cl *cl instead of void in struct mei_cb

We can use correct type 'struct mei_cl' instead of
'void *' for file_private in the struct mei_cb
as there is no other type assigned to this member of the structure

We rename the member from file_private to cl

Remove about 10 lines of declarations of temporary variables
used for type casting

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# e773efc4 11-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: amthif: prefix cb list with amthif

amthif cb list were prefixed with amthi_ instead
if amthif.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ab5c4a56 01-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: move amthif specific code from mei_write to mei_amthif_write

For sake of amthif consolidation move amthif specific code from
mei_write to mei_amthif_write

The original mei_amthif_write to mei_amthif_send_cmd
as this function deals with sending single command
while mei_amthif_write is interface function called from
the main driver which in turns calls mei_amthif_send_cmd

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 15ea1910 01-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: mei_clear_list: kill file_temp

file_temp is used only once, so there is no any benefit of creating
a temporary variable

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 19838fb8 01-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: extract AMTHI functions into the amthif.c file

Move AMT Host Interface functions into the new amthif.c file.
All functions has now common prefix: mei_amthif_

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 3870c320 01-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: normalize timeouts definitions

1. The hardware book defines timeouts in seconds
so we stick to this and define the wrapper function
mei_secs_to_jiffies around msecs_to_jiffies
to use be used instead multiplying by HZ

2. We add name space prefix MEI_ to all timer defines

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b0d0cf77 01-Nov-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: mei_write: revamp function flow

Use goto statement for error handling instead of deeper if constructs
and rename label 'unlock_dev' to more appropriate 'err'

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 664df38b 11-Oct-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: use mei_io_cb_ warppers also for control flows

move the mei_io_cb_ wrappers to to iorw.c for global use
and use them also for handling control flows

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 601a1efa 09-Oct-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: rename mei_free_cb_private to mei_io_cb_free

1. cb_private was an old name that we depriacated in earlier
cleanups

2. we also group the funcion declaration with other _io_
functions

3. Don't check cb for NULL as mei_io_cb_free is NULL safe

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# fb601adb 14-Oct-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: kill usless struct mei_io_list

kill useless mei_io_list list wrapper and use directly
struct mei_cl_cb mei_cb which was its only member for managing io queues

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 75f0ee15 09-Oct-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: mei_write: revamp error path handling

1. unify common amt and regular error path and use it early in the
function
2. fix indentation
3. propagate error code directly from copy_from_user
4. print out errors using dev_err instead of dev_dbg

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 33d28c92 09-Oct-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: add allocation and initialization wrappers for io callback

mei_io_cb_init - allocat and initializate mei_cl_cb
mei_io_cb_alloc_req/resp_buf are separate function as buffers
are not always needed

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ebb108ef 09-Oct-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: rename mei_cl_cb.information to mei_cl_cb.buf_idx

rename 'information' member of the struct mei_cl_cb to
more self-descriptive 'buf_idx'

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1b812947 10-Sep-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: add error messages for open count errors

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9af51423 28-Aug-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: add lynx point pci device ids

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# daed6b5e 17-Aug-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: rename struct pci_dev *mei_device to mei_pdev

1. rename mei_device variable to mei_pdev to remove
confusion with type 'struct mei_device'
2. mei_pdev no longer need to be gloabal so make it static
and remove the declaration from the header file

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a2f69853 06-Aug-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: add mei_quirk_probe function

The main purpose of this function is to exclude ME devices
without support for MEI/HECI interface from binding

Currently affected systems are C600/X79 based servers
that expose PCI device even though it doesn't supported ME Interface.
MEI driver accessing such nonfunctional device can corrupt
the system.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c216fdeb 16-Aug-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: wd: decouple and revamp watchdog state machine

Before ME watchdog was exported through standard watchdog interface
it was closed and started together with the mei device.

The major issue is that closing ME watchdog disabled also MEI device,
to fix this the watchdog state machine has to be independent from MEI
state machine.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b210d750 06-Aug-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: name space for mei device state

1. add MEI_DEV_ prefix for mei device state enums
2. rename mei_state to dev_state
3. add constant to string translation for debug purposes

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 068c0ae9 06-Aug-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: use KBUILD_MODNAME when allocating resources from the OS

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9a123f19 06-Aug-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: add mei_quirk_probe function

The main purpose of this function is to exclude ME devices
without support for MEI/HECI interface from binding

Currently affected systems are C600/X79 based servers
that expose PCI device even though it doesn't supported ME Interface.
MEI driver accessing such nonfunctional device can corrupt
the system.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 07b509b7 23-Jul-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: revamp me client search function

me client search functions returns index
into me_client array according me client id
or me client uuid.

1. Add common prefix for the functions mei_me_cl_<>
2. create new function mei_me_cl_by_id that wraps open
coded loops scattered over the code
3. rename mei_find_me_client_index to mei_me_cl_by_uuid
4. rename mei_find_me_client_update_filext to
mei_me_cl_update_filext and updates its parameter names

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6078188e 19-Jul-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: use module_pci_driver

use module_pci_driver() macro to wrap standard
pci module registration into a single line

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 16a50b12 27-Jun-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: pci_resume: set IRQF_ONESHOT for msi request_threaded_irq

when the default irq quick handler is used then IRQF_ONESHOT must be set
otherwise the request fails and following error is displayed:

mei 0000:00:16.0: irq 48 for MSI/MSI-X
genirq: Threaded irq requested with handler=NULL and !ONESHOT for irq 48
mei 0000:00:16.0: request_threaded_irq failed: irq = 48.
dpm_run_callback(): pci_pm_resume+0x0/0x140 returns -22
PM: Device 0000:00:16.0 failed to resume async: error -22

Reported-by: Peter Wu <lekensteyn@gmail.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Tested-by: Peter Wu <lekensteyn@gmail.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Cc: stable <stable@vger.kernel.org> # 3.5
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 24aadc80 25-Jun-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: don't query HCSR for host buffer depth

1. We record host (write) buffer depth during reset
so we don't need to query HCSR register later on.
The host buffer depth doesn't change after the reset
2. Use mei_hbuf_max_data function to compute payload size in bytes

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 169dc388 10-Jun-2012 Samuel Ortiz <sameo@linux.intel.com>

misc: mei: Disable MSI when IRQ registration fails

Since MSI is enabled right before that, we should disable it when
registration fails.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# a44cab4a 29-May-2012 Tomas Winkler <tomas.winkler@intel.com>

misc: mei: unregister misc device in pci_remove function

Since the misc device is registered only in the pci probe function
it has to be also unregistered in the counterpart pci remove function
and not in the module exit function.
In case of probe failure the driver was oopsing in module exit function.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# aa189ecd 29-May-2012 Tomas Winkler <tomas.winkler@intel.com>

misc: mei: set IRQF_ONESHOT for msi request_threaded_irq

when the default irq quick handler is used then IRQF_ONESHOT must be set
otherwise the request fails and following error is displayed:

genirq: Threaded irq requested with handler=NULL and !ONESHOT for irq ...

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 4f3afe1d 09-May-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: export mei.h for the user space

The header exports API for application layer

1. move under include/linux and add to the export list
2. update include path n the sources
3. update TODO

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 32c826b6 08-May-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: pci_probe/remove: use dev_err instead of printk(KERN_ERR

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 37421275 08-May-2012 Tomas Winkler <tomas.winkler@intel.com>

mei: use pr_err instead of printk(KERN_ERR

pr_ format is more compact and enable utilizing of pr_fmt macro

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ffc2825c 01-May-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Staging: mei: move the mei code out of staging

It's been cleaned up, and there's nothing else left to do, so move it
out of staging into drivers/misc/ where all can use it now.

Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Oren Weil <oren.jer.weil@intel.com>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>