History

Merge tag 'i2c-fixes-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux

Pull i2c fixes from Andi Shyti: "Fixes mainly for teardown and resource handling, runtime PM and hardware-specific controller issues: - fix debugfs use-after-free when removing the adapter - designware: apply interrupt mask quirk for HJMC3001 - imx-lpi2c: avoid target accesses on master-only controllers - mux: release channel node when adapter registration fails - qcom-cci: fix autosuspend and runtime PM cleanup on removal - qcom-geni: fix timing parameters for 32 MHz clock" * tag 'i2c-fixes-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux: i2c: core: fix debugfs UAF on adapter removal i2c: imx-lpi2c: avoid accessing target registers on master-only controllers i2c: qcom-cci: fix autosuspend cleanup i2c: designware: Enable interrupt mask workaround for HJMC3001 i2c: qcom-geni: update frequency table to fix timing parameters i2c: mux: Fix channel node leak on adapter add failure

Linus Torvalds committed 2 months ago

Commit 78bb2082 parents eea8bdc b15b5486 files · +37 −14Browse files

Unified · Split

6 files
  1. drivers/i2c/busses/i2c-designware-platdrv.c +1 −1
  2. drivers/i2c/busses/i2c-imx-lpi2c.c +23 −4
  3. drivers/i2c/busses/i2c-qcom-cci.c +4 −7
  4. drivers/i2c/busses/i2c-qcom-geni.c +2 −2
  5. drivers/i2c/i2c-core-base.c +6 −0
  6. drivers/i2c/i2c-mux.c +1 −0
