Re: [PATCH 2/8] libata: implement protocol tests

2007-12-01 Thread Jeff Garzik

Tejun Heo wrote:

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 5eb5983..8d5cd16 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5969,7 +5946,7 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
 */
WARN_ON(ap-ops-error_handler  ata_tag_valid(link-active_tag));
 
-	if (qc-tf.protocol == ATA_PROT_NCQ) {

+   if (prot == ATA_PROT_NCQ) {
WARN_ON(link-sactive  (1  qc-tag));
 
 		if (!link-sactive)


missed one?

-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/8] libata: implement protocol tests

2007-11-27 Thread Tejun Heo
Implement protocol tests - ata_is_atapi(), ata_is_nodata(),
ata_is_pio(), ata_is_dma(), ata_is_ncq() and ata_is_data() and use
them to replace is_atapi_taskfile() and hard coded protocol tests.

Signed-off-by: Tejun Heo [EMAIL PROTECTED]
---
 drivers/ata/ahci.c|2 +-
 drivers/ata/libata-core.c |   36 -
 drivers/ata/sata_fsl.c|2 +-
 drivers/ata/sata_sil.c|   10 ++---
 drivers/ata/sata_sil24.c  |   26 ++-
 drivers/scsi/libsas/sas_ata.c |2 +-
 include/linux/ata.h   |   71 +
 7 files changed, 82 insertions(+), 67 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 2c686b4..a8fc9c0 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1505,7 +1505,7 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
 {
struct ata_port *ap = qc-ap;
struct ahci_port_priv *pp = ap-private_data;
-   int is_atapi = is_atapi_taskfile(qc-tf);
+   int is_atapi = ata_is_atapi(qc-tf.protocol);
void *cmd_tbl;
u32 opts;
const u32 cmd_fis_len = 5; /* five dwords */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 5eb5983..8d5cd16 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5325,7 +5325,7 @@ static inline int ata_hsm_ok_in_wq(struct ata_port *ap, 
struct ata_queued_cmd *q
(qc-tf.flags  ATA_TFLAG_WRITE))
return 1;
 
-   if (is_atapi_taskfile(qc-tf) 
+   if (ata_is_atapi(qc-tf.protocol) 
!(qc-dev-flags  ATA_DFLAG_CDB_INTR))
return 1;
}
@@ -5922,30 +5922,6 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 
qc_active,
return nr_done;
 }
 
-static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
-{
-   struct ata_port *ap = qc-ap;
-
-   switch (qc-tf.protocol) {
-   case ATA_PROT_NCQ:
-   case ATA_PROT_DMA:
-   case ATA_PROT_ATAPI_DMA:
-   return 1;
-
-   case ATA_PROT_ATAPI:
-   case ATA_PROT_PIO:
-   if (ap-flags  ATA_FLAG_PIO_DMA)
-   return 1;
-
-   /* fall through */
-
-   default:
-   return 0;
-   }
-
-   /* never reached */
-}
-
 /**
  * ata_qc_issue - issue taskfile to device
  * @qc: command to issue to device
@@ -5962,6 +5938,7 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
 {
struct ata_port *ap = qc-ap;
struct ata_link *link = qc-dev-link;
+   u8 prot = qc-tf.protocol;
 
/* Make sure only one non-NCQ command is outstanding.  The
 * check is skipped for old EH because it reuses active qc to
@@ -5969,7 +5946,7 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
 */
WARN_ON(ap-ops-error_handler  ata_tag_valid(link-active_tag));
 
-   if (qc-tf.protocol == ATA_PROT_NCQ) {
+   if (prot == ATA_PROT_NCQ) {
WARN_ON(link-sactive  (1  qc-tag));
 
if (!link-sactive)
@@ -5985,7 +5962,8 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
qc-flags |= ATA_QCFLAG_ACTIVE;
ap-qc_active |= 1  qc-tag;
 
-   if (ata_should_dma_map(qc)) {
+   if (ata_is_dma(prot) || (ata_is_pio(prot) 
+(ap-flags  ATA_FLAG_PIO_DMA))) {
if (qc-flags  ATA_QCFLAG_SG) {
if (ata_sg_setup(qc))
goto sg_err;
@@ -6184,8 +6162,8 @@ inline unsigned int ata_host_intr(struct ata_port *ap,
 */
 
/* Check the ATA_DFLAG_CDB_INTR flag is enough here.
-* The flag was turned on only for atapi devices.
-* No need to check is_atapi_taskfile(qc-tf) again.
+* The flag was turned on only for atapi devices.  No
+* need to check ata_is_atapi(qc-tf.protocol) again.
 */
if (!(qc-dev-flags  ATA_DFLAG_CDB_INTR))
goto idle_irq;
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index d015b4a..a3c33f1 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -417,7 +417,7 @@ static void sata_fsl_qc_prep(struct ata_queued_cmd *qc)
}
 
/* setup ACMD - atapi command in cmd. desc. if this is ATAPI cmd */
-   if (is_atapi_taskfile(qc-tf)) {
+   if (ata_is_atapi(qc-tf.protocol)) {
desc_info |= ATAPI_CMD;
memset((void *)cd-acmd, 0, 32);
memcpy((void *)cd-acmd, qc-cdb, qc-dev-cdb_len);
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 4e6e381..4f31481 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -420,15 +420,14 @@ static void sil_host_intr(struct ata_port *ap, u32 bmdma2)
 */
 
/* Check the ATA_DFLAG_CDB_INTR flag is enough here.
-* The flag was turned on only for atapi