Commit graph

118 commits

Author SHA1 Message Date
Tomas Winkler
b95d788ac7 mei: fix undefined wd symbols when MEI_ME is not set
Currently watchdog client is compiled with MEI and not
with MEI_ME

Fixes error:
When CONFIG_WATCHDOG is not enabled:

ERROR: "watchdog_unregister_device" [drivers/misc/mei/mei.ko] undefined!
ERROR: "watchdog_register_device" [drivers/misc/mei/mei.ko] undefined

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-07 14:00:25 -08:00
Tomas Winkler
074b4c01ab mei: move clients cleanup code from init.c to client.c
during reset we clean up client data structures
we move that code into wrappers in client
and call the wrappers

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-06 11:24:33 -08:00
Tomas Winkler
330dd7da5e 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>
2013-02-06 11:24:33 -08:00
Tomas Winkler
06ecd64598 mei: move interrupt handlers to be me hw specific
interrupt handler are  platform specifics so we move
them to hw-mei.c. For sake of that we need to export
write, read, and complete handlers from the interrupt.c

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-06 11:24:33 -08:00
Tomas Winkler
827eef51f8 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>
2013-02-06 11:23:47 -08:00
Tomas Winkler
52c3456141 mei: initial extract of ME hw specifics from mei_device
This is initial step of move the ME hw specifics
out of mei_device structure into mei_me_hw

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-02-06 11:23:14 -08:00
Tomas Winkler
2703d4b2e6 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>
2013-02-06 11:21:51 -08:00
Greg Kroah-Hartman
6596afe3f3 Merge 3.8-rc4 into char-misc-next
This brings in all of the mei and other fixes that are needed to continue
development in this branch.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-18 09:31:04 -08:00
Sedat Dilek
7353f85ce8 mei: Fix some more kernel-doc typos in hw-me.c
Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-17 11:59:53 -08:00
Tomas Winkler
8e9a4a9a5c mei: drop the warning when cl is not initialized during unlinking
On systems where wd and amthif is not initialized
we will hit cl->dev == NULL. This condition is okay
so we don't need to be laud about it.

Fixes the follwing warning during suspend
[  137.061985] WARNING: at drivers/misc/mei/client.c:315 mei_cl_unlink+0x86/0x90 [mei]()
[  137.061986] Hardware name: 530U3BI/530U4BI/530U4BH
[  137.062140] Modules linked in: snd_hda_codec_hdmi snd_hda_codec_realtek joydev coretemp kvm_intel snd_hda_intel snd_hda_codec kvm arc4 iwldvm snd_hwdep i915 snd_pcm mac80211 ghash_clmulni_intel snd_page_alloc aesni_intel snd_seq_midi xts snd_seq_midi_event aes_x86_64 rfcomm snd_rawmidi parport_pc bnep lrw snd_seq uvcvideo i2c_algo_bit ppdev gf128mul iwlwifi snd_timer drm_kms_helper ablk_helper cryptd drm snd_seq_device videobuf2_vmalloc psmouse videobuf2_memops snd cfg80211 btusb videobuf2_core soundcore videodev lp bluetooth samsung_laptop wmi microcode mei serio_raw mac_hid video hid_generic lpc_ich parport usbhid hid r8169
[  137.062143] Pid: 2706, comm: kworker/u:15 Tainted: G      D W    3.8.0-rc2-next20130109-1-iniza-generic #1
[  137.062144] Call Trace:
[  137.062156]  [<ffffffff8105860f>] warn_slowpath_common+0x7f/0xc0
[  137.062159]  [<ffffffff8135b1ea>] ? ioread32+0x3a/0x40
[  137.062162]  [<ffffffff8105866a>] warn_slowpath_null+0x1a/0x20
[  137.062168]  [<ffffffffa0076be6>] mei_cl_unlink+0x86/0x90 [mei]
[  137.062173]  [<ffffffffa0071325>] mei_reset+0xc5/0x240 [mei]
[  137.062178]  [<ffffffffa0073703>] mei_pci_resume+0xa3/0x110 [mei]
[  137.062183]  [<ffffffff81379cae>] pci_pm_resume+0x7e/0xe0
[  137.062185]  [<ffffffff81379c30>] ? pci_pm_thaw+0x80/0x80
[  137.062189]  [<ffffffff8145a415>] dpm_run_callback.isra.6+0x25/0x50
[  137.062192]  [<ffffffff8145a6cf>] device_resume+0x9f/0x140
[  137.062194]  [<ffffffff8145a791>] async_resume+0x21/0x50
[  137.062200]  [<ffffffff810858b0>] async_run_entry_fn+0x90/0x1c0
[  137.062203]  [<ffffffff810778e5>] process_one_work+0x155/0x460
[  137.062207]  [<ffffffff81078578>] worker_thread+0x168/0x400
[  137.062210]  [<ffffffff81078410>] ? manage_workers+0x2b0/0x2b0
[  137.062214]  [<ffffffff8107d9f0>] kthread+0xc0/0xd0
[  137.062218]  [<ffffffff8107d930>] ? flush_kthread_worker+0xb0/0xb0
[  137.062222]  [<ffffffff816bac6c>] ret_from_fork+0x7c/0xb0
[  137.062228]  [<ffffffff8107d930>] ? flush_kthread_worker+0xb0/0xb0

Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-14 08:26:03 -08:00
Tomas Winkler
627ca75733 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>
2013-01-08 16:40:48 -08:00
Tomas Winkler
e7e0c231aa mei: make host csr and me csr internal to hw-me
Move csr reading into me hardware functional calls.
Since we gave up on registers caching we remove some of the unnecessary
queries in mei_hw_init ane mei_reset functions.

