From patchwork Tue Sep 27 18:14:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Manzanares X-Patchwork-Id: 9352557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1E9E260757 for ; Tue, 27 Sep 2016 18:15:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 142DF287F3 for ; Tue, 27 Sep 2016 18:15:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 090C329193; Tue, 27 Sep 2016 18:15:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BD16287F3 for ; Tue, 27 Sep 2016 18:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934109AbcI0SPc (ORCPT ); Tue, 27 Sep 2016 14:15:32 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:47177 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933067AbcI0SPa (ORCPT ); Tue, 27 Sep 2016 14:15:30 -0400 X-IronPort-AV: E=Sophos;i="5.30,406,1470672000"; d="scan'208";a="18618864" Received: from mail-cys01nam02lp0050.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.50]) by ob1.hgst.iphmx.com with ESMTP; 28 Sep 2016 02:15:20 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-hgst-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ct8wWHdy/OgAzPBwrRx1p+p3EFtCJtRlDRYrDoe0qtw=; b=agBBh6mLqBxH9WmIaOipfq+vvnGaEc1waHkEpFT9JC6FZImBj3MoTyxA4go1NWlPLJuLIcz66D1PgtGZJegMsAhPKx1ZDoJO9HQtLLz4vjLm60j2r/zav3rVauLOpOeo6Mj0Hy9wLGeSOsaMWtC5dOAWIWZ2WLE1o46kRIetfuI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Adam.Manzanares@hgst.com; Received: from penguito.sanjose.hgst.com (199.255.44.175) by BLUPR0401MB1714.namprd04.prod.outlook.com (10.162.215.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Tue, 27 Sep 2016 18:15:18 +0000 From: Adam Manzanares To: , CC: , , "Adam Manzanares" Subject: [PATCH 3/3] ata: ATA Command Priority Disabled By Default Date: Tue, 27 Sep 2016 11:14:56 -0700 Message-ID: <1475000096-6148-4-git-send-email-adam.manzanares@hgst.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1475000096-6148-1-git-send-email-adam.manzanares@hgst.com> References: <1475000096-6148-1-git-send-email-adam.manzanares@hgst.com> MIME-Version: 1.0 X-Originating-IP: [199.255.44.175] X-ClientProxiedBy: SN1PR0701CA0045.namprd07.prod.outlook.com (10.163.126.13) To BLUPR0401MB1714.namprd04.prod.outlook.com (10.162.215.16) X-MS-Office365-Filtering-Correlation-Id: 5d922152-f322-4394-4dbd-08d3e7023d23 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1714; 2:jqfvs850TQMOruntb7pssYpBtHolElpAe3dN8fq0Vhyt0kip4G64QQawE1FRjakRKUHvbPYD5j7Q/cKNt/jPqRMBZMcfio6Ydw8Go7oX1RHbSXp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+52dpvZeauIdVbFKaOUQAzzuh/cE+58VZXyh8cCMVWO+agDVL+y+NqBc5IByN0XaOuO2DEp72AjDKkHh5J3CLoqeAPEsOZ2mFX0fRgq2IMrsmnCw1bHRkXYT8Kbda1Hx5uNVDzOH5e/DHoYv+VmKNHN1g6FNGp91rov4tL3mT9GvmK7fIrkCJxN9ypcZuXGB7gqkgTiYh6CihjagOL/uxRWEI9rcgaQslI25xkvHbS6Ow9OsTrNJiN7ftoppkrWEa5lqhOCa9WEUxeBLu3pAoEcA/yUw3Zo3ltdrEGJhFMkgwL3tnJyL1R2BNtUb2gpLV/4sZlY+bXkNXjU/wLSK19SzGivhetUTl7Vn9qq9dZ1R5oYTl768bLdXm177Q6ziiT6V4Gcq1ZUEspdRtjPQGCWUdIoQt9LheVKj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(79135771888625); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:BLUPR0401MB1714; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0401MB1714; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1714; 4:yMRnnFagvEt4tfP14FxfVP+RzKBGKuMH7/1nvUeZxb+qrDpGXNHkR3/spv6ZG2SUdEp0CGiKfoDGobGsSi9yPMpqweP0RNty5Xb9Wbez8lDICXJm7Wzj8VlE2g035io1VWTUz278ToP7NRhEcD9i0JTbuirNbssmpr/XqdSp/HK4hKvZsJKsB3Qfw9FP+fWTGesCPU/9kTvfehS8BtXqqYi/UhCQ6gJzT2lQDOqAFAET8IjOAb0tnktWxBWBl/uV/kQWAbfuHCuPQ1W2tGrNsTsLbCoWDIyPQyI+Ekbfp77wp5bzfP1oTIeCfRAvoxbfzj3DZbJ5+hNA3lIZ/FEqodMg3I9Kb0qeXDI/h2XGB2zGiMIsPnOEWJI6ZjlKv5dor67nsufbL7yG0lcXphD2wiP1g9l+9IonT50ipMVnVO9uafr2X8FEK8Qt5+BJMWY5JsLigwsITwQNOqpc7pglxg== X-Forefront-PRVS: 007814487B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(5001770100001)(97736004)(107886002)(5003940100001)(47776003)(101416001)(66066001)(48376002)(50466002)(77096005)(575784001)(86362001)(3846002)(6116002)(19580405001)(19580395003)(189998001)(5660300001)(586003)(8676002)(33646002)(4001430100002)(42186005)(105586002)(229853001)(106356001)(81156014)(2906002)(81166006)(2950100002)(92566002)(50226002)(7846002)(50986999)(76176999)(68736007)(7736002)(305945005)(4326007)(36756003)(7099028); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR0401MB1714; H:penguito.sanjose.hgst.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: hgst.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0401MB1714; 23:nwYQuin1oRsM0qWRVmSrEWGUjYi3hEvN+byl0tw?= =?us-ascii?Q?1F7hkaR+kBLrDeH1RsYmYRD3u7ZH2uW+Uf5YTyokwnsRzcpKDrtJkVSjswBZ?= =?us-ascii?Q?a6IWvHera5e5gYl6LBHAqEfl3sM4ThL9DlAv/nCvyBRLyCr3e/sUVWNOJvxX?= =?us-ascii?Q?ji7Cwr6MSY010XTJGnqNAVpWQcrecz838ZQiSDvKQfOTBfNk7/ri5kSJIW4k?= =?us-ascii?Q?OTNRcDLs3h1Z+ZY3FcX762XCP3BukP+N53sAGHAX3kJsBBesIKgYGgzrXDNy?= =?us-ascii?Q?6FQOyp1Wqysg8Hp0z1JjbVFCnmLqCOdh5TL3CDbMGN2xh9Wz26cYq0iBftmS?= =?us-ascii?Q?R0rMcLuH2cBrOi2oV1AgPoj6NJRGo8nMLpDdysg8+z/xyoo1z+X6+xrC/rc5?= =?us-ascii?Q?2BzwxyOA5xjqt8aff3jjgkNP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I+TC/xEOPxuY3Hi3DOzhM8EOurzdhajUbZEFcdL+Orz X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2016 18:15:18.5862 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0401MB1714 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Adam Manzanares --- drivers/ata/libahci.c | 1 + drivers/ata/libata-core.c | 2 +- drivers/ata/libata-scsi.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/libata.h | 8 ++++++ 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index dcf2c72..383adf7 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_enable_prio, NULL }; EXPORT_SYMBOL_GPL(ahci_sdev_attrs); diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 181b530..d0cf987 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -787,7 +787,7 @@ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, if (tf->flags & ATA_TFLAG_FUA) tf->device |= 1 << 7; - if (ata_ncq_prio_enabled(dev)) { + if (ata_ncq_prio_enabled(dev) && ata_prio_enabled(dev)) { 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 18629e8..10ba118 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -271,6 +271,73 @@ 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_enable_prio_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; + int rc = 0; + int enable_prio; + + 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; + } + + enable_prio = ata_prio_enabled(dev); + +unlock: + spin_unlock_irq(ap->lock); + + return rc ? rc : snprintf(buf, 20, "%u\n", enable_prio); +} + +static ssize_t ata_enable_prio_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_ENABLE_PRIO; + else + dev->flags &= ~ATA_DFLAG_ENABLE_PRIO; + +unlock: + spin_unlock_irqrestore(ap->lock, flags); + + return rc ? rc : len; +} + +DEVICE_ATTR(enable_prio, S_IRUGO | S_IWUSR, + ata_enable_prio_show, ata_enable_prio_store); +EXPORT_SYMBOL_GPL(dev_attr_enable_prio); + void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) { @@ -402,6 +469,7 @@ EXPORT_SYMBOL_GPL(dev_attr_sw_activity); struct device_attribute *ata_common_sdev_attrs[] = { &dev_attr_unload_heads, + &dev_attr_enable_prio, NULL }; EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); diff --git a/include/linux/libata.h b/include/linux/libata.h index a3c66852..804c4c6 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -166,6 +166,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_ENABLE_PRIO = (1 << 21), /* User enable device priority */ ATA_DFLAG_INIT_MASK = (1 << 24) - 1, ATA_DFLAG_DETACH = (1 << 24), @@ -544,6 +545,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_enable_prio; 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; @@ -1628,6 +1630,12 @@ static inline int ata_ncq_prio_enabled(struct ata_device *dev) ATA_DFLAG_NCQ_PRIO)) == ATA_DFLAG_NCQ_PRIO; } +static inline int ata_prio_enabled(struct ata_device *dev) +{ + return ((dev->flags & ATA_DFLAG_ENABLE_PRIO) == + ATA_DFLAG_ENABLE_PRIO); +} + static inline bool ata_fpdma_dsm_supported(struct ata_device *dev) { return (dev->flags & ATA_DFLAG_NCQ_SEND_RECV) &&