Skip to contentSkip to conversation

Candidates from Spreadtrum 4.14 product kernel

PATCH In review Baolin Wang 2 participants 6 messages Sep 25, 2019 – Sep 26, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover Candidates from Spreadtrum 4.14 product kernel

With Arnd's script [1] help, I found some bugfixes in Spreadtrum 4.14 product kernel, but missing in v4.14.146:

513e1073d52e locking/lockdep: Add debug_locks check in __lock_downgrade() 957063c92473 pinctrl: sprd: Use define directive for sprd_pinconf_params values 87a2b65fc855 power: supply: sysfs: ratelimit property read error message

[1] https://lore.kernel.org/lkml/[email protected]/T/

Changes from v2:
- Drop 2 unnecessary patches (patch 1 and patch 6) from v2 patch set.
- Backport these patches to 4.19.y.

Changes from v1:
- Drop 2 unnecessary patches (patch 1 and patch 4) from v1 patch set.
- Add upstream commit id in change log for each stable patch.

David Lechner (1):
power: supply: sysfs: ratelimit property read error message

Nathan Chancellor (1):
pinctrl: sprd: Use define directive for sprd_pinconf_params values

Waiman Long (1):
locking/lockdep: Add debug_locks check in __lock_downgrade()

 drivers/pinctrl/sprd/pinctrl-sprd.c       |    6 ++----
 drivers/power/supply/power_supply_sysfs.c |    3 ++-
 kernel/locking/lockdep.c                  |    3 +++
 3 files changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/3 locking/lockdep: Add debug_locks check in __lock_downgrade()

From: Waiman Long <[email protected]>

[Upstream commit 513e1073d52e55b8024b4f238a48de7587c64ccf]

Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning.

Fix that by add a check for debug_locks at the beginning of __lock_downgrade().

---
 kernel/locking/lockdep.c |    3 +++
 1 file changed, 3 insertions(+)
