From patchwork Fri May 28 09:11:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 449501 Delivered-To: patches@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp163347jac; Fri, 28 May 2021 02:11:52 -0700 (PDT) X-Received: by 2002:a05:6512:3457:: with SMTP id j23mr4399084lfr.505.1622193111880; Fri, 28 May 2021 02:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622193111; cv=none; d=google.com; s=arc-20160816; b=qG1yjk8xnP2NHbbPIyKg2vWAk2oBgwWqMqjeVRqJIntSR4DUr3LCWZMTF/avOMWZzX HgbOuvn0oxy5/dgSaW3BS9zPXS+L2w5XBVAZHF3s4FFspiO3/psO56vel3F0VIndfydl XSXmCRws42W6m1gxOW/n0fCFH6VPJU/5qQIUvidr9PpEZrTND9SgIWT/1R0xrewLDTiN bJa9xUsEkAJc1nFP9PYQB8aLi2jXPGPE2BZFmmyGSFt1xl3OAcKbWzDSdfaR3ngf9pN0 4zNyj/QEFNl73H/wftqTQFR2oEQ6TJrEMQaoSs1S14hV/7KPHlF+y32Gvcw8oaD5lj7N 30Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=sUYpUgduivuCVF6eHvNxAOyVhrifC73di+ff0lHlcsA=; b=ktgKpUDobCWxkSM3QlO0/UienBw1nXNEoF/WgINw2QgXpMrfvMjr+6N5bh/bfiUi02 g5MiP7meGILlKj6kdRNT2NOIhSHLjhnfOVsxZLyKlg6FikOYlmAB8n85esXeQsylrbZw WQPJCbXArkipV8vJm3m7WthNqD3AF6GsvMIur9Mq7Dck4UhW6tGQ7+IJxHVDYycxwI3F bBHonI3uO7VLnIdYBbNjYelvBgbyA5Be6FtIFehrJvDrGRbiLtp2KiQYAtT6qyuUJ3xX +HeRFp1tjJ47A2GdqUdPDpwH9lGt9/O6fKRAXLgZMJbvp4w9R5neJmRDvvxailHaWsz5 QBtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wyZ4T5i+; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id z4sor1169389lfq.45.2021.05.28.02.11.51 for (Google Transport Security); Fri, 28 May 2021 02:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wyZ4T5i+; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sUYpUgduivuCVF6eHvNxAOyVhrifC73di+ff0lHlcsA=; b=wyZ4T5i+3aVchglrAZqFAVF0C6hOe/zQhiG/Y2DqaSz/q2fNL7xknah6KEG0xpQN3A qg34hQVg80hsXJnqaNIMyx+RpN/y8DQ41nGBEPG/xBJ8/N6MfM+4yG5VAI1iwDWtJ7IN vsdoma7Wxm/rhHsbi4rGtxG7lNuXCSDOXForFR1s6FEyAt+o5MJp4tps0GAuUyCiq25r yr0E0DXczvkGlrHEnEXfWRWJnuw3Mqo7iNaozOpvj5rllSI1mfflbG4RSybvt24L5Dro G3tKsOcQCYEmNN4QEe42/KZJa+zWf5t/d7Qt17qWGFIULkOsu0hVEJC9j5VCRTzildIH nTHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sUYpUgduivuCVF6eHvNxAOyVhrifC73di+ff0lHlcsA=; b=FpgjiRHNyqLFGP2DTK0RoIoqGipLG4oqMK0zHYwOK8BDJrgHNHYgsQDVzZN8Yd2bqg XreXSE08+rlKYo/CrfBbPkdP6RTEdg2g+zBeclFwe0FxYPSNVG6w0Jw6RdC66FfJN4pC +dKFnJ3ywYO3H0Bvi7Vj3gFgKMxDSbKeWO76ZGHOHXnJhje5IbGd13cSm2U/tFB6vqMY En+BttwxAEnrjJQTgtUXkJSDvp7KS/vl0IRnCxjSOmEfP7rOGcXx9t7eHoPbQ28Uqfhh XRtUKeeydtc+8EBMBQfPs/6nYvmS9/OCu4/hRVB66Apic7YLpGbrOGUVpo5cKqViZ51T Sa7A== X-Gm-Message-State: AOAM531tcBEAzU4jSbqKsU8YOthWvgu3zBfCY+FrTRNDxD+mw8SyPO4R JWbd+T84aL2rX8+RMq5lBdGehJ6W X-Google-Smtp-Source: ABdhPJwsVzF+nC4WNJPqBtVliQbqeg943XE0P+2MUBvV2a1tnubgAiDDFZnyk++mWwJZ3eEuHuTE4Q== X-Received: by 2002:ac2:4908:: with SMTP id n8mr5125093lfi.641.1622193111489; Fri, 28 May 2021 02:11:51 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id n15sm421927lfq.274.2021.05.28.02.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 02:11:50 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Saravana Kannan , Alan Stern , Adrian Hunter , Tony Lindgren , Kevin Hilman , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] PM: runtime: Improve path in rpm_idle() when no callback Date: Fri, 28 May 2021 11:11:47 +0200 Message-Id: <20210528091147.11541-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 When pm_runtime_no_callbacks() has been called for a struct device to set the dev->power.no_callbacks flag for it, it enables rpm_idle() to take a slightly quicker path by assuming that a ->runtime_idle() callback would have returned 0 to indicate success. A device that does not have the dev->power.no_callbacks flag set for it, may still be missing a corresponding ->runtime_idle() callback, in which case the slower path in rpm_idle() is taken. Let's improve the behaviour for this case, by aligning code to the quicker path. Signed-off-by: Ulf Hansson --- drivers/base/power/runtime.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.25.1 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index b570848d23e0..68bebbf81347 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -446,7 +446,10 @@ static int rpm_idle(struct device *dev, int rpmflags) /* Pending requests need to be canceled. */ dev->power.request = RPM_REQ_NONE; - if (dev->power.no_callbacks) + callback = RPM_GET_CALLBACK(dev, runtime_idle); + + /* If no callback assume success. */ + if (!callback || dev->power.no_callbacks) goto out; /* Carry out an asynchronous or a synchronous idle notification. */ @@ -462,10 +465,7 @@ static int rpm_idle(struct device *dev, int rpmflags) dev->power.idle_notification = true; - callback = RPM_GET_CALLBACK(dev, runtime_idle); - - if (callback) - retval = __rpm_callback(callback, dev); + retval = __rpm_callback(callback, dev); dev->power.idle_notification = false; wake_up_all(&dev->power.wait_queue); From patchwork Fri May 28 09:12:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 449502 Delivered-To: patches@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp163495jac; Fri, 28 May 2021 02:12:06 -0700 (PDT) X-Received: by 2002:a19:c7c5:: with SMTP id x188mr52356lff.213.1622193126493; Fri, 28 May 2021 02:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622193126; cv=none; d=google.com; s=arc-20160816; b=jcOntYsjoKU/lnh8PGH1PrcnNPNfw8gJsulhZBN0xVJ3dajnAtpMUG95Uj+FDprXcp p1rp8OBCzlmSqxkZ/5KS5xaEPYmf5vNOuK3/FOIsivqBGxGRU8R9HqHM5YD2lm5sfQcg 8WXz3al9iqY2bLuDJ/RyR6J1FH3f1MnLMGcfytzC8UJvV+Sa3l6fQUb489KwigNL/qnT rRLFPtYgHU4XDSXyQ8oz/WvzkljBcfPHLhRgdO7uSxpw25BuYOYONBO+j90pYw9z239r 0GdUE0S+pfQ1S/S22iAZKiOPp1QgM8DndIIqwpLAFSsCs3zXMGuJvQPwiItTUWvX17KC 1+qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=ZB800bOhKFCGK6d7wDa9t/A1lZSI4wYj4YKflJqW4BE=; b=mAPnC291jjU+B5RiI7I0yuFP5QDeRetMTZZkpA8B9SPxMEdgtlpM7YiUhDTBwvBgEw ys5UETDZzjwkPOkBO/TGbB8fckOAevpbHcMxt/EOf+qnx1jzd1Usb/R0yDde9Lfr8UPh 7uKrmVCNKqSkZ6ENlFsRXNsTWUf9Ofu7RaJv2NHxXSjgHR/RcNmERUZ20L+swJMiK6uB 8nMXfey38EDrFv6pRehMS3KnI51MQBQdxL5EAyzHrvNQaJydY7Id32YGUd99aqUs7lte aewy//KHNGoHqhiEV7CgQaqWrEE098GEXJX5IONT80hRfgzChyr7bkT3Vx2iBQhDkyMj rMQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KlhgpHI6; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id u13sor1219851lfo.185.2021.05.28.02.12.06 for (Google Transport Security); Fri, 28 May 2021 02:12:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KlhgpHI6; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZB800bOhKFCGK6d7wDa9t/A1lZSI4wYj4YKflJqW4BE=; b=KlhgpHI6b5tTvVjNUp85mgiuuWggqNBSOcObUyi0mrUDSuH0/J9coPaxoqyBwaw9qK RDGeCgR8eODiassfVCSNeLmOyRUMFeid8Yd2LyGwWto6lydEIzcSGgSgXTe4/2PRJW71 CXBY4DZpHotaNtp7TMg/f57+OpBhzFCZDWicDleIh8Ijdey1ym7VFXViRzwojlW0gUjK sdcY27oD7qneN++kxIT1Atlis8+pgDdeeXS+VfZ7hQdqJO8PfLg1lx8vBtbIm1afRH0E QOQ+2yycLqX3/9bcWZUU5wNBncEx0hCGD9LiKoGKFadmS0jwTc39Ei8JtuQlxzhpWZOS dELQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZB800bOhKFCGK6d7wDa9t/A1lZSI4wYj4YKflJqW4BE=; b=E2CjmWm0I5NhfJRwTjZJ63GkFhL2KBCaZwjS8fCK3g/0W2iGM3JE45EkOMsiffig8y ARmcKdnPfOfoM1nKApka1YsEKH5ZmSYzwk+qSbz/5/kEeYPX6kn9VuCCWv/GrQPJpFxG r6E7WSGI2UKmvwCd1QaaT20//NTL4GbDF59BdA7OmNC3mI8VZQFMF0DCU4TCzZ+wB7Nh l3EHfIpxLrMFudzep1pfAGUh2oBqcQRUQhd4hiki0isjE9lMpmz8m9LXIXQbpR1p76DT Fc1JLmq33WJkAqnf+4oZ6f7HDs2o7SHGdseR5BU8wbN5K1EQI2D6udRHYes7co5sEnlJ 0TuQ== X-Gm-Message-State: AOAM530p1iXfdJGjz/X2EL7M7cSwqspLH0Baalz+CoTYdGu0QoL6Tpss YIUnft7s8VqAI1EBUocVRqolNXgh X-Google-Smtp-Source: ABdhPJw3cbp9c36WWL8oxcRJGQCUpv15fo/C/Ij+mnr+wRpiMSsA1kh7obLCs9cz7vWnAxlGRhBbrQ== X-Received: by 2002:ac2:598e:: with SMTP id w14mr5037682lfn.558.1622193126115; Fri, 28 May 2021 02:12:06 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id m4sm537061ljp.9.2021.05.28.02.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 02:12:05 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Saravana Kannan , Alan Stern , Adrian Hunter , Tony Lindgren , Kevin Hilman , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] PM: runtime: Allow unassigned ->runtime_suspend|resume callbacks Date: Fri, 28 May 2021 11:12:02 +0200 Message-Id: <20210528091202.11603-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 We are currently allowing ->rpm_idle() callbacks to be unassigned without returning an error code from rpm_idle(). This has been useful to avoid boilerplate code in drivers. Let's take this approach a step further, by allowing unassigned ->runtime_suspend|resume() callbacks as well. In this way, a consumer/supplier device link can be used to let a consumer device be power managed through its supplier device, without requiring assigned ->runtime_suspend|resume() callbacks for the consumer device, for example. Signed-off-by: Ulf Hansson --- drivers/base/power/runtime.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.25.1 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 68bebbf81347..8a66eaf731e4 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -345,7 +345,7 @@ static void rpm_suspend_suppliers(struct device *dev) static int __rpm_callback(int (*cb)(struct device *), struct device *dev) __releases(&dev->power.lock) __acquires(&dev->power.lock) { - int retval, idx; + int retval = 0, idx; bool use_links = dev->power.links_count > 0; if (dev->power.irq_safe) { @@ -373,7 +373,8 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev) } } - retval = cb(dev); + if (cb) + retval = cb(dev); if (dev->power.irq_safe) { spin_lock(&dev->power.lock); @@ -484,9 +485,6 @@ static int rpm_callback(int (*cb)(struct device *), struct device *dev) { int retval; - if (!cb) - return -ENOSYS; - if (dev->power.memalloc_noio) { unsigned int noio_flag;