Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753204AbcLFRfI (ORCPT ); Tue, 6 Dec 2016 12:35:08 -0500 Received: from mail-sn1nam01on0073.outbound.protection.outlook.com ([104.47.32.73]:41504 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751689AbcLFRfD (ORCPT ); Tue, 6 Dec 2016 12:35:03 -0500 Authentication-Results: spf=fail (sender IP is 63.163.107.21) smtp.mailfrom=wdc.com; canonical.com; dkim=none (message not signed) header.d=none;canonical.com; dmarc=none action=none header.from=hgst.com; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:3249;Count:18 X-AuditID: 0ac94369-9793798000000b53-a5-5846f0a635d8 From: Adam Manzanares To: , , , , , , , , CC: , , , Adam Manzanares Subject: [PATCH v7 3/4] ata: ATA Command Priority Disabled By Default Date: Tue, 6 Dec 2016 09:18:04 -0800 Message-ID: <1481044685-2803-4-git-send-email-adam.manzanares@hgst.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481044685-2803-1-git-send-email-adam.manzanares@hgst.com> References: <1481044685-2803-1-git-send-email-adam.manzanares@hgst.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRmVeSWpSXmKPExsXCddJ5ke6yD24RBnP7rS1uH93BYrH6bj+b xc8rs9gspk+9wGixZ9EkJou9t7Qtju14xGRxedccNovlx/8xWaw/soHRYtfD7+wWv5YfZbR4 uGAzuwOvx6yGXjaPXbsa2T0W73nJ5HH5bKnHplWdbB4fn95i8Xi/7yqbx6Wz7Swem09Xe3ze JBfAFcVlk5Kak1mWWqRvl8CV8enzWsaCPrWKn181GxhPyncxcnJICJhITFk0l7WLkYtDSGAp k8TP46tYQBJCAtsZJW7vYIMpenD7PzNE0XpGiU9rdwF1cHCwCRhITL+cCBIXEbjOKNH9+RQb iMMs0M0osfl7AytIt7CAq8SJex+ZQWwW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yD+5lbi00j8gu XWFZcXJTw2p2yZ2+d7UDOmfLGkea3eY1cg7LS+57ECIxZSVbwjY2mz9OsuXBU08/VdnSv3VF 3jqOylfJmvrrDs8MX6bEUpyRaKjFXFScCABfGw3q+wEAAA== MIME-Version: 1.0 Content-Type: text/plain X-IncomingHeaderCount: 18 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.21;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(626004)(106466001)(105606002)(6666003)(2950100002)(42882006)(39840400001)(36756003)(189998001)(68736007)(39850400001)(39860400001)(960300001)(85426001)(50466002)(69596002)(5001770100001)(47776003)(48376002)(97736004)(5660300001)(8676002)(81156014)(81166006)(7416002)(8936002)(77096006)(50226002)(2270400002)(92566002)(76176999)(38730400001)(39410400001)(50986999)(39450400002)(5003940100001)(356003)(33646002)(7846002)(4326007)(2906002)(2201001)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR0201MB1516;H:milsmgep15.sandisk.com;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD016;1:SUw/KSMN1VpsV/rdAPZni/VB8+W9Sl5JgC+dmHNmu29sFBEKL18EzIglHkYSMQICwVOUbngkmIMxtb/mQuob2rJoRLSZbtRxbWGopnLCEu7E1wX05e+59TLO5smyFVYuwLYUMwF+891rMlvDaA4GJZW7RZL3tsGLkk+E2T6sLDlkYvpLtdjaybHb2wq5mZcyRD/nMO2eSZSwBbVnSjan02FkeS7jb50jzKUZsbJUu414SeNgWqT582G38PcRab0xQOwD2qKJVWyw1+B9giqkQs95UYRUWapKY77piC0EhUsC2z/tiN15RTZnydMAOotsPCJ/NRGYFN8hmwPkvwkm9pi+umCSWE1zT+0QwJTgRVMpv84WURUdchzwZIKpxkspmG3COg2PxGC+i9u34/tviIo8rKIRtiJct+FBEINvn5Mp+8MXsNMybd+PT19tT4AtrCylxPXEEILBa7XhIk+r0kzFggyrCfQceI4k390TGVVEaicjk64tW5FLp/7pex9geDoYAFEobrNTt8Uvz4EihzY/7Vph0ScnWolsoWrDt1Q/QkAe/b6bAiYLAlSYXLRj4LBeuFazhsi+zfdFSJE1oQ== X-MS-Office365-Filtering-Correlation-Id: 10a69777-aced-47f5-be6a-08d41dfbe69f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR0201MB1516; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1516;3:SLllIhQrcvvG1JE7WkGXjzLgko6xG8DG/qunzbOEo4dis1ypGQmYvdwKkyS1WFUUs27XttQQIAepYguwxz5YKPX1F16+b9BB9yu7y9wDzb39KWx2SrzJ+w1ESwgaOKFyGf1ZU5mJbphWn9wfNZtsDgO+XwODq7tIWHt+30dYgvqmvOjHZCwpL5MDpVG9PApc2S1rRXDelKNgkxnj6b5HVkq0l/vjTXmMhb7BSQZS68vQYdmpaG6F0x6OqjxHVzleJpSejwFkKRPzFMYVbjWjl//cG0W+57GtssL/mE6R0iZhNJGGSs8mvYxUEXYOXHTugH6LUzWVFFclyjMAKg1x24b5NGRtlJ8nr3T6zptucoXe0/NSPTj0Jp0S/QxVcYMa;25:bFRLrgTMmP7THARJbV6ZLp/Y8rmg1JEz/CM0MvcdYQjeZlEubT4mDyGMJi43jfrkux6fvlm5QsWWMByJTl+4u0JclzFQQI+RNMiEQO+nN/bFY9xevPvB7O1XX9M1tQp0b7HDDF7xu6jhnVp4Z+D53/MfAESgzQGrWtFfcMy6CMH7E1DDRla1q2GDqL8OW47WAl1sFSgr/CfMMAkDtUH3H19rQd5qEriPT0dOKcYMEoFZeSTkoiYP5r0MPO/k0I90Geu5B8wvrod7KcVyhOQX37EM3DaVoSB25PkL84/6fphz3uhsGu82Hx208aj8cyCzgcvrPFX4Wt0gkI9ciJmMvmaxum5gwFXL+UWqeykCfyKGz9+WAIiCVvC3FkvQeojnBqQvaBdtBK+LXdskW8hhrRAODN42Qh1ZBYWalaxknJl5afBiPqlKgJL7rUgC4c5EPdSho0PSbUB2NjU20BbDOQ== X-LD-Processed: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1516;31:8zz7VhpWeox+8Ffl8BqReC8E1fBpikVxGp+Nc7+e8QUzumgFcpXurdocajxdLEpZb5octcwO0VovPNJ4A7hjIEhInhFTwu42iaDfHzfUg8ULKbZyb8RLIRferWPlURDSRVMDuLIsVBLTFUigw/Phl9c2x4M4/lLfJ8TuG3ufLOq6nNtsBqVsVOdu/EHIok9WSocqa6MA7x72WeHLiDt+sCcTWkNTKvjEznHso+N7uGB4gTpd8UJ4idVpx0vCb5je49k/BIN9azmhgxB42WT79gPTNl9Qw5bojz8uFnNz7d0=;20:hJoVbkfZc1hHYYfnhcjmHknvbT4U3w/FN8Hu+qb/9hDoJI7c0ur6+e6k3kZJIwQh2gIodlHeI19/5pQX8rRtHC8CRjFmwwvo4V7VCB7v83gzl21c4krQr571zpyDU6n71w8kD1q3S9uzZhD+CZ6NaBRGL6FOaIuDib/4gO7MBuxdoaeseWlIoKS77qjq6EXnKaEm1qEWSMVf/wQa8Bi1tbAMHvAvfT/1n66LfbJIvHW2uuZ7z/x46VlP8AtDQqTMOoT1KtJnBWEa5R3WokIUpuK5PEY65KnyHCXOHugOyyy/n80bjpEH9+durTWg5bfp873BHjbmdQUQQcSE92q23bG3lP3jUEcT9e9kHQDqG2nAE/tO2A+feHyCJknRvwXkS0Xw0azQgU/OVQhamwEAOlVnpQYVWKxBRGVjz5Ahe5iD2dpSuXw7W2JDzZLPqzWwVZ4l5gCJNoI/3fvcdCLvut/31jINUgnccvRifl3eG3XZvAu374a9lP40a2TgkbKy X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(13016025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(6072148);SRVR:CY1PR0201MB1516;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0201MB1516; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1516;4:UfeDNdq1oyjanW+ULCE1sldwmqiWGokUgciT7Vwm6jM/S0lmQ6a4Y0G8hT9I7o5YdWQSwNzNMq9qBd8zI1rlK1y5qoFc6dJ/Y8WRCTYB962hT9xk+pfLEXgSQMlOue6f6FMTAcYuA8J+y+apzSUaSC6dfZdSMAMx5iuaIVWVLBp6HdSfgX194mdlvhB0jWTSKU9OQa0y0gjLPzL/BfLqnoYL+DX3sSPNGckSTSIAERwp8ghKXY7p90h/elUDkejWGHuIPzq7EWkPWcAm3GVAT1Kn/MAUvQsXXXu6S1wODRnZ54vGF0uplmo6fzkZy/SdxWgA2prAgIuT6My8d95vLsJOBJPLJ/7hS8CqDQS1O35A0WWR4znx5Ws6znplqIgQqMiZHFiOYV1Yk5bVfadO5Sj7DZPr5Z56esdGiW6hohX15Qo/NmFFiZdh2rMWT6n2np/CBxjqW1bVTnVcF9l99RQO1r3zkXWPaUaHt9B5wPnaWd5krUDbxfisrxHe8PQOEFj1aAVNRz01pW8HV+vReHFAuuv4fqNt7E+MHwB/xM5dGrRil+0UuwEVMuKbfyRpHTWBijyL+8umm9ZEhD/5CWu1+NOu1qa7RFHGhPWwsQLel/MbyREFPn5rbimXyWIv X-Forefront-PRVS: 01480965DA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0201MB1516;23:C1h/XOXUZVPCGpXvziUuIE19rXtEZX9eiAzxhJr?= =?us-ascii?Q?vmpo1L81fLoZlE3elCIsoRF3bAcr7jZvMuBhYOfIlrjmIxo1XjgUYLKi4K2W?= =?us-ascii?Q?E+pjvodIhnLXM3mF6q+pTDr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XirTbew80d/jfKon4cbMLijQE1tS6effoL8dbzs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR0201MB1516;7:Czu2nTLXLLkhqEOrOLDBtqt4Cibk/CHakfbKe0RNGOhEmWzVA9P2uqoLEakIhRgGrWmelpxLYCOgQrGCyiOeg6Mq52QRFd7dQ31LzkL9zZeUg9J3VFIg+UqcfpWEDpsjRT2muLIH3OV2CWulT68Wr5Ydnaye0Jmdl4d6lK3igXVE/SGAJ+40fAZbRDLBn6DbwYrJax2TdcwvAAii9Msfa6vO4qaOqw9ozmKgBU+CWtw3vj7rmvrNEF9s8NUBQgfipuipigBTMB0M1iV8njv2QqHCkEdFb6AjYLGFODyovaAlDAbeoCIBSTaZ3fZNKm5Cvk7B+Y8Grzs7Xk9mH43RCB9OU5CoyTvKGYBlg24NN5e2duZgyFCFqKpXFPSgcAx+8RQH0dLm+ZFFpykgh4j9fWSLSnqL4TAnk4GEYAnMEwexBaZK/he8ZcZMqH2/dgeitMhFhtUP98um8ec8hylQhw==;20:qqLfykekc8LDURKFDFb2S1axxkRTkUCjxpjsrvLXFasBI0oIMHKocFoiMX+OX74fbD6c7WNQeN98lyWZ4RqVU2hC2itlz29P7wRVHtb3S73Qb8TmJU+riSL3XtNbp+61CoYQJmu/q0CHJabgow2J++5Ovq+NjD7LvByoi64K74mjOtrySEGZ53I04qJLuMuVC7c3/J0De1H2lwwfr/wKosIK0e4rhCiTycGeFJpmBCdVEjz2GCX2lncgUbUcU6+P X-OriginatorOrg: sandiskcorp.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2016 17:18:30.8060 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d;Ip=[63.163.107.21];Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB1516 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4723 Lines: 153 From: Adam Manzanares Add a sysfs entry to turn on priority information being passed to a ATA device. By default this feature is turned off. This patch depends on ata: Enabling ATA Command Priorities tj: Renamed ncq_prio_on to ncq_prio_enable and removed trivial ata_ncq_prio_on() and open-coded the test. Signed-off-by: Adam Manzanares --- drivers/ata/libahci.c | 1 + drivers/ata/libata-core.c | 3 ++- drivers/ata/libata-scsi.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/libata.h | 2 ++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 0d028ea..ee7db31 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -140,6 +140,7 @@ EXPORT_SYMBOL_GPL(ahci_shost_attrs); struct device_attribute *ahci_sdev_attrs[] = { &dev_attr_sw_activity, &dev_attr_unload_heads, + &dev_attr_ncq_prio_enable, NULL }; EXPORT_SYMBOL_GPL(ahci_sdev_attrs); diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 5d16363..f6a631a 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -787,7 +787,8 @@ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, if (tf->flags & ATA_TFLAG_FUA) tf->device |= 1 << 7; - if (dev->flags & ATA_DFLAG_NCQ_PRIO) { + if ((dev->flags & ATA_DFLAG_NCQ_PRIO) && + (dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE)) { if (class == IOPRIO_CLASS_RT) tf->hob_nsect |= ATA_PRIO_HIGH << ATA_SHIFT_PRIO; diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 2bccc3c..328a601 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -271,6 +271,74 @@ DEVICE_ATTR(unload_heads, S_IRUGO | S_IWUSR, ata_scsi_park_show, ata_scsi_park_store); EXPORT_SYMBOL_GPL(dev_attr_unload_heads); +static ssize_t ata_ncq_prio_enable_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct ata_port *ap; + struct ata_device *dev; + bool ncq_prio_enable; + int rc = 0; + + ap = ata_shost_to_port(sdev->host); + + spin_lock_irq(ap->lock); + dev = ata_scsi_find_dev(ap, sdev); + if (!dev) { + rc = -ENODEV; + goto unlock; + } + + ncq_prio_enable = dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE; + +unlock: + spin_unlock_irq(ap->lock); + + return rc ? rc : snprintf(buf, 20, "%u\n", ncq_prio_enable); +} + +static ssize_t ata_ncq_prio_enable_store(struct device *device, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct ata_port *ap; + struct ata_device *dev; + long int input; + unsigned long flags; + int rc; + + rc = kstrtol(buf, 10, &input); + if (rc) + return rc; + if ((input < 0) || (input > 1)) + return -EINVAL; + + ap = ata_shost_to_port(sdev->host); + + spin_lock_irqsave(ap->lock, flags); + dev = ata_scsi_find_dev(ap, sdev); + if (unlikely(!dev)) { + rc = -ENODEV; + goto unlock; + } + + if (input) + dev->flags |= ATA_DFLAG_NCQ_PRIO_ENABLE; + else + dev->flags &= ~ATA_DFLAG_NCQ_PRIO_ENABLE; + +unlock: + spin_unlock_irqrestore(ap->lock, flags); + + return rc ? rc : len; +} + +DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR, + ata_ncq_prio_enable_show, ata_ncq_prio_enable_store); +EXPORT_SYMBOL_GPL(dev_attr_ncq_prio_enable); + void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) { @@ -402,6 +470,7 @@ EXPORT_SYMBOL_GPL(dev_attr_sw_activity); struct device_attribute *ata_common_sdev_attrs[] = { &dev_attr_unload_heads, + &dev_attr_ncq_prio_enable, NULL }; EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); diff --git a/include/linux/libata.h b/include/linux/libata.h index 90b69a6..c170be5 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -167,6 +167,7 @@ enum { ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */ ATA_DFLAG_NCQ_SEND_RECV = (1 << 19), /* device supports NCQ SEND and RECV */ ATA_DFLAG_NCQ_PRIO = (1 << 20), /* device supports NCQ priority */ + ATA_DFLAG_NCQ_PRIO_ENABLE = (1 << 21), /* Priority cmds sent to dev */ ATA_DFLAG_INIT_MASK = (1 << 24) - 1, ATA_DFLAG_DETACH = (1 << 24), @@ -545,6 +546,7 @@ typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes) extern struct device_attribute dev_attr_link_power_management_policy; extern struct device_attribute dev_attr_unload_heads; +extern struct device_attribute dev_attr_ncq_prio_enable; extern struct device_attribute dev_attr_em_message_type; extern struct device_attribute dev_attr_em_message; extern struct device_attribute dev_attr_sw_activity; -- 2.7.4