kernel/locking/lockdep.c +3 -0
index 565005a..5c370c6 100644
@@ -3650,6 +3650,9 @@ static int reacquire_held_locks(struct task_struct *curr, unsigned int depth,
 	unsigned int depth;
 	int i;
 
+	if (unlikely(!debug_locks))
+		return 0;
+
 	depth = curr->lockdep_depth;
 	/*
 	 * This function is about (re)setting the class of a held lock,
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [BACKPORT 4.14.y v3 1/3] locking/lockdep: Add debug_locks check in __lock_downgrade()

Quoted 34 lines · Baolin Wang

From: Waiman Long <[email protected]>

[Upstream commit 513e1073d52e55b8024b4f238a48de7587c64ccf]

Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning.

Fix that by add a check for debug_locks at the beginning of __lock_downgrade().

---
 kernel/locking/lockdep.c |    3 +++
 1 file changed, 3 insertions(+)
kernel/locking/lockdep.c +0 -0
index 565005a..5c370c6 100644

kernel/locking/lockdep.c static int reacquire_held_locks(struct task_struct *curr, unsigned int depth, · line 3658

Quoted 9 lines
kernel/locking/lockdep.c +3 -0
@@ -3650,6 +3650,9 @@ static int reacquire_held_locks(struct task_struct *curr, unsigned int depth,
 	unsigned int depth;
 	int i;
 
+	if (unlikely(!debug_locks))
+		return 0;
+
 	depth = curr->lockdep_depth;
 	/*
 	 * This function is about (re)setting the class of a held lock,

Apparently, there are 2 such patches in the upstream kernel - commit 513e1073d52e55b8024b4f238a48de7587c64ccf and 71492580571467fb7177aade19c18ce7486267f5. These are probably caused by the fact that there are 2 places in the code that can match the hunks. Anyway, this looks like it is applying to the wrong function. It should be applied to __lock_downgrade. Though it shouldn't harm if it is applied to the wrong function.

Cheers,
Longman

#3 lore raw

Re: [BACKPORT 4.14.y v3 1/3] locking/lockdep: Add debug_locks check in __lock_downgrade()

Quoted 39 lines · Waiman Long
Quoted 37 lines · Baolin Wang

From: Waiman Long <[email protected]>

[Upstream commit 513e1073d52e55b8024b4f238a48de7587c64ccf]

Tetsuo Handa had reported he saw an incorrect "downgrading a read lock" warning right after a previous lockdep warning. It is likely that the previous warning turned off lock debugging causing the lockdep to have inconsistency states leading to the lock downgrade warning.

Fix that by add a check for debug_locks at the beginning of __lock_downgrade().

---
 kernel/locking/lockdep.c |    3 +++
 1 file changed, 3 insertions(+)
kernel/locking/lockdep.c +0 -0
index 565005a..5c370c6 100644
@@ -3650,6 +3650,9 @@ static int reacquire_held_locks(struct task_struct *curr, unsigned int depth,
      unsigned int depth;
      int i;
 
Quoted 14 lines

kernel/locking/lockdep.c static int reacquire_held_locks(struct task_struct *curr, unsigned int depth, · line 3658

Quoted 6 lines
kernel/locking/lockdep.c +3 -0
+     if (unlikely(!debug_locks))
+             return 0;
+
      depth = curr->lockdep_depth;
      /*
       * This function is about (re)setting the class of a held lock,

Apparently, there are 2 such patches in the upstream kernel - commit 513e1073d52e55b8024b4f238a48de7587c64ccf and 71492580571467fb7177aade19c18ce7486267f5. These are probably caused by the fact that there are 2 places in the code that can match the hunks. Anyway, this looks like it is applying to the wrong function. It should be applied to __lock_downgrade. Though it shouldn't harm if it is applied to the wrong function.

Ah, I noticed there are 2 commits with the same commit message, though 513e1073d52e55b8024b4f238a48de7587c64ccf patch did not change the __lock_downgrade(), which is really confusing. This patch (513e1073d52e55b8024b4f238a48de7587c64ccf) did the right thing, and 71492580571467fb7177aade19c18ce7486267f5 patch should be applied to __lock_downgrade.

I'll backport commit 71492580571467fb7177aade19c18ce7486267f5 too in future. Thanks.

Signature · 2 lines
Baolin Wang
Best Regards
#4 lore raw

PATCH v3 2/3 pinctrl: sprd: Use define directive for sprd_pinconf_params values

In reply to Baolin Wang

From: Nathan Chancellor <[email protected]>

[Upstream commit 957063c924736d4341e5d588757b9f31e8f6fa24]

Clang warns when one enumerated type is implicitly converted to another:

drivers/pinctrl/sprd/pinctrl-sprd.c:845:19: warning: implicit conversion from enumeration type 'enum sprd_pinconf_params' to different enumeration type 'enum pin_config_param' [-Wenum-conversion]

        {"sprd,control", SPRD_PIN_CONFIG_CONTROL, 0},
        ~                ^~~~~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/sprd/pinctrl-sprd.c:846:22: warning: implicit conversion
from enumeration type 'enum sprd_pinconf_params' to different
enumeration type 'enum pin_config_param' [-Wenum-conversion]
        {"sprd,sleep-mode", SPRD_PIN_CONFIG_SLEEP_MODE, 0},
        ~                   ^~~~~~~~~~~~~~~~~~~~~~~~~~

It is expected that pinctrl drivers can extend pin_config_param because of the gap between PIN_CONFIG_END and PIN_CONFIG_MAX so this conversion isn't an issue. Most drivers that take advantage of this define the PIN_CONFIG variables as constants, rather than enumerated values. Do the same thing here so that Clang no longer warns.

---
 drivers/pinctrl/sprd/pinctrl-sprd.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pinctrl/sprd/pinctrl-sprd.c +2 -4
index 6352991..83958bd 100644
@@ -159,10 +159,8 @@ struct sprd_pinctrl {
 	struct sprd_pinctrl_soc_info *info;
 };
 
-enum sprd_pinconf_params {
-	SPRD_PIN_CONFIG_CONTROL = PIN_CONFIG_END + 1,
-	SPRD_PIN_CONFIG_SLEEP_MODE = PIN_CONFIG_END + 2,
-};
+#define SPRD_PIN_CONFIG_CONTROL		(PIN_CONFIG_END + 1)
+#define SPRD_PIN_CONFIG_SLEEP_MODE	(PIN_CONFIG_END + 2)
 
 static int sprd_pinctrl_get_id_by_name(struct sprd_pinctrl *sprd_pctl,
 				       const char *name)
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v3 3/3 power: supply: sysfs: ratelimit property read error message

In reply to Baolin Wang

From: David Lechner <[email protected]>

[Upstream commit 87a2b65fc855e6be50f791c2ebbb492541896827]

This adds rate limiting to the message that is printed when reading a power supply property via sysfs returns an error. This will prevent userspace applications from unintentionally dDOSing the system by continuously reading a property that returns an error.

---
 drivers/power/supply/power_supply_sysfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/power_supply_sysfs.c +2 -1
index eb5dc74..2ccaf4f 100644
@@ -91,7 +91,8 @@ static ssize_t power_supply_show_property(struct device *dev,
 				dev_dbg(dev, "driver has no data for `%s' property\n",
 					attr->attr.name);
 			else if (ret != -ENODEV && ret != -EAGAIN)
-				dev_err(dev, "driver failed to report `%s' property: %zd\n",
+				dev_err_ratelimited(dev,
+					"driver failed to report `%s' property: %zd\n",
 					attr->attr.name, ret);
 			return ret;
 		}
Signature · 1 line
1.7.9.5