Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2996170ybc; Mon, 25 Nov 2019 07:25:46 -0800 (PST) X-Google-Smtp-Source: APXvYqz7G2iJdf6NxOgDwl+q+HvVjvsvFcq5P2vRnp1o70cQt7MZoGnU5yqcbBifXfuxUddXJNex X-Received: by 2002:a17:906:7c4e:: with SMTP id g14mr37241339ejp.150.1574695546705; Mon, 25 Nov 2019 07:25:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574695546; cv=none; d=google.com; s=arc-20160816; b=Hyt2E8f1JaUgQPWEc7DY4H6WffCkzUxebyaXPznV3Kkh5EvYp6BBeoslZ/jEReuEUT ecFNTZad3K/k59/aa0Is8kASpunq4bXcMnP9mywJXdmKij3hCyMXweeLpgvEauHthPCs hF/56nz/e1WTak/py9r/NTBi4ky63at/0XMYXuZYL9sYOPwm0k3lM9HhV+2PBD9I6zib wbDeehh/Fqp0jgYE/Mn1VXpASeJxaaMoEygO8QBPr+gQBj5xIH1U++7Z68XVFYguD2Cy iX6KFNUy8stxYysyQIi8vRe2cwBe7oTyvmgcSRzs5LIfm0VqPqE1iNW9HewpPtVUk9fH aAgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=QxQNDY3h4QEH/474FEBZsr50zPaZur7gyEqjwq7sTZM=; b=aFoP9QdWHDAofmTJ1xcAMYLdejBECaNXAHt/vqo7H3OdZbN+8yXGq9ZWnqAVLlQ0g7 NOX7fKPxJafaXCieeJSEMtWxX28LPVgPE0pJuzYMsMMxPl/5v1oOLfg/inNEvCorba+S cXvDXg/8IhP8j0f4WVhMj8cyL5Hq4yimzFZUstxJhjKiZubUjoD+E3agM6aFdrfipF3t sn+Y+1XVYzdLtK3X5QR6ErOC6fkySN9EqeaLZ4X09u9wJZa3JD3fxNQeNXuimrxT7kbQ NyQVHAofnI1I0ZzycqLxHJwTlIzP0dULJXyirHRIBzgfEeYu2j542Q6T2SHorqhxuFcb 9AGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=mijzQuOf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y23si4723784edt.366.2019.11.25.07.25.22; Mon, 25 Nov 2019 07:25:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=mijzQuOf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728541AbfKYPXQ (ORCPT + 99 others); Mon, 25 Nov 2019 10:23:16 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:55312 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727785AbfKYPXQ (ORCPT ); Mon, 25 Nov 2019 10:23:16 -0500 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=QxQNDY3h4QEH/474FEBZsr50zPaZur7gyEqjwq7sTZM=; b=mijzQuOfdJ4Y2MJffDpDWUAHJU zAmGh+pHy/bdZumijvMa5jTNBetlh8xEgic7xoCr5sdF5V569i4n4u9j+44Rm+BE/0FhjF9AGp4pL qlxWvESVzBxgOLE7kKvNRpM1iR3tnv/jrHAlPTkezhYDGCk0QbxeQdUjKAgK6tlTQOXk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.92.2) (envelope-from ) id 1iZGCm-0007xf-FU; Mon, 25 Nov 2019 16:23:12 +0100 Date: Mon, 25 Nov 2019 16:23:12 +0100 From: Andrew Lunn To: Vladimir Oltean Cc: Oleksij Rempel , mkl@pengutronix.de, Vivien Didelot , Florian Fainelli , "David S. Miller" , kernel@pengutronix.de, netdev , lkml , david@protonic.nl Subject: Re: [PATCH v1 1/2] net: dsa: sja1105: print info about probet chip only after every thing was done. Message-ID: <20191125152312.GJ6602@lunn.ch> References: <20191125100259.5147-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > If you want to actually fix something, there is also a memory leak > related to this. It is present in most DSA drivers. When > dsa_register_switch returns -EPROBE_DEFER, anything allocated with > devm_kzalloc will be overwritten and the old memory will leak. There is a rather unfortunate chicken/egg problem here for any switch using MDIO. At the moment i don't know how to solve it. As a result the first probe is pretty much guaranteed to return -EPROBE_DEFER. The problem is that the MAC driver registers its MDIO bus. That causes the DT to be walked for the bus and the switch probed. The switch probe registers the switch with the DSA core. It then tries to get a handle on the master device. But the MAC driver has not called netdev_register() yet, it is busy registering its MDIO bus. So the master device is not there, and so we get a -EPROBE_DEFER and the switch driver needs to unwind. So for an MDIO switch, i suggest the probe it kept to a minimum, and all the real work is done in the setup callback. Setup is called when all resources the DSA core needs are available. I've got a patch somewhere for mv88e6xxx which does this move, and it cut boot time by a noticeable amount. Andrew