Commit Graph

30 Commits

Author SHA1 Message Date
Corey Minyard 4495ec6d77 ipmi:ssif: Add missing unlock in error branch
When getting flags, a response to a different message would
result in a deadlock because of a missing unlock.  Add that
unlock and a comment.  Found by static analysis.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable@vger.kernel.org # 3.19
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2017-06-30 07:18:08 -05:00
Corey Minyard 87ff091c40 ipmi:ssif: Check dev before setting drvdata
dev can be NULL.

Reported-by: Austin Christ <austinwc@codeaurora.org>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2017-06-28 12:44:35 -05:00
Corey Minyard 0944d889a2 ipmi: Convert DMI handling over to a platform device
Now that the IPMI DMI code creates a platform device for IPMI devices
in the firmware, use that instead of handling all the DMI work
in the IPMI drivers themselves.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Andy Lutomirski <luto@kernel.org>
2017-06-19 12:49:38 -05:00
Corey Minyard be8647d2be ipmi:ssif: Use i2c_adapter_id instead of adapter->nr
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2017-06-16 16:56:38 -05:00
Colin Ian King bf10ff69dd ipmi_ssif: remove redundant null check on array client->adapter->name
The null check on client->adapter->name is redundant as name is an
array of I2C_NAME_SIZE chars and hence can never be null. We may as
well remove this redundant check.

Detected by CoverityScan, CID#1375918 ("Array compared against 0")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2017-05-17 18:30:35 -05:00
Dan Carpenter cf9806f32e ipmi_ssif: unlock on allocation failure
We should unlock and re-enable IRQs if this allocation fails.

Fixes: 259307074b ("ipmi: Add SMBus interface driver (SSIF) ")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2017-05-08 14:01:41 -05:00
Geliang Tang 36cb82dabb ipmi_ssif: use setup_timer
Use setup_timer() instead of init_timer() to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2017-04-07 12:25:36 -05:00
Joeseph Chang 6de65fcfdb ipmi: Fix kernel panic at ipmi_ssif_thread()
msg_written_handler() may set ssif_info->multi_data to NULL
when using ipmitool to write fru.

Before setting ssif_info->multi_data to NULL, add new local
pointer "data_to_send" and store correct i2c data pointer to
it to fix NULL pointer kernel panic and incorrect ssif_info->multi_pos.

Signed-off-by: Joeseph Chang <joechang@codeaurora.org>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: stable@vger.kernel.org # 3.19-
2017-04-07 12:25:22 -05:00
Corey Minyard 9467171018 ipmi: Pick up slave address from SMBIOS on an ACPI device
When added by ACPI, the information does not contain the slave address
of the BMC.  However, that information is available from SMBIOS.  So
if we add a device that doesn't have a slave address, look at the other
devices that are duplicate interfaces and see if they have a slave
address.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2016-11-24 18:09:48 -06:00
Corey Minyard 56189b5f2f ipmi_ssif: Remove an unused module parameter
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2016-11-07 12:16:06 -06:00
Benjamin Tissoires b4f210541f i2c: add a protocol parameter to the alert callback
.alert() is meant to be generic, but there is currently no way
for the device driver to know which protocol generated the alert.
Add a parameter in .alert() to help the device driver to understand
what is given in data.

This patch is required to have the support of SMBus Host Notify protocol
through .alert().

Tested-by: Andrew Duggan <aduggan@synaptics.com>
For hwmon:
Acked-by: Guenter Roeck <linux@roeck-us.net>
For IPMI:
Acked-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-06-17 12:41:25 +02:00
Corey Minyard 70f95b76f1 ipmi: Fix the I2C address extraction from SPMI tables
Unlike everywhere else in the IPMI specification, the I2C address
specified in the SPMI table is not shifted to the left one bit with
the LSB zero.  Instead it is not shifted with the MSB zero.

Reported-by: Sanjeev <singhsan@codeaurora.org>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2016-05-16 19:49:49 -05:00
Corey Minyard 21c8f9154d ipmi_ssif: Fix logic around alert handling
There was a mistake in the logic, if an alert came in very quickly
it would hang the driver.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2016-03-18 07:01:23 -05:00
Krzysztof Kozlowski aad756f869 char: ipmi: Drop owner assignment from i2c_driver
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
2016-01-12 15:08:49 -06:00
Amitoj Kaur Chawla 526290aa62 char: ipmi: ipmi_ssif: Replace timeval with timespec64
This patch replaces timeval with timespec64 as 32 bit 'struct timeval'
will not give current time beyond 2038.

The patch changes the code to use ktime_get_real_ts64() which returns
a 'struct timespec64' instead of do_gettimeofday() which returns a
'struct timeval'

