Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4185688pxb; Tue, 2 Nov 2021 05:43:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySMpQcKK4H8YLlqCjaa7qTjO9KHQe43riY7KicJJPiIlucaPEQc1z3VVFl6pBfZzsQ5fIp X-Received: by 2002:a05:6402:184c:: with SMTP id v12mr28129638edy.242.1635857020518; Tue, 02 Nov 2021 05:43:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635857020; cv=none; d=google.com; s=arc-20160816; b=XYpclzGGUrrOou1UquxBg5yJLWXZjEpfaHQNdIWSLnMXtrBQnDsjTePwPVJMi283lT 5WvUgqft3nek6jeOdYqxFgdCoESkE49ZEh5SdAd+kfXbAjlT4kHiXHNs5jY9U5jbS/X4 PeuLKDrD5a9hZ8+lJHZ0iK9b28YfzQyqQuSNTVgBgjfQSphvS9KnL8IBKiVXYOBYIPpb XTrkrSgQrTOtSZ/gLj2PfpzpF3gXLdAWl2uSzn60VobsM1p+EW8L9QYbQCTiAezBVr6Z EEWy8qKwk3qaPLwO7VhSBLTyijSPOVAJ2LRNWIoiABl+faPWFTu5TRoCK+ekried9cN4 +AUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Q2t2Yay9P4Tekd7fAPWyB6W35FYZ8UjNPE7qgmxtFgo=; b=PEtsTdU+jUbUdkocTo3MUNNF9PWVQjzZL6inIELgNw1a+xdTYgR70A5ze0RP1qotz+ ibJhCy4zZ9MoaxrJ2r8eeu0HdIvqx6b0ZL6m0MqXvLQyeYQC/AefKHiBkZA6wgg4Q/vz 8ScpwNz6HYwg2smu5VAI2MBe0yOLAB9Ouo6QzeHrywQWOiRwC5I8zVV0XOZWeHfpqBVj aZTQ2qP8Ng/RGvAybKvproyLkX1GG+9n1Cy5gCzbbo8DVbYcXC3mdjsNfzHAQ0/uAswL DiymX29sMsPcDaxSKPnms99DA4Lndy6isNvIqAzqIiuDyAzMKnjHH5d5ceY8EzlXXTel 3dGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=mzrMOti1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds5si33885724ejc.522.2021.11.02.05.43.15; Tue, 02 Nov 2021 05:43:40 -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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=mzrMOti1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbhKBMme (ORCPT + 99 others); Tue, 2 Nov 2021 08:42:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbhKBMmd (ORCPT ); Tue, 2 Nov 2021 08:42:33 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54BEAC061714; Tue, 2 Nov 2021 05:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: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=Q2t2Yay9P4Tekd7fAPWyB6W35FYZ8UjNPE7qgmxtFgo=; b=mzrMOti1jC7Z7IrbXrFKTxSdjj xBdhuoTsRPyszsPNVJYGOM9tVuEUkNjumWw8op58jmC+Klrwy0rGjhCSOHgJPbCkVC+1lzq2mtm4D t86k3knymXnDi/mx9OWBtMV3bSEpm+L3YEGn40GGagGNuqVLdhQdFZ1K30/Ok8hczyJxGYVUzo8Vq FYQrT+XN+w0HPHiv8oWogVv0zNN+muK+TF7ib5PiIJg3onDrfMcWBQ+RsCcRpXXJ25YBGrlCPoskT MtH87Vcwn9uecvpIVZxx1A1hnxQMYmxObQWAsq5wWvqjtKO2zs1QMac4NsDB3hJivGwUOXqkzQNel YG6nSHWw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:55438) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mht50-0003oe-Oy; Tue, 02 Nov 2021 12:39:54 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mht4y-0005QI-Rn; Tue, 02 Nov 2021 12:39:52 +0000 Date: Tue, 2 Nov 2021 12:39:52 +0000 From: "Russell King (Oracle)" To: Andrew Lunn Cc: Grygorii Strashko , "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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 02, 2021 at 01:49:42AM +0100, Andrew Lunn wrote: > > The use of the indirect registers is specific to PHYs, and we already > > know that various PHYs don't support indirect access, and some emulate > > access to the EEE registers - both of which are handled at the PHY > > driver level. > > That is actually an interesting point. Should the ioctl call actually > use the PHY driver read_mmd and write_mmd? Or should it go direct to > the bus? realtek uses MII_MMD_DATA for something to do with suspend, > and hence it uses genphy_write_mmd_unsupported(), or it has its own > function emulating MMD operations. > > So maybe the ioctl handler actually needs to use __phy_read_mmd() if > there is a phy at the address, rather than go direct to the bus? > > Or maybe we should just say no, you should do this all from userspace, > by implementing C45 over C22 in userspace, the ioctl allows that, the > kernel does not need to be involved. Yes and no. There's a problem accessing anything that involves some kind of indirect or paged access with the current API - you can only do one access under the bus lock at a time, which makes the whole thing unreliable. We've accepted that unreliability on the grounds that this interface is for debugging only, so if it does go wrong, you get to keep all the pieces! The paged access case is really no different from the indirect C45 case. They're both exactly the same type of indirect access, just using different registers. That said, the MII ioctls are designed to be a bus level thing - you can address anything on the MII bus with them. Pushing the ioctl up to the PHY layer means we need to find the right phy device to operate on. What if we attempt a C45 access at an address that there isn't a phy device? For example, what would be the effect of trying a C45 indirect access to a DSA switch? Personally, my feeling would be that if we want to solve this, we need to solve this properly - we need to revise the interface so it's possible to request the kernel to perform a group of MII operations, so that userspace can safely access any paged/indirect register. With that solved, there will be no issue with requiring userspace to know what it's doing with indirect C45 accesses. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!