From patchwork Fri Aug 6 07:42:44 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: 12422835 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.6 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 7EFE3C4338F for ; Fri, 6 Aug 2021 07:42:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DBE160F25 for ; Fri, 6 Aug 2021 07:42:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236261AbhHFHnL (ORCPT ); Fri, 6 Aug 2021 03:43:11 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:24064 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbhHFHnL (ORCPT ); Fri, 6 Aug 2021 03:43:11 -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=1628235775; x=1659771775; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bJFUvSu2jxaDKZ3bBp8YruRrixre9uNygCd7ppaDfh0=; b=Q5FO4Me3iCUuqMPW5gFqzpa0cOaGFF5pNNMGaoACeSE5xtFOQz5uLwWA lcUpdG8Cfl2xc9OV80D/LT/W6EiaCmLmaYGHp7+ZvdyKOjdLxHJZTW99k 0D52cxMcRFdhqQS96clb+maxE0qaaeBEGXOGT75vcEWPJu+G49x/ox3WA rWyrWS6Fxjr3MrozNVw6FuhMTSWlmTm/ZYkuradXKGMYeNsFWmBsH83v+ NsUHdUOiYUyMtd0sJdmiztz5vQL0XfiyG2HQf9SrmvbnXhZMyLZ9IR6yu 1trJ+ZlYstXdTU3lI5MnWQbbBGf9gd+gaK8TGdvhmevFwwMTODnZ6fM2o g==; X-IronPort-AV: E=Sophos;i="5.84,300,1620662400"; d="scan'208";a="181296842" 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; 06 Aug 2021 15:42:55 +0800 IronPort-SDR: 8URcNQSwGYqiQayFdzR74LVeIvtqgn/q1X++hXfFKR/YgK59fz7zwAz4d9HL6fOPhg4pCtgoZa mq85Hx4FSkTApMzOfGfN5+eRdHQjJm8a/74CgjLjG99ozvq1qBef9jlWrF7Zj8YpnXlbvP5tib C9mf1POQnk77espmRb6v4JsD18aMit873DHvIhTKteFOHQ81pPTsoWw9mio37jrvSx0hMdaJL0 TlZN1NckBVPQ7Frgm1nJDJvRO2n1PRssDOphjyaTKbRBF2DXMc/VlxprEEmV6feRi4a1awZE2Q //r4aq76UI63H6kh+9/orxhp 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; 06 Aug 2021 00:20:24 -0700 IronPort-SDR: A2skzo8YiMqKPxtfUQJ9xPDwk6Nc7d8NKMe4JkFcWI9YGrxojj7oFCuT0v2ZQJCVtnvRFMtWnj iIKJnlblZJPYQlWyaeuvsb6Abc7/w586h4UUPkNuYZJVtHnG9yqlFVHSET3mnDMey4w8hHiPsL CRbLWw11FF21oWxuGoJQsNpZp7MId/OD4jBjV6LsCRLpYw/0K0c4xEsZnN0Qy2tc/qvroKDzjq SMhyJqDVGGDOLV3gcpo8QbREMfOYcMSliyc0FQpQlcvGA/TuIzdFsWzoX8OaY6KpyT3m8bRpz7 +qM= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Aug 2021 00:42:54 -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 v2 1/9] libata: fix ata_host_alloc_pinfo() Date: Fri, 6 Aug 2021 16:42:44 +0900 Message-Id: <20210806074252.398482-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210806074252.398482-1-damien.lemoal@wdc.com> References: <20210806074252.398482-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Avoid a potential NULL pointer dereference by testing that the ATA port info variable "pi". Reported-by: kernel test robot Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke --- drivers/ata/libata-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 61c762961ca8..ea8b91297f12 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5458,7 +5458,7 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev, ap->link.flags |= pi->link_flags; ap->ops = pi->port_ops; - if (!host->ops && (pi->port_ops != &ata_dummy_port_ops)) + if (!host->ops && pi && pi->port_ops != &ata_dummy_port_ops) host->ops = pi->port_ops; } From patchwork Fri Aug 6 07:42:45 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: 12422837 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.6 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 539FCC432BE for ; Fri, 6 Aug 2021 07:43:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3788360F25 for ; Fri, 6 Aug 2021 07:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239122AbhHFHnS (ORCPT ); Fri, 6 Aug 2021 03:43:18 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:24064 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236860AbhHFHnN (ORCPT ); Fri, 6 Aug 2021 03:43:13 -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=1628235777; x=1659771777; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cNgb2TROU2WsZ1zU8ihpVY71OcdgiBcGbW7LESxTUo0=; b=cCFUR+zNI50BCRwv8Fc1Ed5932PCzQegMa/5T0Ldg1OZlHXZ0e3StRDA 8Wspy3tBkurlyFCueU8QayzSKpRThC0LX1018k0ea8AJMigT1VaB3/XAP 0+iCrZQUYp9GygTAzJx/uhw8PMl4ZjwlXRp+9HPtEeXShNsH5T3+xvjIk A4htuM6WTpC4O5P56G3caTuOiYst9FdQ6TBqUKj4CJDyl/gx5BEjT8qW5 Z4b5PM3R7AHHfNSJbrAWa7/dxP7VN1AfiT7VUMXcLe966ZXFkq6GbJ+ha FQzBBlnw1aY3hNPpbYBS5kUxdIt6dTg2styr1AUJ+mYMCmkOSSCerFW9b w==; X-IronPort-AV: E=Sophos;i="5.84,300,1620662400"; d="scan'208";a="181296847" 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; 06 Aug 2021 15:42:57 +0800 IronPort-SDR: lDVC/xls6cqjf7GOzaxjdZIeoG017ZDyNvZM2IlttAkZJ9tSQ07E3TZGPFdwfFcz4i403+4DDs VN5ZLMWW+GnI6rZOHNY65G43a81LOlTIuCYJa9OZr1m9nyfhdawGJzR1yuOQH21xZyp/kHUg6y GXmmTNQWSon9FqGCdq0x3AvE2evlwk56eCebPLkRL/En0z/7QM5KbvWLh5lduLvXex8cqCqLtm 9OD8bewGe/0V7DRSYZM0zacpM8sZG1e2wHIVCuj77+YXLYlRpkCSgK36PNpGADEsPwzimYWswV woS1bNvAdGhP3wHasdsBzwWU 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; 06 Aug 2021 00:20:25 -0700 IronPort-SDR: z/Nhu9Qg97cElW4dG7C3BRIhv/bpEniPzQevntb6xReHLZ1SST8yEdbUtBbtVCHs3pxjO66jmJ yambJo4aPmCyK0QF7rlkWTvpgU/RkguNsjzBL6Bb9ZxmNZq3Mh8uD+UKThziZNCLZKPyA+nSz+ HzPPUqKwcfQUepj92ymcN7Uu3/UDf3IyjtFccEsu+1ocu2Ijvdkt+EH5GZAE2hh4lAuFGk17vq /bK3wmcd/UtouN6TB/U91GTc4+aEHRrFyS5QDYTcvhAg8bEDnWKkFHvKONZvSWW56Nwv5aWS6z ML8= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Aug 2021 00:42:56 -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 v2 2/9] libata: fix ata_host_start() Date: Fri, 6 Aug 2021 16:42:45 +0900 Message-Id: <20210806074252.398482-3-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210806074252.398482-1-damien.lemoal@wdc.com> References: <20210806074252.398482-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The loop on entry of ata_host_start() may not initialize host->ops to a non NULL value. The test on the host_stop field of host->ops must then be preceded by a check that host->ops is not NULL. Reported-by: kernel test robot Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke --- drivers/ata/libata-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index ea8b91297f12..fe49197caf99 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5573,7 +5573,7 @@ int ata_host_start(struct ata_host *host) have_stop = 1; } - if (host->ops->host_stop) + if (host->ops && host->ops->host_stop) have_stop = 1; if (have_stop) { From patchwork Fri Aug 6 07:42:46 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: 12422839 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.6 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=ham 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 D0C71C43214 for ; Fri, 6 Aug 2021 07:43:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B94D8610FD for ; Fri, 6 Aug 2021 07:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239651AbhHFHnS (ORCPT ); Fri, 6 Aug 2021 03:43:18 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:24071 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237114AbhHFHnO (ORCPT ); Fri, 6 Aug 2021 03:43:14 -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=1628235778; x=1659771778; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fl178F5dJP4MrjAB3i84z1UPjR8a6z38mtu0l91vz0c=; b=jq24dfZkOtgmCZOgMQKMa0Dx6WuyDuvuofwutpJjkWIx4Iqg4W2WRvK7 NSWBaAgvANfJ7+yiOGyMB7f70nK3Wgb/9yIbWrysawK90Hwgo/JV7kFnI /uc+8V5HKr5BAiZ7Ln66S61BisG7ljRw0ILrH3D+4RKt0A44zrujVMRXf nW9C74oVAAJUhZ4aPW9aedDT7nl1F4rNDTS+BZSWkDYTF5J5P73ftyt6J 4nxIbag6KZVVP3VWuP7YVTftQLUGq5G65J9ykRF6nS+7jS27RCO11aIKI Me6mhhQ+GVZIbBDJspMzpsZEhxH4LUBsPZ8bmzof2OIcPa2OVrZH1CktC Q==; X-IronPort-AV: E=Sophos;i="5.84,300,1620662400"; d="scan'208";a="181296848" 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; 06 Aug 2021 15:42:58 +0800 IronPort-SDR: Z0Utv644KZAARpXSPue5ziqrUh8p3y9VNUhtagJ8vQLunRa/RIt6J95ioKq26K1MXPTotcRing sWHt1gtkfQ9XT5kp6RKXYPRp4jGJPZQEUCKTkMO19+E7o5sYHI9nJb/opNNGZscNoTfDBu4r1u k+cWkL1bjkYqbmD0sqj2LKwywXzFGPP/qbrvSeru4eB3Hqv2knDNf0L++izCkXKRDSqCEh65g3 psfCZxctSMMZh1c4p28oTs4birIdTnaC3xsRdYakcYSAGexqBKy7ixKxlS5SxPvMcIPcoNRhqH MuWAIcTwHR8Dls9rYZMP8I8U 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; 06 Aug 2021 00:20:27 -0700 IronPort-SDR: hxnQVcRG+RVxt5TNy2+i3atUir5L2heCClnd1puHSz63USDGYrCK4vWjAm2wZ5EvHMe/aQo/H0 /ooqtwOfmek9Qx5KQv6NqMP5CbrYKYzco3yqRsSihlpE/ogioSaPaXUgsYeWIDLA4Gfh/dBt+D fAPKbhimRLvAeGC7G8e2BWcNGkWz32/bqe5qEXCU8L7n02FU5zhgX+kIsAtWn6dMpS9ROOEwtq bOJ5HQvpyy8RZmw6TYv/aTntEo1gqfZ6knFJrXisIQSTqrDMz57MNcNO6Jm6bR9doY7KDg5QXn jog= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Aug 2021 00:42:57 -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 v2 3/9] libata: cleanup device sleep capability detection Date: Fri, 6 Aug 2021 16:42:46 +0900 Message-Id: <20210806074252.398482-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210806074252.398482-1-damien.lemoal@wdc.com> References: <20210806074252.398482-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@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 Reviewed-by: Hannes Reinecke --- 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 fe49197caf99..b13194432e5a 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 Fri Aug 6 07:42:47 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: 12422841 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.6 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 E240EC19F38 for ; Fri, 6 Aug 2021 07:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE3AE6113C for ; Fri, 6 Aug 2021 07:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238685AbhHFHnT (ORCPT ); Fri, 6 Aug 2021 03:43:19 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:24074 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238682AbhHFHnP (ORCPT ); Fri, 6 Aug 2021 03:43:15 -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=1628235780; x=1659771780; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/GKiBcGNCHf0CUSVfrIJTyG1d7bktg9vl+k7UAd6i/o=; b=b9p3MsgbUx4qa2jam2QdN+FGo3KrL5/DpH2bkbGwtkfvei2M3thoyXqf edd2bTPBPv/0/SKiybbUMVhgr311LTqwwgg1AIe13X74JLph+YqZ2APou l7kPCeyrqZdWAaiKSQU/6B2OyK9fRbX/bHnMDU5Nl3uvHRkW5BE9sJ75z PJlxCYRlpAGibkxtpVuJw0DALoAHJzClJs/Te4fygXEp7kV4YmzHPOTL7 L400XV2lH6riqBJ1VWWwzQXkHKWUwBbn15fgXgk9CkORWmXsDAdu6uGCd bhg+WVSP17XRFT94NBq4RfBhpSvRA4NCFaFshore1JpV/dt4mO8aD/nYs g==; X-IronPort-AV: E=Sophos;i="5.84,300,1620662400"; d="scan'208";a="181296849" 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; 06 Aug 2021 15:43:00 +0800 IronPort-SDR: AVYJqk3FCXQsr1CDddDPVcBmq2RMnqBEAbiD2SnpU9GROkTKKg13kBNSpcyjEyernGHLaARlhW tGRbrk9HBz7zZ+02sYqsFNLtDXheahfntZFWRy9dcCx0m07BY4UubLEXhPF3Hpn/bPPNTOoRhp Z0v4fdjvckj0ME/WMOsg/UO7KRdVL7VzOt5rMdursLAJU6OXpUZb0NVS76toNb0aCWsObpS/YW wlATbxAgzrWw05jR1DOj2jPLOXn/sAmm4R43H+m7Bok6kFphJukB0Z4VmcVKXVZQK/v/XezPIu NfOOMjwgzEA3jsRjB/HyAyD1 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; 06 Aug 2021 00:20:28 -0700 IronPort-SDR: y5vwB1t9n3hakKfYwHzE8HPyADy7ix4E9S9eVdpqtqKMI6G1Bcs1BSN8AVwSw2Ydl/3eBGX9BL aDf+4TIJiZIWoMK0Q7BIJ0c/8datMmNi//xQTq2exriqycue4z5tL11fBG/lJWGbq//Fo16F8b Vh67iPXYFj4cYVdXiOFJEg2hqINZ1OBg+rvrzhtOsuAOM23CJEUfUfXekTiOcQ3c3bzlJIVvJA B+SVpc/+zx0md5DIou3XAl/6F1rcvwVX/ng3h99sc/3H3r40YXL7VxPlXk3pPmH4BR5ekL+/L/ y10= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Aug 2021 00:42:59 -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 v2 4/9] libata: cleanup ata_dev_configure() Date: Fri, 6 Aug 2021 16:42:47 +0900 Message-Id: <20210806074252.398482-5-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210806074252.398482-1-damien.lemoal@wdc.com> References: <20210806074252.398482-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@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 b13194432e5a..2b6054cdd8fc 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; + strscpy(info, "LBA48 ", infosz); + + if (dev->n_sectors >= (1UL << 28) && + ata_id_has_flush_ext(id)) + dev->flags |= ATA_DFLAG_FLUSH_EXT; + } else { + strscpy(info, "LBA ", infosz); + } + 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 Fri Aug 6 07:42:48 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: 12422843 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.6 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 02FE8C19F39 for ; Fri, 6 Aug 2021 07:43:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA01E611CC for ; Fri, 6 Aug 2021 07:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237114AbhHFHnU (ORCPT ); Fri, 6 Aug 2021 03:43:20 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:24079 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239081AbhHFHnR (ORCPT ); Fri, 6 Aug 2021 03:43:17 -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=1628235782; x=1659771782; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=usGSvq6maWhsy2A1YASD6bEzuGG2tWNpEOItZgIURbs=; b=oPZa8QA4S7Kr3c6wocfEhmTb8ItWpIMjRd+7AjN6aWw5zgiTlOKFgH/O /ATjOkfOMOQhUsroUeXyWpBhevgj6FR0YKCfWuZeOCMP/ImMtEtYkHpdj laLmygfP8M4IO/LzqRTZEFW4+kaHNBvG+N0bED8VQ5vKNtNJ/Fgfugcl5 WDO8i7TY4GVJosr4hbsrVkXfHAh52TYkcFUazJu7/YnN5XcZy2/3dWZs5 SjzLSmrYH3q/dHMPPYb6205fp7ta1KSDZVfDq6Q6Y6tky3UHpqBoahGeV 7kBjGGqRTStorRygluQPEAPES6my6lU4h/OxyNms+LkWjP2xYQlSejZy3 A==; X-IronPort-AV: E=Sophos;i="5.84,300,1620662400"; d="scan'208";a="181296852" 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; 06 Aug 2021 15:43:01 +0800 IronPort-SDR: SHzYrDyQ1cewTi8VNQbe4afPkjt1cPyhTGDCbWJCq+awbcb7Pmcwpg6ilVGXrdxgUUPfm1f2o/ CCOcSsWSduupGE/YzdjsCmDhrzovvTk17pS68VfheuEg/vTuqAG/zKUyuXy9R08s3U/G7uhxFt HGzYCjVB9ZTnD5d3DQhY9PGpFTpViAsKcPaVZ6AEFVuZw7E2SYpVm82jPy49OgFE2WZ17VwkA6 hnaj/dWfv/76Cs7evkn8fyFQrBzFnhF/kJU8nO7unFkHnH8DC+UK8MPefCFidBcE+Q6nGuI76N sKFq+/aFQtFZcdsy/40c8APo 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; 06 Aug 2021 00:20:30 -0700 IronPort-SDR: vncz/1aOQHb3ZhuRDx8crZu16hrd7QJ7+Rt0yZqknucn7do4HETxpaa2aa+b3w79+lqBP7O4/O iEpJrqChyRrzstVP3ynjZzi/UWIIR51HafMmchcARINAf8U2qktIVDFV+TFY2qTllSoTSax0+d ui/xndbxPTY1j9lSwlIUBoYjCiZX1gOu9MpaazTKBu2OIzf29G3DpPQuZo+xDZSnZIHmrbFbts iKOIUSIAZQZcasJS6ckG8zsbpAQr1VDg7/Hbz87pcFFebKALNbqNFWpZ/v3i7Jg4sOUm9zxvq3 h3Q= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Aug 2021 00:43:01 -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 v2 5/9] libata: cleanup NCQ priority handling Date: Fri, 6 Aug 2021 16:42:48 +0900 Message-Id: <20210806074252.398482-6-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210806074252.398482-1-damien.lemoal@wdc.com> References: <20210806074252.398482-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@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 Reviewed-by: Hannes Reinecke --- 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 2b6054cdd8fc..b556401cc110 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 Fri Aug 6 07:42:49 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: 12422847 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.6 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 4E853C43214 for ; Fri, 6 Aug 2021 07:43:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FAD460F38 for ; Fri, 6 Aug 2021 07:43:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240583AbhHFHnW (ORCPT ); Fri, 6 Aug 2021 03:43:22 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:24088 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237731AbhHFHnT (ORCPT ); Fri, 6 Aug 2021 03:43:19 -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=1628235783; x=1659771783; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S5Y3bG6NIEAG8gtHiA4fje5arZx2YV3BaonuYZeLlKc=; b=cP+pDK+y97ktUfcY0R/4eGgd/nAWjmMTAhaf8WVrPTsixaVVtykXNaGU j9HRAj0wi2tWDWmhCMkjXM9O4W2dsJKweJ6fJ0kNM827Fei3E56C4T753 Blw3AI8aso9oLPuXA6tKkAuP7i9IXqYVcPmz3p6vUup/p15+2e3KVn9Y4 nyZLy+gnnfdSwwNGnudlPDLzGEkhDbD0jf5zUJ9pAcq0oHU+V44Dsy4XD 8Cfvqn2ZinWgMM9K2ATml4EBoOBLF+KtEjNvPZVjD+XQONsud3Yp3Tqeg EKjqgde622wy+IgrKazZ7C3TB8Fb1tp+rs/lhjFInfAiOupKf0umPUxrq w==; X-IronPort-AV: E=Sophos;i="5.84,300,1620662400"; d="scan'208";a="181296855" 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; 06 Aug 2021 15:43:03 +0800 IronPort-SDR: RF0NwlGhVnpbX1uVwkF8siOAMnXl+0AnhmuITi5+JU5Z1ZwdN4xOxCHaDxOd6Di43PrnHVKbvX DWSrtTh8Nt/bYLmAsW9PDuK5kHSM7FQjYUzWcdS73+062HqAo8aczSkznQ79Y+hXMxatq/Loh4 WIEUoAxAlNCOgQw4DhhuYCmAM67ZkN/rpduncUv5KnoDideh0ePZFly3M3c2cRR/kphxnUF8Za bUNyEah808Tli4wQLzy6JHTtnHx2JclZxKzptdu+x+9DeAOw5zmE37S88RGd+2LLklhe3ua81e SuZ9xcP2HpKZPBpYQd81MRjZ 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; 06 Aug 2021 00:20:32 -0700 IronPort-SDR: 8raPk64+yRWv4D+eNI6j5q9KY+7EQ2flHAYIenXvgp5CVUQah4n43oJiSOahwZnUKXH00WWG15 QpCIqTAG5Cp+oXNk9NOsSKnXkaH8EKXKTlVBXVnDxJwobqHuQtBAD0HmtkqD4pkACUKXy/CzSz 4CBxryb5+yGGyBIQ2OCBlaArQAf/fiMYTBrvA+zuPue2+VPPqpWS05sYMa4lq8CkwWNh4wJKPV fdW87ZaSUWDMKuKXJY+i3oLAzgvjhv9B3RlKOh2lal8uAlhzaOlyxv7y/y0hSggxpFQ9Tv2QZ9 XBE= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Aug 2021 00:43:02 -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 v2 6/9] libata: fix ata_read_log_page() warning Date: Fri, 6 Aug 2021 16:42:49 +0900 Message-Id: <20210806074252.398482-7-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210806074252.398482-1-damien.lemoal@wdc.com> References: <20210806074252.398482-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@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 Reviewed-by: Hannes Reinecke --- 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 b556401cc110..3c213d125e95 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 Fri Aug 6 07:42:50 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: 12422845 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.6 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=ham 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 29917C19F31 for ; Fri, 6 Aug 2021 07:43:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B4DC61050 for ; Fri, 6 Aug 2021 07:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240910AbhHFHnY (ORCPT ); Fri, 6 Aug 2021 03:43:24 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:24090 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238682AbhHFHnU (ORCPT ); Fri, 6 Aug 2021 03:43:20 -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=1628235785; x=1659771785; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ULciBzNUpJiXKFe0vahoPorjWXdHAnS2iZV514wtpz4=; b=ZNpH8CtcQlfhEQJdB7U9pAbbze0NgqoIYYa0ucFPnusECFaa04XwsD5b XBg0oIbQsDR7TIpMvOS3NbN7NIdR4XOh9NkVLoQw2D3FZDV+UFyeXV50+ f9YKTI2DutGSc/WpaEPpUGy6f0p/xoW5wwBgoouln58iyrM0QWLG8CiBq 3EN28u1BPiqyyiv2rWN9SCrhLolyeM+RHzrzVYN11WukB9uznLzZebNUH 9N6dEttgkNVv8BLUfMqN7Hcx0Rq4b8riTHwra+SFYYC1seUk8ckxehin0 fVwsVIgXw1IMtHISQe6HLiwj9JVuKudSr6LpyNQDk7uGciU8PqA38WQWw A==; X-IronPort-AV: E=Sophos;i="5.84,300,1620662400"; d="scan'208";a="181296859" 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; 06 Aug 2021 15:43:05 +0800 IronPort-SDR: 5U5RSpC37v6GG4jBnW3jzm8W+Z8xTDK1z/dEfxr2dTWNGLcEm6XnSWcp+mAToRsbV4GmRPg2Tl B5zxCCl+aL+rpux4QgyBGbxGA2Ny0wO8FXANPORp9TWSwnDTsUvPcTcI133ObxqtVww0qd3C32 Bc4XG19yTOJ46EVlYmbkbR0rm1f1QjNgxSNDhaCSsXnQiJTvgvYPw3YMuvM2WNPeSKGLtJ5cXf r60ml+WZ0WIPI4aGLth21A1hK4s6ZjuTOUM0tmKHXD9UZzDyWnMMEnQaItSbOJwE+xeqO6AeXi ejuDAYJ6sOdiPg1dgnBA73Y0 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; 06 Aug 2021 00:20:33 -0700 IronPort-SDR: fvXXs3hdmWAYGyA46+5rxnvGSrN76aiG0t8zQuh3+HcNcOcbJ7cwlEodw5dz0MApduQQEPVLpa CjRTqY70bRrv0p+08djAKCIsaZ/aShZ3e+A/N+QBc9dZdqNlkk7rU04EI9bzzbdFVVUqSsm4LA aJHgmS0SFC8+WalAavIAmagvZTMlm5NRd5ECILaOA/L6gaVPmWVwte6IxrnV+CxtYJYHfLtu7Q pqsM/1v/txHVmaF7qxs8XufhnKv2gIL5SMLdSuv7D/aMT9AJvdc/uhm85/pfE9t7mLYgKkTx6D OhA= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Aug 2021 00:43:04 -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 v2 7/9] libata: print feature list on device scan Date: Fri, 6 Aug 2021 16:42:50 +0900 Message-Id: <20210806074252.398482-8-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210806074252.398482-1-damien.lemoal@wdc.com> References: <20210806074252.398482-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@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 Reviewed-by: Hannes Reinecke --- 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 3c213d125e95..cef6d516b4d8 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 Fri Aug 6 07:42:51 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: 12422849 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.6 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 14B5DC432BE for ; Fri, 6 Aug 2021 07:43:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6B1861050 for ; Fri, 6 Aug 2021 07:43:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241166AbhHFHn0 (ORCPT ); Fri, 6 Aug 2021 03:43:26 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:24093 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240392AbhHFHnW (ORCPT ); Fri, 6 Aug 2021 03:43:22 -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=1628235786; x=1659771786; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dxUqBpMfBGL8QgT/G4aYqB14OK8eppkoSmc37wpGAVA=; b=q1rvwL6GdGYrrEnysLazGCqKlEURyGYX2Lz77GQUNXB2P7L9+Do3QQEn lV888T2mjlYKgYuQz6uxCIK+NcmNhkak/AJGGO4WRVQ2tmwqwtNjhZ+Zl y87no/zTIZGd2ZRy8YTVlH3w+yyWKEa19asIsVTN8EkI91A7UNs8XwK4f 8hO1lch39EpPPvxnAQUcX2Ll2d3wOX0Uoc+NnMbQtM13K/fU2BfLt8P7U 9b0h0eRmOECVar+ZmzJ4DDaE2/3RqIwJBiaILq6MdHEdjeePlVQzoX7yj hR2nunI23FEMd16MgSJn8hPEzqTlO3P/sq+or3PXZrvR5bQyPsIe3RIQr Q==; X-IronPort-AV: E=Sophos;i="5.84,300,1620662400"; d="scan'208";a="181296862" 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; 06 Aug 2021 15:43:06 +0800 IronPort-SDR: OVn+zhAm+ajheG8cfo9i5NIAn0xeJNOuV1Oz1xvNeyELG1BHz4Q4+b4J2mK2Ah6b1TBh2r3dRR 0cz1je3XWKi+YzCrMEH2gEGrjjfrjduzhlVKvCItHc4oPsWRVmW+icIqs4ISYRSu01zP0IewYp 1Q9DEdviSceZG9EXuPX5pS/kV5LrZT+Il24k2p0FFoUwITsxuDwTbfTVV/2YZYjqy7o+4Zeiyf 0K8MeXzo9zmCuqE23h6qV24ES18wF95OQ2nxTTMKTOs1nZGVrGaVMMrqP3dctr7twKiMJHp4C0 ccjMpsYC6PGvGFS8rkFtZTok 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; 06 Aug 2021 00:20:35 -0700 IronPort-SDR: dvH2ITMNED8Yc5D9k3khnKoOeYImeai83+ykB4R4PundXhR9Ir30Q70TaKH9VW1relrjf+MnHs askepwacX/RxcBKiKLP/wMxhFWnIunvTwZV6XajQkHIWOWoXv7pm5InqmmUMjZhbzGRo7Jmsk5 n6vFJNgXSlIYZnneO/zRDOwmZUY9SY4yBhk5fJk+FfipVboqtw1TaReNPRTa2KxPAJWnRNo4YB DtFpYBp0kIxSad/RgllC2bsjD9iG+4sD+JbOj7DXSALmJduFCurk33OQJ1y7tzSIpQQXGxPF2U 70c= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Aug 2021 00:43:05 -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 v2 8/9] libahci: Introduce ncq_prio_supported sysfs sttribute Date: Fri, 6 Aug 2021 16:42:51 +0900 Message-Id: <20210806074252.398482-9-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210806074252.398482-1-damien.lemoal@wdc.com> References: <20210806074252.398482-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@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..5566fd4bb38f 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 : sysfs_emit(buf, "%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 Fri Aug 6 07:42:52 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: 12422851 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.6 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 863CCC43214 for ; Fri, 6 Aug 2021 07:43:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68C9761050 for ; Fri, 6 Aug 2021 07:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241230AbhHFHn2 (ORCPT ); Fri, 6 Aug 2021 03:43:28 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:24098 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237731AbhHFHnX (ORCPT ); Fri, 6 Aug 2021 03:43:23 -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=1628235788; x=1659771788; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ULrEcE5t9wkFqxwczLZAuZuz5T9Sl9Ovubu3sAYR6Qo=; b=AStdzQb77kd6DzzqX1fmJas3iXXTl9vxD5IzcJGKJ4MW6Sp2ZoPLJf7/ aPzrxEgxhR7aPcEbRpUwMjglLQjcYMuYwncnzdwOedjval+Lrog5EG7OR Thvdygtbg5vu69UysagBTInQPCQks0j0yYqyfvlLyGNHGsbfoqYYVQ0Y4 Cs2uM7iHC1Fdotug/dH2khY7JFjYCy4I6es7XFD8gzneN0iqBUqwSv3rc IqKjfnU3M6zJzdL78unXZjUc3n5KP82KrdwfjZYyouIPJrESsUlw5IVJe ZK3EEMm4X8LNZp3qsDjdWbqrkXe+PNbGM+UeSrJR2nExpVr7DFIoU87ry Q==; X-IronPort-AV: E=Sophos;i="5.84,300,1620662400"; d="scan'208";a="181296867" 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; 06 Aug 2021 15:43:08 +0800 IronPort-SDR: iDg/ZjlVTAlTXFbgu5gH5ojiZgDdKUx1cROTJLScU+x1YrzqAwrHrJU4KTgjBy4qrGJK82leQT 7SAEjjwJL6olJysnmGYFVfRohQpzFVgwe5fS8/vTOR1YNOUZlYTB0IDEh1fJz4sj9zfr1kTtUS vd6UIm/fpXJDg91iD3GZtF1031EwDFXXjlgqs5Wi8gc6FPyJxjFpFasPV/n6EUsiJ/JQEQuGvz ka50inCdw6ePMQNsJqRW2H3V6gTOitXVJPm44RQ2SV4wXjYmReNXx4DRrtOxOlBGr+WlCTikE9 Jt3nz/LH/FN1guCdlA3mtYYI 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; 06 Aug 2021 00:20:36 -0700 IronPort-SDR: 3xFDLSmLyEbguGAbwxLdRsxHRd+vIRs87r4PX86DjK8YEdyUtulZPc446c6tpts1UMeGDaBi4Z hJa8+Vi/5e2pWQmbVSB8lkPvcZI2ZxgEBg4RBdphGJGRPoya5DM2g7FlcnY80B66My+QxcnjDA Dg4AIKDcYpRCd4FcG/trQWb+5xJhhTPpXP83fZNj6px4L4bmNObRlyhWqdGHEfMtNrrx5x5RCw 7I7m9uMXaf7obqrbPgl4NWAUQpmyzxdiX/FVecb+wrgtxzBD/lVt5u5z2PMEShPjM0BRKcRwfH jqc= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Aug 2021 00:43:07 -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 v2 9/9] scsi: mpt3sas: Introduce sas_ncq_prio_supported sysfs sttribute Date: Fri, 6 Aug 2021 16:42:52 +0900 Message-Id: <20210806074252.398482-10-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210806074252.398482-1-damien.lemoal@wdc.com> References: <20210806074252.398482-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@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 Reviewed-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index b66140e4c370..f83d4d32d459 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -3918,6 +3918,24 @@ 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 descriptor + * @buf: the buffer returned + * + * A sysfs 'read-only' 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 sysfs_emit(buf, "%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 +3978,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, };