Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp44106rwb; Mon, 26 Sep 2022 14:28:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4y/GUrL7TxWM0PGxF8srGnAvgMldE3+rSNpGNLQ9enkjalr+mqo+9ihGxeNgHu897bXHU0 X-Received: by 2002:a17:90b:3b90:b0:202:8a60:c852 with SMTP id pc16-20020a17090b3b9000b002028a60c852mr778014pjb.169.1664227706249; Mon, 26 Sep 2022 14:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664227706; cv=none; d=google.com; s=arc-20160816; b=eQ2qqSuDBSe10KZnHyjxEHEEn3YcSxPTU9Rl22e/5l1ThtY83kkNUitFk2qdU9MKeC aCQsvsQ1IyCkyvc5WNgvr087kDum+E13G1IIwYT8oL04Qqt0aFtDonWIHLSi6+pJ77Yr 0CbOFTovNRnQMSKP0w7yFb3b4ErCBqKI5VXJcGlxf+A+54W3xHREg9sabtersgykJWVS 7euxQ9HpkvMqTSFDQXlIS1yntUCYoqbmdzteU0EfxpZZs5L1EYaCHiMaFkJC6ga56feW dzLG4iu1Cplnb7XQNmpZ+jd1H/BQ+aI1HgRqmfOHzF5gJ7maouREQO2xIqtoHv6R/ycK G25Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RgWBOdGwiFZq4ZO5n5kADtvoHgwWD2W/5LLKJFdTUYo=; b=TKSKW0TKOFgeSB86S1ES1PKxnPg/Rw5NAskJXBDOnPxrOb+cj4qnvjnL7WpZNaIndH fi9kyT+G17Q/rAb3YEMcbKMLoKUhA3B9jRbpilwhi5M3id3/f15ypx49LY8lv4fyCPfQ j1ud1frJ62Uqx8b2COJIjFb3mdyFNqm9CHIjR9IwSuYN+BtKNz4+KDqdHrOP6RYro1+L xHZ9+uK3kyMtlcDetnS6xlKaTu+UTzaI+N/k87olJ1Zlpt7aiOCRw+HxsA3FKajhccKp RMYeY9y184snsgswc3CTxXkgReNPJKU+PXI5cCklv5vrG+kZfkwCFUA3U/ambVzb0yWx xJvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a170903110c00b001713df1fd46si16783143plh.568.2022.09.26.14.28.14; Mon, 26 Sep 2022 14:28:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230415AbiIZURL (ORCPT + 99 others); Mon, 26 Sep 2022 16:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230389AbiIZURE (ORCPT ); Mon, 26 Sep 2022 16:17:04 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 080C1A2236; Mon, 26 Sep 2022 13:17:03 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ocu8w-0001Yl-Il; Mon, 26 Sep 2022 21:51:54 +0200 From: "Maciej S. Szmigiero" To: Damien Le Moal Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] ata: allow enabling FUA support in Kconfig Date: Mon, 26 Sep 2022 21:51:43 +0200 Message-Id: X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Maciej S. Szmigiero" Currently, if one wants to make use of FUA support in libata it is necessary to provide an explicit kernel command line parameter in order to enable it (for drives that report such support). In terms of Git archaeology: FUA support was enabled by default in early libata versions but was disabled soon after. Since then there were a few attempts to enable this support by default: [1] (for NCQ drives only), [2] (for all drives). However, the second change had to be reverted after a report came of an incompatibility with the HDD in 2011 Mac Mini. Enabling FUA avoids having to emulate it by issuing an extra drive cache flush for every request that have this flag set. Since FUA support is required by the ATA/ATAPI spec for any drive that supports LBA48 and so these days should be pretty widespread let's provide an ability to enable it by default in Kconfig. [1]: https://lore.kernel.org/lkml/45CFFF82.4030301@shaw.ca/ [2]: https://lore.kernel.org/lkml/1336447443-4685-1-git-send-email-wenqing.lz@taobao.com/ Signed-off-by: Maciej S. Szmigiero --- drivers/ata/Kconfig | 15 +++++++++++++++ drivers/ata/libata-core.c | 5 +++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 36833a8629980..fd39bb22963a3 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -102,6 +102,21 @@ config SATA_PMP This option adds support for SATA Port Multipliers (the SATA version of an ethernet hub, or SAS expander). +config ATA_FUA + bool "ATA FUA support" + help + Enables Forced Unit Access (FUA) support by default for drives that + have it. + Otherwise the FUA flag has to be emulated by flushing the drive cache. + + Regardless of this option, you can enable or disable such support at + kernel boot time by providing libata.fua=1 or libata.fua=0 kernel + command line parameter. + + If building a kernel for yourself, say Y. + If building a kernel for a distro that's supposed to run out of the + box on old and broken hardware say N. + if HAS_DMA comment "Controllers with non-SFF native interface" diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index b322006c85806..941836c4b5eda 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -127,9 +127,10 @@ 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 = IS_ENABLED(CONFIG_ATA_FUA); module_param_named(fua, libata_fua, int, 0644); -MODULE_PARM_DESC(fua, "FUA support (0=off [default], 1=on)"); +MODULE_PARM_DESC(fua, + "FUA support (0=off, 1=on), default " __stringify(IS_ENABLED(CONFIG_ATA_FUA))); static int ata_ignore_hpa; module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644);