Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2557696pxj; Mon, 10 May 2021 05:54:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBe+UiC+nQwdb5OnRryWbeCbltgAurVcanOoKhmEDUHYiWle+BGFu5fXDNUyOQotKAA+QH X-Received: by 2002:aa7:d14f:: with SMTP id r15mr29071688edo.71.1620651151098; Mon, 10 May 2021 05:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620651151; cv=none; d=google.com; s=arc-20160816; b=BpNlvIfoMsqdk1PRJupNliPFJ/eNf6XymTDZ1WtgGO8Yl2KFRs57n6g4Iycd3KaYMj 7NLjPNlsnK2DngLbhCs2ibNX3gfwo0w4Pj+RmYp+dS9LMac9ntFMlmQqnAwZ0DQ/kI7p Nflp//FukUSr8/krZ/jGZ4BX2j/e4gPCMIDtDjDhW27uPjXUD5kpn1Jzflbpz74A/Dcd cnbmBvZlZUUwgnHNb6oO1bdsxOTser0XxhHSn25jFcF8vbTfSi3BU7FwSWHe6ynTSFfd vCTe7uI0sBmgocU+KmJvwjB+EztI2FfnFeZPEH01FGRSaSCjFkwUfqdpGk/Hk8TN++ZE lfRA== 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=ft2as+DEhhR7uAKVAn+z+CaK8IC5vgi2WkAS6id5V0Q=; b=RGHB3pylGJM62yFcHPtEtFKwsDV9o+XyDGBGi/SK2Lr5NFPjXszlLmi2l5gjFVf/e8 +ZjLyOyJEFEp7rQPjy8CTsYhkMShgJPP4SCGBz2Rd6WGk40462CVaDMUfTeFF9cVs9cO gEghHQ03JeVgds8fXBbbbYpLip9umBiCMu6RmPa1wznaODbh7NdTzaX6DBltQHrpUSu3 PvacKR0jmvE8X3qzjcaXSTyO3Oncx0/DztntDvCRlQuD5Xb5i3LBwqbkgf34vyfavtui jLTRKbYpUj8BrIbOqmYit7QrUVj0v0m42lZT6aTBnCR9UwGxHHJRo5r65nEb+OEfFy1o sR1A== 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 y18si13257040ejc.232.2021.05.10.05.52.07; Mon, 10 May 2021 05:52:31 -0700 (PDT) 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 S241685AbhEJMuw (ORCPT + 99 others); Mon, 10 May 2021 08:50:52 -0400 Received: from mail-oi1-f174.google.com ([209.85.167.174]:36649 "EHLO mail-oi1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235960AbhEJMAi (ORCPT ); Mon, 10 May 2021 08:00:38 -0400 Received: by mail-oi1-f174.google.com with SMTP id w16so7374924oiv.3 for ; Mon, 10 May 2021 04:59:33 -0700 (PDT) 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=ft2as+DEhhR7uAKVAn+z+CaK8IC5vgi2WkAS6id5V0Q=; b=ahXXXJE3cT1ObcbonDkLDpAttVPSjLUpUjPcesIzHPJ+h8bbb1MJWc0YJS6KuzOeLJ ewvAQugTcqKAVlwKVyEFRWqG49U1Ca6g0OYbcZrKbqj7j2epVkJu4qVCVzuvmTgxWPtJ XFEqR9AFhyisKd6NJdfeJZKz5lfUxkrbRjJgOWOriHBotBJVUHdhMvFQpvKwVM1PisGi bACY2NSEIpyegIBvb1WDFIOlbVsBhi/v3PoNR6uG0eqwCLww2tf3ElXniwM9EhUHzcqA DMVG1DUxoAQqaIfyUA5vKd+UyWEUg1H2sPZOlwSHof7x9iEx+7FvAKjKIUxw1sEAToTp mwxQ== X-Gm-Message-State: AOAM532fSeI6XB7w1l7H62WRfHm8cjCRGA10i9GRZDQnzBEOK4Rr5FyC JrXR3chdcSO5Y8s9Krzd+7RLkUVA3Tuu/j921oQ= X-Received: by 2002:a05:6808:90d:: with SMTP id w13mr3003924oih.71.1620647973280; Mon, 10 May 2021 04:59:33 -0700 (PDT) MIME-Version: 1.0 References: <20210508074118.1621729-1-swboyd@chromium.org> In-Reply-To: <20210508074118.1621729-1-swboyd@chromium.org> From: "Rafael J. Wysocki" Date: Mon, 10 May 2021 13:59:17 +0200 Message-ID: Subject: Re: [PATCH] component: Move host device to end of device lists on binding To: Stephen Boyd Cc: Greg Kroah-Hartman , Linux Kernel Mailing List , "Rafael J. Wysocki" , Daniel Vetter , Russell King , Rob Clark , dri-devel , Saravana Kannan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 8, 2021 at 9:41 AM Stephen Boyd wrote: > > The device lists are poorly ordered when the component device code is > used. This is because component_master_add_with_match() returns 0 > regardless of component devices calling component_add() first. It can > really only fail if an allocation fails, in which case everything is > going bad and we're out of memory. The host device (called master_dev in > the code), can succeed at probe and be put on the device lists before > any of the component devices are probed and put on the lists. > > Within the component device framework this usually isn't that bad > because the real driver work is done at bind time via > component{,master}_ops::bind(). It becomes a problem when the driver > core, or host driver, wants to operate on the component device outside > of the bind/unbind functions, e.g. via 'remove' or 'shutdown'. The > driver core doesn't understand the relationship between the host device > and the component devices and could possibly try to operate on component > devices when they're already removed from the system or shut down. > > Normally, device links or probe defer would reorder the lists and put > devices that depend on other devices in the lists at the correct > location, but with component devices this doesn't happen because this > information isn't expressed anywhere. Drivers simply succeed at > registering their component or host with the component framework and > wait for their bind() callback to be called once the other components > are ready. We could make various device links between 'master_dev' and > 'component->dev' but it's not necessary. Let's simply move the hosting > device to the end of the device lists when the component device fully > binds. This way we know that all components are present and have probed > properly and now the host device has really probed so it's safe to > assume the host driver ops can operate on any component device. Moving a device to the end of dpm_list is generally risky in cases when some dependency information may be missing. For example, if there is a device depending on the hosting one, but that dependency is not represented by a device link or a direct ancestor-descendant relationship (or generally a path in the device dependency graph leading from one of them to the other), then moving it to the end of dpm_list would cause system-wide suspend to fail (the hosting device would be suspended before the one depending on it). That may not be a concern here, but at least it would be good to document why it is not a concern.