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.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham 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 A46FEC169C4 for ; Mon, 11 Feb 2019 17:51:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F9B4218D8 for ; Mon, 11 Feb 2019 17:51:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=aruba.it header.i=@aruba.it header.b="Nj9TvZ3k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729293AbfBKRvY (ORCPT ); Mon, 11 Feb 2019 12:51:24 -0500 Received: from smtpcmd0871.aruba.it ([62.149.156.71]:57414 "EHLO smtpcmd0871.aruba.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbfBKRvY (ORCPT ); Mon, 11 Feb 2019 12:51:24 -0500 Received: from [192.168.0.102] ([93.146.66.165]) by smtpcmd08.ad.aruba.it with bizsmtp id bVrJ1z00D3Zw7e501VrJ1j; Mon, 11 Feb 2019 18:51:21 +0100 Subject: Re: Possible bug into DSA2 code. To: Florian Fainelli , Andrew Lunn Cc: Vivien Didelot , "David S. Miller" , netdev@vger.kernel.org References: <528f797d-445b-a314-d8ef-db15a3b6a8ce@enneenne.com> <20190209193409.GI30856@lunn.ch> <084b3973-88b9-8c71-50d5-9d773999ad04@enneenne.com> From: Rodolfo Giometti Message-ID: <49728829-49cc-6d6a-04b1-ccfc1e5266dd@enneenne.com> Date: Mon, 11 Feb 2019 18:51:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aruba.it; s=a1; t=1549907481; bh=sh2fZ0EEi6MPXdl+CWJf+yAEJn58oRE1qMdjDNq70nE=; h=Subject:To:From:Date:MIME-Version:Content-Type; b=Nj9TvZ3k8bg8z45LDzEMKfXnlfCYXl2uLuXSwPNzVTgMz73JACz5ZefVZkDoTc2cN 6IB1mh0oS1kH5cf6MawfEtRns3lUI9qi33zASOWlUh18/ln9+dGr/xyK9ks6bWV4zD XG2cIMtactTn/7iSfWPg1Wlm6k+37mp1Xiui1oUZHj0+smff6w4l98HxflbZWetv4t /W/7pVnxAzo0TyINpY7clypsy7ijqtsY9utYNZbK8El4rLvdDOlsWBe9Z34Xue5MUL EbNdB5TsMLiBHYYIsyfPOsm+cVcZT3F9NOImWNQmxLR4KrNsj9XpFgpBuOFEoKzae6 erJQX0HbmCKgA== Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 11/02/2019 18:28, Florian Fainelli wrote: > On 2/10/19 3:45 AM, Rodolfo Giometti wrote: >> On 09/02/2019 20:34, Andrew Lunn wrote: >>>> So we I see two possible solutions: >>>> >>>> 1) having both ds->slave_mii_bus and ds->ops->phy_read already >>>> defined is an >>>> error, then it must be signaled to the calling code, or >>> >>> I don't think we can do that. mv88e6xxx optionally instantiates the >>> MDIO busses, depending on what is in device tree. If there is no mdio >>> property, we need the DSA core to create an MDIO bus. >> >> OK, but using the following check to know if DSA did such allocation is >> not correct because DSA drivers can allocate it by their own: >> >> static void dsa_switch_teardown(struct dsa_switch *ds) >> { >>         if (ds->slave_mii_bus && ds->ops->phy_read) >>                 mdiobus_unregister(ds->slave_mii_bus); >> >> Maybe can we add a flag to register ds->slave_mii_bus allocation by DSA? > > If drivers allocate the slave_mii_bus, or use it as a pointer to their > bus, then they should not be providing a ds->ops->phy_read() callback > since we assume they would have mii_bus::read and mii_bus::write set to > their driver internal version. I see, so having ds->slave_mii_bus and ds->ops->phy_read both not NULL into dsa_switch_setup() is a potential bug, I suppose... If so why not adding a BUG_ON() call to signal it instead of doing nothing? :-o Ciao, Rodolfo -- GNU/Linux Solutions e-mail: giometti@enneenne.com Linux Device Driver giometti@linux.it Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti