aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/ata/sata_rcar.txt11
-rw-r--r--drivers/ata/ahci_sunxi.c16
-rw-r--r--drivers/ata/libata-core.c20
-rw-r--r--drivers/ata/libata-eh.c7
-rw-r--r--drivers/ata/libata-scsi.c31
-rw-r--r--drivers/ata/libata-transport.c1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_task.c10
-rw-r--r--drivers/scsi/isci/request.c4
-rw-r--r--drivers/scsi/libsas/sas_ata.c66
-rw-r--r--drivers/scsi/mvsas/mv_sas.c4
-rw-r--r--drivers/scsi/pm8001/pm8001_hwi.c2
-rw-r--r--drivers/scsi/pm8001/pm80xx_hwi.c2
-rw-r--r--include/linux/libata.h6
-rw-r--r--include/scsi/libsas.h11
14 files changed, 98 insertions, 93 deletions
diff --git a/Documentation/devicetree/bindings/ata/sata_rcar.txt b/Documentation/devicetree/bindings/ata/sata_rcar.txt
index 80ae87a0784b..2493a5a31655 100644
--- a/Documentation/devicetree/bindings/ata/sata_rcar.txt
+++ b/Documentation/devicetree/bindings/ata/sata_rcar.txt
@@ -3,18 +3,21 @@
3Required properties: 3Required properties:
4- compatible : should contain one of the following: 4- compatible : should contain one of the following:
5 - "renesas,sata-r8a7779" for R-Car H1 5 - "renesas,sata-r8a7779" for R-Car H1
6 ("renesas,rcar-sata" is deprecated)
6 - "renesas,sata-r8a7790-es1" for R-Car H2 ES1 7 - "renesas,sata-r8a7790-es1" for R-Car H2 ES1
7 - "renesas,sata-r8a7790" for R-Car H2 other than ES1 8 - "renesas,sata-r8a7790" for R-Car H2 other than ES1
8 - "renesas,sata-r8a7791" for R-Car M2-W 9 - "renesas,sata-r8a7791" for R-Car M2-W
9 - "renesas,sata-r8a7793" for R-Car M2-N 10 - "renesas,sata-r8a7793" for R-Car M2-N
10- reg : address and length of the SATA registers; 11- reg : address and length of the SATA registers;
11- interrupts : must consist of one interrupt specifier. 12- interrupts : must consist of one interrupt specifier.
13- clocks : must contain a reference to the functional clock.
12 14
13Example: 15Example:
14 16
15sata: sata@fc600000 { 17sata0: sata@ee300000 {
16 compatible = "renesas,sata-r8a7779"; 18 compatible = "renesas,sata-r8a7791";
17 reg = <0xfc600000 0x2000>; 19 reg = <0 0xee300000 0 0x2000>;
18 interrupt-parent = <&gic>; 20 interrupt-parent = <&gic>;
19 interrupts = <0 100 IRQ_TYPE_LEVEL_HIGH>; 21 interrupts = <0 105 IRQ_TYPE_LEVEL_HIGH>;
22 clocks = <&mstp8_clks R8A7791_CLK_SATA0>;
20}; 23};
diff --git a/drivers/ata/ahci_sunxi.c b/drivers/ata/ahci_sunxi.c
index e44d675a30ec..b5aedca5ea3c 100644
--- a/drivers/ata/ahci_sunxi.c
+++ b/drivers/ata/ahci_sunxi.c
@@ -27,6 +27,12 @@
27#include <linux/regulator/consumer.h> 27#include <linux/regulator/consumer.h>
28#include "ahci.h" 28#include "ahci.h"
29 29
30/* Insmod parameters */
31static bool enable_pmp;
32module_param(enable_pmp, bool, 0);
33MODULE_PARM_DESC(enable_pmp,
34 "Enable support for sata port multipliers, only use if you use a pmp!");
35
30#define AHCI_BISTAFR 0x00a0 36#define AHCI_BISTAFR 0x00a0
31#define AHCI_BISTCR 0x00a4 37#define AHCI_BISTCR 0x00a4
32#define AHCI_BISTFCTR 0x00a8 38#define AHCI_BISTFCTR 0x00a8
@@ -184,7 +190,15 @@ static int ahci_sunxi_probe(struct platform_device *pdev)
184 goto disable_resources; 190 goto disable_resources;
185 191
186 hpriv->flags = AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI | 192 hpriv->flags = AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI |
187 AHCI_HFLAG_NO_PMP | AHCI_HFLAG_YES_NCQ; 193 AHCI_HFLAG_YES_NCQ;
194
195 /*
196 * The sunxi sata controller seems to be unable to successfully do a
197 * soft reset if no pmp is attached, so disable pmp use unless
198 * requested, otherwise directly attached disks do not work.
199 */
200 if (!enable_pmp)
201 hpriv->flags |= AHCI_HFLAG_NO_PMP;
188 202
189 rc = ahci_platform_init_host(pdev, hpriv, &ahci_sunxi_port_info); 203 rc = ahci_platform_init_host(pdev, hpriv, &ahci_sunxi_port_info);
190 if (rc) 204 if (rc)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index c5ba15af87d3..5c84fb5c3372 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1043,8 +1043,8 @@ const char *sata_spd_string(unsigned int spd)
1043 * None. 1043 * None.
1044 * 1044 *
1045 * RETURNS: 1045 * RETURNS:
1046 * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP or 1046 * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP,
1047 * %ATA_DEV_UNKNOWN the event of failure. 1047 * %ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure.
1048 */ 1048 */
1049unsigned int ata_dev_classify(const struct ata_taskfile *tf) 1049unsigned int ata_dev_classify(const struct ata_taskfile *tf)
1050{ 1050{
@@ -1089,6 +1089,11 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf)
1089 return ATA_DEV_SEMB; 1089 return ATA_DEV_SEMB;
1090 } 1090 }
1091 1091
1092 if ((tf->lbam == 0xcd) && (tf->lbah == 0xab)) {
1093 DPRINTK("found ZAC device by sig\n");
1094 return ATA_DEV_ZAC;
1095 }
1096
1092 DPRINTK("unknown device\n"); 1097 DPRINTK("unknown device\n");
1093 return ATA_DEV_UNKNOWN; 1098 return ATA_DEV_UNKNOWN;
1094} 1099}
@@ -1329,7 +1334,7 @@ static int ata_hpa_resize(struct ata_device *dev)
1329 int rc; 1334 int rc;
1330 1335
1331 /* do we need to do it? */ 1336 /* do we need to do it? */
1332 if (dev->class != ATA_DEV_ATA || 1337 if ((dev->class != ATA_DEV_ATA && dev->class != ATA_DEV_ZAC) ||
1333 !ata_id_has_lba(dev->id) || !ata_id_hpa_enabled(dev->id) || 1338 !ata_id_has_lba(dev->id) || !ata_id_hpa_enabled(dev->id) ||
1334 (dev->horkage & ATA_HORKAGE_BROKEN_HPA)) 1339 (dev->horkage & ATA_HORKAGE_BROKEN_HPA))
1335 return 0; 1340 return 0;
@@ -1889,6 +1894,7 @@ retry:
1889 case ATA_DEV_SEMB: 1894 case ATA_DEV_SEMB:
1890 class = ATA_DEV_ATA; /* some hard drives report SEMB sig */ 1895 class = ATA_DEV_ATA; /* some hard drives report SEMB sig */
1891 case ATA_DEV_ATA: 1896 case ATA_DEV_ATA:
1897 case ATA_DEV_ZAC:
1892 tf.command = ATA_CMD_ID_ATA; 1898 tf.command = ATA_CMD_ID_ATA;
1893 break; 1899 break;
1894 case ATA_DEV_ATAPI: 1900 case ATA_DEV_ATAPI:
@@ -1980,7 +1986,7 @@ retry:
1980 rc = -EINVAL; 1986 rc = -EINVAL;
1981 reason = "device reports invalid type"; 1987 reason = "device reports invalid type";
1982 1988
1983 if (class == ATA_DEV_ATA) { 1989 if (class == ATA_DEV_ATA || class == ATA_DEV_ZAC) {
1984 if (!ata_id_is_ata(id) && !ata_id_is_cfa(id)) 1990 if (!ata_id_is_ata(id) && !ata_id_is_cfa(id))
1985 goto err_out; 1991 goto err_out;
1986 if (ap->host->flags & ATA_HOST_IGNORE_ATA && 1992 if (ap->host->flags & ATA_HOST_IGNORE_ATA &&
@@ -2015,7 +2021,8 @@ retry:
2015 goto retry; 2021 goto retry;
2016 } 2022 }
2017 2023
2018 if ((flags & ATA_READID_POSTRESET) && class == ATA_DEV_ATA) { 2024 if ((flags & ATA_READID_POSTRESET) &&
2025 (class == ATA_DEV_ATA || class == ATA_DEV_ZAC)) {
2019 /* 2026 /*
2020 * The exact sequence expected by certain pre-ATA4 drives is: 2027 * The exact sequence expected by certain pre-ATA4 drives is:
2021 * SRST RESET 2028 * SRST RESET
@@ -2280,7 +2287,7 @@ int ata_dev_configure(struct ata_device *dev)
2280 sizeof(modelbuf)); 2287 sizeof(modelbuf));
2281 2288
2282 /* ATA-specific feature tests */ 2289 /* ATA-specific feature tests */
2283 if (dev->class == ATA_DEV_ATA) { 2290 if (dev->class == ATA_DEV_ATA || dev->class == ATA_DEV_ZAC) {
2284 if (ata_id_is_cfa(id)) { 2291 if (ata_id_is_cfa(id)) {
2285 /* CPRM may make this media unusable */ 2292 /* CPRM may make this media unusable */
2286 if (id[ATA_ID_CFA_KEY_MGMT] & 1) 2293 if (id[ATA_ID_CFA_KEY_MGMT] & 1)
@@ -4033,6 +4040,7 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
4033 if (ata_class_enabled(new_class) && 4040 if (ata_class_enabled(new_class) &&
4034 new_class != ATA_DEV_ATA && 4041 new_class != ATA_DEV_ATA &&
4035 new_class != ATA_DEV_ATAPI && 4042 new_class != ATA_DEV_ATAPI &&
4043 new_class != ATA_DEV_ZAC &&
4036 new_class != ATA_DEV_SEMB) { 4044 new_class != ATA_DEV_SEMB) {
4037 ata_dev_info(dev, "class mismatch %u != %u\n", 4045 ata_dev_info(dev, "class mismatch %u != %u\n",
4038 dev->class, new_class); 4046 dev->class, new_class);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index dad83df555c4..3dbec8954c86 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1809,6 +1809,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
1809 1809
1810 switch (qc->dev->class) { 1810 switch (qc->dev->class) {
1811 case ATA_DEV_ATA: 1811 case ATA_DEV_ATA:
1812 case ATA_DEV_ZAC:
1812 if (err & ATA_ICRC) 1813 if (err & ATA_ICRC)
1813 qc->err_mask |= AC_ERR_ATA_BUS; 1814 qc->err_mask |= AC_ERR_ATA_BUS;
1814 if (err & (ATA_UNC | ATA_AMNF)) 1815 if (err & (ATA_UNC | ATA_AMNF))
@@ -3792,7 +3793,8 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
3792 struct ata_eh_context *ehc = &link->eh_context; 3793 struct ata_eh_context *ehc = &link->eh_context;
3793 unsigned long tmp; 3794 unsigned long tmp;
3794 3795
3795 if (dev->class != ATA_DEV_ATA) 3796 if (dev->class != ATA_DEV_ATA &&
3797 dev->class != ATA_DEV_ZAC)
3796 continue; 3798 continue;
3797 if (!(ehc->i.dev_action[dev->devno] & 3799 if (!(ehc->i.dev_action[dev->devno] &
3798 ATA_EH_PARK)) 3800 ATA_EH_PARK))
@@ -3873,7 +3875,8 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
3873 3875
3874 /* retry flush if necessary */ 3876 /* retry flush if necessary */
3875 ata_for_each_dev(dev, link, ALL) { 3877 ata_for_each_dev(dev, link, ALL) {
3876 if (dev->class != ATA_DEV_ATA) 3878 if (dev->class != ATA_DEV_ATA &&
3879 dev->class != ATA_DEV_ZAC)
3877 continue; 3880 continue;
3878 rc = ata_eh_maybe_retry_flush(dev); 3881 rc = ata_eh_maybe_retry_flush(dev);
3879 if (rc) 3882 if (rc)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index dd45c6a03e5d..e364e86e84d7 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -235,7 +235,8 @@ static ssize_t ata_scsi_park_store(struct device *device,
235 rc = -ENODEV; 235 rc = -ENODEV;
236 goto unlock; 236 goto unlock;
237 } 237 }
238 if (dev->class != ATA_DEV_ATA) { 238 if (dev->class != ATA_DEV_ATA &&
239 dev->class != ATA_DEV_ZAC) {
239 rc = -EOPNOTSUPP; 240 rc = -EOPNOTSUPP;
240 goto unlock; 241 goto unlock;
241 } 242 }
@@ -1961,6 +1962,7 @@ static void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1961static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf) 1962static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
1962{ 1963{
1963 const u8 versions[] = { 1964 const u8 versions[] = {
1965 0x00,
1964 0x60, /* SAM-3 (no version claimed) */ 1966 0x60, /* SAM-3 (no version claimed) */
1965 1967
1966 0x03, 1968 0x03,
@@ -1969,6 +1971,20 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
1969 0x02, 1971 0x02,
1970 0x60 /* SPC-3 (no version claimed) */ 1972 0x60 /* SPC-3 (no version claimed) */
1971 }; 1973 };
1974 const u8 versions_zbc[] = {
1975 0x00,
1976 0xA0, /* SAM-5 (no version claimed) */
1977
1978 0x04,
1979 0xC0, /* SBC-3 (no version claimed) */
1980
1981 0x04,
1982 0x60, /* SPC-4 (no version claimed) */
1983
1984 0x60,
1985 0x20, /* ZBC (no version claimed) */
1986 };
1987
1972 u8 hdr[] = { 1988 u8 hdr[] = {
1973 TYPE_DISK, 1989 TYPE_DISK,
1974 0, 1990 0,
@@ -1983,6 +1999,11 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
1983 if (ata_id_removeable(args->id)) 1999 if (ata_id_removeable(args->id))
1984 hdr[1] |= (1 << 7); 2000 hdr[1] |= (1 << 7);
1985 2001
2002 if (args->dev->class == ATA_DEV_ZAC) {
2003 hdr[0] = TYPE_ZBC;
2004 hdr[2] = 0x6; /* ZBC is defined in SPC-4 */
2005 }
2006
1986 memcpy(rbuf, hdr, sizeof(hdr)); 2007 memcpy(rbuf, hdr, sizeof(hdr));
1987 memcpy(&rbuf[8], "ATA ", 8); 2008 memcpy(&rbuf[8], "ATA ", 8);
1988 ata_id_string(args->id, &rbuf[16], ATA_ID_PROD, 16); 2009 ata_id_string(args->id, &rbuf[16], ATA_ID_PROD, 16);
@@ -1995,7 +2016,10 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
1995 if (rbuf[32] == 0 || rbuf[32] == ' ') 2016 if (rbuf[32] == 0 || rbuf[32] == ' ')
1996 memcpy(&rbuf[32], "n/a ", 4); 2017 memcpy(&rbuf[32], "n/a ", 4);
1997 2018
1998 memcpy(rbuf + 59, versions, sizeof(versions)); 2019 if (args->dev->class == ATA_DEV_ZAC)
2020 memcpy(rbuf + 58, versions_zbc, sizeof(versions_zbc));
2021 else
2022 memcpy(rbuf + 58, versions, sizeof(versions));
1999 2023
2000 return 0; 2024 return 0;
2001} 2025}
@@ -2564,7 +2588,6 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2564 2588
2565 DPRINTK("ATAPI request sense\n"); 2589 DPRINTK("ATAPI request sense\n");
2566 2590
2567 /* FIXME: is this needed? */
2568 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 2591 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
2569 2592
2570#ifdef CONFIG_ATA_SFF 2593#ifdef CONFIG_ATA_SFF
@@ -3405,7 +3428,7 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd,
3405 ata_xlat_func_t xlat_func; 3428 ata_xlat_func_t xlat_func;
3406 int rc = 0; 3429 int rc = 0;
3407 3430
3408 if (dev->class == ATA_DEV_ATA) { 3431 if (dev->class == ATA_DEV_ATA || dev->class == ATA_DEV_ZAC) {
3409 if (unlikely(!scmd->cmd_len || scmd->cmd_len > dev->cdb_len)) 3432 if (unlikely(!scmd->cmd_len || scmd->cmd_len > dev->cdb_len))
3410 goto bad_cdb_len; 3433 goto bad_cdb_len;
3411 3434
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index e37413228228..3227b7c8a05f 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -143,6 +143,7 @@ static struct {
143 { ATA_DEV_PMP_UNSUP, "pmp" }, 143 { ATA_DEV_PMP_UNSUP, "pmp" },
144 { ATA_DEV_SEMB, "semb" }, 144 { ATA_DEV_SEMB, "semb" },
145 { ATA_DEV_SEMB_UNSUP, "semb" }, 145 { ATA_DEV_SEMB_UNSUP, "semb" },
146 { ATA_DEV_ZAC, "zac" },
146 { ATA_DEV_NONE, "none" } 147 { ATA_DEV_NONE, "none" }
147}; 148};
148ata_bitfield_name_search(class, ata_class_names) 149ata_bitfield_name_search(class, ata_class_names)
diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
index 5ff1ce7ba1f4..cdd4ab683be9 100644
--- a/drivers/scsi/aic94xx/aic94xx_task.c
+++ b/drivers/scsi/aic94xx/aic94xx_task.c
@@ -373,10 +373,10 @@ static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
373 373
374 if (unlikely(task->ata_task.device_control_reg_update)) 374 if (unlikely(task->ata_task.device_control_reg_update))
375 scb->header.opcode = CONTROL_ATA_DEV; 375 scb->header.opcode = CONTROL_ATA_DEV;
376 else if (dev->sata_dev.command_set == ATA_COMMAND_SET) 376 else if (dev->sata_dev.class == ATA_DEV_ATAPI)
377 scb->header.opcode = INITIATE_ATA_TASK;
378 else
379 scb->header.opcode = INITIATE_ATAPI_TASK; 377 scb->header.opcode = INITIATE_ATAPI_TASK;
378 else
379 scb->header.opcode = INITIATE_ATA_TASK;
380 380
381 scb->ata_task.proto_conn_rate = (1 << 5); /* STP */ 381 scb->ata_task.proto_conn_rate = (1 << 5); /* STP */
382 if (dev->port->oob_mode == SAS_OOB_MODE) 382 if (dev->port->oob_mode == SAS_OOB_MODE)
@@ -387,7 +387,7 @@ static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
387 if (likely(!task->ata_task.device_control_reg_update)) 387 if (likely(!task->ata_task.device_control_reg_update))
388 scb->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */ 388 scb->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
389 scb->ata_task.fis.flags &= 0xF0; /* PM_PORT field shall be 0 */ 389 scb->ata_task.fis.flags &= 0xF0; /* PM_PORT field shall be 0 */
390 if (dev->sata_dev.command_set == ATAPI_COMMAND_SET) 390 if (dev->sata_dev.class == ATA_DEV_ATAPI)
391 memcpy(scb->ata_task.atapi_packet, task->ata_task.atapi_packet, 391 memcpy(scb->ata_task.atapi_packet, task->ata_task.atapi_packet,
392 16); 392 16);
393 scb->ata_task.sister_scb = cpu_to_le16(0xFFFF); 393 scb->ata_task.sister_scb = cpu_to_le16(0xFFFF);
@@ -399,7 +399,7 @@ static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
399 if (task->ata_task.dma_xfer) 399 if (task->ata_task.dma_xfer)
400 flags |= DATA_XFER_MODE_DMA; 400 flags |= DATA_XFER_MODE_DMA;
401 if (task->ata_task.use_ncq && 401 if (task->ata_task.use_ncq &&
402 dev->sata_dev.command_set != ATAPI_COMMAND_SET) 402 dev->sata_dev.class != ATA_DEV_ATAPI)
403 flags |= ATA_Q_TYPE_NCQ; 403 flags |= ATA_Q_TYPE_NCQ;
404 flags |= data_dir_flags[task->data_dir]; 404 flags |= data_dir_flags[task->data_dir];
405 scb->ata_task.ata_flags = flags; 405 scb->ata_task.ata_flags = flags;
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 56e38096f0c4..cfd0084f1cd2 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -694,7 +694,7 @@ sci_io_request_construct_sata(struct isci_request *ireq,
694 } 694 }
695 695
696 /* ATAPI */ 696 /* ATAPI */
697 if (dev->sata_dev.command_set == ATAPI_COMMAND_SET && 697 if (dev->sata_dev.class == ATA_DEV_ATAPI &&
698 task->ata_task.fis.command == ATA_CMD_PACKET) { 698 task->ata_task.fis.command == ATA_CMD_PACKET) {
699 sci_atapi_construct(ireq); 699 sci_atapi_construct(ireq);
700 return SCI_SUCCESS; 700 return SCI_SUCCESS;
@@ -2980,7 +2980,7 @@ static void sci_request_started_state_enter(struct sci_base_state_machine *sm)
2980 state = SCI_REQ_SMP_WAIT_RESP; 2980 state = SCI_REQ_SMP_WAIT_RESP;
2981 } else if (task && sas_protocol_ata(task->task_proto) && 2981 } else if (task && sas_protocol_ata(task->task_proto) &&
2982 !task->ata_task.use_ncq) { 2982 !task->ata_task.use_ncq) {
2983 if (dev->sata_dev.command_set == ATAPI_COMMAND_SET && 2983 if (dev->sata_dev.class == ATA_DEV_ATAPI &&
2984 task->ata_task.fis.command == ATA_CMD_PACKET) { 2984 task->ata_task.fis.command == ATA_CMD_PACKET) {
2985 state = SCI_REQ_ATAPI_WAIT_H2D; 2985 state = SCI_REQ_ATAPI_WAIT_H2D;
2986 } else if (task->data_dir == DMA_NONE) { 2986 } else if (task->data_dir == DMA_NONE) {
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 577770fdee86..932d9cc98d2f 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -138,7 +138,7 @@ static void sas_ata_task_done(struct sas_task *task)
138 138
139 if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_STAT_GOOD || 139 if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_STAT_GOOD ||
140 ((stat->stat == SAM_STAT_CHECK_CONDITION && 140 ((stat->stat == SAM_STAT_CHECK_CONDITION &&
141 dev->sata_dev.command_set == ATAPI_COMMAND_SET))) { 141 dev->sata_dev.class == ATA_DEV_ATAPI))) {
142 memcpy(dev->sata_dev.fis, resp->ending_fis, ATA_RESP_FIS_SIZE); 142 memcpy(dev->sata_dev.fis, resp->ending_fis, ATA_RESP_FIS_SIZE);
143 143
144 if (!link->sactive) { 144 if (!link->sactive) {
@@ -272,7 +272,7 @@ static struct sas_internal *dev_to_sas_internal(struct domain_device *dev)
272 return to_sas_internal(dev->port->ha->core.shost->transportt); 272 return to_sas_internal(dev->port->ha->core.shost->transportt);
273} 273}
274 274
275static void sas_get_ata_command_set(struct domain_device *dev); 275static int sas_get_ata_command_set(struct domain_device *dev);
276 276
277int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy) 277int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy)
278{ 278{
@@ -297,8 +297,7 @@ int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy)
297 } 297 }
298 memcpy(dev->frame_rcvd, &dev->sata_dev.rps_resp.rps.fis, 298 memcpy(dev->frame_rcvd, &dev->sata_dev.rps_resp.rps.fis,
299 sizeof(struct dev_to_host_fis)); 299 sizeof(struct dev_to_host_fis));
300 /* TODO switch to ata_dev_classify() */ 300 dev->sata_dev.class = sas_get_ata_command_set(dev);
301 sas_get_ata_command_set(dev);
302 } 301 }
303 return 0; 302 return 0;
304} 303}
@@ -419,18 +418,7 @@ static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,
419 if (ret && ret != -EAGAIN) 418 if (ret && ret != -EAGAIN)
420 sas_ata_printk(KERN_ERR, dev, "reset failed (errno=%d)\n", ret); 419 sas_ata_printk(KERN_ERR, dev, "reset failed (errno=%d)\n", ret);
421 420
422 /* XXX: if the class changes during the reset the upper layer 421 *class = dev->sata_dev.class;
423 * should be informed, if the device has gone away we assume
424 * libsas will eventually delete it
425 */
426 switch (dev->sata_dev.command_set) {
427 case ATA_COMMAND_SET:
428 *class = ATA_DEV_ATA;
429 break;
430 case ATAPI_COMMAND_SET:
431 *class = ATA_DEV_ATAPI;
432 break;
433 }
434 422
435 ap->cbl = ATA_CBL_SATA; 423 ap->cbl = ATA_CBL_SATA;
436 return ret; 424 return ret;
@@ -619,50 +607,18 @@ void sas_ata_task_abort(struct sas_task *task)
619 complete(waiting); 607 complete(waiting);
620} 608}
621 609
622static void sas_get_ata_command_set(struct domain_device *dev) 610static int sas_get_ata_command_set(struct domain_device *dev)
623{ 611{
624 struct dev_to_host_fis *fis = 612 struct dev_to_host_fis *fis =
625 (struct dev_to_host_fis *) dev->frame_rcvd; 613 (struct dev_to_host_fis *) dev->frame_rcvd;
614 struct ata_taskfile tf;
626 615
627 if (dev->dev_type == SAS_SATA_PENDING) 616 if (dev->dev_type == SAS_SATA_PENDING)
628 return; 617 return ATA_DEV_UNKNOWN;
618
619 ata_tf_from_fis((const u8 *)fis, &tf);
629 620
630 if ((fis->sector_count == 1 && /* ATA */ 621 return ata_dev_classify(&tf);
631 fis->lbal == 1 &&
632 fis->lbam == 0 &&
633 fis->lbah == 0 &&
634 fis->device == 0)
635 ||
636 (fis->sector_count == 0 && /* CE-ATA (mATA) */
637 fis->lbal == 0 &&
638 fis->lbam == 0xCE &&
639 fis->lbah == 0xAA &&
640 (fis->device & ~0x10) == 0))
641
642 dev->sata_dev.command_set = ATA_COMMAND_SET;
643
644 else if ((fis->interrupt_reason == 1 && /* ATAPI */
645 fis->lbal == 1 &&
646 fis->byte_count_low == 0x14 &&
647 fis->byte_count_high == 0xEB &&
648 (fis->device & ~0x10) == 0))
649
650 dev->sata_dev.command_set = ATAPI_COMMAND_SET;
651
652 else if ((fis->sector_count == 1 && /* SEMB */
653 fis->lbal == 1 &&
654 fis->lbam == 0x3C &&
655 fis->lbah == 0xC3 &&
656 fis->device == 0)
657 ||
658 (fis->interrupt_reason == 1 && /* SATA PM */
659 fis->lbal == 1 &&
660 fis->byte_count_low == 0x69 &&
661 fis->byte_count_high == 0x96 &&
662 (fis->device & ~0x10) == 0))
663
664 /* Treat it as a superset? */
665 dev->sata_dev.command_set = ATAPI_COMMAND_SET;
666} 622}
667 623
668void sas_probe_sata(struct asd_sas_port *port) 624void sas_probe_sata(struct asd_sas_port *port)
@@ -768,7 +724,7 @@ int sas_discover_sata(struct domain_device *dev)
768 if (dev->dev_type == SAS_SATA_PM) 724 if (dev->dev_type == SAS_SATA_PM)
769 return -ENODEV; 725 return -ENODEV;
770 726
771 sas_get_ata_command_set(dev); 727 dev->sata_dev.class = sas_get_ata_command_set(dev);
772 sas_fill_in_rphy(dev, dev->rphy); 728 sas_fill_in_rphy(dev, dev->rphy);
773 729
774 res = sas_notify_lldd_dev_found(dev); 730 res = sas_notify_lldd_dev_found(dev);
diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index 85d86a5cdb60..2d5ab6d969ec 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -479,7 +479,7 @@ static int mvs_task_prep_ata(struct mvs_info *mvi,
479 479
480 if (task->ata_task.use_ncq) 480 if (task->ata_task.use_ncq)
481 flags |= MCH_FPDMA; 481 flags |= MCH_FPDMA;
482 if (dev->sata_dev.command_set == ATAPI_COMMAND_SET) { 482 if (dev->sata_dev.class == ATA_DEV_ATAPI) {
483 if (task->ata_task.fis.command != ATA_CMD_ID_ATAPI) 483 if (task->ata_task.fis.command != ATA_CMD_ID_ATAPI)
484 flags |= MCH_ATAPI; 484 flags |= MCH_ATAPI;
485 } 485 }
@@ -546,7 +546,7 @@ static int mvs_task_prep_ata(struct mvs_info *mvi,
546 task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */ 546 task->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
547 /* fill in command FIS and ATAPI CDB */ 547 /* fill in command FIS and ATAPI CDB */
548 memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis)); 548 memcpy(buf_cmd, &task->ata_task.fis, sizeof(struct host_to_dev_fis));
549 if (dev->sata_dev.command_set == ATAPI_COMMAND_SET) 549 if (dev->sata_dev.class == ATA_DEV_ATAPI)
550 memcpy(buf_cmd + STP_ATAPI_CMD, 550 memcpy(buf_cmd + STP_ATAPI_CMD,
551 task->ata_task.atapi_packet, 16); 551 task->ata_task.atapi_packet, 16);
552 552
diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 933f21471951..96dcc097a463 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -4367,7 +4367,7 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
4367 PM8001_IO_DBG(pm8001_ha, pm8001_printk("PIO\n")); 4367 PM8001_IO_DBG(pm8001_ha, pm8001_printk("PIO\n"));
4368 } 4368 }
4369 if (task->ata_task.use_ncq && 4369 if (task->ata_task.use_ncq &&
4370 dev->sata_dev.command_set != ATAPI_COMMAND_SET) { 4370 dev->sata_dev.class != ATA_DEV_ATAPI) {
4371 ATAP = 0x07; /* FPDMA */ 4371 ATAP = 0x07; /* FPDMA */
4372 PM8001_IO_DBG(pm8001_ha, pm8001_printk("FPDMA\n")); 4372 PM8001_IO_DBG(pm8001_ha, pm8001_printk("FPDMA\n"));
4373 } 4373 }
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index b06443a0db2d..05cce463ab01 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -4077,7 +4077,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
4077 PM8001_IO_DBG(pm8001_ha, pm8001_printk("PIO\n")); 4077 PM8001_IO_DBG(pm8001_ha, pm8001_printk("PIO\n"));
4078 } 4078 }
4079 if (task->ata_task.use_ncq && 4079 if (task->ata_task.use_ncq &&
4080 dev->sata_dev.command_set != ATAPI_COMMAND_SET) { 4080 dev->sata_dev.class != ATA_DEV_ATAPI) {
4081 ATAP = 0x07; /* FPDMA */ 4081 ATAP = 0x07; /* FPDMA */
4082 PM8001_IO_DBG(pm8001_ha, pm8001_printk("FPDMA\n")); 4082 PM8001_IO_DBG(pm8001_ha, pm8001_printk("FPDMA\n"));
4083 } 4083 }
diff --git a/include/linux/libata.h b/include/linux/libata.h
index bfbc817c34ee..2d182413b1db 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -191,7 +191,8 @@ enum {
191 ATA_DEV_PMP_UNSUP = 6, /* SATA port multiplier (unsupported) */ 191 ATA_DEV_PMP_UNSUP = 6, /* SATA port multiplier (unsupported) */
192 ATA_DEV_SEMB = 7, /* SEMB */ 192 ATA_DEV_SEMB = 7, /* SEMB */
193 ATA_DEV_SEMB_UNSUP = 8, /* SEMB (unsupported) */ 193 ATA_DEV_SEMB_UNSUP = 8, /* SEMB (unsupported) */
194 ATA_DEV_NONE = 9, /* no device */ 194 ATA_DEV_ZAC = 9, /* ZAC device */
195 ATA_DEV_NONE = 10, /* no device */
195 196
196 /* struct ata_link flags */ 197 /* struct ata_link flags */
197 ATA_LFLAG_NO_HRST = (1 << 1), /* avoid hardreset */ 198 ATA_LFLAG_NO_HRST = (1 << 1), /* avoid hardreset */
@@ -1491,7 +1492,8 @@ static inline unsigned int ata_tag_internal(unsigned int tag)
1491static inline unsigned int ata_class_enabled(unsigned int class) 1492static inline unsigned int ata_class_enabled(unsigned int class)
1492{ 1493{
1493 return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI || 1494 return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI ||
1494 class == ATA_DEV_PMP || class == ATA_DEV_SEMB; 1495 class == ATA_DEV_PMP || class == ATA_DEV_SEMB ||
1496 class == ATA_DEV_ZAC;
1495} 1497}
1496 1498
1497static inline unsigned int ata_class_disabled(unsigned int class) 1499static inline unsigned int ata_class_disabled(unsigned int class)
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 832dcc9f86ec..9d87a37aecad 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -161,17 +161,12 @@ struct expander_device {
161}; 161};
162 162
163/* ---------- SATA device ---------- */ 163/* ---------- SATA device ---------- */
164enum ata_command_set {
165 ATA_COMMAND_SET = 0,
166 ATAPI_COMMAND_SET = 1,
167};
168
169#define ATA_RESP_FIS_SIZE 24 164#define ATA_RESP_FIS_SIZE 24
170 165
171struct sata_device { 166struct sata_device {
172 enum ata_command_set command_set; 167 unsigned int class;
173 struct smp_resp rps_resp; /* report_phy_sata_resp */ 168 struct smp_resp rps_resp; /* report_phy_sata_resp */
174 u8 port_no; /* port number, if this is a PM (Port) */ 169 u8 port_no; /* port number, if this is a PM (Port) */
175 170
176 struct ata_port *ap; 171 struct ata_port *ap;
177 struct ata_host ata_host; 172 struct ata_host ata_host;