History

Merge tag 'i2c-host-fixes-7.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux into i2c/for-current

i2c-host-fixes for v7.1-rc8 - imx: keep clock and pinctrl states consistent in runtime PM - imx-lpi2c: fix DMA resource leaks on PIO fallback - qcom-cci: fix NULL pointer dereference on remove - riic: fix reset refcount leak on resume_noirq error path - stm32f7: account for analog filter in timing computation - tegra: fix suspend/resume handling in NOIRQ phase - tegra: update Tegra410 I2C timings to match hardware specs - MAINTAINERS: hand over I2C maintainership to Andi

Wolfram Sang committed 5 months ago

Commit 35ebcfc2 parents 5cad752 9bffa2a7 files · +87 −58Browse files

Unified · Split

7 files
  1. MAINTAINERS +2 −2
  2. drivers/i2c/busses/i2c-imx-lpi2c.c +32 −21
  3. drivers/i2c/busses/i2c-imx.c +12 −3
  4. drivers/i2c/busses/i2c-qcom-cci.c +1 −1
  5. drivers/i2c/busses/i2c-riic.c +3 −1
  6. drivers/i2c/busses/i2c-stm32f7.c +3 −3
  7. drivers/i2c/busses/i2c-tegra.c +34 −27
MAINTAINERS+2−2
@@ -12095,11 +12095,11 @@ F: Documentation/i2c/busses/i2c-parport.rst · 12094 unmodified lines
1209512095 F: drivers/i2c/busses/i2c-parport.c
1209612096
1209712097 I2C SUBSYSTEM
12098−M: Wolfram Sang <wsa+renesas@sang-engineering.com>
12098+M: Andi Shyti <andi.shyti@kernel.org>
1209912099 L: linux-i2c@vger.kernel.org
1210012100 S: Maintained
1210112101 Q: https://patchwork.ozlabs.org/project/linux-i2c/list/
12102−T: git git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git
12102+T: git git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git
1210312103 F: Documentation/i2c/
1210412104 F: drivers/i2c/*
1210512105 F: include/dt-bindings/i2c/i2c.h
drivers/i2c/busses/i2c-imx-lpi2c.c+32−21
@@ -1383,55 +1383,66 @@ static int lpi2c_imx_init_recovery_info(struct lpi2c_imx_struct *lpi2c_imx, · 1382 unmodified lines
13831383 return 0;
13841384 }
13851385
1386−static void dma_exit(struct device *dev, struct lpi2c_imx_dma *dma)
1387−{
1388− if (dma->chan_rx)
1389− dma_release_channel(dma->chan_rx);
1390−
1391− if (dma->chan_tx)
1392− dma_release_channel(dma->chan_tx);
1393−
1394− devm_kfree(dev, dma);
1395−}
1396−
13971386 static int lpi2c_dma_init(struct device *dev, dma_addr_t phy_addr)
13981387 {
13991388 struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);
14001389 struct lpi2c_imx_dma *dma;
1390+ void *group;
14011391 int ret;
14021392
1403− dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
1404− if (!dma)
1393+ /*
1394+ * Open a devres group so that all resources allocated within
1395+ * this function can be released together if DMA init fails but
1396+ * probe continues in PIO mode.
1397+ */
1398+ group = devres_open_group(dev, NULL, GFP_KERNEL);
1399+ if (!group)
14051400 return -ENOMEM;
14061401
1402+ dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
1403+ if (!dma) {
1404+ ret = -ENOMEM;
1405+ goto release_group;
1406+ }
1407+
14071408 dma->phy_addr = phy_addr;
14081409
14091410 /* Prepare for TX DMA: */
1410− dma->chan_tx = dma_request_chan(dev, "tx");
1411+ dma->chan_tx = devm_dma_request_chan(dev, "tx");
14111412 if (IS_ERR(dma->chan_tx)) {
14121413 ret = PTR_ERR(dma->chan_tx);
14131414 if (ret != -ENODEV && ret != -EPROBE_DEFER)
14141415 dev_err(dev, "can't request DMA tx channel (%d)\n", ret);
1415− dma->chan_tx = NULL;
1416− goto dma_exit;
1416+ goto release_group;
14171417 }
14181418
14191419 /* Prepare for RX DMA: */
1420− dma->chan_rx = dma_request_chan(dev, "rx");
1420+ dma->chan_rx = devm_dma_request_chan(dev, "rx");
14211421 if (IS_ERR(dma->chan_rx)) {
14221422 ret = PTR_ERR(dma->chan_rx);
14231423 if (ret != -ENODEV && ret != -EPROBE_DEFER)
14241424 dev_err(dev, "can't request DMA rx channel (%d)\n", ret);
1425− dma->chan_rx = NULL;
1426− goto dma_exit;
1425+ goto release_group;
14271426 }
14281427
1428+ /*
1429+ * DMA init succeeded. Remove the group marker but keep all resources
1430+ * bound to the device, they will be freed at device removal.
1431+ */
1432+ devres_remove_group(dev, group);
1433+
14291434 lpi2c_imx->can_use_dma = true;
14301435 lpi2c_imx->dma = dma;
14311436 return 0;
14321437
1433−dma_exit:
1434− dma_exit(dev, dma);
1438+release_group:
1439+ /*
1440+ * DMA init failed. Release ALL resources allocated inside this
1441+ * group (dma memory, TX channel if already acquired, etc.) so
1442+ * that a successful PIO-mode probe does not hold unused resources
1443+ * for the entire device lifetime.
1444+ */
1445+ devres_release_group(dev, group);
14351446 return ret;
14361447 }
14371448
drivers/i2c/busses/i2c-imx.c+12−3
@@ -1892,9 +1892,15 @@ static void i2c_imx_remove(struct platform_device *pdev) · 1891 unmodified lines
18921892 static int i2c_imx_runtime_suspend(struct device *dev)
18931893 {
18941894 struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev);
1895+ int ret;
1896+
1897+ ret = pinctrl_pm_select_sleep_state(dev);
1898+ if (ret)
1899+ return ret;
18951900
18961901 clk_disable(i2c_imx->clk);
1897− return pinctrl_pm_select_sleep_state(dev);
1902+
1903+ return 0;
18981904 }
18991905
19001906 static int i2c_imx_runtime_resume(struct device *dev)
@@ -1907,10 +1913,13 @@ static int i2c_imx_runtime_resume(struct device *dev) · 6 unmodified lines
19071913 return ret;
19081914
19091915 ret = clk_enable(i2c_imx->clk);
1910− if (ret)
1916+ if (ret) {
19111917 dev_err(dev, "can't enable I2C clock, ret=%d\n", ret);
1918+ pinctrl_pm_select_sleep_state(dev);
1919+ return ret;
1920+ }
19121921
1913− return ret;
1922+ return 0;
19141923 }
19151924
19161925 static int i2c_imx_suspend(struct device *dev)
drivers/i2c/busses/i2c-qcom-cci.c+1−1
@@ -660,8 +660,8 @@ static void cci_remove(struct platform_device *pdev) · 659 unmodified lines
660660 if (cci->master[i].cci) {
661661 i2c_del_adapter(&cci->master[i].adap);
662662 of_node_put(cci->master[i].adap.dev.of_node);
663+ cci_halt(cci, i);
663664 }
664− cci_halt(cci, i);
665665 }
666666
667667 disable_irq(cci->irq);
drivers/i2c/busses/i2c-riic.c+3−1
@@ -725,8 +725,10 @@ static int riic_i2c_resume_noirq(struct device *dev) · 724 unmodified lines
725725 return ret;
726726
727727 ret = pm_runtime_force_resume(dev);
728− if (ret)
728+ if (ret) {
729+ reset_control_assert(riic->rstc);
729730 return ret;
731+ }
730732
731733 ret = riic_init_hw(riic);
732734 if (ret) {
drivers/i2c/busses/i2c-stm32f7.c+3−3
@@ -694,6 +694,9 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev, · 693 unmodified lines
694694 if (!of_property_read_bool(i2c_dev->dev->of_node, "i2c-digital-filter"))
695695 i2c_dev->dnf_dt = STM32F7_I2C_DNF_DEFAULT;
696696
697+ i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node,
698+ "i2c-analog-filter");
699+
697700 do {
698701 ret = stm32f7_i2c_compute_timing(i2c_dev, setup,
699702 &i2c_dev->timing);
@@ -715,9 +718,6 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev, · 15 unmodified lines
715718 return ret;
716719 }
717720
718− i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node,
719− "i2c-analog-filter");
720−
721721 dev_dbg(i2c_dev->dev, "I2C Speed(%i), Clk Source(%i)\n",
722722 setup->speed_freq, setup->clock_src);
723723 dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n",
drivers/i2c/busses/i2c-tegra.c+34−27
@@ -2115,9 +2115,9 @@ static const struct tegra_i2c_hw_feature tegra264_i2c_hw = { · 2114 unmodified lines
21152115 static const struct tegra_i2c_hw_feature tegra410_i2c_hw = {
21162116 .has_continue_xfer_support = true,
21172117 .has_per_pkt_xfer_complete_irq = true,
2118− .clk_divisor_hs_mode = 1,
2118+ .clk_divisor_hs_mode = 2,
21192119 .clk_divisor_std_mode = 0x3f,
2120− .clk_divisor_fast_mode = 0x2c,
2120+ .clk_divisor_fast_mode = 0x2f,
21212121 .clk_divisor_fast_plus_mode = 0x11,
21222122 .has_config_load_reg = true,
21232123 .has_multi_master_mode = true,
@@ -2133,8 +2133,8 @@ static const struct tegra_i2c_hw_feature tegra410_i2c_hw = { · 9 unmodified lines
21332133 .thigh_fast_mode = 0x2,
21342134 .tlow_fastplus_mode = 0x2,
21352135 .thigh_fastplus_mode = 0x2,
2136− .tlow_hs_mode = 0x8,
2137− .thigh_hs_mode = 0x6,
2136+ .tlow_hs_mode = 0x5,
2137+ .thigh_hs_mode = 0x2,
21382138 .setup_hold_time_std_mode = 0x08080808,
21392139 .setup_hold_time_fast_mode = 0x02020202,
21402140 .setup_hold_time_fastplus_mode = 0x02020202,
@@ -2401,29 +2401,38 @@ static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev) · 260 unmodified lines
24012401 }
24022402
24032403 static int __maybe_unused tegra_i2c_suspend(struct device *dev)
2404+{
2405+ /*
2406+ * Bring the controller up and hold a usage count so it stays
2407+ * available until the noirq phase.
2408+ */
2409+ return pm_runtime_resume_and_get(dev);
2410+}
2411+
2412+static int __maybe_unused tegra_i2c_suspend_noirq(struct device *dev)
24042413 {
24052414 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
2406− int err;
24072415
24082416 i2c_mark_adapter_suspended(&i2c_dev->adapter);
24092417
2410− if (!pm_runtime_status_suspended(dev)) {
2411− err = tegra_i2c_runtime_suspend(dev);
2412− if (err)
2413− return err;
2414− }
2415−
2416− return 0;
2418+ /*
2419+ * Runtime PM is already disabled at this point, so invoke the
2420+ * runtime_suspend callback directly to put the controller down.
2421+ */
2422+ return tegra_i2c_runtime_suspend(dev);
24172423 }
24182424
2419−static int __maybe_unused tegra_i2c_resume(struct device *dev)
2425+static int __maybe_unused tegra_i2c_resume_noirq(struct device *dev)
24202426 {
24212427 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
24222428 int err;
24232429
24242430 /*
2425− * We need to ensure that clocks are enabled so that registers can be
2426− * restored in tegra_i2c_init().
2431+ * Runtime PM is still disabled at this point, so invoke the
2432+ * runtime_resume callback directly to bring the controller back up
2433+ * before re-initializing the hardware. The adapter is then marked
2434+ * resumed so that consumers can issue transfers from their own
2435+ * resume_noirq() handlers and onwards.
24272436 */
24282437 err = tegra_i2c_runtime_resume(dev);
24292438 if (err)
@@ -2433,24 +2442,22 @@ static int __maybe_unused tegra_i2c_resume(struct device *dev) · 3 unmodified lines
24332442 if (err)
24342443 return err;
24352444
2436− /*
2437− * In case we are runtime suspended, disable clocks again so that we
2438− * don't unbalance the clock reference counts during the next runtime
2439− * resume transition.
2440− */
2441− if (pm_runtime_status_suspended(dev)) {
2442− err = tegra_i2c_runtime_suspend(dev);
2443− if (err)
2444− return err;
2445− }
2446−
24472445 i2c_mark_adapter_resumed(&i2c_dev->adapter);
24482446
24492447 return 0;
24502448 }
24512449
2450+static int __maybe_unused tegra_i2c_resume(struct device *dev)
2451+{
2452+ pm_runtime_put(dev);
2453+
2454+ return 0;
2455+}
2456+
24522457 static const struct dev_pm_ops tegra_i2c_pm = {
2453− SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume)
2458+ SET_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume)
2459+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend_noirq,
2460+ tegra_i2c_resume_noirq)
24542461 SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume,
24552462 NULL)
24562463 };

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