Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4600394ybv; Mon, 10 Feb 2020 23:25:21 -0800 (PST) X-Google-Smtp-Source: APXvYqzGzgILa4f5Iyzg2cMeO3N6+YF6HTaA28a4sU+BMGBoS6mk0qHKA+XT1YXGt0WUmncHBcDE X-Received: by 2002:aca:fd16:: with SMTP id b22mr2039181oii.73.1581405921164; Mon, 10 Feb 2020 23:25:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581405921; cv=none; d=google.com; s=arc-20160816; b=KqVIa3oV3EPiMHavqZXhkzfHpkvuwUnjqQp2Pg121Slv93oVi2PHvcO3vQ8M6za9+L b5ewBMT/4GyD/d0AEFyhpSrHfC5eHmdqUZ+MXk5WOaRR5WPt1zjwApyVZ9WAMjzz4XVF luYk4LuSA9yktXt8MlfWrdq/Jhjly7sNEfkQR1jQ8qRYrMVMNej9QUeU3T7eWjoXc0Mz 9HfGd5s90qVXSqNQtQd7Vl1QNmbk/FoFQOOBty9r6DYoO8DwezFQJ4jaEDuK0hLN1i2p rQlvMU4kPHNrf3bSPo7i8wRXa83Waa/Yo1wW/ZCyaYuWX+lkNX0uLmoG1+sc0eb4AFS3 JaCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/MEQw0BcuYdl7OtM/Po64qcj8s7w0xeBRRKP2Qjooeg=; b=Kd9hbW6SHFXphusJAaEDY17pziZdmGe4sjoLlgdgfxKk5qRrM9svYCcXwGsDiwo+DV NjjfmBCsC8rjCeR5POZZxFbxjBPqi6B+d7ul3yrmpZFYHItwnyNcReDKIl99OIE5zVqS 3DIBORIsjZb6vSoO1miAgLmu6BdtSs6j6YLEQyVx2Cy+BIGKEFWL5e/Cw9bkakSTg3Yv hYlJN4FLXWkrKV7Wu9Sc0VztfR99/o9SsF4GNgiJtyWaiVfXdy3fE0kPGeGpGoFz25Ro lzwZjPwR0l4KkWzXG3m4Dgny6fWpgmoGPAump5Ve3Ylhm8UPNiPvG3m8BS7QlYN3a7Dk JRhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ra5Yme6f; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si1406384oih.206.2020.02.10.23.24.36; Mon, 10 Feb 2020 23:25:21 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=Ra5Yme6f; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728178AbgBKGRm (ORCPT + 99 others); Tue, 11 Feb 2020 01:17:42 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:39258 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727762AbgBKGRl (ORCPT ); Tue, 11 Feb 2020 01:17:41 -0500 Received: by mail-ot1-f66.google.com with SMTP id 77so8975583oty.6 for ; Mon, 10 Feb 2020 22:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/MEQw0BcuYdl7OtM/Po64qcj8s7w0xeBRRKP2Qjooeg=; b=Ra5Yme6f+eJhQ+sE18QIS6TeOm5m5itvWkjIzpibvGQNTEEhAKV1Th6DIsD3pxOFav Mw5QQIwS7LuzVztrrYN7KOC0LXlLEkoAZYqPrrqI8EJnnRlwr0cf1Q0ZBhZvaAJmLI8p ioMj/xaGKLO5UiBOFH8cOfhklbNmAvcJFUT+Q2RZU6RJ0ZVRuiP0Ie47p3jAbGDIvRI1 9yyLqfzSRang/16dsH321tTXBZgRcQQYvJHBcbB6w73BDLZmxdynCJZSg7XxkFGyfMHK V6p/in3KTrdjh7o6mKOOf5Qr3gLnEZ76jiCf+S2SGNGt4QrmLVklK3w4yFNqIBlS9cgm U7nQ== 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=/MEQw0BcuYdl7OtM/Po64qcj8s7w0xeBRRKP2Qjooeg=; b=ntcSZgb5Neob5nNYrLtO3OqrrTy4czzDCKsWlvLN64zFm9x/er9McfDxCy7VkvIYSD FGkYYu3R+L3AoGh6rZw/nybXxFTCiQa1yRxFyXSq6PuIWAsjZEosCcfsPdZUo+OPhF/l lucrwXo4dENEHGuHGCrW6zA62rsjRvo7kB2sfiDyyY0M0s5PZnDAuNhDJW/vApFXmmXe McAmLhSU4q+xytgK3CWNEHWRXOcIuzX6YoaS039OgSGDEWLLxmcdJD3rg6jqJrZQqBNI v4H/YStXdObSrFL60Iy17h8sagOg3wrsfOe+1xLucu/s4spR+Nw/hAQUYV0Dtf0/6DYV uthw== X-Gm-Message-State: APjAAAVJ6Jt8DOyVZjMPL1HiBAD8DxkDeBjXll7h+jkchwmrUZNh8oP8 kmSgs/MA82aA6WRmzxlcnHJC7qGRussY8hergIh+iw== X-Received: by 2002:a9d:6a85:: with SMTP id l5mr4218800otq.231.1581401860586; Mon, 10 Feb 2020 22:17:40 -0800 (PST) MIME-Version: 1.0 References: <20191104143713.11137-1-alexandre.torgue@st.com> <20200206133918.15012-1-youling257@gmail.com> <0c4a37a9-0a2e-e698-f423-53060854ea05@ti.com> <8bd72269-16ae-b24a-7144-44d22d668dc6@ti.com> <1cd5885d-7db4-59b9-ef2d-e3556f60ca68@st.com> In-Reply-To: From: Saravana Kannan Date: Mon, 10 Feb 2020 22:17:04 -0800 Message-ID: Subject: Re: [PATCH] phy: core: Add consumer device link support To: Kishon Vijay Abraham I Cc: Alexandre Torgue , youling 257 , yoshihiro.shimoda.uh@renesas.com, Greg Kroah-Hartman , LKML , linux-usb@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 10, 2020 at 4:14 AM Kishon Vijay Abraham I wrote: > > Hi, > > On 10/02/20 5:00 PM, Alexandre Torgue wrote: > > Hi Kishon, > > > > On 2/10/20 9:08 AM, Kishon Vijay Abraham I wrote: > >> Hi Alexandre, > >> > >> On 07/02/20 12:27 PM, youling 257 wrote: > >>> test this diff, dwc3 work for my device, thanks. > >>> > >>> 2020-02-07 13:16 GMT+08:00, Kishon Vijay Abraham I : > >>>> Hi, > >>>> > >>>> On 06/02/20 7:09 PM, youling257 wrote: > >>>>> This patch cause "dwc3 dwc3.3.auto: failed to create device link to > >>>>> dwc3.3.auto.ulpi" problem. > >>>>> https://bugzilla.kernel.org/show_bug.cgi?id=206435 > >>>> > >>>> I'm suspecting there is some sort of reverse dependency with dwc3 ULPI. > >>>> Can you try the following diff? > >>>> > >>>> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c > >>>> index 2eb28cc2d2dc..397311dcb116 100644 > >>>> --- a/drivers/phy/phy-core.c > >>>> +++ b/drivers/phy/phy-core.c > >>>> @@ -687,7 +687,7 @@ struct phy *phy_get(struct device *dev, const char > >>>> *string) > >>>> > >>>> get_device(&phy->dev); > >>>> > >>>> - link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS); > >>>> + link = device_link_add(dev, &phy->dev, > >>>> DL_FLAG_SYNC_STATE_ONLY); > >>>> if (!link) { > >>>> dev_err(dev, "failed to create device link to %s\n", > >>>> dev_name(phy->dev.parent)); > >>>> @@ -802,7 +802,7 @@ struct phy *devm_of_phy_get(struct device *dev, > >>>> struct device_node *np, > >>>> return phy; > >>>> } > >>>> > >>>> - link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS); > >>>> + link = device_link_add(dev, &phy->dev, > >>>> DL_FLAG_SYNC_STATE_ONLY); Definitely don't use SYNC_STATE_ONLY. To give some context, drivers themselves are only expected to use STATELESS links. Only the driver core is supposed to use MANAGED (if you don't use STATELESS, it's MANAGED by default) links. And SYNC_STATE_ONLY makes sense only for MANAGED links. Also, as the SYNC_STATE_ONLY documentation says, it only affect sync_state() behavior and doesn't affect suspend/resume in any way. > >>>> if (!link) { > >>>> dev_err(dev, "failed to create device link to %s\n", > >>>> dev_name(phy->dev.parent)); > >>>> @@ -851,7 +851,7 @@ struct phy *devm_of_phy_get_by_index(struct device > >>>> *dev, struct device_node *np, > >>>> *ptr = phy; > >>>> devres_add(dev, ptr); > >>>> > >>>> - link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS); > >>>> + link = device_link_add(dev, &phy->dev, > >>>> DL_FLAG_SYNC_STATE_ONLY); > >>>> if (!link) { > >>>> dev_err(dev, "failed to create device link to %s\n", > >>>> dev_name(phy->dev.parent));Parent > >> > >> Can you check if this doesn't affect the suspend/resume ordering? > > > > With this fix, suspend/resume ordering is broken on my side. What do you > > think to keep the STATELESS flag and to only display a warn if > > "device_link_add" returns an error ? It's not "smart" but it could > > solved our issue. > > yeah, that sounds reasonable for now. Can you find out the dependencies > between dwc3 and ulpi and what exactly breaks. That would help Saravana > to suggest a fix? Yup, I don't have enough context of the dependencies here to suggest a good fix. But if device_link_add() is failing with STATELESS and not failing with SYNC_STATE_ONLY, I'm pretty sure you have a cyclic dependency between these devices when you create this link. Keep in mind that it can be a cycle involving more than 2 devices -- A -> B -> C -> A. And cycles don't make sense when you are trying to order suspend/resume. Looks like the new link is wrong or an existing link is wrong. If the dependencies are actually correct in hardware, then maybe your hardware device needs to be split into multiple devices so that you don't have cycles and can suspend in a meaningful way? Hope that helps. Thanks, Saravana