History

misc/pvpanic: Convert regular spinlock into trylock on panic path

The pvpanic driver relies on panic notifiers to execute a callback on panic event. Such function is executed in atomic context - the panic function disables local IRQs, preemption and all other CPUs that aren't running the panic code. With that said, it's dangerous to use regular spinlocks in such path, as introduced by commit b3c0f8774668 ("misc/pvpanic: probe multiple instances"). This patch fixes that by replacing regular spinlocks with the trylock safer approach. It also fixes an old comment (about a long gone framebuffer code) and the notifier priority - we should execute hypervisor notifiers early, deferring this way the panic action to the hypervisor, as expected by the users that are setting up pvpanic.

Guilherme G. Piccoli committed 4 years ago

Commit e918c101 parent c268c0a1 file · +8 −2Browse files

Unified · Split

drivers/misc/pvpanic/pvpanic.c+8−2
@@ -34,7 +34,9 @@ pvpanic_send_event(unsigned int event) · 33 unmodified lines
3434 {
3535 struct pvpanic_instance *pi_cur;
3636
37− spin_lock(&pvpanic_lock);
37+ if (!spin_trylock(&pvpanic_lock))
38+ return;
39+
3840 list_for_each_entry(pi_cur, &pvpanic_list, list) {
3941 if (event & pi_cur->capability & pi_cur->events)
4042 iowrite8(event, pi_cur->base);
@@ -55,9 +57,13 @@ pvpanic_panic_notify(struct notifier_block *nb, unsigned long code, void *unused · 14 unmodified lines
5557 return NOTIFY_DONE;
5658 }
5759
60+/*
61+ * Call our notifier very early on panic, deferring the
62+ * action taken to the hypervisor.
63+ */
5864 static struct notifier_block pvpanic_panic_nb = {
5965 .notifier_call = pvpanic_panic_notify,
60− .priority = 1, /* let this called before broken drm_fb_helper() */
66+ .priority = INT_MAX,
6167 };
6268
6369 static void pvpanic_remove(void *param)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t