Received: by 10.192.165.148 with SMTP id m20csp1597448imm; Wed, 25 Apr 2018 22:31:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Q6pXMjfjtXQH9EmLBsoBHYxsVWYyVxQbpiQfejCKk9/QUnhSds9tJvUmXiF5YlsGcTJHX X-Received: by 10.99.169.1 with SMTP id u1mr26934655pge.251.1524720692531; Wed, 25 Apr 2018 22:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524720692; cv=none; d=google.com; s=arc-20160816; b=dZqQNt/1T/L+blkL+y0Y8iXX+ig4P2EpfVwSI0bi/PjGa70fi/RXNHI8K6qqQPO9g1 eG+je51qmWFtwIb3rGHXl8zu532nkn58JSWRgUVWUuB77hujlPd1TxYWIKETN6caMKNC dUcM2hgMQxMjCUOtWMNblkb1ZWXp1FeIXYbgwCUlBJjj0DZIYlzVVEZ1tR3hjY/PC5SR N2fjwX/gQ7eLd+0FeBkf7ihzAVqogTfv5x5Ru9jhqAxMVNUdPf76GIvm1YKVwsTYx2qf hQbdS2jq/gMppkubgcDehXUwYhDzPvY0j2X76XML3DHkJQCX6yR6LOiuQ7eGpzo34FGq XhBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=/RFzc2BHewU+1v4jCGAKSFWg4XITGjp5tH0g2lHujRc=; b=Dx4cNyOJBbOBCbPSUISEkp8xrLyALZAhrAak9Ffp+TaKglRUvPrihgZ6LlB1pKxLh1 f4Poe9DYzSGq7YQ1SwCskfRF6vUJ8x7SC7L2Aj8LvP8sfSuls67lFYQ9wBuBxzUm2kcv poZUeBNKzE8W/z/4pc0hzDJgYZGFAQheR5piMo732OQN0i3wpWafmAshILXmv3/Gzi+n /VuzJfLd+A2FgIITa6mqhTH1K98rF4KTz8M9oZZh5s02RV84zHMY1HfD/oqMXFGHyGI8 aM7BqBSelJUtMOQsJqE7XVOP6Z29BWH6RoOyxloAdweY8sWL0S63QJfrixeiovlkwLU1 vEHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12si10079388pgp.119.2018.04.25.22.31.17; Wed, 25 Apr 2018 22:31:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751763AbeDZFaG (ORCPT + 99 others); Thu, 26 Apr 2018 01:30:06 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:21588 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751040AbeDZFaE (ORCPT ); Thu, 26 Apr 2018 01:30:04 -0400 X-UUID: 88a60e048f0c411e9805e88380848de2-20180426 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 885672867; Thu, 26 Apr 2018 13:30:00 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Thu, 26 Apr 2018 13:29:58 +0800 Received: from [172.21.77.33] (172.21.77.33) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Thu, 26 Apr 2018 13:29:58 +0800 Message-ID: <1524720598.12322.37.camel@mtkswgap22> Subject: Re: [PATCH v1 2/7] serdev: add dev_pm_domain_attach|detach() From: Sean Wang To: Marcel Holtmann CC: Rob Herring , Mark Rutland , Johan Hedberg , devicetree , Bluez mailing list , linux-arm-kernel , , LKML , Rob Herring , "Ulf Hansson" , Greg Kroah-Hartman , Jiri Slaby , Date: Thu, 26 Apr 2018 13:29:58 +0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-04-03 at 12:29 +0200, Marcel Holtmann wrote: > Hi Sean, > > > In order to open up the required power gate before any operation can be > > effectively performed over the serial bus between CPU and serdev, it's > > clearly essential to add common attach functions for PM domains to serdev > > at the probe phase. > > > > Similarly, the relevant dettach function for the PM domains should be > > properly and reversely added at the remove phase. > > > > Signed-off-by: Sean Wang > > Cc: Rob Herring > > Cc: Ulf Hansson > > Cc: Greg Kroah-Hartman > > Cc: Jiri Slaby > > Cc: linux-serial@vger.kernel.org > > --- > > drivers/tty/serdev/core.c | 14 +++++++++++++- > > 1 file changed, 13 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c > > index df93b72..c93d8ee 100644 > > --- a/drivers/tty/serdev/core.c > > +++ b/drivers/tty/serdev/core.c > > @@ -13,6 +13,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -330,8 +331,16 @@ EXPORT_SYMBOL_GPL(serdev_device_set_tiocm); > > static int serdev_drv_probe(struct device *dev) > > { > > const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver); > > + int ret; > > + > > + ret = dev_pm_domain_attach(dev, true); > > + if (ret != -EPROBE_DEFER) { > > + ret = sdrv->probe(to_serdev_device(dev)); > > + if (ret) > > + dev_pm_domain_detach(dev, true); > > + } > > so if this is deferred, when does the serdev device gets probed? > driver probe deferral mechanism is supported in driver core deferred_probe_initcall makes sure that deferred probing is delayed until late_initcall time. Below is a few of word I got from drivers/base/core.c I thought it helps to understand the mechanism in complete picture * If a required resource is not available yet, a driver can request probing to be deferred by returning -EPROBE_DEFER from its probe hook. * A driver returning -EPROBE_DEFER causes the device to be added to the pending list. A successful driver probe will trigger moving all devices from the pending to the active list so that the workqueue will eventually retry them. > > > > - return sdrv->probe(to_serdev_device(dev)); > > + return ret; > > } > > > > static int serdev_drv_remove(struct device *dev) > > @@ -339,6 +348,9 @@ static int serdev_drv_remove(struct device *dev) > > const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver); > > if (sdrv->remove) > > sdrv->remove(to_serdev_device(dev)); > > + > > + dev_pm_domain_detach(dev, true); > > + > > return 0; > > } > > Regards > > Marcel >