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
Unified · Split
| @@ -12095,11 +12095,11 @@ F: Documentation/i2c/busses/i2c-parport.rst · 12094 unmodified lines | ||
| 12095 | 12095 | F: drivers/i2c/busses/i2c-parport.c |
| 12096 | 12096 | |
| 12097 | 12097 | I2C SUBSYSTEM |
| 12098 | −M: Wolfram Sang <wsa+renesas@sang-engineering.com> | |
| 12098 | +M: Andi Shyti <andi.shyti@kernel.org> | |
| 12099 | 12099 | L: linux-i2c@vger.kernel.org |
| 12100 | 12100 | S: Maintained |
| 12101 | 12101 | 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 | |
| 12103 | 12103 | F: Documentation/i2c/ |
| 12104 | 12104 | F: drivers/i2c/* |
| 12105 | 12105 | F: include/dt-bindings/i2c/i2c.h |
| @@ -1383,55 +1383,66 @@ static int lpi2c_imx_init_recovery_info(struct lpi2c_imx_struct *lpi2c_imx, · 1382 unmodified lines | ||
| 1383 | 1383 | return 0; |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 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 | − | |
| 1397 | 1386 | static int lpi2c_dma_init(struct device *dev, dma_addr_t phy_addr) |
| 1398 | 1387 | { |
| 1399 | 1388 | struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev); |
| 1400 | 1389 | struct lpi2c_imx_dma *dma; |
| 1390 | + void *group; | |
| 1401 | 1391 | int ret; |
| 1402 | 1392 | |
| 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) | |
| 1405 | 1400 | return -ENOMEM; |
| 1406 | 1401 | |
| 1402 | + dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL); | |
| 1403 | + if (!dma) { | |
| 1404 | + ret = -ENOMEM; | |
| 1405 | + goto release_group; | |
| 1406 | + } | |
| 1407 | + | |
| 1407 | 1408 | dma->phy_addr = phy_addr; |
| 1408 | 1409 | |
| 1409 | 1410 | /* Prepare for TX DMA: */ |
| 1410 | − dma->chan_tx = dma_request_chan(dev, "tx"); | |
| 1411 | + dma->chan_tx = devm_dma_request_chan(dev, "tx"); | |
| 1411 | 1412 | if (IS_ERR(dma->chan_tx)) { |
| 1412 | 1413 | ret = PTR_ERR(dma->chan_tx); |
| 1413 | 1414 | if (ret != -ENODEV && ret != -EPROBE_DEFER) |
| 1414 | 1415 | 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; | |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | /* Prepare for RX DMA: */ |
| 1420 | − dma->chan_rx = dma_request_chan(dev, "rx"); | |
| 1420 | + dma->chan_rx = devm_dma_request_chan(dev, "rx"); | |
| 1421 | 1421 | if (IS_ERR(dma->chan_rx)) { |
| 1422 | 1422 | ret = PTR_ERR(dma->chan_rx); |
| 1423 | 1423 | if (ret != -ENODEV && ret != -EPROBE_DEFER) |
| 1424 | 1424 | 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; | |
| 1427 | 1426 | } |
| 1428 | 1427 | |
| 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 | + | |
| 1429 | 1434 | lpi2c_imx->can_use_dma = true; |
| 1430 | 1435 | lpi2c_imx->dma = dma; |
| 1431 | 1436 | return 0; |
| 1432 | 1437 | |
| 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); | |
| 1435 | 1446 | return ret; |
| 1436 | 1447 | } |
| 1437 | 1448 | |
| @@ -1892,9 +1892,15 @@ static void i2c_imx_remove(struct platform_device *pdev) · 1891 unmodified lines | ||
| 1892 | 1892 | static int i2c_imx_runtime_suspend(struct device *dev) |
| 1893 | 1893 | { |
| 1894 | 1894 | 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; | |
| 1895 | 1900 | |
| 1896 | 1901 | clk_disable(i2c_imx->clk); |
| 1897 | − return pinctrl_pm_select_sleep_state(dev); | |
| 1902 | + | |
| 1903 | + return 0; | |
| 1898 | 1904 | } |
| 1899 | 1905 | |
| 1900 | 1906 | 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 | ||
| 1907 | 1913 | return ret; |
| 1908 | 1914 | |
| 1909 | 1915 | ret = clk_enable(i2c_imx->clk); |
| 1910 | − if (ret) | |
| 1916 | + if (ret) { | |
| 1911 | 1917 | dev_err(dev, "can't enable I2C clock, ret=%d\n", ret); |
| 1918 | + pinctrl_pm_select_sleep_state(dev); | |
| 1919 | + return ret; | |
| 1920 | + } | |
| 1912 | 1921 | |
| 1913 | − return ret; | |
| 1922 | + return 0; | |
| 1914 | 1923 | } |
| 1915 | 1924 | |
| 1916 | 1925 | static int i2c_imx_suspend(struct device *dev) |
| @@ -660,8 +660,8 @@ static void cci_remove(struct platform_device *pdev) · 659 unmodified lines | ||
| 660 | 660 | if (cci->master[i].cci) { |
| 661 | 661 | i2c_del_adapter(&cci->master[i].adap); |
| 662 | 662 | of_node_put(cci->master[i].adap.dev.of_node); |
| 663 | + cci_halt(cci, i); | |
| 663 | 664 | } |
| 664 | − cci_halt(cci, i); | |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | disable_irq(cci->irq); |
| @@ -725,8 +725,10 @@ static int riic_i2c_resume_noirq(struct device *dev) · 724 unmodified lines | ||
| 725 | 725 | return ret; |
| 726 | 726 | |
| 727 | 727 | ret = pm_runtime_force_resume(dev); |
| 728 | − if (ret) | |
| 728 | + if (ret) { | |
| 729 | + reset_control_assert(riic->rstc); | |
| 729 | 730 | return ret; |
| 731 | + } | |
| 730 | 732 | |
| 731 | 733 | ret = riic_init_hw(riic); |
| 732 | 734 | if (ret) { |
| @@ -694,6 +694,9 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev, · 693 unmodified lines | ||
| 694 | 694 | if (!of_property_read_bool(i2c_dev->dev->of_node, "i2c-digital-filter")) |
| 695 | 695 | i2c_dev->dnf_dt = STM32F7_I2C_DNF_DEFAULT; |
| 696 | 696 | |
| 697 | + i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node, | |
| 698 | + "i2c-analog-filter"); | |
| 699 | + | |
| 697 | 700 | do { |
| 698 | 701 | ret = stm32f7_i2c_compute_timing(i2c_dev, setup, |
| 699 | 702 | &i2c_dev->timing); |
| @@ -715,9 +718,6 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev, · 15 unmodified lines | ||
| 715 | 718 | return ret; |
| 716 | 719 | } |
| 717 | 720 | |
| 718 | − i2c_dev->analog_filter = of_property_read_bool(i2c_dev->dev->of_node, | |
| 719 | − "i2c-analog-filter"); | |
| 720 | − | |
| 721 | 721 | dev_dbg(i2c_dev->dev, "I2C Speed(%i), Clk Source(%i)\n", |
| 722 | 722 | setup->speed_freq, setup->clock_src); |
| 723 | 723 | dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n", |
| @@ -2115,9 +2115,9 @@ static const struct tegra_i2c_hw_feature tegra264_i2c_hw = { · 2114 unmodified lines | ||
| 2115 | 2115 | static const struct tegra_i2c_hw_feature tegra410_i2c_hw = { |
| 2116 | 2116 | .has_continue_xfer_support = true, |
| 2117 | 2117 | .has_per_pkt_xfer_complete_irq = true, |
| 2118 | − .clk_divisor_hs_mode = 1, | |
| 2118 | + .clk_divisor_hs_mode = 2, | |
| 2119 | 2119 | .clk_divisor_std_mode = 0x3f, |
| 2120 | − .clk_divisor_fast_mode = 0x2c, | |
| 2120 | + .clk_divisor_fast_mode = 0x2f, | |
| 2121 | 2121 | .clk_divisor_fast_plus_mode = 0x11, |
| 2122 | 2122 | .has_config_load_reg = true, |
| 2123 | 2123 | .has_multi_master_mode = true, |
| @@ -2133,8 +2133,8 @@ static const struct tegra_i2c_hw_feature tegra410_i2c_hw = { · 9 unmodified lines | ||
| 2133 | 2133 | .thigh_fast_mode = 0x2, |
| 2134 | 2134 | .tlow_fastplus_mode = 0x2, |
| 2135 | 2135 | .thigh_fastplus_mode = 0x2, |
| 2136 | − .tlow_hs_mode = 0x8, | |
| 2137 | − .thigh_hs_mode = 0x6, | |
| 2136 | + .tlow_hs_mode = 0x5, | |
| 2137 | + .thigh_hs_mode = 0x2, | |
| 2138 | 2138 | .setup_hold_time_std_mode = 0x08080808, |
| 2139 | 2139 | .setup_hold_time_fast_mode = 0x02020202, |
| 2140 | 2140 | .setup_hold_time_fastplus_mode = 0x02020202, |
| @@ -2401,29 +2401,38 @@ static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev) · 260 unmodified lines | ||
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | 2403 | 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) | |
| 2404 | 2413 | { |
| 2405 | 2414 | struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); |
| 2406 | − int err; | |
| 2407 | 2415 | |
| 2408 | 2416 | i2c_mark_adapter_suspended(&i2c_dev->adapter); |
| 2409 | 2417 | |
| 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); | |
| 2417 | 2423 | } |
| 2418 | 2424 | |
| 2419 | −static int __maybe_unused tegra_i2c_resume(struct device *dev) | |
| 2425 | +static int __maybe_unused tegra_i2c_resume_noirq(struct device *dev) | |
| 2420 | 2426 | { |
| 2421 | 2427 | struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); |
| 2422 | 2428 | int err; |
| 2423 | 2429 | |
| 2424 | 2430 | /* |
| 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. | |
| 2427 | 2436 | */ |
| 2428 | 2437 | err = tegra_i2c_runtime_resume(dev); |
| 2429 | 2438 | if (err) |
| @@ -2433,24 +2442,22 @@ static int __maybe_unused tegra_i2c_resume(struct device *dev) · 3 unmodified lines | ||
| 2433 | 2442 | if (err) |
| 2434 | 2443 | return err; |
| 2435 | 2444 | |
| 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 | − | |
| 2447 | 2445 | i2c_mark_adapter_resumed(&i2c_dev->adapter); |
| 2448 | 2446 | |
| 2449 | 2447 | return 0; |
| 2450 | 2448 | } |
| 2451 | 2449 | |
| 2450 | +static int __maybe_unused tegra_i2c_resume(struct device *dev) | |
| 2451 | +{ | |
| 2452 | + pm_runtime_put(dev); | |
| 2453 | + | |
| 2454 | + return 0; | |
| 2455 | +} | |
| 2456 | + | |
| 2452 | 2457 | 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) | |
| 2454 | 2461 | SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume, |
| 2455 | 2462 | NULL) |
| 2456 | 2463 | }; |