Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp715031ybj; Thu, 7 May 2020 06:05:52 -0700 (PDT) X-Google-Smtp-Source: APiQypKBek++qDdeTgX2tMqkGccTFM10O6ZzWUbHkg7+RGghTc/p14f1CDLEHknB+V4Fq5cbGPhF X-Received: by 2002:a05:6402:3047:: with SMTP id bu7mr11781625edb.303.1588856751942; Thu, 07 May 2020 06:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588856751; cv=none; d=google.com; s=arc-20160816; b=GFgMHSL9iMoDCIRKwM87gGFZSBw+ZqQfkdCRWRxBDqojYNZNh2t6whJp3FYvnNO3bS u9xa54wgdBMXJCIG/qAb4E4GyGXVgml4DHwttXsBos0wyguHJutqSkOiQpPR3oIT3rCk WxkZ9l1Rx6J0jctvvZPwfPcR17Izti4mv5bwuNW6jb+GQCf8FeVFtUGyBWLHU0HmoZwd 8fd2dgZuyF0X4PA022M+RV8wYMea3vW2p1sAHpCXIpIkniKPHd7tZdV2sWMvqgxqwgLu JQgX0rCgL435RNXXMSZo3a5wdIdDIznRSJV6OwoQ+TAtV23/s9v1R6MTvO5Qk6qDbXXI C5GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Z6KuXtJXawSDTaJcg/aiiJZVD/MQw/2EooMYHaz1n38=; b=0W6frmjwPwutujFalnm7wcVKmeI9bhOw6IQKcPFCkY9lcRQVsgZjpbzN+63osIB4c8 nnQp48mILulD8pTu0x5xEJmSSy72IsTFUqt/kcUW3OXNAATtG4/JYTyuLfoixD01jLAF p4cUFlM4Rid0FtBVHvxtnx/FsIh7tqH3nlJrZGuuTF+oDADMeleygxIHxraerKlKP2IU H2c8iDMF74pfptyGgMaoeDsXZ/2nBSg4gJA3r8BJbZkdGiXQD4DZVlAo0jpeVF++tgGz CKARplIKeAehabL1WrqiX37Q7LNwXU8xQ/KivZZoZ608M6JR7nR16c11OAASud3bfcUw 6E2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=NZBesiYZ; 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 e16si922443ejx.37.2020.05.07.06.05.24; Thu, 07 May 2020 06:05:51 -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; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=NZBesiYZ; 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 S1726514AbgEGNC7 (ORCPT + 99 others); Thu, 7 May 2020 09:02:59 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:47150 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbgEGNC7 (ORCPT ); Thu, 7 May 2020 09:02:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Z6KuXtJXawSDTaJcg/aiiJZVD/MQw/2EooMYHaz1n38=; b=NZBesiYZmcT+GQ5aRvDvCuwRji QfXQu2V3SjosPKNkKlqCn8dK0a8Ur+VYM1W3x7AvNkKXbEVves+KKczOEdnKRPJ4JEMtyvJSZLR0B RyGvIrnev+ogcbU0gC+8OUuMJVc0Xzv19/0BrS9/gA9oywKOD3dMQfoAlgDZBYAcyo+w=; Received: from andrew by vps0.lunn.ch with local (Exim 4.93) (envelope-from ) id 1jWgAt-001Dto-76; Thu, 07 May 2020 15:02:51 +0200 Date: Thu, 7 May 2020 15:02:51 +0200 From: Andrew Lunn To: Florian Fainelli Cc: Vivien Didelot , netdev@vger.kernel.org, olteanv@gmail.com, "David S. Miller" , Jakub Kicinski , open list Subject: Re: [RFC net] net: dsa: Add missing reference counting Message-ID: <20200507130251.GL208718@lunn.ch> References: <20200505210253.20311-1-f.fainelli@gmail.com> <20200505172302.GB1170406@t480s.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 06, 2020 at 02:24:14PM -0700, Florian Fainelli wrote: > > > On 5/5/2020 2:23 PM, Vivien Didelot wrote: > > On Tue, 5 May 2020 14:02:53 -0700, Florian Fainelli wrote: > >> If we are probed through platform_data we would be intentionally > >> dropping the reference count on master after dev_to_net_device() > >> incremented it. If we are probed through Device Tree, > >> of_find_net_device() does not do a dev_hold() at all. > >> > >> Ensure that the DSA master device is properly reference counted by > >> holding it as soon as the CPU port is successfully initialized and later > >> released during dsa_switch_release_ports(). dsa_get_tag_protocol() does > >> a short de-reference, so we hold and release the master at that time, > >> too. > >> > >> Fixes: 83c0afaec7b7 ("net: dsa: Add new binding implementation") > >> Signed-off-by: Florian Fainelli > > > > Reviewed-by: Vivien Didelot > > > Andrew, Vladimir, any thoughts on that? Hi Florian Have you looked at how other stacked drivers do this? bond/team, vlan, bridge, BATMAN? Do we maybe need to subscribe to the master devices notifier chain, and do a tear down when the device is removed? Andrew