Message ID | 20231022151911.4279-1-aford173@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp813295vqx; Sun, 22 Oct 2023 08:21:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvjRQorSXJPJqrAspqZ8jk8vsoWssTq1Le7FR45LG3lbtsjYBVXuCy5Y+4rYver+4ksAJs X-Received: by 2002:a05:6a00:189c:b0:6bd:254a:8876 with SMTP id x28-20020a056a00189c00b006bd254a8876mr5927268pfh.23.1697988071345; Sun, 22 Oct 2023 08:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697988071; cv=none; d=google.com; s=arc-20160816; b=vMoAyY4Y3df8kNpfZWzMo5hii1f6VoDf4cl1izSrChE28nJoH34+OdIY0OcL3jxNp6 qijqOs5un4uD++Y5khlF+j/0G4RGqwunRVZmmudtygTReTKvH5iNuflGK1JR2gT1n0PI PihFk87IRVrpsVWtwsHRgQRduj3HNKjFj4HJIMm1WypVb8OnP42UHZUwSopUBm74YkIf D4s0u4KY0DteBcXtDh+jn46Oy2oFTG1GmgrABZgB8w29rVax1c4jXER/k4QHp8BdSc0c TrChxBdUXbmFBS/4yYv8jTVd4LZfDCCdoZiyLeUELwkAALuZQIaYVx/e7l4ulCul+LIt bw/A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=FmSfe58FfVT1+C5BDfWt5zaNsraT3ia/sP6v6KkffFo=; fh=O90CjnX46wCdbUBO0on215waJEIuFhHTpk73dQ6e38A=; b=vQNx/g1tDNm1ixdu9c65rRbOu7K3vN1cd/kcvrbz6apSXgfVrdpEciYQZ3gmiWZX4w WhGFDyb4xBf1Mms/J8KdU9sOqxn7Ms+toZ5vmtPm6fanEtmNClpIAj1Avk4j+0TkqO9f OwvYb9IKT0uJ/U0tMhrkWH4iWY76ldaJshhVmyIYLjHHfsyRpeGNeLVPMqtsmunHkfFW eZoc3+uaO3NabMciR0DT91vdvzWfMFvDRBMo3z/euN2+lKdTxBi03EJKXykamVvCmzuQ 7+iWUE4zcSYIQdR/IMDHqItFsNYh4llfPF4qByrVccRwo1YuUqaHqLmrXwN7lE/7Vk6Z fnoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KBLZ88Ai; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ck7-20020a056a00328700b006bf2e5f0840si4011548pfb.67.2023.10.22.08.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 08:21:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KBLZ88Ai; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 597B0807C855; Sun, 22 Oct 2023 08:20:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbjJVPT0 (ORCPT <rfc822;a1648639935@gmail.com> + 27 others); Sun, 22 Oct 2023 11:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjJVPTY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 22 Oct 2023 11:19:24 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63B90F4; Sun, 22 Oct 2023 08:19:22 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-7789aed0e46so176735285a.0; Sun, 22 Oct 2023 08:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697987961; x=1698592761; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FmSfe58FfVT1+C5BDfWt5zaNsraT3ia/sP6v6KkffFo=; b=KBLZ88Aiv2ZHtpomUHwExfmgCScpEe5auOh5on9De+5JWbcUdJJNfuNvF95hnQTSbR NClHioRXr6wPajPBRa+9Wq5nBmKZTtBKu0R5A5jqe5Dz9RZ37D8BHRDN7oVV3Xh7mgVF jZE/K2Yk9YUUm4ZK/sLwDu4A9b6Ek8edipmGKmemXe6JVXaZQo/Yi7oH0Q3VreXxl6C3 kS47Ty+mqGwSXgYT5eUeDVObJbloQQ+mRxs3IaONj1H3XgJAUdsGO0TnPUiZRpYFJeJh LBTYUppDV+28YaKIfeLyzRGjtBYWcydWuy5WZt0gphflSCFdvPhHQu8ojdiAZJd5n7LQ jIlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697987961; x=1698592761; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FmSfe58FfVT1+C5BDfWt5zaNsraT3ia/sP6v6KkffFo=; b=JRcHccqP3ynaiIvggexbQDcmNUMeWhKHDxyTC26SmjNRW63DnyXtjd+fAawMt4S+bW G3XNdoBPi1gUZkfueUUdNxjr6Vazl8mp7ZIrCD2rdtrpq1LwstyftTxDd2FHXiyekjHc UcbaKCMxZ0ubNw60/v48R0o64ayP6plmxwcoRhg/BvnI8Ic0sEo7YIAIiHzugZZZuY0G 9OGy4Uy4rkn+rzht2aQAXu5+1VSo4NNemtluaXZB6sPXE1jskJzCFJcLfm7dMDvB0AFH c5+ZcJfnlB85+UycNEJAdkeEO/3ckNdoOtNGGeVftyHRcZA6wh8P6ghDQV+mcGjR8P1q dYVQ== X-Gm-Message-State: AOJu0YzjAsN+JZRl5NzfjAcmjHRAjfxIV60G+6wDAV4nrlSUwCwGFZ47 tB2sBLayq7tm14oTHCKB+isk9dB+9jI= X-Received: by 2002:a05:620a:444c:b0:777:27f9:7e54 with SMTP id w12-20020a05620a444c00b0077727f97e54mr9324065qkp.50.1697987960936; Sun, 22 Oct 2023 08:19:20 -0700 (PDT) Received: from aford-System-Version.lan ([2601:447:d002:5be:a07c:e734:336b:c675]) by smtp.gmail.com with ESMTPSA id m26-20020ae9e01a000000b007726002d69esm2084375qkk.10.2023.10.22.08.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 08:19:20 -0700 (PDT) From: Adam Ford <aford173@gmail.com> To: netdev@vger.kernel.org Cc: aford@beaconembedded.com, Adam Ford <aford173@gmail.com>, Andrew Lunn <andrew@lunn.ch>, Grygorii Strashko <grygorii.strashko@ti.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2] net: ethernet: davinci_emac: Use MAC Address from Device Tree Date: Sun, 22 Oct 2023 10:19:11 -0500 Message-Id: <20231022151911.4279-1-aford173@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 22 Oct 2023 08:20:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780469539699064680 X-GMAIL-MSGID: 1780469539699064680 |
Series |
[V2] net: ethernet: davinci_emac: Use MAC Address from Device Tree
|
|
Commit Message
Adam Ford
Oct. 22, 2023, 3:19 p.m. UTC
Currently there is a device tree entry called "local-mac-address" which can be filled by the bootloader or manually set.This is useful when the user does not want to use the MAC address programmed into the SoC. Currently, the davinci_emac reads the MAC from the DT, copies it from pdata->mac_addr to priv->mac_addr, then blindly overwrites it by reading from registers in the SoC, and falls back to a random MAC if it's still not valid. This completely ignores any MAC address in the device tree. In order to use the local-mac-address, check to see if the contents of priv->mac_addr are valid before falling back to reading from the SoC when the MAC address is not valid. Signed-off-by: Adam Ford <aford173@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> --- V2: Rebase, add R-B tag, and post stand-alone for netdev branch, since the device tree patch has already been accepted via the omap tree.
Comments
On 10/22/2023 8:19 AM, Adam Ford wrote: > Currently there is a device tree entry called "local-mac-address" > which can be filled by the bootloader or manually set.This is > useful when the user does not want to use the MAC address > programmed into the SoC. > > Currently, the davinci_emac reads the MAC from the DT, copies > it from pdata->mac_addr to priv->mac_addr, then blindly overwrites > it by reading from registers in the SoC, and falls back to a > random MAC if it's still not valid. This completely ignores any > MAC address in the device tree. > > In order to use the local-mac-address, check to see if the contents > of priv->mac_addr are valid before falling back to reading from the > SoC when the MAC address is not valid. > > Signed-off-by: Adam Ford <aford173@gmail.com> > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > --- > V2: Rebase, add R-B tag, and post stand-alone for netdev branch, since > the device tree patch has already been accepted via the omap tree. Looks like you didn't add the tag for which tree. Given the context, I would assume net-next. Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
On Mon, Oct 23, 2023 at 7:14 PM Jacob Keller <jacob.e.keller@intel.com> wrote: > > > > On 10/22/2023 8:19 AM, Adam Ford wrote: > > Currently there is a device tree entry called "local-mac-address" > > which can be filled by the bootloader or manually set.This is > > useful when the user does not want to use the MAC address > > programmed into the SoC. > > > > Currently, the davinci_emac reads the MAC from the DT, copies > > it from pdata->mac_addr to priv->mac_addr, then blindly overwrites > > it by reading from registers in the SoC, and falls back to a > > random MAC if it's still not valid. This completely ignores any > > MAC address in the device tree. > > > > In order to use the local-mac-address, check to see if the contents > > of priv->mac_addr are valid before falling back to reading from the > > SoC when the MAC address is not valid. > > > > Signed-off-by: Adam Ford <aford173@gmail.com> > > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > > --- > > V2: Rebase, add R-B tag, and post stand-alone for netdev branch, since > > the device tree patch has already been accepted via the omap tree. > > Looks like you didn't add the tag for which tree. Given the context, I > would assume net-next. > That was my intent. I sent the e-mail to netdev and CC'd others. I thought that was enough. > Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
On Mon, 2023-10-23 at 20:22 -0500, Adam Ford wrote: > On Mon, Oct 23, 2023 at 7:14 PM Jacob Keller <jacob.e.keller@intel.com> wrote: > > Looks like you didn't add the tag for which tree. Given the context, I > > would assume net-next. > > That was my intent. I sent the e-mail to netdev and CC'd others. I > thought that was enough. For future submissions: there are 2 different netdev trees, one for new features (net-next) and another one for bugfixes (net), and you should specify the target explcitly in the patch prefix. See: Documentation/process/maintainer-netdev.rst for the more details. Looks like this one is targeting net-next. Cheers, Paolo
Hello: This patch was applied to netdev/net-next.git (main) by Paolo Abeni <pabeni@redhat.com>: On Sun, 22 Oct 2023 10:19:11 -0500 you wrote: > Currently there is a device tree entry called "local-mac-address" > which can be filled by the bootloader or manually set.This is > useful when the user does not want to use the MAC address > programmed into the SoC. > > Currently, the davinci_emac reads the MAC from the DT, copies > it from pdata->mac_addr to priv->mac_addr, then blindly overwrites > it by reading from registers in the SoC, and falls back to a > random MAC if it's still not valid. This completely ignores any > MAC address in the device tree. > > [...] Here is the summary with links: - [V2] net: ethernet: davinci_emac: Use MAC Address from Device Tree https://git.kernel.org/netdev/net-next/c/f30a51a41828 You are awesome, thank you!
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 23f8bc1cd20d..b0950a318c42 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1928,18 +1928,20 @@ static int davinci_emac_probe(struct platform_device *pdev) goto err_free_rxchan; ndev->irq = rc; - rc = davinci_emac_try_get_mac(pdev, res_ctrl ? 0 : 1, priv->mac_addr); - if (!rc) - eth_hw_addr_set(ndev, priv->mac_addr); - + /* If the MAC address is not present, read the registers from the SoC */ if (!is_valid_ether_addr(priv->mac_addr)) { - /* Use random MAC if still none obtained. */ - eth_hw_addr_random(ndev); - memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len); - dev_warn(&pdev->dev, "using random MAC addr: %pM\n", - priv->mac_addr); + rc = davinci_emac_try_get_mac(pdev, res_ctrl ? 0 : 1, priv->mac_addr); + if (!rc) + eth_hw_addr_set(ndev, priv->mac_addr); + + if (!is_valid_ether_addr(priv->mac_addr)) { + /* Use random MAC if still none obtained. */ + eth_hw_addr_random(ndev); + memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len); + dev_warn(&pdev->dev, "using random MAC addr: %pM\n", + priv->mac_addr); + } } - ndev->netdev_ops = &emac_netdev_ops; ndev->ethtool_ops = ðtool_ops; netif_napi_add(ndev, &priv->napi, emac_poll);