drivers/i2c/busses/i2c-designware-platdrv.c+1−1
@@ -272,7 +272,7 @@ static const struct acpi_device_id dw_i2c_acpi_match[] = { · 271 unmodified lines
272272 { "HISI02A1", 0 },
273273 { "HISI02A2", 0 },
274274 { "HISI02A3", 0 },
275− { "HJMC3001", 0 },
275+ { "HJMC3001", ACCESS_INTR_MASK },
276276 { "HYGO0010", ACCESS_INTR_MASK },
277277 { "INT33C2", 0 },
278278 { "INT33C3", 0 },
drivers/i2c/busses/i2c-imx-lpi2c.c+23−4
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929
3030 #define DRIVER_NAME "imx-lpi2c"
3131
32+#define LPI2C_VERID 0x00 /* i2c version ID */
3233 #define LPI2C_PARAM 0x04 /* i2c RX/TX FIFO size */
3334 #define LPI2C_MCR 0x10 /* i2c contrl register */
3435 #define LPI2C_MSR 0x14 /* i2c status register */
@@ -136,6 +137,9 @@ · 101 unmodified lines
136137 #define I2C_PM_LONG_TIMEOUT_MS 1000 /* Avoid dead lock caused by big clock prepare lock */
137138 #define I2C_DMA_THRESHOLD 8 /* bytes */
138139
140+/* Bit 0 indicates the presence of the target feature */
141+#define VERID_FEATURE_TARGET_PRESENT BIT(0)
142+
139143 enum lpi2c_imx_mode {
140144 STANDARD, /* 100+Kbps */
141145 FAST, /* 400+Kbps */
@@ -194,6 +198,7 @@ struct lpi2c_imx_struct { · 52 unmodified lines
194198 bool can_use_dma;
195199 struct lpi2c_imx_dma *dma;
196200 struct i2c_client *target;
201+ bool target_supported;
197202 int irq;
198203 const struct imx_lpi2c_hwdata *hwdata;
199204 };
@@ -1330,6 +1335,10 @@ static int lpi2c_imx_register_target(struct i2c_client *client) · 1130 unmodified lines
13301335 struct lpi2c_imx_struct *lpi2c_imx = i2c_get_adapdata(client->adapter);
13311336 int ret;
13321337
1338+ /* Reject target-mode registration on controllers that don't support it. */
1339+ if (!lpi2c_imx->target_supported)
1340+ return -EOPNOTSUPP;
1341+
13331342 if (lpi2c_imx->target)
13341343 return -EBUSY;
13351344
@@ -1546,13 +1555,23 @@ static int lpi2c_imx_probe(struct platform_device *pdev) · 210 unmodified lines
15461555 pm_runtime_enable(&pdev->dev);
15471556
15481557 /*
1549− * Reset all internal controller registers of both Master and Target
1550− * to avoid effects of previous status.
1558+ * Reset all internal controller registers to avoid effects of any
1559+ * state left over from a previous stage (e.g. the bootloader).
1560+ *
1561+ * The Master block (MCR) is present on every controller, so reset it
1562+ * unconditionally. VERID shows whether the target feature is supported.
1563+ * Do not touch the Target block (SCR) on a master-only controller to
1564+ * avoid an asynchronous SError.
15511565 */
15521566 writel(MCR_RST, lpi2c_imx->base + LPI2C_MCR);
1553− writel(SCR_RST, lpi2c_imx->base + LPI2C_SCR);
15541567 writel(0, lpi2c_imx->base + LPI2C_MCR);
1555− writel(0, lpi2c_imx->base + LPI2C_SCR);
1568+
1569+ lpi2c_imx->target_supported = !!(readl(lpi2c_imx->base + LPI2C_VERID) &
1570+ VERID_FEATURE_TARGET_PRESENT);
1571+ if (lpi2c_imx->target_supported) {
1572+ writel(SCR_RST, lpi2c_imx->base + LPI2C_SCR);
1573+ writel(0, lpi2c_imx->base + LPI2C_SCR);
1574+ }
15561575
15571576 ret = devm_request_irq(&pdev->dev, lpi2c_imx->irq, lpi2c_imx_isr, IRQF_NO_SUSPEND,
15581577 pdev->name, lpi2c_imx);
drivers/i2c/busses/i2c-qcom-cci.c+4−7
@@ -595,9 +595,11 @@ static int cci_probe(struct platform_device *pdev) · 594 unmodified lines
595595 goto disable_clocks;
596596
597597 pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
598+ ret = devm_pm_runtime_set_active_enabled(dev);
599+ if (ret)
600+ goto disable_clocks;
601+
598602 pm_runtime_use_autosuspend(dev);
599− pm_runtime_set_active(dev);
600− pm_runtime_enable(dev);
601603
602604 for (i = 0; i < cci->data->num_masters; i++) {
603605 if (!cci->master[i].cci)
@@ -613,8 +615,6 @@ static int cci_probe(struct platform_device *pdev) · 9 unmodified lines
613615 return 0;
614616
615617 error_i2c:
616− pm_runtime_disable(dev);
617− pm_runtime_dont_use_autosuspend(dev);
618618
619619 for (--i ; i >= 0; i--) {
620620 if (cci->master[i].cci) {
@@ -640,9 +640,6 @@ static void cci_remove(struct platform_device *pdev) · 19 unmodified lines
640640 cci_halt(cci, i);
641641 }
642642 }
643−
644− pm_runtime_disable(&pdev->dev);
645− pm_runtime_set_suspended(&pdev->dev);
646643 }
647644
648645 static const struct cci_data cci_v1_data = {
drivers/i2c/busses/i2c-qcom-geni.c+2−2
@@ -188,8 +188,8 @@ static const struct geni_i2c_clk_fld geni_i2c_clk_map_19p2mhz[] = { · 187 unmodified lines
188188
189189 /* source_clock = 32 MHz */
190190 static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
191− { I2C_MAX_STANDARD_MODE_FREQ, 8, 14, 18, 38 },
192− { I2C_MAX_FAST_MODE_FREQ, 4, 3, 9, 19 },
191+ { I2C_MAX_STANDARD_MODE_FREQ, 12, 9, 10, 26 },
192+ { I2C_MAX_FAST_MODE_FREQ, 4, 3, 9, 19 },
193193 { I2C_MAX_FAST_MODE_PLUS_FREQ, 2, 3, 5, 15 },
194194 {}
195195 };
drivers/i2c/i2c-core-base.c+6−0
@@ -1816,6 +1816,12 @@ void i2c_del_adapter(struct i2c_adapter *adap) · 1815 unmodified lines
18161816 return;
18171817 }
18181818
1819+ /*
1820+ * This drains any in-flight writers, so all
1821+ * clients will be caught by i2c_deregister_clients().
1822+ */
1823+ device_remove_file(&adap->dev, &dev_attr_new_device);
1824+
18191825 i2c_acpi_remove_space_handler(adap);
18201826
18211827 i2c_deregister_clients(adap);
drivers/i2c/i2c-mux.c+1−0
@@ -408,6 +408,7 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, · 407 unmodified lines
408408 return 0;
409409
410410 err_free_priv:
411+ of_node_put(priv->adap.dev.of_node);
411412 kfree(priv);
412413 return ret;
413414 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t