Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4478982imw; Tue, 19 Jul 2022 07:22:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tGRn/i3TOBTkefE5J39IH3rcVcnJnFFhe1w58349raFsT5EnM5IfV9xR2JhiV1ivpBswkj X-Received: by 2002:a05:6808:1496:b0:33a:6d79:1e0c with SMTP id e22-20020a056808149600b0033a6d791e0cmr6702943oiw.182.1658240547112; Tue, 19 Jul 2022 07:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658240547; cv=none; d=google.com; s=arc-20160816; b=baqwVqZWRmFeRE0ZEDxZ0PUW+uS1UnYxMxkroYsxBIU/c7O0C3THx6fGtjpPdNOjnU aO9us+XicGabQAR4AmnlxFARFYqepAsBiBu3SK6EzsihHLiV6PjtvaWRVt3a609adMPQ FZlpUPk2EsLuF1EuR30f3NvjxKgWfKBvdrP85lwYtZhHvMVYZFg6gGxVrJ5Z84XsZ3O+ 9j6Wa66BSOo2CiTGwCrpJAA2+PuYpc6IxR6Sdv/fHPNNKN3HbpeGDJm9sb5SMU7+i7AE 7Z1H+fJRTpQKAiMx6BPKdNU88RCLfZ9F6qtTgsxpkg8p/ifE/36PSnppzjMHWYBcSDDI XkfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TICEpGQ6AncKbAJRlH5R7h1pURM/tmlquuTa4aR2amQ=; b=jgNtWQ+O8jW3bQ/9o3a73BCMo9rTgMi0rGCa2Mmrg/mvihyCcXsKvkrpvMJEzscR88 6b7jE2DMbvCjw5EsXrpVd176DKJujzzIPsmK1GSzYi6RvGsEt/bCBahrEz3V4cl1li+P 2XO+1u6VYDfKCXptiNFFKSMmgQlwF/x3X6nwEEfEzkrBgA08Iz4Dsb2NbFja4eeR7eth j5w1P2hMq9Ye7zE7YWiT78bSxAZaVa7fhKUCDeSUSEfkBIC9caCROHCBDqbRQTCkjcK6 dbVMkGP63sbHycGmrSUgxNdpJ1pjANQzscVaJKoHHIJg9PAAE4RWkrpibmRkdDOGTWcA xoxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gCn9sPY6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a056870f28b00b000f2d840050asi14333955oap.149.2022.07.19.07.22.13; Tue, 19 Jul 2022 07:22:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gCn9sPY6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240885AbiGSMhE (ORCPT + 99 others); Tue, 19 Jul 2022 08:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238347AbiGSMgW (ORCPT ); Tue, 19 Jul 2022 08:36:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23E3F1EAFB; Tue, 19 Jul 2022 05:14:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 13B6BB81B37; Tue, 19 Jul 2022 12:13:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56BB3C341C6; Tue, 19 Jul 2022 12:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232802; bh=EuBfvooEShle36Ymb8/NN7rUAZS38Mpq4oSHSzKHNew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gCn9sPY68SwzIGk+0WUOzNO8wgS6YXgI+A4QR9TX9M/D4liwpChr9gmqS4oqmwqLc SnqKocrZ+jSw/xeBpTQgR9zvkoRB30tkc8s0K2fUePtQXNzxf8barrWRTCM+vkFU6R 5n2VIcbNJdfpOn2ce0IZRsl0xxKxM90cgrcIHOag= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Siddharth Vadapalli , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 050/167] net: ethernet: ti: am65-cpsw: Fix devlink port register sequence Date: Tue, 19 Jul 2022 13:53:02 +0200 Message-Id: <20220719114701.456218440@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Siddharth Vadapalli [ Upstream commit 0680e20af5fbf41df8a11b11bd9a7c25b2ca0746 ] Renaming interfaces using udevd depends on the interface being registered before its netdev is registered. Otherwise, udevd reads an empty phys_port_name value, resulting in the interface not being renamed. Fix this by registering the interface before registering its netdev by invoking am65_cpsw_nuss_register_devlink() before invoking register_netdev() for the interface. Move the function call to devlink_port_type_eth_set(), invoking it after register_netdev() is invoked, to ensure that netlink notification for the port state change is generated after the netdev is completely initialized. Fixes: 58356eb31d60 ("net: ti: am65-cpsw-nuss: Add devlink support") Signed-off-by: Siddharth Vadapalli Link: https://lore.kernel.org/r/20220706070208.12207-1-s-vadapalli@ti.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index ea9d073e87fa..901571c2626a 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -2467,7 +2467,6 @@ static int am65_cpsw_nuss_register_devlink(struct am65_cpsw_common *common) port->port_id, ret); goto dl_port_unreg; } - devlink_port_type_eth_set(dl_port, port->ndev); } return ret; @@ -2514,6 +2513,7 @@ static void am65_cpsw_unregister_devlink(struct am65_cpsw_common *common) static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common) { struct device *dev = common->dev; + struct devlink_port *dl_port; struct am65_cpsw_port *port; int ret = 0, i; @@ -2530,6 +2530,10 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common) return ret; } + ret = am65_cpsw_nuss_register_devlink(common); + if (ret) + return ret; + for (i = 0; i < common->port_num; i++) { port = &common->ports[i]; @@ -2542,25 +2546,24 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common) i, ret); goto err_cleanup_ndev; } + + dl_port = &port->devlink_port; + devlink_port_type_eth_set(dl_port, port->ndev); } ret = am65_cpsw_register_notifiers(common); if (ret) goto err_cleanup_ndev; - ret = am65_cpsw_nuss_register_devlink(common); - if (ret) - goto clean_unregister_notifiers; - /* can't auto unregister ndev using devm_add_action() due to * devres release sequence in DD core for DMA */ return 0; -clean_unregister_notifiers: - am65_cpsw_unregister_notifiers(common); + err_cleanup_ndev: am65_cpsw_nuss_cleanup_ndev(common); + am65_cpsw_unregister_devlink(common); return ret; } -- 2.35.1