Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3508781pxf; Mon, 5 Apr 2021 14:09:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypQZCeIZ8MY58+7I5W6vp9IHAy4R6vQ+nPF1mcTuQ9wihVe4u1wbB+FyAhtW9fljCFS/ls X-Received: by 2002:a05:6638:e93:: with SMTP id p19mr25630957jas.10.1617656967243; Mon, 05 Apr 2021 14:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617656967; cv=none; d=google.com; s=arc-20160816; b=GKFXR3+DwTNW/yfGT9A1oKj9gpXLO5c7m54Y59YDIna93eUm+aRHOPMTVVZhL+G+T0 3njrUkm5uWizv7pjP6sqoc9ZgPapXDQ9yo4jfUJj4joU5CkhbbU2vWpaqor434CYkiUm m0rX8gkYrKiQpSouUkyzhHMUGef0TFHOh3Fr2nzYUUqMDnhvp8VQT1Eh7SOLfcrGTV6h khQXzOz/gTcLuJY8aAOXXf9PkicZdE5ww76kO12vYQqPWaNI84547qbn9tQrwgwQxqmj Mp81hvm2n4IC+s1LSgwFoA/XwCeThFS7RWfAEpvVEoDaan/rKPGQBZI1vNw0ib32uadY Cf5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Z7/Zk2F7dZBb+FAKwiS1UDUTt6G01QzFIb8uNOF4sSQ=; b=pxdkrQrTMaGEmW3CU4me3RvZf1X/7UrtzAuo75XkqgAatxpoGN8UwxpcBg38nh97Yf GV1mbTiar/Ewm5GaXyt0oBFqziGf7PjuJRtIAacCJdhZvxz1RSIj7kL1ETi+4bEjoG9q xprt/p0FIAZF2vVuAVHvcgOg7mlYptGBPMnp6adPa9KMxto1CzuuQ9RGezJ60mZaD33L 9wrsy71/GfpSMUtQaz7kaLaPMst2L43uiPXC4HzJBYjKy5H2L7PGogZDJVQGHKuc/JTH qoH/IJqIAexcPaM7b0mEu61TevpC1jdw2UbRt0dCHCa3lv35m/CQjTLMVqc+S4yKpp5N BeGQ== ARC-Authentication-Results: i=1; mx.google.com; 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 k15si16019036jan.49.2021.04.05.14.09.14; Mon, 05 Apr 2021 14:09:27 -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; 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 S237419AbhDENeI (ORCPT + 99 others); Mon, 5 Apr 2021 09:34:08 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:33976 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232694AbhDENeH (ORCPT ); Mon, 5 Apr 2021 09:34:07 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1lTPMZ-00EvmM-Ns; Mon, 05 Apr 2021 15:33:55 +0200 Date: Mon, 5 Apr 2021 15:33:55 +0200 From: Andrew Lunn To: Danilo Krummrich Cc: Russell King - ARM Linux admin , davem@davemloft.net, hkallweit1@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jeremy.linton@arm.com Subject: Re: [PATCH 2/2] net: mdio: support c45 peripherals on c22 busses Message-ID: References: <20210331141755.126178-1-danilokrummrich@dk-develop.de> <20210331141755.126178-3-danilokrummrich@dk-develop.de> <6f1dfc28368d098ace9564e53ed92041@dk-develop.de> <20210331183524.GV1463@shell.armlinux.org.uk> <2f0ea3c3076466e197ca2977753b07f3@dk-develop.de> <20210401084857.GW1463@shell.armlinux.org.uk> <20210402125858.GB1463@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 04, 2021 at 09:23:55PM +0200, Danilo Krummrich wrote: > On Fri, Apr 02, 2021 at 01:58:58PM +0100, Russell King - ARM Linux admin wrote: > > On Fri, Apr 02, 2021 at 03:10:49AM +0200, Danilo Krummrich wrote: > > > On Thu, Apr 01, 2021 at 09:48:58AM +0100, Russell King - ARM Linux admin wrote: > > > > One could also argue this is a feature, and it allows userspace to > > > > know whether C45 cycles are supported or not. > > > > > > > No, if the userspace requests such a transfer although the MDIO controller > > > does not support real c45 framing the kernel will call mdiobus_c45_addr() to > > > join the devaddr and and regaddr in one parameter and pass it to > > > mdiobus_read() or mdiobus_write(). A bus driver not supporting c45 framing > > > will not care and just mask/shift the joined value and write it to the > > > particular register. Obviously, this will result into complete garbage being > > > read or (even worse) written. > > > > > > We have established that MDIO drivers need to reject accesses for > > reads/writes that they do not support - this isn't something that > > they have historically checked for because it is only recent that > > phylib has really started to support clause 45 PHYs. > > > I see, that's why you consider it a feature - because it is. > What do you think about adding a flag MDIO_PHY_ID_MMD (or similar) analog to > MDIO_PHY_ID_C45 for phy_mii_ioctl() to check for, such that userspace can ask > for an indirect access in order to save userspace doing the indirect access > itself. A nice side effect would be saving 3 syscalls per request. We don't care about the performance of this IOCTL interface. It is for debug only, and you need to be very careful how you use it, because you can very easily shoot yourself in the foot. > So currently every driver should check for the flag MII_ADDR_C45 and report an > error in case it's unsupported. > > What do you think about checking the bus' capabilities instead in > mdiobus_c45_*()? This way the check if C45 is supported can even happen before > calling the driver at all. I think that would be a little cleaner than having > two places where information of the bus' capabilities are stored (return value > of read/write functions and the capabilities field). > > I think there are not too many drivers setting their capabilities though, but > it should be easy to derive this information from how and if they handle the > MII_ADDR_C45 flag. I actually don't think anything needs to change. The Marvell PHY probably probes due to its C22 IDs. The driver will then requests C45 access which automagically get converted into C45 over C22 for your hardware, but remain C45 access for bus drivers which support C45. Andrew