drm/msm/kms: Make a lock_class_key for each crtc mutex
Subsystems (7)
PATCH 1/1 drm/msm/kms: Make a lock_class_key for each crtc mutex
Lockdep complains about an AA deadlock when rebooting the device.
============================================
WARNING: possible recursive locking detected
5.4.91 #1 Not tainted
--------------------------------------------
reboot/5213 is trying to acquire lock:ffffff80d13391b0 (&kms->commit_lock[i]){+.+.}, at: lock_crtcs+0x60/0xa4
but task is already holding lock:ffffff80d1339110 (&kms->commit_lock[i]){+.+.}, at: lock_crtcs+0x60/0xa4
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----lock(&kms->commit_lock[i]);lock(&kms->commit_lock[i]);
*** DEADLOCK ***
May be due to missing lock nesting notation
6 locks held by reboot/5213:
__arm64_sys_reboot+0x148/0x2a0 device_shutdown+0x10c/0x2c4 drm_atomic_helper_shutdown+0x48/0xfc modeset_lock+0x120/0x24c lock_crtcs+0x60/0xa4 stack backtrace: CPU: 4 PID: 5213 Comm: reboot Not tainted 5.4.91 #1 Hardware name: Google Pompom (rev1) with LTE (DT) Call trace: dump_backtrace+0x0/0x1dc show_stack+0x24/0x30 dump_stack+0xfc/0x1a8 __lock_acquire+0xcd0/0x22b8 lock_acquire+0x1ec/0x240 __mutex_lock_common+0xe0/0xc84 mutex_lock_nested+0x48/0x58 lock_crtcs+0x60/0xa4 msm_atomic_commit_tail+0x348/0x570 commit_tail+0xdc/0x178 drm_atomic_helper_commit+0x160/0x168 drm_atomic_commit+0x68/0x80
This is because lockdep thinks all the locks taken in lock_crtcs() are the same lock, when they actually aren't. That's because we call mutex_init() in msm_kms_init() and that assigns on static key for every lock initialized in this loop. Let's allocate a dynamic number of lock_class_keys and assign them to each lock so that lockdep can figure out an AA deadlock isn't possible here.
--- drivers/gpu/drm/msm/msm_kms.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_kms.h +6 -2
@@ -157,6 +157,7 @@ struct msm_kms {* from the crtc's pending_timer close to end of the frame: */ struct mutex commit_lock[MAX_CRTCS ]; +struct lock_class_key commit_lock_keys[MAX_CRTCS ];unsigned pending_crtc_mask;struct msm_pending_timer pending_timers[MAX_CRTCS ]; };
@@ -166,8 +167,11 @@ static inline int msm_kms_init(struct msm_kms *kms, {unsigned i, ret; -for (i =0 ; i <ARRAY_SIZE (kms->commit_lock); i++) -mutex_init (&kms->commit_lock[i]); +for (i =0 ; i <ARRAY_SIZE (kms->commit_lock); i++) { +lockdep_register_key (&kms->commit_lock_keys[i]); +__mutex_init (&kms->commit_lock[i],"&kms->commit_lock[i]" , + &kms->commit_lock_keys[i]); + } kms->funcs = funcs;
base-commit: 19c329f6808995b142b3966301f217c831e7cf31
Signature · 6 lines
https://chromeos.dev _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
v2 cover iio: Add a ChromeOS EC MKBP proximity driver
This is a different approach to [1] where I tried to add this proximity sensor logic to the input subsystem. Instead, we'll take the approach of making a small IIO proximity driver that parses the EC switch bitmap to find out if the front proximity sensor is detecting something or not. This allows us to treat proximity sensors as IIO devices all the time in userspace instead of handling this switch on the EC via the input subsystem and then other proximity sensors via IIO.
I propose this is all merged through IIO subsystem. Please ack the first patch so it can be merged that way.
Changes from v1:
* Driver moved location
* Put mkbp everywhere
* Fixed up DT binding to not fail and make sure is a child of cros-ec
* Simplified logic for sending a message
* Dropped CONFIG_OF usage
* Sorted includes
[1] https://lore.kernel.org/r/[email protected]
Stephen Boyd (3):
platform/chrome: cros_ec: Add SW_FRONT_PROXIMITY MKBP define
dt-bindings: iio: Add cros ec proximity yaml doc
iio: proximity: Add a ChromeOS EC MKBP proximity driver
.../google,cros-ec-mkbp-proximity.yaml | 38 +++ .../bindings/mfd/google,cros-ec.yaml | 3 + drivers/iio/proximity/Kconfig | 11 + drivers/iio/proximity/Makefile | 1 + .../iio/proximity/cros_ec_mkbp_proximity.c | 243 ++++++++++++++++++ .../linux/platform_data/cros_ec_commands.h | 1 + 6 files changed, 297 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/proximity/google,cros-ec-mkbp-proximity.yaml create mode 100644 drivers/iio/proximity/cros_ec_mkbp_proximity.c
base-commit: 19c329f6808995b142b3966301f217c831e7cf31
Signature · 1 line
https://chromeos.dev
PATCH v2 1/3 platform/chrome: cros_ec: Add SW_FRONT_PROXIMITY MKBP define
In reply to Stephen BoydSome cros ECs support a front proximity MKBP event via 'EC_MKBP_FRONT_PROXIMITY'. Add this define so it can be used in a future patch.
--- include/linux/platform_data/cros_ec_commands.h | 1 + 1 file changed, 1 insertion(+)
include/linux/platform_data/cros_ec_commands.h +1 -0
@@ -3457,6 +3457,7 @@ struct ec_response_get_next_event_v1 {#define EC_MKBP_LID_OPEN 0#define EC_MKBP_TABLET_MODE 1#define EC_MKBP_BASE_ATTACHED 2 +#define EC_MKBP_FRONT_PROXIMITY 3/* Run keyboard factory test scanning */ #define EC_CMD_KEYBOARD_FACTORY_TEST 0x0068
Signature · 1 line
https://chromeos.dev
PATCH v2 2/3 dt-bindings: iio: Add cros ec proximity yaml doc
In reply to Stephen BoydSome cros ECs support a front proximity MKBP event via 'EC_MKBP_FRONT_PROXIMITY'. Add a DT binding to document this feature via a node that is a child of the main cros_ec device node. Devices that have this ability will describe this in firmware.
---
Changes from v1:
* Added additionalProperties
* Included proximity in cros-ec yaml
.../google,cros-ec-mkbp-proximity.yaml | 38 +++++++++++++++++++ .../bindings/mfd/google,cros-ec.yaml | 3 ++ 2 files changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/proximity/google,cros-ec-mkbp-proximity.yaml
Documentation/devicetree/bindings/iio/proximity/google,cros-ec-mkbp-proximity.yaml new file +38 -0
@@ -0,0 +1,38 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/iio/proximity/google,cros-ec-mkbp-proximity.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ChromeOS EC MKBP Proximity Sensor + +maintainers: + - Stephen Boyd <[email protected]> + - Benson Leung <[email protected]> + - Enric Balletbo i Serra <[email protected]> + +description: | + Google's ChromeOS EC sometimes has the ability to detect user proximity. + This is implemented on the EC as near/far logic and exposed to the OS + via an MKBP switch bit. + +properties: + compatible: + const: google,cros-ec-mkbp-proximity + + label: + description: Name for proximity sensor + +required: + - compatible + +unevaluatedProperties: false +additionalProperties: false + +examples: + - | + proximity { + compatible = "google,cros-ec-mkbp-proximity"; + label = "proximity-wifi-lte"; + };
Documentation/devicetree/bindings/mfd/google,cros-ec.yaml +3 -0
@@ -94,6 +94,9 @@ properties: keyboard-controller: $ref: "/schemas/input/google,cros-ec-keyb.yaml#" + proximity: + $ref: "/schemas/iio/proximity/google,cros-ec-mkbp-proximity.yaml#" + codecs: type: object additionalProperties: false
Signature · 1 line
https://chromeos.dev
PATCH v2 3/3 iio: proximity: Add a ChromeOS EC MKBP proximity driver
In reply to Stephen BoydAdd support for a ChromeOS EC proximity driver that exposes a "front" proximity sensor via the IIO subsystem. The EC decides when front proximity is near and sets an MKBP switch 'EC_MKBP_FRONT_PROXIMITY' to notify the kernel of proximity. Similarly, when proximity detects something far away it sets the switch bit to 0. For now this driver exposes a single sensor, but it could be expanded in the future via more MKBP bits if desired.
---
Changes from v1:
* Sorted includes
* Renamed to have MKBP everywhere
* Use last_event_time for timestamp
* Dropped claim calls
* Dropped useless dev assignment
drivers/iio/proximity/Kconfig | 11 + drivers/iio/proximity/Makefile | 1 + .../iio/proximity/cros_ec_mkbp_proximity.c | 243 ++++++++++++++++++ 3 files changed, 255 insertions(+) create mode 100644 drivers/iio/proximity/cros_ec_mkbp_proximity.c
drivers/iio/proximity/Kconfig +11 -0
@@ -21,6 +21,17 @@ endmenu menu "Proximity and distance sensors" +config CROS_EC_MKBP_PROXIMITY + tristate "ChromeOS EC MKBP Proximity sensor" + depends on CROS_EC + help + Say Y here to enable the proximity sensor implemented via the ChromeOS EC MKBP + switches protocol. You must enable one bus option (CROS_EC_I2C or CROS_EC_SPI) + to use this. + + To compile this driver as a module, choose M here: the + module will be called cros_ec_mkbp_proximity. + config ISL29501 tristate "Intersil ISL29501 Time Of Flight sensor" depends on I2C
drivers/iio/proximity/Makefile +1 -0
@@ -5,6 +5,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_AS3935) += as3935.o +obj-$(CONFIG_CROS_EC_MKBP_PROXIMITY) += cros_ec_mkbp_proximity.o obj-$(CONFIG_ISL29501) += isl29501.o obj-$(CONFIG_LIDAR_LITE_V2) += pulsedlight-lidar-lite-v2.o obj-$(CONFIG_MB1232) += mb1232.o
drivers/iio/proximity/cros_ec_mkbp_proximity.c new file +243 -0
243 lines not on this page · raw message
Signature · 1 line
https://chromeos.dev