Skip to contentSkip to conversation

floppy: remove is_alive()

PATCH New Denis Efremov (Oracle) 1 participant 1 message Oct 9

Subsystems (2)
lore
Share & tools
lore

Denis Efremov (Oracle)

author maintainer
#0 lore raw

PATCH 1/1 floppy: remove is_alive()

is_alive() prints "timeout handler died" when fdc_busy is set, command_status is below 2 and fd_timeout is not pending. The driver passes through that state on every FDC handover:

- lock_fdc() and floppy_queue_rq() set fdc_busy before they arm fd_timeout, with set_fdc() in between since "floppy: select FDC before arming timeout work";
- unlock_fdc() cancels fd_timeout before it clears fdc_busy;
- fd_timeout is not pending while floppy_shutdown() runs, and without a cont floppy_shutdown() only queues redo_fd_request(), which arms fd_timeout or releases the FDC later.

None of the callers excludes these windows, so each of them can report a dead timeout handler while the driver works normally:

- floppy_queue_rq() returns BLK_STS_RESOURCE while the FDC is busy, and blk-mq re-runs the queue every 3 ms, so it samples other contexts' handovers hundreds of times per second;
- floppy_interrupt() checks after schedule_bh(), when the next step may already run on another CPU, and also when the interrupt arrives while floppy_shutdown() runs;
- floppy_shutdown() checks right after it queued redo_fd_request() in the "no cont in shutdown!" case.

The check also cannot report the hang it describes. With the FDC held and no timeout armed, floppy_shutdown() never runs, and floppy_interrupt() runs only if the controller interrupts. Only the blk-mq retries in floppy_queue_rq() would keep checking, among their false reports. When fd_timeout does fire, show_floppy() already prints fdc_busy, command_status and whether fd_timeout is pending.

Remove is_alive() and its callers.

---
 drivers/block/floppy.c | 14 --------------
 1 file changed, 14 deletions(-)
drivers/block/floppy.c +0 -14
index f04397b8e381..e354ea61f23d 100644
@@ -635,15 +635,6 @@ static inline void debugt(const char *func, const char *msg) { }
 static DECLARE_DELAYED_WORK(fd_timeout, floppy_shutdown);
 static const char *timeout_message;
 
-static void is_alive(const char *func, const char *message)
-{
-	/* this routine checks whether the floppy driver is "alive" */
-	if (test_bit(0, &fdc_busy) && command_status < 2 &&
-	    !delayed_work_pending(&fd_timeout)) {
-		DPRINT("%s: timeout handler died.  %s\n", func, message);
-	}
-}
-
 static void (*do_floppy)(void) = NULL;
 
 #define OLOGSIZE 20
@@ -1727,7 +1718,6 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id)
 		pr_info("DOR0=%x\n", fdc_state[0].dor);
 		pr_info("floppy interrupt on bizarre fdc %d\n", current_fdc);
 		pr_info("handler=%ps\n", handler);
-		is_alive(__func__, "bizarre fdc");
 		return IRQ_NONE;
 	}
 
@@ -1762,7 +1752,6 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id)
 		return IRQ_NONE;
 	}
 	schedule_bh(handler);
-	is_alive(__func__, "normal interrupt end");
 
 	/* FIXME! Was it really for us? */
 	return IRQ_HANDLED;
@@ -1890,7 +1879,6 @@ static void floppy_shutdown(struct work_struct *arg)
 		pr_info("no cont in shutdown!\n");
 		process_fd_request();
 	}
-	is_alive(__func__, "");
 }
 
 /* start motor, check media-changed condition and write protection */
@@ -2863,7 +2851,6 @@ static blk_status_t floppy_queue_rq(struct blk_mq_hw_ctx *hctx,
 	if (test_and_set_bit(0, &fdc_busy)) {
 		/* fdc busy, this new request will be treated when the
 		   current one is done */
-		is_alive(__func__, "old request running");
 		return BLK_STS_RESOURCE;
 	}
 
@@ -2875,7 +2862,6 @@ static blk_status_t floppy_queue_rq(struct blk_mq_hw_ctx *hctx,
 	__reschedule_timeout(MAXTIMEOUT, "fd_request");
 	set_fdc(0);
 	process_fd_request();
-	is_alive(__func__, "");
 	return BLK_STS_OK;
 }
 

base-commit: af32da41b0327b9c6a37856ba82b6760d6c8d10e

Signature · 1 line
2.56.0