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

Commit d274a987 authored by Jens Axboe's avatar Jens Axboe
Browse files

ide-scsi: sg chaining support

parent 2f08fe52
Loading
Loading
Loading
Loading
+18 −14
Original line number Original line Diff line number Diff line
@@ -70,6 +70,7 @@ typedef struct idescsi_pc_s {
	u8 *buffer;				/* Data buffer */
	u8 *buffer;				/* Data buffer */
	u8 *current_position;			/* Pointer into the above buffer */
	u8 *current_position;			/* Pointer into the above buffer */
	struct scatterlist *sg;			/* Scatter gather table */
	struct scatterlist *sg;			/* Scatter gather table */
	struct scatterlist *last_sg;		/* Last sg element */
	int b_count;				/* Bytes transferred from current entry */
	int b_count;				/* Bytes transferred from current entry */
	struct scsi_cmnd *scsi_cmd;		/* SCSI command */
	struct scsi_cmnd *scsi_cmd;		/* SCSI command */
	void (*done)(struct scsi_cmnd *);	/* Scsi completion routine */
	void (*done)(struct scsi_cmnd *);	/* Scsi completion routine */
@@ -173,12 +174,6 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
	char *buf;
	char *buf;


	while (bcount) {
	while (bcount) {
		if (pc->sg - scsi_sglist(pc->scsi_cmd) >
		                                 scsi_sg_count(pc->scsi_cmd)) {
			printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
			idescsi_discard_data (drive, bcount);
			return;
		}
		count = min(pc->sg->length - pc->b_count, bcount);
		count = min(pc->sg->length - pc->b_count, bcount);
		if (PageHighMem(pc->sg->page)) {
		if (PageHighMem(pc->sg->page)) {
			unsigned long flags;
			unsigned long flags;
@@ -197,10 +192,17 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
		}
		}
		bcount -= count; pc->b_count += count;
		bcount -= count; pc->b_count += count;
		if (pc->b_count == pc->sg->length) {
		if (pc->b_count == pc->sg->length) {
			pc->sg++;
			if (pc->sg == pc->last_sg)
				break;
			pc->sg = sg_next(pc->sg);
			pc->b_count = 0;
			pc->b_count = 0;
		}
		}
	}
	}

	if (bcount) {
		printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
		idescsi_discard_data (drive, bcount);
	}
}
}


static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigned int bcount)
static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigned int bcount)
@@ -209,12 +211,6 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
	char *buf;
	char *buf;


	while (bcount) {
	while (bcount) {
		if (pc->sg - scsi_sglist(pc->scsi_cmd) >
		                                 scsi_sg_count(pc->scsi_cmd)) {
			printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
			idescsi_output_zeros (drive, bcount);
			return;
		}
		count = min(pc->sg->length - pc->b_count, bcount);
		count = min(pc->sg->length - pc->b_count, bcount);
		if (PageHighMem(pc->sg->page)) {
		if (PageHighMem(pc->sg->page)) {
			unsigned long flags;
			unsigned long flags;
@@ -233,10 +229,17 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
		}
		}
		bcount -= count; pc->b_count += count;
		bcount -= count; pc->b_count += count;
		if (pc->b_count == pc->sg->length) {
		if (pc->b_count == pc->sg->length) {
			pc->sg++;
			if (pc->sg == pc->last_sg)
				break;
			pc->sg = sg_next(pc->sg);
			pc->b_count = 0;
			pc->b_count = 0;
		}
		}
	}
	}

	if (bcount) {
		printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
		idescsi_output_zeros (drive, bcount);
	}
}
}


static void hexdump(u8 *x, int len)
static void hexdump(u8 *x, int len)
@@ -804,6 +807,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
	memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
	memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
	pc->buffer = NULL;
	pc->buffer = NULL;
	pc->sg = scsi_sglist(cmd);
	pc->sg = scsi_sglist(cmd);
	pc->last_sg = sg_last(pc->sg, cmd->use_sg);
	pc->b_count = 0;
	pc->b_count = 0;
	pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd);
	pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd);
	pc->scsi_cmd = cmd;
	pc->scsi_cmd = cmd;