Skip to contentSkip to conversation

phy: Set missing .owner = THIS_MODULE in phy_ops

PATCH In review Ian Rogers 2 participants 12 messages Nov 30 – Dec 1

Subsystems (12)
lore
Share & tools
lore

Ian Rogers

author
#0 lore raw

cover phy: Set missing .owner = THIS_MODULE in phy_ops

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while a PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Ten modular drivers under drivers/phy/ omit .owner = THIS_MODULE in their const struct phy_ops definitions, leaving phy->ops->owner NULL.

Split per driver to simplify per-vendor review and stable backporting.

Tooling note: Found using Clang's require_explicit_initialization attribute; an AI coding assistant helped audit call sites, verify Fixes commits, and draft the changelogs. All ten drivers were build-tested as modules (-DMODULE) with LLVM=1.

Ian Rogers (10):
phy: allwinner: phy-sun6i-mipi-dphy: Set .owner = THIS_MODULE
phy: cadence: cdns-dphy-rx: Set .owner = THIS_MODULE
phy: cadence: cdns-dphy: Set .owner = THIS_MODULE
phy: eyeq5-eth: Set .owner = THIS_MODULE
phy: google: usb: Set .owner = THIS_MODULE
phy: qcom: ipq4019-usb: Set .owner = THIS_MODULE
phy: renesas: r8a779f0-ether-serdes: Set .owner = THIS_MODULE
phy: starfive: jh7110-dphy-rx: Set .owner = THIS_MODULE
phy: sunplus: usb2: Set .owner = THIS_MODULE
phy: tegra: mphy: Set .owner = THIS_MODULE

 drivers/phy/allwinner/phy-sun6i-mipi-dphy.c | 1 +
 drivers/phy/cadence/cdns-dphy-rx.c          | 1 +
 drivers/phy/cadence/cdns-dphy.c             | 1 +
 drivers/phy/phy-eyeq5-eth.c                 | 1 +
 drivers/phy/phy-google-usb.c                | 2 ++
 drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c | 2 ++
 drivers/phy/renesas/r8a779f0-ether-serdes.c | 1 +
 drivers/phy/starfive/phy-jh7110-dphy-rx.c   | 1 +
 drivers/phy/sunplus/phy-sunplus-usb2.c      | 1 +
 drivers/phy/tegra/phy-tegra-mphy.c          | 2 ++
 10 files changed, 13 insertions(+)

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244

Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#1 lore raw

PATCH 1/10 phy: allwinner: phy-sun6i-mipi-dphy: Set .owner = THIS_MODULE

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in sun6i_dphy_ops, found with Clang's require_explicit_initialization attribute.

Fixes bb3b6fcb6849 ("sun6i: dsi: Convert to generic phy handling")
---
 drivers/phy/allwinner/phy-sun6i-mipi-dphy.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/allwinner/phy-sun6i-mipi-dphy.c +1 -0
index e5a9aa3f4aac..663b3d4d295b 100644
@@ -535,6 +535,7 @@ static const struct phy_ops sun6i_dphy_ops = {
 	.power_off	= sun6i_dphy_power_off,
 	.init		= sun6i_dphy_init,
 	.exit		= sun6i_dphy_exit,
+	.owner		= THIS_MODULE,
 };
 
 static const struct regmap_config sun6i_dphy_regmap_config = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#2 lore raw

PATCH 2/10 phy: cadence: cdns-dphy-rx: Set .owner = THIS_MODULE

In reply to Ian Rogers

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in cdns_dphy_rx_ops, found with Clang's require_explicit_initialization attribute.

Fixes 41d393aaead4 ("phy: cadence: Add Cadence D-PHY Rx driver")
---
 drivers/phy/cadence/cdns-dphy-rx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/cadence/cdns-dphy-rx.c +1 -0
index d3f7e9513dd6..97dbbe789bb5 100644
@@ -232,6 +232,7 @@ static const struct phy_ops cdns_dphy_rx_ops = {
 	.power_off = cdns_dphy_rx_power_off,
 	.configure = cdns_dphy_rx_configure,
 	.validate = cdns_dphy_rx_validate,
+	.owner = THIS_MODULE,
 };
 
 static int cdns_dphy_rx_probe(struct platform_device *pdev)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#3 lore raw

PATCH 3/10 phy: cadence: cdns-dphy: Set .owner = THIS_MODULE

In reply to Ian Rogers

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in cdns_dphy_ops, found with Clang's require_explicit_initialization attribute.

Fixes 7a343c8bf4b5 ("phy: Add Cadence D-PHY support")
---
 drivers/phy/cadence/cdns-dphy.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/cadence/cdns-dphy.c +1 -0