This patch also alters the format string in pr_info() for now.tv_sec
to incorporate 'long long' on 32 bit architectures.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-24 19:46:42 -07:00
Corey Minyard bf2d087749 ipmi:ssif: Add a module parm to specify that SMBus alerts don't work
They are broken on some platforms, this gives people a chance to work
around it until the firmware is fixed.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-09-03 15:02:31 -05:00
Mathias Krause 5186cf9c74 ipmi: constify SSIF ACPI device ids
Constify the ACPI device ID array, it doesn't need to be writable at
runtime.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-09-03 15:02:26 -05:00
Shailendra Verma fedb25ea90 char:ipmi - Change 1 to true for bool type variables during initialization.
Signed-off-by: Shailendra Verma <shailendra.capricorn@gmail.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-09-03 15:02:25 -05:00
Corey Minyard 3d69d43baa ipmi: Fix multi-part message handling
Lots of little fixes for multi-part messages:

The values was not being re-initialized, if something went wrong
handling a multi-part message and it got left in a bad state, it
might be an issue.

The commands were not correct when issuing multi-part reads, the
code was not passing in the proper value for commands.  Also clean
up some minor formatting issues.

Get the block number from the right location, limit the maximum send
message size to 63 bytes and explain why, and fix some minor sylistic
issues.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-05-05 19:37:22 -05:00
Corey Minyard 9162052173 ipmi: Add alert handling to SSIF
The SSIF interface can optionally have an SMBus alert come in when
data is ready.  Unfortunately, the IPMI spec gives wiggle room to
the implementer to allow them to always have the alert enabled,
even if the driver doesn't enable it.  So implement alerts.
If you don't in this situation, the SMBus alert handling will
constantly complain.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-05-05 19:36:38 -05:00
Wei Yongjun 15c5725e6b ipmi: Remove unused including <linux/version.h>
Remove including <linux/version.h> that don't need it.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-05-05 19:33:28 -05:00
Joe Perches 5e33cd0c5a ipmi: Remove incorrect use of seq_has_overflowed
commit d6c5dc18d8 ("ipmi: Remove uses of return value of seq_printf")
incorrectly changed the return value of various proc_show functions
to use seq_has_overflowed().

These functions should return 0 on completion rather than 1/true
on overflow.  1 is the same as #define SEQ_SKIP which would cause
the output to not be emitted (skipped) instead.

This is a logical defect only as the length of these outputs are
all smaller than the initial allocation done by the seq filesystem.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-05-05 14:24:46 -05:00
Corey Minyard b0e9aaa99d ipmi:ssif: Ignore spaces when comparing I2C adapter names
Some of the adapters have spaces in their names, but that's really
hard to pass in as a module or kernel parameters.  So ignore the
spaces.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-05-05 14:24:45 -05:00
Corey Minyard d467f7a405 ipmi_ssif: Fix the logic on user-supplied addresses
Returning zero is success.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-05-05 14:24:45 -05:00
Corey Minyard d0acf734d8 ipmi_ssif: Use interruptible completion for waiting in the thread
The code was using an normal completion, but that caused stuck
task errors after a while.  Use an interruptible one to avoid that.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-04-10 20:51:42 -05:00
Joe Perches d6c5dc18d8 ipmi: Remove uses of return value of seq_printf
The seq_printf like functions will soon be changed to return void.

Convert these uses to check seq_has_overflowed instead.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-02-19 20:58:41 -06:00
Wolfram Sang bb82d90e74 char: ipmi: Remove obsolete cleanup for clientdata
A few new i2c-drivers came into the kernel which clear the clientdata-pointer
on exit or error. This is obsolete meanwhile, the core will do it.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
2015-02-19 19:54:50 -06:00
Corey Minyard 1421c935df ipmi: Fix compile warning with tv_usec
It's not a long int on all arches.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2014-12-30 13:34:36 -06:00
Corey Minyard e3fe142704 ipmi: Fix compile issue with isspace()
Some arches don't get ctypes.h included from these includes, so add
it explicitly.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
2014-12-21 17:03:19 -06:00
Corey Minyard 259307074b ipmi: Add SMBus interface driver (SSIF)
This patch adds the SMBus interface to the IPMI driver.

Signed-off-by: Corey Minyard <minyard@acm.org>

 Documentation/IPMI.txt       |   32
 drivers/char/ipmi/Kconfig    |   11
 drivers/char/ipmi/Makefile   |    1
 drivers/char/ipmi/ipmi_smb.c | 1737 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1769 insertions(+), 12 deletions(-)
2014-12-11 15:04:11 -06:00