Skip to contentSkip to conversation

mmc: dw_mmc-rockchip: Add missing private data for very old controllers

PATCH In review Heiko Stuebner 3 participants 3 messages May 22 – May 29

Subsystems (4)
lore
Share & tools
lore

Heiko Stuebner

author maintainer
#0 lore raw

PATCH 1/1 mmc: dw_mmc-rockchip: Add missing private data for very old controllers

The really old controllers (rk2928, rk3066, rk3188) do not support UHS speeds at all, and thus never handled phase data.

For that reason it never had a parse_dt callback and no driver private data at all.

Commit ff6f0286c896 ("mmc: dw_mmc-rockchip: Add memory clock auto-gating support") makes the private data sort of mandatory, because the init function checks whether phases are configured internally or through the clock controller.

This results in the old SoCs then experiencing NULL-pointer dereferences when they try to access that private-data struct.

While we could have if (priv) conditionals in all places, it's way less cluttery to just give the old types their private-data struct.

Fixes ff6f0286c896 ("mmc: dw_mmc-rockchip: Add memory clock auto-gating support")
---
 drivers/mmc/host/dw_mmc-rockchip.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/host/dw_mmc-rockchip.c +17 -0
index c6eece4ec3fd..75c82ff20f17 100644
@@ -441,6 +441,22 @@ static int dw_mci_common_parse_dt(struct dw_mci *host)
 	return 0;
 }
 
+static int dw_mci_rk2928_parse_dt(struct dw_mci *host)
+{
+	struct dw_mci_rockchip_priv_data *priv;
+	int err;
+
+	err = dw_mci_common_parse_dt(host);
+	if (err)
+		return err;
+
+	priv = host->priv;
+
+	priv->internal_phase = false;
+
+	return 0;
+}
+
 static int dw_mci_rk3288_parse_dt(struct dw_mci *host)
 {
 	struct dw_mci_rockchip_priv_data *priv;
@@ -514,6 +530,7 @@ static int dw_mci_rockchip_init(struct dw_mci *host)
 
 static const struct dw_mci_drv_data rk2928_drv_data = {
 	.init			= dw_mci_rockchip_init,
+	.parse_dt		= dw_mci_rk2928_parse_dt,
 };
 
 static const struct dw_mci_drv_data rk3288_drv_data = {
Signature · 1 line
2.47.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Heiko Stuebner

The really old controllers (rk2928, rk3066, rk3188) do not support UHS speeds at all, and thus never handled phase data.

For that reason it never had a parse_dt callback and no driver private data at all.

Commit ff6f0286c896 ("mmc: dw_mmc-rockchip: Add memory clock auto-gating support") makes the private data sort of mandatory, because the init function checks whether phases are configured internally or through the clock controller.

Quoted 5 lines

This results in the old SoCs then experiencing NULL-pointer dereferences when they try to access that private-data struct.

While we could have if (priv) conditionals in all places, it's way less cluttery to just give the old types their private-data struct.

Thanks for fixing this.

Quoted 43 lines
Fixes ff6f0286c896 ("mmc: dw_mmc-rockchip: Add memory clock auto-gating support")
---
  drivers/mmc/host/dw_mmc-rockchip.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/mmc/host/dw_mmc-rockchip.c +17 -0
index c6eece4ec3fd..75c82ff20f17 100644
@@ -441,6 +441,22 @@ static int dw_mci_common_parse_dt(struct dw_mci *host)
  	return 0;
  }
 
+static int dw_mci_rk2928_parse_dt(struct dw_mci *host)
+{
+	struct dw_mci_rockchip_priv_data *priv;
+	int err;
+
+	err = dw_mci_common_parse_dt(host);
+	if (err)
+		return err;
+
+	priv = host->priv;
+
+	priv->internal_phase = false;
+
+	return 0;
+}
+
  static int dw_mci_rk3288_parse_dt(struct dw_mci *host)
  {
  	struct dw_mci_rockchip_priv_data *priv;
@@ -514,6 +530,7 @@ static int dw_mci_rockchip_init(struct dw_mci *host)
 
  static const struct dw_mci_drv_data rk2928_drv_data = {
  	.init			= dw_mci_rockchip_init,
+	.parse_dt		= dw_mci_rk2928_parse_dt,
  };
 
  static const struct dw_mci_drv_data rk3288_drv_data = {
#2 lore raw
In reply to Heiko Stuebner
Quoted 15 lines · Heiko Stuebner

The really old controllers (rk2928, rk3066, rk3188) do not support UHS speeds at all, and thus never handled phase data.

For that reason it never had a parse_dt callback and no driver private data at all.

Commit ff6f0286c896 ("mmc: dw_mmc-rockchip: Add memory clock auto-gating support") makes the private data sort of mandatory, because the init function checks whether phases are configured internally or through the clock controller.

This results in the old SoCs then experiencing NULL-pointer dereferences when they try to access that private-data struct.

Quoted 6 lines

While we could have if (priv) conditionals in all places, it's way less cluttery to just give the old types their private-data struct.

Fixes ff6f0286c896 ("mmc: dw_mmc-rockchip: Add memory clock auto-gating support")

Applied for fixes, thanks!

Kind regards
Uffe

Quoted 47 lines
---
 drivers/mmc/host/dw_mmc-rockchip.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/host/dw_mmc-rockchip.c +17 -1
index c6eece4ec3fd..75c82ff20f17 100644
@@ -441,6 +441,22 @@ static int dw_mci_common_parse_dt(struct dw_mci *host)
        return 0;
 }
 
+static int dw_mci_rk2928_parse_dt(struct dw_mci *host)
+{
+       struct dw_mci_rockchip_priv_data *priv;
+       int err;
+
+       err = dw_mci_common_parse_dt(host);
+       if (err)
+               return err;
+
+       priv = host->priv;
+
+       priv->internal_phase = false;
+
+       return 0;
+}
+
 static int dw_mci_rk3288_parse_dt(struct dw_mci *host)
 {
        struct dw_mci_rockchip_priv_data *priv;
@@ -514,6 +530,7 @@ static int dw_mci_rockchip_init(struct dw_mci *host)
 
 static const struct dw_mci_drv_data rk2928_drv_data = {
        .init                   = dw_mci_rockchip_init,
+       .parse_dt               = dw_mci_rk2928_parse_dt,
 };
 
 static const struct dw_mci_drv_data rk3288_drv_data = {
--

2.47.3

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip