drm/bridge: analogix_dp: use devm_phy_optional_get() for the DP PHY
Subsystems (4)
PATCH v3 1/1 drm/bridge: analogix_dp: use devm_phy_optional_get() for the DP PHY
The DP PHY is optional: the Rockchip RK3399 eDP controller (used as the internal eDP port) has no separate PHY device and relies on its built-in PHY, which is programmed directly through the GRF registers, so its DT node carries no "phys"/"phy-names" property.
Requesting the PHY with devm_phy_get() therefore returns -ENODEV (or -ENOSYS when CONFIG_GENERIC_PHY is disabled) and the driver logs a misleading "no DP phy configured" error at probe time before falling back to a NULL phy.
Use devm_phy_optional_get() instead, which returns NULL when the PHY is absent and otherwise behaves identically, and drop the manual -ENODEV/ -ENOSYS handling. This also removes the spurious error message.
---
Changes in v3:
- Add missing changelog entries and reference links
- Link to v2: https://lore.kernel.org/dri-devel/[email protected]/
Changes in v2:
- Added comments to explain the changes made.
- Link to v1: https://lore.kernel.org/dri-devel/[email protected]/
.../drm/bridge/analogix/analogix_dp_core.c | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +7 -15
@@ -1426,21 +1426,13 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)if (ret)return ERR_PTR (ret); - dp->phy =devm_phy_get (dp->dev,"dp" ); -if (IS_ERR (dp->phy)) { -dev_err (dp->dev,"no DP phy configured\n" ); - ret =PTR_ERR (dp->phy); -if (ret) { -/* -* phy itself is not enabled, so we can move forward -* assigning NULL to phy pointer. -*/ -if (ret == -ENOSYS || ret == -ENODEV ) - dp->phy =NULL ; -else -return ERR_PTR (ret); - } - } +/* +* RK3288/RK3399 use Analogix DP controller built-in PHY, +* no extra PHY configuration is required. +*/ + dp->phy =devm_phy_optional_get (dp->dev,"dp" ); +if (IS_ERR (dp->phy)) +return ERR_CAST (dp->phy); dp->clock =devm_clk_get (&pdev->dev,"dp" );if (IS_ERR (dp->clock)) {
Signature · 1 line
2.56.0
Luca Ceresoli
reviewerHello,
Quoted 48 lines · Jun Yan
The DP PHY is optional: the Rockchip RK3399 eDP controller (used as the internal eDP port) has no separate PHY device and relies on its built-in PHY, which is programmed directly through the GRF registers, so its DT node carries no "phys"/"phy-names" property.
Requesting the PHY with
devm_phy_get()therefore returns-ENODEV(or-ENOSYSwhenCONFIG_GENERIC_PHYis disabled) and the driver logs a misleading "no DP phy configured" error at probe time before falling back to a NULL phy.Use
devm_phy_optional_get()instead, which returns NULL when the PHY is absent and otherwise behaves identically, and drop the manual -ENODEV/-ENOSYShandling. This also removes the spurious error message.Signed-off-by Jun Yan <[email protected]>Reviewed-by Damon Ding <[email protected]>---
Changes in v3:
- Add missing changelog entries and reference links
- Link to v2: https://lore.kernel.org/dri-devel/[email protected]/Changes in v2:
- Added comments to explain the changes made.
- Link to v1: https://lore.kernel.org/dri-devel/[email protected]/.../drm/bridge/analogix/analogix_dp_core.c | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-)drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-12@@ -1426,21 +1426,13 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)if (ret)return ERR_PTR (ret); - dp->phy =devm_phy_get (dp->dev,"dp" ); -if (IS_ERR (dp->phy)) { -dev_err (dp->dev,"no DP phy configured\n" ); - ret =PTR_ERR (dp->phy); -if (ret) { -/* -* phy itself is not enabled, so we can move forward -* assigning NULL to phy pointer. -*/ -if (ret == -ENOSYS || ret == -ENODEV ) - dp->phy =NULL ; -else
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) · line 1435
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +7
-3-return ERR_PTR (ret); - } - } +/* +* RK3288/RK3399 use Analogix DP controller built-in PHY, +* no extra PHY configuration is required. +*/ + dp->phy =devm_phy_optional_get (dp->dev,"dp" ); +if (IS_ERR (dp->phy)) +return ERR_CAST (dp->phy);
The original code ignbores -ENOSYS, devm_phy_optional_get() does not. So, either -ENOSYS was just impossible, or this patch potentially changes the behaviour.
Can you elaborate on that?
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Quoted 66 lines · Luca Ceresoli
Hello,
Quoted 48 lines · Jun Yan
The DP PHY is optional: the Rockchip RK3399 eDP controller (used as the internal eDP port) has no separate PHY device and relies on its built-in PHY, which is programmed directly through the GRF registers, so its DT node carries no "phys"/"phy-names" property.
Requesting the PHY with
devm_phy_get()therefore returns-ENODEV(or-ENOSYSwhenCONFIG_GENERIC_PHYis disabled) and the driver logs a misleading "no DP phy configured" error at probe time before falling back to a NULL phy.Use
devm_phy_optional_get()instead, which returns NULL when the PHY is absent and otherwise behaves identically, and drop the manual -ENODEV/-ENOSYShandling. This also removes the spurious error message.Signed-off-by Jun Yan <[email protected]>Reviewed-by Damon Ding <[email protected]>---
Changes in v3:
- Add missing changelog entries and reference links
- Link to v2: https://lore.kernel.org/dri-devel/[email protected]/Changes in v2:
- Added comments to explain the changes made.
- Link to v1: https://lore.kernel.org/dri-devel/[email protected]/.../drm/bridge/analogix/analogix_dp_core.c | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-)drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-12@@ -1426,21 +1426,13 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)if (ret)return ERR_PTR (ret); - dp->phy =devm_phy_get (dp->dev,"dp" ); -if (IS_ERR (dp->phy)) { -dev_err (dp->dev,"no DP phy configured\n" ); - ret =PTR_ERR (dp->phy); -if (ret) { -/* -* phy itself is not enabled, so we can move forward -* assigning NULL to phy pointer. -*/ -if (ret == -ENOSYS || ret == -ENODEV ) - dp->phy =NULL ; -else drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) · line 1435
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +7
-3-return ERR_PTR (ret); - } - } +/* +* RK3288/RK3399 use Analogix DP controller built-in PHY, +* no extra PHY configuration is required. +*/ + dp->phy =devm_phy_optional_get (dp->dev,"dp" ); +if (IS_ERR (dp->phy)) +return ERR_CAST (dp->phy);The original code ignbores
-ENOSYS,devm_phy_optional_get()does not. So, either-ENOSYSwas just impossible, or this patch potentially changes the behaviour.
Quoted 3 lines
Can you elaborate on that?
You are right, this is really a valid concern.
If CONFIG_GENERIC_PHY is disabled, the old code could still proceed and keep the driver probing, while the new version would return an error directly.
It should be better to keep the -ENOSYS handling to preserve the original behavior.
Best regards,
Damon
Hi Damon,
Quoted 5 lines
You are right, this is really a valid concern.
If
CONFIG_GENERIC_PHYis disabled, the old code could still proceed and keep the driver probing, while the new version would return an error directly.
-ENOSYS can only come from the !CONFIG_GENERIC_PHY stubs in include/linux/phy/phy.h; the real implementation in drivers/phy/phy-core.c never returns it. And the stub for the optional variant returns NULL, not -ENOSYS:
static inline struct phy *devm_phy_optional_get(struct device *dev,
const char *string)
{
return NULL;
}So with CONFIG_GENERIC_PHY disabled the PHY is still treated as absent (NULL), exactly as the old -ENOSYS branch did. With CONFIG_GENERIC_PHY enabled, -ENOSYS cannot occur, devm_phy_optional_get() turns -ENODEV into NULL, and any other error is still propagated - same as the open-coded check.
Quoted 2 lines
It should be better to keep the
-ENOSYShandling to preserve the original behavior.
Overall the behaviour is unchanged in both configurations, so no separate handling is needed.
Best regards,
Jun Yan
Luca Ceresoli
reviewerHello,
Quoted 25 lines · Jun Yan
Hi Damon,
Quoted 5 lines
You are right, this is really a valid concern.
If
CONFIG_GENERIC_PHYis disabled, the old code could still proceed and keep the driver probing, while the new version would return an error directly.
-ENOSYScan only come from the !CONFIG_GENERIC_PHY stubs ininclude/linux/phy/phy.h; the real implementation indrivers/phy/phy-core.cnever returns it. And the stub for the optional variant returns NULL, not-ENOSYS:static inline struct phy *devm_phy_optional_get(struct device *dev, const char *string) { return NULL; }So with
CONFIG_GENERIC_PHYdisabled the PHY is still treated as absent (NULL), exactly as the old-ENOSYSbranch did. WithCONFIG_GENERIC_PHYenabled,-ENOSYScannot occur,devm_phy_optional_get()turns-ENODEVinto NULL, and any other error is still propagated - same as the open-coded check.
Quoted 5 lines
Quoted 2 lines
It should be better to keep the
-ENOSYShandling to preserve the original behavior.Overall the behaviour is unchanged in both configurations, so no separate handling is needed.
Thanks for the analysis! Cna you send a v4 with that explained in the commit message, possibly in a more concise way, maybe with bullets for the various CONFIG_GENERIC_PHY on/off cases or so, for readability?
Reading it now, this v3 commit message kind of said the same things. but it misled both me and Damon, so it's worth a clear explanation.
Thanks!
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Hi Luca,
Quoted 32 lines
Hello,
Quoted 10 lines · Jun Yan
Hi Damon,
Quoted 5 lines
You are right, this is really a valid concern.
If
CONFIG_GENERIC_PHYis disabled, the old code could still proceed and keep the driver probing, while the new version would return an error directly.
-ENOSYScan only come from the !CONFIG_GENERIC_PHY stubs ininclude/linux/phy/phy.h; the real implementation in drivers/phy/phy-core.=c
Quoted 18 lines
never returns it. And the stub for the optional variant returns NULL, not
-ENOSYS:static inline struct phy *devm_phy_optional_get(struct device *dev, const char *string) { return NULL; }So with
CONFIG_GENERIC_PHYdisabled the PHY is still treated as absent (NULL), exactly as the old-ENOSYSbranch did. WithCONFIG_GENERIC_PHYenabled,-ENOSYScannot occur,devm_phy_optional_get()turns-ENODEVinto NULL, and any other error is still propagated - same as the open-coded check.Quoted 2 lines
It should be better to keep the
-ENOSYShandling to preserve the original behavior.
Quoted 7 lines
Quoted 2 lines
Overall the behaviour is unchanged in both configurations, so no separate handling is needed.
Thanks for the analysis! Cna you send a v4 with that explained in the commit message, possibly in a more concise way, maybe with bullets for the various
CONFIG_GENERIC_PHYon/off cases or so, for readability?
Yes, I'll send a v4.
Quoted 6 lines
Reading it now, this v3 commit message kind of said the same things. but it misled both me and Damon, so it's worth a clear explanation.
Thanks!
Luca
Thanks,
Jun