Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4617684pxb; Tue, 2 Nov 2021 12:48:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx7U1i2QQatZctuy/WoY6bx+TctrVG1aA0vYMCvH+TGvUlU9jsQh19hhZYIQj58DHS50rj X-Received: by 2002:a05:6e02:20cb:: with SMTP id 11mr14892534ilq.258.1635882486572; Tue, 02 Nov 2021 12:48:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1635882486; cv=pass; d=google.com; s=arc-20160816; b=wicsWo+7eeE8JmHZPj7JJEpnsgik7J4jWEl6UB7HuXSGGr3wD2rWR7hPkHeYua1ZZO uUFRxeIv2gThf25CQnS0u7iQTjykyeS9zvQ0XCn8fChpq+eQzCf/odoxgOH8l+qIlRRN U2/FmSeuQWPxd673Hmy65fleUL1QwacE86nEG//2YlppbTIElarF2FUExGvS6ElMvrPS 5iFVfqwhoXB5Dw1sFOAdPhCK6KxTlsqK3iecJLVTdX4KLVsHHoCYanBeNa2cdiMPt/IM 7rEd9ofN6rDGcSBhtG3+4rs+IEZW88ORNrztEWwWk4iWrzfrBSmxE7L7xkRiC0isl1XA CLOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:references :cc:to:subject:from:dkim-signature; bh=xsMYHXHkHO1UqAQtpCZOAmvD0N+kNV//6mEqHIGyvMQ=; b=AkaXOeMTKM6Oq4VVRZH8K/Cnyi+siJDqPRH9eIczrhIs2LjrK7ezXH9JVQdwYyoH4O qXfH0wlVcCyBxny54cLRZaS3mGwMf+Xs+gS5puS5zZNn+Sfq3uLUxdD4Rki0TDl6ekOI tv0V5hJTD78SI5nhKo2RTSdOTY2jn6HKOZHrtRny7d1YVjOkGid/mViogqcDff8dtOdl RuMwGr4hPgLNsf0fEg8sKSRuI8S/9dWosd/YsvF8i1OjdFTFI1OhUQv4p4hisKcmVUbQ ULxeNmz2DV93L5UkLlxnQSyixhlVinzaDcWW2KZAxjfENrQWs0/gXVhgMXBvYZMr8oZV tS0A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@secospa.onmicrosoft.com header.s=selector2-secospa-onmicrosoft-com header.b=rlgBwr2I; arc=pass (i=1 spf=pass spfdomain=seco.com dkim=pass dkdomain=seco.com dmarc=pass fromdomain=seco.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=seco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si639110jal.30.2021.11.02.12.47.53; Tue, 02 Nov 2021 12:48:06 -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=@secospa.onmicrosoft.com header.s=selector2-secospa-onmicrosoft-com header.b=rlgBwr2I; arc=pass (i=1 spf=pass spfdomain=seco.com dkim=pass dkdomain=seco.com dmarc=pass fromdomain=seco.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=seco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230251AbhKBTs5 (ORCPT + 99 others); Tue, 2 Nov 2021 15:48:57 -0400 Received: from mail-db8eur05on2042.outbound.protection.outlook.com ([40.107.20.42]:52865 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229813AbhKBTs4 (ORCPT ); Tue, 2 Nov 2021 15:48:56 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=duxKEaYoTsoL19A0aq4HnSLQRgDUctg4G2bV225sPYNSwrmalUddPiJ9UG/ufTmodmpywcWnLyNTm8VoTMQ9H2ucy/K6mnO+6VKj4suB4oVqwYoyR+WXzH5EQiVNGxPw/S9RM7yHs4YCkY86mYXvYJ/AWu8i9hRhYQyTexGkCc39DGT2MuA4VGsKy+kj45ukvXiIA205rJg1bueToGvffj3sSBnmduZdVWW75NuVcSQQjSQSSWGhMU4M1zQ1qBQfZYe/nJHE9HICDJH+FRD1v9BxPNeKXiw46k7YDpNOCeIA+RtENL5NuXaJLAriSoPFXuigU058qv6vEzprPETuQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xsMYHXHkHO1UqAQtpCZOAmvD0N+kNV//6mEqHIGyvMQ=; b=nDrHB4IEM9rFhwLT7+RLvyy0deP6LUDacvx18j8lo5+yrrzLxvGHfJTMu8287xs0X9hNIU7YYnMJkH3U9DYJ6MDUjc9+O9xLK4fJY1oSgRszv0KM8VDj8RI03T7Uk+SyROAldyrjwrpM/c9I4giCyH8pYVhNPnuk2w4mps3e3orbvqkK3RPtvuvXxNPCigVt0SzAS1OOsr90NugTj3SeaxtBz610NtItZg7fDSrahwYDHwaekOYVxUR3nNQT1SyGfALUZBcyStIqszqpcs9KEHLOjrRTj2BzBqC7hMW6XH053+K81fyouts0vUtAmiY9wSifjhEbKUBBmiywTlRQag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xsMYHXHkHO1UqAQtpCZOAmvD0N+kNV//6mEqHIGyvMQ=; b=rlgBwr2ICgGe4hNCDUh28dQMqO8G/lb9a40vcbDh8ZfAi7y7lqkJDSJPqstSbowfTTpPsZNV4otVrl60/hfz438WIxD4KrdTHFzH6slEsk4k7j7YMGmu46WknTC25XV+WNc5CeQTYFf1ZLrT29dhX6Jljcxb5wAUhdOsbcH561I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DBBPR03MB5368.eurprd03.prod.outlook.com (2603:10a6:10:d6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14; Tue, 2 Nov 2021 19:46:18 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::a9aa:f363:66e:fadf%6]) with mapi id 15.20.4649.019; Tue, 2 Nov 2021 19:46:18 +0000 From: Sean Anderson Subject: Re: [RFC PATCH] net: phy/mdio: enable mmd indirect access through phy_mii_ioctl() To: Andrew Lunn , "Russell King (Oracle)" Cc: Grygorii Strashko , "David S. Miller" , netdev@vger.kernel.org, Jakub Kicinski , Heiner Kallweit , Florian Fainelli , linux-kernel@vger.kernel.org, Vignesh Raghavendra References: <20211101182859.24073-1-grygorii.strashko@ti.com> Message-ID: Date: Tue, 2 Nov 2021 15:46:13 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MN2PR05CA0045.namprd05.prod.outlook.com (2603:10b6:208:236::14) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 Received: from [172.27.1.65] (50.195.82.171) by MN2PR05CA0045.namprd05.prod.outlook.com (2603:10b6:208:236::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.4 via Frontend Transport; Tue, 2 Nov 2021 19:46:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b49181a1-5775-4221-4436-08d99e397074 X-MS-TrafficTypeDiagnostic: DBBPR03MB5368: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yQ9FIbX8DMuowuC1PbCxwpiGDXRLrXRH3uggLaCkcsKrtSoaEiLtYEG5K4Ua1m/Z+Rhg8dUxbEDmWKEVMEEbEHvG2pr7OeMjkLItGGZP0zfyY3jPQH6EPMqbLOEVfHQgHuirGTjR8H8ovRCXqqXoze5ctmY9helKBkyG5qwds3XAyOVMMiF8A8lToCzpGhnp9VQjxb9JbCvjGmK2/I/qWwtASO0Nat9xxAMJozr3EEswZssrUEiA1FsJkO0erUsRnoFzqE5z4WwOU2PEfzmPaPzussbQ1Xq4UW6H8jR/oeD31AlY0Zec0aDZXveqr3OF71xUoDOwby+CaXrYav4UfirF6tkAP0u9BcIdV8u6oYJXFHj3BZ09zyUxMzu3u3pRtf+L1afa/ZV0vksZU2i0zVJrMVITTSQJFrD3mU7BB938UC4MRTm+8eOCRXFphKO3GTcB3uahAJ+/OOivYDpSrUxVP44RAXvtvTA9BSoub/0TWjQ2xnjsxNSNt+yQxI3RTJ9yUMMJTv9t4eDydBPjJsHAlkbS/LEQSj9wMrhRCzQZ7g1giv51SYW+Pqdg6hHsTuW0j5Bw2/EOFnrIzmDjaat+6EQguBsNPe8hUZUxmeVVIQ33M+i3PUceaNNAMxUQPjq6lvmbDFfbugQz2g6XH+vOnoGCKUbsjyQ7N99F3RQMRdOFd5lJyA4rGakvmUqo1otD4KnSHSP/VPONEqWTP8vEs+t53flC/qEpDXFTst5rkiu50DKaDwcXec61q3yeG/nCUTYNMwx171TNDfTo81fFDt1Byz7whtm2nhXyKsrYgzK3k/VprFNfXXfq0V4a7NYLnm1YMsZ2KazWM+ed0A5WcVZtxmZO6zLn/fiM7uE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(52116002)(36756003)(38100700002)(38350700002)(26005)(8936002)(316002)(2906002)(83380400001)(31696002)(7416002)(8676002)(86362001)(53546011)(4326008)(508600001)(31686004)(956004)(966005)(110136005)(66476007)(66556008)(44832011)(66946007)(54906003)(186003)(6486002)(6666004)(5660300002)(2616005)(16576012)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NXB5RkZKRmVGMUJoYjhWeU1tQXZhdTdyK29jZWgvTTc5KzZVKzd0RGhzMUIz?= =?utf-8?B?SDUrelJsSVlHL0lyU2RCQ3lVdWxodlZaY3lxUzRmMVpnUTJtRndZZjU1ZXRC?= =?utf-8?B?SWE5cXNDbU1WUXR0clJ4WTdUQkJIWURQRjMvTUljZDAxajU1V3pnV3V2ckdo?= =?utf-8?B?dEl5MStjWmNSb1ljamxnUkhCSVd0TWYvVTBqN1JPZGY4by9yWXdrdFRwWGtR?= =?utf-8?B?akRURE9Ga3FMSm9nNlpyd2pNdTRSdmRSTXN4U00zTzdFc3BLdSt6RSsrVFdr?= =?utf-8?B?a1VMcGJpSVB3b3VpNnZEcUZWa3JkUkNpelg3NHpHRTFDdkR0Y2s1anNyTjgy?= =?utf-8?B?K2Z1d0wzMXF1dkVCbkd1aEVzd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= =?utf-8?Q?sWg0GxpKPNmA5+EqjlSbjGM=3D?= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: b49181a1-5775-4221-4436-08d99e397074 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2021 19:46:18.7417 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QaB14L+1i7qXv5M2AWfmli/01aetH3pvdN1kwnnwT9fng2ufQ4MzuPOgzxUfJiXp+NkZCjBEv51jenGV+tClIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB5368 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/2/21 1:13 PM, Andrew Lunn wrote: > On Tue, Nov 02, 2021 at 12:39:52PM +0000, Russell King (Oracle) wrote: >> 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! > > Agreed. > >> 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? > > Yes, i think we need to keep with, this API is for MDIO bus access. If > you want to do C45 over C22, you need to do it in user space, since > that builds on top of basic MDIO bus accesses. > >> 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. > > I'm against that. It opens up an API to allow user space drivers, > which i have always pushed back against. The current API is good > enough you can use it for debug, but at the same time it is > sufficiently broken that anybody trying to do user space drivers over > it is asking for trouble. That seems like a good balance to me. I have not found this to be the case. As soon as you need to access something using phylink, the emulated registers make the ioctls useless (especially because there may be multiple phy-like devices for one interface). Currently, I use [1] to debug phys without having to worry about what phylink is trying to simulate. I would much prefer something like what regmap does: reads are allowed through debugfs, but writes require editing the kernel source. This allows useful debugging, while making zero-edit userspace drivers impossible. And fundamentally, you can always load a module which lets you do your driver development from userspace anyway (as [1] demonstrates, though I personally compile it in). I don't really understand why we have to have worse debug tools to prevent something which is trivial to implement anyway. --Sean [1] https://github.com/wkz/mdio-tools