We add mei_hw_config function to wrap up host buffer depth configuration.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:47 -08:00
Tomas Winkler
88eb99f29c mei: reenable mei_hcsr_set abstraction
Now when mei_hcsr_set is local to hw-me.c
we can benefit form the fact that it wraps
H_IS removal from the host csr.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:47 -08:00
Tomas Winkler
115ba28c5e mei: abstract host and device readieness
Add mei_host_set_ready function to enable the device
and is_ready function to query the host and me readiness

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:47 -08:00
Tomas Winkler
9ea73ddd4f 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>
2013-01-08 16:40:47 -08:00
Tomas Winkler
adfba3220b mei: don't use cached value for hcsr in mei_hw_reset
Open code mei_hw_reset to avoid using cached hcsr.
Using cached hcsr can cause unwanted side effects.

Move mei_hw_restet function to hw-me.c as it is hw dependent

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:47 -08:00
Tomas Winkler
528c8eb4e7 mei: remove mei_csr_clear_his prototype
The function mei_csr_clear_his is not implemented

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:47 -08:00
Tomas Winkler
a9f6b133ab mei: remove write only need_reset member of struct mei_device
need_reset is not used anymore

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:46 -08:00
Tomas Winkler
d025284d06 mei: hw-me.c fix kernel doc
Fix the kernel doc for the functions in hw-me.c

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:46 -08:00
Tomas Winkler
6222f7bf8d mei: move MEI_IAMTHIF_IDLE to amthif host init function
Since the amthif state is not examined until amthif is connected
we can safely move it to the amthif host init function

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:46 -08:00
Tomas Winkler
781d0d8922 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>
2013-01-08 16:40:46 -08:00
Tomas Winkler
1a1aca42c9 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>
2013-01-08 16:40:46 -08:00
Tomas Winkler
038c8a6ebc mei: mei_dev.h - remove prototypes of dropped functions
mei_task_initialize_clients and mei_initialize_clients
are no longer among us

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:46 -08:00
Tomas Winkler
a40b260da6 mei: move me client storage allocation to hbm.c
rename function to mei_me_cl_allocate to match the current
names convention: mei_hbm_me_cl_allocate

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:45 -08:00
Tomas Winkler
d91aaed30a 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>
2013-01-08 16:40:45 -08:00
Tomas Winkler
9dc64d6a26 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>
2013-01-08 16:40:45 -08:00
Tomas Winkler
37e7d6e74f mei: move watchdog prototypes to mei_dev.h from interface.h
interface.h contains lower layer functionality

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:45 -08:00
Tomas Winkler
9f81abdac3 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>
2013-01-08 16:40:45 -08:00
Tomas Winkler
90e0b5f185 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>
2013-01-08 16:40:44 -08:00
Tomas Winkler
9ca9050b3d mei: move client functions to client.c
This file now contains me and host client functions
and also io callback helpers
We also kill iorw.c which is no longer needed

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:44 -08:00
Tomas Winkler
0edb23fc34 mei: add new hbm.h header to export hbm protocol
hbm.h provides access host bus messaging functionality
for other MEI layers

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-08 16:40:44 -08:00
Tomas Winkler
6bbda15f27 mei: move hbm responses from interrupt.c to hbm.c
1. Add common prefix mei_hbm_ to all handlers
and made them static
2. Drop now useless function  same_flow_addr

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:30 -08:00
Tomas Winkler
8120e7201c mei: add common prefix to hbm function
1. use mei_hbm_ for basic host bus message function
2. use mei_hbm_cl prefix for host bus messages that operation
on behalf of a client

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:29 -08:00
Tomas Winkler
e46f187487 mei: use structured buffer for the write buffer
We can drop useless castings and use proper types.
We remove the casting in mei_hbm_hdr function
and add new function mei_hbm_stop_request_prepare that
utilize the new structure

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:29 -08:00
Tomas Winkler
cd51ed649f mei: simplify preparing client host bus messages
Define a new parent type mei_hbm_cl_cmd for hbm
commands that are sent on behalf of specific ME client.
This allows us compacting boilerplate code via mei_hbm_cl_hdr
function

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:29 -08:00
Tomas Winkler
2efdf54603 mei: drop nonexistent function prototype
mei_amthif_read_message prototype was not dropped
in one of the moving/renaming patches

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:29 -08:00
Tomas Winkler
bb1b0133b3 mei: move host bus message handling to hbm.c
for sake of more layered design we move host
bus message handling to the new hbm.c file

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:29 -08:00
Tomas Winkler
3a65dd4ea3 mei: move hw dependent functions to interface.c
1. move direct register handling to interface.c and make them static
2. add new function mei_clear_interrupts that wraps direct register
access
3. export other functions in mei_dev.h

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:29 -08:00
Tomas Winkler
db7da79df1 mei: mei_me_client is not hw API move to mei_dev.h
Move struct mei_me_client from hw.h to mei_dev.h as it is not
part of the hardware API. The structutre doesn't have to
be packed. Add kdoc for this structure.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:28 -08:00
Tomas Winkler
fecb0d584e mei: kill not used BAR0 length and base variables
1. mem_base and mem_length are not used so we can delete
them
2. add kdoc for mem_addr member of mei_device

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:28 -08:00
Tomas Winkler
47a73801f4 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>
2013-01-07 10:31:28 -08:00
Tomas Winkler
66ef5ea9b0 mei: extract device dependent constants into hw-me.h
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:28 -08:00
Tomas Winkler
1d3f3da3e2 mei: move internal host clients ids to mei_dev.h from hw.h
Internal clients numbers are implementation choice
and not defined by the hardware.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:31:28 -08:00
Tomas Winkler
15d4acc57f 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>
2013-01-07 10:31:28 -08:00
Tomas Winkler
438763f37e 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>
2013-01-07 10:31:27 -08:00
Alexey Khoroshilov
e6028db014 mei: fix mismatch in mutex unlock-lock in mei_amthif_read()
Users of mei_amthif_read() expect it leaves dev->device_lock held,
while there is a path where mei_amthif_read() unlocks device_lock
and returns -ERESTARTSYS.

The patch move code locking device_lock back before the return.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: Sedat Dilek <sedat.dilek@gmail.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-07 10:28:03 -08:00
Tomas Winkler
d692170037 watchdog: mei: avoid oops in watchdog unregister code path
With commit c7d3df3 "mei: use internal watchdog device registration
tracking" will crash the kernel on shutdown path on systems
where ME watchdog is not present.
Since the watchdog was never initialized in such case
the WDOG_UNREGISTERED bit is never set and the system
crashes on access to uninitialized variables down the path.

To solve the issue we query for NULL on watchdog driver driver_data
to check whether the device is registered. This is handled in the
driver and doesn't depend on watchdog core internals.

Cc: Borislav Petkov <bp@alien8.de>
Cc: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Jerry Snitselaar <jerry.snitselaar@oracle.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
2012-12-19 22:25:11 +01:00
Bill Pemberton
486a5c28c2 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>
2012-11-21 12:53:32 -08:00
Bill Pemberton
80c8ae2892 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>
2012-11-21 12:51:53 -08:00
Bill Pemberton
9306a8b0c2 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>
2012-11-21 12:43:58 -08:00