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=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED autolearn=unavailable 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 3348EC04AAB for ; Tue, 7 May 2019 16:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0442A205ED for ; Tue, 7 May 2019 16:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557245221; bh=txyb9Y+CIwA4enBc2YCDCF+N4hSkRF7C1dUEQSU+8ps=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=Wixx1NgvA41tkIcyoSdZj4XCkmLqpBQJ4zGKCjXDVFayc7pC22a93BM+k1XNCZFtS N88YHglby8LeEHeH8YdueIGGrDbnytz//Qp4es6Uzdlpn/MJzFKsAJ0/KCY58yMePu rIx/Y3B8RcJZQyx6vs2WZWqWep2+7FKVAij1JLg8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727162AbfEGQG7 (ORCPT ); Tue, 7 May 2019 12:06:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:39596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbfEGQG5 (ORCPT ); Tue, 7 May 2019 12:06:57 -0400 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C92720C01; Tue, 7 May 2019 16:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557245215; bh=txyb9Y+CIwA4enBc2YCDCF+N4hSkRF7C1dUEQSU+8ps=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=1J42lltBRC2h71CY4Ic717tbQN1Xvz1Ps7lzeZwtLowbxoYAUY6AN0qduLcIc/+y8 Y8Uu4SXHVXkfeXYxUnhaEuMQc9zLAvpFb3DEcu1j1f5Kv/SmCB7faGdE+CY8WVoU4x 0TqhJ1TLKpgTARHYQNJgI0Xlhi5lKs2UsXwDEM1U= Received: by mail-qt1-f173.google.com with SMTP id i31so19618674qti.13; Tue, 07 May 2019 09:06:55 -0700 (PDT) X-Gm-Message-State: APjAAAXMVKItBO4RfUc7Xj8ZUXnF4EKs42v14VM4r4YgeDOEL3YszJyt Kv7PYxbSMO/ukspusRxlFdJ/TPwni6i6s4bntg== X-Google-Smtp-Source: APXvYqzRisZ+NY+n+aLjSLgDhm39bZicoTuSyfmVwu2JgfiQOEZmLX/TkvP/ZUbPjlIhWr/N5rZYuaWBd0G4e1VyjHY= X-Received: by 2002:aed:2471:: with SMTP id s46mr6955104qtc.144.1557245214590; Tue, 07 May 2019 09:06:54 -0700 (PDT) MIME-Version: 1.0 References: <1556456002-13430-1-git-send-email-ynezz@true.cz> <1556456002-13430-2-git-send-email-ynezz@true.cz> <20190501201925.GA15495@bogus> <20190502090538.GD346@meh.true.cz> In-Reply-To: <20190502090538.GD346@meh.true.cz> From: Rob Herring Date: Tue, 7 May 2019 11:06:43 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/4] of_net: Add NVMEM support to of_get_mac_address To: =?UTF-8?Q?Petr_=C5=A0tetiar?= Cc: netdev , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Andrew Lunn , Florian Fainelli , Heiner Kallweit , Frank Rowand , Srinivas Kandagatla , Maxime Ripard , Alban Bedel , Felix Fietkau , John Crispin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 2, 2019 at 4:05 AM Petr =C5=A0tetiar wrote: > > Rob Herring [2019-05-01 15:19:25]: > > Hi Rob, > > > > + struct property *pp; > > ... > > > > + pp =3D kzalloc(sizeof(*pp), GFP_KERNEL); > > > + if (!pp) > > > + return NULL; > > > + > > > + pp->name =3D "nvmem-mac-address"; > > > + pp->length =3D ETH_ALEN; > > > + pp->value =3D kmemdup(mac, ETH_ALEN, GFP_KERNEL); > > > + if (!pp->value || of_add_property(np, pp)) > > > + goto free; > > > > Why add this to the DT? > > I've just carried it over from v1 ("of_net: add mtd-mac-address support t= o > of_get_mac_address()")[1] as nobody objected about this so far. That's not really a reason... > Honestly I don't know if it's necessary to have it, but so far address, > mac-address and local-mac-address properties provide this DT nodes, so I'= ve > simply thought, that it would be good to have it for MAC address from NVM= EM as > well in order to stay consistent. If you want to be consistent, then fill in 'local-mac-address' with the value from nvmem. We don't need the same thing with a new name added to DT. (TBC, I'm not suggesting you do that here.) But really, my point with using devm_kzalloc() is just return the data, not store in DT and free it when the driver unbinds. Allocating it with devm_kzalloc AND adding it to DT as you've done in v4 leads to 2 entities refcounting the allocation. If the driver unbinds, the buffer is freed, but DT code is still referencing that memory. Also, what happens the 2 time a driver binds? The property would already be in the DT. > > Just FYI, my testing ar9331_8dev_carambola2.dts[2] currently produces > following runtime DT content: > > root@OpenWrt:/# find /sys/firmware/devicetree/ -name *nvmem* -o -name *a= ddr@* > /sys/firmware/devicetree/base/ahb/spi@1f000000/flash@0/partitions/partit= ion@ff0000/nvmem-cells > /sys/firmware/devicetree/base/ahb/spi@1f000000/flash@0/partitions/partit= ion@ff0000/nvmem-cells/eth-mac-addr@0 > /sys/firmware/devicetree/base/ahb/spi@1f000000/flash@0/partitions/partit= ion@ff0000/nvmem-cells/eth-mac-addr@6 > /sys/firmware/devicetree/base/ahb/spi@1f000000/flash@0/partitions/partit= ion@ff0000/nvmem-cells/wifi-mac-addr@1002 > /sys/firmware/devicetree/base/ahb/wmac@18100000/nvmem-cells > /sys/firmware/devicetree/base/ahb/wmac@18100000/nvmem-mac-address > /sys/firmware/devicetree/base/ahb/wmac@18100000/nvmem-cell-names > /sys/firmware/devicetree/base/ahb/eth@1a000000/nvmem-cells > /sys/firmware/devicetree/base/ahb/eth@1a000000/nvmem-mac-address > /sys/firmware/devicetree/base/ahb/eth@1a000000/nvmem-cell-names > /sys/firmware/devicetree/base/ahb/eth@19000000/nvmem-cells > /sys/firmware/devicetree/base/ahb/eth@19000000/nvmem-mac-address > /sys/firmware/devicetree/base/ahb/eth@19000000/nvmem-cell-names 'nvmem-mac-address' is not a documented property. That would need to be documented before using upstream. Though, for reasons above, I don't think it should be. Rob