)]}'
{
  "commit": "ba2bbfbf63075850bb523e2adb815d45e3509995",
  "tree": "f47ba2fd0eb5ed9443201aae2a02ebb6863a0144",
  "parents": [
    "cbfe8fa6cd672011c755c3cd85c9ffd4e2d10a6f"
  ],
  "author": {
    "name": "Ulf Hansson",
    "email": "ulf.hansson@linaro.org",
    "time": "Thu Jun 18 15:17:53 2015 +0200"
  },
  "committer": {
    "name": "Rafael J. Wysocki",
    "email": "rafael.j.wysocki@intel.com",
    "time": "Fri Jul 31 23:31:52 2015 +0200"
  },
  "message": "PM / Domains: Remove intermediate states from the power off sequence\n\nGenpd\u0027s -\u003eruntime_suspend() (assigned to pm_genpd_runtime_suspend())\ndoesn\u0027t immediately walk the hierarchy of -\u003eruntime_suspend() callbacks.\nInstead, pm_genpd_runtime_suspend() calls pm_genpd_poweroff() which\npostpones that until *all* the devices in the genpd are runtime suspended.\n\nWhen pm_genpd_poweroff() discovers that the last device in the genpd is\nabout to be runtime suspended, it calls __pm_genpd_save_device() for *all*\nthe devices in the genpd sequentially. Furthermore,\n__pm_genpd_save_device() invokes the -\u003estart() callback, walks the\nhierarchy of the -\u003eruntime_suspend() callbacks and invokes the -\u003estop()\ncallback. This causes a \"thundering herd\" problem.\n\nLet\u0027s address this issue by having pm_genpd_runtime_suspend() immediately\nwalk the hierarchy of the -\u003eruntime_suspend() callbacks, instead of\npostponing that to the power off sequence via pm_genpd_poweroff(). If the\nselected -\u003eruntime_suspend() callback doesn\u0027t return an error code, call\npm_genpd_poweroff() to see if it\u0027s feasible to also power off the PM\ndomain.\n\nAdopting this change enables us to simplify parts of the code in genpd,\nfor example the locking mechanism. Additionally, it gives some positive\nside effects, as described below.\n\ni)\nOne device\u0027s -\u003eruntime_resume() latency is no longer affected by other\ndevices\u0027 latencies in a genpd.\n\nThe complexity genpd has to support the option to abort the power off\nsequence suffers from latency issues. More precisely, a device that is\nrequested to be runtime resumed, may end up waiting for\n__pm_genpd_save_device() to complete its operations for *another* device.\nThat\u0027s because pm_genpd_poweroff() can\u0027t confirm an abort request while it\nwaits for __pm_genpd_save_device() to return.\n\nAs this patch removes the intermediate states in pm_genpd_poweroff() while\npowering off the PM domain, we no longer need the ability to abort that\nsequence.\n\nii)\nMake pm_runtime[_status]_suspended() reliable when used with genpd.\n\nUntil the last device in a genpd becomes idle, pm_genpd_runtime_suspend()\nwill return 0 without actually walking the hierarchy of the\n-\u003eruntime_suspend() callbacks. However, by returning 0 the runtime PM core\nconsiders the device as runtime_suspended, so\npm_runtime[_status]_suspended() will return true, even though the device\nisn\u0027t (yet) runtime suspended.\n\nAfter this patch, since pm_genpd_runtime_suspend() immediately walks the\nhierarchy of the -\u003eruntime_suspend() callbacks,\npm_runtime[_status]_suspended() will accurately reflect the status of the\ndevice.\n\niii)\nEnable fine-grained PM through runtime PM callbacks in drivers/subsystems.\n\nThere are currently cases were drivers/subsystems implements runtime PM\ncallbacks to deploy fine-grained PM (e.g. gate clocks, move pinctrl to\npower-save state, etc.). While using the genpd, pm_genpd_runtime_suspend()\npostpones invoking these callbacks until *all* the devices in the genpd\nare runtime suspended. In essence, one runtime resumed device prevents\nfine-grained PM for other devices within the same genpd.\n\nAfter this patch, since pm_genpd_runtime_suspend() immediately walks the\nhierarchy of the -\u003eruntime_suspend() callbacks, fine-grained PM is enabled\nthroughout all the levels of runtime PM callbacks.\n\niiii)\nEnable fine-grained PM for IRQ safe devices\n\nPer the definition for an IRQ safe device, its runtime PM callbacks must\nbe able to execute in atomic context. In the path while genpd walks the\nhierarchy of the -\u003eruntime_suspend() callbacks for the device, it uses a\nmutex. Therefore, genpd prevents that path to be executed for IRQ safe\ndevices.\n\nAs this patch changes pm_genpd_runtime_suspend() to immediately walk the\nhierarchy of the -\u003eruntime_suspend() callbacks and without needing to use\na mutex, fine-grained PM is enabled throughout all the levels of runtime\nPM callbacks for IRQ safe devices.\n\nUnfortunately this patch also comes with a drawback, as described in the\nsummary below.\n\nDriver\u0027s/subsystem\u0027s runtime PM callbacks may be invoked even when the\ngenpd hasn\u0027t actually powered off the PM domain, potentially introducing\nunnecessary latency.\n\nHowever, in most cases, saving/restoring register contexts for devices are\ntypically fast operations or can be optimized in device specific ways\n(e.g. shadow copies of register contents in memory, device-specific checks\nto see if context has been lost before restoring context, etc.).\n\nStill, in some cases the driver/subsystem may suffer from latency if\nruntime PM is used in a very fine-grained manner (e.g. for each IO request\nor xfer). To prevent that extra overhead, the driver/subsystem may deploy\nthe runtime PM autosuspend feature.\n\nSigned-off-by: Ulf Hansson \u003culf.hansson@linaro.org\u003e\nReviewed-by: Kevin Hilman \u003ckhilman@linaro.org\u003e\nTested-by: Geert Uytterhoeven \u003cgeert+renesas@glider.be\u003e\nTested-by: Lina Iyer \u003clina.iyer@linaro.org\u003e\nSigned-off-by: Rafael J. Wysocki \u003crafael.j.wysocki@intel.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "0ee43c1056e045bd6a402908e8a11cf9dac8f34e",
      "old_mode": 33188,
      "old_path": "drivers/base/power/domain.c",
      "new_id": "a1abe16dfe163d9e377ff80072a75b4783410163",
      "new_mode": 33188,
      "new_path": "drivers/base/power/domain.c"
    },
    {
      "type": "modify",
      "old_id": "681ccb053f72474ae4424bf9e083194f5384cec5",
      "old_mode": 33188,
      "old_path": "include/linux/pm_domain.h",
      "new_id": "b2725e6e8e7b94bc3dd4814d5c639cc95c9514cd",
      "new_mode": 33188,
      "new_path": "include/linux/pm_domain.h"
    }
  ]
}
