From patchwork Mon Aug 2 09:02:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12413605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01500C4338F for ; Mon, 2 Aug 2021 09:03:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8CC860F9F for ; Mon, 2 Aug 2021 09:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232977AbhHBJDJ (ORCPT ); Mon, 2 Aug 2021 05:03:09 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:6558 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232788AbhHBJCs (ORCPT ); Mon, 2 Aug 2021 05:02:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1627894957; x=1659430957; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1lJCZKzFplMb5NB2wZ+Qms6TSDfs/rcPRomXSgSO30Q=; b=BG4NuLSYZeodZBLs7wo/fmWwPz+BT3CeiJB0M4j30SfYMK7af0an91Bm l3zqBpgkNNOB32TkY/ikHON8DIzlYdoRrJdCq/mwBydL0knYZkB+3cudD x6+BCD5RCD4+ProeUtKqKKtmUJQXWq/T6eAFFHsfzFjcYqxrKfuuhJ39R v2jBF+CdYe0d8zJpWPOcJ2iPTBhb+prsstZjtkfBvOMRIcU6wmvVENZjB ezGqHiKgCtnjvj1+kd0tfGQoF4KZuUcTQvbakguhf8G+acfkUZ85c384c uaKZ0HJnN+zZWD4uFTkBhi1beq6WZVoNdAWO9mYbi1X29W5PUz1iAi/OH w==; X-IronPort-AV: E=Sophos;i="5.84,288,1620662400"; d="scan'208";a="180887616" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2021 17:02:33 +0800 IronPort-SDR: LH3u78C9lsxkMuTlgbrnHoskOFTFCNSlcizlSVEIWjR8TRaJ97xHxpnU6jxSdxU3pPYlkyB8/3 Uficg01+ILFW9en/vPgVaiOquWVl90d+7GIwHnJdzMngrjt64T2VKHH1ON34udiRJ7NT2tyTTz oX2nE+ju3wMpQxYeFPQcgfSpX1bk/Xc5AxXegaU6hpcMp0ZyT+fRKtiam2MILRjm347dNlihnT 7Ia4YptOYEwFAlq1WIAtrIomV6B5YX9u0gT67IQjzmRHz8mymxmqbKyI2ixVpZzv4aQWrW+wWO i/uqjJ8tec8lFe9QNylhL+e3 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 01:40:10 -0700 IronPort-SDR: cB91D50I+Uae0uto9At4gJmXxhv3HcX3NqPwi/nNr7PTsbErYOqqYqIumdguW3nSPMEdwgeEfl AH0HS/QRnOwl9dTZsME/T3Ozk+sMA3VHMTyCv1HIixgnWgFEIyt7x7ac+V+z2jdOJgDJ7SIZYJ p5KCGPlnHaTr79VcPAZ9MJLClJyQv/E89hKX6JAS1TNFtepBQldB2Ap9lhLQHLku1j73heVU/9 8Iftpvx3I2iEIrNA2JNYMkpJp/WuIYPix6SL4U1e37ELHQh5I9XqTEzxzaOZ64KO8YDiX856Vl Ez0= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Aug 2021 02:02:35 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani Subject: [PATCH 1/7] libata: cleanup device sleep capability detection Date: Mon, 2 Aug 2021 18:02:26 +0900 Message-Id: <20210802090232.1166195-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210802090232.1166195-1-damien.lemoal@wdc.com> References: <20210802090232.1166195-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Move the code to retrieve the device sleep capability and timings out of ata_dev_configure() into the helper function ata_dev_config_devslp(). While at it, mark the device as supporting the device sleep capability only if the sata settings page was retrieved successfully to ensure that the timing information is correctly initialized. Signed-off-by: Damien Le Moal --- drivers/ata/libata-core.c | 55 +++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 61c762961ca8..9b39a4e2e567 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2363,6 +2363,37 @@ static void ata_dev_config_trusted(struct ata_device *dev) dev->flags |= ATA_DFLAG_TRUSTED; } +static void ata_dev_config_devslp(struct ata_device *dev) +{ + u8 *sata_setting = dev->link->ap->sector_buf; + unsigned int err_mask; + int i, j; + + /* + * Check device sleep capability. Get DevSlp timing variables + * from SATA Settings page of Identify Device Data Log. + */ + if (!ata_id_has_devslp(dev->id)) + return; + + err_mask = ata_read_log_page(dev, + ATA_LOG_IDENTIFY_DEVICE, + ATA_LOG_SATA_SETTINGS, + sata_setting, 1); + if (err_mask) { + ata_dev_dbg(dev, + "failed to get SATA Settings Log, Emask 0x%x\n", + err_mask); + return; + } + + dev->flags |= ATA_DFLAG_DEVSLP; + for (i = 0; i < ATA_LOG_DEVSLP_SIZE; i++) { + j = ATA_LOG_DEVSLP_OFFSET + i; + dev->devslp_timing[i] = sata_setting[j]; + } +} + /** * ata_dev_configure - Configure the specified ATA/ATAPI device * @dev: Target device to configure @@ -2565,29 +2596,7 @@ int ata_dev_configure(struct ata_device *dev) } } - /* Check and mark DevSlp capability. Get DevSlp timing variables - * from SATA Settings page of Identify Device Data Log. - */ - if (ata_id_has_devslp(dev->id)) { - u8 *sata_setting = ap->sector_buf; - int i, j; - - dev->flags |= ATA_DFLAG_DEVSLP; - err_mask = ata_read_log_page(dev, - ATA_LOG_IDENTIFY_DEVICE, - ATA_LOG_SATA_SETTINGS, - sata_setting, - 1); - if (err_mask) - ata_dev_dbg(dev, - "failed to get Identify Device Data, Emask 0x%x\n", - err_mask); - else - for (i = 0; i < ATA_LOG_DEVSLP_SIZE; i++) { - j = ATA_LOG_DEVSLP_OFFSET + i; - dev->devslp_timing[i] = sata_setting[j]; - } - } + ata_dev_config_devslp(dev); ata_dev_config_sense_reporting(dev); ata_dev_config_zac(dev); ata_dev_config_trusted(dev); From patchwork Mon Aug 2 09:02:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12413603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E294C4320E for ; Mon, 2 Aug 2021 09:03:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05A96610CC for ; Mon, 2 Aug 2021 09:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232940AbhHBJDE (ORCPT ); Mon, 2 Aug 2021 05:03:04 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:6561 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232856AbhHBJCs (ORCPT ); Mon, 2 Aug 2021 05:02:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1627894957; x=1659430957; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UsY3zNp+4Y74npaMKBNtjE5KDrgJ0zn2Z35nPaW5zAw=; b=Gy6xEpswTaRX/cFKp1hC7z1pOCCDTymYAaDrYfwVGaKoGEs5FZ4OVgpK p6dxD6yXslTPamOoMLQ7E0U3E0Wndj+rwyk4/pMJfQCGt9TcjpzsAfjVx srjU13QdkNNUhmfejjvy79pNvRMkxB4m+EgYopqdOPlptD1o8U1z3pl6q lgm06iJ0vYLrwpgAhhTkr3FHGDaMN7nZUZwzEkcIAiZ7PLhBkGmRjUnwr lQahc4bGPsC0uy96GzzrRMOFKvVuUGxIkPL1F208m/x5NWKeyrFcf/2tg UuYZMgdWoBBVzJTudkQtG4+puzG33D1JGJjyHuv6UtAnSo0XyRsEa58ML g==; X-IronPort-AV: E=Sophos;i="5.84,288,1620662400"; d="scan'208";a="180887618" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2021 17:02:35 +0800 IronPort-SDR: kta8M1woVs3bLcxqlGIRVr48DXQTmu1rk+dX5oRxMdJCoMPBaAPfnvw/MCiHX7tkCehVWeYeYa bBzrkOCJle2boHkv7Z+aoAuwjQKPWaH/r6JCdmj3GZ47elXRaGWuqPHnUAdxLoiw7rU12OdUT1 +tSHZ7lkmPK211LUxewU7xO07amgFu1l/ocTwx0DhiHCqaIbiDcRSUjugTZmEvKgvLg8MyKwiW nJ6NSKs0G3fFsUHsVlRehu6MNFKdCn5vB28dWu5PBr+n2q76BqT0+q45zv0zDKBLQsrqrSaail b5yqENajdawuSjuB/YfNTryG Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 01:40:11 -0700 IronPort-SDR: hDPe+nS0Z6HFpfRLqYn91XXcM27Q5PFchkFGfaY/sylQOz+vHRErky7KYwVB2iFBd6S42vTH+0 vw0r/bzSv3dQSxHeEOIKZx8HAhwYxv8uCNi4wMjYt/tqpbL5ptLZtl3cSiComBHhQhD0LSrIjY PLjur0cBlAZGt+qOkjKg7ngkBsTDFt8Qibk+kTcdc+R/2USZKDiYsyqBY69P7K6wo3WbqKRHQo GBMiXDW6zfkowJLTTSVYXWT558wBXBS5rRerabXtJrZiJwSvKQR7nIguAPn1HLGSedgtMwqt33 hFY= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Aug 2021 02:02:36 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani Subject: [PATCH 2/7] libata: cleanup ata_dev_configure() Date: Mon, 2 Aug 2021 18:02:27 +0900 Message-Id: <20210802090232.1166195-3-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210802090232.1166195-1-damien.lemoal@wdc.com> References: <20210802090232.1166195-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Introduce the helper functions ata_dev_config_lba() and ata_dev_config_chs() to configure the addressing capabilities of a device. Each helper takes a string as argument for the addressing information printed after these helpers execution completes. Signed-off-by: Damien Le Moal --- drivers/ata/libata-core.c | 110 ++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 51 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 9b39a4e2e567..1849f858761b 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2363,6 +2363,52 @@ static void ata_dev_config_trusted(struct ata_device *dev) dev->flags |= ATA_DFLAG_TRUSTED; } +static int ata_dev_config_lba(struct ata_device *dev, + char *info, size_t infosz) +{ + const u16 *id = dev->id; + int info_ofst; + + dev->flags |= ATA_DFLAG_LBA; + + if (ata_id_has_lba48(id)) { + dev->flags |= ATA_DFLAG_LBA48; + strcpy(info, "LBA48 "); + + if (dev->n_sectors >= (1UL << 28) && + ata_id_has_flush_ext(id)) + dev->flags |= ATA_DFLAG_FLUSH_EXT; + } else { + strcpy(info, "LBA "); + } + info_ofst = strlen(info); + + /* config NCQ */ + return ata_dev_config_ncq(dev, info + info_ofst, + infosz - info_ofst); +} + +static void ata_dev_config_chs(struct ata_device *dev, + char *info, size_t infosz) +{ + const u16 *id = dev->id; + + /* Default translation */ + dev->cylinders = id[1]; + dev->heads = id[3]; + dev->sectors = id[6]; + + if (ata_id_current_chs_valid(id)) { + /* Current CHS translation is valid. */ + dev->cylinders = id[54]; + dev->heads = id[55]; + dev->sectors = id[56]; + } + + snprintf(info, infosz, "CHS %u/%u/%u", + dev->cylinders, dev->heads, dev->sectors); +} + static void ata_dev_config_devslp(struct ata_device *dev) { u8 *sata_setting = dev->link->ap->sector_buf; @@ -2418,6 +2464,7 @@ int ata_dev_configure(struct ata_device *dev) char revbuf[7]; /* XYZ-99\0 */ char fwrevbuf[ATA_ID_FW_REV_LEN+1]; char modelbuf[ATA_ID_PROD_LEN+1]; + char lba_info[40]; int rc; if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { @@ -2539,61 +2586,22 @@ int ata_dev_configure(struct ata_device *dev) } if (ata_id_has_lba(id)) { - const char *lba_desc; - char ncq_desc[24]; - - lba_desc = "LBA"; - dev->flags |= ATA_DFLAG_LBA; - if (ata_id_has_lba48(id)) { - dev->flags |= ATA_DFLAG_LBA48; - lba_desc = "LBA48"; - - if (dev->n_sectors >= (1UL << 28) && - ata_id_has_flush_ext(id)) - dev->flags |= ATA_DFLAG_FLUSH_EXT; - } - - /* config NCQ */ - rc = ata_dev_config_ncq(dev, ncq_desc, sizeof(ncq_desc)); + rc = ata_dev_config_lba(dev, lba_info, sizeof(lba_info)); if (rc) return rc; - - /* print device info to dmesg */ - if (ata_msg_drv(ap) && print_info) { - ata_dev_info(dev, "%s: %s, %s, max %s\n", - revbuf, modelbuf, fwrevbuf, - ata_mode_string(xfer_mask)); - ata_dev_info(dev, - "%llu sectors, multi %u: %s %s\n", - (unsigned long long)dev->n_sectors, - dev->multi_count, lba_desc, ncq_desc); - } } else { - /* CHS */ - - /* Default translation */ - dev->cylinders = id[1]; - dev->heads = id[3]; - dev->sectors = id[6]; - - if (ata_id_current_chs_valid(id)) { - /* Current CHS translation is valid. */ - dev->cylinders = id[54]; - dev->heads = id[55]; - dev->sectors = id[56]; - } + ata_dev_config_chs(dev, lba_info, sizeof(lba_info)); + } - /* print device info to dmesg */ - if (ata_msg_drv(ap) && print_info) { - ata_dev_info(dev, "%s: %s, %s, max %s\n", - revbuf, modelbuf, fwrevbuf, - ata_mode_string(xfer_mask)); - ata_dev_info(dev, - "%llu sectors, multi %u, CHS %u/%u/%u\n", - (unsigned long long)dev->n_sectors, - dev->multi_count, dev->cylinders, - dev->heads, dev->sectors); - } + /* print device info to dmesg */ + if (ata_msg_drv(ap) && print_info) { + ata_dev_info(dev, "%s: %s, %s, max %s\n", + revbuf, modelbuf, fwrevbuf, + ata_mode_string(xfer_mask)); + ata_dev_info(dev, + "%llu sectors, multi %u, %s\n", + (unsigned long long)dev->n_sectors, + dev->multi_count, lba_info); } ata_dev_config_devslp(dev); From patchwork Mon Aug 2 09:02:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12413609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68E9AC00143 for ; Mon, 2 Aug 2021 09:03:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 501C860F39 for ; Mon, 2 Aug 2021 09:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233014AbhHBJDQ (ORCPT ); Mon, 2 Aug 2021 05:03:16 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:6555 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232814AbhHBJCv (ORCPT ); Mon, 2 Aug 2021 05:02:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1627894960; x=1659430960; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9Tbl+ZYaDpBVRwr+peFFdheaVaDWXB+rHBnYavgl5IE=; b=aRQKvT3wkohCNbiKz8YBELHTGpHVPGwSh9LMoJ7+3CDPjYwCArqG16I7 G+qeDQcvf4jfmDQ9yzpSAmXnI461zroCJls8co1KDvAD/5JVlU+iZ7qz+ P/YNvs9fwJQ+HthNxvmMniYdXJ45ay3fZFiRr1AxwEGCDyK0GWNkD4Bc+ pN/NwNKvR2xh4t29O3Opwx8xUuVUJoJc4HphWk+LOPSWHeGo4cIghyg66 wAa3HuFRyMF8uXxF/zP/4ZEFj5LmIIF9+CqQecL1rL61YX1GM3Rt2IEKC rvoDIcvddL0iiVqQZAmYuEJt8VKk+eltd+q5kmfvzsHmRR5rJxObCuvIw w==; X-IronPort-AV: E=Sophos;i="5.84,288,1620662400"; d="scan'208";a="180887620" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2021 17:02:36 +0800 IronPort-SDR: yANogrtc5D0nQfqLUgtfbVPJg2KifXnMx+CLlcr0xspWers4iNI+nBKk9fKT7xBgfX8Ev568yV dmCYmuKxQYCTOcb83wB1fbDBzmn/BFZ0WUPL6S4YmjM3oxJtxvBVYHjPYlM+k+grsd3LA4rWSc KuWQ+iPZmQdA904pn259lUcm8kqlusNVaswk69jilQrmTsNw0u2hxuTSh9IRL/VZF7p1UKN2XZ 9IWq4CJD2xLaX5EOg9tdkvKk+CdAWzv9jNdV0QevkANv72DsmSZ9nZ7pVAeX33c4u/FvZpI24t DT892Hu1Ylk17xpRLK0kuU+G Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 01:40:13 -0700 IronPort-SDR: UwxAmegxJfFLnLnYo0VM7dIKc3afNkMlH6hRsiMgHAqo3pLpFeBN29h9z/KipAKTX374yX0lDn bEFsV6On1RGDOLjL8JB2N3Lcg0iIaFM0EGbFx1+NbQjwjEPwtVdQQ90O4fKnw7bJvQNGVf6LkF nHTuTAw3Vh0OR1EvLujZ95z++3y8/2AMr2oOLBO8S5pyQYPoOVHtxbb+8gxcQxBaDK9PJeTlgd eMeo9VUL2j2aQWNyI3joGVS6x0hREYEZNVii3aILaOW/VKztBWgFIC/Rl1NexLieegcJ3izCos 0J4= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Aug 2021 02:02:38 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani Subject: [PATCH 3/7] libata: cleanup NCQ priority handling Date: Mon, 2 Aug 2021 18:02:28 +0900 Message-Id: <20210802090232.1166195-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210802090232.1166195-1-damien.lemoal@wdc.com> References: <20210802090232.1166195-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The ata device flag ATA_DFLAG_NCQ_PRIO indicates if a device supports the NCQ Priority feature while the ATA_DFLAG_NCQ_PRIO_ENABLE device flag indicates if the feature is enabled. Enabling NCQ priority use is controlled by the user through the device sysfs attribute ncq_prio_enable. As a result, the ATA_DFLAG_NCQ_PRIO flag should not be cleared when ATA_DFLAG_NCQ_PRIO_ENABLE is not set as the device still supports the feature even after the user disables it. This leads to the following cleanups: - In ata_build_rw_tf(), set a command high priority bit based on the ATA_DFLAG_NCQ_PRIO_ENABLE flag, not on the ATA_DFLAG_NCQ flag. That is, set a command high priority only if the user enabled NCQ priority use. - In ata_dev_config_ncq_prio(), ATA_DFLAG_NCQ_PRIO should not be cleared if ATA_DFLAG_NCQ_PRIO_ENABLE is not set. If the device does not support NCQ priority, both ATA_DFLAG_NCQ_PRIO and ATA_DFLAG_NCQ_PRIO_ENABLE must be cleared. With the above ata_dev_config_ncq_prio() change, ATA_DFLAG_NCQ_PRIO flag is set on device scan and revalidation. There is no need to trigger a device revalidation in ata_ncq_prio_enable_store() when the user enables the use of NCQ priority. Remove the revalidation code from that funciton to simplify it. Also change the return value from -EIO to -EINVAL when a user tries to enable NCQ priority for a device that does not support this feature. While at it, also simplify ata_ncq_prio_enable_show(). Overall, there is no functional change introduced by this patch. Signed-off-by: Damien Le Moal --- drivers/ata/libata-core.c | 32 ++++++++++++++------------------ drivers/ata/libata-sata.c | 37 ++++++++++++------------------------- 2 files changed, 26 insertions(+), 43 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 1849f858761b..21afb59f359f 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -706,11 +706,9 @@ 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 (class == IOPRIO_CLASS_RT) - tf->hob_nsect |= ATA_PRIO_HIGH << - ATA_SHIFT_PRIO; - } + if (dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE && + class == IOPRIO_CLASS_RT) + tf->hob_nsect |= ATA_PRIO_HIGH << ATA_SHIFT_PRIO; } else if (dev->flags & ATA_DFLAG_LBA) { tf->flags |= ATA_TFLAG_LBA; @@ -2173,11 +2171,6 @@ static void ata_dev_config_ncq_prio(struct ata_device *dev) struct ata_port *ap = dev->link->ap; unsigned int err_mask; - if (!(dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE)) { - dev->flags &= ~ATA_DFLAG_NCQ_PRIO; - return; - } - err_mask = ata_read_log_page(dev, ATA_LOG_IDENTIFY_DEVICE, ATA_LOG_SATA_SETTINGS, @@ -2185,18 +2178,21 @@ static void ata_dev_config_ncq_prio(struct ata_device *dev) 1); if (err_mask) { ata_dev_dbg(dev, - "failed to get Identify Device data, Emask 0x%x\n", + "failed to get SATA settings log, Emask 0x%x\n", err_mask); - return; + goto not_supported; } - if (ap->sector_buf[ATA_LOG_NCQ_PRIO_OFFSET] & BIT(3)) { - dev->flags |= ATA_DFLAG_NCQ_PRIO; - } else { - dev->flags &= ~ATA_DFLAG_NCQ_PRIO; - ata_dev_dbg(dev, "SATA page does not support priority\n"); - } + if (!(ap->sector_buf[ATA_LOG_NCQ_PRIO_OFFSET] & BIT(3))) + goto not_supported; + + dev->flags |= ATA_DFLAG_NCQ_PRIO; + + return; +not_supported: + dev->flags &= ~ATA_DFLAG_NCQ_PRIO_ENABLE; + dev->flags &= ~ATA_DFLAG_NCQ_PRIO; } static int ata_dev_config_ncq(struct ata_device *dev, diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c index 8adeab76dd38..dc397ebda089 100644 --- a/drivers/ata/libata-sata.c +++ b/drivers/ata/libata-sata.c @@ -839,23 +839,17 @@ static ssize_t ata_ncq_prio_enable_show(struct device *device, char *buf) { struct scsi_device *sdev = to_scsi_device(device); - struct ata_port *ap; + struct ata_port *ap = ata_shost_to_port(sdev->host); 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) { + if (!dev) rc = -ENODEV; - goto unlock; - } - - ncq_prio_enable = dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE; - -unlock: + else + ncq_prio_enable = dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE; spin_unlock_irq(ap->lock); return rc ? rc : snprintf(buf, 20, "%u\n", ncq_prio_enable); @@ -869,7 +863,7 @@ static ssize_t ata_ncq_prio_enable_store(struct device *device, struct ata_port *ap; struct ata_device *dev; long int input; - int rc; + int rc = 0; rc = kstrtol(buf, 10, &input); if (rc) @@ -883,27 +877,20 @@ static ssize_t ata_ncq_prio_enable_store(struct device *device, return -ENODEV; spin_lock_irq(ap->lock); + + if (!(dev->flags & ATA_DFLAG_NCQ_PRIO)) { + rc = -EINVAL; + goto unlock; + } + if (input) dev->flags |= ATA_DFLAG_NCQ_PRIO_ENABLE; else dev->flags &= ~ATA_DFLAG_NCQ_PRIO_ENABLE; - dev->link->eh_info.action |= ATA_EH_REVALIDATE; - dev->link->eh_info.flags |= ATA_EHI_QUIET; - ata_port_schedule_eh(ap); +unlock: spin_unlock_irq(ap->lock); - ata_port_wait_eh(ap); - - if (input) { - spin_lock_irq(ap->lock); - if (!(dev->flags & ATA_DFLAG_NCQ_PRIO)) { - dev->flags &= ~ATA_DFLAG_NCQ_PRIO_ENABLE; - rc = -EIO; - } - spin_unlock_irq(ap->lock); - } - return rc ? rc : len; } From patchwork Mon Aug 2 09:02:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12413607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 843B5C43214 for ; Mon, 2 Aug 2021 09:03:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D2A260F39 for ; Mon, 2 Aug 2021 09:03:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233009AbhHBJDP (ORCPT ); Mon, 2 Aug 2021 05:03:15 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:6561 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232854AbhHBJCv (ORCPT ); Mon, 2 Aug 2021 05:02:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1627894960; x=1659430960; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LnD1J8RQFYPIisOr7xZNxesFu45GSlyRNMneORoQlkA=; b=Atugjh0G+U965BuA4jRCo9iqQ+8mPKxXESaCmEiq6kvTKo2gHfS0vjHH jIFeIyGR4XzIItmYAjC4Ad3whw2/xPfyScM7FiD1ca1VtBeUiyDWCi/+U 16BTZncX4G66TpiXUERBu7hPZP45XXwT2lHDUjsKG/tBzw7cjGQQd8P6p VWAWyrEfy5QRP9TLDwcKZ3D2DOMQAg+LHEQFN7Q97Tg8xMPw2uHnfw9gk LgS8X0WZe2QLqk7nJm/tiK5TmQj2ci1L0yVrMOPJUSwejB+2IF1fe0twZ MaTBmXdamaK7p7s13LTvB72sZ4K15j4WxWOkjBiXodlrOIrWsdKqVYh2f Q==; X-IronPort-AV: E=Sophos;i="5.84,288,1620662400"; d="scan'208";a="180887621" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2021 17:02:38 +0800 IronPort-SDR: HmQ281sALqFgLvu24R/N75GxjVJlffWOiCpmUCGut/yqEw33LH1oVFf54SyyuVHvi3/EMMTCKd KKnCtlWpMMaMvVl7Qqf3W9rO1onHC34iJNgYWrYgN1j8ic/C5/a0MWRV3JADdkJvFiwHIDv+rv z1u4+LxZw1BcpXJ2EAU8jKC2cVTa+FyyaESA9zPJAulr9SxIySDK/h7O6XZR+aXl2+I+mMOyzf n2UazEZA95cTSidSaih8AqLq4hzCsC7uUwZNVUaZTRQrFfNKyKLWNQ8rnZM05pkHfWntOOv4ZC qWgUkrekRWyKviqmud/l5n5+ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 01:40:14 -0700 IronPort-SDR: iQ/XHQ+ypLtnVV+oZ/uN33y6MJFPykQoZ9554kJWwf4q3P+S46IyGXb9hkd9g6xgq2E+cQ09dX y2rOj/jgGCey0cAc6GxnJhyuHD6FeoxvI75VYQsZHxCH6sIVcyY3RAAiLDp2+yu5T7c208Xarz WCMOEcKXL9VRwKwmKfFiDCKTuB8tsBkuLudyGa+CRfNpaGpVSkRLJN9aSrI00+ZjJW/YqwvIpX vZZEpoUr/3Iik5Msbm06NU7zyIoXetacE/0qetyJfrqBZQg/eK5dEtom8FNFNlP+30YIk9wukV 9qI= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Aug 2021 02:02:39 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani Subject: [PATCH 4/7] libata: fix ata_read_log_page() warning Date: Mon, 2 Aug 2021 18:02:29 +0900 Message-Id: <20210802090232.1166195-5-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210802090232.1166195-1-damien.lemoal@wdc.com> References: <20210802090232.1166195-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Support for the READ LOG PAGE DMA EXT command is indicated by words 119 and 120 of a device identify data. This is tested in ata_read_log_page() with ata_id_has_read_log_dma_ext() and the READ LOG PAGE DMA command used if the device reports supports for it. However, some devices lie about this support and using the DMA version of the command fails, generating the warning message "READ LOG DMA EXT failed, trying PIO". Since READ LOG PAGE DMA EXT is an optional command, this warning is not at all important but may be scary for the user. Change ata_read_log_page() to suppres this warning and to print an error message if both DMA and PIO attempts failed. With this change, there is no need to print again an error message when ata_read_log_page() returns an error. So simplify the users of this function. Signed-off-by: Damien Le Moal --- drivers/ata/libata-core.c | 47 +++++++++++---------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 21afb59f359f..68ef43de0ed2 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2021,13 +2021,15 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log, err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, buf, sectors * ATA_SECT_SIZE, 0); - if (err_mask && dma) { - dev->horkage |= ATA_HORKAGE_NO_DMA_LOG; - ata_dev_warn(dev, "READ LOG DMA EXT failed, trying PIO\n"); - goto retry; + if (err_mask) { + if (dma) { + dev->horkage |= ATA_HORKAGE_NO_DMA_LOG; + goto retry; + } + ata_dev_err(dev, "Read log page 0x%02x failed, Emask 0x%x\n", + (unsigned int)page, err_mask); } - DPRINTK("EXIT, err_mask=%x\n", err_mask); return err_mask; } @@ -2056,12 +2058,8 @@ static bool ata_identify_page_supported(struct ata_device *dev, u8 page) */ err = ata_read_log_page(dev, ATA_LOG_IDENTIFY_DEVICE, 0, ap->sector_buf, 1); - if (err) { - ata_dev_info(dev, - "failed to get Device Identify Log Emask 0x%x\n", - err); + if (err) return false; - } for (i = 0; i < ap->sector_buf[8]; i++) { if (ap->sector_buf[9 + i] == page) @@ -2125,11 +2123,7 @@ static void ata_dev_config_ncq_send_recv(struct ata_device *dev) } err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV, 0, ap->sector_buf, 1); - if (err_mask) { - ata_dev_dbg(dev, - "failed to get NCQ Send/Recv Log Emask 0x%x\n", - err_mask); - } else { + if (!err_mask) { u8 *cmds = dev->ncq_send_recv_cmds; dev->flags |= ATA_DFLAG_NCQ_SEND_RECV; @@ -2155,11 +2149,7 @@ static void ata_dev_config_ncq_non_data(struct ata_device *dev) } err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_NON_DATA, 0, ap->sector_buf, 1); - if (err_mask) { - ata_dev_dbg(dev, - "failed to get NCQ Non-Data Log Emask 0x%x\n", - err_mask); - } else { + if (!err_mask) { u8 *cmds = dev->ncq_non_data_cmds; memcpy(cmds, ap->sector_buf, ATA_LOG_NCQ_NON_DATA_SIZE); @@ -2176,12 +2166,8 @@ static void ata_dev_config_ncq_prio(struct ata_device *dev) ATA_LOG_SATA_SETTINGS, ap->sector_buf, 1); - if (err_mask) { - ata_dev_dbg(dev, - "failed to get SATA settings log, Emask 0x%x\n", - err_mask); + if (err_mask) goto not_supported; - } if (!(ap->sector_buf[ATA_LOG_NCQ_PRIO_OFFSET] & BIT(3))) goto not_supported; @@ -2342,11 +2328,8 @@ static void ata_dev_config_trusted(struct ata_device *dev) err = ata_read_log_page(dev, ATA_LOG_IDENTIFY_DEVICE, ATA_LOG_SECURITY, ap->sector_buf, 1); - if (err) { - ata_dev_dbg(dev, - "failed to read Security Log, Emask 0x%x\n", err); + if (err) return; - } trusted_cap = get_unaligned_le64(&ap->sector_buf[40]); if (!(trusted_cap & (1ULL << 63))) { @@ -2422,12 +2405,8 @@ static void ata_dev_config_devslp(struct ata_device *dev) ATA_LOG_IDENTIFY_DEVICE, ATA_LOG_SATA_SETTINGS, sata_setting, 1); - if (err_mask) { - ata_dev_dbg(dev, - "failed to get SATA Settings Log, Emask 0x%x\n", - err_mask); + if (err_mask) return; - } dev->flags |= ATA_DFLAG_DEVSLP; for (i = 0; i < ATA_LOG_DEVSLP_SIZE; i++) { From patchwork Mon Aug 2 09:02:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12413611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D18BC4338F for ; Mon, 2 Aug 2021 09:03:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 305E660F9F for ; Mon, 2 Aug 2021 09:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233029AbhHBJDS (ORCPT ); Mon, 2 Aug 2021 05:03:18 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:6558 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232871AbhHBJCx (ORCPT ); Mon, 2 Aug 2021 05:02:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1627894962; x=1659430962; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f7WZKZcvvqTN7PtjxoPt6LREs35g8kRsrNmm7vSfhHM=; b=OyKp0A9AmUDrqLFwORoJhy6wWQDjAoHPeUTQ3rbYLFj/E+l5xboaL/ah RNty/1eh8BIsVMQLSNvFl5BM9GA8BbKSaKCH5BhxkLctBsYPx0codw97Q bhfKbx8cUuteVNGNUf0M95y1xvAo/WVW4FxBzOWp3PIR6giHxHU2HDHbd n4x6Uq52cCGqKrTS6+gt8NOfbsi8UWfua6So+Y1yuP8UpcApb5ArXXNtP UlnnRrugjhKtiiT+8X9fBRELledhGALYXVn0h/CJeCvDwh4c1bzKp9YGW lYXahgLaOBqF2d7OvBUpd5U4mE/ZrGJ9UA9PH7LX+by5Y2pHSFNfXQwHP w==; X-IronPort-AV: E=Sophos;i="5.84,288,1620662400"; d="scan'208";a="180887623" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2021 17:02:39 +0800 IronPort-SDR: ukHWnnHN/VEWy1E6dP8Dy7/VUeJofaORJEI1sRJ3eRxNUU8ETtwNCbqPuJBytK9SN1/ts0kn8v 0NXThDzxXGkhhBLGJV9FxLD00PwRTgWES76/BYkp/RuyNLBWG1Sdj/t2WC9FdqnDAo88GlABa3 +YrgY72vd6rRELLXmR4yF7XntqPczfuwu/Wdww4zP3yIqazIyF7/c9DEYnmi6/9v0NlpKRSPE4 Em/ZWMlY4m1i6T72EkjfoaE33cPLr9a6Nrv3Of6+90003b9o9iGIK0dx61fJXgb/Jnt+8iZJLt jlIYTB0XRxjdRgg8j/+78QFu Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 01:40:16 -0700 IronPort-SDR: tGWIFYFfs5yhQm9H+hRYXPM5/PSjDZBZs1ZMuKtX+WsWTfq5wpXkOtCE1yB76ozyGDRHizleNi cPiiKmmWtULxQJa81lM02Hq2XB/RtMym2SYXWLJRR/OE0f7giYMnAYc/CfUF86pNWcwckYiir/ kLeXKgTL6tVYlftpDD+Rp5VenjAUCW12vb/th3+eGiQizqxOuXDOF/lga6M7zCmAhjI8QqxU0d XkRCY99CeDTDtCl8H3Y0dwnEfKTEhEuwEqTT0sxksVoqeQmNz9tq/KILgQVHCpXr7vGsDqzEqA JHk= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Aug 2021 02:02:41 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani Subject: [PATCH 5/7] libata: print feature list on device scan Date: Mon, 2 Aug 2021 18:02:30 +0900 Message-Id: <20210802090232.1166195-6-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210802090232.1166195-1-damien.lemoal@wdc.com> References: <20210802090232.1166195-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Print a list of features supported by a drive when it is configured in ata_dev_configure() using the new function ata_dev_print_features(). The features printed are not already advertized and are: trusted send-recev support, device attention support, device sleep support, NCQ send-recv support and NCQ priority support. Signed-off-by: Damien Le Moal --- drivers/ata/libata-core.c | 17 +++++++++++++++++ include/linux/libata.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 68ef43de0ed2..77118719e494 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2415,6 +2415,20 @@ static void ata_dev_config_devslp(struct ata_device *dev) } } +static void ata_dev_print_features(struct ata_device *dev) +{ + if (!(dev->flags & ATA_DFLAG_FEATURES_MASK)) + return; + + ata_dev_info(dev, + "Features:%s%s%s%s%s\n", + dev->flags & ATA_DFLAG_TRUSTED ? " Trust" : "", + dev->flags & ATA_DFLAG_DA ? " Dev-Attention" : "", + dev->flags & ATA_DFLAG_DEVSLP ? " Dev-Sleep" : "", + dev->flags & ATA_DFLAG_NCQ_SEND_RECV ? " NCQ-sndrcv" : "", + dev->flags & ATA_DFLAG_NCQ_PRIO ? " NCQ-prio" : ""); +} + /** * ata_dev_configure - Configure the specified ATA/ATAPI device * @dev: Target device to configure @@ -2584,6 +2598,9 @@ int ata_dev_configure(struct ata_device *dev) ata_dev_config_zac(dev); ata_dev_config_trusted(dev); dev->cdb_len = 32; + + if (ata_msg_drv(ap) && print_info) + ata_dev_print_features(dev); } /* ATAPI-specific feature tests */ diff --git a/include/linux/libata.h b/include/linux/libata.h index 3fcd24236793..b23f28cfc8e0 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -161,6 +161,10 @@ enum { ATA_DFLAG_D_SENSE = (1 << 29), /* Descriptor sense requested */ ATA_DFLAG_ZAC = (1 << 30), /* ZAC device */ + ATA_DFLAG_FEATURES_MASK = ATA_DFLAG_TRUSTED | ATA_DFLAG_DA | \ + ATA_DFLAG_DEVSLP | ATA_DFLAG_NCQ_SEND_RECV | \ + ATA_DFLAG_NCQ_PRIO, + ATA_DEV_UNKNOWN = 0, /* unknown device */ ATA_DEV_ATA = 1, /* ATA device */ ATA_DEV_ATA_UNSUP = 2, /* ATA device (unsupported) */ From patchwork Mon Aug 2 09:02:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12413613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5134AC4338F for ; Mon, 2 Aug 2021 09:03:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38FF4610A7 for ; Mon, 2 Aug 2021 09:03:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232888AbhHBJDZ (ORCPT ); Mon, 2 Aug 2021 05:03:25 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:6561 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232875AbhHBJCz (ORCPT ); Mon, 2 Aug 2021 05:02:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1627894964; x=1659430964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8XjriTNRfkHpzNkE2dEravGJzqEPs8r8H0bC3ba6Ylw=; b=OJvhMctpgswapmXrmTbi/GDbrZBN1P/RtRTmlrgCf9q/X/rv6XY0J7Ns UGxonaEjo0tSXZWYuF24DVDK2bPkoQZJQu/m1vGVTjuNqML0ECvrnpSb1 mapCI78nhK7JKpVmZuKWyMzreAsm596u72pAPETybq129ytX2wz1AoQbB dqlAfC5g9f6ZmCOrq/kJTt3MZK1vot86+Zae0V5lQToFGTl7aTncr2ZNp MNjwpMEv9+cOtH/F1mguKfAwFCwCddDSOfbfN0Kfk7HKtumRHyqum8l04 9cBZIoSdxtjpoHamKXD6hRpqbWTDJ3Ug9pNEFvefHjS2uCXvSdhpR/BPY Q==; X-IronPort-AV: E=Sophos;i="5.84,288,1620662400"; d="scan'208";a="180887625" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2021 17:02:41 +0800 IronPort-SDR: Y427aJf2VxpBkaEfic4MOv23kzrhhRyi0YF41AmOqF9cUoIc7bc9Lr/tA8ucsOeLFO9kOKxoU4 TC3SiV7bKkNwwAkjPCb7O8aRfyNXQa0AvG7v5cFqNNA0i/7dxKH8UHdMeUjuboDjUWuETTNN8C ANAnTWYNm8H9ECKr9A/5aFlLL8QOWysWNljXKMdY+5O8V8mxG3SbPnhZy7AfaqH+QgjRTrRlLn Kny7QNBZnnkigwD9tom2WfgfmQEAfFklybfZl1qG7wotZL4xewn5NxNg1s/cXA63XF0AQEq6I1 hCwZrVictqk40a4L3yfQFUjH Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 01:40:18 -0700 IronPort-SDR: U6fhYddiq00W0X9oFl/7enRHYG4dZe5L+CWEZhJa17a+K5aNJenwRLqqCRaU16bmng3cnK+8NS EWQhygYs7/fknHIocZa2yqBFq4n03FoogB6AIvhcHMTSbhaHx1K9aYk7Z/TDZ/zF1Jw+6G+zrJ KHpb8jc8wkqYhaOk07CwccWnC1CdNN+C+1/gMIYV71dtyJi13wutF3aTrPjTtcM7wymyu3qYjS W3iOABSJbmGUf1loYpKe/sgulVikTgKx8yPbBEkLQp1U1yUjzXnHkVefD28FNm0vi63cXAHYbl dHw= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Aug 2021 02:02:42 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani Subject: [PATCH 6/7] libahci: Introduce ncq_prio_supported sysfs sttribute Date: Mon, 2 Aug 2021 18:02:31 +0900 Message-Id: <20210802090232.1166195-7-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210802090232.1166195-1-damien.lemoal@wdc.com> References: <20210802090232.1166195-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Currently, the only way a user can determine if a SATA device supports NCQ priority is to try to enable the use of this feature using the ncq_prio_enable sysfs device attribute. If enabling the feature fails, it is because the device does not support NCQ priority. Otherwise, the feature is enabled and indicates that the device supports NCQ priority. Improve this odd interface by introducing the read-only ncq_prio_supported sysfs device attribute to indicate if a SATA device supports NCQ priority. The value of this attribute reflects if the device flag ATA_DFLAG_NCQ_PRIO is set or cleared. Signed-off-by: Damien Le Moal --- drivers/ata/libahci.c | 1 + drivers/ata/libata-sata.c | 24 ++++++++++++++++++++++++ include/linux/libata.h | 1 + 3 files changed, 26 insertions(+) diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index fec2e9754aed..5b3fa2cbe722 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -125,6 +125,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_supported, &dev_attr_ncq_prio_enable, NULL }; diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c index dc397ebda089..4a067384086b 100644 --- a/drivers/ata/libata-sata.c +++ b/drivers/ata/libata-sata.c @@ -834,6 +834,30 @@ DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, ata_scsi_lpm_show, ata_scsi_lpm_store); EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); +static ssize_t ata_ncq_prio_supported_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct ata_port *ap = ata_shost_to_port(sdev->host); + struct ata_device *dev; + bool ncq_prio_supported; + int rc = 0; + + spin_lock_irq(ap->lock); + dev = ata_scsi_find_dev(ap, sdev); + if (!dev) + rc = -ENODEV; + else + ncq_prio_supported = dev->flags & ATA_DFLAG_NCQ_PRIO; + spin_unlock_irq(ap->lock); + + return rc ? rc : snprintf(buf, 20, "%u\n", ncq_prio_supported); +} + +DEVICE_ATTR(ncq_prio_supported, S_IRUGO, ata_ncq_prio_supported_show, NULL); +EXPORT_SYMBOL_GPL(dev_attr_ncq_prio_supported); + static ssize_t ata_ncq_prio_enable_show(struct device *device, struct device_attribute *attr, char *buf) diff --git a/include/linux/libata.h b/include/linux/libata.h index b23f28cfc8e0..a2d1bae7900b 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -539,6 +539,7 @@ typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes) extern struct device_attribute dev_attr_unload_heads; #ifdef CONFIG_SATA_HOST extern struct device_attribute dev_attr_link_power_management_policy; +extern struct device_attribute dev_attr_ncq_prio_supported; 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; From patchwork Mon Aug 2 09:02:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12413615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31766C432BE for ; Mon, 2 Aug 2021 09:03:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C24161057 for ; Mon, 2 Aug 2021 09:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233061AbhHBJD2 (ORCPT ); Mon, 2 Aug 2021 05:03:28 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:6555 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232881AbhHBJCz (ORCPT ); Mon, 2 Aug 2021 05:02:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1627894964; x=1659430964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HdzMOU/LeJVtqgIQ0L6R3yYK3hsl5WlTjCJZhu0jSx8=; b=iECMfPH+XpISIYPyRXExLOB6eWUQHsZ9sb9ueeCnzbMgD8OFIs7QJXxZ i209Kzc0hdV2dRHCAUfhmB8JAwyV0zIi2DOYeWOZHyELHg0VZIC6knzRj MghZfYmIsCKxwDhkJlwlOklD+jQuSoKGA3TWS+J7AMWmWMqS1zPeJ5X2q BDvJHQUcLH/lzOj5APV/VeHGhS/6NxjEC3Qf7230WeHuj54uOIoNI9/bA duquHK/QzsIYxSCRAY9anJb2Ku8zC3rzc35EVfhi5IQQIn0I9oXScTqFr 4/EC+tf086SyaJhiTubSMHKqKYtQfuN23sZKLQAnTcKphhtSX/MiWkVAP g==; X-IronPort-AV: E=Sophos;i="5.84,288,1620662400"; d="scan'208";a="180887627" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Aug 2021 17:02:43 +0800 IronPort-SDR: mOCb55JzHUAUsLIQdh6PZ3d3u8sdARBsH5mQuE6QjlTWc0/iwKD5d+ua6XZ4EVFuB9G36azQw4 qs8AydeAsoONREZk51w5jK0y6hRtdQ5g1M3iZb1M09WkRu0OXDRTclreZCVy+16/xnjTkBMt4q +3QqxTQehm9YLhjjNYSysZ6vpaF//Mb2skR14ovin1o2FfYMH5Ogw+QW2T7N0A3k6O94XNUbkR XHp3Hr1bM5MpF6aAD+UWxDBcfCyq0aRYzgkt0SLoiZWy2TzbBNUd53mGDIe3B/iiqkYTBX3YOQ 2R5/K949H93Ui3rWTrk6Scmx Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 01:40:19 -0700 IronPort-SDR: oNBX9ORnT0Cm8EZHt+dJBibyRuKOAB63u0ptFs80pIzE8t/EhYYUkKZcaakISD0kOyx1c8xrBX 5yiRkMXOveGqW9/wUn5IcYzqdvMgue+hQ0XoXwIKiXBTm9LAvjfKqMIWivuAJxDo5XcfWkWofd w/vjFIQoYJL65paBrJmW0At7NsZNNHLnQ7oifyGB4/s3d2xdmgWceWNQ8IOLConYzJZrwlJnxu o3zIS2Rs81rdszgSqShBpAwNEZVGjaWKDh1/lMAk3oT6gL5QtkXqI4ioVr2ImSCP/t+0EnAPrl RHk= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Aug 2021 02:02:44 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, linux-ide@vger.kernel.org, "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani Subject: [PATCH 7/7] scsi: mpt3sas: Introduce sas_ncq_prio_supported sysfs sttribute Date: Mon, 2 Aug 2021 18:02:32 +0900 Message-Id: <20210802090232.1166195-8-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210802090232.1166195-1-damien.lemoal@wdc.com> References: <20210802090232.1166195-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Similarly to AHCI, introduce the device sysfs attribute sas_ncq_prio_supported to advertize if a SATA device supports the NCQ priority feature. Without this new attribute, the user can only discover if a SATA device supports NCQ priority by trying to enable the feature use with the sas_ncq_prio_enable sysfs device attribute, which fails when the device does not support high priroity commands. Signed-off-by: Damien Le Moal --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index b66140e4c370..7bce8288fb4f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -3918,6 +3918,25 @@ sas_device_handle_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(sas_device_handle); +/** + * sas_ncq_prio_supported_show - Indicate if device supports NCQ priority + * @dev: pointer to embedded device + * @attr: sas_ncq_prio_supported attribute desciptor + * @buf: the buffer returned + * + * A sysfs 'read/write' sdev attribute, only works with SATA + */ +static ssize_t +sas_ncq_prio_supported_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct scsi_device *sdev = to_scsi_device(dev); + + return snprintf(buf, PAGE_SIZE, "%d\n", + scsih_ncq_prio_supp(sdev)); +} +static DEVICE_ATTR_RO(sas_ncq_prio_supported); + /** * sas_ncq_prio_enable_show - send prioritized io commands to device * @dev: pointer to embedded device @@ -3960,6 +3979,7 @@ static DEVICE_ATTR_RW(sas_ncq_prio_enable); struct device_attribute *mpt3sas_dev_attrs[] = { &dev_attr_sas_address, &dev_attr_sas_device_handle, + &dev_attr_sas_ncq_prio_supported, &dev_attr_sas_ncq_prio_enable, NULL, };