From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A24D9C433DB for ; Wed, 27 Jan 2021 17:14:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B65E64DA3 for ; Wed, 27 Jan 2021 17:14:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235334AbhA0ROU (ORCPT ); Wed, 27 Jan 2021 12:14:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232310AbhA0RML (ORCPT ); Wed, 27 Jan 2021 12:12:11 -0500 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7150EC061574 for ; Wed, 27 Jan 2021 09:11:31 -0800 (PST) Received: by mail-yb1-xb33.google.com with SMTP id v200so2735519ybe.1 for ; Wed, 27 Jan 2021 09:11:31 -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=SCMC9c1Y3UdZlZUZ7gotdft22BvIa2n17Y+bk6uxrpU=; b=buF+e6cQQikru+I+wPmZzNHqUP53S5gn9SMSJhpEVq/IXcbgB6FO65hbHfPo5g2lK5 tUusqRpXb7HvQiCBMvWBMVL5Oid4fmEwGQ/2fQo47okY61Ue2gIUeT/kfiIac7f/Hwyj 6FFRbPsxZnt7Sma6ev9KJH145i55FdneRppghjcezH8k7lsQBohDAsn1SSjCT2nBwLVL eHJ3P7RvYKqs/+NCcq/RDW145cZKVpfugES4mbapMWIaTaMMwD21YwXD8+fYXkgMReNw k3RHPl/7T3Z9hcN33LNPPMq/w+APPDTRZPmfjV7r5YSKnh7nEVYr+/9yphZuhauCX4zE skMg== 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=SCMC9c1Y3UdZlZUZ7gotdft22BvIa2n17Y+bk6uxrpU=; b=qbrUlqlJNKioDQzQk0gSILlxLOVYbovPhHOBsF+ctDkyNsU0e2FGkjsxnRmzvfxIwN 1WNEX1VSWUHiKeqDA6khrKnedX4dI31KkAx5Upf4SFjHDCQXnCguoaEAOdSVjNwAhdxT NPC7dG4/rVtgpssDGnIOtwXHWLPgu/IepJvU4Xg4TlV2FQa2E5k5Hh7ZflL3qUtZn+nC 97lvLKwGtni2pMyAFoBNSiYb/ECkJZYcrHsneK4gft/kjflMQ+gB+OdlHppMRHx5ZFyf kHxvIxPX0zOqOrMQZETasdB+mlX4pzFB8qccytldfeQxreIgdLxg9eXqqInMAGyks0BZ OsEg== X-Gm-Message-State: AOAM531nPxqlHC3nyMlr/BSfXCq47G2WTgPOr+zrp4SD3STz0cLYcyYn zA5wJJPLA6ZqxYE/wckUVae80z1Nq2Yq/DZYhJBpOA== X-Google-Smtp-Source: ABdhPJxrBQe4Av/shkBNQ8ehUaFA7s4Ekhjqa1UpGiP1H/CtNg0Du0ryBzR8ZDxVbe7g6lqnkfZP88faYZGZi40TLVg= X-Received: by 2002:a25:8b8b:: with SMTP id j11mr16073043ybl.310.1611767490478; Wed, 27 Jan 2021 09:11:30 -0800 (PST) MIME-Version: 1.0 References: <20210120105246.23218-1-michael@walle.cc> In-Reply-To: From: Saravana Kannan Date: Wed, 27 Jan 2021 09:10:54 -0800 Message-ID: Subject: Re: [PATCH] PCI: dwc: layerscape: convert to builtin_platform_driver() To: Geert Uytterhoeven Cc: Michael Walle , Lorenzo Pieralisi , Roy Zang , PCI , LKML , Minghuan Lian , Mingkai Hu , Greg Kroah-Hartman , Bjorn Helgaas , linuxppc-dev , linux-arm-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 27, 2021 at 8:56 AM Geert Uytterhoeven wrote: > > Hi Saravana, > > On Wed, Jan 27, 2021 at 5:42 PM Saravana Kannan wrote: > > On Tue, Jan 26, 2021 at 11:43 PM Geert Uytterhoeven > > wrote: > > > On Wed, Jan 27, 2021 at 1:44 AM Saravana Kannan wrote: > > > > On Tue, Jan 26, 2021 at 12:50 AM Geert Uytterhoeven > > > > wrote: > > > > > On Mon, Jan 25, 2021 at 11:42 PM Saravana Kannan wrote: > > > > > > On Mon, Jan 25, 2021 at 11:49 AM Michael Walle wrote: > > > > > > > Am 2021-01-21 12:01, schrieb Geert Uytterhoeven: > > > > > > > > On Thu, Jan 21, 2021 at 1:05 AM Saravana Kannan > > > > > > > > wrote: > > > > > > > >> On Wed, Jan 20, 2021 at 3:53 PM Michael Walle > > > > > > > >> wrote: > > > > > > > >> > Am 2021-01-20 20:47, schrieb Saravana Kannan: > > > > > > > >> > > On Wed, Jan 20, 2021 at 11:28 AM Michael Walle > > > > > > > >> > > wrote: > > > > > > > >> > >> > > > > > > > >> > >> [RESEND, fat-fingered the buttons of my mail client and converted > > > > > > > >> > >> all CCs to BCCs :(] > > > > > > > >> > >> > > > > > > > >> > >> Am 2021-01-20 20:02, schrieb Saravana Kannan: > > > > > > > >> > >> > On Wed, Jan 20, 2021 at 6:24 AM Rob Herring wrote: > > > > > > > >> > >> >> > > > > > > > >> > >> >> On Wed, Jan 20, 2021 at 4:53 AM Michael Walle > > > > > > > >> > >> >> wrote: > > > > > > > >> > >> >> > > > > > > > > >> > >> >> > fw_devlink will defer the probe until all suppliers are ready. We can't > > > > > > > >> > >> >> > use builtin_platform_driver_probe() because it doesn't retry after probe > > > > > > > >> > >> >> > deferral. Convert it to builtin_platform_driver(). > > > > > > > >> > >> >> > > > > > > > >> > >> >> If builtin_platform_driver_probe() doesn't work with fw_devlink, then > > > > > > > >> > >> >> shouldn't it be fixed or removed? > > > > > > > >> > >> > > > > > > > > >> > >> > I was actually thinking about this too. The problem with fixing > > > > > > > >> > >> > builtin_platform_driver_probe() to behave like > > > > > > > >> > >> > builtin_platform_driver() is that these probe functions could be > > > > > > > >> > >> > marked with __init. But there are also only 20 instances of > > > > > > > >> > >> > builtin_platform_driver_probe() in the kernel: > > > > > > > >> > >> > $ git grep ^builtin_platform_driver_probe | wc -l > > > > > > > >> > >> > 20 > > > > > > > >> > >> > > > > > > > > >> > >> > So it might be easier to just fix them to not use > > > > > > > >> > >> > builtin_platform_driver_probe(). > > > > > > > >> > >> > > > > > > > > >> > >> > Michael, > > > > > > > >> > >> > > > > > > > > >> > >> > Any chance you'd be willing to help me by converting all these to > > > > > > > >> > >> > builtin_platform_driver() and delete builtin_platform_driver_probe()? > > > > > > > >> > >> > > > > > > > >> > >> If it just moving the probe function to the _driver struct and > > > > > > > >> > >> remove the __init annotations. I could look into that. > > > > > > > >> > > > > > > > > > >> > > Yup. That's pretty much it AFAICT. > > > > > > > >> > > > > > > > > > >> > > builtin_platform_driver_probe() also makes sure the driver doesn't ask > > > > > > > >> > > for async probe, etc. But I doubt anyone is actually setting async > > > > > > > >> > > flags and still using builtin_platform_driver_probe(). > > > > > > > >> > > > > > > > > >> > Hasn't module_platform_driver_probe() the same problem? And there > > > > > > > >> > are ~80 drivers which uses that. > > > > > > > >> > > > > > > > >> Yeah. The biggest problem with all of these is the __init markers. > > > > > > > >> Maybe some familiar with coccinelle can help? > > > > > > > > > > > > > > > > And dropping them will increase memory usage. > > > > > > > > > > > > > > Although I do have the changes for the builtin_platform_driver_probe() > > > > > > > ready, I don't think it makes much sense to send these unless we agree > > > > > > > on the increased memory footprint. While there are just a few > > > > > > > builtin_platform_driver_probe() and memory increase _might_ be > > > > > > > negligible, there are many more module_platform_driver_probe(). > > > > > > > > > > > > While it's good to drop code that'll not be used past kernel init, the > > > > > > module_platform_driver_probe() is going even more extreme. It doesn't > > > > > > even allow deferred probe (well before kernel init is done). I don't > > > > > > think that behavior is right and that's why we should delete it. Also, > > > > > > > > > > This construct is typically used for builtin hardware for which the > > > > > dependencies are registered very early, and thus known to probe at > > > > > first try (if present). > > > > > > > > > > > I doubt if any of these probe functions even take up 4KB of memory. > > > > > > > > > > How many 4 KiB pages do you have in a system with 10 MiB of SRAM? > > > > > How many can you afford to waste? > > > > > > > > There are only a few instances of this macro in the kernel. How many > > > > > > $ git grep -lw builtin_platform_driver_probe | wc -l > > > 21 > > > $ git grep -lw module_platform_driver_probe | wc -l > > > 86 > > > > > > + the ones that haven't been converted to the above yet: > > > > > > $ git grep -lw platform_driver_probe | wc -l > > > 58 > > > > > > > Yeah, this adds up in terms of the number of places we'd need to fix. > > But thinking more about it, a couple of points: > > 1. Not all builtin_platform_driver_probe() are problems for > > fw_devlink. So we can just fix them as we go if we need to. > > > > 2. The problem with builtin_platform_driver_probe() isn't really with > > the use of __init. It's the fact that it doesn't allow deferred > > probes. builtin_platform_driver_probe()/platform_driver_probe() could > > still be fixed up to allow deferred probe until we get to the point > > where we free the __init section (so at least till late_initcall). > > That's intentional: it is used for cases that will (must) never be deferred. > That's why it's safe to use __init. So was the usage of builtin_platform_driver_probe() wrong in the driver Michael fixed? Because, deferring and probing again clearly works? Also, "must never be deferred" seems like a weird condition to enforce. I think the real "rule" is that if it defers, the platform is not expected to work. But disallowing a probe reattempt seems weird. What is it going to hurt if it's attempted again? At worst it fails one more time? Also, I'd argue that all/most of the "can't defer, but I'm still a proper struct device" cases are all just patchwork to deal with the fact we were playing initcall chicken when there was no fw_devlink. I'm hoping we can move people away from that mindset. And the first step towards that would be to allow *platform_probe() to allow deferred probes until late_initcall(). -Saravana From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB7E9C4332D for ; Wed, 27 Jan 2021 17:14:18 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6795E64DA1 for ; Wed, 27 Jan 2021 17:14:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6795E64DA1 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DQqvq5xDyzDr1P for ; Thu, 28 Jan 2021 04:14:15 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=google.com (client-ip=2607:f8b0:4864:20::b29; helo=mail-yb1-xb29.google.com; envelope-from=saravanak@google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=buF+e6cQ; dkim-atps=neutral Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DQqrk643LzDqjp for ; Thu, 28 Jan 2021 04:11:34 +1100 (AEDT) Received: by mail-yb1-xb29.google.com with SMTP id b11so2694276ybj.9 for ; Wed, 27 Jan 2021 09:11:34 -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=SCMC9c1Y3UdZlZUZ7gotdft22BvIa2n17Y+bk6uxrpU=; b=buF+e6cQQikru+I+wPmZzNHqUP53S5gn9SMSJhpEVq/IXcbgB6FO65hbHfPo5g2lK5 tUusqRpXb7HvQiCBMvWBMVL5Oid4fmEwGQ/2fQo47okY61Ue2gIUeT/kfiIac7f/Hwyj 6FFRbPsxZnt7Sma6ev9KJH145i55FdneRppghjcezH8k7lsQBohDAsn1SSjCT2nBwLVL eHJ3P7RvYKqs/+NCcq/RDW145cZKVpfugES4mbapMWIaTaMMwD21YwXD8+fYXkgMReNw k3RHPl/7T3Z9hcN33LNPPMq/w+APPDTRZPmfjV7r5YSKnh7nEVYr+/9yphZuhauCX4zE skMg== 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=SCMC9c1Y3UdZlZUZ7gotdft22BvIa2n17Y+bk6uxrpU=; b=SOcD7NmlcsHSEPXfxWJQ+DZtoYgQLw//VJesO7jwmRstkWsMvxydWR1e1bkS3is6ez 2kjqtVHbkX+1ZI5KiNfTDTUKFjfwTE0phcS1x9HpuIcyxPeDwLDugtvMAt5NWUNp7Nh/ +288f9sjw8+kuRvm+ShKanBz7qOFOVJdpZNQ6Llx9711S1TN+LH/B+JaiZe40m26LIMf +Gv6jkpSP1ErOkj7AV5pc/A7aNCVEdQhX99vboo5AmXJEM6Amgif47K0pqdwl1wIzLGi QbVdDQfWqsbw3mA0j8/O37pxqYy2IPkcIEXY9cyV6bXFvyW+Ezl/v5vGq95jiQUNdp9S xLSg== X-Gm-Message-State: AOAM533mhZ2DDN94KTsKmfS7A52A922+ZA2aFpVHMq3jBGQR1oE1IMYs Phno6MmAakQ7EwRIl29Pfw4d3ThC4742BKugiDwLJw== X-Google-Smtp-Source: ABdhPJxrBQe4Av/shkBNQ8ehUaFA7s4Ekhjqa1UpGiP1H/CtNg0Du0ryBzR8ZDxVbe7g6lqnkfZP88faYZGZi40TLVg= X-Received: by 2002:a25:8b8b:: with SMTP id j11mr16073043ybl.310.1611767490478; Wed, 27 Jan 2021 09:11:30 -0800 (PST) MIME-Version: 1.0 References: <20210120105246.23218-1-michael@walle.cc> In-Reply-To: From: Saravana Kannan Date: Wed, 27 Jan 2021 09:10:54 -0800 Message-ID: Subject: Re: [PATCH] PCI: dwc: layerscape: convert to builtin_platform_driver() To: Geert Uytterhoeven Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roy Zang , Lorenzo Pieralisi , PCI , LKML , Minghuan Lian , Michael Walle , linux-arm-kernel , Greg Kroah-Hartman , Bjorn Helgaas , linuxppc-dev , Mingkai Hu Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, Jan 27, 2021 at 8:56 AM Geert Uytterhoeven wrote: > > Hi Saravana, > > On Wed, Jan 27, 2021 at 5:42 PM Saravana Kannan wrote: > > On Tue, Jan 26, 2021 at 11:43 PM Geert Uytterhoeven > > wrote: > > > On Wed, Jan 27, 2021 at 1:44 AM Saravana Kannan wrote: > > > > On Tue, Jan 26, 2021 at 12:50 AM Geert Uytterhoeven > > > > wrote: > > > > > On Mon, Jan 25, 2021 at 11:42 PM Saravana Kannan wrote: > > > > > > On Mon, Jan 25, 2021 at 11:49 AM Michael Walle wrote: > > > > > > > Am 2021-01-21 12:01, schrieb Geert Uytterhoeven: > > > > > > > > On Thu, Jan 21, 2021 at 1:05 AM Saravana Kannan > > > > > > > > wrote: > > > > > > > >> On Wed, Jan 20, 2021 at 3:53 PM Michael Walle > > > > > > > >> wrote: > > > > > > > >> > Am 2021-01-20 20:47, schrieb Saravana Kannan: > > > > > > > >> > > On Wed, Jan 20, 2021 at 11:28 AM Michael Walle > > > > > > > >> > > wrote: > > > > > > > >> > >> > > > > > > > >> > >> [RESEND, fat-fingered the buttons of my mail client and converted > > > > > > > >> > >> all CCs to BCCs :(] > > > > > > > >> > >> > > > > > > > >> > >> Am 2021-01-20 20:02, schrieb Saravana Kannan: > > > > > > > >> > >> > On Wed, Jan 20, 2021 at 6:24 AM Rob Herring wrote: > > > > > > > >> > >> >> > > > > > > > >> > >> >> On Wed, Jan 20, 2021 at 4:53 AM Michael Walle > > > > > > > >> > >> >> wrote: > > > > > > > >> > >> >> > > > > > > > > >> > >> >> > fw_devlink will defer the probe until all suppliers are ready. We can't > > > > > > > >> > >> >> > use builtin_platform_driver_probe() because it doesn't retry after probe > > > > > > > >> > >> >> > deferral. Convert it to builtin_platform_driver(). > > > > > > > >> > >> >> > > > > > > > >> > >> >> If builtin_platform_driver_probe() doesn't work with fw_devlink, then > > > > > > > >> > >> >> shouldn't it be fixed or removed? > > > > > > > >> > >> > > > > > > > > >> > >> > I was actually thinking about this too. The problem with fixing > > > > > > > >> > >> > builtin_platform_driver_probe() to behave like > > > > > > > >> > >> > builtin_platform_driver() is that these probe functions could be > > > > > > > >> > >> > marked with __init. But there are also only 20 instances of > > > > > > > >> > >> > builtin_platform_driver_probe() in the kernel: > > > > > > > >> > >> > $ git grep ^builtin_platform_driver_probe | wc -l > > > > > > > >> > >> > 20 > > > > > > > >> > >> > > > > > > > > >> > >> > So it might be easier to just fix them to not use > > > > > > > >> > >> > builtin_platform_driver_probe(). > > > > > > > >> > >> > > > > > > > > >> > >> > Michael, > > > > > > > >> > >> > > > > > > > > >> > >> > Any chance you'd be willing to help me by converting all these to > > > > > > > >> > >> > builtin_platform_driver() and delete builtin_platform_driver_probe()? > > > > > > > >> > >> > > > > > > > >> > >> If it just moving the probe function to the _driver struct and > > > > > > > >> > >> remove the __init annotations. I could look into that. > > > > > > > >> > > > > > > > > > >> > > Yup. That's pretty much it AFAICT. > > > > > > > >> > > > > > > > > > >> > > builtin_platform_driver_probe() also makes sure the driver doesn't ask > > > > > > > >> > > for async probe, etc. But I doubt anyone is actually setting async > > > > > > > >> > > flags and still using builtin_platform_driver_probe(). > > > > > > > >> > > > > > > > > >> > Hasn't module_platform_driver_probe() the same problem? And there > > > > > > > >> > are ~80 drivers which uses that. > > > > > > > >> > > > > > > > >> Yeah. The biggest problem with all of these is the __init markers. > > > > > > > >> Maybe some familiar with coccinelle can help? > > > > > > > > > > > > > > > > And dropping them will increase memory usage. > > > > > > > > > > > > > > Although I do have the changes for the builtin_platform_driver_probe() > > > > > > > ready, I don't think it makes much sense to send these unless we agree > > > > > > > on the increased memory footprint. While there are just a few > > > > > > > builtin_platform_driver_probe() and memory increase _might_ be > > > > > > > negligible, there are many more module_platform_driver_probe(). > > > > > > > > > > > > While it's good to drop code that'll not be used past kernel init, the > > > > > > module_platform_driver_probe() is going even more extreme. It doesn't > > > > > > even allow deferred probe (well before kernel init is done). I don't > > > > > > think that behavior is right and that's why we should delete it. Also, > > > > > > > > > > This construct is typically used for builtin hardware for which the > > > > > dependencies are registered very early, and thus known to probe at > > > > > first try (if present). > > > > > > > > > > > I doubt if any of these probe functions even take up 4KB of memory. > > > > > > > > > > How many 4 KiB pages do you have in a system with 10 MiB of SRAM? > > > > > How many can you afford to waste? > > > > > > > > There are only a few instances of this macro in the kernel. How many > > > > > > $ git grep -lw builtin_platform_driver_probe | wc -l > > > 21 > > > $ git grep -lw module_platform_driver_probe | wc -l > > > 86 > > > > > > + the ones that haven't been converted to the above yet: > > > > > > $ git grep -lw platform_driver_probe | wc -l > > > 58 > > > > > > > Yeah, this adds up in terms of the number of places we'd need to fix. > > But thinking more about it, a couple of points: > > 1. Not all builtin_platform_driver_probe() are problems for > > fw_devlink. So we can just fix them as we go if we need to. > > > > 2. The problem with builtin_platform_driver_probe() isn't really with > > the use of __init. It's the fact that it doesn't allow deferred > > probes. builtin_platform_driver_probe()/platform_driver_probe() could > > still be fixed up to allow deferred probe until we get to the point > > where we free the __init section (so at least till late_initcall). > > That's intentional: it is used for cases that will (must) never be deferred. > That's why it's safe to use __init. So was the usage of builtin_platform_driver_probe() wrong in the driver Michael fixed? Because, deferring and probing again clearly works? Also, "must never be deferred" seems like a weird condition to enforce. I think the real "rule" is that if it defers, the platform is not expected to work. But disallowing a probe reattempt seems weird. What is it going to hurt if it's attempted again? At worst it fails one more time? Also, I'd argue that all/most of the "can't defer, but I'm still a proper struct device" cases are all just patchwork to deal with the fact we were playing initcall chicken when there was no fw_devlink. I'm hoping we can move people away from that mindset. And the first step towards that would be to allow *platform_probe() to allow deferred probes until late_initcall(). -Saravana From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFB37C433DB for ; Wed, 27 Jan 2021 17:13:07 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7CFFA64DA0 for ; Wed, 27 Jan 2021 17:13:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CFFA64DA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GV/dZL11z56VpLKuIX0XH30VdTPQtTSjPZz1tefnMTY=; b=1LeEszQruJK/hTd4uDW6Ie9ux FnR01v99QETYzgDfMlXEwlsbFSPqixuroV9q/TXd6FJLq4p2oW+Dg3/1u5mDFGT2boBbHjJnfd+fN Ib+2Aa1GwQcvQ69Jur5dJgfqJVN2CVsNW+QfFm3mLGp/NTMzzVxDQfnmsG0aaftbgWIytdIU6H8wC IDH7sCTGTAzXS1jcUJlClcC/6ek/mCMlO2H1ZqUpKNj4b5xWv9YwdZHY/DR/BYd9p187Ll3n1Rzk4 vHaOvbhz/ER+s9Z7WZGQR6tdYVmsNKGHdaNOPBiAupjeh2D+q7CfiP+JCmwuu5wq4/abPrC2nUNph ulmbgTm+A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4oLu-0002G6-Qg; Wed, 27 Jan 2021 17:11:34 +0000 Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4oLs-0002FQ-TX for linux-arm-kernel@lists.infradead.org; Wed, 27 Jan 2021 17:11:33 +0000 Received: by mail-yb1-xb35.google.com with SMTP id k132so2731464ybf.2 for ; Wed, 27 Jan 2021 09:11:32 -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=SCMC9c1Y3UdZlZUZ7gotdft22BvIa2n17Y+bk6uxrpU=; b=buF+e6cQQikru+I+wPmZzNHqUP53S5gn9SMSJhpEVq/IXcbgB6FO65hbHfPo5g2lK5 tUusqRpXb7HvQiCBMvWBMVL5Oid4fmEwGQ/2fQo47okY61Ue2gIUeT/kfiIac7f/Hwyj 6FFRbPsxZnt7Sma6ev9KJH145i55FdneRppghjcezH8k7lsQBohDAsn1SSjCT2nBwLVL eHJ3P7RvYKqs/+NCcq/RDW145cZKVpfugES4mbapMWIaTaMMwD21YwXD8+fYXkgMReNw k3RHPl/7T3Z9hcN33LNPPMq/w+APPDTRZPmfjV7r5YSKnh7nEVYr+/9yphZuhauCX4zE skMg== 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=SCMC9c1Y3UdZlZUZ7gotdft22BvIa2n17Y+bk6uxrpU=; b=n5TpuWsIuxRRt7VYTlaBTRg9ePkwkpois9Np7vjXDzZq4M+0ZRVvmMfeunbO9JPHFK C65+cU+zZ8QTnURNnooxu10T4PSUxu9+IX72emZfdh7m4VohuRHYvi+3umF0UIt2WHEG zSrLgCYocVYGM7z4CIs8Ph9qYlyYxvndxZdny7rutABP/5aRWQiDKSxD+ZE7Fqo1hrsw LITTk9asVTesp4peQWKS8s+D+aJuRI2+4QDOPM5uj5z7n/Rsna7m9R6MHRkSewplhioY HDLzQY98ZsuXuGRwgNk1X+Q5nCvTuZa6fWntoIh9syU3hq075iwihgTWBZnFCajpaqvo Z1iA== X-Gm-Message-State: AOAM5301m6JbPG6SmedoPIVXDupUAJqdbjs3k/ujTPL2eGujXemQqXeb 2vfn+Y7s164sjNaPgZJxXlSMPMToJJHWDZ912J666Q== X-Google-Smtp-Source: ABdhPJxrBQe4Av/shkBNQ8ehUaFA7s4Ekhjqa1UpGiP1H/CtNg0Du0ryBzR8ZDxVbe7g6lqnkfZP88faYZGZi40TLVg= X-Received: by 2002:a25:8b8b:: with SMTP id j11mr16073043ybl.310.1611767490478; Wed, 27 Jan 2021 09:11:30 -0800 (PST) MIME-Version: 1.0 References: <20210120105246.23218-1-michael@walle.cc> In-Reply-To: From: Saravana Kannan Date: Wed, 27 Jan 2021 09:10:54 -0800 Message-ID: Subject: Re: [PATCH] PCI: dwc: layerscape: convert to builtin_platform_driver() To: Geert Uytterhoeven X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210127_121133_018186_2CAC9BA7 X-CRM114-Status: GOOD ( 47.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roy Zang , Lorenzo Pieralisi , PCI , LKML , Minghuan Lian , Michael Walle , linux-arm-kernel , Greg Kroah-Hartman , Bjorn Helgaas , linuxppc-dev , Mingkai Hu Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jan 27, 2021 at 8:56 AM Geert Uytterhoeven wrote: > > Hi Saravana, > > On Wed, Jan 27, 2021 at 5:42 PM Saravana Kannan wrote: > > On Tue, Jan 26, 2021 at 11:43 PM Geert Uytterhoeven > > wrote: > > > On Wed, Jan 27, 2021 at 1:44 AM Saravana Kannan wrote: > > > > On Tue, Jan 26, 2021 at 12:50 AM Geert Uytterhoeven > > > > wrote: > > > > > On Mon, Jan 25, 2021 at 11:42 PM Saravana Kannan wrote: > > > > > > On Mon, Jan 25, 2021 at 11:49 AM Michael Walle wrote: > > > > > > > Am 2021-01-21 12:01, schrieb Geert Uytterhoeven: > > > > > > > > On Thu, Jan 21, 2021 at 1:05 AM Saravana Kannan > > > > > > > > wrote: > > > > > > > >> On Wed, Jan 20, 2021 at 3:53 PM Michael Walle > > > > > > > >> wrote: > > > > > > > >> > Am 2021-01-20 20:47, schrieb Saravana Kannan: > > > > > > > >> > > On Wed, Jan 20, 2021 at 11:28 AM Michael Walle > > > > > > > >> > > wrote: > > > > > > > >> > >> > > > > > > > >> > >> [RESEND, fat-fingered the buttons of my mail client and converted > > > > > > > >> > >> all CCs to BCCs :(] > > > > > > > >> > >> > > > > > > > >> > >> Am 2021-01-20 20:02, schrieb Saravana Kannan: > > > > > > > >> > >> > On Wed, Jan 20, 2021 at 6:24 AM Rob Herring wrote: > > > > > > > >> > >> >> > > > > > > > >> > >> >> On Wed, Jan 20, 2021 at 4:53 AM Michael Walle > > > > > > > >> > >> >> wrote: > > > > > > > >> > >> >> > > > > > > > > >> > >> >> > fw_devlink will defer the probe until all suppliers are ready. We can't > > > > > > > >> > >> >> > use builtin_platform_driver_probe() because it doesn't retry after probe > > > > > > > >> > >> >> > deferral. Convert it to builtin_platform_driver(). > > > > > > > >> > >> >> > > > > > > > >> > >> >> If builtin_platform_driver_probe() doesn't work with fw_devlink, then > > > > > > > >> > >> >> shouldn't it be fixed or removed? > > > > > > > >> > >> > > > > > > > > >> > >> > I was actually thinking about this too. The problem with fixing > > > > > > > >> > >> > builtin_platform_driver_probe() to behave like > > > > > > > >> > >> > builtin_platform_driver() is that these probe functions could be > > > > > > > >> > >> > marked with __init. But there are also only 20 instances of > > > > > > > >> > >> > builtin_platform_driver_probe() in the kernel: > > > > > > > >> > >> > $ git grep ^builtin_platform_driver_probe | wc -l > > > > > > > >> > >> > 20 > > > > > > > >> > >> > > > > > > > > >> > >> > So it might be easier to just fix them to not use > > > > > > > >> > >> > builtin_platform_driver_probe(). > > > > > > > >> > >> > > > > > > > > >> > >> > Michael, > > > > > > > >> > >> > > > > > > > > >> > >> > Any chance you'd be willing to help me by converting all these to > > > > > > > >> > >> > builtin_platform_driver() and delete builtin_platform_driver_probe()? > > > > > > > >> > >> > > > > > > > >> > >> If it just moving the probe function to the _driver struct and > > > > > > > >> > >> remove the __init annotations. I could look into that. > > > > > > > >> > > > > > > > > > >> > > Yup. That's pretty much it AFAICT. > > > > > > > >> > > > > > > > > > >> > > builtin_platform_driver_probe() also makes sure the driver doesn't ask > > > > > > > >> > > for async probe, etc. But I doubt anyone is actually setting async > > > > > > > >> > > flags and still using builtin_platform_driver_probe(). > > > > > > > >> > > > > > > > > >> > Hasn't module_platform_driver_probe() the same problem? And there > > > > > > > >> > are ~80 drivers which uses that. > > > > > > > >> > > > > > > > >> Yeah. The biggest problem with all of these is the __init markers. > > > > > > > >> Maybe some familiar with coccinelle can help? > > > > > > > > > > > > > > > > And dropping them will increase memory usage. > > > > > > > > > > > > > > Although I do have the changes for the builtin_platform_driver_probe() > > > > > > > ready, I don't think it makes much sense to send these unless we agree > > > > > > > on the increased memory footprint. While there are just a few > > > > > > > builtin_platform_driver_probe() and memory increase _might_ be > > > > > > > negligible, there are many more module_platform_driver_probe(). > > > > > > > > > > > > While it's good to drop code that'll not be used past kernel init, the > > > > > > module_platform_driver_probe() is going even more extreme. It doesn't > > > > > > even allow deferred probe (well before kernel init is done). I don't > > > > > > think that behavior is right and that's why we should delete it. Also, > > > > > > > > > > This construct is typically used for builtin hardware for which the > > > > > dependencies are registered very early, and thus known to probe at > > > > > first try (if present). > > > > > > > > > > > I doubt if any of these probe functions even take up 4KB of memory. > > > > > > > > > > How many 4 KiB pages do you have in a system with 10 MiB of SRAM? > > > > > How many can you afford to waste? > > > > > > > > There are only a few instances of this macro in the kernel. How many > > > > > > $ git grep -lw builtin_platform_driver_probe | wc -l > > > 21 > > > $ git grep -lw module_platform_driver_probe | wc -l > > > 86 > > > > > > + the ones that haven't been converted to the above yet: > > > > > > $ git grep -lw platform_driver_probe | wc -l > > > 58 > > > > > > > Yeah, this adds up in terms of the number of places we'd need to fix. > > But thinking more about it, a couple of points: > > 1. Not all builtin_platform_driver_probe() are problems for > > fw_devlink. So we can just fix them as we go if we need to. > > > > 2. The problem with builtin_platform_driver_probe() isn't really with > > the use of __init. It's the fact that it doesn't allow deferred > > probes. builtin_platform_driver_probe()/platform_driver_probe() could > > still be fixed up to allow deferred probe until we get to the point > > where we free the __init section (so at least till late_initcall). > > That's intentional: it is used for cases that will (must) never be deferred. > That's why it's safe to use __init. So was the usage of builtin_platform_driver_probe() wrong in the driver Michael fixed? Because, deferring and probing again clearly works? Also, "must never be deferred" seems like a weird condition to enforce. I think the real "rule" is that if it defers, the platform is not expected to work. But disallowing a probe reattempt seems weird. What is it going to hurt if it's attempted again? At worst it fails one more time? Also, I'd argue that all/most of the "can't defer, but I'm still a proper struct device" cases are all just patchwork to deal with the fact we were playing initcall chicken when there was no fw_devlink. I'm hoping we can move people away from that mindset. And the first step towards that would be to allow *platform_probe() to allow deferred probes until late_initcall(). -Saravana _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel