Skip to contentSkip to conversation

ide: merge do_rw_taskfile() and flagged_taskfile() into do_taskfile()

PATCH In review Tejun Heo 2 participants 3 messages Feb 6, 2005 libata

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 ide: merge do_rw_taskfile() and flagged_taskfile() into do_taskfile()

Hello, Bartlomiej.

This is a new version of ide_do_taskfile.patch. Compared to the
original do_rw_task(), only one more 'if' is used in the hot path, so I think the performance issue can be ignored now. Also, there's no userland visible change with this patch. Everything should work just as it did with do_rw_taskfile()/flagged_taskfile().

do_taskfile() is different from do_rw_taskfile() in that

- It uses task->data_phase to determine whether it's a DMA command or not.

do_taskfile() is different from flagged_taskfile() in that

- No (TASKFILE_MULTI_IN && !mult_count) check. ide_taskfile_ioctl() checks the same thing, so it doesn't change anything.
- No task->tf_out_flags handling. ide_end_drive_cmd() ignores it anyway, so, again, it doesn't change anything.

So, what do you think?

drivers/ide/ide-disk.c +6 -6
Index: linux-ide-series3-export/drivers/ide/ide-disk.c
===================================================================
@@ -535,7 +535,7 @@ static ide_startstop_t idedisk_special (
 			args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SPECIFY;
 			args.command_type = IDE_DRIVE_TASK_NO_DATA;
 			args.handler	  = &set_geometry_intr;
-			do_rw_taskfile(drive, &args);
+			do_taskfile(drive, &args);
 		}
 	} else if (s->b.recalibrate) {
 		s->b.recalibrate = 0;
@@ -546,7 +546,7 @@ static ide_startstop_t idedisk_special (
 			args.tfRegister[IDE_COMMAND_OFFSET] = WIN_RESTORE;
 			args.command_type = IDE_DRIVE_TASK_NO_DATA;
 			args.handler	  = &recal_intr;
-			do_rw_taskfile(drive, &args);
+			do_taskfile(drive, &args);
 		}
 	} else if (s->b.set_multmode) {
 		s->b.set_multmode = 0;
@@ -559,7 +559,7 @@ static ide_startstop_t idedisk_special (
 			args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETMULT;
 			args.command_type = IDE_DRIVE_TASK_NO_DATA;
 			args.handler	  = &set_multmode_intr;
-			do_rw_taskfile(drive, &args);
+			do_taskfile(drive, &args);
 		}
 	} else if (s->all) {
 		int special = s->all;
@@ -898,19 +898,19 @@ static ide_startstop_t idedisk_start_pow
 			args->tfRegister[IDE_COMMAND_OFFSET] = WIN_FLUSH_CACHE;
 		args->command_type = IDE_DRIVE_TASK_NO_DATA;
 		args->handler	   = &task_no_data_intr;
-		return do_rw_taskfile(drive, args);
+		return do_taskfile(drive, args);
 
 	case idedisk_pm_standby:	/* Suspend step 2 (standby) */
 		args->tfRegister[IDE_COMMAND_OFFSET] = WIN_STANDBYNOW1;
 		args->command_type = IDE_DRIVE_TASK_NO_DATA;
 		args->handler	   = &task_no_data_intr;
-		return do_rw_taskfile(drive, args);
+		return do_taskfile(drive, args);
 
 	case idedisk_pm_idle:		/* Resume step 1 (idle) */
 		args->tfRegister[IDE_COMMAND_OFFSET] = WIN_IDLEIMMEDIATE;
 		args->command_type = IDE_DRIVE_TASK_NO_DATA;
 		args->handler = task_no_data_intr;
-		return do_rw_taskfile(drive, args);
+		return do_taskfile(drive, args);
 
 	case idedisk_pm_restore_dma:	/* Resume step 2 (restore DMA) */
 		/*
drivers/ide/ide-io.c +1 -3
Index: linux-ide-series3-export/drivers/ide/ide-io.c
===================================================================
@@ -682,9 +682,7 @@ static ide_startstop_t execute_drive_tas
 		break;
 	}
 
-	if (args->tf_out_flags.all != 0) 
-		return flagged_taskfile(drive, args);
-	return do_rw_taskfile(drive, args);
+	return do_taskfile(drive, args);
 }
 
 /**
drivers/ide/ide-taskfile.c +83 -162

274 lines not on this page · raw message

include/linux/ide.h +2 -7
Index: linux-ide-series3-export/include/linux/ide.h
===================================================================
@@ -1090,7 +1090,7 @@ static inline void destroy_proc_ide_inte
  *	- ide_started :	In this case, the channel is left busy until an
  *			async event (interrupt) occurs.
  * Typically, start_power_step() will issue a taskfile request with
- * do_rw_taskfile().
+ * do_taskfile().
  *
  * Upon reception of the interrupt, the core will call complete_power_step()
  * with the error code if any. This routine should update the step value
@@ -1298,12 +1298,7 @@ extern int wait_for_ready(ide_drive_t *,
 /*
  * taskfile io for disks for now...and builds request from ide_ioctl
  */
-extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
-
-/*
- * Special Flagged Register Validation Caller
- */
-extern ide_startstop_t flagged_taskfile(ide_drive_t *, ide_task_t *);
+extern ide_startstop_t do_taskfile(ide_drive_t *, ide_task_t *);
 
 extern ide_startstop_t set_multmode_intr(ide_drive_t *);
 extern ide_startstop_t set_geometry_intr(ide_drive_t *);
#1 lore raw
Quoted 1 line · Tejun Heo

Hello, Bartlomiej.

Hi,

Quoted 7 lines

This is a new version of ide_do_taskfile.patch. Compared to the
original do_rw_task(), only one more 'if' is used in the hot path, so I think the performance issue can be ignored now. Also, there's no userland visible change with this patch. Everything should work just as it did with do_rw_taskfile()/flagged_taskfile().

do_taskfile() is different from do_rw_taskfile() in that

Is there any gain in changing name to do_taskfile()?

Quoted 2 lines

- It uses task->data_phase to determine whether it's a DMA command or not.

this is user-space visible change
(it is right thing to do, I just wanted to point the fact)

Quoted 4 lines

do_taskfile() is different from flagged_taskfile() in that

- No (TASKFILE_MULTI_IN && !mult_count) check. ide_taskfile_ioctl() checks the same thing, so it doesn't change anything.

The check may be needed. AFAIR drive->mult_count may change before our taskfile request is started.

Quoted 2 lines

- No task->tf_out_flags handling. ide_end_drive_cmd() ignores it anyway, so, again, it doesn't change anything.

I guess you mean ->tf_in_flags?

Quoted 1 line

So, what do you think?

This patch looks much better but could you move writing taskfile registers to separate helpers (one for non-flagged and one for flagged)?

Probably splitting non-flagged taskfile load helper off do_rw_taskfile() should be done in separate patch. We can then use this helper in ide-disk.c for __ide_do_rw_taskfile() (we can't do direct conversion to do_rw_taskfile() yet for various reasons).

Thanks,
Bartlomiej

author
#2 lore raw

Hello,

Quoted 14 lines · Bartlomiej Zolnierkiewicz
Quoted 1 line · Tejun Heo

Hello, Bartlomiej.

Hi,

Quoted 6 lines

This is a new version of ide_do_taskfile.patch. Compared to the original do_rw_task(), only one more 'if' is used in the hot path, so I think the performance issue can be ignored now. Also, there's no userland visible change with this patch. Everything should work just as it did with do_rw_taskfile()/flagged_taskfile().

Quoted 5 lines
Quoted 1 line

do_taskfile() is different from do_rw_taskfile() in that

Is there any gain in changing name to do_taskfile()?

Well, I was just thinking

do_rw_taskfile + (do_)flagged_taskfile -> do_taskfile.

If you like do_rw_taskfile better, I guess that's okay too. :-)

Quoted 8 lines
Quoted 3 lines

- It uses task->data_phase to determine whether it's a DMA command or not.

this is user-space visible change
(it is right thing to do, I just wanted to point the fact)

Oops, I forgot that. Still, it was kind of weird before. If any of
tf_{in|out}_flags is set, flagged_taskfile() is called and ->data_phase was used, but, if none of the flags was set, do_rw_taskfile() was called and the command is used to determine the same thing. But, yeah, it's user-visible.

Quoted 10 lines
Quoted 5 lines

do_taskfile() is different from flagged_taskfile() in that

- No (TASKFILE_MULTI_IN && !mult_count) check. ide_taskfile_ioctl() checks the same thing, so it doesn't change anything.

The check may be needed. AFAIR drive->mult_count may change before our taskfile request is started.

Okay, I'll resurrect that test.

Quoted 7 lines
Quoted 3 lines

- No task->tf_out_flags handling. ide_end_drive_cmd() ignores it anyway, so, again, it doesn't change anything.

I guess you mean ->tf_in_flags?

Yes.

Quoted 11 lines
Quoted 2 lines

So, what do you think?

This patch looks much better but could you move writing taskfile registers to separate helpers (one for non-flagged and one for flagged)?

Probably splitting non-flagged taskfile load helper off do_rw_taskfile() should be done in separate patch. We can then use this helper in ide-disk.c for __ide_do_rw_taskfile() (we can't do direct conversion to do_rw_taskfile() yet for various reasons).

Sure, I'll do it now.

Thanks.

Signature · 1 line
tejun