Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: ti: Remove pm_runtime_irq_safe() usage for smartreflex

For the smartreflex device, we need to disable smartreflex on SoC idle,
and have been using pm_runtime_irq_safe() to do that. But we want to
remove the irq_safe usage as PM runtime takes a permanent usage count
on the parent device with it.

In order to remove the need for pm_runtime_irq_safe(), let's gate
the clock directly in the driver. This removes the need to call PM runtime
during idle, and allows us to switch to using CPU_PM in the following
patch.

Note that the smartreflex interconnect target module is configured for smart
idle, but the clock does not have autoidle capability, and needs to be gated
manually. If the clock supported autoidle, we would not need to even gate
the clock.

With this change, we can now remove the related quirk flags for ti-sysc
also.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>

authored by

Tony Lindgren and committed by
Santosh Shilimkar
ed4520d6 22ea87ef

+26 -34
+2 -4
drivers/bus/ti-sysc.c
··· 1444 1444 SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_OPT_CLKS_IN_RESET), 1445 1445 SYSC_QUIRK("sham", 0, 0x100, 0x110, 0x114, 0x40000c03, 0xffffffff, 1446 1446 SYSC_QUIRK_LEGACY_IDLE), 1447 - SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x24, -ENODEV, 0x00000000, 0xffffffff, 1448 - SYSC_QUIRK_LEGACY_IDLE), 1449 - SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x38, -ENODEV, 0x00000000, 0xffffffff, 1450 - SYSC_QUIRK_LEGACY_IDLE), 1451 1447 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000046, 0xffffffff, 1452 1448 SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE), 1453 1449 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff, ··· 1579 1583 SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff, 0), 1580 1584 SYSC_QUIRK("slimbus", 0, 0, 0x10, -ENODEV, 0x40000902, 0xffffffff, 0), 1581 1585 SYSC_QUIRK("slimbus", 0, 0, 0x10, -ENODEV, 0x40002903, 0xffffffff, 0), 1586 + SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x24, -ENODEV, 0x00000000, 0xffffffff, 0), 1587 + SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x38, -ENODEV, 0x00000000, 0xffffffff, 0), 1582 1588 SYSC_QUIRK("spinlock", 0, 0, 0x10, -ENODEV, 0x50020000, 0xffffffff, 0), 1583 1589 SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -ENODEV, 0x00000020, 0xffffffff, 0), 1584 1590 SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000013, 0xffffffff, 0),
+22 -30
drivers/soc/ti/smartreflex.c
··· 126 126 127 127 static void sr_set_clk_length(struct omap_sr *sr) 128 128 { 129 - struct clk *fck; 130 129 u32 fclk_speed; 131 130 132 131 /* Try interconnect target module fck first if it already exists */ 133 - fck = clk_get(sr->pdev->dev.parent, "fck"); 134 - if (IS_ERR(fck)) { 135 - fck = clk_get(&sr->pdev->dev, "fck"); 136 - if (IS_ERR(fck)) { 137 - dev_err(&sr->pdev->dev, 138 - "%s: unable to get fck for device %s\n", 139 - __func__, dev_name(&sr->pdev->dev)); 140 - return; 141 - } 142 - } 132 + if (IS_ERR(sr->fck)) 133 + return; 143 134 144 - fclk_speed = clk_get_rate(fck); 145 - clk_put(fck); 135 + fclk_speed = clk_get_rate(sr->fck); 146 136 147 137 switch (fclk_speed) { 148 138 case 12000000: ··· 577 587 /* errminlimit is opp dependent and hence linked to voltage */ 578 588 sr->err_minlimit = nvalue_row->errminlimit; 579 589 580 - pm_runtime_get_sync(&sr->pdev->dev); 590 + clk_enable(sr->fck); 581 591 582 592 /* Check if SR is already enabled. If yes do nothing */ 583 593 if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE) 584 - return 0; 594 + goto out_enabled; 585 595 586 596 /* Configure SR */ 587 597 ret = sr_class->configure(sr); 588 598 if (ret) 589 - return ret; 599 + goto out_enabled; 590 600 591 601 sr_write_reg(sr, NVALUERECIPROCAL, nvalue_row->nvalue); 592 602 593 603 /* SRCONFIG - enable SR */ 594 604 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, SRCONFIG_SRENABLE); 605 + 606 + out_enabled: 607 + sr->enabled = 1; 608 + 595 609 return 0; 596 610 } 597 611 ··· 615 621 } 616 622 617 623 /* Check if SR clocks are already disabled. If yes do nothing */ 618 - if (pm_runtime_suspended(&sr->pdev->dev)) 624 + if (!sr->enabled) 619 625 return; 620 626 621 627 /* ··· 636 642 } 637 643 } 638 644 639 - pm_runtime_put_sync_suspend(&sr->pdev->dev); 645 + clk_disable(sr->fck); 646 + sr->enabled = 0; 640 647 } 641 648 642 649 /** ··· 846 851 847 852 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 848 853 854 + sr_info->fck = devm_clk_get(pdev->dev.parent, "fck"); 855 + if (IS_ERR(sr_info->fck)) 856 + return PTR_ERR(sr_info->fck); 857 + clk_prepare(sr_info->fck); 858 + 849 859 pm_runtime_enable(&pdev->dev); 850 - pm_runtime_irq_safe(&pdev->dev); 851 860 852 861 snprintf(sr_info->name, SMARTREFLEX_NAME_LEN, "%s", pdata->name); 853 862 ··· 876 877 sr_set_clk_length(sr_info); 877 878 878 879 list_add(&sr_info->node, &sr_list); 879 - 880 - ret = pm_runtime_get_sync(&pdev->dev); 881 - if (ret < 0) { 882 - pm_runtime_put_noidle(&pdev->dev); 883 - goto err_list_del; 884 - } 885 880 886 881 /* 887 882 * Call into late init to do initializations that require ··· 926 933 927 934 } 928 935 929 - pm_runtime_put_sync(&pdev->dev); 930 - 931 936 return ret; 932 937 933 938 err_debugfs: 934 939 debugfs_remove_recursive(sr_info->dbg_dir); 935 940 err_list_del: 936 941 list_del(&sr_info->node); 937 - 938 - pm_runtime_put_sync(&pdev->dev); 942 + clk_unprepare(sr_info->fck); 939 943 940 944 return ret; 941 945 } ··· 940 950 static int omap_sr_remove(struct platform_device *pdev) 941 951 { 942 952 struct omap_sr_data *pdata = pdev->dev.platform_data; 953 + struct device *dev = &pdev->dev; 943 954 struct omap_sr *sr_info; 944 955 945 956 if (!pdata) { ··· 959 968 sr_stop_vddautocomp(sr_info); 960 969 debugfs_remove_recursive(sr_info->dbg_dir); 961 970 962 - pm_runtime_disable(&pdev->dev); 971 + pm_runtime_disable(dev); 972 + clk_unprepare(sr_info->fck); 963 973 list_del(&sr_info->node); 964 974 return 0; 965 975 }
+2
include/linux/power/smartreflex.h
··· 155 155 struct voltagedomain *voltdm; 156 156 struct dentry *dbg_dir; 157 157 unsigned int irq; 158 + struct clk *fck; 158 159 int srid; 159 160 int ip_type; 160 161 int nvalue_count; ··· 170 169 u32 senp_mod; 171 170 u32 senn_mod; 172 171 void __iomem *base; 172 + unsigned long enabled:1; 173 173 }; 174 174 175 175 /**