From patchwork Tue Jan 10 13:14:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13095106 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95445C54EBC for ; Tue, 10 Jan 2023 13:15:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238426AbjAJNPR (ORCPT ); Tue, 10 Jan 2023 08:15:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238433AbjAJNPK (ORCPT ); Tue, 10 Jan 2023 08:15:10 -0500 Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B08043A02 for ; Tue, 10 Jan 2023 05:15:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1673356508; x=1704892508; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R873OM2Ku7NzjIV4vPevY+ELpWrUMJedKCQYFLdggVk=; b=iUM0zcCN/Pn6SeTlePtBptQ5VsIIjzGVfUrhQzZFOenmvVXHIodoUo6H 1eFj6INo6/Dxg62+onuUAMqSmEwab4cVoBDo1kzM33mPhJLuTlpFKZr+i EPMhg8CyV5WVflTEcZURuoarge1G9ydvQJufPerrmlf52/Qhc0QtJiCnO i1XrMtd3PzxnR3B5HUaqeKLr/BHKj7VaMYckRg0qZvKmSX2LzVkVYjEqT MYdJ+U9cX/m1SQ4CoX+oDoon1w4z9441QIDWL68cumFmotSdI/JiOE4U1 kJhzd8HTCXqJJKfpC2P6nXp9INS7KjuwjcHz/tTgIFl8ge3nMFLig+5dY Q==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="332448515" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Jan 2023 21:15:07 +0800 IronPort-SDR: YKXRPA1wWnjUnc+nugxCm3feEO7N9y+X5oYCAq7PUayXnWfINMxm9uwdsC1+Mzh8nMp00X6xlv Sohy93gYaqh8y5LoqHcvn6IvaaM17KFNGqbThpsa2j3u7RWZyc+WIurv5cJ1vEO58O6qHkFmEU AqCQBLprqJYF44S9kCIbhv3DAkD0lphbyj0Es8ukbbNiA1TBfL1RcX/844QpDIf1VtuhLJaMPA 6TW0M1N6rflDd7tWOQ5kJxt+88k8TwwQG0jKqnB05qWDUZgjDwH9TNGwPESUts6fwy0280hXsK G84= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:27:13 -0800 IronPort-SDR: dVOrbNBMzuljmrC0GRv+d1GU+5Aer/3ruIpvjyqmAtDK8l+Cbm+BhyscOqWfA+tDhOq+vugM33 HKMZJIiVA9q74eup62/SMpL0B/NbpZy0GKD/AtA20CJEo52QbqJSCQYToPvminnVM7+KX5TLnP c3DeLdZzu9cd5EobZnYxKv7QNCt24Dthsfdbdo1E6bg4WkpXKtqsUnWrQ6O5M/rWBquy0rQZBB psEKqJyaLulvVg9zvH0Mc+5J3Q0h7mpmDiW7WXE7bZMGX7jTwCON8IO3oI0n4KZ8PnqHiP3QnR vXM= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:15:08 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nrrrq2hTwz1Rwt8 for ; Tue, 10 Jan 2023 05:15:07 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1673356506; x=1675948507; bh=R873OM2Ku7NzjIV4vP evY+ELpWrUMJedKCQYFLdggVk=; b=fRYATrjqhGCPOlTpKcTI1UA+B88729kzk/ KqQLV9weSPXsWm/3E+o0aXWKaQsduikm9fKn6slVbRWe59FhA4osdyCJwBO9DJpU sCc7gbfGVAYnhpaBNYbN+/+FtDspSmt4hxtXx9GXE6dzieavy0Qy2JebFY9ZYlQk cC474WHVoEPkdc3vvXUP6i6LcILDWTLWrQild3LYQaNZzy60CsaTGgNHpmPkuaAZ 2jQw+7zJqwgRSHfXfT7wBEG+l6JgUuyhaS0GfcroaaGLJZtZhHWkGjUv9yPY8xSr Hk/RB8c5XcZdLAEmhm3BYwgB/Xa7WNvS1Z50GCfeSoQdGcyWdovw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 5juotUv_9ULq for ; Tue, 10 Jan 2023 05:15:06 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nrrrp0FYNz1RvTp; Tue, 10 Jan 2023 05:15:05 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Christoph Hellwig Subject: [PATCH v8 1/6] block: add a sanity check for non-write flush/fua bios Date: Tue, 10 Jan 2023 22:14:58 +0900 Message-Id: <20230110131503.251712-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> References: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Christoph Hellwig Check that the PREFUSH and FUA flags are only set on write bios, given that the flush state machine expects that. [Damien] The check is also extended to REQ_OP_ZONE_APPEND operations as these are data write operations used by btrfs and zonefs and may also have the REQ_FUA bit set. Reported-by: Damien Le Moal Signed-off-by: Christoph Hellwig Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke --- block/blk-core.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 9321767470dc..c644aac498ef 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -744,12 +744,16 @@ void submit_bio_noacct(struct bio *bio) * Filter flush bio's early so that bio based drivers without flush * support don't have to worry about them. */ - if (op_is_flush(bio->bi_opf) && - !test_bit(QUEUE_FLAG_WC, &q->queue_flags)) { - bio->bi_opf &= ~(REQ_PREFLUSH | REQ_FUA); - if (!bio_sectors(bio)) { - status = BLK_STS_OK; + if (op_is_flush(bio->bi_opf)) { + if (WARN_ON_ONCE(bio_op(bio) != REQ_OP_WRITE && + bio_op(bio) != REQ_OP_ZONE_APPEND)) goto end_io; + if (!test_bit(QUEUE_FLAG_WC, &q->queue_flags)) { + bio->bi_opf &= ~(REQ_PREFLUSH | REQ_FUA); + if (!bio_sectors(bio)) { + status = BLK_STS_OK; + goto end_io; + } } } From patchwork Tue Jan 10 13:14:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13095107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94350C54EBC for ; Tue, 10 Jan 2023 13:15:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238597AbjAJNPW (ORCPT ); Tue, 10 Jan 2023 08:15:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238478AbjAJNPL (ORCPT ); Tue, 10 Jan 2023 08:15:11 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4B15792A for ; Tue, 10 Jan 2023 05:15:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1673356509; x=1704892509; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9NoQ954DbHhZGptKeI7CVe5HvdsPZfAJoSreUyiSqMQ=; b=OEvZY+1kRYVT4Iga/OifCJ5ihOd2wsvWfIBJ3YSb7kH8QYCO7M8jG87d O7kKObCqv+9VAVn1cSZlvwQmqS9t5O0U/RJqKWg32GlZ5gS3II/TWfmxG TUaMP6ciutkZl9vM8AbYhXVQkmqTa/mruHybQFohKFXqzrvSphoQDBA9Q +tFTdX/R7pZRNe9ab9BP6ssWD5WRMZ/9XAcnXhYJY6Oevt6e3xOun/maH ob4i5gOFc5WLknL70Pt0NAZuL1eDhCQEgMtySCvnrO7/y/kQiMAAB3PWb B+eTgqw7XkLDNY8gsURLWPd2KtinGjFwk2GZ1qXH11HuI1GmPAVTmq18k A==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="225492645" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Jan 2023 21:15:08 +0800 IronPort-SDR: rn6+kMugyGkGzV9i+WHrqJjaH6j6STQ4kW8Her2iBplIPBUifmLtS0JPrZqN9KDDyVK90gPReC IMsJoEXR/Kjde+HB91zpJrBwEMhhZIIEytJdSPA/IF0lMhTzAha6BgFGFqgBiu113v8+VAJzQi vEDAZNKXmlJOi9EleNoOkMy3Xlf2Xx+6WJvICj9s17bXvGFch9mMNeRnxsvkuGXn+Ylf4aQwwb tLQroIBPZ+HHnFRG03VUysriSEYb1pLi4T7OFUVI9lA/8x5lBEQ0GCMkyytfCIF9x35WDg3rd0 l0Y= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:27:14 -0800 IronPort-SDR: +/UtFNt+Sr3Km/Qujb79wzVkHG+9EtR8NE0RBLcW8CJuAlGW1JSKAB5VvTcIEmZLxLp8U6jh8m bimY5z+PLabeRGYEuyuVWrVtg4dTOtLFiIK9akuJcOmNHqMmJX1M4zLTSadpLCtgo3FUmSkIAl NVgmHWb8QbxZwhEUEl0GyKBSWKu5s/M2GXlCG3yD5nQUYi8eThLw5r5M2Ik6qR5JvXcDU04J3Y LABSQkOiYTFToYn+BGnpYXTfRFE2QxbXIZbpADAe7EIjNsAq3/QgKtefGpGWkR5JkgQQF+kNSx y/w= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:15:09 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nrrrr3jYSz1Rwrq for ; Tue, 10 Jan 2023 05:15:08 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1673356508; x=1675948509; bh=9NoQ954DbHhZGptKeI 7CVe5HvdsPZfAJoSreUyiSqMQ=; b=MsQDj2OdWbs87YfBm2acyAhuOFkoh4sXJR WhgoxjOOTYnBD4SI93hbE6uoLSi3f6xMVUu9IVZ7uTJZ9b5/ifuJ5WGMlSx19zXV eASoFT+AgdXgGxdODLmbXF1ttyEMoyRiUMXeTI/5TFI2DVdsNYqOrE/zY1ML/29H aoK42Z5xm0PwEdrP/IUVd8D/2TLPZvnueDN1bm1q6zzd04Lt4pj68cFM5RKpoB3l 1PVtsJTcMyBmyuViMdgalHZ160C1eUgqcywQorQUPGG2kr4Q5f5KA++uHL1HzyPU pLZ1/zO2luXXPc8GStrHPPymkU/5irPO37AgxvQtjHQo1QN/q2WQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6p5ak6xojbVP for ; Tue, 10 Jan 2023 05:15:08 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nrrrq1FrNz1RvLy; Tue, 10 Jan 2023 05:15:07 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Christoph Hellwig Subject: [PATCH v8 2/6] ata: libata: Introduce ata_ncq_supported() Date: Tue, 10 Jan 2023 22:14:59 +0900 Message-Id: <20230110131503.251712-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> References: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Introduce the inline helper function ata_ncq_supported() to test if a device supports NCQ commands. The function ata_ncq_enabled() is also rewritten using this new helper function. Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Niklas Cassel --- include/linux/libata.h | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/include/linux/libata.h b/include/linux/libata.h index 3b7f5d9e2f87..059ca7f2b69c 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1691,21 +1691,35 @@ extern struct ata_device *ata_dev_next(struct ata_device *dev, (dev) = ata_dev_next((dev), (link), ATA_DITER_##mode)) /** - * ata_ncq_enabled - Test whether NCQ is enabled - * @dev: ATA device to test for + * ata_ncq_supported - Test whether NCQ is supported + * @dev: ATA device to test * * LOCKING: * spin_lock_irqsave(host lock) * * RETURNS: - * 1 if NCQ is enabled for @dev, 0 otherwise. + * true if @dev supports NCQ, false otherwise. */ -static inline int ata_ncq_enabled(struct ata_device *dev) +static inline bool ata_ncq_supported(struct ata_device *dev) { if (!IS_ENABLED(CONFIG_SATA_HOST)) - return 0; - return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ_OFF | - ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; + return false; + return (dev->flags & (ATA_DFLAG_PIO | ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; +} + +/** + * ata_ncq_enabled - Test whether NCQ is enabled + * @dev: ATA device to test + * + * LOCKING: + * spin_lock_irqsave(host lock) + * + * RETURNS: + * true if NCQ is enabled for @dev, false otherwise. + */ +static inline bool ata_ncq_enabled(struct ata_device *dev) +{ + return ata_ncq_supported(dev) && !(dev->flags & ATA_DFLAG_NCQ_OFF); } static inline bool ata_fpdma_dsm_supported(struct ata_device *dev) From patchwork Tue Jan 10 13:15:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13095108 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7431C54EBE for ; Tue, 10 Jan 2023 13:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234166AbjAJNP2 (ORCPT ); Tue, 10 Jan 2023 08:15:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233891AbjAJNPM (ORCPT ); Tue, 10 Jan 2023 08:15:12 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C67C15E080 for ; Tue, 10 Jan 2023 05:15:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1673356511; x=1704892511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/IW0E0zt4+oK414/Fnxtbs0u089eGYcEATsrMArum+s=; b=I56ndQEGz1JgLPAPgEIuaI7V2hqeUzxnnSEeHynyoEDyn7cZCgMy8b92 GR7tPa2R0zfrIg92vi7W6JJPaEJZJ7FWQjNUyTveP18pmt3XFQASwuEEy mK25R6ipw7VX2qKE7Pco2EZWXlvB/Ye/nSBDHNeTpVUs6NV2XU54fFYN/ 5IJ1m9SrBZyiN9ZWFQ3/kGxVtNb0VIoblg7fmeqzWuYRwDZ9LqKbT+PBi tnVcOZZiybm7o2vCDFGRU0SkAdBmp5pcxPyRw5Ad9KpTC8KRCtJFjJLpf 2Pvy5T89wrJlg3yYEMlkUqhbHda7TeQEJ6/azw/aPrzBC1t4fCU4OY+hQ A==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="225492650" 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; 10 Jan 2023 21:15:09 +0800 IronPort-SDR: cXRVx3HuKG1MTA/VRksAYqLYYN6JFDEMWlkPMXQmGlfsJnGQx4ApKYxLxAhIV2Meg9H8RY9nih shWgtaslyTFcjY93CQQSnNhO1Q3zdsxs6P0ZYuYC1yXF++YH6yPUHb537F0yWr26h62NEZvSge N5vyKD6EPVRDm/5mardyhgPxC8DOAtozxK5MkR6tvLtYKPZua3egjwhElW1gje5VKil4ly0/Jd 55+csNIwZgqMfWTrLfJKltpTbJ/O6RK6S1V1Mxe4slAazGA9qLp2QG5NYhZtCBLouFLzb3nYAj OqQ= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:32:59 -0800 IronPort-SDR: eusB/fJ0lTPiQauBVvmdM/hqYzm8B/4egRqXPdFHqcxCzUJmTC7ALsPUtw+0D24jeAD2pOKGU3 GiucttkiSjjDctOYgKDUyiQOJysrvUFrywtPGPqMx+q23/A1zBaGRWoITxoubEcga5ThUOFPYd yIdis6MAcB3ayezzeTUwvlxmspqCbAj7FgJDbd1DGLRtNVglKSPRuFQke0crFcua8fCgQh9TbJ D8zrtwDf7KvZWeOm3g8OhUJlKqdB0M31I7BWWePMdx5Y17UF4zXKXTPBb+/9F6wFWaPmRaPrLw J1w= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:15:10 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nrrrs58jdz1Rwrq for ; Tue, 10 Jan 2023 05:15:09 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1673356509; x=1675948510; bh=/IW0E0zt4+oK414/Fn xtbs0u089eGYcEATsrMArum+s=; b=Prfl90dAQRianVVCKovPCof4A/01sz28yM Ad/4Jd6AteiQvYYyKeP1AV3zTdVLfPYHqH7eL9MInl3IDYPTSbZGWJuFAFx7VLUr BXXnYf6NryhiDMP+guZefP4l+pLUrMBfLZWsuNjcw5ULSK5D3IGqfdXVr4x7aPjx lUFx1xW05f6U76vPv/AxK2AllzG8d+adOfiNuKhNRk7nQmCAlBWhr9O9qaWVrgNz SGEUztNS5bHWi29D6NJU/6zy5VBPKdWh+YaUdWF+3KtlooYKTRiPzu7+x1nu0kuh 96NFny1USu9IHtGF49KMx2sZmsuI4xgYnICFE9zZhTST6pu6+H6Q== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id J9lMm3fOWyTB for ; Tue, 10 Jan 2023 05:15:09 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nrrrr2t2Jz1RvTr; Tue, 10 Jan 2023 05:15:08 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Christoph Hellwig Subject: [PATCH v8 3/6] ata: libata: Rename and cleanup ata_rwcmd_protocol() Date: Tue, 10 Jan 2023 22:15:00 +0900 Message-Id: <20230110131503.251712-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> References: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Rename ata_rwcmd_protocol() to ata_set_rwcmd_protocol() to better reflect the fact that this function sets a task file command and protocol. The arguments order is also reversed and the function return type changed to a bool to indicate if the command and protocol were set correctly (instead of returning a completely arbitrary "-1" value. Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Niklas Cassel --- drivers/ata/libata-core.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 6b03bebcde50..1c16342dda08 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -574,17 +574,18 @@ static const u8 ata_rw_cmds[] = { }; /** - * ata_rwcmd_protocol - set taskfile r/w commands and protocol - * @tf: command to examine and configure - * @dev: device tf belongs to + * ata_set_rwcmd_protocol - set taskfile r/w command and protocol + * @dev: target device for the taskfile + * @tf: taskfile to examine and configure * - * Examine the device configuration and tf->flags to calculate - * the proper read/write commands and protocol to use. + * Examine the device configuration and tf->flags to determine + * the proper read/write command and protocol to use for @tf. * * LOCKING: * caller. */ -static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev) +static bool ata_set_rwcmd_protocol(struct ata_device *dev, + struct ata_taskfile *tf) { u8 cmd; @@ -607,11 +608,12 @@ static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev) } cmd = ata_rw_cmds[index + fua + lba48 + write]; - if (cmd) { - tf->command = cmd; - return 0; - } - return -1; + if (!cmd) + return false; + + tf->command = cmd; + + return true; } /** @@ -744,7 +746,7 @@ int ata_build_rw_tf(struct ata_queued_cmd *qc, u64 block, u32 n_block, /* request too large even for LBA48 */ return -ERANGE; - if (unlikely(ata_rwcmd_protocol(tf, dev) < 0)) + if (unlikely(!ata_set_rwcmd_protocol(dev, tf))) return -EINVAL; tf->nsect = n_block & 0xff; @@ -762,7 +764,7 @@ int ata_build_rw_tf(struct ata_queued_cmd *qc, u64 block, u32 n_block, if (!lba_28_ok(block, n_block)) return -ERANGE; - if (unlikely(ata_rwcmd_protocol(tf, dev) < 0)) + if (unlikely(!ata_set_rwcmd_protocol(dev, tf))) return -EINVAL; /* Convert LBA to CHS */ From patchwork Tue Jan 10 13:15:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13095109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BA78C46467 for ; Tue, 10 Jan 2023 13:15:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232318AbjAJNPa (ORCPT ); Tue, 10 Jan 2023 08:15:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238555AbjAJNPO (ORCPT ); Tue, 10 Jan 2023 08:15:14 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 204DA72896 for ; Tue, 10 Jan 2023 05:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1673356511; x=1704892511; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X3kzvQdGX1FhwiReGoda+divC3uvv6Zg1kXuu40s1fM=; b=YvkG7QDF46P/rciEezbtC/vPMavJ3sy/6j6k7KQ1iDlaEat/sPYpVV6F 51gFwcLzXGOjetz7PTQrV8Gw7D7601nQw7RroeXGv2Apn74543Mq8mm2d 2q2C8nuvzweLTUj+Jv5+A25s/vVrrWfBl+UM3a9fIers38bC7t5z75rpt eshei2U3vr4wAHveJ0o1ZKGmeKt8iJMc8GkcDp+UswqNF1AG0MFe3+nFb KfTpi6hbUcKI6mjXxRkLg0vnhM/Lcp64YD49RVJDCH/hqGFLzQtWO+jAw IHoie2XecGqF/e27ttE992scPEn/fkGvqHvz7q79tzEP4Vhch991YrXa5 Q==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="225492651" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Jan 2023 21:15:11 +0800 IronPort-SDR: cpnQq0CYEPmqQ0qnXIwH34BDMOiFy0aWh6neEFyUoyG2C7RYjoJO0tQ7D+AOdwbd2Epul0cIKO gju1rKdclWqDQ1uL0hqBiFhXHo+RlbAWs6FiDcBmmnfg3WRutIwamhIRZe5xboeHqTU1xvCXZ0 C4mfJ58v4ei6YRdbJ7bTljnPjLJuH0LhJhv8z2SocEXXeRXrEJ7HVye1AZ95WxT/BWbGTGWNOk KPmgdESycxvUyIGBCFo4WhZ5QLsCk8rEb42LvoIk14QgBl/qNrgspf4q975eCDbWnR/jiAFNzV pmc= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:27:17 -0800 IronPort-SDR: 0UZY9rocEvEiI7wDqbGG4b03dFjQRf/pnkjJV0z6gIjtOCWxNxP/bU3nScveYBPzWbZPRCGcKm tUz0YbaGA/NeaNlZ1NECbwpvuCnjnswvQbFOTcvpYEgGVSwUqZPL4bpWCknVe85K+dvYdqajeP SBhsAtEOgLEJKEQvhfIhoLKe+Sz/sg+cGXRJzzMf/NlaC+DVvhH0J+Up8MZS3jBeOg0rImKsaJ 3tuHIj9fzYv9D8jx0Nv3enXmJDLq0yu6IonpQv4ZdyOr/AJWZKm4f+YSCx+/XWtNY4/k72sVmj yvw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:15:12 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nrrrv2P2fz1RwtC for ; Tue, 10 Jan 2023 05:15:11 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1673356510; x=1675948511; bh=X3kzvQdGX1FhwiReGo da+divC3uvv6Zg1kXuu40s1fM=; b=CYKQ1IJLchweojByCtALUDVqbmUQc6GVJS zUOaXKZUqXpW3BaErpyrj2o8esGWb/2Vh0Ax/hl5Xw0kyKbP227OausAW4teG94H gRFWayV8TmcqQ7U74F7atNFpfIdjyOKCJZTKohcKKrIE0ess/tK0LBFMgTbwSV8j /Ct0D1/3sYPflEMUH6JxOFF3joZnuoT2uyXOfHuzyvTHnvxn+f2i8eWkw+Fykh+N CeGlo4ROGI54bq+d7gCJcGdKOdZvfBppmASlhQT3PyERatE2dZbyWaKL85XAFxFG qui0JMgojnFP5ESevRkaDj6unvab+/ju0bYvBPOqX6204pnDMSdA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id eJI_DJs1ufKy for ; Tue, 10 Jan 2023 05:15:10 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nrrrs48Lwz1RvLy; Tue, 10 Jan 2023 05:15:09 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Christoph Hellwig Subject: [PATCH v8 4/6] ata: libata: cleanup fua support detection Date: Tue, 10 Jan 2023 22:15:01 +0900 Message-Id: <20230110131503.251712-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> References: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Move the detection of a device FUA support from ata_scsiop_mode_sense()/ata_dev_supports_fua() to device scan time in ata_dev_configure(). The function ata_dev_config_fua() is introduced to detect if a device supports FUA and this support is indicated using the new device flag ATA_DFLAG_FUA. In order to blacklist known buggy devices, the horkage flag ATA_HORKAGE_NO_FUA is introduced. Similarly to other horkage flags, the libata.force= arguments "fua" and "nofua" are also introduced to allow a user to control this horkage flag through the "force" libata module parameter. The ATA_DFLAG_FUA device flag is set only and only if all the following conditions are met: * libata.fua module parameter is set to 1 * The device supports the WRITE DMA FUA EXT command, * The device is not marked with the ATA_HORKAGE_NO_FUA flag, either from the blacklist or set by the user with libata.force=nofua * The device supports NCQ (while this is not mandated by the standards, this restriction is introduced to avoid problems with older non-NCQ devices). Enabling or diabling libata FUA support for all devices can now also be done using the "force=[no]fua" module parameter when libata.fua is set to 1. Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Niklas Cassel --- .../admin-guide/kernel-parameters.txt | 3 ++ drivers/ata/libata-core.c | 30 ++++++++++++++++++- drivers/ata/libata-scsi.c | 30 ++----------------- include/linux/libata.h | 8 +++-- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 6cfa6e3996cf..3d0f2de7dc03 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2816,6 +2816,9 @@ * [no]setxfer: Indicate if transfer speed mode setting should be skipped. + * [no]fua: Disable or enable FUA (Force Unit Access) + support for devices supporting this feature. + * dump_id: Dump IDENTIFY data. * disable: Disable this device. diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 1c16342dda08..d25a53a873dc 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2422,6 +2422,28 @@ static void ata_dev_config_chs(struct ata_device *dev) dev->heads, dev->sectors); } +static void ata_dev_config_fua(struct ata_device *dev) +{ + /* Ignore FUA support if its use is disabled globally */ + if (!libata_fua) + goto nofua; + + /* Ignore devices without support for WRITE DMA FUA EXT */ + if (!(dev->flags & ATA_DFLAG_LBA48) || !ata_id_has_fua(dev->id)) + goto nofua; + + /* Ignore known bad devices and devices that lack NCQ support */ + if (!ata_ncq_supported(dev) || (dev->horkage & ATA_HORKAGE_NO_FUA)) + goto nofua; + + dev->flags |= ATA_DFLAG_FUA; + + return; + +nofua: + dev->flags &= ~ATA_DFLAG_FUA; +} + static void ata_dev_config_devslp(struct ata_device *dev) { u8 *sata_setting = dev->link->ap->sector_buf; @@ -2510,7 +2532,8 @@ static void ata_dev_print_features(struct ata_device *dev) return; ata_dev_info(dev, - "Features:%s%s%s%s%s%s\n", + "Features:%s%s%s%s%s%s%s\n", + dev->flags & ATA_DFLAG_FUA ? " FUA" : "", dev->flags & ATA_DFLAG_TRUSTED ? " Trust" : "", dev->flags & ATA_DFLAG_DA ? " Dev-Attention" : "", dev->flags & ATA_DFLAG_DEVSLP ? " Dev-Sleep" : "", @@ -2671,6 +2694,7 @@ int ata_dev_configure(struct ata_device *dev) ata_dev_config_chs(dev); } + ata_dev_config_fua(dev); ata_dev_config_devslp(dev); ata_dev_config_sense_reporting(dev); ata_dev_config_zac(dev); @@ -4105,6 +4129,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { */ { "SATADOM-ML 3ME", NULL, ATA_HORKAGE_NO_LOG_DIR }, + /* Buggy FUA */ + { "Maxtor", "BANC1G10", ATA_HORKAGE_NO_FUA }, + /* End Marker */ { } }; @@ -6216,6 +6243,7 @@ static const struct ata_force_param force_tbl[] __initconst = { force_horkage_onoff(lpm, ATA_HORKAGE_NOLPM), force_horkage_onoff(setxfer, ATA_HORKAGE_NOSETXFER), force_horkage_on(dump_id, ATA_HORKAGE_DUMP_ID), + force_horkage_onoff(fua, ATA_HORKAGE_NO_FUA), force_horkage_on(disable, ATA_HORKAGE_DISABLE), }; diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 46109bde8a04..aa338f10cef2 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2240,30 +2240,6 @@ static unsigned int ata_msense_rw_recovery(u8 *buf, bool changeable) return sizeof(def_rw_recovery_mpage); } -/* - * We can turn this into a real blacklist if it's needed, for now just - * blacklist any Maxtor BANC1G10 revision firmware - */ -static int ata_dev_supports_fua(u16 *id) -{ - unsigned char model[ATA_ID_PROD_LEN + 1], fw[ATA_ID_FW_REV_LEN + 1]; - - if (!libata_fua) - return 0; - if (!ata_id_has_fua(id)) - return 0; - - ata_id_c_string(id, model, ATA_ID_PROD, sizeof(model)); - ata_id_c_string(id, fw, ATA_ID_FW_REV, sizeof(fw)); - - if (strcmp(model, "Maxtor")) - return 1; - if (strcmp(fw, "BANC1G10")) - return 1; - - return 0; /* blacklisted */ -} - /** * ata_scsiop_mode_sense - Simulate MODE SENSE 6, 10 commands * @args: device IDENTIFY data / SCSI command of interest. @@ -2287,7 +2263,7 @@ static unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf) }; u8 pg, spg; unsigned int ebd, page_control, six_byte; - u8 dpofua, bp = 0xff; + u8 dpofua = 0, bp = 0xff; u16 fp; six_byte = (scsicmd[0] == MODE_SENSE); @@ -2350,9 +2326,7 @@ static unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf) goto invalid_fld; } - dpofua = 0; - if (ata_dev_supports_fua(args->id) && (dev->flags & ATA_DFLAG_LBA48) && - (!(dev->flags & ATA_DFLAG_PIO) || dev->multi_count)) + if (dev->flags & ATA_DFLAG_FUA) dpofua = 1 << 4; if (six_byte) { diff --git a/include/linux/libata.h b/include/linux/libata.h index 059ca7f2b69c..a759dfbdcc91 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -90,6 +90,7 @@ enum { ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */ ATA_DFLAG_AN = (1 << 7), /* AN configured */ ATA_DFLAG_TRUSTED = (1 << 8), /* device supports trusted send/recv */ + ATA_DFLAG_FUA = (1 << 9), /* device supports FUA */ ATA_DFLAG_DMADIR = (1 << 10), /* device requires DMADIR */ ATA_DFLAG_NCQ_SEND_RECV = (1 << 11), /* device supports NCQ SEND and RECV */ ATA_DFLAG_NCQ_PRIO = (1 << 12), /* device supports NCQ priority */ @@ -112,9 +113,9 @@ 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_DFLAG_FEATURES_MASK = (ATA_DFLAG_TRUSTED | ATA_DFLAG_DA | \ + ATA_DFLAG_DEVSLP | ATA_DFLAG_NCQ_SEND_RECV | \ + ATA_DFLAG_NCQ_PRIO | ATA_DFLAG_FUA), ATA_DEV_UNKNOWN = 0, /* unknown device */ ATA_DEV_ATA = 1, /* ATA device */ @@ -381,6 +382,7 @@ enum { ATA_HORKAGE_NO_NCQ_ON_ATI = (1 << 27), /* Disable NCQ on ATI chipset */ ATA_HORKAGE_NO_ID_DEV_LOG = (1 << 28), /* Identify device log missing */ ATA_HORKAGE_NO_LOG_DIR = (1 << 29), /* Do not read log directory */ + ATA_HORKAGE_NO_FUA = (1 << 30), /* Do not use FUA */ /* DMA mask for user DMA control: User visible values; DO NOT renumber */ From patchwork Tue Jan 10 13:15:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13095110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E536C67871 for ; Tue, 10 Jan 2023 13:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238555AbjAJNPa (ORCPT ); Tue, 10 Jan 2023 08:15:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238568AbjAJNPP (ORCPT ); Tue, 10 Jan 2023 08:15:15 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AAA244C6B for ; Tue, 10 Jan 2023 05:15:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1673356513; x=1704892513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K+DjrBoMp8r4GmO2ND7jZ/tYn6dWl8LN/Wiw9iXU22w=; b=cFUEdVD19WWFLvSpN+ZdWIinv2bKpGmcf1EgrYdGg4mJEFhJBnypaR2E 1CxpdoKhWjKOPPnfTUDpqtFdmW4aabNvRuamHbiy8uCVu74FrOQEYup+H ye1/WrIQjbrGlpIj5Q4hS1iODdXO3EAfGK4rdBNVbeIqiK1OTlX59JBTN bMR3snwi1x6LG3rBdpKXTqKJR3mYbr0BtsPpeOkadoZ8YW5kTyq97mZfq 8BDs3h3SjmicfuIvGdvqD4jBUtnCeojiOw3rHh2NvoLqt8RnTxbKfPOsy DcNsNF53gaZA11JSNSpINTRanMdCXq7jTqt4+Fojn+E/JALOhrdAMv+U6 A==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="324740900" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Jan 2023 21:15:12 +0800 IronPort-SDR: EYktQLdZ7q+UrQNyZrlamWkEab5HSEOkbsPjAve8/OIDZ/+ArtELv2sCOvzv3g9mf7zzFCw5Ci Y+zgAqtZ6/fI00KJDF0j4apy5ZSgPu6g1eyKBgPlWuVZ2WVxQHZls7y5VMnU6ZBftpdR/CFKRW sJCjp8duek6r5SsUi4y17tNbDir2Yaoucb1mDnScfZrZzVR5g/KR4U1P/n5GXSxLk9Fgq7Ce4z thi3IatBpPg6d54Qz9gB5C4ewTAUpNx8720svdPErYk2zjj9B7QteSOQMEB6XYbgUgXlTS3VLW N2c= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:27:17 -0800 IronPort-SDR: izoYCNyJh8qg3qFZ8aXsb8qOYJ9/vL53h3dlDb0v0rWnhfaJOG89q2hC3unhNKp2W6H+agJJbB cwl53fe1yL5gwy9rSTxbOdUYagJFyTTGmd22h82BwA8a62UXMLFa2brknkuKMVjmaywZM/G2fK gOh5BLrjQ1kMvYO+uEz+VITEYtli9j9gJIQLTfoa7an7PwkYQmvsbhLlCuo3ICyPH3O2U5a6cR dQzYzo7aXaCaN4+9Q1Bvro2yosm8fLfek3dOXPHwS5OPMmfWTblBLSl4X9xx0GCApR/jZ5n9pk 6/k= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:15:12 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nrrrw193Cz1Rwt8 for ; Tue, 10 Jan 2023 05:15:12 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1673356511; x=1675948512; bh=K+DjrBoMp8r4GmO2ND 7jZ/tYn6dWl8LN/Wiw9iXU22w=; b=VS/YA3zsPC6bO1OTx1gumSfe9r2u3EDVh/ I6HmKPuODGnKnIvxq1YWaeNmZ4Cj5KCFIRmpBr2p5kJDHpospZOXjFJ11tX3yqpl +gUOO+o/isvEv9UuJFk1BOoGKGemhVCrQVK2QLF7MATrhVeGyQB8N0Lq1eS95s+/ +IBb9OTM4MuE3zyd1oBKBsc3xx/7bivwv6v9SPLWM/R2vScp2bUMDdZyS9j9gaID OuEdlCYoev6TEgevNcb0tWKw3r6aW/TATI0bVU2Wn/icFhRIIDMpyc7Ml8XGuGqj FhQPb8FOQl0X122D07LhgUShlCNgKzF97etBSFIYBB9xqk8UY9Sw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id cOdhXTyWZiZf for ; Tue, 10 Jan 2023 05:15:11 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nrrrt50pbz1RvTr; Tue, 10 Jan 2023 05:15:10 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Christoph Hellwig Subject: [PATCH v8 5/6] ata: libata: Fix FUA handling in ata_build_rw_tf() Date: Tue, 10 Jan 2023 22:15:02 +0900 Message-Id: <20230110131503.251712-6-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> References: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org If a user issues a write command with the FUA bit set for a device with NCQ support disabled (that is, the device queue depth was set to 1), the LBA 48 command WRITE DMA FUA EXT must be used. However, ata_build_rw_tf() ignores this and first tests if LBA 28 can be used based on the write command sector and number of blocks. That is, for small FUA writes at low LBAs, ata_rwcmd_protocol() will cause the write to fail. Fix this by preventing the use of LBA 28 for any FUA write request. Given that the WRITE MULTI FUA EXT command is marked as obsolete in the ATA specification since ACS-3 (published in 2013), remove the ATA_CMD_WRITE_MULTI_FUA_EXT command from the ata_rw_cmds array. Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Niklas Cassel Reviewed-by: Hannes Reinecke --- drivers/ata/libata-core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index d25a53a873dc..ac88376f095a 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -552,7 +552,7 @@ static const u8 ata_rw_cmds[] = { 0, 0, 0, - ATA_CMD_WRITE_MULTI_FUA_EXT, + 0, /* pio */ ATA_CMD_PIO_READ, ATA_CMD_PIO_WRITE, @@ -727,7 +727,8 @@ int ata_build_rw_tf(struct ata_queued_cmd *qc, u64 block, u32 n_block, } else if (dev->flags & ATA_DFLAG_LBA) { tf->flags |= ATA_TFLAG_LBA; - if (lba_28_ok(block, n_block)) { + /* We need LBA48 for FUA writes */ + if (!(tf->flags & ATA_TFLAG_FUA) && lba_28_ok(block, n_block)) { /* use LBA28 */ tf->device |= (block >> 24) & 0xf; } else if (lba_48_ok(block, n_block)) { @@ -742,9 +743,10 @@ int ata_build_rw_tf(struct ata_queued_cmd *qc, u64 block, u32 n_block, tf->hob_lbah = (block >> 40) & 0xff; tf->hob_lbam = (block >> 32) & 0xff; tf->hob_lbal = (block >> 24) & 0xff; - } else + } else { /* request too large even for LBA48 */ return -ERANGE; + } if (unlikely(!ata_set_rwcmd_protocol(dev, tf))) return -EINVAL; From patchwork Tue Jan 10 13:15:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13095111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5093BC678D7 for ; Tue, 10 Jan 2023 13:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbjAJNPb (ORCPT ); Tue, 10 Jan 2023 08:15:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238284AbjAJNPQ (ORCPT ); Tue, 10 Jan 2023 08:15:16 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5588643A1C for ; Tue, 10 Jan 2023 05:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1673356515; x=1704892515; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R2Z83dzCeZHKddXeuTUmcn0ovi37DfKGzvD49wy2LNI=; b=ITg/H93O9mcCtMnsWldkId76iEph51XoDUrsVgYHj0Dn7d9jWzhZ2xkG hn83e+lmopeLP1bHdSEpVhay5NDuUpAypz+zePv56DGBgCg2xB68M6wZX qhyVQ+nD83ZmNizjcAV2uHgcERYr2yiqGLZK+8MdxZZuBYIc5re8iJF5U tOriiVz3rFQmSF1QGFO8r15lVNfbUV/i4coCLVxU09LjbsMGSSYvbcTWp lsSUw6/hDgjKXmPSKAns1BaxLwJnfvgE8D0MyTz53iGmJA1tGPo7aU/4V i+FjSSYOgJpjPdrhmO8jvA/UHw5Qhr9exRaeYOjJp5MsfZ4GO7ECuFMh6 w==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="324740903" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Jan 2023 21:15:13 +0800 IronPort-SDR: ePM4mv6az79NpJS7TuqSRW/o/+vhs2rmNJ5rrDddB9pJ1K191vAyaGxBt04Nptyk0uHD9cMalj dj1pslmNkxis8FzhlKTqySydjZU4cTvMJfRM25B45yUlRAPIYh0MgsZs5f+PkioRfP3ODwVYyd 4Xq7yG9CQoD25PnWIhp2QtCVVAi4HFxsToqN+lE6zmIPffWpOskSnkItJZhADRyONbeHwfCeJW /4gaWKYb0gbpqFKUnfbr8KjIuElJ989K3knB8FWjyi3GT1y2CG225yjqbXPYs5J4QBMbfRiOkb Vwo= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:27:19 -0800 IronPort-SDR: x2gpvCpWvwxcBRy+F7xQUZ+Xo5ca0elTHyC6KK8k0QPi4a8uKq8jWkmYGF2wzmcTP5WwkivvGH CpuvgG8Qvd0HccH738HVWVvv5VaQJ2TG4Wg+XA9uDTRo+eVJBy401tD2vkA1xgSd5jRq8hd5iL FGp46nsO3QVo5AEsj1xTBG+q+Nr+LJUH5J2d8yr20Am8dga1Ales7yMEkE3gi/WPOFBNTmW71R dqJg1ISFvOPixRUfafVtNR5+YeXRAqDZAsBmt/UqCGfk1NCP/Lx8xgJhdT9mo8ZR7e4IYVNmTn 4Cg= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:15:14 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nrrrx2Q7wz1RvTp for ; Tue, 10 Jan 2023 05:15:13 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1673356512; x=1675948513; bh=R2Z83dzCeZHKddXeuT Umcn0ovi37DfKGzvD49wy2LNI=; b=VX2Kvw4AbdRR1YuzyfHvgUG8L/5D6rCZ5r gvRN4heP8JVI/VSlOxxhR28MzfWxtz9RI6LbsJdGkr5u/i6wdvx6WOBAE2Fi4spG zqQ2l6sqKPjV/qn0XWkZ+J5MFBCdeQo4KDJ3z637hIthT+Qu3l2cBm2ZXIpnXwBb hO1Eb08xCsoIfnzo6WkoHRHvRV0X6xw4CaZSdP/7qFz6JgYXymR6ANp6Mx1ShNNG ZhsGDjAFE/DeATfGDYTPmDEXmQk/wkUsWOKW0Dl9uQwFfG2KgW2tfGw/ymd8ibJG blzMeEnDrOcEYAhdl5QWgvr+U3BKHtTIVnxLehs2mX/xmWV0mtPw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id AriUG8RTjCeb for ; Tue, 10 Jan 2023 05:15:12 -0800 (PST) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nrrrv6VDdz1RvLy; Tue, 10 Jan 2023 05:15:11 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Christoph Hellwig Subject: [PATCH v8 6/6] ata: libata: blacklist FUA support for known buggy drives Date: Tue, 10 Jan 2023 22:15:03 +0900 Message-Id: <20230110131503.251712-7-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> References: <20230110131503.251712-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Thread [1] reported back in 2012 problems with enabling FUA for 3 different drives. Add these drives to ata_device_blacklist[] to mark them with the ATA_HORKAGE_NO_FUA flag. To be conservative and avoid problems on old systems, the model number for the three new entries are defined as to widely match all drives in the same product line. [1]: https://lore.kernel.org/lkml/CA+6av4=uxu_q5U_46HtpUt=FSgbh3pZuAEY54J5_xK=MKWq-YQ@mail.gmail.com/ Suggested-by: Maciej S. Szmigiero Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Maciej S. Szmigiero Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Niklas Cassel --- drivers/ata/libata-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index ac88376f095a..36c1aca310e9 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4133,6 +4133,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { /* Buggy FUA */ { "Maxtor", "BANC1G10", ATA_HORKAGE_NO_FUA }, + { "WDC*WD2500J*", NULL, ATA_HORKAGE_NO_FUA }, + { "OCZ-VERTEX*", NULL, ATA_HORKAGE_NO_FUA }, + { "INTEL*SSDSC2CT*", NULL, ATA_HORKAGE_NO_FUA }, /* End Marker */ { }