Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1389941imm; Sun, 8 Jul 2018 01:26:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpflRTMsf/sh4vPDQY0vnCHv6jD1hceerXWcKD5UbjXbjIwNMGLHTfhDQws7pQvFG5rcViC/ X-Received: by 2002:a63:5922:: with SMTP id n34-v6mr14994395pgb.113.1531038373678; Sun, 08 Jul 2018 01:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531038373; cv=none; d=google.com; s=arc-20160816; b=uXQvNvgXQ1DXmTsAfmoDlZZWbqvsy7442TCTzYig5R27tQ0/N6RS+DlNrq/xBTvnFc /TsA4H8EjzAfz55DOGKexfM3Z6pAQZ27Go2ZbNCBQeXPZ4g+g3a1T5wtywbg7RP4bmkL KOAy4aEav7vTRN0L0QzWDygTaneWJCwjFoT+43I1aYmETi+T1xvmUNJL3QfufVC4+39T dmQtrUE5NAtHb6CkOruGDlTb4cMifCY72AhTaSprxBCJdjMEbtdHFKeDJ6oVlz/ZClJf KLPaBCvfkvFaUH7Da6DbBJlITBeqJNLnVuqBfVbENRppmFqOVzam1XBsGCY0qFb1BhC4 BRmw== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=tnfHLa00LuvmHD08Ta5f68QuKAbpzHHTTsGUXCXhtCQ=; b=AZT2VpbWY7yuGFShO2O3A9Qv7eESBP1Y7YLwo8z9pz5fxJQ/+6huUR7WLjnZNO7Iwo YKh99U54aErGC0bEWu4Tr+8InKlgegT1PUkFfpXXPyfqBNUWQgQbmIz5FgwRtztBY7Ok O1SG4xf4y/lUsgkQxPzbF0/4fZqmIQz/1hUX6a/dBdVmAv1I+lpB4NVhSHiAj6G/HBmF 8U3YfVfBPFWeKLe6iG1jzytSzNsys7xFoI5/ukiQF8aJ/cYgCDB3KTcMzWyyxfnpXU7C 1c+QqWlNPge/mVZqTYUO857M5EnUuFM1Wv2W6HhZKERYdNZ52/P3klZVsU2VdfuGCkDm 6xnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=RJ8eC7o1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si11475713pgq.479.2018.07.08.01.25.57; Sun, 08 Jul 2018 01:26:13 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=RJ8eC7o1; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753957AbeGHIZR (ORCPT + 99 others); Sun, 8 Jul 2018 04:25:17 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:32894 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753774AbeGHIZP (ORCPT ); Sun, 8 Jul 2018 04:25:15 -0400 Received: by mail-oi0-f65.google.com with SMTP id c6-v6so30758139oiy.0; Sun, 08 Jul 2018 01:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=tnfHLa00LuvmHD08Ta5f68QuKAbpzHHTTsGUXCXhtCQ=; b=RJ8eC7o1nv3EEu0FbZJoL+pazBo24ZqQF995gMwUf7bt5Zu8KMVJBP+x+rmTFTHA5s p3Ec8U6LTiZ6kTGPMlGRVMawEGmSfO1Fv/Wu6Ynp133P1ZtvWIcM2joed5MB14YjjCdY 4MU6Pa7H4EVA8aDJ+/1FLP0TFwiRveQjmLd0ZsHgrFw9qEjywpJXjo7nZgf6H8qwkKWg GfMpFHqCrBzOfQe6eBURy3Z9RfgyobpWGbaxlgi8ZpruQEx28KCKpwv5ThHVwLMmV1GO TQkwqrAfJGz3QMfR93fPw+mIU4pRyGuPIglE4GGKRO7XqGg4QEy1ss6BdTkhFJ0wiaOD muXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=tnfHLa00LuvmHD08Ta5f68QuKAbpzHHTTsGUXCXhtCQ=; b=GB3kPzMwUxTmUnaL2hACmSKO8GGuXVIyxhYSCHw/9wNa+woQjZ7r32Bkmr+6VHfogh EfRecKR1s8r7Q/MtxCZNNqEXERp5W2pP3L32jZJdHdSuD0+/ZgNGHAQj9F/lDALNY3mo vGT39gaHcijKY679O3aVo/I2HhxTKEU8Ru2X4bJGBxZCDbGS7cbqoKxa1DL+x156SLpd PQ6Fnw3dLOyT0Q5Fwg04OfIVian9qHqRqFO/LIs341msyxQK82dkEHZeLmvjkxJV9P8O 8In+1xPqdATsWVknl05K0mAqEvuY5H4zwF9Ed1sSh/DTcMt+fWKbfA2DXNXFf/gafshQ adUQ== X-Gm-Message-State: APt69E0brvqYZuqtV/orlLDxU1qQGeOhgsfwsU0VW1wT4eGMYilpOykp 36S3VZkU4YDAjAX/67R39GL+hA4EpN/IDV1uNRua4w== X-Received: by 2002:aca:ad4f:: with SMTP id w76-v6mr19556184oie.233.1531038314819; Sun, 08 Jul 2018 01:25:14 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:63d2:0:0:0:0:0 with HTTP; Sun, 8 Jul 2018 01:25:14 -0700 (PDT) In-Reply-To: References: <1530600642-25090-1-git-send-email-kernelfans@gmail.com> <4685360.VNmeYLh0dQ@aspire.rjw.lan> <6281446.GoJLz6Hq6C@aspire.rjw.lan> <20180706083603.GA9063@wunner.de> From: "Rafael J. Wysocki" Date: Sun, 8 Jul 2018 10:25:14 +0200 X-Google-Sender-Auth: lFj0vqZ_5-IU8whSjnFj-zYH94U Message-ID: Subject: Re: [PATCHv3 0/4] drivers/base: bugfix for supplier<-consumer ordering in device_kset To: Pingfan Liu Cc: "Rafael J. Wysocki" , Lukas Wunner , Linux Kernel Mailing List , Greg Kroah-Hartman , Grygorii Strashko , Christoph Hellwig , Bjorn Helgaas , Dave Young , Linux PCI , linuxppc-dev , Linux PM , Kishon Vijay Abraham I 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 Sat, Jul 7, 2018 at 6:24 AM, Pingfan Liu wrote: > On Fri, Jul 6, 2018 at 9:55 PM Pingfan Liu wrote: >> >> On Fri, Jul 6, 2018 at 4:47 PM Rafael J. Wysocki wrote: >> > >> > On Fri, Jul 6, 2018 at 10:36 AM, Lukas Wunner wrote: >> > > [cc += Kishon Vijay Abraham] >> > > >> > > On Thu, Jul 05, 2018 at 11:18:28AM +0200, Rafael J. Wysocki wrote: >> > >> OK, so calling devices_kset_move_last() from really_probe() clearly is >> > >> a mistake. >> > >> >> > >> I'm not really sure what the intention of it was as the changelog of >> > >> commit 52cdbdd49853d doesn't really explain that (why would it be >> > >> insufficient without that change?) >> > > >> > > It seems 52cdbdd49853d fixed an issue with boards which have an MMC >> > > whose reset pin needs to be driven high on shutdown, lest the MMC >> > > won't be found on the next boot. >> > > >> > > The boards' devicetrees use a kludge wherein the reset pin is modelled >> > > as a regulator. The regulator is enabled when the MMC probes and >> > > disabled on driver unbind and shutdown. As a result, the pin is driven >> > > low on shutdown and the MMC is not found on the next boot. >> > > >> > > To fix this, another kludge was invented wherein the GPIO expander >> > > driving the reset pin unconditionally drives all its pins high on >> > > shutdown, see pcf857x_shutdown() in drivers/gpio/gpio-pcf857x.c >> > > (commit adc284755055, "gpio: pcf857x: restore the initial line state >> > > of all pcf lines"). >> > > >> > > For this kludge to work, the GPIO expander's ->shutdown hook needs to >> > > be executed after the MMC expander's ->shutdown hook. >> > > >> > > Commit 52cdbdd49853d achieved that by reordering devices_kset according >> > > to the probe order. Apparently the MMC probes after the GPIO expander, >> > > possibly because it returns -EPROBE_DEFER if the vmmc regulator isn't >> > > available yet, see mmc_regulator_get_supply(). >> > > >> > > Note, I'm just piecing the information together from git history, >> > > I'm not responsible for these kludges. (I'm innocent!) >> > >> > Sure enough. :-) >> > >> > In any case, calling devices_kset_move_last() in really_probe() is >> > plain broken and if its only purpose was to address a single, arguably >> > kludgy, use case, let's just get rid of it in the first place IMO. >> > >> Yes, if it is only used for a single use case. >> > Think it again, I saw other potential issue with the current code. > device_link_add->device_reorder_to_tail() can break the > "supplier<-consumer" order. During moving children after parent's > supplier, it ignores the order of child's consumer. What do you mean? > Beside this, essentially both devices_kset_move_after/_before() and > device_pm_move_after/_before() expose the shutdown order to the > indirect caller, and we can not expect that the caller can not handle > it correctly. It should be a job of drivers core. Arguably so, but that's how those functions were designed and the callers should be aware of the limitation. If they aren't, there is a bug in the caller. > It is hard to extract high dimension info and pack them into one dimension > linked-list. Well, yes and no. We know it for a fact that there is a linear ordering that will work. It is inefficient to figure it out every time during system suspend and resume, for one and that's why we have dpm_list. Now, if we have it for suspend and resume, it can also be used for shutdown. > And in theory, it is warranted that the shutdown seq is > correct by using device tree info. More important, it is cheap with > the data structure in hand. So I think it is time to resolve the issue > once for all. Not the way you want to do that, though. Thanks, Rafael