Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e8a6f89 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide-{floppy,tape}: remove packet command stack



* Add 'struct ide_atapi_pc queued_pc' to struct ide_{floppy,tape}_obj
  and switch ide*_do_request() to use it (there can be only one active
  request for a given device).

* Add 'struct ide_atapi_pc request_sense_pc' to struct ide_*_obj
  and switch ide*_retry_pc() to use it.

* Remove needless {floppy,tape}->pc assignment from ide*_setup().

* Remove no longer needed ide*_next_pc_storage(), pc_stack[],
  rq_stack_index, IDE*_PC_STACK and DBG_PC_STACK.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 394a4c21
Loading
Loading
Loading
Loading
+7 −25
Original line number Original line Diff line number Diff line
@@ -75,13 +75,6 @@
 */
 */
#define IDEFLOPPY_PC_BUFFER_SIZE	256
#define IDEFLOPPY_PC_BUFFER_SIZE	256


/*
 * In various places in the driver, we need to allocate storage for packet
 * commands, which will remain valid while we leave the driver to wait for
 * an interrupt or a timeout event.
 */
#define IDEFLOPPY_PC_STACK		(10 + IDEFLOPPY_MAX_PC_RETRIES)

/* format capacities descriptor codes */
/* format capacities descriptor codes */
#define CAPACITY_INVALID	0x00
#define CAPACITY_INVALID	0x00
#define CAPACITY_UNFORMATTED	0x01
#define CAPACITY_UNFORMATTED	0x01
@@ -104,11 +97,10 @@ typedef struct ide_floppy_obj {
	struct ide_atapi_pc *pc;
	struct ide_atapi_pc *pc;
	/* Last failed packet command */
	/* Last failed packet command */
	struct ide_atapi_pc *failed_pc;
	struct ide_atapi_pc *failed_pc;
	/* Packet command stack */
	/* used for blk_{fs,pc}_request() requests */
	struct ide_atapi_pc pc_stack[IDEFLOPPY_PC_STACK];
	struct ide_atapi_pc queued_pc;
	/* Next free packet command storage space */
	int pc_stack_index;


	struct ide_atapi_pc request_sense_pc;
	struct request request_sense_rq;
	struct request request_sense_rq;


	/* Last error information */
	/* Last error information */
@@ -296,15 +288,6 @@ static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc,
	ide_do_drive_cmd(drive, rq);
	ide_do_drive_cmd(drive, rq);
}
}


static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive)
{
	idefloppy_floppy_t *floppy = drive->driver_data;

	if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK)
		floppy->pc_stack_index = 0;
	return (&floppy->pc_stack[floppy->pc_stack_index++]);
}

