aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/pseries/dlpar.c
diff options
context:
space:
mode:
authorNathan Fontenot <nfont@austin.ibm.com>2010-08-18 05:58:46 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-09-01 20:07:38 -0400
commit93f68f1ef787d97ab688f78a01f446e85bb9a496 (patch)
tree48686ab3564991aba66e47f1a6048ff8a4cbe4c2 /arch/powerpc/platforms/pseries/dlpar.c
parenta28dec2f26013aad89446b1f708f948617bc28a2 (diff)
powerpc/pseries: Correct rtas_data_buf locking in dlpar code
The dlpar code can cause a deadlock to occur when making the RTAS configure-connector call. This occurs because we make kmalloc calls, which can block, while parsing the rtas_data_buf and holding the rtas_data_buf_lock. This an cause issues if someone else attempts to grab the rtas_data_bug_lock. This patch alleviates this issue by copying the contents of the rtas_data_buf to a local buffer before parsing. This allows us to only hold the rtas_data_buf_lock around the RTAS configure-connector calls. Signed-off-by: Nathan Fontenot <nfont@austin.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/platforms/pseries/dlpar.c')
-rw-r--r--arch/powerpc/platforms/pseries/dlpar.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 227c1c3d585e..72d8054fa739 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -129,20 +129,35 @@ struct device_node *dlpar_configure_connector(u32 drc_index)
129 struct property *property; 129 struct property *property;
130 struct property *last_property = NULL; 130 struct property *last_property = NULL;
131 struct cc_workarea *ccwa; 131 struct cc_workarea *ccwa;
132 char *data_buf;
132 int cc_token; 133 int cc_token;
133 int rc; 134 int rc = -1;
134 135
135 cc_token = rtas_token("ibm,configure-connector"); 136 cc_token = rtas_token("ibm,configure-connector");
136 if (cc_token == RTAS_UNKNOWN_SERVICE) 137 if (cc_token == RTAS_UNKNOWN_SERVICE)
137 return NULL; 138 return NULL;
138 139
139 spin_lock(&rtas_data_buf_lock); 140 data_buf = kzalloc(RTAS_DATA_BUF_SIZE, GFP_KERNEL);
140 ccwa = (struct cc_workarea *)&rtas_data_buf[0]; 141 if (!data_buf)
142 return NULL;
143
144 ccwa = (struct cc_workarea *)&data_buf[0];
141 ccwa->drc_index = drc_index; 145 ccwa->drc_index = drc_index;
142 ccwa->zero = 0; 146 ccwa->zero = 0;
143 147
144 rc = rtas_call(cc_token, 2, 1, NULL, rtas_data_buf, NULL); 148 do {
145 while (rc) { 149 /* Since we release the rtas_data_buf lock between configure
150 * connector calls we want to re-populate the rtas_data_buffer
151 * with the contents of the previous call.
152 */
153 spin_lock(&rtas_data_buf_lock);
154
155 memcpy(rtas_data_buf, data_buf, RTAS_DATA_BUF_SIZE);
156 rc = rtas_call(cc_token, 2, 1, NULL, rtas_data_buf, NULL);
157 memcpy(data_buf, rtas_data_buf, RTAS_DATA_BUF_SIZE);
158
159 spin_unlock(&rtas_data_buf_lock);
160
146 switch (rc) { 161 switch (rc) {
147 case NEXT_SIBLING: 162 case NEXT_SIBLING:
148 dn = dlpar_parse_cc_node(ccwa); 163 dn = dlpar_parse_cc_node(ccwa);
@@ -197,18 +212,19 @@ struct device_node *dlpar_configure_connector(u32 drc_index)
197 "returned from configure-connector\n", rc); 212 "returned from configure-connector\n", rc);
198 goto cc_error; 213 goto cc_error;
199 } 214 }
215 } while (rc);
200 216
201 rc = rtas_call(cc_token, 2, 1, NULL, rtas_data_buf, NULL); 217cc_error:
218 kfree(data_buf);
219
220 if (rc) {
221 if (first_dn)
222 dlpar_free_cc_nodes(first_dn);
223
224 return NULL;
202 } 225 }
203 226
204 spin_unlock(&rtas_data_buf_lock);
205 return first_dn; 227 return first_dn;
206
207cc_error:
208 if (first_dn)
209 dlpar_free_cc_nodes(first_dn);
210 spin_unlock(&rtas_data_buf_lock);
211 return NULL;
212} 228}
213 229
214static struct device_node *derive_parent(const char *path) 230static struct device_node *derive_parent(const char *path)