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
12095F: drivers/i2c/busses/i2c-parport.c12095F: drivers/i2c/busses/i2c-parport.c
12096 12096
12097I2C SUBSYSTEM12097I2C SUBSYSTEM
12098M: Wolfram Sang <wsa+renesas@sang-engineering.com>12098M: Andi Shyti <andi.shyti@kernel.org>
12099L: linux-i2c@vger.kernel.org12099L: linux-i2c@vger.kernel.org
12100S: Maintained12100S: Maintained
12101Q: https://patchwork.ozlabs.org/project/linux-i2c/list/12101Q: https://patchwork.ozlabs.org/project/linux-i2c/list/
12102T: git git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git12102T: git git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git
12103F: Documentation/i2c/12103F: Documentation/i2c/
12104F: drivers/i2c/*12104F: drivers/i2c/*
12105F: include/dt-bindings/i2c/i2c.h12105F: 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
1383 return 0;1383 return 0;
1384}1384}
1385 1385
1386static 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
1397static int lpi2c_dma_init(struct device *dev, dma_addr_t phy_addr)1386static int lpi2c_dma_init(struct device *dev, dma_addr_t phy_addr)
1398{1387{
1399 struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);1388 struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);
1400 struct lpi2c_imx_dma *dma;1389 struct lpi2c_imx_dma *dma;
1390 void *group;
1401 int ret;1391 int ret;
1402 1392
1403 dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);1393 /*
1404 if (!dma)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 return -ENOMEM;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 dma->phy_addr = phy_addr;1408 dma->phy_addr = phy_addr;
1408 1409
1409 /* Prepare for TX DMA: */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 if (IS_ERR(dma->chan_tx)) {1412 if (IS_ERR(dma->chan_tx)) {
1412 ret = PTR_ERR(dma->chan_tx);1413 ret = PTR_ERR(dma->chan_tx);
1413 if (ret != -ENODEV && ret != -EPROBE_DEFER)1414 if (ret != -ENODEV && ret != -EPROBE_DEFER)
1414 dev_err(dev, "can't request DMA tx channel (%d)\n", ret);1415 dev_err(dev, "can't request DMA tx channel (%d)\n", ret);
1415 dma->chan_tx = NULL;1416 goto release_group;
1416 goto dma_exit;
1417 }1417 }
1418 1418
1419 /* Prepare for RX DMA: */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 if (IS_ERR(dma->chan_rx)) {1421 if (IS_ERR(dma->chan_rx)) {
1422 ret = PTR_ERR(dma->chan_rx);1422 ret = PTR_ERR(dma->chan_rx);
1423 if (ret != -ENODEV && ret != -EPROBE_DEFER)1423 if (ret != -ENODEV && ret != -EPROBE_DEFER)
1424 dev_err(dev, "can't request DMA rx channel (%d)\n", ret);1424 dev_err(dev, "can't request DMA rx channel (%d)\n", ret);
1425 dma->chan_rx = NULL;1425 goto release_group;
1426 goto dma_exit;
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 lpi2c_imx->can_use_dma = true;1434 lpi2c_imx->can_use_dma = true;
1430 lpi2c_imx->dma = dma;1435 lpi2c_imx->dma = dma;
1431 return 0;1436 return 0;
1432 1437
1433dma_exit:1438release_group:
1434 dma_exit(dev, dma);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 return ret;1446 return ret;
1436}1447}
1437 1448
drivers/i2c/busses/i2c-imx.c+12−3
@@ -1892,9 +1892,15 @@ static void i2c_imx_remove(struct platform_device *pdev) · 1891 unmodified lines
1892static int i2c_imx_runtime_suspend(struct device *dev)1892static int i2c_imx_runtime_suspend(struct device *dev)
1893{1893{
1894 struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev);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 clk_disable(i2c_imx->clk);1901 clk_disable(i2c_imx->clk);
1897 return pinctrl_pm_select_sleep_state(dev);1902
1903 return 0;
1898}1904}
1899 1905
1900static int i2c_imx_runtime_resume(struct device *dev)1906static 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 return ret;1913 return ret;
1908 1914
1909 ret = clk_enable(i2c_imx->clk);1915 ret = clk_enable(i2c_imx->clk);
1910 if (ret)1916 if (ret) {
1911 dev_err(dev, "can't enable I2C clock, ret=%d\n", ret);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
1916static int i2c_imx_suspend(struct device *dev)1925static 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
660 if (cci->master[i].cci) {660 if (cci->master[i].cci) {
661 i2c_del_adapter(&cci->master[i].adap);661 i2c_del_adapter(&cci->master[i].adap);
662 of_node_put(cci->master[i].adap.dev.of_node);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 disable_irq(cci->irq);667 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
725 return ret;725 return ret;
726 726
727 ret = pm_runtime_force_resume(dev);727 ret = pm_runtime_force_resume(dev);
728 if (ret)728 if (ret) {
729 reset_control_assert(riic->rstc);
729 return ret;730 return ret;
731 }
730 732
731 ret = riic_init_hw(riic);733 ret = riic_init_hw(riic);
732 if (ret) {734 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
694 if (!of_property_read_bool(i2c_dev->dev->of_node, "i2c-digital-filter"))694 if (!of_property_read_bool(i2c_dev->dev->of_node, "i2c-digital-filter"))
695 i2c_dev->dnf_dt = STM32F7_I2C_DNF_DEFAULT;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 do {700 do {
698 ret = stm32f7_i2c_compute_timing(i2c_dev, setup,701 ret = stm32f7_i2c_compute_timing(i2c_dev, setup,
699 &i2c_dev->timing);702 &i2c_dev->timing);
@@ -715,9 +718,6 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev, · 15 unmodified lines
715 return ret;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 dev_dbg(i2c_dev->dev, "I2C Speed(%i), Clk Source(%i)\n",721 dev_dbg(i2c_dev->dev, "I2C Speed(%i), Clk Source(%i)\n",
722 setup->speed_freq, setup->clock_src);722 setup->speed_freq, setup->clock_src);
723 dev_dbg(i2c_dev->dev, "I2C Rise(%i) and Fall(%i) Time\n",723 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
2115static const struct tegra_i2c_hw_feature tegra410_i2c_hw = {2115static const struct tegra_i2c_hw_feature tegra410_i2c_hw = {
2116 .has_continue_xfer_support = true,2116 .has_continue_xfer_support = true,
2117 .has_per_pkt_xfer_complete_irq = true,2117 .has_per_pkt_xfer_complete_irq = true,
2118 .clk_divisor_hs_mode = 1,2118 .clk_divisor_hs_mode = 2,
2119 .clk_divisor_std_mode = 0x3f,2119 .clk_divisor_std_mode = 0x3f,
2120 .clk_divisor_fast_mode = 0x2c,2120 .clk_divisor_fast_mode = 0x2f,
2121 .clk_divisor_fast_plus_mode = 0x11,2121 .clk_divisor_fast_plus_mode = 0x11,
2122 .has_config_load_reg = true,2122 .has_config_load_reg = true,
2123 .has_multi_master_mode = true,2123 .has_multi_master_mode = true,
@@ -2133,8 +2133,8 @@ static const struct tegra_i2c_hw_feature tegra410_i2c_hw = { · 9 unmodified lines
2133 .thigh_fast_mode = 0x2,2133 .thigh_fast_mode = 0x2,
2134 .tlow_fastplus_mode = 0x2,2134 .tlow_fastplus_mode = 0x2,
2135 .thigh_fastplus_mode = 0x2,2135 .thigh_fastplus_mode = 0x2,
2136 .tlow_hs_mode = 0x8,2136 .tlow_hs_mode = 0x5,
2137 .thigh_hs_mode = 0x6,2137 .thigh_hs_mode = 0x2,
2138 .setup_hold_time_std_mode = 0x08080808,2138 .setup_hold_time_std_mode = 0x08080808,
2139 .setup_hold_time_fast_mode = 0x02020202,2139 .setup_hold_time_fast_mode = 0x02020202,
2140 .setup_hold_time_fastplus_mode = 0x02020202,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
2403static int __maybe_unused tegra_i2c_suspend(struct device *dev)2403static 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
2412static int __maybe_unused tegra_i2c_suspend_noirq(struct device *dev)
2404{2413{
2405 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);2414 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
2406 int err;
2407 2415
2408 i2c_mark_adapter_suspended(&i2c_dev->adapter);2416 i2c_mark_adapter_suspended(&i2c_dev->adapter);
2409 2417
2410 if (!pm_runtime_status_suspended(dev)) {2418 /*
2411 err = tegra_i2c_runtime_suspend(dev);2419 * Runtime PM is already disabled at this point, so invoke the
2412 if (err)2420 * runtime_suspend callback directly to put the controller down.
2413 return err;2421 */
2414 }2422 return tegra_i2c_runtime_suspend(dev);
2415
2416 return 0;
2417}2423}
2418 2424
2419static int __maybe_unused tegra_i2c_resume(struct device *dev)2425static int __maybe_unused tegra_i2c_resume_noirq(struct device *dev)
2420{2426{
2421 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);2427 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
2422 int err;2428 int err;
2423 2429
2424 /*2430 /*
2425 * We need to ensure that clocks are enabled so that registers can be2431 * Runtime PM is still disabled at this point, so invoke the
2426 * restored in tegra_i2c_init().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 err = tegra_i2c_runtime_resume(dev);2437 err = tegra_i2c_runtime_resume(dev);
2429 if (err)2438 if (err)
@@ -2433,24 +2442,22 @@ static int __maybe_unused tegra_i2c_resume(struct device *dev) · 3 unmodified lines
2433 if (err)2442 if (err)
2434 return err;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 i2c_mark_adapter_resumed(&i2c_dev->adapter);2445 i2c_mark_adapter_resumed(&i2c_dev->adapter);
2448 2446
2449 return 0;2447 return 0;
2450}2448}
2451 2449
2450static int __maybe_unused tegra_i2c_resume(struct device *dev)
2451{
2452 pm_runtime_put(dev);
2453
2454 return 0;
2455}
2456
2452static const struct dev_pm_ops tegra_i2c_pm = {2457static 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 SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume,2461 SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume,
2455 NULL)2462 NULL)
2456};2463};

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