@@ -181,7 +181,7 @@ static u64 rtas_fadump_get_bootmem_min(void)
181181
182182static int rtas_fadump_register (struct fw_dump * fadump_conf )
183183{
184- unsigned int wait_time , fdm_size ;
184+ unsigned int wait_time , total_wait , fdm_size ;
185185 int rc , err = - EIO ;
186186
187187 /*
@@ -192,15 +192,20 @@ static int rtas_fadump_register(struct fw_dump *fadump_conf)
192192 fdm_size = sizeof (struct rtas_fadump_section_header );
193193 fdm_size += be16_to_cpu (fdm .header .dump_num_sections ) * sizeof (struct rtas_fadump_section );
194194
195- /* TODO: Add upper time limit for the delay */
195+ total_wait = 0 ;
196196 do {
197197 rc = rtas_call (fadump_conf -> ibm_configure_kernel_dump , 3 , 1 ,
198198 NULL , FADUMP_REGISTER , & fdm , fdm_size );
199199
200200 wait_time = rtas_busy_delay_time (rc );
201- if (wait_time )
201+ if (wait_time ) {
202+ if (total_wait >= RTAS_FADUMP_MAX_WAIT_MS ) {
203+ pr_err ("Timed out waiting for firmware to register fadump\n" );
204+ return - ETIMEDOUT ;
205+ }
206+ total_wait += wait_time ;
202207 mdelay (wait_time );
203-
208+ }
204209 } while (wait_time );
205210
206211 switch (rc ) {
@@ -234,18 +239,24 @@ static int rtas_fadump_register(struct fw_dump *fadump_conf)
234239
235240static int rtas_fadump_unregister (struct fw_dump * fadump_conf )
236241{
237- unsigned int wait_time ;
242+ unsigned int wait_time , total_wait ;
238243 int rc ;
239244
240- /* TODO: Add upper time limit for the delay */
245+ total_wait = 0 ;
241246 do {
242247 rc = rtas_call (fadump_conf -> ibm_configure_kernel_dump , 3 , 1 ,
243248 NULL , FADUMP_UNREGISTER , & fdm ,
244249 sizeof (struct rtas_fadump_mem_struct ));
245250
246251 wait_time = rtas_busy_delay_time (rc );
247- if (wait_time )
252+ if (wait_time ) {
253+ if (total_wait >= RTAS_FADUMP_MAX_WAIT_MS ) {
254+ pr_err ("Timed out waiting for firmware to unregister fadump\n" );
255+ return - ETIMEDOUT ;
256+ }
257+ total_wait += wait_time ;
248258 mdelay (wait_time );
259+ }
249260 } while (wait_time );
250261
251262 if (rc ) {
@@ -259,18 +270,24 @@ static int rtas_fadump_unregister(struct fw_dump *fadump_conf)
259270
260271static int rtas_fadump_invalidate (struct fw_dump * fadump_conf )
261272{
262- unsigned int wait_time ;
273+ unsigned int wait_time , total_wait ;
263274 int rc ;
264275
265- /* TODO: Add upper time limit for the delay */
276+ total_wait = 0 ;
266277 do {
267278 rc = rtas_call (fadump_conf -> ibm_configure_kernel_dump , 3 , 1 ,
268279 NULL , FADUMP_INVALIDATE , fdm_active ,
269280 sizeof (struct rtas_fadump_mem_struct ));
270281
271282 wait_time = rtas_busy_delay_time (rc );
272- if (wait_time )
283+ if (wait_time ) {
284+ if (total_wait >= RTAS_FADUMP_MAX_WAIT_MS ) {
285+ pr_err ("Timed out waiting for firmware to invalidate fadump\n" );
286+ return - ETIMEDOUT ;
287+ }
288+ total_wait += wait_time ;
273289 mdelay (wait_time );
290+ }
274291 } while (wait_time );
275292
276293 if (rc ) {
0 commit comments