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=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 804CCC43215 for ; Mon, 25 Nov 2019 15:23:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 508CC2082F for ; Mon, 25 Nov 2019 15:23:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="mijzQuOf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728540AbfKYPXQ (ORCPT ); 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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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