index 483e35c82a11..00167cefd476 100644
@@ -463,6 +463,7 @@ static const struct phy_ops cdns_dphy_ops = {
 	.validate	= cdns_dphy_validate,
 	.power_on	= cdns_dphy_power_on,
 	.power_off	= cdns_dphy_power_off,
+	.owner		= THIS_MODULE,
 };
 
 static int cdns_dphy_probe(struct platform_device *pdev)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#4 lore raw

PATCH 4/10 phy: eyeq5-eth: Set .owner = THIS_MODULE

In reply to Ian Rogers

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in eq5_phy_ops, found with Clang's require_explicit_initialization attribute.

Fixes b6e33443876d ("phy: Add driver for EyeQ5 Ethernet PHY wrapper")
---
 drivers/phy/phy-eyeq5-eth.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/phy-eyeq5-eth.c +1 -0
index fae147268f5f..69c428a867c8 100644
@@ -182,6 +182,7 @@ static const struct phy_ops eq5_phy_ops = {
 	.power_off	= eq5_phy_power_off,
 	.set_mode	= eq5_phy_set_mode,
 	.validate	= eq5_phy_validate,
+	.owner		= THIS_MODULE,
 };
 
 static struct phy *eq5_phy_xlate(struct device *dev,
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#5 lore raw

PATCH 5/10 phy: google: usb: Set .owner = THIS_MODULE

In reply to Ian Rogers

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in google_usb2_phy_ops and google_usb3_phy_ops, found with Clang's require_explicit_initialization attribute.

Fixes cbce66669c82 ("phy: Add Google Tensor SoC USB PHY driver")
Fixes 8c2b331e6327 ("phy: Add USB3 PHY support to Google Tensor SoC USB PHY driver")
---
 drivers/phy/phy-google-usb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/phy/phy-google-usb.c +2 -0
index 2acdb2b0e534..b820b1e34ad9 100644
@@ -348,6 +348,7 @@ static int google_usb2_phy_exit(struct phy *_phy)
 static const struct phy_ops google_usb2_phy_ops = {
 	.init		= google_usb2_phy_init,
 	.exit		= google_usb2_phy_exit,
+	.owner		= THIS_MODULE,
 };
 
 static int google_usb3_phy_init(struct phy *_phy)
@@ -470,6 +471,7 @@ static const struct phy_ops google_usb3_phy_ops = {
 	.init		= google_usb3_phy_init,
 	.exit		= google_usb3_phy_exit,
 	.power_on	= google_usb3_phy_power_on,
+	.owner		= THIS_MODULE,
 };
 
 static struct phy *google_usb_phy_xlate(struct device *dev,
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#6 lore raw

PATCH 6/10 phy: qcom: ipq4019-usb: Set .owner = THIS_MODULE

In reply to Ian Rogers

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in ipq4019_usb_ss_phy_ops and ipq4019_usb_hs_phy_ops, found with Clang's require_explicit_initialization attribute.

Fixes 3c9d8f6c03a2 ("phy: add driver for Qualcomm IPQ40xx USB PHY")
---
 drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/phy/qualcomm/phy-qcom-ipq4019-usb.c +2 -0
index 13ccad70e77a..afb2b10030cf 100644
@@ -50,6 +50,7 @@ static int ipq4019_ss_phy_power_on(struct phy *_phy)
 static const struct phy_ops ipq4019_usb_ss_phy_ops = {
 	.power_on	= ipq4019_ss_phy_power_on,
 	.power_off	= ipq4019_ss_phy_power_off,
+	.owner		= THIS_MODULE,
 };
 
 static int ipq4019_hs_phy_power_off(struct phy *_phy)
@@ -82,6 +83,7 @@ static int ipq4019_hs_phy_power_on(struct phy *_phy)
 static const struct phy_ops ipq4019_usb_hs_phy_ops = {
 	.power_on	= ipq4019_hs_phy_power_on,
 	.power_off	= ipq4019_hs_phy_power_off,
+	.owner		= THIS_MODULE,
 };
 
 static const struct of_device_id ipq4019_usb_phy_of_match[] = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#7 lore raw

PATCH 7/10 phy: renesas: r8a779f0-ether-serdes: Set .owner = THIS_MODULE

In reply to Ian Rogers

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in r8a779f0_eth_serdes_ops, found with Clang's require_explicit_initialization attribute.

Fixes 742859441d44 ("phy: renesas: Add Renesas Ethernet SERDES driver for R-Car S4-8")
---
 drivers/phy/renesas/r8a779f0-ether-serdes.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/renesas/r8a779f0-ether-serdes.c +1 -0
index 721d8ae527ca..c82e82fe7656 100644
@@ -404,6 +404,7 @@ static const struct phy_ops r8a779f0_eth_serdes_ops = {
 	.power_on	= r8a779f0_eth_serdes_power_on,
 	.set_mode	= r8a779f0_eth_serdes_set_mode,
 	.set_speed	= r8a779f0_eth_serdes_set_speed,
+	.owner		= THIS_MODULE,
 };
 
 static struct phy *r8a779f0_eth_serdes_xlate(struct device *dev,
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#8 lore raw

PATCH 8/10 phy: starfive: jh7110-dphy-rx: Set .owner = THIS_MODULE

In reply to Ian Rogers

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in stf_dphy_ops, found with Clang's require_explicit_initialization attribute.

Fixes f8aa660841bc ("phy: starfive: Add mipi dphy rx support")
---
 drivers/phy/starfive/phy-jh7110-dphy-rx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/starfive/phy-jh7110-dphy-rx.c +1 -0
index 043a7e11d187..895a9ff5ca0d 100644
@@ -144,6 +144,7 @@ static const struct phy_ops stf_dphy_ops = {
 	.configure = stf_dphy_configure,
 	.power_on  = stf_dphy_power_on,
 	.power_off = stf_dphy_power_off,
+	.owner     = THIS_MODULE,
 };
 
 static int stf_dphy_probe(struct platform_device *pdev)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#10 lore raw

PATCH 9/10 phy: sunplus: usb2: Set .owner = THIS_MODULE

In reply to Ian Rogers

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in sp_uphy_ops, found with Clang's require_explicit_initialization attribute.

Fixes 99d9ccd97385 ("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
---
 drivers/phy/sunplus/phy-sunplus-usb2.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/sunplus/phy-sunplus-usb2.c +1 -0
index 6fe096ff1e43..15c068ae48c1 100644
@@ -227,6 +227,7 @@ static const struct phy_ops sp_uphy_ops = {
 	.power_on	= sp_uphy_power_on,
 	.power_off	= sp_uphy_power_off,
 	.exit		= sp_uphy_exit,
+	.owner		= THIS_MODULE,
 };
 
 static const struct of_device_id sp_uphy_dt_ids[] = {
Signature · 1 line
2.56.1.839.g22a8290db9-goog
author
#11 lore raw

PATCH 10/10 phy: tegra: mphy: Set .owner = THIS_MODULE

In reply to Ian Rogers

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Set .owner = THIS_MODULE in tegra_mphy_rx_ops and tegra_mphy_tx_ops, found with Clang's require_explicit_initialization attribute.

Fixes 256cb243f4c2 ("phy: tegra: Add Tegra264 MPHY driver")
---
 drivers/phy/tegra/phy-tegra-mphy.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/phy/tegra/phy-tegra-mphy.c +2 -0
index 17722aaaa361..a054c102229a 100644
@@ -276,6 +276,7 @@ static const struct phy_ops tegra_mphy_rx_ops = {
 	.power_off = tegra_mphy_rx_power_off,
 	.configure = tegra_mphy_rx_configure,
 	.calibrate = tegra_mphy_rx_calibrate,
+	.owner = THIS_MODULE,
 };
 
 static int tegra_mphy_tx_configure(struct phy *phy, union phy_configure_opts *opts)
@@ -339,6 +340,7 @@ static int tegra_mphy_tx_calibrate(struct phy *phy)
 static const struct phy_ops tegra_mphy_tx_ops = {
 	.configure = tegra_mphy_tx_configure,
 	.calibrate = tegra_mphy_tx_calibrate,
+	.owner = THIS_MODULE,
 };
 
 static struct phy *tegra_mphy_xlate(struct device *dev, const struct of_phandle_args *args)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
maintainer Reviewed-by on v1 8/10
#9 lore raw

回复: [PATCH 08/10] phy: starfive: jh7110-dphy-rx: Set .owner = THIS_MODULE

In reply to Ian Rogers

Hi, lan

Thanks for the patch.

Quoted 7 lines

phy_get() and of_phy_get() call try_module_get(phy->ops->owner) to pin the PHY provider module while the PHY is in use, and of_phy_put() calls module_put(phy->ops->owner). Because phy->ops is const struct phy_ops *, phy_create() cannot populate ops->owner at runtime, and try_module_get(NULL) returns true without incrementing the module reference count.

Quoted 5 lines

Set .owner = THIS_MODULE in stf_dphy_ops, found with Clang's require_explicit_initialization attribute.

Fixes f8aa660841bc ("phy: starfive: Add mipi dphy rx support")

Best Regards,
Changhuang