Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp354577pxb; Wed, 14 Apr 2021 17:38:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymTEedovb6kwHI+/UHuqVefxfsAWz+Zmyf6tSqhAlDgsXlj9CB0zAXmntrpwl4GFMePsgO X-Received: by 2002:a63:5b26:: with SMTP id p38mr964581pgb.141.1618447083626; Wed, 14 Apr 2021 17:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618447083; cv=none; d=google.com; s=arc-20160816; b=kPjoAVeHpQB/9u5heJm7G0EEf430T4Z63rlcgcGLa/N/pcXtiCGOmlzQ6p5J+6qx5J KqchM2vf2M6zi4aItx6e+GQ5NFP6X41oCDOXlHXRx1gGMApfn++CjEstygGFCssKwwc6 zutHuMWki5bnJHM03rIUjDQ/GUdRCVn7lFTdJaFRwcF+gRoi6eje9XhKo2p+tLA9vYTP ktfsR1AiTsaNmwJ20Rr+N2iqrTA198gM/8Tvvx4ZMN/AV2d6YYMe1365ZzT2D3m7bYUm VT+sotpkbkeIX8E9N6eKhVuQyswwuMzztOl2NL2YLIv3NOsV0Aq0O++7GziCIIp9Zg7v FndA== 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=LrQhYoofWK1qIE+Puebb8490xY7FtwOJErFPSvGIMtY=; b=Hb25gviTbrkXk0/UYgdLLtSQjTsI/Gmm0UBDDIXQEEWBB9/5XRqxcccV41EryfcsAT kYReJA5IT/1Y2txk2qUTsf2Q0AaNMkFrbnxbTDZTkQOn2yR4Gm6yTQYdjBv99MwHXzw1 kQIvLc/+r3fkyX2XJvL1fkjugY05b+LmfmvmDCbVo6uI0vWVgM9wRt5Td8yuax1FrpX4 MUhGENkgdkG06EMi8WOBAMgWgdFIUd9Ri4P6ZxUPrKk3pClkNLUftLcy226ebbkE3hhM jy+c2J9JF829Gw8ZdOmny7AwMD2GsuutMO3ytyEWh9WuCUAGjIRN1EEdL6s0IqwJIB9l WpfQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mp6si1159120pjb.53.2021.04.14.17.37.51; Wed, 14 Apr 2021 17:38:03 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351474AbhDNSAT (ORCPT + 99 others); Wed, 14 Apr 2021 14:00:19 -0400 Received: from mail-vs1-f53.google.com ([209.85.217.53]:37687 "EHLO mail-vs1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234303AbhDNSAS (ORCPT ); Wed, 14 Apr 2021 14:00:18 -0400 Received: by mail-vs1-f53.google.com with SMTP id 2so10774755vsh.4; Wed, 14 Apr 2021 10:59:55 -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=LrQhYoofWK1qIE+Puebb8490xY7FtwOJErFPSvGIMtY=; b=shBio9KXJcxBAmzKpdwcUWISMSsYL8M3tQO4z507KY7PgFMkaEswmzkin+rxfTFEUw gE4FBQTec8Moz+tuk7xwCZCQ694Dh34mYn1t3vrNYsTp6XtEo/yIyTOEObyybO6aZjIV +skifyO2nWsM3Z3ijX7gtDpYLtrtzg1JcaveBJzpODOGN1jTKKSRu1aEEGN4IlnfJbct HDplDg8Oc8YQmB06F4JvM8/oyHSW8KbX3UCwkBx7/t2JOamu5s6mlW8VE7omAkYl9bCY w1K2Og6Ug5L+vhdghyXYyoYkr0GknFN1TD18kRjMYxcz+FPdZERqV7nRsbZQvmly1iK3 7FQg== X-Gm-Message-State: AOAM531LqaKLI8iIRXD0m1UWr3iM/H2WaoPWUOy+C92HVyEXlTNx93N6 YjP0GApOe3SOjqCOX6O3o7/nOGUzO3Vp2eRPr8yBXqhjj/o= X-Received: by 2002:a67:80c4:: with SMTP id b187mr29655934vsd.42.1618423195054; Wed, 14 Apr 2021 10:59:55 -0700 (PDT) MIME-Version: 1.0 References: <20210412132619.7896-1-aford173@gmail.com> <20210412132619.7896-2-aford173@gmail.com> In-Reply-To: From: Geert Uytterhoeven Date: Wed, 14 Apr 2021 19:59:43 +0200 Message-ID: Subject: Re: [PATCH V4 2/2] net: ethernet: ravb: Enable optional refclk To: Adam Ford Cc: netdev , Adam Ford-BE , Sergei Shtylyov , "David S. Miller" , Jakub Kicinski , Rob Herring , Linux-Renesas , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Adam, On Wed, Apr 14, 2021 at 3:08 PM Adam Ford wrote: > On Tue, Apr 13, 2021 at 2:33 AM Geert Uytterhoeven wrote: > > On Mon, Apr 12, 2021 at 3:27 PM Adam Ford wrote: > > > For devices that use a programmable clock for the AVB reference clock, > > > the driver may need to enable them. Add code to find the optional clock > > > and enable it when available. > > > > > > Signed-off-by: Adam Ford > > > Reviewed-by: Andrew Lunn > > > > > > --- > > > V4: Eliminate the NULL check when disabling refclk, and add a line > > > to disable the refclk if there is a failure after it's been > > > initialized. > > > > Thanks for the update! > > > > > --- a/drivers/net/ethernet/renesas/ravb_main.c > > > +++ b/drivers/net/ethernet/renesas/ravb_main.c > > > @@ -2148,6 +2148,13 @@ static int ravb_probe(struct platform_device *pdev) > > > goto out_release; > > > } > > > > > > + priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk"); > > > + if (IS_ERR(priv->refclk)) { > > > + error = PTR_ERR(priv->refclk); > > > + goto out_release; > > > > Note that this will call clk_disable_unprepare() in case of failure, which is > > fine, as that function is a no-op in case of a failed clock. > > Geert, > > A bot reported that if I jump to out_release may try to free a clock > if some instances where priv isn't defined. As priv is allocated using alloc_etherdev_mqs(), priv->refclk is NULL initially, but priv itself may indeed not be initialized when the first "goto out_release" is taken. Sorry for missing that. > Currently, the priv->clk isn't freed either. I have heard some > back-and-forth discussions in other threads on whether or not devm > functions auto free or not. The devm_clk_get_optional() will be undone automatically, so there is no need to handle that explicitly. > I'm fine with sending a V5 to make the free for the refclock happen > only when the priv has successfully initialized. Should I also add As this patch has been applied to net-next, you''ll have to send a follow-up fix patch, not a v5. > one for freeing priv->clk and change all the other goto out_release > commands to point to this new section? No, not for priv->clk, due to devm_*(). > I am thinking it would like something like: > > free_refclk: > clk_disable_unprepare(priv->refclk); OK. > free_clk; > clk_disable_unprepare(priv->clk); NAK, as priv->clk is not enabled in ravb_probe(). > out_release: > free_netdev(ndev); > .... OK. Thanks! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds