Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4725746pxb; Tue, 2 Nov 2021 14:49:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWXm0lwGt2+jpCaDdFzt6e4HWcagbE1qaR/Mh90Kfb3+nqYGqmFyzLSrFVLuA6N1edmtmt X-Received: by 2002:a05:6402:2712:: with SMTP id y18mr56462996edd.392.1635889770232; Tue, 02 Nov 2021 14:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635889770; cv=none; d=google.com; s=arc-20160816; b=QQHYA2JA0CXNgBcNKjCA5cAcWBBUmGgKBX8j92CPLJ08mtrgdtEKkxWs2TC18inO8L gBd/7+kuuWskKBrTpfpQ7NS61DBA4tF+t9zKzQqfaylsPQQ1xcUggbqhBFRYfU/1DzIY dZgt1wBiJiJpVLuh+GlGcc4emSqZ3B0f2Pf4yS1XUqt6bBPBfnDE475I2TlnADUE0BnC YhssM3OKwEo+5taiDL7n+iEKhGMKqgK7ilr5NIqMG7W9eglF/NtG4knDnsy9HfBxQIFx eVD7SHNRYZ28SH4pr016ZoG73MqGl2rGX0Cr17e3So3jxT+KbAHaP1XFOdZ9/jZD3fsK 7gBA== 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:dkim-signature; bh=g5PjRPGooZX9QLmvsUQz9bR1LIK1fGNbet4Pw/YnfcA=; b=qkmDI0LvKPgiiZhGZ6zVzrhsmX379QxDTuU2oJNfyjyEunLL0xrq9V4V0s8LRevxTR CZVdEdA6ngp9/yQDZfMmBe4SuuWsXgv9H5UNnpUpaVpG6mso3uG4HoftmYoecZXqkv+H 5Dyg9NXPDhK5/pSlAeMS5tq2B+fO+nBHHULpBwLwUcSlZdcl8/Q9rgUAHQ7WAUQfeqVG Uv18Z/HVMkGdCGJpHJ6b4V1Ex+eiTkEwVPhz8Rj5Ke2AZBBNkkMRRs78pk/jprUnASR3 hPwRijI8abTZ6iluEhj0QckIlCrKmdTdWbeSEMkjIAEbLgo67dKj/ym2ZZoKals/EM3e dw0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=gH3tlkPP; 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 x44si327252ede.453.2021.11.02.14.49.06; Tue, 02 Nov 2021 14:49:30 -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=pass header.i=@lunn.ch header.s=20171124 header.b=gH3tlkPP; 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 S231304AbhKBVtY (ORCPT + 99 others); Tue, 2 Nov 2021 17:49:24 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:44002 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbhKBVtX (ORCPT ); Tue, 2 Nov 2021 17:49:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=g5PjRPGooZX9QLmvsUQz9bR1LIK1fGNbet4Pw/YnfcA=; b=gH3tlkPPy29T0EWrbCXzqKHcQJ PeCvulc+CZDyNFCkRWsTfvEeohEBC6jXgwQH5ExkEtKUVtGRquiiYYoCsUlnKbRJ5cADLduFrP8Ic MxioaURJFaVUIw8xky+TXasu0/lKP3oF+Nea8nQtyOY92NoRhxUyer2llaFm/U4iw0mU=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1mi1c6-00CRRZ-K9; Tue, 02 Nov 2021 22:46:38 +0100 Date: Tue, 2 Nov 2021 22:46:38 +0100 From: Andrew Lunn To: Grygorii Strashko Cc: "Russell King (Oracle)" , "David S. Miller" , netdev@vger.kernel.org, Jakub Kicinski , Heiner Kallweit , Florian Fainelli , linux-kernel@vger.kernel.org, Vignesh Raghavendra Subject: Re: [RFC PATCH] net: phy/mdio: enable mmd indirect access through phy_mii_ioctl() Message-ID: References: <20211101182859.24073-1-grygorii.strashko@ti.com> <828e2d69-be15-fe69-48d8-9cfc29c4e76e@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <828e2d69-be15-fe69-48d8-9cfc29c4e76e@ti.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > @@ -300,8 +301,18 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd) > prtad = mii_data->phy_id; > devad = mii_data->reg_num; > } > - mii_data->val_out = mdiobus_read(phydev->mdio.bus, prtad, > - devad); > + > + if (prtad != phydev->mdio.addr) > + phydev_rq = mdiobus_get_phy(phydev->mdio.bus, prtad); > + > + if (!phydev_rq) { > + mii_data->val_out = mdiobus_read(phydev->mdio.bus, prtad, devad); > + } else if (mdio_phy_id_is_c45(mii_data->phy_id) && !phydev->is_c45) { > + mii_data->val_out = phy_read_mmd(phydev_rq, mdio_phy_id_devad(mii_data->phy_id), mii_data->reg_num); > + } else { > + mii_data->val_out = phy_read(phydev_rq, mii_data->reg_num); > + } > + One thing i don't like about this is you have little idea what it has actually done. If you pass a C45 address, i expect a C45 access. If i pass a C22 i expect a C22 access. What i find interesting is that you and the other resent requester are using the same user space tool. If you implement C45 over C22 in that tool, you get your solution, and it will work for older kernels as well. Also, given the diverse implementations of this IOTCL, it probably works for more drivers than just those using phy_mii_ioctl(). Andrew