static void ide_floppy_callback(ide_drive_t *drive)
static void ide_floppy_callback(ide_drive_t *drive)
{
{
	idefloppy_floppy_t *floppy = drive->driver_data;
	idefloppy_floppy_t *floppy = drive->driver_data;
@@ -365,10 +348,9 @@ static void idefloppy_retry_pc(ide_drive_t *drive)
{
{
	struct ide_floppy_obj *floppy = drive->driver_data;
	struct ide_floppy_obj *floppy = drive->driver_data;
	struct request *rq = &floppy->request_sense_rq;
	struct request *rq = &floppy->request_sense_rq;
	struct ide_atapi_pc *pc;
	struct ide_atapi_pc *pc = &floppy->request_sense_pc;


	(void)ide_read_error(drive);
	(void)ide_read_error(drive);
	pc = idefloppy_next_pc_storage(drive);
	idefloppy_create_request_sense_cmd(pc);
	idefloppy_create_request_sense_cmd(pc);
	idefloppy_queue_pc_head(drive, pc, rq);
	idefloppy_queue_pc_head(drive, pc, rq);
}
}
@@ -629,12 +611,12 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
			idefloppy_end_request(drive, 0, 0);
			idefloppy_end_request(drive, 0, 0);
			return ide_stopped;
			return ide_stopped;
		}
		}
		pc = idefloppy_next_pc_storage(drive);
		pc = &floppy->queued_pc;
		idefloppy_create_rw_cmd(floppy, pc, rq, block);
		idefloppy_create_rw_cmd(floppy, pc, rq, block);
	} else if (blk_special_request(rq)) {
	} else if (blk_special_request(rq)) {
		pc = (struct ide_atapi_pc *) rq->buffer;
		pc = (struct ide_atapi_pc *) rq->buffer;
	} else if (blk_pc_request(rq)) {
	} else if (blk_pc_request(rq)) {
		pc = idefloppy_next_pc_storage(drive);
		pc = &floppy->queued_pc;
		idefloppy_blockpc_cmd(floppy, pc, rq);
		idefloppy_blockpc_cmd(floppy, pc, rq);
	} else {
	} else {
		blk_dump_rq_flags(rq,
		blk_dump_rq_flags(rq,
@@ -1010,7 +992,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
	u8 gcw[2];
	u8 gcw[2];


	*((u16 *)&gcw) = id[ATA_ID_CONFIG];
	*((u16 *)&gcw) = id[ATA_ID_CONFIG];
	floppy->pc = floppy->pc_stack;

	drive->pc_callback = ide_floppy_callback;
	drive->pc_callback = ide_floppy_callback;


	if (((gcw[0] & 0x60) >> 5) == 1)
	if (((gcw[0] & 0x60) >> 5) == 1)
+6 −42
Original line number Original line Diff line number Diff line
@@ -56,8 +56,6 @@ enum {
	DBG_CHRDEV =		(1 << 2),
	DBG_CHRDEV =		(1 << 2),
	/* all remaining procedures */
	/* all remaining procedures */
	DBG_PROCS =		(1 << 3),
	DBG_PROCS =		(1 << 3),
	/* buffer alloc info (pc_stack) */
	DBG_PC_STACK =	(1 << 4),
};
};


/* define to see debug info */
/* define to see debug info */
@@ -88,13 +86,6 @@ enum {
 */
 */
#define IDETAPE_PC_BUFFER_SIZE		256
#define IDETAPE_PC_BUFFER_SIZE		256


/*
 * In various places in the driver, we need to allocate storage for packet
 * commands, which will remain valid while we leave the driver to wait for
 * an interrupt or a timeout event.
 */
#define IDETAPE_PC_STACK		(10 + IDETAPE_MAX_PC_RETRIES)

/*
/*
 * Some drives (for example, Seagate STT3401A Travan) require a very long
 * Some drives (for example, Seagate STT3401A Travan) require a very long
 * timeout, because they don't return an interrupt or clear their busy bit
 * timeout, because they don't return an interrupt or clear their busy bit
@@ -208,13 +199,6 @@ typedef struct ide_tape_obj {
	struct kref	kref;
	struct kref	kref;


	/*
	/*
	 *	Since a typical character device operation requires more
	 *	than one packet command, we provide here enough memory
	 *	for the maximum of interconnected packet commands.
	 *	The packet commands are stored in the circular array pc_stack.
	 *	pc_stack_index points to the last used entry, and warps around
	 *	to the start when we get to the last array entry.
	 *
	 *	pc points to the current processed packet command.
	 *	pc points to the current processed packet command.
	 *
	 *
	 *	failed_pc points to the last failed packet command, or contains
	 *	failed_pc points to the last failed packet command, or contains
@@ -226,11 +210,10 @@ typedef struct ide_tape_obj {
	struct ide_atapi_pc *pc;
	struct ide_atapi_pc *pc;
	/* Last failed packet command */
	/* Last failed packet command */
	struct ide_atapi_pc *failed_pc;
	struct ide_atapi_pc *failed_pc;
	/* Packet command stack */
	/* used by REQ_IDETAPE_{READ,WRITE} requests */
	struct ide_atapi_pc pc_stack[IDETAPE_PC_STACK];
	struct ide_atapi_pc queued_pc;
	/* Next free packet command storage space */
	int pc_stack_index;


	struct ide_atapi_pc request_sense_pc;
	struct request request_sense_rq;
	struct request request_sense_rq;


	/*
	/*
@@ -451,23 +434,6 @@ static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc)
	pc->bh = bh;
	pc->bh = bh;
}
}


/*
 *	idetape_next_pc_storage returns a pointer to a place in which we can
 *	safely store a packet command, even though we intend to leave the
 *	driver. A storage space for a maximum of IDETAPE_PC_STACK packet
 *	commands is allocated at initialization time.
 */
static struct ide_atapi_pc *idetape_next_pc_storage(ide_drive_t *drive)
{
	idetape_tape_t *tape = drive->driver_data;

	debug_log(DBG_PC_STACK, "pc_stack_index=%d\n", tape->pc_stack_index);

	if (tape->pc_stack_index == IDETAPE_PC_STACK)
		tape->pc_stack_index = 0;
	return (&tape->pc_stack[tape->pc_stack_index++]);
}

/*
/*
 * called on each failed packet command retry to analyze the request sense. We
 * called on each failed packet command retry to analyze the request sense. We
 * currently do not utilize this information.
 * currently do not utilize this information.
@@ -693,10 +659,9 @@ static void idetape_retry_pc(ide_drive_t *drive)
{
{
	struct ide_tape_obj *tape = drive->driver_data;
	struct ide_tape_obj *tape = drive->driver_data;
	struct request *rq = &tape->request_sense_rq;
	struct request *rq = &tape->request_sense_rq;
	struct ide_atapi_pc *pc;
	struct ide_atapi_pc *pc = &tape->request_sense_pc;


	(void)ide_read_error(drive);
	(void)ide_read_error(drive);
	pc = idetape_next_pc_storage(drive);
	idetape_create_request_sense_cmd(pc);
	idetape_create_request_sense_cmd(pc);
	set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
	set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
	idetape_queue_pc_head(drive, pc, rq);
	idetape_queue_pc_head(drive, pc, rq);
@@ -1006,12 +971,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
		return ide_stopped;
		return ide_stopped;
	}
	}
	if (rq->cmd[13] & REQ_IDETAPE_READ) {
	if (rq->cmd[13] & REQ_IDETAPE_READ) {
		pc = idetape_next_pc_storage(drive);
		pc = &tape->queued_pc;
		ide_tape_create_rw_cmd(tape, pc, rq, READ_6);
		ide_tape_create_rw_cmd(tape, pc, rq, READ_6);
		goto out;
		goto out;
	}
	}
	if (rq->cmd[13] & REQ_IDETAPE_WRITE) {
	if (rq->cmd[13] & REQ_IDETAPE_WRITE) {
		pc = idetape_next_pc_storage(drive);
		pc = &tape->queued_pc;
		ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6);
		ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6);
		goto out;
		goto out;
	}
	}
@@ -2412,7 +2377,6 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
	tape->name[1] = 't';
	tape->name[1] = 't';
	tape->name[2] = '0' + minor;
	tape->name[2] = '0' + minor;
	tape->chrdev_dir = IDETAPE_DIR_NONE;
	tape->chrdev_dir = IDETAPE_DIR_NONE;
	tape->pc = tape->pc_stack;


	*((u16 *)&gcw) = drive->id[ATA_ID_CONFIG];
	*((u16 *)&gcw) = drive->id[ATA_ID_CONFIG];