Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1998789pxb; Mon, 8 Mar 2021 11:17:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZhhH+WpWviBHE2yBnnVpoUoWiLOmcY+eiAGqxaK1Ofuabs6U6T4pTjpKlU5SVTzpJUGoD X-Received: by 2002:a17:907:788e:: with SMTP id ku14mr16955264ejc.17.1615231067305; Mon, 08 Mar 2021 11:17:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615231067; cv=none; d=google.com; s=arc-20160816; b=kp618ey4G0zJ5NkKRpHNznwiFOOjCmiOXrSEntPP1CGVVxj1f68xLONDktPmzi2Ncr XPxLqNtiSzra6esxyH+rpINZF8DAbiJVrDwwqdTQKGnXUWCtjJ+ontf2ui7j9v+ijslk O5+C3pQxTHjmlyRW4Rei7O7PAGlVR3DW+GY+eyUXado9WfYaBSN+ISWjmTGtcZmLf9r1 R7sBALP9kO3QnwahxQfWB2gZpaispOEzSWJRQrbdJIpEJgvfPy8gITKLNaLlV7o/Vc5L 7/8iYdIzLeD25+Tqn6/Ix8nrFuAl9+8UyzFS1rYKsF+7uOJQ/ZzFs74zyAAYjvwQWxRT Ih1A== 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:dkim-signature; bh=X0OqlKDb33mMSyy19H9Hh5defv7wao6ITQZuQb7xnco=; b=g56GnOz8yjEdaNaSoq5BGwXfNtt6hRuYi+eR4Jcp6RDieQSYYFQBZjFzRuy8z1Gg1l 0zLQrnO++62JamEPTRAXWy7mJod7QBZ63BGgKYEVm/TCt0wKRWBAI1JoVWLegjOgQ8yP ZLC74yzuTuKD9BkE8ilWTqW7PgMl9AS7B4JhEnjnZQmUR4VGaN1j7uVKCPUpwnWKUihg bE3Z41XSMbyr9Ob1rhBs7dIxHP1DwEODc82yqoeQC7etjHxRSXhpe45vB3eLZk2dRf0f UPFbmEAq2yyAJMXO/ZmBVQkvbPvemSSYh9E8hZa9rDWqMEyVToalFmnqbJQZkwNLKHJL EkTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DLb8sQHo; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o6si7393990ejn.281.2021.03.08.11.17.24; Mon, 08 Mar 2021 11:17:47 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=DLb8sQHo; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231243AbhCHTQE (ORCPT + 99 others); Mon, 8 Mar 2021 14:16:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231153AbhCHTPk (ORCPT ); Mon, 8 Mar 2021 14:15:40 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C05BC06174A for ; Mon, 8 Mar 2021 11:15:40 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id u187so166707wmg.4 for ; Mon, 08 Mar 2021 11:15:40 -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=X0OqlKDb33mMSyy19H9Hh5defv7wao6ITQZuQb7xnco=; b=DLb8sQHoYvX8hicv1EiFBNZSbM6fBTbszJH5RQwt8+ZWpeZESJ4M9s1vMlG4KK0UEn 6FifSWdTMIUOkhLrcq1leFqDr3WmyP3T11m7SKJELOVhwK76ip75yLvUaXI9S8xJ4Bwh FGBkTBbrtYzLVJ8neqcBqAWiw4oEnIFbeBdw7KjCK7EMfmdlj2OapoPsZd/tMZrDUVnn sfaQ0MEUgWDAONgxBPO/MRfMPz1qB4Z3k6pRyfPbe47CHLD1snU14PCxLCxy8S701LKM +SgijTCv9aciyMqiPX7rmh3uNKorKmSw+ssLcRABVQ/TlvXD9ZGmI7EBMB/uGSJTHOyS CS/w== 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=X0OqlKDb33mMSyy19H9Hh5defv7wao6ITQZuQb7xnco=; b=gcbCym9RIinNll/vnN0Ww28zVNR+2xksgvFUlW4w7M27g4kN8OTE02OZB8oD81VIrX Lss8zCyU+dHCLhrHjq9lE3uGNZHSaoAXb5ZwGVwKjWEy3tnbxQj+lx8YjNfuQeFh9yiT 2igpvTL85bNySeQodkCaa/qiBwwcObrvjh+ZfgQwMwd+hoESntWBkS1esTy+C1D7O35U L+VMpvGrwkyzECG0ekpRZjfu5QAGGjXZQv/CKVsK+1mHZJKekwwK+O0dwfikWqjRKzr/ FZe6KuTdmVw6MnzfPUiQeWYrXLF4qnTB41+Qv6FhFZUbp3odYY5J5OVbhV6gFsM7AhDs Klkw== X-Gm-Message-State: AOAM530wXu0UVWq6tHZfASPHJ8G+3vNqOzV+0hnWFGCXbPrucJHtHh6E ANy36MtscPjqWVH6/enRTiNzWLW42zggdOo+qcEP2A== X-Received: by 2002:a7b:c1c9:: with SMTP id a9mr254164wmj.145.1615230938783; Mon, 08 Mar 2021 11:15:38 -0800 (PST) MIME-Version: 1.0 References: <20210304195101.3843496-1-saravanak@google.com> <30b4141e-11bd-45a2-b890-fddf444548ea@samsung.com> <077fcc5b-cd09-d587-6906-d10bcc991eaf@samsung.com> In-Reply-To: <077fcc5b-cd09-d587-6906-d10bcc991eaf@samsung.com> From: Saravana Kannan Date: Mon, 8 Mar 2021 11:15:02 -0800 Message-ID: Subject: Re: [PATCH v3] amba: Remove deferred device addition To: Marek Szyprowski Cc: Russell King , Philipp Zabel , Rob Herring , Ulf Hansson , John Stultz , Linus Walleij , Sudeep Holla , Nicolas Saenz Julienne , Geert Uytterhoeven , Android Kernel Team , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 7, 2021 at 11:28 PM Marek Szyprowski wrote: > > Hi Saravana, > > On 05.03.2021 19:02, Saravana Kannan wrote: > > On Fri, Mar 5, 2021 at 3:45 AM Marek Szyprowski > > wrote: > >> On 04.03.2021 20:51, Saravana Kannan wrote: > >>> The uevents generated for an amba device need PID and CID information > >>> that's available only when the amba device is powered on, clocked and > >>> out of reset. So, if those resources aren't available, the information > >>> can't be read to generate the uevents. To workaround this requirement, > >>> if the resources weren't available, the device addition was deferred and > >>> retried periodically. > >>> > >>> However, this deferred addition retry isn't based on resources becoming > >>> available. Instead, it's retried every 5 seconds and causes arbitrary > >>> probe delays for amba devices and their consumers. > >>> > >>> Also, maintaining a separate deferred-probe like mechanism is > >>> maintenance headache. > >>> > >>> With this commit, instead of deferring the device addition, we simply > >>> defer the generation of uevents for the device and probing of the device > >>> (because drivers needs PID and CID to match) until the PID and CID > >>> information can be read. This allows us to delete all the amba specific > >>> deferring code and also avoid the arbitrary probing delays. > >>> > >>> Cc: Rob Herring > >>> Cc: Ulf Hansson > >>> Cc: John Stultz > >>> Cc: Saravana Kannan > >>> Cc: Linus Walleij > >>> Cc: Sudeep Holla > >>> Cc: Nicolas Saenz Julienne > >>> Cc: Geert Uytterhoeven > >>> Cc: Marek Szyprowski > >>> Cc: Russell King > >>> Signed-off-by: Saravana Kannan > >>> --- > >>> > >>> v1 -> v2: > >>> - Dropped RFC tag > >>> - Complete rewrite to not use stub devices. > >>> v2 -> v3: > >>> - Flipped the if() condition for hard-coded periphids. > >>> - Added a stub driver to handle the case where all amba drivers are > >>> modules loaded by uevents. > >>> - Cc Marek after I realized I forgot to add him. > >>> > >>> Marek, > >>> > >>> Would you mind testing this? It looks okay with my limited testing. > >> It looks it works fine on my test systems. I've checked current > >> linux-next and this patch. You can add: > >> > >> Tested-by: Marek Szyprowski > > Hi Marek, > > > > Thanks! Does your test set up have amda drivers that are loaded based > > on uevents? That's the one I couldn't test. > > I've checked both, the built-in and all amba drivers compiled as > modules, loaded by udev. Both works fine here. > > >> I've briefly scanned the code and I'm curious how does it work. Does it > >> depend on the recently introduced "fw_devlink=on" feature? I don't see > >> other mechanism, which would trigger matching amba device if pm domains, > >> clocks or resets were not available on time to read pid/cid while adding > >> a device... > > No, it does not depend on fw_devlink or device links in any way. > > > > When a device is attempted to be probed (when it's added or during > > deferred probe), it's matched with all the drivers on the bus. > > When a new driver is registered to a bus, all devices in that bus are > > matched with the driver to see if they'll work together. > > That's how match is called. And match() can return -EPROBE_DEFER and > > that'll cause the device to be put in the deferred probe list by > > driver core. > > > > The tricky part in this patch was the uevent handling and the > > chicken-and-egg issue I talk about in the comments. > > Thanks for the explanation. This EPROBE_DEFER support in match() > callback must be something added after I crafted that periodic retry > based workaround. > I think it got in just a few months before your patches, but your patches worked :) I actually don't like match returning -EPROBE_DEFER, but I can work around it for some of my fw_devlink optimization plans. More context here: https://lore.kernel.org/lkml/CAGETcx_qO4vxTSyBtBR2k7fd_3rGJF42iBbJH37HPNw=FheDKg@mail.gmail.com/ -Saravana