Skip to contentSkip to conversation

pinctrl: sh-pfc: r8a77970: remove SH_PFC_PIN_CFG_DRIVE_STRENGTH flag

PATCH Superseded Niklas Söderlund 5 participants 7 messages Jul 2, 2018 – Jul 3, 2018 Pin control

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: sh-pfc: r8a77970: remove SH_PFC_PIN_CFG_DRIVE_STRENGTH flag

The datasheet do not document any registers to control drive strength, and no drive strength registers are for this reason described for this SoC. The flag indicating that drive strength can be controlled are however set for some pins in the driver.

This leads to a NULL pointer dereference when the sh-pfc core tries to access the struct describing the drive strength registers, for example when reading the sysfs file pinconf-pins.

Fix this by removing the SH_PFC_PIN_CFG_DRIVE_STRENGTH from all pins.

---
 drivers/pinctrl/sh-pfc/pfc-r8a77970.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/pinctrl/sh-pfc/pfc-r8a77970.c +6 -8
index b02caf31671186d9..eeb58b3bbc9a0cef 100644
@@ -21,15 +21,13 @@
 #include "core.h"
 #include "sh_pfc.h"
 
-#define CFG_FLAGS SH_PFC_PIN_CFG_DRIVE_STRENGTH
-
 #define CPU_ALL_PORT(fn, sfx)						\
