aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-04-02 05:51:53 -0400
committerJeff Garzik <jeff@garzik.org>2006-04-02 10:09:20 -0400
commitc91af2c87e4048cdefcfc9f16fed8d728243c92d (patch)
tree346a50bed1b05bd144d755ba4281186877a432db /drivers
parent2719736779da2c7fbb17d3de16c817b429bfeb9c (diff)
[PATCH] libata: pass qc around intead of ap during PIO
The current code passes pointer to ap around and repeatedly performs ata_qc_from_tag() to access the ongoing qc. This is unnatural and makes EH synchronization cumbersome. Make PIO codes deal with qc instead of ap. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/libata-core.c71
1 files changed, 26 insertions, 45 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 007d18888045..e9002a4174d0 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -3416,7 +3416,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc)
3416 3416
3417/** 3417/**
3418 * ata_pio_poll - poll using PIO, depending on current state 3418 * ata_pio_poll - poll using PIO, depending on current state
3419 * @ap: the target ata_port 3419 * @qc: qc in progress
3420 * 3420 *
3421 * LOCKING: 3421 * LOCKING:
3422 * None. (executing in kernel thread context) 3422 * None. (executing in kernel thread context)
@@ -3424,17 +3424,13 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc)
3424 * RETURNS: 3424 * RETURNS:
3425 * timeout value to use 3425 * timeout value to use
3426 */ 3426 */
3427 3427static unsigned long ata_pio_poll(struct ata_queued_cmd *qc)
3428static unsigned long ata_pio_poll(struct ata_port *ap)
3429{ 3428{
3430 struct ata_queued_cmd *qc; 3429 struct ata_port *ap = qc->ap;
3431 u8 status; 3430 u8 status;
3432 unsigned int poll_state = HSM_ST_UNKNOWN; 3431 unsigned int poll_state = HSM_ST_UNKNOWN;
3433 unsigned int reg_state = HSM_ST_UNKNOWN; 3432 unsigned int reg_state = HSM_ST_UNKNOWN;
3434 3433
3435 qc = ata_qc_from_tag(ap, ap->active_tag);
3436 WARN_ON(qc == NULL);
3437
3438 switch (ap->hsm_task_state) { 3434 switch (ap->hsm_task_state) {
3439 case HSM_ST: 3435 case HSM_ST:
3440 case HSM_ST_POLL: 3436 case HSM_ST_POLL:
@@ -3468,7 +3464,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
3468 3464
3469/** 3465/**
3470 * ata_pio_complete - check if drive is busy or idle 3466 * ata_pio_complete - check if drive is busy or idle
3471 * @ap: the target ata_port 3467 * @qc: qc to complete
3472 * 3468 *
3473 * LOCKING: 3469 * LOCKING:
3474 * None. (executing in kernel thread context) 3470 * None. (executing in kernel thread context)
@@ -3476,10 +3472,9 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
3476 * RETURNS: 3472 * RETURNS:
3477 * Non-zero if qc completed, zero otherwise. 3473 * Non-zero if qc completed, zero otherwise.
3478 */ 3474 */
3479 3475static int ata_pio_complete(struct ata_queued_cmd *qc)
3480static int ata_pio_complete (struct ata_port *ap)
3481{ 3476{
3482 struct ata_queued_cmd *qc; 3477 struct ata_port *ap = qc->ap;
3483 u8 drv_stat; 3478 u8 drv_stat;
3484 3479
3485 /* 3480 /*
@@ -3500,9 +3495,6 @@ static int ata_pio_complete (struct ata_port *ap)
3500 } 3495 }
3501 } 3496 }
3502 3497
3503 qc = ata_qc_from_tag(ap, ap->active_tag);
3504 WARN_ON(qc == NULL);
3505
3506 drv_stat = ata_wait_idle(ap); 3498 drv_stat = ata_wait_idle(ap);
3507 if (!ata_ok(drv_stat)) { 3499 if (!ata_ok(drv_stat)) {
3508 qc->err_mask |= __ac_err_mask(drv_stat); 3500 qc->err_mask |= __ac_err_mask(drv_stat);
@@ -3838,15 +3830,14 @@ err_out:
3838 3830
3839/** 3831/**
3840 * ata_pio_block - start PIO on a block 3832 * ata_pio_block - start PIO on a block
3841 * @ap: the target ata_port 3833 * @qc: qc to transfer block for
3842 * 3834 *
3843 * LOCKING: 3835 * LOCKING:
3844 * None. (executing in kernel thread context) 3836 * None. (executing in kernel thread context)
3845 */ 3837 */
3846 3838static void ata_pio_block(struct ata_queued_cmd *qc)
3847static void ata_pio_block(struct ata_port *ap)
3848{ 3839{
3849 struct ata_queued_cmd *qc; 3840 struct ata_port *ap = qc->ap;
3850 u8 status; 3841 u8 status;
3851 3842
3852 /* 3843 /*
@@ -3868,9 +3859,6 @@ static void ata_pio_block(struct ata_port *ap)
3868 } 3859 }
3869 } 3860 }
3870 3861
3871 qc = ata_qc_from_tag(ap, ap->active_tag);
3872 WARN_ON(qc == NULL);
3873
3874 /* check error */ 3862 /* check error */
3875 if (status & (ATA_ERR | ATA_DF)) { 3863 if (status & (ATA_ERR | ATA_DF)) {
3876 qc->err_mask |= AC_ERR_DEV; 3864 qc->err_mask |= AC_ERR_DEV;
@@ -3899,12 +3887,9 @@ static void ata_pio_block(struct ata_port *ap)
3899 } 3887 }
3900} 3888}
3901 3889
3902static void ata_pio_error(struct ata_port *ap) 3890static void ata_pio_error(struct ata_queued_cmd *qc)
3903{ 3891{
3904 struct ata_queued_cmd *qc; 3892 struct ata_port *ap = qc->ap;
3905
3906 qc = ata_qc_from_tag(ap, ap->active_tag);
3907 WARN_ON(qc == NULL);
3908 3893
3909 if (qc->tf.command != ATA_CMD_PACKET) 3894 if (qc->tf.command != ATA_CMD_PACKET)
3910 printk(KERN_WARNING "ata%u: dev %u PIO error\n", 3895 printk(KERN_WARNING "ata%u: dev %u PIO error\n",
@@ -3922,7 +3907,8 @@ static void ata_pio_error(struct ata_port *ap)
3922 3907
3923static void ata_pio_task(void *_data) 3908static void ata_pio_task(void *_data)
3924{ 3909{
3925 struct ata_port *ap = _data; 3910 struct ata_queued_cmd *qc = _data;
3911 struct ata_port *ap = qc->ap;
3926 unsigned long timeout; 3912 unsigned long timeout;
3927 int qc_completed; 3913 int qc_completed;
3928 3914
@@ -3935,33 +3921,33 @@ fsm_start:
3935 return; 3921 return;
3936 3922
3937 case HSM_ST: 3923 case HSM_ST:
3938 ata_pio_block(ap); 3924 ata_pio_block(qc);
3939 break; 3925 break;
3940 3926
3941 case HSM_ST_LAST: 3927 case HSM_ST_LAST:
3942 qc_completed = ata_pio_complete(ap); 3928 qc_completed = ata_pio_complete(qc);
3943 break; 3929 break;
3944 3930
3945 case HSM_ST_POLL: 3931 case HSM_ST_POLL:
3946 case HSM_ST_LAST_POLL: 3932 case HSM_ST_LAST_POLL:
3947 timeout = ata_pio_poll(ap); 3933 timeout = ata_pio_poll(qc);
3948 break; 3934 break;
3949 3935
3950 case HSM_ST_TMOUT: 3936 case HSM_ST_TMOUT:
3951 case HSM_ST_ERR: 3937 case HSM_ST_ERR:
3952 ata_pio_error(ap); 3938 ata_pio_error(qc);
3953 return; 3939 return;
3954 } 3940 }
3955 3941
3956 if (timeout) 3942 if (timeout)
3957 ata_port_queue_task(ap, ata_pio_task, ap, timeout); 3943 ata_port_queue_task(ap, ata_pio_task, qc, timeout);
3958 else if (!qc_completed) 3944 else if (!qc_completed)
3959 goto fsm_start; 3945 goto fsm_start;
3960} 3946}
3961 3947
3962/** 3948/**
3963 * atapi_packet_task - Write CDB bytes to hardware 3949 * atapi_packet_task - Write CDB bytes to hardware
3964 * @_data: Port to which ATAPI device is attached. 3950 * @_data: qc in progress
3965 * 3951 *
3966 * When device has indicated its readiness to accept 3952 * When device has indicated its readiness to accept
3967 * a CDB, this function is called. Send the CDB. 3953 * a CDB, this function is called. Send the CDB.
@@ -3972,17 +3958,12 @@ fsm_start:
3972 * LOCKING: 3958 * LOCKING:
3973 * Kernel thread context (may sleep) 3959 * Kernel thread context (may sleep)
3974 */ 3960 */
3975
3976static void atapi_packet_task(void *_data) 3961static void atapi_packet_task(void *_data)
3977{ 3962{
3978 struct ata_port *ap = _data; 3963 struct ata_queued_cmd *qc = _data;
3979 struct ata_queued_cmd *qc; 3964 struct ata_port *ap = qc->ap;
3980 u8 status; 3965 u8 status;
3981 3966
3982 qc = ata_qc_from_tag(ap, ap->active_tag);
3983 WARN_ON(qc == NULL);
3984 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE));
3985
3986 /* sleep-wait for BSY to clear */ 3967 /* sleep-wait for BSY to clear */
3987 DPRINTK("busy wait\n"); 3968 DPRINTK("busy wait\n");
3988 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { 3969 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) {
@@ -4022,7 +4003,7 @@ static void atapi_packet_task(void *_data)
4022 4003
4023 /* PIO commands are handled by polling */ 4004 /* PIO commands are handled by polling */
4024 ap->hsm_task_state = HSM_ST; 4005 ap->hsm_task_state = HSM_ST;
4025 ata_port_queue_task(ap, ata_pio_task, ap, 0); 4006 ata_port_queue_task(ap, ata_pio_task, qc, 0);
4026 } 4007 }
4027 4008
4028 return; 4009 return;
@@ -4328,26 +4309,26 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4328 ata_qc_set_polling(qc); 4309 ata_qc_set_polling(qc);
4329 ata_tf_to_host(ap, &qc->tf); 4310 ata_tf_to_host(ap, &qc->tf);
4330 ap->hsm_task_state = HSM_ST; 4311 ap->hsm_task_state = HSM_ST;
4331 ata_port_queue_task(ap, ata_pio_task, ap, 0); 4312 ata_port_queue_task(ap, ata_pio_task, qc, 0);
4332 break; 4313 break;
4333 4314
4334 case ATA_PROT_ATAPI: 4315 case ATA_PROT_ATAPI:
4335 ata_qc_set_polling(qc); 4316 ata_qc_set_polling(qc);
4336 ata_tf_to_host(ap, &qc->tf); 4317 ata_tf_to_host(ap, &qc->tf);
4337 ata_port_queue_task(ap, atapi_packet_task, ap, 0); 4318 ata_port_queue_task(ap, atapi_packet_task, qc, 0);
4338 break; 4319 break;
4339 4320
4340 case ATA_PROT_ATAPI_NODATA: 4321 case ATA_PROT_ATAPI_NODATA:
4341 ap->flags |= ATA_FLAG_NOINTR; 4322 ap->flags |= ATA_FLAG_NOINTR;
4342 ata_tf_to_host(ap, &qc->tf); 4323 ata_tf_to_host(ap, &qc->tf);
4343 ata_port_queue_task(ap, atapi_packet_task, ap, 0); 4324 ata_port_queue_task(ap, atapi_packet_task, qc, 0);
4344 break; 4325 break;
4345 4326
4346 case ATA_PROT_ATAPI_DMA: 4327 case ATA_PROT_ATAPI_DMA:
4347 ap->flags |= ATA_FLAG_NOINTR; 4328 ap->flags |= ATA_FLAG_NOINTR;
4348 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ 4329 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */
4349 ap->ops->bmdma_setup(qc); /* set up bmdma */ 4330 ap->ops->bmdma_setup(qc); /* set up bmdma */
4350 ata_port_queue_task(ap, atapi_packet_task, ap, 0); 4331 ata_port_queue_task(ap, atapi_packet_task, qc, 0);
4351 break; 4332 break;
4352 4333
4353 default: 4334 default: