From patchwork Wed Oct 16 13:16:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 176473 Delivered-To: patches@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp7156737ocf; Wed, 16 Oct 2019 06:16:16 -0700 (PDT) X-Received: by 2002:a2e:8694:: with SMTP id l20mr25534251lji.64.1571231776374; Wed, 16 Oct 2019 06:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571231776; cv=none; d=google.com; s=arc-20160816; b=G6ENzdTW3/DSEAXkY/pMBNdF5lRlwj9DkzlNPHAdCgHGi3vOwVO1W7tytzRwfXlgix Fkb9rv3iAnp4o8cHo7rQOkvgT4XLHDdOiiuq9B8biczDi6fHohVUzyA3HkLfiY6Uir9n 0kklC1SEbZt+M6HUwFrLhVi83w+IT5TQrnSCqo40064K097e87c5MEdo3SvbNQ9qUesu sS0mwzDLg8xkTNJUiG2MsLmaHb44qyERtKDPHvQWaKlaV7DgYBnBCCe25HG89p14OF3t Q7QfZ4oiNz3MtD3KrFXvG2HlPfkVwuBPFTCQUb3iOy1iCaq3SU460XO6emEuuRtZdoca 5UMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t/IdaCvXraOwlJZTUOq6plCE0lZnjdA61GIv6muLp1Q=; b=IK/Tpbt4NkJXv6MZKNaHlwzyKzJc04YEVP9IM5fG/IKsz+gAC0U9SJ1GZIQgNdXE8e sJZgxroAkGDG8fUQ62oQMqQu7XS77VMq0vWXsUnNrCeXCLB2Lyr3asMiBhPBXjPNq5ZP SKwBhwkiC294JgierEkkPeV0mynFL0Vh6E9V0hAXkHtpNK74Niwp0zgzeznXNftVTKWe SIKmj+aHDgHBkITpEMl8118iVa9EjVZDnC1xT8NbhBxdmCBGirRoHvMkJ2B9m9gRQBRh 81kzYxc//OkQPZKRKuVB82ZPrTF2dnV4PrynJ9y1ST3kAmOsyNUUFcOYNvt4bauM6tUX c3OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VLCC0f2j; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r13sor12723282ljk.2.2019.10.16.06.16.16 for (Google Transport Security); Wed, 16 Oct 2019 06:16:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VLCC0f2j; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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:in-reply-to:references; bh=t/IdaCvXraOwlJZTUOq6plCE0lZnjdA61GIv6muLp1Q=; b=VLCC0f2jo6csOzQNOAyaHJmjTKt6NC1Cuj782X7mRCJ5HwMnGpia1SOy5aQFzRAmbX 6VF45SZ1bMcN702DI3Pl3OZGkvnTejl52/kfLwkqYZC3OG9JsKUZLKNVUNBW6ocQPW/f uOIefwzS9K9mHHbOaTeh2nJpSV5ubaXqVR2k6PAj62Z0LvMFfgY/qIbn/wkGCONUaaIN VF5dAZhTaJrtlI5xS4Q72xykG393Yf0Eij/3qaNS7Tx7T7VrY29b1eBlsjrTG/W84tYK KA33BxztW85EgaQXb/1lp41lV2jhE/4Ma0aLpYjinRvS1hassm/TlYLqCX7hjxF0J564 Wc8Q== 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:in-reply-to :references; bh=t/IdaCvXraOwlJZTUOq6plCE0lZnjdA61GIv6muLp1Q=; b=kmZfbvbEEMZ2uMtDBB/87zG1lGkJa90lzSDUmF1K22tTWXPf9JfUTBz/9YkbdEfVEr l8OxqWuTF7e5NqMZayPDUjAHqJK7a12eO2y1MkCe47QvK0oJhAhTV9/gsQFNpQII+AQ0 neCmLD/K4ckwecIBl+gmrDu1F1Mny9P3EG5IwlX5tEfkfZB8lSsBETTV5dMMYFWTFVz0 h29Cx7XVTuBYi/8VJ2LED5+l2XO6a8DcjHefSOddxAzuKZeako1Dw3j+Bs1xX8FrEWjJ 8UVeRn191bpSqPtyldAGWReRMcbJK8DHi5ny5id2rzI9kkbt3jAQELbIMhNsiUtsqmj4 HCGg== X-Gm-Message-State: APjAAAXt0lws2EghG68Ri3cVoSxrSMH+ZWpHDQPlWaH23Q9w9eB5OwmX 0DovLIcJyWaopkVQFMWLN+2fqre9 X-Google-Smtp-Source: APXvYqxHpO8/K1SzA/rbXfA8GoR1yQqr6YxgbM2Sg4Pj74RmTLT7iIM9oDjo8SJ4Tqufb8+dDZ73ng== X-Received: by 2002:a2e:a211:: with SMTP id h17mr25768660ljm.251.1571231775888; Wed, 16 Oct 2019 06:16:15 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id c26sm7022530ljj.45.2019.10.16.06.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 06:16:15 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Wolfram Sang , Niklas Soderlund , Ulf Hansson , Kevin Hilman Subject: [PATCH 1/3] PM / Domains: Introduce dev_pm_domain_start() Date: Wed, 16 Oct 2019 15:16:03 +0200 Message-Id: <20191016131603.15784-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <../../misc/pm_patches/submitted_patches/pm_domain_start/0002-PM-Domains-Implement-the-start-callback-for-genpd.patch> References: <../../misc/pm_patches/submitted_patches/pm_domain_start/0002-PM-Domains-Implement-the-start-callback-for-genpd.patch> For a subsystem/driver that either doesn't support runtime PM or makes use of pm_runtime_set_active() during ->probe(), may try to access its device when probing, even if it may not be fully powered on from the PM domain's point of view. This may be the case when the used PM domain is a genpd provider, that implements genpd's ->start|stop() device callbacks. There are cases where the subsystem/driver managed to avoid the above problem, simply by calling pm_runtime_enable() and pm_runtime_get_sync() during ->probe(). However, this approach comes with a drawback, especially if the subsystem/driver implements a ->runtime_resume() callback. More precisely, the subsystem/driver then needs to use a device flag, which is checked in its ->runtime_resume() callback, as to avoid powering on its resources the first time the callback is invoked. This is needed because the subsystem/driver has already powered on the resources for the device, during ->probe() and before it called pm_runtime_get_sync(). In a way to avoid this boilerplate code and the inefficient check for "if (first_time_suspend)" in the ->runtime_resume() callback for these subsystems/drivers, let's introduce and export a dev_pm_domain_start() function, that may be called during ->probe() instead. Moreover, let the dev_pm_domain_start() invoke an optional ->start() callback, added to the struct dev_pm_domain, as to allow a PM domain specific implementation. Signed-off-by: Ulf Hansson --- drivers/base/power/common.c | 20 ++++++++++++++++++++ include/linux/pm.h | 2 ++ include/linux/pm_domain.h | 5 +++++ 3 files changed, 27 insertions(+) -- 2.17.1 diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index 8db98a1f83dc..bbddb267c2e6 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -187,6 +187,26 @@ void dev_pm_domain_detach(struct device *dev, bool power_off) } EXPORT_SYMBOL_GPL(dev_pm_domain_detach); +/** + * dev_pm_domain_start - Start the device through its PM domain. + * @dev: Device to start. + * + * This function should typically be called during probe by a subsystem/driver, + * when it needs to start its device from the PM domain's perspective. Note + * that, it's assumed that the PM domain is already powered on when this + * function is called. + * + * Returns 0 on success and negative error values on failures. + */ +int dev_pm_domain_start(struct device *dev) +{ + if (dev->pm_domain && dev->pm_domain->start) + return dev->pm_domain->start(dev); + + return 0; +} +EXPORT_SYMBOL_GPL(dev_pm_domain_start); + /** * dev_pm_domain_set - Set PM domain of a device. * @dev: Device whose PM domain is to be set. diff --git a/include/linux/pm.h b/include/linux/pm.h index 4c441be03079..e057d1fa2469 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -637,6 +637,7 @@ extern void dev_pm_put_subsys_data(struct device *dev); * struct dev_pm_domain - power management domain representation. * * @ops: Power management operations associated with this domain. + * @start: Called when a user needs to start the device via the domain. * @detach: Called when removing a device from the domain. * @activate: Called before executing probe routines for bus types and drivers. * @sync: Called after successful driver probe. @@ -648,6 +649,7 @@ extern void dev_pm_put_subsys_data(struct device *dev); */ struct dev_pm_domain { struct dev_pm_ops ops; + int (*start)(struct device *dev); void (*detach)(struct device *dev, bool power_off); int (*activate)(struct device *dev); void (*sync)(struct device *dev); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index baf02ff91a31..5a31c711b896 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -366,6 +366,7 @@ struct device *dev_pm_domain_attach_by_id(struct device *dev, struct device *dev_pm_domain_attach_by_name(struct device *dev, const char *name); void dev_pm_domain_detach(struct device *dev, bool power_off); +int dev_pm_domain_start(struct device *dev); void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); #else static inline int dev_pm_domain_attach(struct device *dev, bool power_on) @@ -383,6 +384,10 @@ static inline struct device *dev_pm_domain_attach_by_name(struct device *dev, return NULL; } static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {} +static inline int dev_pm_domain_start(struct device *dev) +{ + return 0; +} static inline void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd) {} #endif From patchwork Wed Oct 16 13:16:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 176474 Delivered-To: patches@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp7157009ocf; Wed, 16 Oct 2019 06:16:28 -0700 (PDT) X-Received: by 2002:a2e:3919:: with SMTP id g25mr25431549lja.162.1571231788260; Wed, 16 Oct 2019 06:16:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571231788; cv=none; d=google.com; s=arc-20160816; b=JVyAwSMQkWZHVzvTEjtwN1SZIQ8Y9x0OWMo9c665OTbIJ2MxqIxmzGCEioY2gI01Ju 23r7R8izk/OyejVweZOeNoG15h1N5gF5j7CEoiYY71x0tuGzJ8R7Xnq8SG8+N+24QqpH CNNzGePoU5pC5h/zLdm/Ym57wnX5te2WM0phGcyC9vDi+KYMxNpD9xFxc20cmF2wPCbP ycda0xnO9+PsHfXVL3AsyzIb5E8CN9zIpuIW7CspwKTnd6KqS/KoXouWQJQhY/uxLEan 9nYx6IVN6TyGWKNAziAdP4cZm0WbeW3sYiRMV7kStF8vQFJufBfT/lFnmZ69cRiyZNyG tmXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=zwcPtwWQF6liVN+zYzdJWAttHhAVvs66PzaVZNVn+cw=; b=Wq7ydh9PyW/tA5YownGGgUbdpyPFqW1tD7/oFpPCyP9qqoog6Cv7yGFzc/ApyYaNMk HW6Nmr/x8k9Shes56X+ies2gIv7XQGGWY2Gv159LpipNzQuYsjKnaitzJXdRNK4AQXht FDhk+WM6f9Ru/tH/AEHkI+g6IUDe/uR4nJqy4SwxjxmM/ZFT57O06x/odY2SrCoYt0ED ie/hbsAGZlKiAcNCRXhL7JYkFfnPYeROPCzp8esyVnv0+dN9pD8FidUYNVX99Ejz96Gc pN0wwMECxn/VpFrqOI9XvZ+eF+gsU66zTac2RLNdc6y6mNzVcxcY1ouRFBUFhVrCCDpE c65g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dvr+4U2i; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d20sor13996213ljo.18.2019.10.16.06.16.28 for (Google Transport Security); Wed, 16 Oct 2019 06:16:28 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dvr+4U2i; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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; bh=zwcPtwWQF6liVN+zYzdJWAttHhAVvs66PzaVZNVn+cw=; b=Dvr+4U2iGye8PwQvS9auZPByIhigKBPwgqTMaVL25rrzhMnxujo74IWXzkz9PvOnrT kvZST1KOBOXRVVvfcdQfLqr4zgVA0OGd397GOX6LE93ttKv7Y8TCpf70xk7yCpMUaLOB tyUFO6tUmWi9i1drghLKs2arwRbpV6HjcZdKmiq1v0zn2h/sB9RLnC5B/SH8Vr0SYG9V p2ziDUB0e3n+wReOMDubHRKJlLSMPz6HZWVaP1Y6UEDLbTKpj45/OkT7GTby3zlilY2j I2lGoV5HOVaH+EioMIxr5e5saj2W1f1kPMl566SBDeUCbu44Cel69n1pIdUOJVBOfY/x Sl/g== 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; bh=zwcPtwWQF6liVN+zYzdJWAttHhAVvs66PzaVZNVn+cw=; b=txh4x5F+RoGebpHvL5QXKahxCFpNsDNssWv3gF8rnJulRWAn8ZPkFf6fnFc0Nn3VWO 41v0+b+JQ8daIyw4LlzoTln9fK6hTdmNodvzXOcqLftv7zwkMAAPSFSzX4rNV5lMulwP 0UgtkiqjV3wq6E2gdEoPNyFWPxBtYch1OGbduS2ExsvVvh3n0GzZXabMgdy5KJ3oP0br pjaiMViAFwyeoIyVdIO8Q6p0Qxafv8cSsMfl/vmDOeA0b+bMr0keN82n0LXphpbm20Fx JKK+2RY2/TY1Q4h2kzON4mQntFcgOXBYmv3xHKZCtl36+S7fGkLD1erHFPF02ftk75Pa ZfEQ== X-Gm-Message-State: APjAAAXg4zwvusHqAN3EIR3r3BqgNB20JX5TTz49uQWOH0L0aP+xnG+T ChIp+tZ4NpdHB+l9piKY9ZE/VOn+ X-Google-Smtp-Source: APXvYqyoH9MQbW8BVPPDIOi4iBgbLqiYtqm6XR1J9gGq8SXdHH51QB1ilbfdS+SKrh56ecUB0gzTKw== X-Received: by 2002:a2e:9ec2:: with SMTP id h2mr22570726ljk.85.1571231787847; Wed, 16 Oct 2019 06:16:27 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id q19sm10215746lfj.9.2019.10.16.06.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 06:16:27 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Wolfram Sang , Niklas Soderlund , Ulf Hansson , Kevin Hilman Subject: [PATCH 2/3] PM / Domains: Implement the ->start() callback for genpd Date: Wed, 16 Oct 2019 15:16:24 +0200 Message-Id: <20191016131624.15832-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 To allow a subsystem/driver to explicitly start its device from genpd's point view, let's implement the ->start() callback in the struct dev_pm_domain that corresponds to the genpd. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index cc85e87eaf05..2adf0661fa3e 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -634,6 +634,13 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth) return ret; } +static int genpd_dev_pm_start(struct device *dev) +{ + struct generic_pm_domain *genpd = dev_to_genpd(dev); + + return genpd_start_dev(genpd, dev); +} + static int genpd_dev_pm_qos_notifier(struct notifier_block *nb, unsigned long val, void *ptr) { @@ -1805,6 +1812,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd, genpd->domain.ops.poweroff_noirq = genpd_poweroff_noirq; genpd->domain.ops.restore_noirq = genpd_restore_noirq; genpd->domain.ops.complete = genpd_complete; + genpd->domain.start = genpd_dev_pm_start; if (genpd->flags & GENPD_FLAG_PM_CLK) { genpd->dev_ops.stop = pm_clk_suspend; From patchwork Wed Oct 16 13:16:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 176475 Delivered-To: patches@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp7157215ocf; Wed, 16 Oct 2019 06:16:38 -0700 (PDT) X-Received: by 2002:a2e:8197:: with SMTP id e23mr26153139ljg.218.1571231798680; Wed, 16 Oct 2019 06:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571231798; cv=none; d=google.com; s=arc-20160816; b=xZmDHK7VNyyxP80Os/74feI8Lmn2R0z+T6jC9kGsrwa4Dp3dMkVXwognbql0gYmR4r 5t+e5JEn2ZbDNLsB9HBAj1U7hIxr9jI4pLKZ0L7ceXNcJA+5x1/+5lyfUDCwzTrUtdL5 lONi2xY+ZbRbPAb20qfPh2mZ1VDjO8CFzwo/SrfJl8eJuBtPZU5Ppf3w5tC6z6qI0BIG qSvYHjQh9rwQljRRMnBZgIqYHlk4FA5upXUvyUdnhLMqaHLBHLrrYbalRbOyjHn0iPgD 4w8BIwnK7WJVeoA+2Y2jwFZjKRCtDIpu5uk6tMMPUVa3oOSnVspDlkhCU75IDBMzrYeC xEQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=8we2EpM0rjQuTwVatnTr1F948OBhtLCctpwujUnCJVM=; b=CQuhO3V7O5DQ5IzfrG3wK9Cm4qU8ofcMDnVMsKX5Vw28JCll9XnS/n1DoEsrY+x8ic bs6kV1YJyk39Thloe1299nZtdineBSLe4rZXlUtAcAbntDXVMNw2Do4rFEFfNq/U5SgN SUjY9zAGfCQ6I91fUamksPNJz5Sb4B1f2I3GpeFuFwMQFM9Hyr1r44CIt3bWEENSk5ob JXGoD3ZfiaK8AOZhOxbBhnEBwe6YlIeZ4uN/4mhdGPya/CHtLeezg+vyo8dOA3ePR7Ur jyELMy9O6cL3skrDhCcK3xl7/q0z8HKFEtAn+jfuZQ9yS0vYdrLa8AWVZ02lVz2wzpqr tJeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pJBfryhn; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a15sor6974656lff.72.2019.10.16.06.16.38 for (Google Transport Security); Wed, 16 Oct 2019 06:16:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pJBfryhn; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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; bh=8we2EpM0rjQuTwVatnTr1F948OBhtLCctpwujUnCJVM=; b=pJBfryhnKfTGvUXCpWb3vmCki72rWDgutvYQXZnfk3eOjMW2CFbW03pxcnkfug+2CP ORQNEmsxeCfx2aE4oKtvpa7NHMDioVAc3RyB+q4ugBabIibwgUkPEo6bx+4P8UcdAKRC Apam9W8X0hB5jNv3Apdm0WsQn54+Q/xCagrQHevdV/DsAP+W6exfTsXMT9BvynwnuYzL 3fVDQiO+xKRC5yMgsghf467iEBOqKYRwexehdQ0fdqyszBgB5UrScMguSUVSPVX3zTdn UnVVRtyORs1Ic8T2Jqh4HK9fR4EWatygNZgrpv849qJ8dOTJSDSIQ8pFSJPp0tV9y5bc sPpw== 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; bh=8we2EpM0rjQuTwVatnTr1F948OBhtLCctpwujUnCJVM=; b=goafTbJ1RZbBJDTI4J26LMnVVo4cGRUfJWCtGc6I245/gTvlpJZqvOiRSIPR87bh8r IZmy/c09mFmKRete9v971RR20fYIpUW/fD4Wfq/dDFPl5UyLlDZqJDC98apHOyRCQe3Q SSsqywCIV0VYWLJkciWo3nY1ImjVYL3jzYQzJzhL0yneDZ/lSkrxKmILz7eYcIvSnnpU HmH+tHmFE4TRPJbzYKgedprZfCa8LQP8azCbzSFFveTffYkQ8ir578kSVRz4s4H0sStp BwApb8ggVJoUtJHsQQhCnjgaByjxHgB8sbYkiTePl1jKhzJmAb8rVuv6geRetmGDY3+5 IamA== X-Gm-Message-State: APjAAAUjF66Af7zlG5si62bUW9v5LM3cLXVuFb0zmCRmh/jqKdbbrouU uY1psXC5RSkpwaqktDOfJOW5ozu5 X-Google-Smtp-Source: APXvYqz+eigY33Bwc9nKZAvdwkxNqFh2HT/skQhZ4tcXvDcDSziBF8sO2BGnhugFqk0IY2gfwd8qkQ== X-Received: by 2002:a19:4f0e:: with SMTP id d14mr24211346lfb.177.1571231798276; Wed, 16 Oct 2019 06:16:38 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id i6sm6044417lfo.83.2019.10.16.06.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 06:16:37 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Wolfram Sang , Niklas Soderlund , Ulf Hansson , Kevin Hilman Subject: [PATCH 3/3] mmc: tmio: Avoid boilerplate code in ->runtime_suspend() Date: Wed, 16 Oct 2019 15:16:34 +0200 Message-Id: <20191016131634.15881-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 Rather than checking the 'runtime_synced' flag each time the ->runtime_suspend() callback is invoked, let's convert into using dev_pm_domain_start() during ->probe() and drop the corresponding boilerplate code. Signed-off-by: Ulf Hansson --- drivers/mmc/host/tmio_mmc.h | 1 - drivers/mmc/host/tmio_mmc_core.c | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 2f0b092d6dcc..c5ba13fae399 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -163,7 +163,6 @@ struct tmio_mmc_host { unsigned long last_req_ts; struct mutex ios_lock; /* protect set_ios() context */ bool native_hotplug; - bool runtime_synced; bool sdio_irq_enabled; /* Mandatory callback */ diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 9b6e1001e77c..86b591100f16 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -1248,10 +1249,12 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) /* See if we also get DMA */ tmio_mmc_request_dma(_host, pdata); + dev_pm_domain_start(&pdev->dev); + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 50); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); - pm_runtime_get_sync(&pdev->dev); ret = mmc_add_host(mmc); if (ret) @@ -1333,11 +1336,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev) { struct tmio_mmc_host *host = dev_get_drvdata(dev); - if (!host->runtime_synced) { - host->runtime_synced = true; - return 0; - } - tmio_mmc_clk_enable(host); tmio_mmc_hw_reset(host->mmc);