-	PORT_GP_CFG_22(0, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-	PORT_GP_CFG_28(1, fn, sfx, CFG_FLAGS),				\
-	PORT_GP_CFG_17(2, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-	PORT_GP_CFG_17(3, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-	PORT_GP_CFG_6(4,  fn, sfx, CFG_FLAGS),				\
-	PORT_GP_CFG_15(5, fn, sfx, CFG_FLAGS)
+	PORT_GP_CFG_22(0, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),		\
+	PORT_GP_28(1, fn, sfx),						\
+	PORT_GP_CFG_17(2, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),		\
+	PORT_GP_CFG_17(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),		\
+	PORT_GP_6(4,  fn, sfx),						\
+	PORT_GP_15(5, fn, sfx)
 /*
  * F_() : just information
  * FM() : macro for FN_xxx / xxx_MARK
Signature · 1 line
2.17.0
Reviewed-by on v1 1/1
#1 lore raw

CC Sergei,

Thanks for your patch!

Quoted 1 line · Niklas Söderlund

The datasheet do not document any registers to control drive strength,

does

Quoted 2 lines

and no drive strength registers are for this reason described for this SoC. The flag indicating that drive strength can be controlled are

flags

Quoted 9 lines

however set for some pins in the driver.

This leads to a NULL pointer dereference when the sh-pfc core tries to access the struct describing the drive strength registers, for example when reading the sysfs file pinconf-pins.

Fix this by removing the SH_PFC_PIN_CFG_DRIVE_STRENGTH from all pins.

I'll wait a bit for Sergei's response.
Perhaps his version of the datasheet does document drive strength registers?

Quoted 14 lines
drivers/pinctrl/sh-pfc/pfc-r8a77970.c +0 -7
@@ -21,15 +21,13 @@
 #include "core.h"
 #include "sh_pfc.h"
 
-#define CFG_FLAGS SH_PFC_PIN_CFG_DRIVE_STRENGTH
-
 #define CPU_ALL_PORT(fn, sfx)                                          \
-       PORT_GP_CFG_22(0, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-       PORT_GP_CFG_28(1, fn, sfx, CFG_FLAGS),                          \
-       PORT_GP_CFG_17(2, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-       PORT_GP_CFG_17(3, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-       PORT_GP_CFG_6(4,  fn, sfx, CFG_FLAGS),                          \

drivers/pinctrl/sh-pfc/pfc-r8a77970.c line 33

Quoted 10 lines
drivers/pinctrl/sh-pfc/pfc-r8a77970.c +6 -1
-       PORT_GP_CFG_15(5, fn, sfx, CFG_FLAGS)
+       PORT_GP_CFG_22(0, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),          \
+       PORT_GP_28(1, fn, sfx),                                         \
+       PORT_GP_CFG_17(2, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),          \
+       PORT_GP_CFG_17(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),          \
+       PORT_GP_6(4,  fn, sfx),                                         \
+       PORT_GP_15(5, fn, sfx)
 /*
  * F_() : just information
  * FM() : macro for FN_xxx / xxx_MARK

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#2 lore raw

Hello!

Quoted 21 lines · Geert Uytterhoeven

CC Sergei,

Thanks for your patch!

Quoted 1 line · Niklas Söderlund

The datasheet do not document any registers to control drive strength,

does

Quoted 2 lines

and no drive strength registers are for this reason described for this SoC. The flag indicating that drive strength can be controlled are

flags

Quoted 6 lines

however set for some pins in the driver.

This leads to a NULL pointer dereference when the sh-pfc core tries to access the struct describing the drive strength registers, for example when reading the sysfs file pinconf-pins.

Quoted 8 lines
Quoted 3 lines

Fix this by removing the SH_PFC_PIN_CFG_DRIVE_STRENGTH from all pins.

I'll wait a bit for Sergei's response.
Perhaps his version of the datasheet does document drive strength registers?

No, I have v1.00 which doesn't tell about drive control on V3M indeed.

MBR, Sergei

#3 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Thanks for your feedback.

Quoted 21 lines · Geert Uytterhoeven

CC Sergei,

Thanks for your patch!

Quoted 1 line · Niklas S�derlund

The datasheet do not document any registers to control drive strength,

does

Quoted 2 lines

and no drive strength registers are for this reason described for this SoC. The flag indicating that drive strength can be controlled are

flags

Quoted 6 lines

however set for some pins in the driver.

This leads to a NULL pointer dereference when the sh-pfc core tries to access the struct describing the drive strength registers, for example when reading the sysfs file pinconf-pins.

Quoted 8 lines
Quoted 3 lines

Fix this by removing the SH_PFC_PIN_CFG_DRIVE_STRENGTH from all pins.

I'll wait a bit for Sergei's response.
Perhaps his version of the datasheet does document drive strength registers?

Do you wish for a v2 addressing the spelling above or can you fix that when applying?

Quoted 36 lines
Quoted 15 lines
drivers/pinctrl/sh-pfc/pfc-r8a77970.c +0 -7
@@ -21,15 +21,13 @@
 #include "core.h"
 #include "sh_pfc.h"
 
-#define CFG_FLAGS SH_PFC_PIN_CFG_DRIVE_STRENGTH
-
 #define CPU_ALL_PORT(fn, sfx)                                          \
-       PORT_GP_CFG_22(0, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-       PORT_GP_CFG_28(1, fn, sfx, CFG_FLAGS),                          \
-       PORT_GP_CFG_17(2, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-       PORT_GP_CFG_17(3, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-       PORT_GP_CFG_6(4,  fn, sfx, CFG_FLAGS),                          \

drivers/pinctrl/sh-pfc/pfc-r8a77970.c line 33

Quoted 10 lines
drivers/pinctrl/sh-pfc/pfc-r8a77970.c +6 -1
-       PORT_GP_CFG_15(5, fn, sfx, CFG_FLAGS)
+       PORT_GP_CFG_22(0, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),          \
+       PORT_GP_28(1, fn, sfx),                                         \
+       PORT_GP_CFG_17(2, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),          \
+       PORT_GP_CFG_17(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),          \
+       PORT_GP_6(4,  fn, sfx),                                         \
+       PORT_GP_15(5, fn, sfx)
 /*
  * F_() : just information
  * FM() : macro for FN_xxx / xxx_MARK

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Signature · 2 lines
Regards,
Niklas S�derlund
#4 lore raw

Hi Niklas,

CC LinusW

Quoted 26 lines · Niklas Söderlund
Quoted 25 lines · Geert Uytterhoeven

CC Sergei,

Thanks for your patch!

Quoted 1 line · Niklas Söderlund

The datasheet do not document any registers to control drive strength,

does

Quoted 2 lines

and no drive strength registers are for this reason described for this SoC. The flag indicating that drive strength can be controlled are

flags

Quoted 9 lines

however set for some pins in the driver.

This leads to a NULL pointer dereference when the sh-pfc core tries to access the struct describing the drive strength registers, for example when reading the sysfs file pinconf-pins.

Fix this by removing the SH_PFC_PIN_CFG_DRIVE_STRENGTH from all pins.

Quoted 7 lines
Quoted 4 lines

I'll wait a bit for Sergei's response.
Perhaps his version of the datasheet does document drive strength registers?

Do you wish for a v2 addressing the spelling above or can you fix that when applying?

Given this fixes a crash, I think this is a fix for v4.18. So please send a v2 straight to LinusW, with

    Fixes: b92ac66a1819602b ("pinctrl: sh-pfc: Add R8A77970 PFC support")

Unfortunately the code has changed since the issue was introduced, so please send an applicable fix for v4.16/v4.17 to stable after the fix has entered upstream.

Thanks!

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/pinctrl/sh-pfc/pfc-r8a77970.c +1 -8
@@ -21,15 +21,13 @@
 #include "core.h"
 #include "sh_pfc.h"
 
-#define CFG_FLAGS SH_PFC_PIN_CFG_DRIVE_STRENGTH
-
 #define CPU_ALL_PORT(fn, sfx)                                          \
-       PORT_GP_CFG_22(0, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-       PORT_GP_CFG_28(1, fn, sfx, CFG_FLAGS),                          \
-       PORT_GP_CFG_17(2, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-       PORT_GP_CFG_17(3, fn, sfx, CFG_FLAGS | SH_PFC_PIN_CFG_IO_VOLTAGE), \
-       PORT_GP_CFG_6(4,  fn, sfx, CFG_FLAGS),                          \
-       PORT_GP_CFG_15(5, fn, sfx, CFG_FLAGS)
+       PORT_GP_CFG_22(0, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),          \
Quoted 8 lines
Quoted 8 lines

drivers/pinctrl/sh-pfc/pfc-r8a77970.c line 33

Quoted 8 lines
drivers/pinctrl/sh-pfc/pfc-r8a77970.c +5 -0
+       PORT_GP_28(1, fn, sfx),                                         \
+       PORT_GP_CFG_17(2, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),          \
+       PORT_GP_CFG_17(3, fn, sfx, SH_PFC_PIN_CFG_IO_VOLTAGE),          \
+       PORT_GP_6(4,  fn, sfx),                                         \
+       PORT_GP_15(5, fn, sfx)
 /*
  * F_() : just information
  * FM() : macro for FN_xxx / xxx_MARK

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Reviewed-by on v1 1/1
#5 lore raw
In reply to Niklas Söderlund
Quoted 5 lines · Niklas Söderlund

The datasheet do not document any registers to control drive strength, and no drive strength registers are for this reason described for this SoC. The flag indicating that drive strength can be controlled are however set for some pins in the driver.

Quoted 7 lines

This leads to a NULL pointer dereference when the sh-pfc core tries to access the struct describing the drive strength registers, for example when reading the sysfs file pinconf-pins.

Fix this by removing the SH_PFC_PIN_CFG_DRIVE_STRENGTH from all pins.

Reviewed-by on v1 1/1
#6 lore raw
In reply to Niklas Söderlund

Hello!

Quoted 10 lines · Niklas Söderlund

The datasheet do not document any registers to control drive strength, and no drive strength registers are for this reason described for this SoC. The flag indicating that drive strength can be controlled are however set for some pins in the driver.

This leads to a NULL pointer dereference when the sh-pfc core tries to access the struct describing the drive strength registers, for example when reading the sysfs file pinconf-pins.

Fix this by removing the SH_PFC_PIN_CFG_DRIVE_STRENGTH from all pins.

Sorry about overlooking this!

Quoted 1 line

[...]

MBR, Sergei