diff options
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0055-fix-hot-unplug-vs-async-scan-race.patch')
-rw-r--r-- | recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0055-fix-hot-unplug-vs-async-scan-race.patch | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0055-fix-hot-unplug-vs-async-scan-race.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0055-fix-hot-unplug-vs-async-scan-race.patch new file mode 100644 index 00000000..9d7c97a9 --- /dev/null +++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.25/0055-fix-hot-unplug-vs-async-scan-race.patch | |||
@@ -0,0 +1,122 @@ | |||
1 | From 04ed7d216271c757e1f14ff369f5aa1908f04189 Mon Sep 17 00:00:00 2001 | ||
2 | From: Dan Williams <dan.j.williams@intel.com> | ||
3 | Date: Thu, 21 Jun 2012 23:47:28 -0700 | ||
4 | Subject: [PATCH 55/73] fix hot unplug vs async scan race | ||
5 | |||
6 | commit 3b661a92e869ebe2358de8f4b3230ad84f7fce51 upstream. | ||
7 | |||
8 | The following crash results from cases where the end_device has been | ||
9 | removed before scsi_sysfs_add_sdev has had a chance to run. | ||
10 | |||
11 | BUG: unable to handle kernel NULL pointer dereference at 0000000000000098 | ||
12 | IP: [<ffffffff8115e100>] sysfs_create_dir+0x32/0xb6 | ||
13 | ... | ||
14 | Call Trace: | ||
15 | [<ffffffff8125e4a8>] kobject_add_internal+0x120/0x1e3 | ||
16 | [<ffffffff81075149>] ? trace_hardirqs_on+0xd/0xf | ||
17 | [<ffffffff8125e641>] kobject_add_varg+0x41/0x50 | ||
18 | [<ffffffff8125e70b>] kobject_add+0x64/0x66 | ||
19 | [<ffffffff8131122b>] device_add+0x12d/0x63a | ||
20 | [<ffffffff814b65ea>] ? _raw_spin_unlock_irqrestore+0x47/0x56 | ||
21 | [<ffffffff8107de15>] ? module_refcount+0x89/0xa0 | ||
22 | [<ffffffff8132f348>] scsi_sysfs_add_sdev+0x4e/0x28a | ||
23 | [<ffffffff8132dcbb>] do_scan_async+0x9c/0x145 | ||
24 | |||
25 | ...teach scsi_sysfs_add_devices() to check for deleted devices() before | ||
26 | trying to add them, and teach scsi_remove_target() how to remove targets | ||
27 | that have not been added via device_add(). | ||
28 | |||
29 | Reported-by: Dariusz Majchrzak <dariusz.majchrzak@intel.com> | ||
30 | Signed-off-by: Dan Williams <dan.j.williams@intel.com> | ||
31 | Signed-off-by: James Bottomley <JBottomley@Parallels.com> | ||
32 | Signed-off-by: Ben Hutchings <ben@decadent.org.uk> | ||
33 | --- | ||
34 | drivers/scsi/scsi_scan.c | 3 +++ | ||
35 | drivers/scsi/scsi_sysfs.c | 41 ++++++++++++++++++++++++++--------------- | ||
36 | 2 files changed, 29 insertions(+), 15 deletions(-) | ||
37 | |||
38 | diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c | ||
39 | index 6e7ea4a..a48b59c 100644 | ||
40 | --- a/drivers/scsi/scsi_scan.c | ||
41 | +++ b/drivers/scsi/scsi_scan.c | ||
42 | @@ -1710,6 +1710,9 @@ static void scsi_sysfs_add_devices(struct Scsi_Host *shost) | ||
43 | { | ||
44 | struct scsi_device *sdev; | ||
45 | shost_for_each_device(sdev, shost) { | ||
46 | + /* target removed before the device could be added */ | ||
47 | + if (sdev->sdev_state == SDEV_DEL) | ||
48 | + continue; | ||
49 | if (!scsi_host_scan_allowed(shost) || | ||
50 | scsi_sysfs_add_sdev(sdev) != 0) | ||
51 | __scsi_remove_device(sdev); | ||
52 | diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c | ||
53 | index 42c35ff..bb7c482 100644 | ||
54 | --- a/drivers/scsi/scsi_sysfs.c | ||
55 | +++ b/drivers/scsi/scsi_sysfs.c | ||
56 | @@ -997,7 +997,6 @@ static void __scsi_remove_target(struct scsi_target *starget) | ||
57 | struct scsi_device *sdev; | ||
58 | |||
59 | spin_lock_irqsave(shost->host_lock, flags); | ||
60 | - starget->reap_ref++; | ||
61 | restart: | ||
62 | list_for_each_entry(sdev, &shost->__devices, siblings) { | ||
63 | if (sdev->channel != starget->channel || | ||
64 | @@ -1011,14 +1010,6 @@ static void __scsi_remove_target(struct scsi_target *starget) | ||
65 | goto restart; | ||
66 | } | ||
67 | spin_unlock_irqrestore(shost->host_lock, flags); | ||
68 | - scsi_target_reap(starget); | ||
69 | -} | ||
70 | - | ||
71 | -static int __remove_child (struct device * dev, void * data) | ||
72 | -{ | ||
73 | - if (scsi_is_target_device(dev)) | ||
74 | - __scsi_remove_target(to_scsi_target(dev)); | ||
75 | - return 0; | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | @@ -1031,14 +1022,34 @@ static int __remove_child (struct device * dev, void * data) | ||
80 | */ | ||
81 | void scsi_remove_target(struct device *dev) | ||
82 | { | ||
83 | - if (scsi_is_target_device(dev)) { | ||
84 | - __scsi_remove_target(to_scsi_target(dev)); | ||
85 | - return; | ||
86 | + struct Scsi_Host *shost = dev_to_shost(dev->parent); | ||
87 | + struct scsi_target *starget, *found; | ||
88 | + unsigned long flags; | ||
89 | + | ||
90 | + restart: | ||
91 | + found = NULL; | ||
92 | + spin_lock_irqsave(shost->host_lock, flags); | ||
93 | + list_for_each_entry(starget, &shost->__targets, siblings) { | ||
94 | + if (starget->state == STARGET_DEL) | ||
95 | + continue; | ||
96 | + if (starget->dev.parent == dev || &starget->dev == dev) { | ||
97 | + found = starget; | ||
98 | + found->reap_ref++; | ||
99 | + break; | ||
100 | + } | ||
101 | } | ||
102 | + spin_unlock_irqrestore(shost->host_lock, flags); | ||
103 | |||
104 | - get_device(dev); | ||
105 | - device_for_each_child(dev, NULL, __remove_child); | ||
106 | - put_device(dev); | ||
107 | + if (found) { | ||
108 | + __scsi_remove_target(found); | ||
109 | + scsi_target_reap(found); | ||
110 | + /* in the case where @dev has multiple starget children, | ||
111 | + * continue removing. | ||
112 | + * | ||
113 | + * FIXME: does such a case exist? | ||
114 | + */ | ||
115 | + goto restart; | ||
116 | + } | ||
117 | } | ||
118 | EXPORT_SYMBOL(scsi_remove_target); | ||
119 | |||
120 | -- | ||
121 | 1.7.7.6 | ||
122 | |||