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

bus: ti-sysc: Just use SET_NOIRQ_SYSTEM_SLEEP_PM_OPS

As Grygorii Strashko pointed out, the runtime PM use count of the
children can be whatever at suspend and we should not use it. So
let's just suspend ti-sysc at noirq level and get rid of some code.

Let's also remove the PM_SLEEP ifdef and use __maybe_unused as the
PM code already deals with the ifdefs.

Suggested-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

+4 -111
+4 -111
drivers/bus/ti-sysc.c
··· 87 87 u32 revision; 88 88 bool enabled; 89 89 bool needs_resume; 90 - unsigned int noirq_suspend:1; 91 90 bool child_needs_resume; 92 91 struct delayed_work idle_work; 93 92 }; ··· 701 702 return error; 702 703 } 703 704 704 - #ifdef CONFIG_PM_SLEEP 705 - static int sysc_suspend(struct device *dev) 705 + static int __maybe_unused sysc_noirq_suspend(struct device *dev) 706 706 { 707 707 struct sysc *ddata; 708 - int error; 709 708 710 709 ddata = dev_get_drvdata(dev); 711 710 712 711 if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) 713 712 return 0; 714 713 715 - if (!ddata->enabled || ddata->noirq_suspend) 716 - return 0; 717 - 718 - dev_dbg(ddata->dev, "%s %s\n", __func__, 719 - ddata->name ? ddata->name : ""); 720 - 721 - error = pm_runtime_put_sync_suspend(dev); 722 - if (error == -EBUSY) { 723 - dev_dbg(ddata->dev, "%s busy, tagging for noirq suspend %s\n", 724 - __func__, ddata->name ? ddata->name : ""); 725 - 726 - ddata->noirq_suspend = true; 727 - 728 - return 0; 729 - } else if (error < 0) { 730 - dev_warn(ddata->dev, "%s cannot suspend %i %s\n", 731 - __func__, error, 732 - ddata->name ? ddata->name : ""); 733 - 734 - return 0; 735 - } 736 - 737 - ddata->needs_resume = true; 738 - 739 - return 0; 714 + return pm_runtime_force_suspend(dev); 740 715 } 741 716 742 - static int sysc_resume(struct device *dev) 717 + static int __maybe_unused sysc_noirq_resume(struct device *dev) 743 718 { 744 719 struct sysc *ddata; 745 - int error; 746 720 747 721 ddata = dev_get_drvdata(dev); 748 722 749 723 if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) 750 724 return 0; 751 725 752 - if (!ddata->needs_resume || ddata->noirq_suspend) 753 - return 0; 754 - 755 - dev_dbg(ddata->dev, "%s %s\n", __func__, 756 - ddata->name ? ddata->name : ""); 757 - 758 - error = pm_runtime_get_sync(dev); 759 - if (error < 0) { 760 - dev_err(ddata->dev, "%s error %i %s\n", 761 - __func__, error, 762 - ddata->name ? ddata->name : ""); 763 - 764 - return error; 765 - } 766 - 767 - ddata->needs_resume = false; 768 - 769 - return 0; 726 + return pm_runtime_force_resume(dev); 770 727 } 771 - 772 - static int sysc_noirq_suspend(struct device *dev) 773 - { 774 - struct sysc *ddata; 775 - int error; 776 - 777 - ddata = dev_get_drvdata(dev); 778 - 779 - if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) 780 - return 0; 781 - 782 - if (!ddata->enabled || !ddata->noirq_suspend) 783 - return 0; 784 - 785 - dev_dbg(ddata->dev, "%s %s\n", __func__, 786 - ddata->name ? ddata->name : ""); 787 - 788 - error = sysc_runtime_suspend(dev); 789 - if (error) { 790 - dev_warn(ddata->dev, "%s busy %i %s\n", 791 - __func__, error, ddata->name ? ddata->name : ""); 792 - 793 - return 0; 794 - } 795 - 796 - ddata->needs_resume = true; 797 - 798 - return 0; 799 - } 800 - 801 - static int sysc_noirq_resume(struct device *dev) 802 - { 803 - struct sysc *ddata; 804 - int error; 805 - 806 - ddata = dev_get_drvdata(dev); 807 - 808 - if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE) 809 - return 0; 810 - 811 - if (!ddata->needs_resume || !ddata->noirq_suspend) 812 - return 0; 813 - 814 - dev_dbg(ddata->dev, "%s %s\n", __func__, 815 - ddata->name ? ddata->name : ""); 816 - 817 - error = sysc_runtime_resume(dev); 818 - if (error) { 819 - dev_warn(ddata->dev, "%s cannot resume %i %s\n", 820 - __func__, error, 821 - ddata->name ? ddata->name : ""); 822 - 823 - return error; 824 - } 825 - 826 - /* Maybe also reconsider clearing noirq_suspend at some point */ 827 - ddata->needs_resume = false; 828 - 829 - return 0; 830 - } 831 - #endif 832 728 833 729 static const struct dev_pm_ops sysc_pm_ops = { 834 - SET_SYSTEM_SLEEP_PM_OPS(sysc_suspend, sysc_resume) 835 730 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_noirq_suspend, sysc_noirq_resume) 836 731 SET_RUNTIME_PM_OPS(sysc_runtime_suspend, 837 732 sysc_runtime_resume,