aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-04-07 09:47:20 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-17 15:44:23 -0400
commit4c9bf4e799ce06a7378f1196587084802a414c03 (patch)
tree70a7d3741e756b975468850537f222349143a0be
parent79f97dadfe9b4b561634d202225ba2fa910dc225 (diff)
libata: replace tf_read with qc_fill_rtf for non-SFF drivers
Now that all SFF stuff is separated out of core layer, core layer doesn't call ops->tf_read directly. It gets called only via ops->qc_fill_rtf() for non-SFF drivers. This patch directly implements private ops->qc_fill_rtf() for non-SFF controllers and kill ops->tf_read(). This is much cleaner for non-SFF controllers as some of them have to cache SFF register values in private data structure and report the cached values via ops->tf_read(). Also, ops->tf_read() gets nasty for controllers which don't have clear notion of TF registers when operation is not in progress. As this change makes default ops->qc_fill_rtf unnecessary, move ata_sff_qc_fill_rtf() form ata_base_port_ops to ata_sff_port_ops where it belongs. Signed-off-by: Tejun Heo <htejun@gmail.com>
-rw-r--r--drivers/ata/ahci.c21
-rw-r--r--drivers/ata/libata-core.c1
-rw-r--r--drivers/ata/libata-sff.c1
-rw-r--r--drivers/ata/sata_fsl.c24
-rw-r--r--drivers/ata/sata_sil24.c8
-rw-r--r--drivers/scsi/ipr.c59
-rw-r--r--drivers/scsi/libsas/sas_ata.c17
7 files changed, 66 insertions, 65 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 1389c64e0027..ad5b6f384ba1 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -243,9 +243,9 @@ static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
243static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val); 243static int ahci_scr_write(struct ata_port *ap, unsigned int sc_reg, u32 val);
244static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 244static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
245static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc); 245static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc);
246static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc);
246static int ahci_port_start(struct ata_port *ap); 247static int ahci_port_start(struct ata_port *ap);
247static void ahci_port_stop(struct ata_port *ap); 248static void ahci_port_stop(struct ata_port *ap);
248static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
249static void ahci_qc_prep(struct ata_queued_cmd *qc); 249static void ahci_qc_prep(struct ata_queued_cmd *qc);
250static u8 ahci_check_status(struct ata_port *ap); 250static u8 ahci_check_status(struct ata_port *ap);
251static void ahci_freeze(struct ata_port *ap); 251static void ahci_freeze(struct ata_port *ap);
@@ -295,10 +295,10 @@ static struct ata_port_operations ahci_ops = {
295 .sff_check_status = ahci_check_status, 295 .sff_check_status = ahci_check_status,
296 .sff_check_altstatus = ahci_check_status, 296 .sff_check_altstatus = ahci_check_status,
297 297
298 .sff_tf_read = ahci_tf_read,
299 .qc_defer = sata_pmp_qc_defer_cmd_switch, 298 .qc_defer = sata_pmp_qc_defer_cmd_switch,
300 .qc_prep = ahci_qc_prep, 299 .qc_prep = ahci_qc_prep,
301 .qc_issue = ahci_qc_issue, 300 .qc_issue = ahci_qc_issue,
301 .qc_fill_rtf = ahci_qc_fill_rtf,
302 302
303 .freeze = ahci_freeze, 303 .freeze = ahci_freeze,
304 .thaw = ahci_thaw, 304 .thaw = ahci_thaw,
@@ -1473,14 +1473,6 @@ static u8 ahci_check_status(struct ata_port *ap)
1473 return readl(mmio + PORT_TFDATA) & 0xFF; 1473 return readl(mmio + PORT_TFDATA) & 0xFF;
1474} 1474}
1475 1475
1476static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
1477{
1478 struct ahci_port_priv *pp = ap->private_data;
1479 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
1480
1481 ata_tf_from_fis(d2h_fis, tf);
1482}
1483
1484static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl) 1476static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl)
1485{ 1477{
1486 struct scatterlist *sg; 1478 struct scatterlist *sg;
@@ -1779,6 +1771,15 @@ static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
1779 return 0; 1771 return 0;
1780} 1772}
1781 1773
1774static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
1775{
1776 struct ahci_port_priv *pp = qc->ap->private_data;
1777 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
1778
1779 ata_tf_from_fis(d2h_fis, &qc->result_tf);
1780 return true;
1781}
1782
1782static void ahci_freeze(struct ata_port *ap) 1783static void ahci_freeze(struct ata_port *ap)
1783{ 1784{
1784 void __iomem *port_mmio = ahci_port_base(ap); 1785 void __iomem *port_mmio = ahci_port_base(ap);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index dcc5a28e26c1..e8598eeeec39 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -74,7 +74,6 @@ const unsigned long sata_deb_timing_hotplug[] = { 25, 500, 2000 };
74const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 }; 74const unsigned long sata_deb_timing_long[] = { 100, 2000, 5000 };
75 75
76const struct ata_port_operations ata_base_port_ops = { 76const struct ata_port_operations ata_base_port_ops = {
77 .qc_fill_rtf = ata_sff_qc_fill_rtf,
78 .prereset = ata_std_prereset, 77 .prereset = ata_std_prereset,
79 .postreset = ata_std_postreset, 78 .postreset = ata_std_postreset,
80 .error_handler = ata_std_error_handler, 79 .error_handler = ata_std_error_handler,
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 5ae813f54420..8e6c78ac70f8 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -44,6 +44,7 @@ const struct ata_port_operations ata_sff_port_ops = {
44 44
45 .qc_prep = ata_sff_qc_prep, 45 .qc_prep = ata_sff_qc_prep,
46 .qc_issue = ata_sff_qc_issue, 46 .qc_issue = ata_sff_qc_issue,
47 .qc_fill_rtf = ata_sff_qc_fill_rtf,
47 48
48 .freeze = ata_sff_freeze, 49 .freeze = ata_sff_freeze,
49 .thaw = ata_sff_thaw, 50 .thaw = ata_sff_thaw,
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 37482d4e883f..e880b7ec060f 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -464,6 +464,20 @@ static unsigned int sata_fsl_qc_issue(struct ata_queued_cmd *qc)
464 return 0; 464 return 0;
465} 465}
466 466
467static bool sata_fsl_qc_fill_rtf(struct ata_queued_cmd *qc)
468{
469 struct sata_fsl_port_priv *pp = qc->ap->private_data;
470 struct sata_fsl_host_priv *host_priv = qc->ap->host->private_data;
471 void __iomem *hcr_base = host_priv->hcr_base;
472 unsigned int tag = sata_fsl_tag(qc->tag, hcr_base);
473 struct command_desc *cd;
474
475 cd = pp->cmdentry + tag;
476
477 ata_tf_from_fis(cd->sfis, &qc->result_tf);
478 return true;
479}
480
467static int sata_fsl_scr_write(struct ata_port *ap, unsigned int sc_reg_in, 481static int sata_fsl_scr_write(struct ata_port *ap, unsigned int sc_reg_in,
468 u32 val) 482 u32 val)
469{ 483{
@@ -580,13 +594,6 @@ static u8 sata_fsl_check_status(struct ata_port *ap)
580 return pp->tf.command; 594 return pp->tf.command;
581} 595}
582 596
583static void sata_fsl_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
584{
585 struct sata_fsl_port_priv *pp = ap->private_data;
586
587 *tf = pp->tf;
588}
589
590static int sata_fsl_port_start(struct ata_port *ap) 597static int sata_fsl_port_start(struct ata_port *ap)
591{ 598{
592 struct device *dev = ap->host->dev; 599 struct device *dev = ap->host->dev;
@@ -1193,10 +1200,9 @@ static const struct ata_port_operations sata_fsl_ops = {
1193 .sff_check_status = sata_fsl_check_status, 1200 .sff_check_status = sata_fsl_check_status,
1194 .sff_check_altstatus = sata_fsl_check_status, 1201 .sff_check_altstatus = sata_fsl_check_status,
1195 1202
1196 .sff_tf_read = sata_fsl_tf_read,
1197
1198 .qc_prep = sata_fsl_qc_prep, 1203 .qc_prep = sata_fsl_qc_prep,
1199 .qc_issue = sata_fsl_qc_issue, 1204 .qc_issue = sata_fsl_qc_issue,
1205 .qc_fill_rtf = sata_fsl_qc_fill_rtf,
1200 1206
1201 .scr_read = sata_fsl_scr_read, 1207 .scr_read = sata_fsl_scr_read,
1202 .scr_write = sata_fsl_scr_write, 1208 .scr_write = sata_fsl_scr_write,
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 79952f825b40..51a7c06803df 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -344,7 +344,6 @@ static void sil24_dev_config(struct ata_device *dev);
344static u8 sil24_check_status(struct ata_port *ap); 344static u8 sil24_check_status(struct ata_port *ap);
345static int sil24_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val); 345static int sil24_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val);
346static int sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); 346static int sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val);
347static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
348static int sil24_qc_defer(struct ata_queued_cmd *qc); 347static int sil24_qc_defer(struct ata_queued_cmd *qc);
349static void sil24_qc_prep(struct ata_queued_cmd *qc); 348static void sil24_qc_prep(struct ata_queued_cmd *qc);
350static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc); 349static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc);
@@ -404,7 +403,6 @@ static struct ata_port_operations sil24_ops = {
404 403
405 .sff_check_status = sil24_check_status, 404 .sff_check_status = sil24_check_status,
406 .sff_check_altstatus = sil24_check_status, 405 .sff_check_altstatus = sil24_check_status,
407 .sff_tf_read = sil24_tf_read,
408 .qc_defer = sil24_qc_defer, 406 .qc_defer = sil24_qc_defer,
409 .qc_prep = sil24_qc_prep, 407 .qc_prep = sil24_qc_prep,
410 .qc_issue = sil24_qc_issue, 408 .qc_issue = sil24_qc_issue,
@@ -533,12 +531,6 @@ static int sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
533 return -EINVAL; 531 return -EINVAL;
534} 532}
535 533
536static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
537{
538 struct sil24_port_priv *pp = ap->private_data;
539 *tf = pp->tf;
540}
541
542static void sil24_config_port(struct ata_port *ap) 534static void sil24_config_port(struct ata_port *ap)
543{ 535{
544 void __iomem *port = ap->ioaddr.cmd_addr; 536 void __iomem *port = ap->ioaddr.cmd_addr;
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 2ecd32991522..b079f6c33711 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -5041,33 +5041,6 @@ static void ipr_ata_post_internal(struct ata_queued_cmd *qc)
5041} 5041}
5042 5042
5043/** 5043/**
5044 * ipr_tf_read - Read the current ATA taskfile for the ATA port
5045 * @ap: ATA port
5046 * @tf: destination ATA taskfile
5047 *
5048 * Return value:
5049 * none
5050 **/
5051static void ipr_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
5052{
5053 struct ipr_sata_port *sata_port = ap->private_data;
5054 struct ipr_ioasa_gata *g = &sata_port->ioasa;
5055
5056 tf->feature = g->error;
5057 tf->nsect = g->nsect;
5058 tf->lbal = g->lbal;
5059 tf->lbam = g->lbam;
5060 tf->lbah = g->lbah;
5061 tf->device = g->device;
5062 tf->command = g->status;
5063 tf->hob_nsect = g->hob_nsect;
5064 tf->hob_lbal = g->hob_lbal;
5065 tf->hob_lbam = g->hob_lbam;
5066 tf->hob_lbah = g->hob_lbah;
5067 tf->ctl = g->alt_status;
5068}
5069
5070/**
5071 * ipr_copy_sata_tf - Copy a SATA taskfile to an IOA data structure 5044 * ipr_copy_sata_tf - Copy a SATA taskfile to an IOA data structure
5072 * @regs: destination 5045 * @regs: destination
5073 * @tf: source ATA taskfile 5046 * @tf: source ATA taskfile
@@ -5245,6 +5218,35 @@ static unsigned int ipr_qc_issue(struct ata_queued_cmd *qc)
5245} 5218}
5246 5219
5247/** 5220/**
5221 * ipr_qc_fill_rtf - Read result TF
5222 * @qc: ATA queued command
5223 *
5224 * Return value:
5225 * true
5226 **/
5227static bool ipr_qc_fill_rtf(struct ata_queued_cmd *qc)
5228{
5229 struct ipr_sata_port *sata_port = qc->ap->private_data;
5230 struct ipr_ioasa_gata *g = &sata_port->ioasa;
5231 struct ata_taskfile *tf = &qc->result_tf;
5232
5233 tf->feature = g->error;
5234 tf->nsect = g->nsect;
5235 tf->lbal = g->lbal;
5236 tf->lbam = g->lbam;
5237 tf->lbah = g->lbah;
5238 tf->device = g->device;
5239 tf->command = g->status;
5240 tf->hob_nsect = g->hob_nsect;
5241 tf->hob_lbal = g->hob_lbal;
5242 tf->hob_lbam = g->hob_lbam;
5243 tf->hob_lbah = g->hob_lbah;
5244 tf->ctl = g->alt_status;
5245
5246 return true;
5247}
5248
5249/**
5248 * ipr_ata_check_status - Return last ATA status 5250 * ipr_ata_check_status - Return last ATA status
5249 * @ap: ATA port 5251 * @ap: ATA port
5250 * 5252 *
@@ -5277,10 +5279,9 @@ static struct ata_port_operations ipr_sata_ops = {
5277 .phy_reset = ipr_ata_phy_reset, 5279 .phy_reset = ipr_ata_phy_reset,
5278 .hardreset = ipr_sata_reset, 5280 .hardreset = ipr_sata_reset,
5279 .post_internal_cmd = ipr_ata_post_internal, 5281 .post_internal_cmd = ipr_ata_post_internal,
5280 .sff_tf_read = ipr_tf_read,
5281 .qc_prep = ata_noop_qc_prep, 5282 .qc_prep = ata_noop_qc_prep,
5282 .qc_issue = ipr_qc_issue, 5283 .qc_issue = ipr_qc_issue,
5283 .qc_fill_rtf = ata_sff_qc_fill_rtf, 5284 .qc_fill_rtf = ipr_qc_fill_rtf,
5284 .port_start = ata_sas_port_start, 5285 .port_start = ata_sas_port_start,
5285 .port_stop = ata_sas_port_stop 5286 .port_stop = ata_sas_port_stop
5286}; 5287};
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 2ec255839dcd..e81f2fd8ba8b 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -225,6 +225,14 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
225 return 0; 225 return 0;
226} 226}
227 227
228static bool sas_ata_qc_fill_rtf(struct ata_queued_cmd *qc)
229{
230 struct domain_device *dev = qc->ap->private_data;
231
232 memcpy(&qc->result_tf, &dev->sata_dev.tf, sizeof(qc->result_tf));
233 return true;
234}
235
228static u8 sas_ata_check_status(struct ata_port *ap) 236static u8 sas_ata_check_status(struct ata_port *ap)
229{ 237{
230 struct domain_device *dev = ap->private_data; 238 struct domain_device *dev = ap->private_data;
@@ -292,12 +300,6 @@ static void sas_ata_post_internal(struct ata_queued_cmd *qc)
292 } 300 }
293} 301}
294 302
295static void sas_ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
296{
297 struct domain_device *dev = ap->private_data;
298 memcpy(tf, &dev->sata_dev.tf, sizeof (*tf));
299}
300
301static int sas_ata_scr_write(struct ata_port *ap, unsigned int sc_reg_in, 303static int sas_ata_scr_write(struct ata_port *ap, unsigned int sc_reg_in,
302 u32 val) 304 u32 val)
303{ 305{
@@ -353,10 +355,9 @@ static struct ata_port_operations sas_sata_ops = {
353 .sff_dev_select = ata_noop_dev_select, 355 .sff_dev_select = ata_noop_dev_select,
354 .phy_reset = sas_ata_phy_reset, 356 .phy_reset = sas_ata_phy_reset,
355 .post_internal_cmd = sas_ata_post_internal, 357 .post_internal_cmd = sas_ata_post_internal,
356 .sff_tf_read = sas_ata_tf_read,
357 .qc_prep = ata_noop_qc_prep, 358 .qc_prep = ata_noop_qc_prep,
358 .qc_issue = sas_ata_qc_issue, 359 .qc_issue = sas_ata_qc_issue,
359 .qc_fill_rtf = ata_sff_qc_fill_rtf, 360 .qc_fill_rtf = sas_ata_qc_fill_rtf,
360 .port_start = ata_sas_port_start, 361 .port_start = ata_sas_port_start,
361 .port_stop = ata_sas_port_stop, 362 .port_stop = ata_sas_port_stop,
362 .scr_read = sas_ata_scr_read, 363 .scr_read = sas_ata_scr_read,