iamthif_mtu doesn't have default value anymore it
is always supplied by the ME firmware
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
The following changes were made in the document:
1. Update URLs to working links
2. remove old information about module parameters
3. Add IOCTL information.
4. cleanups and fix spelling
5. driver changed from character device to misc character device
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
The irq handler processes queued mei clients connect requests, which were
not transferred to the device in ioctl context due to unavailability
of the write buffer.
The handler may transfer the connection request only if there is
no other ongoing requests for the same mei id.
This condition was implemented inversely which depending on
the write buffer availability lead to seemingly random
failures during connection attempts.
Cc: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Natalia Ovsyanikov <natalia.ovsyanikov@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
list_for_each_entry_safe(pos, next, &head, list)
if (pos) {
....
}
This check isn't needed. The list cursor in a list_for_each()
loop is always a valid pointer
Cc: Oren Weil <oren.jer.weil@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1. No need to check if a list is empty before list_for_each_ looping as
this is already checked by loop stopping conditional.
The side effect is reduced indentation depth
from:
if (!list_empty)
list_for_each()
to:
list_for_each()
2. drop cb_ prefix from cl_pos, cl_next variables used in list_for_each
loops. The code is more compact and readable
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
We can remove BUG_ON in mei_irq_thread_read_client_message()
as the testing for response buffer size overflow has already
graceful handling in place.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
MEI_CLIENTS_MAX is 255 and host_client_id is u8 therefore
for check to work we need to first assign the return value
of find_first_zero_bit to unsigned long variable
Fix warning
drivers/staging/mei/main.c: In function mei_open
drivers/staging/mei/main.c:260:2: warning: comparison is always false due to limited range of data type
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Misc device provides everything MEI needs for registration,
it doesn't required separate driver class.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
wd_ops and wd_info structures are local to wd.c so mark them static
Cc: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
moving the final state, clearing of the client maps and
updating of mei state out from mei_host_client_properties function.
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Sizeof a pointer-typed expression returns the size of the pointer, not that
of the pointed data.
The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression *e;
type T;
identifier f;
@@
f(...,(T)e,...,
-sizeof(e)
+sizeof(*e)
,...)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
wd module parameter is not needed now that driver is using watchdog core.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
starting removing the dependency from the module parameters.
setting the default timeout on init so don't need to check if it is bigger
then zero.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
the timer_work does not only handle watchdog but also handles mei timeouts.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
the wd_work and mei_wd_timer() function was not just for watchdog.
mei managing the AMT watchdog going to be replace by the kernel watchdog
interface.
the mei_timer() will still manage the mei driver timeouts.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
add the ability to let the watchdog core set
the AMT watchdog timeout value.
the default value will be only set in the start function.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
adding watchdog ping to send ping/heartbeat to the the AMT watchdog client.
in addition removing the heartbeat sending from the driver timers function.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
adding start and stop function.
start - check if AMT wd client is connected, which is been connected on driver
load.
stop - send stop command to AMT wd.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Adding kernel watchdog interface (/dev/watchdog) to the MEI Driver to support AMT Watchdog feature.
This patch and the following one will replace MEI Driver self management of the AMT watchdog
with the standard kernel watchdog interface.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
AMTHI need to be initialized after WD Client was initialized, moving the AMTHI outside
of the WD initialization function.
in order to remove the coupling between the initialization of those clients.
AMTHI is getting initialized (getting connected to the FW feature/client) in two ways:
1) if mei driver fails to send connect message to watchdog client (WD initialization), then
immediately the AMTHI client getting initialized right after the watchdog initialization function.
2) if Watchdog client success to send connect message to watchdog client, then only after
the driver is getting the connect response message the AMTHI client is getting initialized
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
mei_open() acquires dev->device_lock mutex and try to allocate mei_cl,
but if the allocation fails it goes to return statement. As a result
dev->device_lock left locked.
The patch fixes goto to unlock dev->device_lock mutex on this path.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
enable msi when supported
also in that case we can drop the quick handler
from the threaded interrupt that protected us from
handling USB interrupts
Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
keeping the exit flow in a reverse order then the init flow.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This handles the merge conflicts with the
drivers/staging/brcm80211/Kconfig file due to changes on the two
different branches.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
It was pointed out by 'make versioncheck' that include of
linux/version.h is not needed in drivers/staging/mei/main.c .
This patch removes it.
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Fix warning: reported in http://marc.info/?l=linux-kernel&m=130812960402606&w=2
drivers/staging/mei/interrupt.c: warning: 'buffer' may be used uninitialized in this function: => 198
It is a real issue and wrong path in execution is taken when
list is empty or (cl && _mei_irq_thread_state_ok(cl, mei_hdr))
evaluates to false
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1. remove list used for loop. There were only 2 loops used in non
time critical places so we can safely unroll them
2. normalize functions names operating on io_list to mei_io_list_<op>
3. rename mei_fe_same_id to mei_cl_cmp_id used for comparing list
elements containing struct mei_cl
4. group together io_list functions in the header file
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
use type bool for boolean variables in struct mei_dev
this should save some space providing boolean is 8 bits
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
All global functions must start with mei_ to reduce the risk of name colisions
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
wait_event_interruptible_timeout return value was wrongly used.
The remaining timeout was used as the error code.
This fix translated wait_event_interruptible_timeout return value
into error code that can be propagated.
[10291.674121] pci_pm_suspend(): mei_pci_suspend+0x0/0x8b [mei] returns 2500
It's thinkpad t400 with
00:03.0 Communication controller [0780]: Intel Corporation Mobile 4 Series Chipset MEI Controller [8086:2a44] (rev 07)
Reported-by: Arkadiusz Miskiewicz <a.miskiewicz@gmail.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
! has higher precedence than !=. H_RDY is 8 and since neither 0 nor
1 are equal to 8 the original condition was always true.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Fix mei build when CONFIG_PM is not enabled (i.e., fix typo):
drivers/staging/mei/main.c:1159: error: 'MEI_PM_OPS' undeclared here (not in a function)
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Add mei to Kconfig and Makefile in drivers/staging
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Itzhak Tzeel-Krupp <itzhak.tzeel-krupp@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
code that open connection and invoke
heartbeats to the AMT Watchdog client/feature, if exists
Connect to WD Client, if exists Send Start WD Command.
Every 2 secs send heartbeats.
On System shutdown/suspends, send Stop WD command.
This is intermediate stage before moving this code to standalone watchdog
driver.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Itzhak Tzeel-Krupp <itzhak.tzeel-krupp@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
define IOCTL_MEI_CONNECT_CLIENT and its associated structure
When the user wants to connect to a ME feature/client after
it open a file descriptor to the driver, he need to use Connect
IOCTL.
This IOCTL received a struct that contains a union of 2 other structs.
1st struct - Input Parameters:
UUID - a predefine unique that identify the ME feature, this
id per feature is constant all over the chipsets
and versions.
2nd struct Output Parameters:
MaxMessageLen - maximum message length that allowed
to be send to the feature
ProtocolVersion ME feature current protocol version.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Itzhak Tzeel-Krupp <itzhak.tzeel-krupp@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
define the MEI protocol msg structs and
HW registers, also define the MEI internal status and struct
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Itzhak Tzeel-Krupp <itzhak.tzeel-krupp@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Init driver list and queue, MEI Hardware reset flow,
init of driver specific host client.
MEI Init/reset flow:
- Ack all waiting interrupts
- Hardware reset flow (Set Reset Bit, Generate Interrupt, Clear Reset Bit
Generate Interrupt)
- Wait for ME Ready Bit (done in interrupt thread)
- Set ME Ready Bit (done in interrupt thread)
- Send Start request (done in interrupt thread)
- wait for answer
- Send Enumerate Clients request (done in interrupt thread)
- wait for answer
- Send Get Client property for each client request (done in interrupt thread)
- Wait for answers
- Init Done.
MEI Driver connect internally to 2 ME clients/features:
AMTHI and AMT watchdog.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Itzhak Tzeel-Krupp <itzhak.tzeel-krupp@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Implementation of the communication between host and ME.
connect/disconnect to/from a client, send MEI message,
read MEI message, flow control handling.
Each MEI message has mei_msg_hdr followed by a payload.
Driver is oblivious the payload.
ME Address/ID - This is the logical address of the ME
feature/client of that message.
Host Address/ID - This is the logical address of the Host
client of that message
Length - This is the Length of message payload in bytes
Reserved - reserved for future use.
Message Complete - This bit is used to indicative that
this is the last message of multi message
MEI transfer of a client message that is larger
then the MEI circular buffer.
Payload - Message payload (data) up to 512bytes
The HW data registers are consist two circular buffers,
one for data from ME and other data from Host application.
Each buffer has two pointers, read_ptr (H_CBRP)
and write_ptr (H_CBWP).
The buffers size is defined by depth value that exists
in the status registers (H_CBD and ME_CBD_HRA).
Every read from ME circular buffer cause read_ptr++
Every write to the Host circular buffer write_ptr++
Flow control MEI message that ME and MEI Driver use to notify
each other that a ME feature/client or Host client buffer is ready
to receive data.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Itzhak Tzeel-Krupp <itzhak.tzeel-krupp@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ISR and interrupt thread for handling incoming data.
e.g. read bus message, read client message, handle reset requests.
quick handler:
As MEI may share interrupt with GFX and/or USB
the HW register need to be checked and acknowledged.
thread handler:
Check if HW has data for read.
Write data to HW if possible.
May init reset flow on error
there can be two types of messages:
1) bus messages:
Management messages between MEI Driver and ME e.g.
Connect request/response,
Disconnect request/response
Enum clients request/response
Flow control request/response
those message are indicated by
ME Address/ID == 0 && Host Address/ID == 0
2) feature/client messages:
message that are sends between ME Feature/Client and
an application, the struct of the message is defined
by the ME Feature Protocol (e.g. APF Protocol, AMTHI Protocol)
those message are indicated by
ME Address/ID != 0 && Host Address/ID != 0
MEI Initialization state machine is also managed by this patch.
After MEI Reset is preform:
Send Start request
wait for answer
Send Enumerate Clients request
wait for answer
Send Get Client property for each client request
wait for answers
Init Done.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Itzhak Tzeel-Krupp <itzhak.tzeel-krupp@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
contains module entries and PCI driver and char device
definitions (using file_operations, pci_driver struts).
The HW interface is exposed on PCI interface.
PCI:
The MEI HW resources are memory map 32 bit registers
(Host and ME Status Registers and Data Registers)
and interrupt (shared, with Intel GFX on some chipsets
and USB2 controller on others).
The device is part of the chipsets and cannot be hotplugged.
The MEI device present is determined by BIOS configuration.
Probe:
The driver starts the init MEI flow, that is explained
in the patch "MEI driver init flow" [06/10],
then schedules a timer that handles
timeouts and watchdog heartbeats.
Remove:
The driver closes all connections and stops the watchdog.
The driver expose char device that supports:
open, release, write, read, ioctl, poll.
Open:
Upon open the driver allocates HOST data structure
on behalf of application which will resides in the file's
private data and assign a host ID number which
will identify messages between driver client instance
and MEI client.
The driver also checks readiness of the device. The number
of simultaneously opened instances is limited to 253.
(255 - (amthi + watchdog))
Release:
In release the driver sends a Disconnect Command to
ME feature and clean all the data structs.
IOCTL:
MEI adds new IOCTL: (IOCTL_MEI_CONNECT_CLIENT)
The IOCTL links the current file descriptor to ME feature.
This is done by sending MEI Bus command: 'hbm_client_connect_request'
to the ME and waiting for an answer :'hbm_client_connect_response'.
Upon answer reception the driver updates its and HOST data
structures in file structure to indicate that the file
descriptor is associated to ME feature.
Each ME feature is represented by UUID which is given as
an input parameter to the IOCTL, upon success connect command the
IOCTL will return the ME feature properties.
ME can reject CONNECT commands due to several reasons,
most common are:
Invalid UUID ME or feature does not exists in ME.
No More Connection allowed to this is feature,
usually only one connection is allowed.
Write:
Upon write, the driver splits the user data into several MEI
messages up to 512 bytes each and sends it to the HW.
If the user wants to write data to AMTHI ME feature then the
drivers routes the messages through AMTHI queues.
Read:
In read the driver checks is a connection exists to
current file descriptor and then wait until a data is available.
Message might be received (by interrupt from ME) in multiple chunks.
Only complete message is released to the application.
Poll:
Nothing special here. Waiting for see if we have
data available for reading.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Itzhak Tzeel-Krupp <itzhak.tzeel-krupp@intel.com>
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>