aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 17:39:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 17:39:40 -0400
commit75a442efb1ca613f8d1cc71a32c2c9b0aefae4a5 (patch)
tree6161c21803db3f03bcbd26715761e2d310246bb8
parentb55b048718c8c833186c87ceeea86b78346cda2e (diff)
parent737bee9308c457090711684b976e0fe02785a094 (diff)
Merge branch 'for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata updates from Tejun Heo: "libata saw quite a bit of activities in this cycle: - SMR drive support still being worked on - bug fixes and improvements to misc SCSI command emulation - some low level driver updates" * 'for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (39 commits) libata-scsi: better style in ata_msense_*() AHCI: Clear GHC.IS to prevent unexpectly asserting INTx ata: sata_dwc_460ex: remove redundant dev_err call ata: define ATA_PROT_* in terms of ATA_PROT_FLAG_* libata: remove ATA_PROT_FLAG_DATA libata: remove ata_is_nodata ata: make lba_{28,48}_ok() use ATA_MAX_SECTORS{,_LBA48} libata-scsi: minor cleanup for ata_scsi_zbc_out_xlat libata-scsi: Fix ZBC management out command translation libata-scsi: Fix translation of REPORT ZONES command ata: Handle ATA NCQ NO-DATA commands correctly libata-eh: decode all taskfile protocols ata: fixup ATA_PROT_NODATA libsas: use ata_is_ncq() and ata_has_dma() accessors libata: use ata_is_ncq() accessors libata: return boolean values from ata_is_* libata-scsi: avoid repeated calculation of number of TRIM ranges libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit libata-scsi: rename ata_msense_ctl_mode() to ata_msense_control() libata-scsi: fix D_SENSE bit relection in control mode page ...
-rw-r--r--Documentation/devicetree/bindings/ata/brcm,sata-brcm.txt (renamed from Documentation/devicetree/bindings/ata/brcm,sata-brcmstb.txt)9
-rw-r--r--Documentation/devicetree/bindings/phy/brcm-sata-phy.txt4
-rw-r--r--MAINTAINERS1
-rw-r--r--arch/arm/boot/dts/bcm-nsp.dtsi42
-rw-r--r--arch/arm/boot/dts/bcm958625k.dts12
-rw-r--r--drivers/ata/Kconfig8
-rw-r--r--drivers/ata/Makefile2
-rw-r--r--drivers/ata/ahci.c2
-rw-r--r--drivers/ata/ahci_brcm.c (renamed from drivers/ata/ahci_brcmstb.c)46
-rw-r--r--drivers/ata/libahci.c10
-rw-r--r--drivers/ata/libata-core.c14
-rw-r--r--drivers/ata/libata-eh.c8
-rw-r--r--drivers/ata/libata-scsi.c82
-rw-r--r--drivers/ata/libata-transport.c9
-rw-r--r--drivers/ata/pata_arasan_cf.c2
-rw-r--r--drivers/ata/pata_atiixp.c4
-rw-r--r--drivers/ata/pata_hpt366.c2
-rw-r--r--drivers/ata/pata_marvell.c2
-rw-r--r--drivers/ata/sata_dwc_460ex.c14
-rw-r--r--drivers/phy/phy-brcm-sata.c81
-rw-r--r--drivers/scsi/libsas/sas_ata.c11
-rw-r--r--include/linux/ata.h41
-rw-r--r--include/linux/libata.h60
-rw-r--r--include/trace/events/libata.h1
24 files changed, 314 insertions, 153 deletions
diff --git a/Documentation/devicetree/bindings/ata/brcm,sata-brcmstb.txt b/Documentation/devicetree/bindings/ata/brcm,sata-brcm.txt
index 60872838f1ad..0a5b3b47f217 100644
--- a/Documentation/devicetree/bindings/ata/brcm,sata-brcmstb.txt
+++ b/Documentation/devicetree/bindings/ata/brcm,sata-brcm.txt
@@ -1,13 +1,14 @@
1* Broadcom SATA3 AHCI Controller for STB 1* Broadcom SATA3 AHCI Controller
2 2
3SATA nodes are defined to describe on-chip Serial ATA controllers. 3SATA nodes are defined to describe on-chip Serial ATA controllers.
4Each SATA controller should have its own node. 4Each SATA controller should have its own node.
5 5
6Required properties: 6Required properties:
7- compatible : should be one or more of 7- compatible : should be one or more of
8 "brcm,bcm7425-ahci" 8 "brcm,bcm7425-ahci"
9 "brcm,bcm7445-ahci" 9 "brcm,bcm7445-ahci"
10 "brcm,sata3-ahci" 10 "brcm,bcm-nsp-ahci"
11 "brcm,sata3-ahci"
11- reg : register mappings for AHCI and SATA_TOP_CTRL 12- reg : register mappings for AHCI and SATA_TOP_CTRL
12- reg-names : "ahci" and "top-ctrl" 13- reg-names : "ahci" and "top-ctrl"
13- interrupts : interrupt mapping for SATA IRQ 14- interrupts : interrupt mapping for SATA IRQ
diff --git a/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt b/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
index d0231209d846..6ccce09d8bbf 100644
--- a/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
+++ b/Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
@@ -5,6 +5,7 @@ Required properties:
5 "brcm,bcm7425-sata-phy" 5 "brcm,bcm7425-sata-phy"
6 "brcm,bcm7445-sata-phy" 6 "brcm,bcm7445-sata-phy"
7 "brcm,iproc-ns2-sata-phy" 7 "brcm,iproc-ns2-sata-phy"
8 "brcm,iproc-nsp-sata-phy"
8 "brcm,phy-sata3" 9 "brcm,phy-sata3"
9- address-cells: should be 1 10- address-cells: should be 1
10- size-cells: should be 0 11- size-cells: should be 0
@@ -22,7 +23,8 @@ Sub-nodes required properties:
22 23
23Sub-nodes optional properties: 24Sub-nodes optional properties:
24- brcm,enable-ssc: use spread spectrum clocking (SSC) on this port 25- brcm,enable-ssc: use spread spectrum clocking (SSC) on this port
25 This property is not applicable for "brcm,iproc-ns2-sata-phy". 26 This property is not applicable for "brcm,iproc-ns2-sata-phy" and
27 "brcm,iproc-nsp-sata-phy".
26 28
27Example: 29Example:
28 sata-phy@f0458100 { 30 sata-phy@f0458100 {
diff --git a/MAINTAINERS b/MAINTAINERS
index 531c600b8b93..9987f8491c55 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6768,6 +6768,7 @@ S: Maintained
6768F: drivers/ata/ 6768F: drivers/ata/
6769F: include/linux/ata.h 6769F: include/linux/ata.h
6770F: include/linux/libata.h 6770F: include/linux/libata.h
6771F: Documentation/devicetree/bindings/ata/
6771 6772
6772LIBATA PATA ARASAN COMPACT FLASH CONTROLLER 6773LIBATA PATA ARASAN COMPACT FLASH CONTROLLER
6773M: Viresh Kumar <vireshk@kernel.org> 6774M: Viresh Kumar <vireshk@kernel.org>
diff --git a/arch/arm/boot/dts/bcm-nsp.dtsi b/arch/arm/boot/dts/bcm-nsp.dtsi
index 1ed829e699d4..6a40ed7d0502 100644
--- a/arch/arm/boot/dts/bcm-nsp.dtsi
+++ b/arch/arm/boot/dts/bcm-nsp.dtsi
@@ -271,6 +271,48 @@
271 <0x30028 0x04>, 271 <0x30028 0x04>,
272 <0x3f408 0x04>; 272 <0x3f408 0x04>;
273 }; 273 };
274
275 sata_phy: sata_phy@40100 {
276 compatible = "brcm,iproc-nsp-sata-phy";
277 reg = <0x40100 0x340>;
278 reg-names = "phy";
279 #address-cells = <1>;
280 #size-cells = <0>;
281
282 sata_phy0: sata-phy@0 {
283 reg = <0>;
284 #phy-cells = <0>;
285 status = "disabled";
286 };
287
288 sata_phy1: sata-phy@1 {
289 reg = <1>;
290 #phy-cells = <0>;
291 status = "disabled";
292 };
293 };
294
295 sata: ahci@41000 {
296 compatible = "brcm,bcm-nsp-ahci";
297 reg-names = "ahci", "top-ctrl";
298 reg = <0x41000 0x1000>, <0x40020 0x1c>;
299 interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
300 #address-cells = <1>;
301 #size-cells = <0>;
302 status = "disabled";
303
304 sata0: sata-port@0 {
305 reg = <0>;
306 phys = <&sata_phy0>;
307 phy-names = "sata-phy";
308 };
309
310 sata1: sata-port@1 {
311 reg = <1>;
312 phys = <&sata_phy1>;
313 phy-names = "sata-phy";
314 };
315 };
274 }; 316 };
275 317
276 pcie0: pcie@18012000 { 318 pcie0: pcie@18012000 {
diff --git a/arch/arm/boot/dts/bcm958625k.dts b/arch/arm/boot/dts/bcm958625k.dts
index e298450b49b2..2d8422632b2b 100644
--- a/arch/arm/boot/dts/bcm958625k.dts
+++ b/arch/arm/boot/dts/bcm958625k.dts
@@ -68,6 +68,18 @@
68 status = "okay"; 68 status = "okay";
69}; 69};
70 70
71&sata_phy0 {
72 status = "okay";
73};
74
75&sata_phy1 {
76 status = "okay";
77};
78
79&sata {
80 status = "okay";
81};
82
71&nand { 83&nand {
72 nandcs@0 { 84 nandcs@0 {
73 compatible = "brcm,nandcs"; 85 compatible = "brcm,nandcs";
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index e2dc4c045146..2c8be74f401d 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -98,12 +98,12 @@ config SATA_AHCI_PLATFORM
98 98
99 If unsure, say N. 99 If unsure, say N.
100 100
101config AHCI_BRCMSTB 101config AHCI_BRCM
102 tristate "Broadcom STB AHCI SATA support" 102 tristate "Broadcom AHCI SATA support"
103 depends on ARCH_BRCMSTB || BMIPS_GENERIC 103 depends on ARCH_BRCMSTB || BMIPS_GENERIC || ARCH_BCM_NSP
104 help 104 help
105 This option enables support for the AHCI SATA3 controller found on 105 This option enables support for the AHCI SATA3 controller found on
106 STB SoC's. 106 Broadcom SoC's.
107 107
108 If unsure, say N. 108 If unsure, say N.
109 109
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 0b2afb7e5f35..a46e6b784bda 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -11,7 +11,7 @@ obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o
11obj-$(CONFIG_SATA_SIL24) += sata_sil24.o 11obj-$(CONFIG_SATA_SIL24) += sata_sil24.o
12obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o 12obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o
13obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o 13obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o
14obj-$(CONFIG_AHCI_BRCMSTB) += ahci_brcmstb.o libahci.o libahci_platform.o 14obj-$(CONFIG_AHCI_BRCM) += ahci_brcm.o libahci.o libahci_platform.o
15obj-$(CONFIG_AHCI_CEVA) += ahci_ceva.o libahci.o libahci_platform.o 15obj-$(CONFIG_AHCI_CEVA) += ahci_ceva.o libahci.o libahci_platform.o
16obj-$(CONFIG_AHCI_DA850) += ahci_da850.o libahci.o libahci_platform.o 16obj-$(CONFIG_AHCI_DA850) += ahci_da850.o libahci.o libahci_platform.o
17obj-$(CONFIG_AHCI_IMX) += ahci_imx.o libahci.o libahci_platform.o 17obj-$(CONFIG_AHCI_IMX) += ahci_imx.o libahci.o libahci_platform.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index a83bbcc58b4c..90eabaf81215 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -580,7 +580,7 @@ static struct pci_driver ahci_pci_driver = {
580 }, 580 },
581}; 581};
582 582
583#if defined(CONFIG_PATA_MARVELL) || defined(CONFIG_PATA_MARVELL_MODULE) 583#if IS_ENABLED(CONFIG_PATA_MARVELL)
584static int marvell_enable; 584static int marvell_enable;
585#else 585#else
586static int marvell_enable = 1; 586static int marvell_enable = 1;
diff --git a/drivers/ata/ahci_brcmstb.c b/drivers/ata/ahci_brcm.c
index e87bcec0fd7c..6f8a7341fa08 100644
--- a/drivers/ata/ahci_brcmstb.c
+++ b/drivers/ata/ahci_brcm.c
@@ -71,6 +71,12 @@
71 (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \ 71 (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \
72 (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT)) 72 (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT))
73 73
74enum brcm_ahci_version {
75 BRCM_SATA_BCM7425 = 1,
76 BRCM_SATA_BCM7445,
77 BRCM_SATA_NSP,
78};
79
74enum brcm_ahci_quirks { 80enum brcm_ahci_quirks {
75 BRCM_AHCI_QUIRK_NO_NCQ = BIT(0), 81 BRCM_AHCI_QUIRK_NO_NCQ = BIT(0),
76 BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1), 82 BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1),
@@ -81,6 +87,7 @@ struct brcm_ahci_priv {
81 void __iomem *top_ctrl; 87 void __iomem *top_ctrl;
82 u32 port_mask; 88 u32 port_mask;
83 u32 quirks; 89 u32 quirks;
90 enum brcm_ahci_version version;
84}; 91};
85 92
86static const struct ata_port_info ahci_brcm_port_info = { 93static const struct ata_port_info ahci_brcm_port_info = {
@@ -247,9 +254,19 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev,
247 254
248static void brcm_sata_init(struct brcm_ahci_priv *priv) 255static void brcm_sata_init(struct brcm_ahci_priv *priv)
249{ 256{
257 void __iomem *ctrl = priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL;
258
250 /* Configure endianness */ 259 /* Configure endianness */
251 brcm_sata_writereg(BUS_CTRL_ENDIAN_CONF, 260 if (priv->version == BRCM_SATA_NSP) {
252 priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL); 261 u32 data = brcm_sata_readreg(ctrl);
262
263 data &= ~((0x03 << DMADATA_ENDIAN_SHIFT) |
264 (0x03 << DMADESC_ENDIAN_SHIFT));
265 data |= (0x02 << DMADATA_ENDIAN_SHIFT) |
266 (0x02 << DMADESC_ENDIAN_SHIFT);
267 brcm_sata_writereg(data, ctrl);
268 } else
269 brcm_sata_writereg(BUS_CTRL_ENDIAN_CONF, ctrl);
253} 270}
254 271
255#ifdef CONFIG_PM_SLEEP 272#ifdef CONFIG_PM_SLEEP
@@ -282,8 +299,17 @@ static struct scsi_host_template ahci_platform_sht = {
282 AHCI_SHT(DRV_NAME), 299 AHCI_SHT(DRV_NAME),
283}; 300};
284 301
302static const struct of_device_id ahci_of_match[] = {
303 {.compatible = "brcm,bcm7425-ahci", .data = (void *)BRCM_SATA_BCM7425},
304 {.compatible = "brcm,bcm7445-ahci", .data = (void *)BRCM_SATA_BCM7445},
305 {.compatible = "brcm,bcm-nsp-ahci", .data = (void *)BRCM_SATA_NSP},
306 {},
307};
308MODULE_DEVICE_TABLE(of, ahci_of_match);
309
285static int brcm_ahci_probe(struct platform_device *pdev) 310static int brcm_ahci_probe(struct platform_device *pdev)
286{ 311{
312 const struct of_device_id *of_id;
287 struct device *dev = &pdev->dev; 313 struct device *dev = &pdev->dev;
288 struct brcm_ahci_priv *priv; 314 struct brcm_ahci_priv *priv;
289 struct ahci_host_priv *hpriv; 315 struct ahci_host_priv *hpriv;
@@ -293,6 +319,12 @@ static int brcm_ahci_probe(struct platform_device *pdev)
293 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 319 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
294 if (!priv) 320 if (!priv)
295 return -ENOMEM; 321 return -ENOMEM;
322
323 of_id = of_match_node(ahci_of_match, pdev->dev.of_node);
324 if (!of_id)
325 return -ENODEV;
326
327 priv->version = (enum brcm_ahci_version)of_id->data;
296 priv->dev = dev; 328 priv->dev = dev;
297 329
298 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "top-ctrl"); 330 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "top-ctrl");
@@ -300,7 +332,8 @@ static int brcm_ahci_probe(struct platform_device *pdev)
300 if (IS_ERR(priv->top_ctrl)) 332 if (IS_ERR(priv->top_ctrl))
301 return PTR_ERR(priv->top_ctrl); 333 return PTR_ERR(priv->top_ctrl);
302 334
303 if (of_device_is_compatible(dev->of_node, "brcm,bcm7425-ahci")) { 335 if ((priv->version == BRCM_SATA_BCM7425) ||
336 (priv->version == BRCM_SATA_NSP)) {
304 priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ; 337 priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ;
305 priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE; 338 priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE;
306 } 339 }
@@ -354,13 +387,6 @@ static int brcm_ahci_remove(struct platform_device *pdev)
354 return 0; 387 return 0;
355} 388}
356 389
357static const struct of_device_id ahci_of_match[] = {
358 {.compatible = "brcm,bcm7425-ahci"},
359 {.compatible = "brcm,bcm7445-ahci"},
360 {},
361};
362MODULE_DEVICE_TABLE(of, ahci_of_match);
363
364static SIMPLE_DEV_PM_OPS(ahci_brcm_pm_ops, brcm_ahci_suspend, brcm_ahci_resume); 390static SIMPLE_DEV_PM_OPS(ahci_brcm_pm_ops, brcm_ahci_suspend, brcm_ahci_resume);
365 391
366static struct platform_driver brcm_ahci_driver = { 392static struct platform_driver brcm_ahci_driver = {
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 71b07198e207..7461a587b39b 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1975,7 +1975,7 @@ unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
1975 */ 1975 */
1976 pp->active_link = qc->dev->link; 1976 pp->active_link = qc->dev->link;
1977 1977
1978 if (qc->tf.protocol == ATA_PROT_NCQ) 1978 if (ata_is_ncq(qc->tf.protocol))
1979 writel(1 << qc->tag, port_mmio + PORT_SCR_ACT); 1979 writel(1 << qc->tag, port_mmio + PORT_SCR_ACT);
1980 1980
1981 if (pp->fbs_enabled && pp->fbs_last_dev != qc->dev->link->pmp) { 1981 if (pp->fbs_enabled && pp->fbs_last_dev != qc->dev->link->pmp) {
@@ -2392,12 +2392,20 @@ static int ahci_port_start(struct ata_port *ap)
2392static void ahci_port_stop(struct ata_port *ap) 2392static void ahci_port_stop(struct ata_port *ap)
2393{ 2393{
2394 const char *emsg = NULL; 2394 const char *emsg = NULL;
2395 struct ahci_host_priv *hpriv = ap->host->private_data;
2396 void __iomem *host_mmio = hpriv->mmio;
2395 int rc; 2397 int rc;
2396 2398
2397 /* de-initialize port */ 2399 /* de-initialize port */
2398 rc = ahci_deinit_port(ap, &emsg); 2400 rc = ahci_deinit_port(ap, &emsg);
2399 if (rc) 2401 if (rc)
2400 ata_port_warn(ap, "%s (%d)\n", emsg, rc); 2402 ata_port_warn(ap, "%s (%d)\n", emsg, rc);
2403
2404 /*
2405 * Clear GHC.IS to prevent stuck INTx after disabling MSI and
2406 * re-enabling INTx.
2407 */
2408 writel(1 << ap->port_no, host_mmio + HOST_IRQ_STAT);
2401} 2409}
2402 2410
2403void ahci_print_info(struct ata_host *host, const char *scc_s) 2411void ahci_print_info(struct ata_host *host, const char *scc_s)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 31c183aed368..67339b4f92f1 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1238,7 +1238,7 @@ static int ata_read_native_max_address(struct ata_device *dev, u64 *max_sectors)
1238 } else 1238 } else
1239 tf.command = ATA_CMD_READ_NATIVE_MAX; 1239 tf.command = ATA_CMD_READ_NATIVE_MAX;
1240 1240
1241 tf.protocol |= ATA_PROT_NODATA; 1241 tf.protocol = ATA_PROT_NODATA;
1242 tf.device |= ATA_LBA; 1242 tf.device |= ATA_LBA;
1243 1243
1244 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 1244 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
@@ -1297,7 +1297,7 @@ static int ata_set_max_sectors(struct ata_device *dev, u64 new_sectors)
1297 tf.device |= (new_sectors >> 24) & 0xf; 1297 tf.device |= (new_sectors >> 24) & 0xf;
1298 } 1298 }
1299 1299
1300 tf.protocol |= ATA_PROT_NODATA; 1300 tf.protocol = ATA_PROT_NODATA;
1301 tf.device |= ATA_LBA; 1301 tf.device |= ATA_LBA;
1302 1302
1303 tf.lbal = (new_sectors >> 0) & 0xff; 1303 tf.lbal = (new_sectors >> 0) & 0xff;
@@ -4848,7 +4848,7 @@ int ata_std_qc_defer(struct ata_queued_cmd *qc)
4848{ 4848{
4849 struct ata_link *link = qc->dev->link; 4849 struct ata_link *link = qc->dev->link;
4850 4850
4851 if (qc->tf.protocol == ATA_PROT_NCQ) { 4851 if (ata_is_ncq(qc->tf.protocol)) {
4852 if (!ata_tag_valid(link->active_tag)) 4852 if (!ata_tag_valid(link->active_tag))
4853 return 0; 4853 return 0;
4854 } else { 4854 } else {
@@ -5013,7 +5013,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
5013 ata_sg_clean(qc); 5013 ata_sg_clean(qc);
5014 5014
5015 /* command should be marked inactive atomically with qc completion */ 5015 /* command should be marked inactive atomically with qc completion */
5016 if (qc->tf.protocol == ATA_PROT_NCQ) { 5016 if (ata_is_ncq(qc->tf.protocol)) {
5017 link->sactive &= ~(1 << qc->tag); 5017 link->sactive &= ~(1 << qc->tag);
5018 if (!link->sactive) 5018 if (!link->sactive)
5019 ap->nr_active_links--; 5019 ap->nr_active_links--;
@@ -5050,7 +5050,7 @@ static void ata_verify_xfer(struct ata_queued_cmd *qc)
5050{ 5050{
5051 struct ata_device *dev = qc->dev; 5051 struct ata_device *dev = qc->dev;
5052 5052
5053 if (ata_is_nodata(qc->tf.protocol)) 5053 if (!ata_is_data(qc->tf.protocol))
5054 return; 5054 return;
5055 5055
5056 if ((dev->mwdma_mask || dev->udma_mask) && ata_is_pio(qc->tf.protocol)) 5056 if ((dev->mwdma_mask || dev->udma_mask) && ata_is_pio(qc->tf.protocol))
@@ -5133,7 +5133,9 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
5133 switch (qc->tf.command) { 5133 switch (qc->tf.command) {
5134 case ATA_CMD_SET_FEATURES: 5134 case ATA_CMD_SET_FEATURES:
5135 if (qc->tf.feature != SETFEATURES_WC_ON && 5135 if (qc->tf.feature != SETFEATURES_WC_ON &&
5136 qc->tf.feature != SETFEATURES_WC_OFF) 5136 qc->tf.feature != SETFEATURES_WC_OFF &&
5137 qc->tf.feature != SETFEATURES_RA_ON &&
5138 qc->tf.feature != SETFEATURES_RA_OFF)
5137 break; 5139 break;
5138 /* fall through */ 5140 /* fall through */
5139 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ 5141 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index c6f017458958..0e1ec37070d1 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2607,9 +2607,13 @@ static void ata_eh_link_report(struct ata_link *link)
2607 [DMA_FROM_DEVICE] = "in", 2607 [DMA_FROM_DEVICE] = "in",
2608 }; 2608 };
2609 static const char *prot_str[] = { 2609 static const char *prot_str[] = {
2610 [ATA_PROT_UNKNOWN] = "unknown",
2611 [ATA_PROT_NODATA] = "nodata",
2610 [ATA_PROT_PIO] = "pio", 2612 [ATA_PROT_PIO] = "pio",
2611 [ATA_PROT_DMA] = "dma", 2613 [ATA_PROT_DMA] = "dma",
2612 [ATA_PROT_NCQ] = "ncq", 2614 [ATA_PROT_NCQ] = "ncq dma",
2615 [ATA_PROT_NCQ_NODATA] = "ncq nodata",
2616 [ATAPI_PROT_NODATA] = "nodata",
2613 [ATAPI_PROT_PIO] = "pio", 2617 [ATAPI_PROT_PIO] = "pio",
2614 [ATAPI_PROT_DMA] = "dma", 2618 [ATAPI_PROT_DMA] = "dma",
2615 }; 2619 };
@@ -3177,7 +3181,7 @@ static void ata_eh_park_issue_cmd(struct ata_device *dev, int park)
3177 } 3181 }
3178 3182
3179 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; 3183 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR;
3180 tf.protocol |= ATA_PROT_NODATA; 3184 tf.protocol = ATA_PROT_NODATA;
3181 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); 3185 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
3182 if (park && (err_mask || tf.lbal != 0xc4)) { 3186 if (park && (err_mask || tf.lbal != 0xc4)) {
3183 ata_dev_err(dev, "head unload failed!\n"); 3187 ata_dev_err(dev, "head unload failed!\n");
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bfec66fb26e2..2bdb5dab922b 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -304,7 +304,7 @@ static void ata_scsi_set_invalid_field(struct ata_device *dev,
304 struct scsi_cmnd *cmd, u16 field, u8 bit) 304 struct scsi_cmnd *cmd, u16 field, u8 bit)
305{ 305{
306 ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x24, 0x0); 306 ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x24, 0x0);
307 /* "Invalid field in cbd" */ 307 /* "Invalid field in CDB" */
308 scsi_set_sense_field_pointer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE, 308 scsi_set_sense_field_pointer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
309 field, bit, 1); 309 field, bit, 1);
310} 310}
@@ -2075,8 +2075,8 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
2075 0x03, 2075 0x03,
2076 0x20, /* SBC-2 (no version claimed) */ 2076 0x20, /* SBC-2 (no version claimed) */
2077 2077
2078 0x02, 2078 0x03,
2079 0x60 /* SPC-3 (no version claimed) */ 2079 0x00 /* SPC-3 (no version claimed) */
2080 }; 2080 };
2081 const u8 versions_zbc[] = { 2081 const u8 versions_zbc[] = {
2082 0x00, 2082 0x00,
@@ -2097,7 +2097,10 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
2097 0, 2097 0,
2098 0x5, /* claim SPC-3 version compatibility */ 2098 0x5, /* claim SPC-3 version compatibility */
2099 2, 2099 2,
2100 95 - 4 2100 95 - 4,
2101 0,
2102 0,
2103 2
2101 }; 2104 };
2102 2105
2103 VPRINTK("ENTER\n"); 2106 VPRINTK("ENTER\n");
@@ -2109,8 +2112,10 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
2109 (args->dev->link->ap->pflags & ATA_PFLAG_EXTERNAL)) 2112 (args->dev->link->ap->pflags & ATA_PFLAG_EXTERNAL))
2110 hdr[1] |= (1 << 7); 2113 hdr[1] |= (1 << 7);
2111 2114
2112 if (args->dev->class == ATA_DEV_ZAC) 2115 if (args->dev->class == ATA_DEV_ZAC) {
2113 hdr[0] = TYPE_ZBC; 2116 hdr[0] = TYPE_ZBC;
2117 hdr[2] = 0x7; /* claim SPC-5 version compatibility */
2118 }
2114 2119
2115 memcpy(rbuf, hdr, sizeof(hdr)); 2120 memcpy(rbuf, hdr, sizeof(hdr));
2116 memcpy(&rbuf[8], "ATA ", 8); 2121 memcpy(&rbuf[8], "ATA ", 8);
@@ -2314,7 +2319,7 @@ static unsigned int ata_scsiop_inq_b0(struct ata_scsi_args *args, u8 *rbuf)
2314 * with the unmap bit set. 2319 * with the unmap bit set.
2315 */ 2320 */
2316 if (ata_id_has_trim(args->id)) { 2321 if (ata_id_has_trim(args->id)) {
2317 put_unaligned_be64(65535 * 512 / 8, &rbuf[36]); 2322 put_unaligned_be64(65535 * ATA_MAX_TRIM_RNUM, &rbuf[36]);
2318 put_unaligned_be32(1, &rbuf[28]); 2323 put_unaligned_be32(1, &rbuf[28]);
2319 } 2324 }
2320 2325
@@ -2424,15 +2429,17 @@ static void modecpy(u8 *dest, const u8 *src, int n, bool changeable)
2424static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable) 2429static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
2425{ 2430{
2426 modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable); 2431 modecpy(buf, def_cache_mpage, sizeof(def_cache_mpage), changeable);
2427 if (changeable || ata_id_wcache_enabled(id)) 2432 if (changeable) {
2428 buf[2] |= (1 << 2); /* write cache enable */ 2433 buf[2] |= (1 << 2); /* ata_mselect_caching() */
2429 if (!changeable && !ata_id_rahead_enabled(id)) 2434 } else {
2430 buf[12] |= (1 << 5); /* disable read ahead */ 2435 buf[2] |= (ata_id_wcache_enabled(id) << 2); /* write cache enable */
2436 buf[12] |= (!ata_id_rahead_enabled(id) << 5); /* disable read ahead */
2437 }
2431 return sizeof(def_cache_mpage); 2438 return sizeof(def_cache_mpage);
2432} 2439}
2433 2440
2434/** 2441/**
2435 * ata_msense_ctl_mode - Simulate MODE SENSE control mode page 2442 * ata_msense_control - Simulate MODE SENSE control mode page
2436 * @dev: ATA device of interest 2443 * @dev: ATA device of interest
2437 * @buf: output buffer 2444 * @buf: output buffer
2438 * @changeable: whether changeable parameters are requested 2445 * @changeable: whether changeable parameters are requested
@@ -2442,12 +2449,17 @@ static unsigned int ata_msense_caching(u16 *id, u8 *buf, bool changeable)
2442 * LOCKING: 2449 * LOCKING:
2443 * None. 2450 * None.
2444 */ 2451 */
2445static unsigned int ata_msense_ctl_mode(struct ata_device *dev, u8 *buf, 2452static unsigned int ata_msense_control(struct ata_device *dev, u8 *buf,
2446 bool changeable) 2453 bool changeable)
2447{ 2454{
2448 modecpy(buf, def_control_mpage, sizeof(def_control_mpage), changeable); 2455 modecpy(buf, def_control_mpage, sizeof(def_control_mpage), changeable);
2449 if (changeable && (dev->flags & ATA_DFLAG_D_SENSE)) 2456 if (changeable) {
2450 buf[2] |= (1 << 2); /* Descriptor sense requested */ 2457 buf[2] |= (1 << 2); /* ata_mselect_control() */
2458 } else {
2459 bool d_sense = (dev->flags & ATA_DFLAG_D_SENSE);
2460
2461 buf[2] |= (d_sense << 2); /* descriptor format sense data */
2462 }
2451 return sizeof(def_control_mpage); 2463 return sizeof(def_control_mpage);
2452} 2464}
2453 2465
@@ -2566,13 +2578,13 @@ static unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf)
2566 break; 2578 break;
2567 2579
2568 case CONTROL_MPAGE: 2580 case CONTROL_MPAGE:
2569 p += ata_msense_ctl_mode(args->dev, p, page_control == 1); 2581 p += ata_msense_control(args->dev, p, page_control == 1);
2570 break; 2582 break;
2571 2583
2572 case ALL_MPAGES: 2584 case ALL_MPAGES:
2573 p += ata_msense_rw_recovery(p, page_control == 1); 2585 p += ata_msense_rw_recovery(p, page_control == 1);
2574 p += ata_msense_caching(args->id, p, page_control == 1); 2586 p += ata_msense_caching(args->id, p, page_control == 1);
2575 p += ata_msense_ctl_mode(args->dev, p, page_control == 1); 2587 p += ata_msense_control(args->dev, p, page_control == 1);
2576 break; 2588 break;
2577 2589
2578 default: /* invalid page code */ 2590 default: /* invalid page code */
@@ -3077,6 +3089,9 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
3077 goto invalid_fld; 3089 goto invalid_fld;
3078 } 3090 }
3079 3091
3092 if (ata_is_ncq(tf->protocol) && (cdb[2] & 0x3) == 0)
3093 tf->protocol = ATA_PROT_NCQ_NODATA;
3094
3080 /* enable LBA */ 3095 /* enable LBA */
3081 tf->flags |= ATA_TFLAG_LBA; 3096 tf->flags |= ATA_TFLAG_LBA;
3082 3097
@@ -3125,8 +3140,8 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
3125 tf->command = cdb[9]; 3140 tf->command = cdb[9];
3126 } 3141 }
3127 3142
3128 /* For NCQ commands with FPDMA protocol, copy the tag value */ 3143 /* For NCQ commands copy the tag value */
3129 if (tf->protocol == ATA_PROT_NCQ) 3144 if (ata_is_ncq(tf->protocol))
3130 tf->nsect = qc->tag << 3; 3145 tf->nsect = qc->tag << 3;
3131 3146
3132 /* enforce correct master/slave bit */ 3147 /* enforce correct master/slave bit */
@@ -3305,7 +3320,13 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
3305 goto invalid_param_len; 3320 goto invalid_param_len;
3306 3321
3307 buf = page_address(sg_page(scsi_sglist(scmd))); 3322 buf = page_address(sg_page(scsi_sglist(scmd)));
3308 size = ata_set_lba_range_entries(buf, 512, block, n_block); 3323
3324 if (n_block <= 65535 * ATA_MAX_TRIM_RNUM) {
3325 size = ata_set_lba_range_entries(buf, ATA_MAX_TRIM_RNUM, block, n_block);
3326 } else {
3327 fp = 2;
3328 goto invalid_fld;
3329 }
3309 3330
3310 if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) { 3331 if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
3311 /* Newer devices support queued TRIM commands */ 3332 /* Newer devices support queued TRIM commands */
@@ -3454,7 +3475,7 @@ static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc)
3454 goto invalid_param_len; 3475 goto invalid_param_len;
3455 } 3476 }
3456 sect = n_block / 512; 3477 sect = n_block / 512;
3457 options = cdb[14]; 3478 options = cdb[14] & 0xbf;
3458 3479
3459 if (ata_ncq_enabled(qc->dev) && 3480 if (ata_ncq_enabled(qc->dev) &&
3460 ata_fpdma_zac_mgmt_in_supported(qc->dev)) { 3481 ata_fpdma_zac_mgmt_in_supported(qc->dev)) {
@@ -3464,7 +3485,7 @@ static unsigned int ata_scsi_zbc_in_xlat(struct ata_queued_cmd *qc)
3464 tf->nsect = qc->tag << 3; 3485 tf->nsect = qc->tag << 3;
3465 tf->feature = sect & 0xff; 3486 tf->feature = sect & 0xff;
3466 tf->hob_feature = (sect >> 8) & 0xff; 3487 tf->hob_feature = (sect >> 8) & 0xff;
3467 tf->auxiliary = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES; 3488 tf->auxiliary = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES | (options << 8);
3468 } else { 3489 } else {
3469 tf->command = ATA_CMD_ZAC_MGMT_IN; 3490 tf->command = ATA_CMD_ZAC_MGMT_IN;
3470 tf->feature = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES; 3491 tf->feature = ATA_SUBCMD_ZAC_MGMT_IN_REPORT_ZONES;
@@ -3506,7 +3527,7 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
3506 struct scsi_cmnd *scmd = qc->scsicmd; 3527 struct scsi_cmnd *scmd = qc->scsicmd;
3507 struct ata_device *dev = qc->dev; 3528 struct ata_device *dev = qc->dev;
3508 const u8 *cdb = scmd->cmnd; 3529 const u8 *cdb = scmd->cmnd;
3509 u8 reset_all, sa; 3530 u8 all, sa;
3510 u64 block; 3531 u64 block;
3511 u32 n_block; 3532 u32 n_block;
3512 u16 fp = (u16)-1; 3533 u16 fp = (u16)-1;
@@ -3533,20 +3554,20 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
3533 if (block > dev->n_sectors) 3554 if (block > dev->n_sectors)
3534 goto out_of_range; 3555 goto out_of_range;
3535 3556
3536 reset_all = cdb[14] & 0x1; 3557 all = cdb[14] & 0x1;
3537 3558
3538 if (ata_ncq_enabled(qc->dev) && 3559 if (ata_ncq_enabled(qc->dev) &&
3539 ata_fpdma_zac_mgmt_out_supported(qc->dev)) { 3560 ata_fpdma_zac_mgmt_out_supported(qc->dev)) {
3540 tf->protocol = ATA_PROT_NCQ; 3561 tf->protocol = ATA_PROT_NCQ_NODATA;
3541 tf->command = ATA_CMD_NCQ_NON_DATA; 3562 tf->command = ATA_CMD_NCQ_NON_DATA;
3542 tf->hob_nsect = ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT; 3563 tf->feature = ATA_SUBCMD_NCQ_NON_DATA_ZAC_MGMT_OUT;
3543 tf->nsect = qc->tag << 3; 3564 tf->nsect = qc->tag << 3;
3544 tf->auxiliary = sa | (reset_all & 0x1) << 8; 3565 tf->auxiliary = sa | ((u16)all << 8);
3545 } else { 3566 } else {
3546 tf->protocol = ATA_PROT_NODATA; 3567 tf->protocol = ATA_PROT_NODATA;
3547 tf->command = ATA_CMD_ZAC_MGMT_OUT; 3568 tf->command = ATA_CMD_ZAC_MGMT_OUT;
3548 tf->feature = sa; 3569 tf->feature = sa;
3549 tf->hob_feature = reset_all & 0x1; 3570 tf->hob_feature = all;
3550 } 3571 }
3551 tf->lbah = (block >> 16) & 0xff; 3572 tf->lbah = (block >> 16) & 0xff;
3552 tf->lbam = (block >> 8) & 0xff; 3573 tf->lbam = (block >> 8) & 0xff;
@@ -3667,7 +3688,7 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
3667 /* 3688 /*
3668 * Check that read-only bits are not modified. 3689 * Check that read-only bits are not modified.
3669 */ 3690 */
3670 ata_msense_ctl_mode(dev, mpage, false); 3691 ata_msense_control(dev, mpage, false);
3671 for (i = 0; i < CONTROL_MPAGE_LEN - 2; i++) { 3692 for (i = 0; i < CONTROL_MPAGE_LEN - 2; i++) {
3672 if (i == 0) 3693 if (i == 0)
3673 continue; 3694 continue;
@@ -4039,11 +4060,6 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
4039 args.done = cmd->scsi_done; 4060 args.done = cmd->scsi_done;
4040 4061
4041 switch(scsicmd[0]) { 4062 switch(scsicmd[0]) {
4042 /* TODO: worth improving? */
4043 case FORMAT_UNIT:
4044 ata_scsi_invalid_field(dev, cmd, 0);
4045 break;
4046
4047 case INQUIRY: 4063 case INQUIRY:
4048 if (scsicmd[1] & 2) /* is CmdDt set? */ 4064 if (scsicmd[1] & 2) /* is CmdDt set? */
4049 ata_scsi_invalid_field(dev, cmd, 1); 4065 ata_scsi_invalid_field(dev, cmd, 1);
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index e2d94972962d..7ef16c085058 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -495,12 +495,13 @@ struct ata_show_ering_arg {
495static int ata_show_ering(struct ata_ering_entry *ent, void *void_arg) 495static int ata_show_ering(struct ata_ering_entry *ent, void *void_arg)
496{ 496{
497 struct ata_show_ering_arg* arg = void_arg; 497 struct ata_show_ering_arg* arg = void_arg;
498 struct timespec time; 498 u64 seconds;
499 u32 rem;
499 500
500 jiffies_to_timespec(ent->timestamp,&time); 501 seconds = div_u64_rem(ent->timestamp, HZ, &rem);
501 arg->written += sprintf(arg->buf + arg->written, 502 arg->written += sprintf(arg->buf + arg->written,
502 "[%5lu.%06lu]", 503 "[%5llu.%09lu]", seconds,
503 time.tv_sec, time.tv_nsec); 504 rem * NSEC_PER_SEC / HZ);
504 arg->written += get_ata_err_names(ent->err_mask, 505 arg->written += get_ata_err_names(ent->err_mask,
505 arg->buf + arg->written); 506 arg->buf + arg->written);
506 return 0; 507 return 0;
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index 80fe0f6fed29..b4d54771c9fe 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -565,7 +565,7 @@ chan_request_fail:
565 qc->ap->hsm_task_state = HSM_ST_ERR; 565 qc->ap->hsm_task_state = HSM_ST_ERR;
566 566
567 cf_ctrl_reset(acdev); 567 cf_ctrl_reset(acdev);
568 spin_unlock_irqrestore(qc->ap->lock, flags); 568 spin_unlock_irqrestore(&acdev->host->lock, flags);
569sff_intr: 569sff_intr:
570 dma_complete(acdev); 570 dma_complete(acdev);
571} 571}
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 970f7767e5fd..49d705c9f0f7 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -183,8 +183,8 @@ static void atiixp_set_dmamode(struct ata_port *ap, struct ata_device *adev)
183 * We must now look at the PIO mode situation. We may need to 183 * We must now look at the PIO mode situation. We may need to
184 * adjust the PIO mode to keep the timings acceptable 184 * adjust the PIO mode to keep the timings acceptable
185 */ 185 */
186 if (adev->dma_mode >= XFER_MW_DMA_2) 186 if (adev->dma_mode >= XFER_MW_DMA_2)
187 wanted_pio = 4; 187 wanted_pio = 4;
188 else if (adev->dma_mode == XFER_MW_DMA_1) 188 else if (adev->dma_mode == XFER_MW_DMA_1)
189 wanted_pio = 3; 189 wanted_pio = 3;
190 else if (adev->dma_mode == XFER_MW_DMA_0) 190 else if (adev->dma_mode == XFER_MW_DMA_0)
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index e5fb7525a5df..a219a503c229 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -368,7 +368,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
368 368
369 /* PCI clocking determines the ATA timing values to use */ 369 /* PCI clocking determines the ATA timing values to use */
370 /* info_hpt366 is safe against re-entry so we can scribble on it */ 370 /* info_hpt366 is safe against re-entry so we can scribble on it */
371 switch ((reg1 & 0x700) >> 8) { 371 switch ((reg1 & 0xf00) >> 8) {
372 case 9: 372 case 9:
373 hpriv = &hpt366_40; 373 hpriv = &hpt366_40;
374 break; 374 break;
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index ae9feb1ba8f7..ff468a6fd8dd 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -146,7 +146,7 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
146 if (pdev->device == 0x6101) 146 if (pdev->device == 0x6101)
147 ppi[1] = &ata_dummy_port_info; 147 ppi[1] = &ata_dummy_port_info;
148 148
149#if defined(CONFIG_SATA_AHCI) || defined(CONFIG_SATA_AHCI_MODULE) 149#if IS_ENABLED(CONFIG_SATA_AHCI)
150 if (!marvell_pata_active(pdev)) { 150 if (!marvell_pata_active(pdev)) {
151 printk(KERN_INFO DRV_NAME ": PATA port not active, deferring to AHCI driver.\n"); 151 printk(KERN_INFO DRV_NAME ": PATA port not active, deferring to AHCI driver.\n");
152 return -ENODEV; 152 return -ENODEV;
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 00c2af1d211b..e0939bd5ea73 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -259,11 +259,8 @@ static int sata_dwc_dma_init_old(struct platform_device *pdev,
259 /* Get physical SATA DMA register base address */ 259 /* Get physical SATA DMA register base address */
260 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 260 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
261 hsdev->dma->regs = devm_ioremap_resource(&pdev->dev, res); 261 hsdev->dma->regs = devm_ioremap_resource(&pdev->dev, res);
262 if (IS_ERR(hsdev->dma->regs)) { 262 if (IS_ERR(hsdev->dma->regs))
263 dev_err(&pdev->dev,
264 "ioremap failed for AHBDMA register address\n");
265 return PTR_ERR(hsdev->dma->regs); 263 return PTR_ERR(hsdev->dma->regs);
266 }
267 264
268 /* Initialize AHB DMAC */ 265 /* Initialize AHB DMAC */
269 return dw_dma_probe(hsdev->dma); 266 return dw_dma_probe(hsdev->dma);
@@ -281,7 +278,7 @@ static void sata_dwc_dma_exit_old(struct sata_dwc_device *hsdev)
281 278
282static const char *get_prot_descript(u8 protocol) 279static const char *get_prot_descript(u8 protocol)
283{ 280{
284 switch ((enum ata_tf_protocols)protocol) { 281 switch (protocol) {
285 case ATA_PROT_NODATA: 282 case ATA_PROT_NODATA:
286 return "ATA no data"; 283 return "ATA no data";
287 case ATA_PROT_PIO: 284 case ATA_PROT_PIO:
@@ -290,6 +287,8 @@ static const char *get_prot_descript(u8 protocol)
290 return "ATA DMA"; 287 return "ATA DMA";
291 case ATA_PROT_NCQ: 288 case ATA_PROT_NCQ:
292 return "ATA NCQ"; 289 return "ATA NCQ";
290 case ATA_PROT_NCQ_NODATA:
291 return "ATA NCQ no data";
293 case ATAPI_PROT_NODATA: 292 case ATAPI_PROT_NODATA:
294 return "ATAPI no data"; 293 return "ATAPI no data";
295 case ATAPI_PROT_PIO: 294 case ATAPI_PROT_PIO:
@@ -1225,11 +1224,8 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1225 /* Ioremap SATA registers */ 1224 /* Ioremap SATA registers */
1226 res = platform_get_resource(ofdev, IORESOURCE_MEM, 0); 1225 res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
1227 base = devm_ioremap_resource(&ofdev->dev, res); 1226 base = devm_ioremap_resource(&ofdev->dev, res);
1228 if (IS_ERR(base)) { 1227 if (IS_ERR(base))
1229 dev_err(&ofdev->dev,
1230 "ioremap failed for SATA register address\n");
1231 return PTR_ERR(base); 1228 return PTR_ERR(base);
1232 }
1233 dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n"); 1229 dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n");
1234 1230
1235 /* Synopsys DWC SATA specific Registers */ 1231 /* Synopsys DWC SATA specific Registers */
diff --git a/drivers/phy/phy-brcm-sata.c b/drivers/phy/phy-brcm-sata.c
index 6c4c5cb791ca..18d662610075 100644
--- a/drivers/phy/phy-brcm-sata.c
+++ b/drivers/phy/phy-brcm-sata.c
@@ -45,6 +45,7 @@ enum brcm_sata_phy_version {
45 BRCM_SATA_PHY_STB_28NM, 45 BRCM_SATA_PHY_STB_28NM,
46 BRCM_SATA_PHY_STB_40NM, 46 BRCM_SATA_PHY_STB_40NM,
47 BRCM_SATA_PHY_IPROC_NS2, 47 BRCM_SATA_PHY_IPROC_NS2,
48 BRCM_SATA_PHY_IPROC_NSP,
48}; 49};
49 50
50struct brcm_sata_port { 51struct brcm_sata_port {
@@ -73,6 +74,13 @@ enum sata_phy_regs {
73 74
74 PLL_REG_BANK_0 = 0x050, 75 PLL_REG_BANK_0 = 0x050,
75 PLL_REG_BANK_0_PLLCONTROL_0 = 0x81, 76 PLL_REG_BANK_0_PLLCONTROL_0 = 0x81,
77 PLLCONTROL_0_FREQ_DET_RESTART = BIT(13),
78 PLLCONTROL_0_FREQ_MONITOR = BIT(12),
79 PLLCONTROL_0_SEQ_START = BIT(15),
80 PLL_CAP_CONTROL = 0x85,
81 PLL_ACTRL2 = 0x8b,
82 PLL_ACTRL2_SELDIV_MASK = 0x1f,
83 PLL_ACTRL2_SELDIV_SHIFT = 9,
76 84
77 PLL1_REG_BANK = 0x060, 85 PLL1_REG_BANK = 0x060,
78 PLL1_ACTRL2 = 0x82, 86 PLL1_ACTRL2 = 0x82,
@@ -80,6 +88,7 @@ enum sata_phy_regs {
80 PLL1_ACTRL4 = 0x84, 88 PLL1_ACTRL4 = 0x84,
81 89
82 OOB_REG_BANK = 0x150, 90 OOB_REG_BANK = 0x150,
91 OOB1_REG_BANK = 0x160,
83 OOB_CTRL1 = 0x80, 92 OOB_CTRL1 = 0x80,
84 OOB_CTRL1_BURST_MAX_MASK = 0xf, 93 OOB_CTRL1_BURST_MAX_MASK = 0xf,
85 OOB_CTRL1_BURST_MAX_SHIFT = 12, 94 OOB_CTRL1_BURST_MAX_SHIFT = 12,
@@ -271,6 +280,73 @@ static int brcm_ns2_sata_init(struct brcm_sata_port *port)
271 return 0; 280 return 0;
272} 281}
273 282
283static int brcm_nsp_sata_init(struct brcm_sata_port *port)
284{
285 struct brcm_sata_phy *priv = port->phy_priv;
286 struct device *dev = port->phy_priv->dev;
287 void __iomem *base = priv->phy_base;
288 unsigned int oob_bank;
289 unsigned int val, try;
290
291 /* Configure OOB control */
292 if (port->portnum == 0)
293 oob_bank = OOB_REG_BANK;
294 else if (port->portnum == 1)
295 oob_bank = OOB1_REG_BANK;
296 else
297 return -EINVAL;
298
299 val = 0x0;
300 val |= (0x0f << OOB_CTRL1_BURST_MAX_SHIFT);
301 val |= (0x06 << OOB_CTRL1_BURST_MIN_SHIFT);
302 val |= (0x0f << OOB_CTRL1_WAKE_IDLE_MAX_SHIFT);
303 val |= (0x06 << OOB_CTRL1_WAKE_IDLE_MIN_SHIFT);
304 brcm_sata_phy_wr(base, oob_bank, OOB_CTRL1, 0x0, val);
305
306 val = 0x0;
307 val |= (0x2e << OOB_CTRL2_RESET_IDLE_MAX_SHIFT);
308 val |= (0x02 << OOB_CTRL2_BURST_CNT_SHIFT);
309 val |= (0x16 << OOB_CTRL2_RESET_IDLE_MIN_SHIFT);
310 brcm_sata_phy_wr(base, oob_bank, OOB_CTRL2, 0x0, val);
311
312
313 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_ACTRL2,
314 ~(PLL_ACTRL2_SELDIV_MASK << PLL_ACTRL2_SELDIV_SHIFT),
315 0x0c << PLL_ACTRL2_SELDIV_SHIFT);
316
317 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_CAP_CONTROL,
318 0xff0, 0x4f0);
319
320 val = PLLCONTROL_0_FREQ_DET_RESTART | PLLCONTROL_0_FREQ_MONITOR;
321 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_REG_BANK_0_PLLCONTROL_0,
322 ~val, val);
323 val = PLLCONTROL_0_SEQ_START;
324 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_REG_BANK_0_PLLCONTROL_0,
325 ~val, 0);
326 mdelay(10);
327 brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_REG_BANK_0_PLLCONTROL_0,
328 ~val, val);
329
330 /* Wait for pll_seq_done bit */
331 try = 50;
332 while (try--) {
333 val = brcm_sata_phy_rd(base, BLOCK0_REG_BANK,
334 BLOCK0_XGXSSTATUS);
335 if (val & BLOCK0_XGXSSTATUS_PLL_LOCK)
336 break;
337 msleep(20);
338 }
339 if (!try) {
340 /* PLL did not lock; give up */
341 dev_err(dev, "port%d PLL did not lock\n", port->portnum);
342 return -ETIMEDOUT;
343 }
344
345 dev_dbg(dev, "port%d initialized\n", port->portnum);
346
347 return 0;
348}
349
274static int brcm_sata_phy_init(struct phy *phy) 350static int brcm_sata_phy_init(struct phy *phy)
275{ 351{
276 int rc; 352 int rc;
@@ -284,6 +360,9 @@ static int brcm_sata_phy_init(struct phy *phy)
284 case BRCM_SATA_PHY_IPROC_NS2: 360 case BRCM_SATA_PHY_IPROC_NS2:
285 rc = brcm_ns2_sata_init(port); 361 rc = brcm_ns2_sata_init(port);
286 break; 362 break;
363 case BRCM_SATA_PHY_IPROC_NSP:
364 rc = brcm_nsp_sata_init(port);
365 break;
287 default: 366 default:
288 rc = -ENODEV; 367 rc = -ENODEV;
289 }; 368 };
@@ -303,6 +382,8 @@ static const struct of_device_id brcm_sata_phy_of_match[] = {
303 .data = (void *)BRCM_SATA_PHY_STB_40NM }, 382 .data = (void *)BRCM_SATA_PHY_STB_40NM },
304 { .compatible = "brcm,iproc-ns2-sata-phy", 383 { .compatible = "brcm,iproc-ns2-sata-phy",
305 .data = (void *)BRCM_SATA_PHY_IPROC_NS2 }, 384 .data = (void *)BRCM_SATA_PHY_IPROC_NS2 },
385 { .compatible = "brcm,iproc-nsp-sata-phy",
386 .data = (void *)BRCM_SATA_PHY_IPROC_NSP },
306 {}, 387 {},
307}; 388};
308MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match); 389MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match);
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 935c43095109..497bc1558377 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -233,15 +233,8 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
233 task->task_state_flags = SAS_TASK_STATE_PENDING; 233 task->task_state_flags = SAS_TASK_STATE_PENDING;
234 qc->lldd_task = task; 234 qc->lldd_task = task;
235 235
236 switch (qc->tf.protocol) { 236 task->ata_task.use_ncq = ata_is_ncq(qc->tf.protocol);
237 case ATA_PROT_NCQ: 237 task->ata_task.dma_xfer = ata_is_dma(qc->tf.protocol);
238 task->ata_task.use_ncq = 1;
239 /* fall through */
240 case ATAPI_PROT_DMA:
241 case ATA_PROT_DMA:
242 task->ata_task.dma_xfer = 1;
243 break;
244 }
245 238
246 if (qc->scsicmd) 239 if (qc->scsicmd)
247 ASSIGN_SAS_TASK(qc->scsicmd, task); 240 ASSIGN_SAS_TASK(qc->scsicmd, task);
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 99346be5a7ca..adbc812c009b 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -46,8 +46,9 @@ enum {
46 ATA_MAX_SECTORS_128 = 128, 46 ATA_MAX_SECTORS_128 = 128,
47 ATA_MAX_SECTORS = 256, 47 ATA_MAX_SECTORS = 256,
48 ATA_MAX_SECTORS_1024 = 1024, 48 ATA_MAX_SECTORS_1024 = 1024,
49 ATA_MAX_SECTORS_LBA48 = 65535,/* TODO: 65536? */ 49 ATA_MAX_SECTORS_LBA48 = 65535,/* avoid count to be 0000h */
50 ATA_MAX_SECTORS_TAPE = 65535, 50 ATA_MAX_SECTORS_TAPE = 65535,
51 ATA_MAX_TRIM_RNUM = 64, /* 512-byte payload / (6-byte LBA + 2-byte range per entry) */
51 52
52 ATA_ID_WORDS = 256, 53 ATA_ID_WORDS = 256,
53 ATA_ID_CONFIG = 0, 54 ATA_ID_CONFIG = 0,
@@ -409,6 +410,9 @@ enum {
409 SETFEATURES_WC_ON = 0x02, /* Enable write cache */ 410 SETFEATURES_WC_ON = 0x02, /* Enable write cache */
410 SETFEATURES_WC_OFF = 0x82, /* Disable write cache */ 411 SETFEATURES_WC_OFF = 0x82, /* Disable write cache */
411 412
413 SETFEATURES_RA_ON = 0xaa, /* Enable read look-ahead */
414 SETFEATURES_RA_OFF = 0x55, /* Disable read look-ahead */
415
412 /* Enable/Disable Automatic Acoustic Management */ 416 /* Enable/Disable Automatic Acoustic Management */
413 SETFEATURES_AAM_ON = 0x42, 417 SETFEATURES_AAM_ON = 0x42,
414 SETFEATURES_AAM_OFF = 0xC2, 418 SETFEATURES_AAM_OFF = 0xC2,
@@ -519,16 +523,23 @@ enum {
519 SERR_DEV_XCHG = (1 << 26), /* device exchanged */ 523 SERR_DEV_XCHG = (1 << 26), /* device exchanged */
520}; 524};
521 525
522enum ata_tf_protocols { 526enum ata_prot_flags {
523 /* ATA taskfile protocols */ 527 /* protocol flags */
524 ATA_PROT_UNKNOWN, /* unknown/invalid */ 528 ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */
525 ATA_PROT_NODATA, /* no data */ 529 ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */
526 ATA_PROT_PIO, /* PIO data xfer */ 530 ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */
527 ATA_PROT_DMA, /* DMA */ 531 ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */
528 ATA_PROT_NCQ, /* NCQ */ 532
529 ATAPI_PROT_NODATA, /* packet command, no data */ 533 /* taskfile protocols */
530 ATAPI_PROT_PIO, /* packet command, PIO data xfer*/ 534 ATA_PROT_UNKNOWN = (u8)-1,
531 ATAPI_PROT_DMA, /* packet command with special DMA sauce */ 535 ATA_PROT_NODATA = 0,
536 ATA_PROT_PIO = ATA_PROT_FLAG_PIO,
537 ATA_PROT_DMA = ATA_PROT_FLAG_DMA,
538 ATA_PROT_NCQ_NODATA = ATA_PROT_FLAG_NCQ,
539 ATA_PROT_NCQ = ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ,
540 ATAPI_PROT_NODATA = ATA_PROT_FLAG_ATAPI,
541 ATAPI_PROT_PIO = ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_PIO,
542 ATAPI_PROT_DMA = ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_DMA,
532}; 543};
533 544
534enum ata_ioctls { 545enum ata_ioctls {
@@ -1066,12 +1077,12 @@ static inline void ata_id_to_hd_driveid(u16 *id)
1066 * TO NV CACHE PINNED SET. 1077 * TO NV CACHE PINNED SET.
1067 */ 1078 */
1068static inline unsigned ata_set_lba_range_entries(void *_buffer, 1079static inline unsigned ata_set_lba_range_entries(void *_buffer,
1069 unsigned buf_size, u64 sector, unsigned long count) 1080 unsigned num, u64 sector, unsigned long count)
1070{ 1081{
1071 __le64 *buffer = _buffer; 1082 __le64 *buffer = _buffer;
1072 unsigned i = 0, used_bytes; 1083 unsigned i = 0, used_bytes;
1073 1084
1074 while (i < buf_size / 8 ) { /* 6-byte LBA + 2-byte range per entry */ 1085 while (i < num) {
1075 u64 entry = sector | 1086 u64 entry = sector |
1076 ((u64)(count > 0xffff ? 0xffff : count) << 48); 1087 ((u64)(count > 0xffff ? 0xffff : count) << 48);
1077 buffer[i++] = __cpu_to_le64(entry); 1088 buffer[i++] = __cpu_to_le64(entry);
@@ -1095,13 +1106,13 @@ static inline bool ata_ok(u8 status)
1095static inline bool lba_28_ok(u64 block, u32 n_block) 1106static inline bool lba_28_ok(u64 block, u32 n_block)
1096{ 1107{
1097 /* check the ending block number: must be LESS THAN 0x0fffffff */ 1108 /* check the ending block number: must be LESS THAN 0x0fffffff */
1098 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256); 1109 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= ATA_MAX_SECTORS);
1099} 1110}
1100 1111
1101static inline bool lba_48_ok(u64 block, u32 n_block) 1112static inline bool lba_48_ok(u64 block, u32 n_block)
1102{ 1113{
1103 /* check the ending block number */ 1114 /* check the ending block number */
1104 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536); 1115 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= ATA_MAX_SECTORS_LBA48);
1105} 1116}
1106 1117
1107#define sata_pmp_gscr_vendor(gscr) ((gscr)[SATA_PMP_GSCR_PROD_ID] & 0xffff) 1118#define sata_pmp_gscr_vendor(gscr) ((gscr)[SATA_PMP_GSCR_PROD_ID] & 0xffff)
diff --git a/include/linux/libata.h b/include/linux/libata.h
index d15c19e331d1..e37d4f99f510 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -146,13 +146,6 @@ enum {
146 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ 146 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */
147 ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */ 147 ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */
148 148
149 /* protocol flags */
150 ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */
151 ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */
152 ATA_PROT_FLAG_DATA = ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA,
153 ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */
154 ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */
155
156 /* struct ata_device stuff */ 149 /* struct ata_device stuff */
157 ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ 150 ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */
158 ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ 151 ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */
@@ -1039,58 +1032,29 @@ extern const unsigned long sata_deb_timing_long[];
1039extern struct ata_port_operations ata_dummy_port_ops; 1032extern struct ata_port_operations ata_dummy_port_ops;
1040extern const struct ata_port_info ata_dummy_port_info; 1033extern const struct ata_port_info ata_dummy_port_info;
1041 1034
1042/* 1035static inline bool ata_is_atapi(u8 prot)
1043 * protocol tests
1044 */
1045static inline unsigned int ata_prot_flags(u8 prot)
1046{
1047 switch (prot) {
1048 case ATA_PROT_NODATA:
1049 return 0;
1050 case ATA_PROT_PIO:
1051 return ATA_PROT_FLAG_PIO;
1052 case ATA_PROT_DMA:
1053 return ATA_PROT_FLAG_DMA;
1054 case ATA_PROT_NCQ:
1055 return ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ;
1056 case ATAPI_PROT_NODATA:
1057 return ATA_PROT_FLAG_ATAPI;
1058 case ATAPI_PROT_PIO:
1059 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_PIO;
1060 case ATAPI_PROT_DMA:
1061 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_DMA;
1062 }
1063 return 0;
1064}
1065
1066static inline int ata_is_atapi(u8 prot)
1067{
1068 return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI;
1069}
1070
1071static inline int ata_is_nodata(u8 prot)
1072{ 1036{
1073 return !(ata_prot_flags(prot) & ATA_PROT_FLAG_DATA); 1037 return prot & ATA_PROT_FLAG_ATAPI;
1074} 1038}
1075 1039
1076static inline int ata_is_pio(u8 prot) 1040static inline bool ata_is_pio(u8 prot)
1077{ 1041{
1078 return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO; 1042 return prot & ATA_PROT_FLAG_PIO;
1079} 1043}
1080 1044
1081static inline int ata_is_dma(u8 prot) 1045static inline bool ata_is_dma(u8 prot)
1082{ 1046{
1083 return ata_prot_flags(prot) & ATA_PROT_FLAG_DMA; 1047 return prot & ATA_PROT_FLAG_DMA;
1084} 1048}
1085 1049
1086static inline int ata_is_ncq(u8 prot) 1050static inline bool ata_is_ncq(u8 prot)
1087{ 1051{
1088 return ata_prot_flags(prot) & ATA_PROT_FLAG_NCQ; 1052 return prot & ATA_PROT_FLAG_NCQ;
1089} 1053}
1090 1054
1091static inline int ata_is_data(u8 prot) 1055static inline bool ata_is_data(u8 prot)
1092{ 1056{
1093 return ata_prot_flags(prot) & ATA_PROT_FLAG_DATA; 1057 return prot & (ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA);
1094} 1058}
1095 1059
1096static inline int is_multi_taskfile(struct ata_taskfile *tf) 1060static inline int is_multi_taskfile(struct ata_taskfile *tf)
@@ -1407,7 +1371,7 @@ static inline bool sata_pmp_attached(struct ata_port *ap)
1407 return ap->nr_pmp_links != 0; 1371 return ap->nr_pmp_links != 0;
1408} 1372}
1409 1373
1410static inline int ata_is_host_link(const struct ata_link *link) 1374static inline bool ata_is_host_link(const struct ata_link *link)
1411{ 1375{
1412 return link == &link->ap->link || link == link->ap->slave_link; 1376 return link == &link->ap->link || link == link->ap->slave_link;
1413} 1377}
@@ -1422,7 +1386,7 @@ static inline bool sata_pmp_attached(struct ata_port *ap)
1422 return false; 1386 return false;
1423} 1387}
1424 1388
1425static inline int ata_is_host_link(const struct ata_link *link) 1389static inline bool ata_is_host_link(const struct ata_link *link)
1426{ 1390{
1427 return 1; 1391 return 1;
1428} 1392}
diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h
index 75fff8696bae..2fbbf990e4b3 100644
--- a/include/trace/events/libata.h
+++ b/include/trace/events/libata.h
@@ -126,6 +126,7 @@
126 ata_protocol_name(ATA_PROT_PIO), \ 126 ata_protocol_name(ATA_PROT_PIO), \
127 ata_protocol_name(ATA_PROT_DMA), \ 127 ata_protocol_name(ATA_PROT_DMA), \
128 ata_protocol_name(ATA_PROT_NCQ), \ 128 ata_protocol_name(ATA_PROT_NCQ), \
129 ata_protocol_name(ATA_PROT_NCQ_NODATA), \
129 ata_protocol_name(ATAPI_PROT_NODATA), \ 130 ata_protocol_name(ATAPI_PROT_NODATA), \
130 ata_protocol_name(ATAPI_PROT_PIO), \ 131 ata_protocol_name(ATAPI_PROT_PIO), \
131 ata_protocol_name(ATAPI_PROT_DMA)) 132 ata_protocol_name(ATAPI_PROT_DMA))