From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFA19F30928 for ; Thu, 5 Mar 2026 09:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:References:Subject:Cc:To:From:Message-Id:Date:Mime-Version: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CKh+g7wcV/qK5iLObcHUpP3QJeOd1hlKiNnV7DeLuLU=; b=3Xh4Q+f3ltokWHjf8OhAndhWbj T6tnH6FMFqhMVL9DjNZv0s4jpiPSh8C7/1a3Eq2nMt5rB9j0azS+Lxn1m3kG5V+b47mFnZ5jb+yIs WcqkWjL6iy30iFiVm4YJblDJXuSbs3C1js0TDBPUU9gsMgd8XeLPFdGoXELLQ/kkzpAXTUt1uFBUj 1V34XDevWqZb9/53xYVDvLpXheTaTDLHaxLWZSPNZokDNw1fR64aa+lSn+xbHCwAndbrtoB+n0IBO Uiz5mE9K45PtcNULlTbfrFL32zj8oe0JnUOWA7iqp8pyldRizb74E15+ju3d+flaCc1rquiX4CndE /k4MXH8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vy58C-00000001PeK-1aFr; Thu, 05 Mar 2026 09:36:32 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vy58A-00000001Pcb-0jhY for linux-phy@bombadil.infradead.org; Thu, 05 Mar 2026 09:36:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:References:Subject:Cc:To: From:Message-Id:Date:Content-Type:Mime-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Mbidr/A9XxccdAFsJsVKLL2bBtmGRz8XUrt7LUMLgOs=; b=dl2ong5NzZGjHxK3+LR4jXgVul OHC6KBy2eYlHoj3X1bKIRpHfH2lElUgPW9/M4dfKa2VVwhPDDf871qF22T9lNqVZ4OnxGQhfDtKWJ 56J1Nvwpk/MIf77sCqVOOLMoUagkt3XzsuXcQoz1d856kdHx77UcTBSTaDyq7EomZ6p0egPBEPXoe 4PAILZahNruS6+UuouBHws21Yq5rspNbKLEipuUgjDsKOaE0789tfFS/mMX2Q9MlPNhzWnMDzrWie 9fvmVB3tjFuToRRTZV50mIkRtgAghjfqpXjiQfmvXnn35FgxR3wxXP323m7gtZl0PmRJuJQLrsJGr +zuR4z8Q==; Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by desiato.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vy586-00000006M3s-3hQv for linux-phy@lists.infradead.org; Thu, 05 Mar 2026 09:36:28 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-439c9bdc1eeso1569063f8f.3 for ; Thu, 05 Mar 2026 01:36:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1772703385; x=1773308185; darn=lists.infradead.org; h=in-reply-to:references:subject:cc:to:from:message-id:date :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Mbidr/A9XxccdAFsJsVKLL2bBtmGRz8XUrt7LUMLgOs=; b=N0S3IsyCKkyFGJvcjWmFM714EtFQIbnd6KXtK5vBVkCbblFSAjIwodqNiXIvbK+17B LPL5czAhCCdebfOh5IpP+PpRp2uO1v2WdaJQcLlPw3eJ9Py0QinlDSm4s1hZAREYNVbi p9NB4YuXDtBOYGFq0xIq24LnULchX6e+/VFz0r8yrylKaBTBpBtko+dmc3xHKyn5gH5B 5h8BPZWou7EqqudPqvzgcP+LBnjQh1u8ahLrasXw1fqU5o0v/HzlceI5sszy+FlP2GY+ EggKaYhiNsBL1Q0f3dFYmCgI5ARiiWZpS9SI7lgrA29Z4rKwVUL2JRzThVNc0T8/r/2K Vvow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772703385; x=1773308185; h=in-reply-to:references:subject:cc:to:from:message-id:date :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Mbidr/A9XxccdAFsJsVKLL2bBtmGRz8XUrt7LUMLgOs=; b=dTnjTGB8dR471AHzTc+ySzayElKlBEKqMHwTJTXa6180yeqUW7CziLM71jvbxm/tnH Y8flrXRqSL71Bg8SFbWuJUtb8+6tunPKnTMzXYlPsKx6kcl/VGQGH7mKZbpLu+GCmoPU bcWYDYK096CGEtg/egDQNLIDOT32YgFSZZtZAKDRw5Rg6KNkobwCaXQZj78wWm8X89id 9sfC6LnyCklfrQeqNDQB1xA0Nsmc6xRiKlcFkQsbCPqyQBp8AfHSZkfh94/fAztnw+GR GZbYF2ns0y5tUZubBXf/k+Hg/3R7WP8E1zUW316YJDwKT/3cW5DlFDVi3RHPEgAEpUc2 bDLQ== X-Forwarded-Encrypted: i=1; AJvYcCXK0XxsNODfRkdZIDu7U6c6IfslOIGdvYktuErRxeYAUf7mYqnyXEs7IHaWicEwIO2c2gZ+m87dM7M=@lists.infradead.org X-Gm-Message-State: AOJu0YyBe4vdxStijP98buiSEcULHk2ftfX75PE+lBFTpxu7+FppQBPA Ir2S1WHkmNVCke2kwBWAG0I7OvbYby1BtBsMVErmkGW7Pn4hc3LZ5Hjm5WvVMY0jIx+jQ621Z8/ Dvh9Kpq8= X-Gm-Gg: ATEYQzzfhzQnZARE2VJRLeMEJ5Z3m+jGnPbRcWxeojkcx/GZ9GTkshdOG2722c5NoT2 h61k18QAC/tupLrdu/yst3vEB2V4ntvpWjJksAtuROhPIWli1qdulwQXdSWEzlxc2pLNpRyFqBf RxNV56wGUBiBZ2lq/FjrqDBhjJEw7xK4EamkfQxbbg82+biQzJcLdMrH6bnrXezib85PxNrKnNg uRkpORY7wXBQt2u5Y8BHF/5lcfmsg6TEYdPVZ6oip0IRYxO40ToWeFHNOIBuGdYFQ3W24zsstGM +TzVAGiDoMUqSPSVuh6PCI51PM0mO0JqDGNCcTtZvKn89LFV2k4cOykyurdvnNdwveSB6ofT30+ C6+5w2/b8TpfPZOcgO608zjxzDBJcAKeX0Dy9uuh4gZlFF0Pwe1OUXWgF4tnpaAZtlj3uQYdY0g P09d6T2uS9GqYTNCA= X-Received: by 2002:a05:6000:144f:b0:439:b564:7a6c with SMTP id ffacd0b85a97d-439c7f6a2c9mr9158913f8f.4.1772703384539; Thu, 05 Mar 2026 01:36:24 -0800 (PST) Received: from localhost ([195.52.25.213]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439c2f7eca1sm14966458f8f.11.2026.03.05.01.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 01:36:22 -0800 (PST) Mime-Version: 1.0 Date: Thu, 05 Mar 2026 10:36:14 +0100 Message-Id: From: "Markus Schneider-Pargmann" To: "Vladimir Oltean" , Cc: "Vinod Koul" , "Neil Armstrong" , , , , , , , , , , , , , , , , , , , , , "Andrzej Hajda" , "Robert Foss" , "Laurent Pinchart" , "Jonas Karlman" , "Jernej Skrabec" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "David Airlie" , "Simona Vetter" , "Andy Yan" , "Marc Kleine-Budde" , "Vincent Mailhol" , "Nicolas Ferre" , "Alexandre Belloni" , "Claudiu Beznea" , "Markus Schneider-Pargmann" , "Geert Uytterhoeven" , "Magnus Damm" Subject: Re: [PATCH phy-next 13/22] phy: introduce phy_get_max_link_rate() helper for consumers X-Mailer: aerc 0.21.0 References: <20260304175735.2660419-1-vladimir.oltean@nxp.com> <20260304175735.2660419-14-vladimir.oltean@nxp.com> In-Reply-To: <20260304175735.2660419-14-vladimir.oltean@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260305_093627_085338_B4271D1B X-CRM114-Status: GOOD ( 24.52 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============5498570745426798129==" Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org --===============5498570745426798129== Content-Type: multipart/signed; boundary=b895f1e89350da7f8491f35b99d431866030fe6df54b62358155e9918430; micalg=pgp-sha512; protocol="application/pgp-signature" --b895f1e89350da7f8491f35b99d431866030fe6df54b62358155e9918430 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Hi, On Wed Mar 4, 2026 at 6:57 PM CET, Vladimir Oltean wrote: > Consumer drivers shouldn't dereference struct phy, not even to get to > its attributes. > > We have phy_get_bus_width() as a precedent for getting the bus_width > attribute, so let's add phy_get_max_link_rate() and use it in DRM and > CAN drivers. > > Signed-off-by: Vladimir Oltean > --- > Cc: Andrzej Hajda > Cc: Neil Armstrong > Cc: Robert Foss > Cc: Laurent Pinchart > Cc: Jonas Karlman > Cc: Jernej Skrabec > Cc: Maarten Lankhorst > Cc: Maxime Ripard > Cc: Thomas Zimmermann > Cc: David Airlie > Cc: Simona Vetter > Cc: Andy Yan > Cc: Marc Kleine-Budde > Cc: Vincent Mailhol > Cc: Nicolas Ferre > Cc: Alexandre Belloni > Cc: Claudiu Beznea > Cc: Markus Schneider-Pargmann > Cc: Geert Uytterhoeven > Cc: Magnus Damm > --- > drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 4 ++-- > drivers/gpu/drm/bridge/synopsys/dw-dp.c | 2 +- > drivers/net/can/at91_can.c | 2 +- > drivers/net/can/flexcan/flexcan-core.c | 2 +- > drivers/net/can/m_can/m_can_platform.c | 2 +- > drivers/net/can/rcar/rcar_canfd.c | 2 +- > drivers/phy/phy-core.c | 6 ++++++ > include/linux/phy/phy.h | 6 ++++++ > 8 files changed, 19 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/driver= s/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c > index a8b6ae58cb0a..ed7ed82ddb64 100644 > --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c > +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c > @@ -1300,7 +1300,7 @@ static u32 cdns_mhdp_get_training_interval_us(struc= t cdns_mhdp_device *mhdp, > =20 > static void cdns_mhdp_fill_host_caps(struct cdns_mhdp_device *mhdp) > { > - unsigned int link_rate; > + u32 link_rate; > =20 > /* Get source capabilities based on PHY attributes */ > =20 > @@ -1308,7 +1308,7 @@ static void cdns_mhdp_fill_host_caps(struct cdns_mh= dp_device *mhdp) > if (!mhdp->host.lanes_cnt) > mhdp->host.lanes_cnt =3D 4; > =20 > - link_rate =3D mhdp->phy->attrs.max_link_rate; > + link_rate =3D phy_get_max_link_rate(mhdp->phy); > if (!link_rate) > link_rate =3D drm_dp_bw_code_to_link_rate(DP_LINK_BW_8_1); > else > diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/br= idge/synopsys/dw-dp.c > index 4ab6922dd79c..79c72ee8e263 100644 > --- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c > +++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c > @@ -536,7 +536,7 @@ static int dw_dp_link_parse(struct dw_dp *dp, struct = drm_connector *connector) > =20 > link->revision =3D link->dpcd[DP_DPCD_REV]; > link->rate =3D min_t(u32, min(dp->plat_data.max_link_rate, > - dp->phy->attrs.max_link_rate * 100), > + phy_get_max_link_rate(dp->phy) * 100), > drm_dp_max_link_rate(link->dpcd)); > link->lanes =3D min_t(u8, phy_get_bus_width(dp->phy), > drm_dp_max_lane_count(link->dpcd)); > diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c > index 58da323f14d7..b56db253f02d 100644 > --- a/drivers/net/can/at91_can.c > +++ b/drivers/net/can/at91_can.c > @@ -1126,7 +1126,7 @@ static int at91_can_probe(struct platform_device *p= dev) > can_rx_offload_add_timestamp(dev, &priv->offload); > =20 > if (transceiver) > - priv->can.bitrate_max =3D transceiver->attrs.max_link_rate; > + priv->can.bitrate_max =3D phy_get_max_link_rate(transceiver); > =20 > if (at91_is_sam9263(priv)) > dev->sysfs_groups[0] =3D &at91_sysfs_attr_group; > diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/fle= xcan/flexcan-core.c > index f5d22c61503f..3a4307bc1d61 100644 > --- a/drivers/net/can/flexcan/flexcan-core.c > +++ b/drivers/net/can/flexcan/flexcan-core.c > @@ -2211,7 +2211,7 @@ static int flexcan_probe(struct platform_device *pd= ev) > priv->transceiver =3D transceiver; > =20 > if (transceiver) > - priv->can.bitrate_max =3D transceiver->attrs.max_link_rate; > + priv->can.bitrate_max =3D phy_get_max_link_rate(transceiver); > =20 > if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3) { > priv->irq_boff =3D platform_get_irq(pdev, 1); > diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_c= an/m_can_platform.c > index 56da411878af..73525be6566b 100644 > --- a/drivers/net/can/m_can/m_can_platform.c > +++ b/drivers/net/can/m_can/m_can_platform.c > @@ -132,7 +132,7 @@ static int m_can_plat_probe(struct platform_device *p= dev) > } > =20 > if (transceiver) > - mcan_class->can.bitrate_max =3D transceiver->attrs.max_link_rate; > + mcan_class->can.bitrate_max =3D phy_get_max_link_rate(transceiver); > =20 > priv->base =3D addr; > priv->mram_base =3D mram_addr; > diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rca= r_canfd.c > index eaf8cac78038..645d5671705d 100644 > --- a/drivers/net/can/rcar/rcar_canfd.c > +++ b/drivers/net/can/rcar/rcar_canfd.c > @@ -1885,7 +1885,7 @@ static int rcar_canfd_channel_probe(struct rcar_can= fd_global *gpriv, u32 ch, > priv->channel =3D ch; > priv->gpriv =3D gpriv; > if (transceiver) > - priv->can.bitrate_max =3D transceiver->attrs.max_link_rate; > + priv->can.bitrate_max =3D phy_get_max_link_rate(transceiver); > priv->can.clock.freq =3D fcan_freq; > dev_info(dev, "can_clk rate is %u\n", priv->can.clock.freq); > =20 > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c > index a1aff00fba7c..89f7410241aa 100644 > --- a/drivers/phy/phy-core.c > +++ b/drivers/phy/phy-core.c > @@ -640,6 +640,12 @@ void phy_set_bus_width(struct phy *phy, int bus_widt= h) > } > EXPORT_SYMBOL_GPL(phy_set_bus_width); > =20 > +u32 phy_get_max_link_rate(struct phy *phy) > +{ All of the can drivers that would use this function are checking phy before assigning the max_link_rate: if (transceiver) priv->can.bitrate_max =3D transceiver->attrs.max_link_rate; Would it be reasonable to have if (!phy) return 0; in this function to be able to drop these individual checks of the drivers? This would be similar to clk_get_rate() which does the same check and return 0 for convenience. Best Markus > + return phy->attrs.max_link_rate; > +} > +EXPORT_SYMBOL_GPL(phy_get_max_link_rate); > + > /** > * _of_phy_get() - lookup and obtain a reference to a phy by phandle > * @np: device_node for which to get the phy > diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h > index 36307e47760d..af9c3e795786 100644 > --- a/include/linux/phy/phy.h > +++ b/include/linux/phy/phy.h > @@ -57,6 +57,7 @@ int phy_notify_disconnect(struct phy *phy, int port); > int phy_notify_state(struct phy *phy, union phy_notify state); > int phy_get_bus_width(struct phy *phy); > void phy_set_bus_width(struct phy *phy, int bus_width); > +u32 phy_get_max_link_rate(struct phy *phy); > #else > static inline struct phy *phy_get(struct device *dev, const char *string= ) > { > @@ -256,6 +257,11 @@ static inline int phy_get_bus_width(struct phy *phy) > static inline void phy_set_bus_width(struct phy *phy, int bus_width) > { > } > + > +static inline u32 phy_get_max_link_rate(struct phy *phy) > +{ > + return 0; > +} > #endif /* IS_ENABLED(CONFIG_GENERIC_PHY) */ > =20 > #endif /* __PHY_CONSUMER_H */ --b895f1e89350da7f8491f35b99d431866030fe6df54b62358155e9918430 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iKMEABYKAEsWIQSJYVVm/x+5xmOiprOFwVZpkBVKUwUCaalOjxsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMSwyLDIRHG1zcEBiYXlsaWJyZS5jb20ACgkQhcFWaZAVSlPc SwEAt3Fg0ly9qnS+HJQv96JGhcc9ssPHPspnN0LcoiUH76oBAJJ1UWuuXcnIsBb3 namewJQN1U0nDnFUFRtJbSq49LcK =6g8b -----END PGP SIGNATURE----- --b895f1e89350da7f8491f35b99d431866030fe6df54b62358155e9918430-- --===============5498570745426798129== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy --===============5498570745426798129==--