From patchwork Mon Nov 20 08:45:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu X-Patchwork-Id: 13460937 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="pmrFMg4J" Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55528AA for ; Mon, 20 Nov 2023 00:46:22 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3316ad2bee5so1694707f8f.1 for ; Mon, 20 Nov 2023 00:46:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1700469981; x=1701074781; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cp/UKHVnA714ikdJHZcbqGoPP5UR9IDH6yqWS6ig3mM=; b=pmrFMg4J196kShqfjSh2VBLm0SzHZsKZj+uD7XU4nNdfVg7EJm3DRaouPPq6JE1VV/ TFBguly6ExckGVq2Z/Ck6g3mXbNXEbSdFFu2+uh1BKNZxYzvB1/WN2yZwwP0SdW9Go+P /ehFdaz1+kQRhQmQkQpkg4eBy3/2Y8pRecfE2NMezpOfMS4W1CX+xZwEWfxetxAwjFti e4Bz5bwIPGfyCOxJi/9M0rTgU4RjlFdE9Mn/SblEOGyEYinEhWMc9vUhMgePN648KkGn i7/AvH0d4dhl4mjV05fl4C4eQr3MEBi0LG/idtAmANe/kJmKb/a0aMYJmCtZv/Th0H+I IPgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700469981; x=1701074781; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cp/UKHVnA714ikdJHZcbqGoPP5UR9IDH6yqWS6ig3mM=; b=QNJpdgZZQitYqxBjCrmRuLQml6cujfK5QryyduDP8gz6LgV+BmUR8EaqEHmyD8t7Th 3j1/uogspGgZjbshwHnf5MIOg5GVy7f7EYCpVZLAQ9MsA9eI6ZVnv4EzvLLhFXxMzoR0 U+gGaL01QfD4humBnlRryVmJUk66unZrLZEMyQUXpT1k/FD+UlK5hQNIR3xJwpaXx6Y7 8g/yNHY4FIsH00LilrNbWgNkZW57Qx8HMj/wU8AO4St8ferA9suikHsAc1C6JHXXLYze hLm/oVYrwAQ4XA0BLZsJnwrExjYa7DDmF2hresDuxN6RTcNR6Wgbv9VjpMwi4UNbgBs0 fvWw== X-Gm-Message-State: AOJu0YyPf27XZlJL3Qm4d6OgJrayCw++VenM13abbF1DXnSaqb9TXHUa HI6I9S1tjSjxTt9OvIhH5+W87g== X-Google-Smtp-Source: AGHT+IFDUtcL/kItW6Ct8wAYuHmG27hXUs5xVSozigyLzY20qpW+SnjNg8LDtQ8uSwnwos1Zsdc1hA== X-Received: by 2002:a05:6000:108f:b0:331:6cfd:e2fc with SMTP id y15-20020a056000108f00b003316cfde2fcmr3780250wrw.21.1700469980699; Mon, 20 Nov 2023 00:46:20 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.183]) by smtp.gmail.com with ESMTPSA id b8-20020a5d45c8000000b003142e438e8csm10435267wrs.26.2023.11.20.00.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 00:46:20 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, geert+renesas@glider.be, wsa+renesas@sang-engineering.com, biju.das.jz@bp.renesas.com, prabhakar.mahadev-lad.rj@bp.renesas.com, sergei.shtylyov@cogentembedded.com, mitsuhiro.kimura.kc@renesas.com, masaru.nagai.vx@renesas.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH 02/13] net: ravb: Use pm_runtime_resume_and_get() Date: Mon, 20 Nov 2023 10:45:55 +0200 Message-Id: <20231120084606.4083194-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120084606.4083194-1-claudiu.beznea.uj@bp.renesas.com> References: <20231120084606.4083194-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea pm_runtime_get_sync() may return with error. In case it returns with error dev->power.usage_count needs to be decremented. pm_runtime_resume_and_get() takes care of this. Thus use it. Along with this pm_runtime_resume_and_get() and reset_control_deassert() were moved before alloc_etherdev_mqs() to simplify the error path. Also, in case pm_runtime_resume_and_get() returns error the reset signal is deasserted and runtime PM is disabled (by jumping to the proper error handling label). Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper") Signed-off-by: Claudiu Beznea --- drivers/net/ethernet/renesas/ravb_main.c | 28 +++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 342978bdbd7e..0486add302b3 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2635,25 +2635,26 @@ static int ravb_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(rstc), "failed to get cpg reset\n"); + error = reset_control_deassert(rstc); + if (error) + return error; + + pm_runtime_enable(&pdev->dev); + error = pm_runtime_resume_and_get(&pdev->dev); + if (error < 0) + goto pm_runtime_disable; + ndev = alloc_etherdev_mqs(sizeof(struct ravb_private), NUM_TX_QUEUE, NUM_RX_QUEUE); - if (!ndev) - return -ENOMEM; - + if (!ndev) { + error = -ENOMEM; + goto pm_runtime_put; + } info = of_device_get_match_data(&pdev->dev); ndev->features = info->net_features; ndev->hw_features = info->net_hw_features; - error = reset_control_deassert(rstc); - if (error) { - free_netdev(ndev); - return error; - } - - pm_runtime_enable(&pdev->dev); - pm_runtime_get_sync(&pdev->dev); - if (info->multi_irqs) { if (info->err_mgmt_irqs) irq = platform_get_irq_byname(pdev, "dia"); @@ -2878,8 +2879,9 @@ static int ravb_probe(struct platform_device *pdev) clk_disable_unprepare(priv->refclk); out_release: free_netdev(ndev); - +pm_runtime_put: pm_runtime_put(&pdev->dev); +pm_runtime_disable: pm_runtime_disable(&pdev->dev); reset_control_assert(rstc); return error;