Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2201637pxb; Fri, 25 Mar 2022 12:57:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2072/IgZd9S2TIozx4M7J640USqLjsSxh8an15B/ert0eY3FZ/ko44JTxwKYmXVdCE9aI X-Received: by 2002:a17:90b:4785:b0:1c6:ad62:dda3 with SMTP id hz5-20020a17090b478500b001c6ad62dda3mr26651344pjb.232.1648238238848; Fri, 25 Mar 2022 12:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648238238; cv=none; d=google.com; s=arc-20160816; b=zNrQh5HkLdBvaCuDQCYadKKr0KlSYaGXgHqdzsCEApJwDvvY5FWlItOzK7qdXJ+sJc IrP3WR220E//HOMLX32CPrLPi86IEj3nHoz+kc5oPcCkX6ZXjJ91D0v8WS/alCkL8/zE RWjbgoSwVkkbo1o9utjEvauk3lHDaXDJeEo+0bjR8SYNmlMomnwvVs6scqgi1QV4ALSv GPsU3GurG8p8KcMWFUtvXALTQ4T74oxpAS5KIIoMdyd/dXv03QfeLRYMX0Jl6KGQ22rD 8qh7YNQUcxvh0a8cpeIl+Y/jqsvlubtn7aMiGoeg3D/gSwzOMyz03FNCoLyt1nD0CG/B vtLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=mW5UfH8Ylkm3/jigdRwLAUC6EVlLm7SjaltxrCgFE7g=; b=MwECsyTG5ThQVZOxMT9dAZX0pIScCWFK3kIcCfRTeCYwTmjL0mJ4W9aBj5FVbSotS2 xFYOUrarTxXH+/ES1b8oN5T7JOBeh4T6vX3/Z6r5Lj9gRkxTeDxdCJsIzVADJn88m2sn MuWiLw8MJRrLEe99QBXxTlBCamFyRWubif8BTcnbuccBFQ+zABds/YlSZ9e3bvaFSney ACvG8uDV3jL30JL+3LrahfijdX4LaQ2rfuXML58JjvavcrTXJkT/PKjbnUfT0OW0VFCp wazKQt85PjgtrZqE7DpaJ1MiFP02lfLYr7KRjBmgSJajTXMTKycm97fdzFBra2WDNQAr zo1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=CkHlieX6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n66-20020a632745000000b003816043f06bsi3219989pgn.608.2022.03.25.12.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:57:18 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=CkHlieX6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9EF69331441; Fri, 25 Mar 2022 11:46:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352209AbiCXRT6 (ORCPT + 99 others); Thu, 24 Mar 2022 13:19:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345269AbiCXRTz (ORCPT ); Thu, 24 Mar 2022 13:19:55 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33ADFDF56; Thu, 24 Mar 2022 10:18:17 -0700 (PDT) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 0C3F22222E; Thu, 24 Mar 2022 18:18:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648142295; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mW5UfH8Ylkm3/jigdRwLAUC6EVlLm7SjaltxrCgFE7g=; b=CkHlieX6xNiThKeWq282t7PUgDhAZ97n/a0kKkZsS3QLnrE1+q/L10hZGvj8UscSyBNNM7 xPJekUK9hwPYqxtZLw4FfrUrByxiiH+3IJcDA3JufWFv6aFEOGmiZcRTHg9yp93g/gIBkg 8uOFHdsnA1sZv86gtjXgH3TuYJ14+iU= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 24 Mar 2022 18:18:14 +0100 From: Michael Walle To: Andrew Lunn Cc: Heiner Kallweit , Russell King , Jakub Kicinski , Paolo Abeni , "David S . Miller" , Xu Liang , Alexandre Belloni , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC net-next 4/5] net: phy: introduce is_c45_over_c22 flag In-Reply-To: References: <20220323183419.2278676-1-michael@walle.cc> <20220323183419.2278676-5-michael@walle.cc> <8304fb3578ee38525a158af768691e75@walle.cc> <30012bd8256be3be9977bd15d1486c84@walle.cc> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <0d4a2654acd2cc56f7b17981bf14474e@walle.cc> X-Sender: michael@walle.cc X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 2022-03-24 17:23, schrieb Andrew Lunn: >> > To some extent, we need to separate finding the device on the bus to >> > actually using the device. The device might respond to C22, give us >> > its ID, get the correct driver loaded based on that ID, and the driver >> > then uses the C45 address space to actually configure the PHY. >> > >> > Then there is the Marvel 10G PHY. It responds to C22, but returns 0 >> > for the ID! There is a special case for this in the code, it then >> > looks in the C45 space and uses the ID from there, if it finds >> > something useful. >> > >> > So as i said in my reply to the cover letter, we have two different >> > state variables: >> > >> > 1) The PHY has the C45 register space. >> > >> > 2) We need to either use C45 transfers, or C45 over C22 transfers to >> > access the C45 register space. >> > >> > And we potentially have a chicken/egg problem. The PHY driver knows >> > 1), but in order to know what driver to load we need the ID registers >> > from the PHY, or some external hint like DT. We are also currently >> > only probing C22, or C45, but not C45 over C22. And i'm not sure we >> > actually can probe C45 over C22 because there are C22 only PHYs which >> > use those two register for other things. So we are back to the driver >> > again which does know if C45 over C22 will work. >> >> Isn't it safe to assume that if a PHY implements the indirect >> registers for c45 in its c22 space that it will also have a valid >> PHY ID and then the it's driver will be probed? > > See: > https://elixir.bootlin.com/linux/latest/source/drivers/net/phy/phy_device.c#L895 > > No valid ID in C22 space. I actually looked at the datasheet and yes, it implements the registers 13 and 14 in c22 to access the c45 space. I couldn't find any descriptions of other c22 registers though. >> So if a PHY is >> probed as c22 its driver might tell us "wait, it's actually a c45 >> phy and hey for your convenience it also have the indirect registers >> in c22". We can then set has_c45 and maybe c45_over_c22 (also >> depending >> on the bus capabilities). > > In general, if the core can do something, it is better than the driver > doing it. If the core cannot reliably figure it out, then we have to > leave it to the drivers. It could well be we need the drivers to set > has_c45. I would prefer that drivers don't touch c45_over_c22 because > they don't have the knowledge of what the bus is capable of doing. The > only valid case i can think of is for a very oddball PHY which has C45 > register space, but cannot actually do C45 transfers, and so C45 over > C22 is the only option. And how would you know that the PHY has the needed registers in c22 space? Or do we assume that every C45 PHY has these registers? .. >> > phydev->c45_over_c22 we are currently in a bad shape for. We cannot >> > reliably say the bus master supports C45. If the bus capabilities say >> > C22 only, we can set phydev->c45_over_c22. If the bus capabilities >> > list C45, we can set it false. But that only covers a few busses, most >> > don't have any capabilities set. We can try a C45 access and see if we >> > get an -EOPNOTSUPP, in which case we can set phydev->c45_over_c22. But >> > the bus driver could also do the wrong thing, issue a C22 transfer and >> > give us back rubbish. >> >> First question, what do you think about keeping the is_c45 property >> but >> with a different meaning and add use_c45_over_c22. That way it will be >> less code churn: >> >> * @is_c45: Set to true if this PHY has clause 45 address space. >> * @use_c45_over_c22: Set to true if c45-over-c22 addressing is used. > > I prefer to change is_c45. We then get the compiler to help us with > code review. The build bots will tell us about any code we fail to > check and change. It will also help anybody with out of tree code > making use of is_c45. Ok. Fair enough. -michael