@@ -107,27 +107,21 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq,
107107int ide_end_request (ide_drive_t * drive , int uptodate , int nr_sectors )
108108{
109109 unsigned int nr_bytes = nr_sectors << 9 ;
110- struct request * rq ;
110+ struct request * rq = drive -> hwif -> hwgroup -> rq ;
111111 unsigned long flags ;
112112 int ret = 1 ;
113113
114- /*
115- * room for locking improvements here, the calls below don't
116- * need the queue lock held at all
117- */
118- spin_lock_irqsave (& ide_lock , flags );
119- rq = HWGROUP (drive )-> rq ;
120-
121114 if (!nr_bytes ) {
122115 if (blk_pc_request (rq ))
123116 nr_bytes = rq -> data_len ;
124117 else
125118 nr_bytes = rq -> hard_cur_sectors << 9 ;
126119 }
127120
121+ spin_lock_irqsave (& ide_lock , flags );
128122 ret = __ide_end_request (drive , rq , uptodate , nr_bytes , 1 );
129-
130123 spin_unlock_irqrestore (& ide_lock , flags );
124+
131125 return ret ;
132126}
133127EXPORT_SYMBOL (ide_end_request );
@@ -245,8 +239,9 @@ int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
245239 unsigned long flags ;
246240 int ret ;
247241
248- spin_lock_irqsave (& ide_lock , flags );
249242 BUG_ON (!blk_rq_started (rq ));
243+
244+ spin_lock_irqsave (& ide_lock , flags );
250245 ret = __ide_end_request (drive , rq , uptodate , nr_sectors << 9 , 0 );
251246 spin_unlock_irqrestore (& ide_lock , flags );
252247
@@ -278,7 +273,11 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq)
278273 drive -> dev_flags &= ~IDE_DFLAG_BLOCKED ;
279274 blk_start_queue (drive -> queue );
280275 }
281- HWGROUP (drive )-> rq = NULL ;
276+ spin_unlock_irqrestore (& ide_lock , flags );
277+
278+ drive -> hwif -> hwgroup -> rq = NULL ;
279+
280+ spin_lock_irqsave (& ide_lock , flags );
282281 if (__blk_end_request (rq , 0 , 0 ))
283282 BUG ();
284283 spin_unlock_irqrestore (& ide_lock , flags );
@@ -300,12 +299,9 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq)
300299
301300void ide_end_drive_cmd (ide_drive_t * drive , u8 stat , u8 err )
302301{
302+ ide_hwgroup_t * hwgroup = drive -> hwif -> hwgroup ;
303+ struct request * rq = hwgroup -> rq ;
303304 unsigned long flags ;
304- struct request * rq ;
305-
306- spin_lock_irqsave (& ide_lock , flags );
307- rq = HWGROUP (drive )-> rq ;
308- spin_unlock_irqrestore (& ide_lock , flags );
309305
310306 if (rq -> cmd_type == REQ_TYPE_ATA_TASKFILE ) {
311307 ide_task_t * task = (ide_task_t * )rq -> special ;
@@ -333,15 +329,16 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
333329 return ;
334330 }
335331
336- spin_lock_irqsave ( & ide_lock , flags ) ;
337- HWGROUP ( drive ) -> rq = NULL ;
332+ hwgroup -> rq = NULL ;
333+
338334 rq -> errors = err ;
335+
336+ spin_lock_irqsave (& ide_lock , flags );
339337 if (unlikely (__blk_end_request (rq , (rq -> errors ? - EIO : 0 ),
340338 blk_rq_bytes (rq ))))
341339 BUG ();
342340 spin_unlock_irqrestore (& ide_lock , flags );
343341}
344-
345342EXPORT_SYMBOL (ide_end_drive_cmd );
346343
347344static void ide_kill_rq (ide_drive_t * drive , struct request * rq )
@@ -1489,11 +1486,12 @@ irqreturn_t ide_intr (int irq, void *dev_id)
14891486
14901487void ide_do_drive_cmd (ide_drive_t * drive , struct request * rq )
14911488{
1489+ ide_hwgroup_t * hwgroup = drive -> hwif -> hwgroup ;
14921490 unsigned long flags ;
1493- ide_hwgroup_t * hwgroup = HWGROUP (drive );
14941491
1495- spin_lock_irqsave (& ide_lock , flags );
14961492 hwgroup -> rq = NULL ;
1493+
1494+ spin_lock_irqsave (& ide_lock , flags );
14971495 __elv_add_request (drive -> queue , rq , ELEVATOR_INSERT_FRONT , 0 );
14981496 blk_start_queueing (drive -> queue );
14991497 spin_unlock_irqrestore (& ide_lock , flags );
0 commit comments