From a086bb8317303dd74725dca933b9b29575159382 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 11 Apr 2018 18:03:31 +0200 Subject: [PATCH 1/5] i2c: i801: Save register SMBSLVCMD value only once Saving the original value of register SMBSLVCMD in i801_enable_host_notify() doesn't work, because this function is called not only at probe time but also at resume time. Do it in i801_probe() instead, so that the saved value is not overwritten at resume time. Signed-off-by: Jean Delvare Fixes: 22e94bd6779e ("i2c: i801: store and restore the SLVCMD register at load and unload") Reviewed-by: Benjamin Tissoires Tested-by: Jason Andryuk Signed-off-by: Wolfram Sang Cc: stable@vger.kernel.org # v4.10+ --- drivers/i2c/busses/i2c-i801.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 692b34125866..17aa20a55642 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -966,8 +966,6 @@ static void i801_enable_host_notify(struct i2c_adapter *adapter) if (!(priv->features & FEATURE_HOST_NOTIFY)) return; - priv->original_slvcmd = inb_p(SMBSLVCMD(priv)); - if (!(SMBSLVCMD_HST_NTFY_INTREN & priv->original_slvcmd)) outb_p(SMBSLVCMD_HST_NTFY_INTREN | priv->original_slvcmd, SMBSLVCMD(priv)); @@ -1615,6 +1613,10 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) outb_p(inb_p(SMBAUXCTL(priv)) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); + /* Remember original Host Notify setting */ + if (priv->features & FEATURE_HOST_NOTIFY) + priv->original_slvcmd = inb_p(SMBSLVCMD(priv)); + /* Default timeout in interrupt mode: 200 ms */ priv->adapter.timeout = HZ / 5; From f7f6d915a10f7f2bce17e3b1b7d3376562395a28 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 11 Apr 2018 18:05:34 +0200 Subject: [PATCH 2/5] i2c: i801: Restore configuration at shutdown On some systems, the BIOS expects certain SMBus register values to match the hardware defaults. Restore these configuration registers at shutdown time to avoid confusing the BIOS. This avoids hard-locking such systems upon reboot. Signed-off-by: Jean Delvare Tested-by: Jason Andryuk Signed-off-by: Wolfram Sang Cc: stable@vger.kernel.org --- drivers/i2c/busses/i2c-i801.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 17aa20a55642..e0d59e9ff3c6 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1701,6 +1701,15 @@ static void i801_remove(struct pci_dev *dev) */ } +static void i801_shutdown(struct pci_dev *dev) +{ + struct i801_priv *priv = pci_get_drvdata(dev); + + /* Restore config registers to avoid hard hang on some systems */ + i801_disable_host_notify(priv); + pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg); +} + #ifdef CONFIG_PM static int i801_suspend(struct device *dev) { @@ -1730,6 +1739,7 @@ static struct pci_driver i801_driver = { .id_table = i801_ids, .probe = i801_probe, .remove = i801_remove, + .shutdown = i801_shutdown, .driver = { .pm = &i801_pm_ops, }, From 95df14f7937482a2a527814061eda9b534adb7eb Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 10 Apr 2018 21:49:13 +0200 Subject: [PATCH 3/5] MAINTAINERS: remove me as maintainer for I2C host drivers The number of I2C host controller drivers keeps increasing, and although I had some success acquiring specific driver maintainers, my bandwidth is by far not enough to act as a fallback for the rest of the drivers. To reflect this status-quo in MAINTAINERS, add a separate entry for I2C host drivers, let the I2C list (= community) be the contact point, and mark this section as "Odd fixes". Signed-off-by: Wolfram Sang Reviewed-by: Simon Horman --- MAINTAINERS | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index c7182d2a9f5c..f840786ef33d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6581,15 +6581,25 @@ W: https://i2c.wiki.kernel.org/ Q: https://patchwork.ozlabs.org/project/linux-i2c/list/ T: git git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git S: Maintained -F: Documentation/devicetree/bindings/i2c/ +F: Documentation/devicetree/bindings/i2c/i2c.txt F: Documentation/i2c/ -F: drivers/i2c/ -F: drivers/i2c/*/ +F: drivers/i2c/* F: include/linux/i2c.h -F: include/linux/i2c-*.h +F: include/linux/i2c-dev.h +F: include/linux/i2c-smbus.h F: include/uapi/linux/i2c.h F: include/uapi/linux/i2c-*.h +I2C SUBSYSTEM HOST DRIVERS +L: linux-i2c@vger.kernel.org +W: https://i2c.wiki.kernel.org/ +Q: https://patchwork.ozlabs.org/project/linux-i2c/list/ +T: git git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git +S: Odd Fixes +F: Documentation/devicetree/bindings/i2c/ +F: drivers/i2c/algos/ +F: drivers/i2c/busses/ + I2C-TAOS-EVM DRIVER M: Jean Delvare L: linux-i2c@vger.kernel.org From 090cecc669d4336a6ce2eeaa3074b628d3fb7678 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 10 Apr 2018 21:49:14 +0200 Subject: [PATCH 4/5] MAINTAINERS: add maintainer for Renesas I2C related drivers Intentionally missing i2c-riic here, Chris Brandt will add himself for that one later. Signed-off-by: Wolfram Sang Reviewed-by: Simon Horman Signed-off-by: Wolfram Sang --- MAINTAINERS | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f840786ef33d..808cf402b257 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5906,6 +5906,11 @@ S: Supported F: drivers/phy/ F: include/linux/phy/ +GENERIC PINCTRL I2C DEMULTIPLEXER DRIVER +M: Wolfram Sang +S: Supported +F: drivers/i2c/muxes/i2c-demux-pinctrl.c + GENERIC PM DOMAINS M: "Rafael J. Wysocki" M: Kevin Hilman @@ -11911,6 +11916,11 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git c S: Supported F: drivers/clk/renesas/ +RENESAS EMEV2 I2C DRIVER +M: Wolfram Sang +S: Supported +F: drivers/i2c/busses/i2c-emev2.c + RENESAS ETHERNET DRIVERS R: Sergei Shtylyov L: netdev@vger.kernel.org @@ -11926,6 +11936,12 @@ L: linux-iio@vger.kernel.org S: Supported F: drivers/iio/adc/rcar_gyro_adc.c +RENESAS R-CAR I2C DRIVERS +M: Wolfram Sang +S: Supported +F: drivers/i2c/busses/i2c-rcar.c +F: drivers/i2c/busses/i2c-sh_mobile.c + RENESAS USB PHY DRIVER M: Yoshihiro Shimoda L: linux-renesas-soc@vger.kernel.org From 1eace8344c02c625ee99cc3ffa50187ded2c87b5 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 3 Apr 2018 21:11:50 +0200 Subject: [PATCH 5/5] i2c: add param sanity check to i2c_transfer() The API docs describe i2c_transfer() as taking a pointer to an array of i2c_msg containing at least 1 entry, but leaves it to the individual drivers to sanity check the msgs and num parameters. Let's do this in core code instead. Signed-off-by: Ard Biesheuvel [wsa: changed '<= 0' to '< 1'] Signed-off-by: Wolfram Sang --- drivers/i2c/i2c-core-base.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 1adeebaa81b0..1ba40bb2b966 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1845,6 +1845,9 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) unsigned long orig_jiffies; int ret, try; + if (WARN_ON(!msgs || num < 1)) + return -EINVAL; + if (adap->quirks && i2c_check_for_quirks(adap, msgs, num)) return -EOPNOTSUPP;