Skip to contentSkip to conversation

firmware/arm_sdei: Fix invalid argument to unregister private events.

PATCH Superseded Levi Yun 3 participants 7 messages Jan 10, 2024 – Jan 18, 2024 Software delegated exception interface (sdei)

lore
Share & tools
lore

Levi Yun

author
#0 lore raw

PATCH 1/1 firmware/arm_sdei: Fix invalid argument to unregister private events.

To unregister private events in device freeze, it should call cpuhp_remove_state with sdei_hp_state not sdei_entry_point. otherwise, it seems to fail on cpuhp_cb_check.

---
 drivers/firmware/arm_sdei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/arm_sdei.c +1 -1
index 285fe7ad490d..3e8051fe8296 100644
@@ -763,7 +763,7 @@ static int sdei_device_freeze(struct device *dev)
 	int err;
 
 	/* unregister private events */
-	cpuhp_remove_state(sdei_entry_point);
+	cpuhp_remove_state(sdei_hp_state);
 
 	err = sdei_unregister_shared();
 	if (err)
Signature · 1 line
2.41.0
#1 lore raw

Hello Levi,

Quoted 4 lines · Levi Yun

To unregister private events in device freeze, it should call cpuhp_remove_state with sdei_hp_state not sdei_entry_point. otherwise, it seems to fail on cpuhp_cb_check.

I think you can also add:

Fixes d2c48b2387eb ("firmware: arm_sdei: Fix sleep from invalid context BUG")
Quoted 10 lines
---
  drivers/firmware/arm_sdei.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/arm_sdei.c +0 -0
index 285fe7ad490d..3e8051fe8296 100644

drivers/firmware/arm_sdei.c static int sdei_device_freeze(struct device *dev) · line 766

Quoted 5 lines
drivers/firmware/arm_sdei.c +1 -1
@@ -763,7 +763,7 @@ static int sdei_device_freeze(struct device *dev)
  	int err;
 
  	/* unregister private events */
-	cpuhp_remove_state(sdei_entry_point);
+	cpuhp_remove_state(sdei_hp_state);

Maybe it would also be worth resetting 'sdei_hp_state':
sdei_hp_state = 0;

drivers/firmware/arm_sdei.c static int sdei_device_freeze(struct device *dev) · line 769

Quoted 3 lines
drivers/firmware/arm_sdei.c +0 -0
  	err = sdei_unregister_shared();
  	if (err)

Regards,
Pierre

maintainer Reviewed-by
#2 lore raw

Hi Levi, Pierre,

Quoted 4 lines · Pierre Gondois
Quoted 3 lines · Levi Yun

To unregister private events in device freeze, it should call cpuhp_remove_state with sdei_hp_state not sdei_entry_point. otherwise, it seems to fail on cpuhp_cb_check.

Oops. Well caught!

Quoted 4 lines

I think you can also add:

Fixes d2c48b2387eb ("firmware: arm_sdei: Fix sleep from invalid context BUG")
Quoted 12 lines

drivers/firmware/arm_sdei.c static int sdei_device_freeze(struct device *dev) · line 765

Quoted 9 lines
drivers/firmware/arm_sdei.c +1 -1
index 285fe7ad490d..3e8051fe8296 100644
@@ -763,7 +763,7 @@ static int sdei_device_freeze(struct device *dev)
       int err;
         /* unregister private events */
-    cpuhp_remove_state(sdei_entry_point);
+    cpuhp_remove_state(sdei_hp_state);

Maybe it would also be worth resetting 'sdei_hp_state':
  sdei_hp_state = 0;

The next call should always be 'thaw', which doesn't check this, but it's good to cleanup stale values.

Regardless:

Thanks,

James

author
#3 lore raw

Hi James, Pierre.

Quoted 2 lines
Quoted 2 lines

I think you can also add:

Fixes d2c48b2387eb ("firmware: arm_sdei: Fix sleep from invalid context BUG")

Thanks, I'll add this fix tag.

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
drivers/firmware/arm_sdei.c +0 -0
index 285fe7ad490d..3e8051fe8296 100644
Quoted 8 lines

drivers/firmware/arm_sdei.c static int sdei_device_freeze(struct device *dev) · line 765

Quoted 5 lines
drivers/firmware/arm_sdei.c +1 -1
@@ -763,7 +763,7 @@ static int sdei_device_freeze(struct device *dev)
      int err;
        /* unregister private events */
-    cpuhp_remove_state(sdei_entry_point);
+    cpuhp_remove_state(sdei_hp_state);

Maybe it would also be worth resetting 'sdei_hp_state':
sdei_hp_state = 0;

Quoted 3 lines

The next call should always be 'thaw', which doesn't check this, but it's good to cleanup stale values.

But, I think it should be checked on sdei_reboot_notifier. otherwise, In the situation sdei device was freezed, when sdei_reboot_notifier is called,
It would fail on cpuhp_cb_check too.

Should I add a sanity check on sdei_reboot_notifier in the next patch?

Many thanks!

author
#4 lore raw
Quoted 7 lines

But, I think it should be checked on sdei_reboot_notifier. otherwise, In the situation sdei device was freezed, when sdei_reboot_notifier is called,
It would fail on cpuhp_cb_check too.

Should I add a sanity check on sdei_reboot_notifier in the next patch?

Sorry to make a noise. Maybe there's no case for this.

author
#5 lore raw

PATCH v2 1/1 firmware/arm_sdei: Fix invalid argument to unregister private events.

In reply to James Morse

To unregister private events in device freeze, it should call cpuhp_remove_state with sdei_hp_state not sdei_entry_point. otherwise, it seems to fail on cpuhp_cb_check.

Fixes d2c48b2387eb ("firmware: arm_sdei: Fix sleep from invalid context BUG")

---
Changes:

    v1->v2: add fixes tag and resetting sdei_hp_state
 drivers/firmware/arm_sdei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/arm_sdei.c +1 -1
index 285fe7ad490d..3e8051fe8296 100644
@@ -763,7 +763,7 @@ static int sdei_device_freeze(struct device *dev)
 	int err;
 
 	/* unregister private events */
-	cpuhp_remove_state(sdei_entry_point);
+	cpuhp_remove_state(sdei_hp_state);
 
 	err = sdei_unregister_shared();
 	if (err)

--
2.41.0

author
#6 lore raw

PATCH v3 1/1 firmware/arm_sdei: Fix invalid argument to unregister private events.

To unregister private events in device freeze, it should call cpuhp_remove_state with sdei_hp_state not sdei_entry_point. otherwise, it seems to fail on cpuhp_cb_check.

Fixes d2c48b2387eb ("firmware: arm_sdei: Fix sleep from invalid context BUG")

---
Changes:

    v1->v2: add fixes tag and resetting sdei_hp_state

v2->v3: add missing resetting sdei_hp_state.

 drivers/firmware/arm_sdei.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/firmware/arm_sdei.c +3 -1
index 285fe7ad490d..973972d50287 100644
@@ -763,7 +763,9 @@ static int sdei_device_freeze(struct device *dev)
 	int err;
 
 	/* unregister private events */
-	cpuhp_remove_state(sdei_entry_point);
+	cpuhp_remove_state(sdei_hp_state);
+
+	sdei_hp_state = 0;
 
 	err = sdei_unregister_shared();
 	if (err)

--
2.41.0