Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp395526pxb; Thu, 19 Nov 2020 04:14:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKgQvLeWXoNBLY/HtlC64QUpT0dhnz4QbNFgTcpWBqPGd/VUsDDs5Sh9/rpONkARMvKaIM X-Received: by 2002:a17:906:bcf9:: with SMTP id op25mr27307215ejb.223.1605788054841; Thu, 19 Nov 2020 04:14:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605788054; cv=none; d=google.com; s=arc-20160816; b=SMHlosq5ISyHnuB8azpBS1oYAy5FGSlmNce4KGCday+UkggtiB0ioC6YheZOpgce8f +v3eiS2HIA4dDeW6EYqYRNASTmJn5rmismcpwT/Kqqfap0DgF2EWU7IcJaEkxJWSC0iC 1F+9czFA+bq3lsvDG9Ik7gxvAXjhR55NMeA4B0dLNwcJjngZlro0xPnCXcupjqZF49dL j6s9KeBpe6xAQ7WWPeW5/DeF4G3/8nWmyp8/XihizkJg70ZfSjoin1zmXQ0HO4mnwAkW TsbOpbP2b9SqguVAWh9PIuZVdOaTaGl1hIT7lMOv9qbITpOHDv+ZDSxdCdjQsT+r1+Kp UeUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=tOC8pFPFR7Gsi/M7h9ymoRYiNwsRE1Z4BQJLMUMH9QU=; b=n74pAfir9vDVm1QfMXp2LKLdLWTW34MmwfWz1TpPSn5n5OXAcSbX2CwMDs2e1zyS6d 8/mXJj0VvM1vYMAMLB5aOkQ06GFvekMsWUYUXzoFBU6inxBqsXCgCREYd+0qbjFkr0DM zrZ3TGEEUBbYABkLD8SbM+Qd5B/u3BVID8Q7Ck2saRIBenXVDVZA/sLszQ2sIhCvujh6 HsWMJmJIYmgy8HmjYcYMj/EKNbxa+sNQ6Pc8EHsDWZ73WeJGO0HGg4NFcaKPoWZ6PnSn 5ICVvEd9jIxdTQ9cHOXAjcVX9XW+vNqaSaBdi9rz8qcsZdJQgLeIZeybA4b/pKafA/Uz kZPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u4si17787486eda.182.2020.11.19.04.13.52; Thu, 19 Nov 2020 04:14:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727197AbgKSMLu (ORCPT + 99 others); Thu, 19 Nov 2020 07:11:50 -0500 Received: from mail-oi1-f195.google.com ([209.85.167.195]:42760 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgKSMLu (ORCPT ); Thu, 19 Nov 2020 07:11:50 -0500 Received: by mail-oi1-f195.google.com with SMTP id v202so2902217oia.9 for ; Thu, 19 Nov 2020 04:11:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tOC8pFPFR7Gsi/M7h9ymoRYiNwsRE1Z4BQJLMUMH9QU=; b=RTAgsW7OuBUtyEudIL9CHX63IOuhbDOiW4nRB/YgCr0DwPgjjgDnDF9AAFRImWHeQR L3re2vkJBL+cLTszipvrzh+yUB3ltUKNpTA5UvIoql62ZH3Kr9KQL2RXw3CyrXmev4Df 3ixLg1XnKZxVAdNU24dnqHtVsyiwI7nBc/+NIERm+gEE3/jui8FGwvphCJaM5b8FvZ4f Hx7S/aFDEGp659L+DR4bR8Gecg528v7VWFiHH41/KTJHjxtP3veBnu9THifd2OBSBijQ 7EluEaBhfmUBaf9hxMZ27BCBZ949y11yEDzah2GqNsPAFPaylUiiaUgno9r0DQJZItYx tRtQ== X-Gm-Message-State: AOAM531nebWJP96qOP9YIhmqfRghHRgRmWIgDxr/2DhygPTvSp4l5ccZ 6TGqI6umHlU5PP17dpUq7CDUB/gNQr0IiK5Q3Ak= X-Received: by 2002:aca:cf4b:: with SMTP id f72mr2660823oig.157.1605787909600; Thu, 19 Nov 2020 04:11:49 -0800 (PST) MIME-Version: 1.0 References: <20201119110036.19959-1-aisheng.dong@nxp.com> In-Reply-To: <20201119110036.19959-1-aisheng.dong@nxp.com> From: "Rafael J. Wysocki" Date: Thu, 19 Nov 2020 13:11:38 +0100 Message-ID: Subject: Re: [PATCH 1/3] driver core: simply go out if the same device_link is added again To: Dong Aisheng Cc: Linux Kernel Mailing List , dl-linux-imx , Dong Aisheng , Greg Kroah-Hartman , "Rafael J. Wysocki" , Saravana Kannan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 19, 2020 at 12:18 PM Dong Aisheng wrote: > > It's possible that the same device link may be added by parsing the > function dependecy in DT. e.g. clock/gpio/regulators. > Simply go out for this case. Why? > Cc: Greg Kroah-Hartman > Cc: "Rafael J. Wysocki" > Cc: Saravana Kannan > Signed-off-by: Dong Aisheng > --- > drivers/base/core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 4c03bdd3a268..7d91d4074136 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -567,6 +567,9 @@ struct device_link *device_link_add(struct device *consumer, > if (link->consumer != consumer) > continue; > > + if (flags == link->flags) > + goto out; But this prevents rpm_count from being incremented if DL_FLAG_RPM_ACTIVE is set in flags, which is necessary, because the supplier's PM-runtime usage counter has been incremented already. Moreover, every attempt to create a stateless link must cause a new reference on the existing link to be acquired, or the removal will not work correctly. > + > if (flags & DL_FLAG_PM_RUNTIME) { > if (!(link->flags & DL_FLAG_PM_RUNTIME)) { > pm_runtime_new_link(consumer); > --