From patchwork Tue Jan 3 05:19:18 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: 13087192 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 33841C5479D for ; Tue, 3 Jan 2023 05:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231396AbjACFWW (ORCPT ); Tue, 3 Jan 2023 00:22:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236855AbjACFVn (ORCPT ); Tue, 3 Jan 2023 00:21:43 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED41CF65 for ; Mon, 2 Jan 2023 21:19:29 -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=1672723169; x=1704259169; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R873OM2Ku7NzjIV4vPevY+ELpWrUMJedKCQYFLdggVk=; b=SXmxJo6LXGWGIS60AVTWHwBwne/1CZapd+6qeFG3A/FV0czt8IuqlGyF YUkKEcdRyMwNR+2pCZsceTy7EcZqS/FubPzuIM6IaNAnt5zylsWD0T7uu BnqxKjdN48OFU3tjwCj1d9dOiDxthwsmqVSHhzYp7agj05YLesUet1N76 /s+5LDxpPJ+RQ/uWNt/xT+3ifRO3mcK3UKfrixHkqyAWFLdXP/OKau7wy dUhFXtMBul/9ndEu27PBv53r1Ed1bq+uW/vQVWSSxAwss1gHlHwqffwAc egFSOjU7IbIvnEYOnMZf9+Nl2jB4bkGWLswo+100fPuz5I15Neq0MT0Nm g==; X-IronPort-AV: E=Sophos;i="5.96,295,1665417600"; d="scan'208";a="219794869" 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; 03 Jan 2023 13:19:29 +0800 IronPort-SDR: vZqdMkQIM1PO/LUYDZQQ93UqBVLVt0o51M2NQkIr9MEyIVPIQQ1hVqZJufOStpghPfcoFiCnci QB14YTstKA3I7ZTzBS9CV4sicq07MxkyAUNxI27juztZppEEXnwHurQJyzPnRBxMnxVz7IfAfp ppdmsvKIuquN5HkFbaitb2ijyIUmMGex0pl6vAP/hqpbJx8GDHSCEMF4QQvxwVGnfS2eNUg9ES fmNY9U82kOr+MIA5v+XbTKDc1iy7ocXO1xdX9xPkrb9JZ0twV1odwvrLNuDvYTve/I8BoEGF1W aLI= 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; 02 Jan 2023 20:37:27 -0800 IronPort-SDR: 39blZyt327+3NePxhpz0YEDrAhGgS15AFa8yj+wygodm8y6RfOU6aHSjj8qzAa1Vji1lekBRzi KunbyVCLU5d8D1WkTi7vfsv9AV8X495E5XchEFsychNcttNqvayKUTZuKXgr0n9GsiwMd6AUgK HypnqPhFOF81UY/w5fNHh+HIYcHLqnv1VSa/u6NjNnsNwqYp7iFnNrufHRVLk62R+1iJqxYptf aTD6LduzQm0ifLE/jaCcktFXpbnLe1Gs2Frv+BWHd1xIT7COJO8hrt4dJjA1oWCxb6NtVXHFjI +FA= 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; 02 Jan 2023 21:19:30 -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 4NmLdF2HV8z1RwtC for ; Mon, 2 Jan 2023 21:19:29 -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=1672723168; x=1675315169; bh=R873OM2Ku7NzjIV4vP evY+ELpWrUMJedKCQYFLdggVk=; b=GjhKCpuUc2dwqJB5cOCKH/1VAchRQj7SER VlhZDRjptBaswUhjHaWhZpJ6zPNAdNmOmt8g/OUvtMYmmFqbG/lIX6aiRsAqj2Z6 bCsbYzUjGAxXdRxmgbWIkvsU2UeizkILrwwasdXuTUUXGn5xC/PLxrBgcYTCem8t w/sZu9Us2T1LEAk8iPVb1drgMgpxOo4AYSfX73npFng2/PmEhc9bCndKYE6DTsQl x2jTg1p92KCVCXp91bMfBqN6Qv344UbKTYi0ywL3GcvT73RjeuWIeTmfSdRiGxKu eFoM5NC9ncL5eD+ny8h2Vl89DRONbP9UTqldxWdOAQ/T+VfQFaFA== 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 c6Xw8NMUYkxk for ; Mon, 2 Jan 2023 21:19:28 -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 4NmLdC4qmSz1RvTp; Mon, 2 Jan 2023 21:19:27 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Hannes Reinecke , Christoph Hellwig , Niklas Cassel Subject: [PATCH v7 1/7] block: add a sanity check for non-write flush/fua bios Date: Tue, 3 Jan 2023 14:19:18 +0900 Message-Id: <20230103051924.233796-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230103051924.233796-1-damien.lemoal@opensource.wdc.com> References: <20230103051924.233796-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: Niklas Cassel --- 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 3 05:19:19 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: 13087193 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 D518CC53210 for ; Tue, 3 Jan 2023 05:22:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236696AbjACFWW (ORCPT ); Tue, 3 Jan 2023 00:22:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236859AbjACFVo (ORCPT ); Tue, 3 Jan 2023 00:21:44 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCDC3F7F for ; Mon, 2 Jan 2023 21:19:31 -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=1672723171; x=1704259171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rXA3kM1+t0Z22RbZdnHUnovsG/0E1mtbQVU8JoBc4nc=; b=JmAMqjoH1eQnWCtmKUW0jrJNFFGZYdVQxcCvbwdnVBGQPPJH4m63HuJl subc906G6zrhb/4AP/uQUEUz7mk7XQsiOnTiSzA3eZdzUhIgYSBWv3rwM durx5Baek38OO4rtqgbYOjuPNSl0qEAhJvwnEh9CYqQsv85d7kzqaY++e IOtI8oKcNLMWC/JRtr3NJ6FRRORc2oBALxBxqn7hOTjm+aqcRtJYBNl7u +F8DjEzXoUyulQG75YtKOJcY+olThGgUhJQkQTFIxh0Qf4h2j8InPFUE1 hRC9R8PnPRpZxSxZLOMs3sup6NHKRIV8C/1JdcK/tsWg4HpofIQCBzPQm g==; X-IronPort-AV: E=Sophos;i="5.96,295,1665417600"; d="scan'208";a="219794872" 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; 03 Jan 2023 13:19:31 +0800 IronPort-SDR: Fz5P+nM5NrK+xvQATmMEWRjD5XghKGiehXjyL63v26oDmt5aJnZlRR/NA6MsuK+pjVVI5m83Y9 uJBdA89pEhRiyoAYOM/GsTmZg5xel9B4Srn08kxDlcewtlwKj4slMH/3Xsz/jxNrLBYEhdjsIV z9sLS07Q2OmQlNA9Xe/LQsokDot22RYXG3a/X/PLAvj/r1yU6CjAWJFxjQVlP239y1ocuOv0w9 9BWvd1xxzd8LRilKgX7fNYXUmAYaaY1GR29OG44nJeOTFXBPUCOpV2dpfA4/F1m9zDyfqA7MvS sCI= 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; 02 Jan 2023 20:37:29 -0800 IronPort-SDR: 60kGqnKc+9KJo5lS2nG8CjmuROeZu+8+5qDwQE5hkq12HvVXd3DBRZZ3ngaNrRZ+MozWT6I/57 8NFPMxEUMT9+reGdJN+djxzYUEO91fvJtRNooTEzo/K9RxuV7mn/nMJ2OCpqGp/tPRmkG9h7qP LI1BxjQxbMGEk1pl6H6ahD8mNZH+XboZOZNl7rbyjq6cv2lLgDRhDJVfDE6VceS0/fMPrsGAyC dTI8NhHP3BEKf0MxsbksG0UvqytApIWmDFdrDjkba324clDlAdLC16XWA3q68GHnWHx1y1LxJc 6ys= 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; 02 Jan 2023 21:19:32 -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 4NmLdG5Nf2z1RwqL for ; Mon, 2 Jan 2023 21:19:30 -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=1672723170; x=1675315171; bh=rXA3kM1+t0Z22RbZdn HUnovsG/0E1mtbQVU8JoBc4nc=; b=XPRoPKq03d0+WwwpukNZDdivgne7WuxxRU KFMJsUn+vbb8Y8O9wPlXYpG6na8XfyN37ll0wBH1p27+6Z7dbLXQfrnXkvEZlakl sA4G7G8ph/pORfRDo5E+rEZe2lO+ug95FFU39/oMWz0j8+qDW/ZM30qJFqiaNxs/ Z6/2vTmDPn8WrDZdPXBymnI9yuMSWsrFldw+MIoVKEUziCFEXyYENl2xHCdvxhj+ +EBX4MMWB17mJjqhmpok66x/PuAKMie9yeHTvIS/AGKn1dQkB9UJE+05ykVqXG+j Uab7YZgkSHBFbcJsq2OG0fGOGxAHNJNvvJlV2tfjZVHvhIcXEOLQ== 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 nw7TapHxasVP for ; Mon, 2 Jan 2023 21:19:30 -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 4NmLdF0tdpz1RvLy; Mon, 2 Jan 2023 21:19:28 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Hannes Reinecke , Christoph Hellwig , Niklas Cassel Subject: [PATCH v7 2/7] ata: libata: Introduce ata_ncq_supported() Date: Tue, 3 Jan 2023 14:19:19 +0900 Message-Id: <20230103051924.233796-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230103051924.233796-1-damien.lemoal@opensource.wdc.com> References: <20230103051924.233796-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 c9149ebe7423..650543afad32 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1690,21 +1690,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 3 05:19:20 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: 13087194 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 47D97C54EBF for ; Tue, 3 Jan 2023 05:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbjACFWY (ORCPT ); Tue, 3 Jan 2023 00:22:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231635AbjACFVq (ORCPT ); Tue, 3 Jan 2023 00:21:46 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3E44AE44 for ; Mon, 2 Jan 2023 21:19:32 -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=1672723172; x=1704259172; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qjsfBZV8/cYQenaf4a1MT8cE4OdYyuK9gJVyVtAGJMQ=; b=K6FMRHU+qzm3ut4jUcsJq8bQsKrX4AEH96MmKx3fBw6HJH1hfMM5BZl8 vbhtEWFcO8gAd7lv6bUFweuMIpKcPwI/wlioELkIsZ/hBfvEVuWwTNF4H 3FqSh/eVkiGbJTKAg0N2DuKxFjFLXU1YE7GK83w3knvT9RTGLIgvpUMuQ v4cwt31S59Fit7EfgkI1ARui8d+esLutK6uewthq0YhkAvyM3hXNCZmrc 81FlurJzP/6ZbaRekCwJQ3Xo/urIjRf8wcL5j4zc8VLTEb/mfrITnRLSK KsZkY+oj4Z4GfVB9sx+u2CmQzxMgUTfjNRbfDUCe/SUBuWOq1qAgvTzM/ w==; X-IronPort-AV: E=Sophos;i="5.96,295,1665417600"; d="scan'208";a="218126864" 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; 03 Jan 2023 13:19:32 +0800 IronPort-SDR: xRRTZBW46iXkA22HL7D5yZxjEdtlTZPthodVa8wY2b72x0d6+9DF5pCuKhznBp9gt2xyOXxlj6 9jsf0Sf5HNzPiF/qtamrLnX0BIInXE3v0YyOd/N3sI7969D+A8MHaobidXoKhrBe1I7gaV0c6a bJ5TtwZO9LGfODXs5/W/OfjF4k6C+XHCjPBc8ylo6EWoMi4HdELYKHrLGTRKs7bHQCD+xSYFp+ kp0oTZ4J4KWghWy1197MPmVjn1Fv/56sSA5pe1zogyGltD2YP3h6RMhqXCvqz9B0OI9Ht/T8dU 4fY= 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; 02 Jan 2023 20:37:30 -0800 IronPort-SDR: ee8H2kHEisOme4vnaYiNhWrAZ70ksx1vqtFBQfCTzFtzkkbctBAwcDL/9x1UWMlUAPQ5UYLB4z DBhkz/28eX24LcBkiywmHxhQwnSqx9j6V17QUqppfefQJA4zjb9W0iObOlaaBq4vwT+dFM3mGK 7pBBmJLcOvoOGUwYEhLEP1n/9tM8EGz2VQn676R8A2U8H00fS1snXk91Oje8blDUN8eF6tYP7w kDmgJkM1jBXTm1xTk6yE+nz6vBgEkcUZ6GuAZcoFMy7rYBMq+cjcPz9RgsVu8Ntt2qYuh+ezDX dxo= 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; 02 Jan 2023 21:19:33 -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 4NmLdJ1YVMz1RwqL for ; Mon, 2 Jan 2023 21:19:32 -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=1672723171; x=1675315172; bh=qjsfBZV8/cYQenaf4a 1MT8cE4OdYyuK9gJVyVtAGJMQ=; b=gxNzoNBobFmA8AcjetYDO3FgL0ug2WYlXF qaKZnGS8C6h28X5QYkuSkt4dNITloAzyy/4jAuFPdkkq4edG12ZBRbAOhBD/QjWZ XA+vlxEdMFfXYQ4h02q5t/zw0ecP6HKYftyNtVpQ84nxSCMESi2EY644tI7lINJM OywaN9v13rRt0Cp7pdfJPcSRwOyZNYAij1wUIDQvpYerpuYQp7ntMR9EFXzoYy0w eTByQNw9u5G0DrQQhQC14U4BOOlYOwI8Rlac3fuhFmB0ET8Zktz3jmzz6PCAXIaB I6RFYCnukDR45L+3q8k73ybupVpW8oVEjhb/dpqHcjrNL7On7+Vg== 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 Awj8Rfdk-IRz for ; Mon, 2 Jan 2023 21:19:31 -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 4NmLdG420Dz1RvTp; Mon, 2 Jan 2023 21:19:30 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Hannes Reinecke , Christoph Hellwig , Niklas Cassel Subject: [PATCH v7 3/7] ata: libata: Rename and cleanup ata_rwcmd_protocol() Date: Tue, 3 Jan 2023 14:19:20 +0900 Message-Id: <20230103051924.233796-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230103051924.233796-1-damien.lemoal@opensource.wdc.com> References: <20230103051924.233796-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 884ae73b11ea..6ee1cbac3ab0 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 3 05:19:21 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: 13087195 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 CC67DC54EBD for ; Tue, 3 Jan 2023 05:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236622AbjACFWZ (ORCPT ); Tue, 3 Jan 2023 00:22:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236858AbjACFVr (ORCPT ); Tue, 3 Jan 2023 00:21:47 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A8ACBCB6 for ; Mon, 2 Jan 2023 21:19:35 -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=1672723174; x=1704259174; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NuPYY3rlZUaBM9lp8igq7CNP3hZGim+0FJY4yALHC60=; b=WThmWUqupMrxGWJT4LZiMYSRf6bf4p0CVGPxhisu+4Z7hNdGXD4MlbUq oHELbauNVknMIW8mRpZMrLcLeGmKx7MtBGdGcks/qQ8tA8lRUDCS7QEJI bj8htupLwoXoOkE4+hFdedcbQbziDWvj1BP4YWCehODBje7lkoubg6Y+S eibx7wViYiaVz/zaFO8XD1hin9TKbe2PFI3+KC56QKCGSDY5XRNG9MGlg 1fJTJSFp4ei5EHh7XP8SLWGBGHm2irIOK2eK0SmZchU81Xix9Rv09jtB1 HzbgpAayKo9ziV53WNVGOBX97qSGoOgp3kg5796PdAOgaig7btuD6nwGv w==; X-IronPort-AV: E=Sophos;i="5.96,295,1665417600"; d="scan'208";a="220022539" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Jan 2023 13:19:34 +0800 IronPort-SDR: a23Ltth4K6V/FZezmx/x5UT558XOTxKITsOpCEOcYsNwEn8CyOrvLcWwaXyFri0cxZegiEdgGT wlva88xzs9t8VNeUD9noch8lFQK3Q30HgbJqG2K8ng6CEiydjZWURMgBOfqK+xoOW8LDVTgV4o TAskzCF+33XwYeeja8qs3kYEPiBGCZr8mYrxcbGrgPsmu8k208Xaf0lXNq7XuUvmU3/4Wl4cMo pT49uEqTgZRGFGxKBAcwyw8pgKqPtvnaAvgxRVr+KBKl6T28PYtD9xv12gSEz8ZRzG+TtQjx9T 0Uc= 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; 02 Jan 2023 20:31:48 -0800 IronPort-SDR: xu80KKTDMcYGr8NPHI4OMA4hRskd1v+uKBq9WCMkiLozCNUh9s/NYecbR0AVuGxEmu1SJlfeZA SLGr1SGQopwJEEITrrsfvMoIAEtntdjTNvS7cGgLdBYAGme8338C5ptvC6YJR57AuFh+VW25Ha AYadWlW4f+4/SD6IFb2EJC7B4915EkdMZV5ECFKeNKqVEvqBD4i188RoBjf2w17URtduPH1T0U 0m+tY1Sq5uM9nCFWVhgz1Sm4sNYCEgldvpe3COrBMBoJIjyqJD8fOX9kMT9GS9IzlhrsACPgfb tiM= 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; 02 Jan 2023 21:19:35 -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 4NmLdL25X8z1Rwtl for ; Mon, 2 Jan 2023 21:19:34 -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=1672723173; x=1675315174; bh=NuPYY3rlZUaBM9lp8i gq7CNP3hZGim+0FJY4yALHC60=; b=i6jHkRPRRekIGudUrWrbPGrNZXTy3YMbQ0 THNcWBoeTkNYa34FAHOvI9PFwcBi7fBt9mL8hlD7sbMhRlpW8uTBCIuNs2PBUIww Ma3FJKaxtZfdv9X/wyXq+0wQw0iaan0eUIyoDlve3PJtejWHLuEXimGJTroKXXF2 woPPKGzannz/BUheFl9J5ZcxF2NkiABo5V0cP93rq1TOhPaLDKFV4fGqYu6EBOIW 3YUzSNMA1DfMGGCtIapnsImAynJN4g2E8PlmCzv3+DHKdbiaR7rGJm0FnGDjdRzW 9nPHGAewL9uXGF7O65pjg9apxg8l8KdlXe4mzk7InTzwwFELV+iw== 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 D5go_hLaZTtA for ; Mon, 2 Jan 2023 21:19:33 -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 4NmLdJ0XmCz1RvLy; Mon, 2 Jan 2023 21:19:31 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Hannes Reinecke , Christoph Hellwig , Niklas Cassel Subject: [PATCH v7 4/7] ata: libata: cleanup fua support detection Date: Tue, 3 Jan 2023 14:19:21 +0900 Message-Id: <20230103051924.233796-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230103051924.233796-1-damien.lemoal@opensource.wdc.com> References: <20230103051924.233796-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 6ee1cbac3ab0..30adae16efff 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 cbb3a7a50816..f1622b8cdb55 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 650543afad32..6352f7f25a6d 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -91,6 +91,7 @@ enum { ATA_DFLAG_AN = (1 << 7), /* AN configured */ ATA_DFLAG_TRUSTED = (1 << 8), /* device supports trusted send/recv */ ATA_DFLAG_DMADIR = (1 << 10), /* device requires DMADIR */ + ATA_DFLAG_FUA = (1 << 11), /* device supports FUA */ ATA_DFLAG_CFG_MASK = (1 << 12) - 1, ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */ @@ -113,9 +114,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 3 05:19:22 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: 13087196 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 43FF4C3DA7D for ; Tue, 3 Jan 2023 05:22:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236734AbjACFW1 (ORCPT ); Tue, 3 Jan 2023 00:22:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236714AbjACFVr (ORCPT ); Tue, 3 Jan 2023 00:21:47 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B011CE2A for ; Mon, 2 Jan 2023 21:19:36 -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=1672723175; x=1704259175; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+E4oIDMFHlNO3TqaQKpEd8queFQgBiehnHqMC1+BKZc=; b=nu18hpxsJQ7karg9hBCVZIMaQV7F0JQuHM6sCQ6JGcyYyu45hE9wcQat 9P1RgcKRICXQz6AXqwxgRDvd5gQx4D3/qDodNwZsms1j1Tpa5r6ksBLcX vQH6xc8ydUSNB2gugWHkf7B39pfF4WR4FbiSI4Kczi8yzM4yYPKwZDie3 E3vX4a/bS094UH2N4lczyTuy2Mx2F0Nw+Kx5ZXM12R5pMX5ijaQ2c1H3U 6FNcnbu1eSaaxoU0qqyp0C8otXCGl0cIekhT8dScuK6uGf1iXS5cn6iyo DvZEtMp4zZMkKeXloyisf2xbko2kAoFY11pGYhi22wRe7mckhsyJ7d2bU g==; X-IronPort-AV: E=Sophos;i="5.96,295,1665417600"; d="scan'208";a="218126867" 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; 03 Jan 2023 13:19:35 +0800 IronPort-SDR: xFZL+X/AodbJEyCPbT8B9XwVqIc3HrNHm9IC5r+TbDixL6hI6wlchrePwKidDMNJx3WUEOnSBv 31fX1leHptHDtK4BWnEosL2UyIH6zwBMKynfTbARa91lNavyT03cc2uRffQgrjlYRHCis+4lhb 0yPDXdQPw50c7urYfu2YdFDYcZqbs/NBIUovIorccCCRQZ0gJIUmkJxicgjcptO6gW+4ZUQzVi IfQlFIprgdhtX9cyUUdPfA7R5whP3OMFxvP2rKcJcGVqAlIWgA/6AjFIWAsSDSRX7Bx5+d9RCC V/g= 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; 02 Jan 2023 20:31:50 -0800 IronPort-SDR: lM5Xf4kJIwh/YmRE4Zmemw0P5wTHV2vR9/VC93P/HdicAUwOxykf3BTOsktZnkFLRQ90wrl+ZV 7uv6LlYyhwPqXQuMrQ5N+Hvvv7oQo4AXURedQzl56CWQQd3eGC6E+NQGA8W6Z3r9OTmuY6M+U/ zMO+PxlLyUHR0QkzE2F5YaT5ErlJ8EhUaWjhvXiUAjBWIUqCo41SDBt7rsVxBxKyg3Xab2dWs3 IrX5FGSAOg2tPLsb/7hZ6DQEF2CQ6TkQrMJdcxXhtGiTKWvP+sw6KdhZICZK7fs34lEw5S7S7m ajQ= 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; 02 Jan 2023 21:19:36 -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 4NmLdM3W7vz1RwqL for ; Mon, 2 Jan 2023 21:19:35 -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=1672723174; x=1675315175; bh=+E4oIDMFHlNO3TqaQK pEd8queFQgBiehnHqMC1+BKZc=; b=GWUKzovw+nMdlKC6Xv+cP+4osYHHQkakEM mA2ojxu+1hQE/Br0W34pUQMV/h36f22R+krMr9Hq5nJLmsepolcIdaloNOmKvDYp HgBxPRAvZSKWKRBpPzQJalRVGmAHKlSq0tdR2MkGGSNM2WZnxtQsDvYGhot4LA2E O62kkg+Xb+NcFk/sHrcBaTzGrgzHONw36c/k2Rgeyg01vib8eOzVoSqg+S/4FBQw Q9cFvsOIAf+FGHPYA8OzJaBP/FbjdtjZbXyaDl/zDqpCXAfwXiPBm3xlXjOikUhB ExvZ4RcBbNk+FhEkKEMzjAjRX9J/BvyA6MAD7V2N4QBQlPngQkYw== 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 g5ZMv2F24id9 for ; Mon, 2 Jan 2023 21:19:34 -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 4NmLdK45gjz1RvTp; Mon, 2 Jan 2023 21:19:33 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Hannes Reinecke , Christoph Hellwig , Niklas Cassel Subject: [PATCH v7 5/7] ata: libata: Fix FUA handling in ata_build_rw_tf() Date: Tue, 3 Jan 2023 14:19:22 +0900 Message-Id: <20230103051924.233796-6-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230103051924.233796-1-damien.lemoal@opensource.wdc.com> References: <20230103051924.233796-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 --- 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 30adae16efff..2b66fe529d81 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 3 05:19:23 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: 13087197 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 C1168C54EBE for ; Tue, 3 Jan 2023 05:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236714AbjACFW2 (ORCPT ); Tue, 3 Jan 2023 00:22:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236789AbjACFVs (ORCPT ); Tue, 3 Jan 2023 00:21:48 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C8ABB5 for ; Mon, 2 Jan 2023 21:19:38 -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=1672723178; x=1704259178; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=87iRoott3W6CZmf35ZkmB8TszihaBydw9Ue0jkE2IcY=; b=mjPgkDUx4O/rCiwg1nanAx6S8/mDvIENM3fYM1TXp3yQCTT0hocKjdVj 3MN2hYq/PAE2Bp5bdEGUPADZaD/PGyDCmsIhchy3IJkdJh2AgCLKZR45p /9kkRZitoura1jJBx9c70Ck3pkj9IILCiG1ISeCk7U4+bYxwVgmg188qk KYfMOvh4QXcth2+PAPhD/73s8wByIgGSLtX76AuGYCKl0z4mAQP+G4nyv r0dwpmJHhTCWpLpkCKe9p79u0kxjXppdXVlxyOOW3DF/IcVY59lKSQd+u jugKvbET70ih2n7wuf6FjyJvDxSSIyf9pr9hHTdydNK80dsq9pVcZenBM Q==; X-IronPort-AV: E=Sophos;i="5.96,295,1665417600"; d="scan'208";a="218126871" 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; 03 Jan 2023 13:19:37 +0800 IronPort-SDR: MyV/DCk/KRkDeb7jVs/hys1e2fxZLRwGjjp3fQTyYVxTOMTjXNzAnnmftmX2Z8bBpKpoyK/DHA w7Kq/J7SkSNsduOlv01+rcUyx6KlqZIIklGx4pMIT2PapMCwB4DJAS+6p4gZ32mFKgNse6qTq7 ifbRC16Bvanub+PEcZC+gXVcgH5ERHBqH+WZ34j/iS/OoLZYkLzJvDbQpHrcFAj2+AQRjNtllF hPMbCG2C2o8z2burLm6TuzHdEdI7fexBgIIPbPdNQAC5Vgo+ILvLtdjKWNvTRN9QtwKUGQqMbI FLA= 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; 02 Jan 2023 20:31:51 -0800 IronPort-SDR: LvWnQoWloFlrJfbkT8wZKeWWMhdmsttvv06ZN4Cg1BojiT4KPp8gqBiyK6eJLeIW0mL6FWhsNG 9L/8oiJJuH0tjE/NLtavjK/c9itjdose2m6c6D9t2f9WfbKnFtXcJbqRqJ3GsCyWlJ/c6G/6qZ zdwHP6g5xXE84TreVjEpQ12uSTjARyS6G7V6cBtbExx0/eSyDwf1TG/oUCBs1GfCCEsNBXqLdN yCUwtEXlKSYjvEU3qjYHJ4X/7sooxNb3a1QaNsMQ4HzlquBcQ5LG5tfaPF/5HG5mS2tByUkNsM 8Xs= 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; 02 Jan 2023 21:19:38 -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 4NmLdN6d3xz1RvTr for ; Mon, 2 Jan 2023 21:19:36 -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=1672723176; x=1675315177; bh=87iRoott3W6CZmf35Z kmB8TszihaBydw9Ue0jkE2IcY=; b=bHbypYkFzqdAk9Or0V5O5a0iwxZCAtLdph cd8llhcDeIYSBy+XlCQtk/Q3p+YsHcs4dR1E+W6kGvVLR74Vou+LNjN7YybBnsdC JKolBHuuPzn7Pk0akCDsyr3czduyajju+pmmfTi8p0jrOwjrJLjQubNbYzGvxwra vRNWwpgdM7xnF5tTC28oP+j+lHpVdPgBvrQLLT6spv/3S5oz94gDsY8b8uEFAo5x LuSDpIa41rgfPkPjNYxmYmJsG6dZci82HQH+yCBQTNTR6ckl1pdacj5eP9Qngy+n Owr5r0JX7c+nGgwmmve7XoHVwJfuDdIG2tXXkUlDp8lvfhkLvxFA== 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 JawmIb4e1jxW for ; Mon, 2 Jan 2023 21:19:36 -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 4NmLdM1RqFz1RvLy; Mon, 2 Jan 2023 21:19:35 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Hannes Reinecke , Christoph Hellwig , Niklas Cassel Subject: [PATCH v7 6/7] ata: libata: blacklist FUA support for known buggy drives Date: Tue, 3 Jan 2023 14:19:23 +0900 Message-Id: <20230103051924.233796-7-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230103051924.233796-1-damien.lemoal@opensource.wdc.com> References: <20230103051924.233796-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 2b66fe529d81..97ade977b830 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 */ { } From patchwork Tue Jan 3 05:19:24 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: 13087198 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 5CFA4C54EBD for ; Tue, 3 Jan 2023 05:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230159AbjACFWa (ORCPT ); Tue, 3 Jan 2023 00:22:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236736AbjACFVt (ORCPT ); Tue, 3 Jan 2023 00:21:49 -0500 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F5B7317 for ; Mon, 2 Jan 2023 21:19:39 -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=1672723179; x=1704259179; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RfCzNezCIKCURHprUN2jJmFdSJzlmGw4xrYVLLd5RBo=; b=Kp93pKdatPG9s3Ys0j4ptFZmVQZasmiy0kEi/FuNTmF9RyJb3ge7W1mQ Kex4dftsSi/6t2Aqo8DKImeEr8aququYCO5QyKYMXVRLOyT/D+cHUrTNO efmGQnh/reqpKAukiLCspyOXw8PLfXYsH+Xm2Mg+jnwRjeFqvGXdSJGli KYnL8W+dSEjRXroJiVfDDht5TmjgxB9ONFAN/X44j1w07UJPwTEMWhrGk 3KOJl0m/nUkatusyFDv9S4ZClIrHv9Rj1R8bGr/sS51oxT/ZmbcZRWtiv 0AV/3x+kwV9o1lJjHJ5hyC0PfIH4Hn0KDUqwyms5EAf/h3pVmX4Hjv7G0 g==; X-IronPort-AV: E=Sophos;i="5.96,295,1665417600"; d="scan'208";a="218126875" 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; 03 Jan 2023 13:19:38 +0800 IronPort-SDR: xZ+XMoQyHd5hsvEycVrHH1VVu/8x51+wBKtzPt+UEQlxFcopO2fRBMhAZsS1AKhtPTfrNTVYro 04wgxSRr2hiqfc+V0AQP4yAwel+wHNqB+fRe+FvQypPN+/Zfux65MLX7EJX61g7r+9xuIMcg2E 3gLynRiIg74p2BorneAANvNvger7MgCDTA26/+UU85Mi6pVMo3BMP7O6/GmmRVzUNXnV5b2Rby ZBn4mW8ZIzGvZrHNykJ/Ao5qYdnKGbNJzzRAfmpyakil8s63uVawgezOuWdGgpk1q3EI9F+Phu Muk= 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; 02 Jan 2023 20:31:53 -0800 IronPort-SDR: e4dV2trKEUERaIKyLfXgbLbzPmvwVofPrjwcDOTTxZvK0AlMy8usK3/HwFf7J2Q+n+UgQAf7R6 1XLq4pXYCS0AxX53zq1KYQ8MPae5T41f9uRIDM1+afGaHuiKGdmfMvWhDxj1YqYT+mxx1/EKiD qp8Zwu8aFmvd7kxKSwsDH4gJ+kJ2H5xMF6A1QD6AJUnmSKg+rDi6OwiMOWriOrDrjwup4vm52A WuDwtsEvkq2Q6PUxxM8R5uoCZkTnCMHvVEyMndVTV1oSXykNgdFsFEfA88fwlFMU2AqB/fe/wt rTQ= 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; 02 Jan 2023 21:19:39 -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 4NmLdQ21bBz1Rwt8 for ; Mon, 2 Jan 2023 21:19:38 -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=1672723177; x=1675315178; bh=RfCzNezCIKCURHprUN 2jJmFdSJzlmGw4xrYVLLd5RBo=; b=UU0u/TU/uNjmy4D7ug9F8GauaAUGkVFKd4 qgpz9c2zSsWcG2sSIJ/CbBn9FUnopZQG1a6JgyE1lsYEomCzaIwqvqnziUlqPSDc 7EAVriuydXuENdlbPTLAAD5jC6jyaBurpXXKYrkc8V+/6vhAKWtv4bJQ6TCafHGS ZdpclQ/7ssHeA+2H3XDUPZWqA4eilEp12JnYByVaNqL37DyqzX8WaiI1B3eahDoe zw5Ia4FnMdhy8ifvrF9v17HhVIsLCJ/rbd3uAejtAAPx9ydenuJGGpX2vAdu7E7g HyV4XxdC+luXrpObKsRMuBjyw21MIjWjWZ6L3Gnsu1HGzVA/xOcw== 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 F82YinuvCACu for ; Mon, 2 Jan 2023 21:19:37 -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 4NmLdN4Tdtz1RvTp; Mon, 2 Jan 2023 21:19:36 -0800 (PST) From: Damien Le Moal To: linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe Cc: "Maciej S . Szmigiero" , Hannes Reinecke , Christoph Hellwig , Niklas Cassel Subject: [PATCH v7 7/7] ata: libata: Enable fua support by default Date: Tue, 3 Jan 2023 14:19:24 +0900 Message-Id: <20230103051924.233796-8-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230103051924.233796-1-damien.lemoal@opensource.wdc.com> References: <20230103051924.233796-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Change the default value of the fua module parameter to 1 to enable fua support by default for all devices supporting it. With this change, ata_dev_config_fua() will now set the flag ATA_DFLAG_FUA by default for devices that support FUA. This will cause ata_scsiop_mode_sense() to set the DPOFUA bit in the DEVICE-SPECIFIC PARAMETER field in the mode parameter header. The SCSI disk driver performs a MODE SENSE and looks at the DPOFUA bit, it then calls blk_queue_write_cache() with the value of the DPOFUA bit, to inform the block layer if FUA is supported or not. The block layer will not issue REQ_FUA requests if it has not been informed that the device actually support FUA. FUA support can be disabled for all drives or for individual drives using the force=[ID]nofua libata module argument. Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Maciej S. Szmigiero Reviewed-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn Reviewed-by: Niklas Cassel --- drivers/ata/libata-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 97ade977b830..2967671131d2 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -127,9 +127,9 @@ int atapi_passthru16 = 1; module_param(atapi_passthru16, int, 0444); MODULE_PARM_DESC(atapi_passthru16, "Enable ATA_16 passthru for ATAPI devices (0=off, 1=on [default])"); -int libata_fua = 0; +int libata_fua = 1; module_param_named(fua, libata_fua, int, 0444); -MODULE_PARM_DESC(fua, "FUA support (0=off [default], 1=on)"); +MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on [default])"); static int ata_ignore_hpa; module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644);