aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-13 16:26:24 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-13 16:26:24 -0500
commitb92e09bb5bf4db65aeb8ca0094fdd5142ed54451 (patch)
tree88607d2c9858a25e0f3bd1cc26224555a9ea8a3c
parentc11a6cfb0103d5d831e20bd9b75d10d13519fec5 (diff)
parentaecec8b60422118b52e3347430ba9382e57d6d76 (diff)
Merge branch 'for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata updates from Tejun Heo: - Adam added opt-in ATA command priority support. - There are machines which hide multiple nvme devices behind an ahci BAR. Dan Williams proposed a solution to force-switch the mode but deemed too hackishd. People are gonna discuss the proper way to handle the situation in nvme standard meetings. For now, detect and warn about the situation. - Low level driver specific changes. Christoph Hellwig pipes in about the hidden nvme warning: "I wish that was the case. We've pretty much agreed that we'll want to implement it as a virtual PCIe root bridge, similar to Intels other 'innovation' VMD that we work around that way. But Intel management has apparently decided that they don't want to spend more cycles on this now that Lenovo has an optional BIOS that doesn't force this broken mode anymore, and no one outside of Intel has enough information to implement something like this. So for now I guess this warning is it, until Intel reconsideres and spends resources on fixing up the damage their Chipset people caused" * 'for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: ahci: warn about remapped NVMe devices ahci-remap.h: add ahci remapping definitions nvme: move NVMe class code to pci_ids.h pata: imx: support controller modes up to PIO4 pata: imx: add support of setting timings for PIO modes pata: imx: set controller PIO mode with .set_piomode callback pata: imx: sort headers out ata: set ncq_prio_enabled iff device has support ata: ATA Command Priority Disabled By Default ata: Enabling ATA Command Priorities block: Add iocontext priority to request ahci: qoriq: added ls1046a platform support
-rw-r--r--block/blk-core.c4
-rw-r--r--drivers/ata/ahci.c39
-rw-r--r--drivers/ata/ahci_qoriq.c16
-rw-r--r--drivers/ata/libahci.c1
-rw-r--r--drivers/ata/libata-core.c35
-rw-r--r--drivers/ata/libata-scsi.c80
-rw-r--r--drivers/ata/libata.h2
-rw-r--r--drivers/ata/pata_imx.c82
-rw-r--r--drivers/nvme/host/pci.c3
-rw-r--r--include/linux/ahci-remap.h28
-rw-r--r--include/linux/ata.h6
-rw-r--r--include/linux/blkdev.h14
-rw-r--r--include/linux/libata.h5
-rw-r--r--include/linux/pci_ids.h2
14 files changed, 282 insertions, 35 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index bd642a43b98b..61ba08c58b64 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1154,6 +1154,7 @@ static struct request *__get_request(struct request_list *rl, unsigned int op,
1154 1154
1155 blk_rq_init(q, rq); 1155 blk_rq_init(q, rq);
1156 blk_rq_set_rl(rq, rl); 1156 blk_rq_set_rl(rq, rl);
1157 blk_rq_set_prio(rq, ioc);
1157 rq->cmd_flags = op; 1158 rq->cmd_flags = op;
1158 rq->rq_flags = rq_flags; 1159 rq->rq_flags = rq_flags;
1159 1160
@@ -1626,7 +1627,8 @@ void init_request_from_bio(struct request *req, struct bio *bio)
1626 1627
1627 req->errors = 0; 1628 req->errors = 0;
1628 req->__sector = bio->bi_iter.bi_sector; 1629 req->__sector = bio->bi_iter.bi_sector;
1629 req->ioprio = bio_prio(bio); 1630 if (ioprio_valid(bio_prio(bio)))
1631 req->ioprio = bio_prio(bio);
1630 blk_rq_bio_prep(req->q, req, bio); 1632 blk_rq_bio_prep(req->q, req, bio);
1631} 1633}
1632 1634
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 74f4c662f776..2fc52407306c 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -46,6 +46,8 @@
46#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
47#include <scsi/scsi_cmnd.h> 47#include <scsi/scsi_cmnd.h>
48#include <linux/libata.h> 48#include <linux/libata.h>
49#include <linux/ahci-remap.h>
50#include <linux/io-64-nonatomic-lo-hi.h>
49#include "ahci.h" 51#include "ahci.h"
50 52
51#define DRV_NAME "ahci" 53#define DRV_NAME "ahci"
@@ -1400,6 +1402,40 @@ static irqreturn_t ahci_thunderx_irq_handler(int irq, void *dev_instance)
1400} 1402}
1401#endif 1403#endif
1402 1404
1405static void ahci_remap_check(struct pci_dev *pdev, int bar,
1406 struct ahci_host_priv *hpriv)
1407{
1408 int i, count = 0;
1409 u32 cap;
1410
1411 /*
1412 * Check if this device might have remapped nvme devices.
1413 */
1414 if (pdev->vendor != PCI_VENDOR_ID_INTEL ||
1415 pci_resource_len(pdev, bar) < SZ_512K ||
1416 bar != AHCI_PCI_BAR_STANDARD ||
1417 !(readl(hpriv->mmio + AHCI_VSCAP) & 1))
1418 return;
1419
1420 cap = readq(hpriv->mmio + AHCI_REMAP_CAP);
1421 for (i = 0; i < AHCI_MAX_REMAP; i++) {
1422 if ((cap & (1 << i)) == 0)
1423 continue;
1424 if (readl(hpriv->mmio + ahci_remap_dcc(i))
1425 != PCI_CLASS_STORAGE_EXPRESS)
1426 continue;
1427
1428 /* We've found a remapped device */
1429 count++;
1430 }
1431
1432 if (!count)
1433 return;
1434
1435 dev_warn(&pdev->dev, "Found %d remapped NVMe devices.\n", count);
1436 dev_warn(&pdev->dev, "Switch your BIOS from RAID to AHCI mode to use them.\n");
1437}
1438
1403static int ahci_get_irq_vector(struct ata_host *host, int port) 1439static int ahci_get_irq_vector(struct ata_host *host, int port)
1404{ 1440{
1405 return pci_irq_vector(to_pci_dev(host->dev), port); 1441 return pci_irq_vector(to_pci_dev(host->dev), port);
@@ -1541,6 +1577,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1541 1577
1542 hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar]; 1578 hpriv->mmio = pcim_iomap_table(pdev)[ahci_pci_bar];
1543 1579
1580 /* detect remapped nvme devices */
1581 ahci_remap_check(pdev, ahci_pci_bar, hpriv);
1582
1544 /* must set flag prior to save config in order to take effect */ 1583 /* must set flag prior to save config in order to take effect */
1545 if (ahci_broken_devslp(pdev)) 1584 if (ahci_broken_devslp(pdev))
1546 hpriv->flags |= AHCI_HFLAG_NO_DEVSLP; 1585 hpriv->flags |= AHCI_HFLAG_NO_DEVSLP;
diff --git a/drivers/ata/ahci_qoriq.c b/drivers/ata/ahci_qoriq.c
index 1eba8dff875e..9884c8c6e934 100644
--- a/drivers/ata/ahci_qoriq.c
+++ b/drivers/ata/ahci_qoriq.c
@@ -46,11 +46,13 @@
46#define LS1021A_AXICC_ADDR 0xC0 46#define LS1021A_AXICC_ADDR 0xC0
47 47
48#define SATA_ECC_DISABLE 0x00020000 48#define SATA_ECC_DISABLE 0x00020000
49#define LS1046A_SATA_ECC_DIS 0x80000000
49 50
50enum ahci_qoriq_type { 51enum ahci_qoriq_type {
51 AHCI_LS1021A, 52 AHCI_LS1021A,
52 AHCI_LS1043A, 53 AHCI_LS1043A,
53 AHCI_LS2080A, 54 AHCI_LS2080A,
55 AHCI_LS1046A,
54}; 56};
55 57
56struct ahci_qoriq_priv { 58struct ahci_qoriq_priv {
@@ -63,6 +65,7 @@ static const struct of_device_id ahci_qoriq_of_match[] = {
63 { .compatible = "fsl,ls1021a-ahci", .data = (void *)AHCI_LS1021A}, 65 { .compatible = "fsl,ls1021a-ahci", .data = (void *)AHCI_LS1021A},
64 { .compatible = "fsl,ls1043a-ahci", .data = (void *)AHCI_LS1043A}, 66 { .compatible = "fsl,ls1043a-ahci", .data = (void *)AHCI_LS1043A},
65 { .compatible = "fsl,ls2080a-ahci", .data = (void *)AHCI_LS2080A}, 67 { .compatible = "fsl,ls2080a-ahci", .data = (void *)AHCI_LS2080A},
68 { .compatible = "fsl,ls1046a-ahci", .data = (void *)AHCI_LS1046A},
66 {}, 69 {},
67}; 70};
68MODULE_DEVICE_TABLE(of, ahci_qoriq_of_match); 71MODULE_DEVICE_TABLE(of, ahci_qoriq_of_match);
@@ -175,6 +178,13 @@ static int ahci_qoriq_phy_init(struct ahci_host_priv *hpriv)
175 writel(AHCI_PORT_TRANS_CFG, reg_base + PORT_TRANS); 178 writel(AHCI_PORT_TRANS_CFG, reg_base + PORT_TRANS);
176 writel(AHCI_PORT_AXICC_CFG, reg_base + PORT_AXICC); 179 writel(AHCI_PORT_AXICC_CFG, reg_base + PORT_AXICC);
177 break; 180 break;
181
182 case AHCI_LS1046A:
183 writel(LS1046A_SATA_ECC_DIS, qpriv->ecc_addr);
184 writel(AHCI_PORT_PHY_1_CFG, reg_base + PORT_PHY1);
185 writel(AHCI_PORT_TRANS_CFG, reg_base + PORT_TRANS);
186 writel(AHCI_PORT_AXICC_CFG, reg_base + PORT_AXICC);
187 break;
178 } 188 }
179 189
180 return 0; 190 return 0;
@@ -204,9 +214,9 @@ static int ahci_qoriq_probe(struct platform_device *pdev)
204 214
205 qoriq_priv->type = (enum ahci_qoriq_type)of_id->data; 215 qoriq_priv->type = (enum ahci_qoriq_type)of_id->data;
206 216
207 if (qoriq_priv->type == AHCI_LS1021A) { 217 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
208 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 218 "sata-ecc");
209 "sata-ecc"); 219 if (res) {
210 qoriq_priv->ecc_addr = devm_ioremap_resource(dev, res); 220 qoriq_priv->ecc_addr = devm_ioremap_resource(dev, res);
211 if (IS_ERR(qoriq_priv->ecc_addr)) 221 if (IS_ERR(qoriq_priv->ecc_addr))
212 return PTR_ERR(qoriq_priv->ecc_addr); 222 return PTR_ERR(qoriq_priv->ecc_addr);
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 0d028ead99e8..ee7db3119b18 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -140,6 +140,7 @@ EXPORT_SYMBOL_GPL(ahci_shost_attrs);
140struct device_attribute *ahci_sdev_attrs[] = { 140struct device_attribute *ahci_sdev_attrs[] = {
141 &dev_attr_sw_activity, 141 &dev_attr_sw_activity,
142 &dev_attr_unload_heads, 142 &dev_attr_unload_heads,
143 &dev_attr_ncq_prio_enable,
143 NULL 144 NULL
144}; 145};
145EXPORT_SYMBOL_GPL(ahci_sdev_attrs); 146EXPORT_SYMBOL_GPL(ahci_sdev_attrs);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 59ce0dd50701..f79d09c9419b 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -739,6 +739,7 @@ u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev)
739 * @n_block: Number of blocks 739 * @n_block: Number of blocks
740 * @tf_flags: RW/FUA etc... 740 * @tf_flags: RW/FUA etc...
741 * @tag: tag 741 * @tag: tag
742 * @class: IO priority class
742 * 743 *
743 * LOCKING: 744 * LOCKING:
744 * None. 745 * None.
@@ -753,7 +754,7 @@ u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev)
753 */ 754 */
754int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 755int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
755 u64 block, u32 n_block, unsigned int tf_flags, 756 u64 block, u32 n_block, unsigned int tf_flags,
756 unsigned int tag) 757 unsigned int tag, int class)
757{ 758{
758 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 759 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
759 tf->flags |= tf_flags; 760 tf->flags |= tf_flags;
@@ -785,6 +786,12 @@ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
785 tf->device = ATA_LBA; 786 tf->device = ATA_LBA;
786 if (tf->flags & ATA_TFLAG_FUA) 787 if (tf->flags & ATA_TFLAG_FUA)
787 tf->device |= 1 << 7; 788 tf->device |= 1 << 7;
789
790 if (dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE) {
791 if (class == IOPRIO_CLASS_RT)
792 tf->hob_nsect |= ATA_PRIO_HIGH <<
793 ATA_SHIFT_PRIO;
794 }
788 } else if (dev->flags & ATA_DFLAG_LBA) { 795 } else if (dev->flags & ATA_DFLAG_LBA) {
789 tf->flags |= ATA_TFLAG_LBA; 796 tf->flags |= ATA_TFLAG_LBA;
790 797
@@ -2156,6 +2163,30 @@ static void ata_dev_config_ncq_non_data(struct ata_device *dev)
2156 } 2163 }
2157} 2164}
2158 2165
2166static void ata_dev_config_ncq_prio(struct ata_device *dev)
2167{
2168 struct ata_port *ap = dev->link->ap;
2169 unsigned int err_mask;
2170
2171 err_mask = ata_read_log_page(dev,
2172 ATA_LOG_SATA_ID_DEV_DATA,
2173 ATA_LOG_SATA_SETTINGS,
2174 ap->sector_buf,
2175 1);
2176 if (err_mask) {
2177 ata_dev_dbg(dev,
2178 "failed to get Identify Device data, Emask 0x%x\n",
2179 err_mask);
2180 return;
2181 }
2182
2183 if (ap->sector_buf[ATA_LOG_NCQ_PRIO_OFFSET] & BIT(3))
2184 dev->flags |= ATA_DFLAG_NCQ_PRIO;
2185 else
2186 ata_dev_dbg(dev, "SATA page does not support priority\n");
2187
2188}
2189
2159static int ata_dev_config_ncq(struct ata_device *dev, 2190static int ata_dev_config_ncq(struct ata_device *dev,
2160 char *desc, size_t desc_sz) 2191 char *desc, size_t desc_sz)
2161{ 2192{
@@ -2205,6 +2236,8 @@ static int ata_dev_config_ncq(struct ata_device *dev,
2205 ata_dev_config_ncq_send_recv(dev); 2236 ata_dev_config_ncq_send_recv(dev);
2206 if (ata_id_has_ncq_non_data(dev->id)) 2237 if (ata_id_has_ncq_non_data(dev->id))
2207 ata_dev_config_ncq_non_data(dev); 2238 ata_dev_config_ncq_non_data(dev);
2239 if (ata_id_has_ncq_prio(dev->id))
2240 ata_dev_config_ncq_prio(dev);
2208 } 2241 }
2209 2242
2210 return 0; 2243 return 0;
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 8e575fbdf31d..c9abb87a09ea 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -50,6 +50,7 @@
50#include <linux/uaccess.h> 50#include <linux/uaccess.h>
51#include <linux/suspend.h> 51#include <linux/suspend.h>
52#include <asm/unaligned.h> 52#include <asm/unaligned.h>
53#include <linux/ioprio.h>
53 54
54#include "libata.h" 55#include "libata.h"
55#include "libata-transport.h" 56#include "libata-transport.h"
@@ -270,6 +271,79 @@ DEVICE_ATTR(unload_heads, S_IRUGO | S_IWUSR,
270 ata_scsi_park_show, ata_scsi_park_store); 271 ata_scsi_park_show, ata_scsi_park_store);
271EXPORT_SYMBOL_GPL(dev_attr_unload_heads); 272EXPORT_SYMBOL_GPL(dev_attr_unload_heads);
272 273
274static ssize_t ata_ncq_prio_enable_show(struct device *device,
275 struct device_attribute *attr, char *buf)
276{
277 struct scsi_device *sdev = to_scsi_device(device);
278 struct ata_port *ap;
279 struct ata_device *dev;
280 bool ncq_prio_enable;
281 int rc = 0;
282
283 ap = ata_shost_to_port(sdev->host);
284
285 spin_lock_irq(ap->lock);
286 dev = ata_scsi_find_dev(ap, sdev);
287 if (!dev) {
288 rc = -ENODEV;
289 goto unlock;
290 }
291
292 ncq_prio_enable = dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE;
293
294unlock:
295 spin_unlock_irq(ap->lock);
296
297 return rc ? rc : snprintf(buf, 20, "%u\n", ncq_prio_enable);
298}
299
300static ssize_t ata_ncq_prio_enable_store(struct device *device,
301 struct device_attribute *attr,
302 const char *buf, size_t len)
303{
304 struct scsi_device *sdev = to_scsi_device(device);
305 struct ata_port *ap;
306 struct ata_device *dev;
307 long int input;
308 unsigned long flags;
309 int rc;
310
311 rc = kstrtol(buf, 10, &input);
312 if (rc)
313 return rc;
314 if ((input < 0) || (input > 1))
315 return -EINVAL;
316
317 ap = ata_shost_to_port(sdev->host);
318
319 spin_lock_irqsave(ap->lock, flags);
320 dev = ata_scsi_find_dev(ap, sdev);
321 if (unlikely(!dev)) {
322 rc = -ENODEV;
323 goto unlock;
324 }
325
326 if (input) {
327 if (!(dev->flags & ATA_DFLAG_NCQ_PRIO)) {
328 rc = -EOPNOTSUPP;
329 goto unlock;
330 }
331
332 dev->flags |= ATA_DFLAG_NCQ_PRIO_ENABLE;
333 } else {
334 dev->flags &= ~ATA_DFLAG_NCQ_PRIO_ENABLE;
335 }
336
337unlock:
338 spin_unlock_irqrestore(ap->lock, flags);
339
340 return rc ? rc : len;
341}
342
343DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
344 ata_ncq_prio_enable_show, ata_ncq_prio_enable_store);
345EXPORT_SYMBOL_GPL(dev_attr_ncq_prio_enable);
346
273void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd, 347void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd,
274 u8 sk, u8 asc, u8 ascq) 348 u8 sk, u8 asc, u8 ascq)
275{ 349{
@@ -401,6 +475,7 @@ EXPORT_SYMBOL_GPL(dev_attr_sw_activity);
401 475
402struct device_attribute *ata_common_sdev_attrs[] = { 476struct device_attribute *ata_common_sdev_attrs[] = {
403 &dev_attr_unload_heads, 477 &dev_attr_unload_heads,
478 &dev_attr_ncq_prio_enable,
404 NULL 479 NULL
405}; 480};
406EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); 481EXPORT_SYMBOL_GPL(ata_common_sdev_attrs);
@@ -1756,6 +1831,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
1756{ 1831{
1757 struct scsi_cmnd *scmd = qc->scsicmd; 1832 struct scsi_cmnd *scmd = qc->scsicmd;
1758 const u8 *cdb = scmd->cmnd; 1833 const u8 *cdb = scmd->cmnd;
1834 struct request *rq = scmd->request;
1835 int class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
1759 unsigned int tf_flags = 0; 1836 unsigned int tf_flags = 0;
1760 u64 block; 1837 u64 block;
1761 u32 n_block; 1838 u32 n_block;
@@ -1822,7 +1899,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
1822 qc->nbytes = n_block * scmd->device->sector_size; 1899 qc->nbytes = n_block * scmd->device->sector_size;
1823 1900
1824 rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags, 1901 rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags,
1825 qc->tag); 1902 qc->tag, class);
1903
1826 if (likely(rc == 0)) 1904 if (likely(rc == 0))
1827 return 0; 1905 return 0;
1828 1906
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 3b301a48007c..8f3a5596dd67 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -66,7 +66,7 @@ extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
66extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag); 66extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag);
67extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 67extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
68 u64 block, u32 n_block, unsigned int tf_flags, 68 u64 block, u32 n_block, unsigned int tf_flags,
69 unsigned int tag); 69 unsigned int tag, int class);
70extern u64 ata_tf_read_block(const struct ata_taskfile *tf, 70extern u64 ata_tf_read_block(const struct ata_taskfile *tf,
71 struct ata_device *dev); 71 struct ata_device *dev);
72extern unsigned ata_exec_internal(struct ata_device *dev, 72extern unsigned ata_exec_internal(struct ata_device *dev,
diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index 139d20778b29..d4caa23f5a88 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -11,19 +11,26 @@
11 * 11 *
12 * TODO: 12 * TODO:
13 * - dmaengine support 13 * - dmaengine support
14 * - check if timing stuff needed
15 */ 14 */
16#include <linux/kernel.h> 15
17#include <linux/module.h>
18#include <linux/blkdev.h>
19#include <scsi/scsi_host.h>
20#include <linux/ata.h> 16#include <linux/ata.h>
17#include <linux/clk.h>
21#include <linux/libata.h> 18#include <linux/libata.h>
19#include <linux/module.h>
22#include <linux/platform_device.h> 20#include <linux/platform_device.h>
23#include <linux/clk.h>
24 21
25#define DRV_NAME "pata_imx" 22#define DRV_NAME "pata_imx"
26 23
24#define PATA_IMX_ATA_TIME_OFF 0x00
25#define PATA_IMX_ATA_TIME_ON 0x01
26#define PATA_IMX_ATA_TIME_1 0x02
27#define PATA_IMX_ATA_TIME_2W 0x03
28#define PATA_IMX_ATA_TIME_2R 0x04
29#define PATA_IMX_ATA_TIME_AX 0x05
30#define PATA_IMX_ATA_TIME_PIO_RDX 0x06
31#define PATA_IMX_ATA_TIME_4 0x07
32#define PATA_IMX_ATA_TIME_9 0x08
33
27#define PATA_IMX_ATA_CONTROL 0x24 34#define PATA_IMX_ATA_CONTROL 0x24
28#define PATA_IMX_ATA_CTRL_FIFO_RST_B (1<<7) 35#define PATA_IMX_ATA_CTRL_FIFO_RST_B (1<<7)
29#define PATA_IMX_ATA_CTRL_ATA_RST_B (1<<6) 36#define PATA_IMX_ATA_CTRL_ATA_RST_B (1<<6)
@@ -33,6 +40,10 @@
33#define PATA_IMX_DRIVE_DATA 0xA0 40#define PATA_IMX_DRIVE_DATA 0xA0
34#define PATA_IMX_DRIVE_CONTROL 0xD8 41#define PATA_IMX_DRIVE_CONTROL 0xD8
35 42
43static u32 pio_t4[] = { 30, 20, 15, 10, 10 };
44static u32 pio_t9[] = { 20, 15, 10, 10, 10 };
45static u32 pio_tA[] = { 35, 35, 35, 35, 35 };
46
36struct pata_imx_priv { 47struct pata_imx_priv {
37 struct clk *clk; 48 struct clk *clk;
38 /* timings/interrupt/control regs */ 49 /* timings/interrupt/control regs */
@@ -40,28 +51,49 @@ struct pata_imx_priv {
40 u32 ata_ctl; 51 u32 ata_ctl;
41}; 52};
42 53
43static int pata_imx_set_mode(struct ata_link *link, struct ata_device **unused) 54static void pata_imx_set_timing(struct ata_device *adev,
55 struct pata_imx_priv *priv)
56{
57 struct ata_timing timing;
58 unsigned long clkrate;
59 u32 T, mode;
60
61 clkrate = clk_get_rate(priv->clk);
62
63 if (adev->pio_mode < XFER_PIO_0 || adev->pio_mode > XFER_PIO_4 ||
64 !clkrate)
65 return;
66
67 T = 1000000000 / clkrate;
68 ata_timing_compute(adev, adev->pio_mode, &timing, T * 1000, 0);
69
70 mode = adev->pio_mode - XFER_PIO_0;
71
72 writeb(3, priv->host_regs + PATA_IMX_ATA_TIME_OFF);
73 writeb(3, priv->host_regs + PATA_IMX_ATA_TIME_ON);
74 writeb(timing.setup, priv->host_regs + PATA_IMX_ATA_TIME_1);
75 writeb(timing.act8b, priv->host_regs + PATA_IMX_ATA_TIME_2W);
76 writeb(timing.act8b, priv->host_regs + PATA_IMX_ATA_TIME_2R);
77 writeb(1, priv->host_regs + PATA_IMX_ATA_TIME_PIO_RDX);
78
79 writeb(pio_t4[mode] / T + 1, priv->host_regs + PATA_IMX_ATA_TIME_4);
80 writeb(pio_t9[mode] / T + 1, priv->host_regs + PATA_IMX_ATA_TIME_9);
81 writeb(pio_tA[mode] / T + 1, priv->host_regs + PATA_IMX_ATA_TIME_AX);
82}
83
84static void pata_imx_set_piomode(struct ata_port *ap, struct ata_device *adev)
44{ 85{
45 struct ata_device *dev;
46 struct ata_port *ap = link->ap;
47 struct pata_imx_priv *priv = ap->host->private_data; 86 struct pata_imx_priv *priv = ap->host->private_data;
48 u32 val; 87 u32 val;
49 88
50 ata_for_each_dev(dev, link, ENABLED) { 89 pata_imx_set_timing(adev, priv);
51 dev->pio_mode = dev->xfer_mode = XFER_PIO_0;
52 dev->xfer_shift = ATA_SHIFT_PIO;
53 dev->flags |= ATA_DFLAG_PIO;
54
55 val = __raw_readl(priv->host_regs + PATA_IMX_ATA_CONTROL);
56 if (ata_pio_need_iordy(dev))
57 val |= PATA_IMX_ATA_CTRL_IORDY_EN;
58 else
59 val &= ~PATA_IMX_ATA_CTRL_IORDY_EN;
60 __raw_writel(val, priv->host_regs + PATA_IMX_ATA_CONTROL);
61 90
62 ata_dev_info(dev, "configured for PIO\n"); 91 val = __raw_readl(priv->host_regs + PATA_IMX_ATA_CONTROL);
63 } 92 if (ata_pio_need_iordy(adev))
64 return 0; 93 val |= PATA_IMX_ATA_CTRL_IORDY_EN;
94 else
95 val &= ~PATA_IMX_ATA_CTRL_IORDY_EN;
96 __raw_writel(val, priv->host_regs + PATA_IMX_ATA_CONTROL);
65} 97}
66 98
67static struct scsi_host_template pata_imx_sht = { 99static struct scsi_host_template pata_imx_sht = {
@@ -72,7 +104,7 @@ static struct ata_port_operations pata_imx_port_ops = {
72 .inherits = &ata_sff_port_ops, 104 .inherits = &ata_sff_port_ops,
73 .sff_data_xfer = ata_sff_data_xfer_noirq, 105 .sff_data_xfer = ata_sff_data_xfer_noirq,
74 .cable_detect = ata_cable_unknown, 106 .cable_detect = ata_cable_unknown,
75 .set_mode = pata_imx_set_mode, 107 .set_piomode = pata_imx_set_piomode,
76}; 108};
77 109
78static void pata_imx_setup_port(struct ata_ioports *ioaddr) 110static void pata_imx_setup_port(struct ata_ioports *ioaddr)
@@ -128,7 +160,7 @@ static int pata_imx_probe(struct platform_device *pdev)
128 ap = host->ports[0]; 160 ap = host->ports[0];
129 161
130 ap->ops = &pata_imx_port_ops; 162 ap->ops = &pata_imx_port_ops;
131 ap->pio_mask = ATA_PIO0; 163 ap->pio_mask = ATA_PIO4;
132 ap->flags |= ATA_FLAG_SLAVE_POSS; 164 ap->flags |= ATA_FLAG_SLAVE_POSS;
133 165
134 io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 166 io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 3ba38f4d774d..d6e6bce93d0c 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2086,9 +2086,6 @@ static const struct pci_error_handlers nvme_err_handler = {
2086 .reset_notify = nvme_reset_notify, 2086 .reset_notify = nvme_reset_notify,
2087}; 2087};
2088 2088
2089/* Move to pci_ids.h later */
2090#define PCI_CLASS_STORAGE_EXPRESS 0x010802
2091
2092static const struct pci_device_id nvme_id_table[] = { 2089static const struct pci_device_id nvme_id_table[] = {
2093 { PCI_VDEVICE(INTEL, 0x0953), 2090 { PCI_VDEVICE(INTEL, 0x0953),
2094 .driver_data = NVME_QUIRK_STRIPE_SIZE | 2091 .driver_data = NVME_QUIRK_STRIPE_SIZE |
diff --git a/include/linux/ahci-remap.h b/include/linux/ahci-remap.h
new file mode 100644
index 000000000000..62be3a40239d
--- /dev/null
+++ b/include/linux/ahci-remap.h
@@ -0,0 +1,28 @@
1#ifndef _LINUX_AHCI_REMAP_H
2#define _LINUX_AHCI_REMAP_H
3
4#include <linux/sizes.h>
5
6#define AHCI_VSCAP 0xa4
7#define AHCI_REMAP_CAP 0x800
8
9/* device class code */
10#define AHCI_REMAP_N_DCC 0x880
11
12/* remap-device base relative to ahci-bar */
13#define AHCI_REMAP_N_OFFSET SZ_16K
14#define AHCI_REMAP_N_SIZE SZ_16K
15
16#define AHCI_MAX_REMAP 3
17
18static inline unsigned int ahci_remap_dcc(int i)
19{
20 return AHCI_REMAP_N_DCC + i * 0x80;
21}
22
23static inline unsigned int ahci_remap_base(int i)
24{
25 return AHCI_REMAP_N_OFFSET + i * AHCI_REMAP_N_SIZE;
26}
27
28#endif /* _LINUX_AHCI_REMAP_H */
diff --git a/include/linux/ata.h b/include/linux/ata.h
index fdb180367ba1..af6859b3a93d 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -348,6 +348,7 @@ enum {
348 ATA_LOG_DEVSLP_DETO = 0x01, 348 ATA_LOG_DEVSLP_DETO = 0x01,
349 ATA_LOG_DEVSLP_VALID = 0x07, 349 ATA_LOG_DEVSLP_VALID = 0x07,
350 ATA_LOG_DEVSLP_VALID_MASK = 0x80, 350 ATA_LOG_DEVSLP_VALID_MASK = 0x80,
351 ATA_LOG_NCQ_PRIO_OFFSET = 0x09,
351 352
352 /* NCQ send and receive log */ 353 /* NCQ send and receive log */
353 ATA_LOG_NCQ_SEND_RECV_SUBCMDS_OFFSET = 0x00, 354 ATA_LOG_NCQ_SEND_RECV_SUBCMDS_OFFSET = 0x00,
@@ -940,6 +941,11 @@ static inline bool ata_id_has_ncq_non_data(const u16 *id)
940 return id[ATA_ID_SATA_CAPABILITY_2] & BIT(5); 941 return id[ATA_ID_SATA_CAPABILITY_2] & BIT(5);
941} 942}
942 943
944static inline bool ata_id_has_ncq_prio(const u16 *id)
945{
946 return id[ATA_ID_SATA_CAPABILITY] & BIT(12);
947}
948
943static inline bool ata_id_has_trim(const u16 *id) 949static inline bool ata_id_has_trim(const u16 *id)
944{ 950{
945 if (ata_id_major_version(id) >= 7 && 951 if (ata_id_major_version(id) >= 7 &&
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index c5393766909d..286b2a264383 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1059,6 +1059,20 @@ static inline unsigned int blk_rq_count_bios(struct request *rq)
1059} 1059}
1060 1060
1061/* 1061/*
1062 * blk_rq_set_prio - associate a request with prio from ioc
1063 * @rq: request of interest
1064 * @ioc: target iocontext
1065 *
1066 * Assocate request prio with ioc prio so request based drivers
1067 * can leverage priority information.
1068 */
1069static inline void blk_rq_set_prio(struct request *rq, struct io_context *ioc)
1070{
1071 if (ioc)
1072 rq->ioprio = ioc->ioprio;
1073}
1074
1075/*
1062 * Request issue related functions. 1076 * Request issue related functions.
1063 */ 1077 */
1064extern struct request *blk_peek_request(struct request_queue *q); 1078extern struct request *blk_peek_request(struct request_queue *q);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 616eef4d81ea..c170be548b7f 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -166,6 +166,8 @@ enum {
166 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */ 166 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */
167 ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */ 167 ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */
168 ATA_DFLAG_NCQ_SEND_RECV = (1 << 19), /* device supports NCQ SEND and RECV */ 168 ATA_DFLAG_NCQ_SEND_RECV = (1 << 19), /* device supports NCQ SEND and RECV */
169 ATA_DFLAG_NCQ_PRIO = (1 << 20), /* device supports NCQ priority */
170 ATA_DFLAG_NCQ_PRIO_ENABLE = (1 << 21), /* Priority cmds sent to dev */
169 ATA_DFLAG_INIT_MASK = (1 << 24) - 1, 171 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
170 172
171 ATA_DFLAG_DETACH = (1 << 24), 173 ATA_DFLAG_DETACH = (1 << 24),
@@ -342,7 +344,9 @@ enum {
342 ATA_SHIFT_PIO = 0, 344 ATA_SHIFT_PIO = 0,
343 ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_NR_PIO_MODES, 345 ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_NR_PIO_MODES,
344 ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES, 346 ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES,
347 ATA_SHIFT_PRIO = 6,
345 348
349 ATA_PRIO_HIGH = 2,
346 /* size of buffer to pad xfers ending on unaligned boundaries */ 350 /* size of buffer to pad xfers ending on unaligned boundaries */
347 ATA_DMA_PAD_SZ = 4, 351 ATA_DMA_PAD_SZ = 4,
348 352
@@ -542,6 +546,7 @@ typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes)
542 546
543extern struct device_attribute dev_attr_link_power_management_policy; 547extern struct device_attribute dev_attr_link_power_management_policy;
544extern struct device_attribute dev_attr_unload_heads; 548extern struct device_attribute dev_attr_unload_heads;
549extern struct device_attribute dev_attr_ncq_prio_enable;
545extern struct device_attribute dev_attr_em_message_type; 550extern struct device_attribute dev_attr_em_message_type;
546extern struct device_attribute dev_attr_em_message; 551extern struct device_attribute dev_attr_em_message;
547extern struct device_attribute dev_attr_sw_activity; 552extern struct device_attribute dev_attr_sw_activity;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index c58752fe16c4..a5e6c7bca610 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -23,8 +23,10 @@
23#define PCI_CLASS_STORAGE_SATA 0x0106 23#define PCI_CLASS_STORAGE_SATA 0x0106
24#define PCI_CLASS_STORAGE_SATA_AHCI 0x010601 24#define PCI_CLASS_STORAGE_SATA_AHCI 0x010601
25#define PCI_CLASS_STORAGE_SAS 0x0107 25#define PCI_CLASS_STORAGE_SAS 0x0107
26#define PCI_CLASS_STORAGE_EXPRESS 0x010802
26#define PCI_CLASS_STORAGE_OTHER 0x0180 27#define PCI_CLASS_STORAGE_OTHER 0x0180
27 28
29
28#define PCI_BASE_CLASS_NETWORK 0x02 30#define PCI_BASE_CLASS_NETWORK 0x02
29#define PCI_CLASS_NETWORK_ETHERNET 0x0200 31#define PCI_CLASS_NETWORK_ETHERNET 0x0200
30#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201 32#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201