From patchwork Tue Jan 10 13:27:05 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: 13095146 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 33CDAC54EBC for ; Tue, 10 Jan 2023 13:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233423AbjAJN1i (ORCPT ); Tue, 10 Jan 2023 08:27:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233023AbjAJN1P (ORCPT ); Tue, 10 Jan 2023 08:27:15 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57B5B3BB for ; Tue, 10 Jan 2023 05:27: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=1673357235; x=1704893235; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AyibMIs0Fjq5vJZru9dnT2TmnjplSYQ6SuX8E1ANMNo=; b=oJo6LSXRkVgxGMZaCopCad67evri6i+bfcfulpQdmtxJKPpys0zxUojh mI9ais3PdE9fJpJqBcfPJudO3iMK39AeQFU5C1kiDHqvVj5gB9c7sJBKE n9oKnbNmYz0joCVTMsIJp2JZhcsCQS65sJVrWyBhClgcWahBeGK/vSUNc 4oD+ALjnGSsx5mZGjR9Q8m3mqoEfU/36hRsN8ISSTMLtyaK7KI4E1TRQS OY4mPfUq1bZ0gQ25wF2IEkgLEkswPg8GvhIt2D7wMlOI2TgSAnSd3QA6e p/+/xcuO6F4zOF9/eOdMHjWzKWf7Tj6KhkcvLShFwkeDKneDL8CHImJUg Q==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="225493135" 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:27:14 +0800 IronPort-SDR: hCX8spIAtN1cwegKvTwK6vhjZZQLX5XIJXs37gFxel/rn7Uzg3o8odhCnuKIMfX+h8DSdS1Yvr jP1IolUrimp6ynFWMlpRjoy/gQYi1hozQxIQ7GDAf4scum0WBbv8yeCtJykamrE5yrAHCfwxLf PP+ZuMjaawY4QTZ+FiwyJFrGyFPCcuht+e3pshpUjCHUKwUPckz7P2kAEpLuoDx5LTFHoqtAas K7kEQU1/jJx53qmwuH8aU5gL0gVTMcocJ/kmIvYxgS4eq9yDgw2iYjJLhnQU03brHJeF9qKSLJ n20= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:45:04 -0800 IronPort-SDR: pD+JEZ5NvD0H4cxyK86exyca2IlG5mzJizDxlDy7brYMTV3FO4h91Qooo6+Hu8oMaLQCCOCrds VKjj+Bn1M3ZOaxksB4n4LO72Zse4KfLD8n8zKQwQKGsEEYmkPfnBKk9nhcSNHqQCr2jUogWPq/ 2zg2PLJq0s+kc/EjljsBmkUPsvre7rKivppgigSyCGluXKW8CS5frR9b/u0ntcKMFln0bxpXeZ cguQDwtA6THZhq/qzUZg5vor8PZY03t+CjucN/3AEZbZ7qJaMBMqOzVrQrsa3XCU3dnM/QVs3k OJw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:27:15 -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 4Nrs6p62kBz1Rwt8 for ; Tue, 10 Jan 2023 05:27:14 -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=1673357234; x=1675949235; bh=AyibMIs0Fjq5vJZru9 dnT2TmnjplSYQ6SuX8E1ANMNo=; b=kwhU8ly1QXkOf6LeGbbDIHZPOn02lIKfKw JHefJq12srTjZ+cdiqh3zJBO37YOPDQfuhr5tohlXk67KY6TischBOkFJOVGJr51 7MZ3la2ij4acIDzkyzK/alIK6aj40O7hOyHqBq6jpye+OMj7AEqCS1Of3nhA7VYZ 4KCYO6j6DCSy6czohxw7kXwZKrFaWrtB458Cg5UkutkkPAdRmxbQQ3r0EGuewRpY ocnbsxjLB4hyIeAyhNmbFErwba3q4/jwh8Q2zxYCgPo2Vuy8Mx6TPFFhmWQyplLv YeAyVwtbcs7AKkAMagd4AQ6SDS1+wUZ9XLgQ4SmWC1Wxb4mv4yiA== 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 5ArK1Xbxjfa6 for ; Tue, 10 Jan 2023 05:27:14 -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 4Nrs6n3X06z1RvTp; Tue, 10 Jan 2023 05:27:13 -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 v9 1/6] block: add a sanity check for non-write flush/fua bios Date: Tue, 10 Jan 2023 22:27:05 +0900 Message-Id: <20230110132710.252015-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110132710.252015-1-damien.lemoal@opensource.wdc.com> References: <20230110132710.252015-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 10 13:27:06 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: 13095143 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 D4333C54EBC for ; Tue, 10 Jan 2023 13:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232941AbjAJN1e (ORCPT ); Tue, 10 Jan 2023 08:27:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233075AbjAJN1R (ORCPT ); Tue, 10 Jan 2023 08:27:17 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A42A065AD for ; Tue, 10 Jan 2023 05:27:16 -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=1673357236; x=1704893236; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9NoQ954DbHhZGptKeI7CVe5HvdsPZfAJoSreUyiSqMQ=; b=rK6uTfNYFgxnBXMDT8B56ZrEnisI6cO5kFk/WipZgP2rSogeQ8QRnBqk rwTlx4OOooeILVR6fX0dgNcTnlB3uyod1R4c+V63z1sm8lyTCpunfLeeH B2sKFHOkqw42zNycsT7Y+C3y2QBvxphL6N88EeC3lyUOY/VtbEh700K2Q FAZMoFLEMghOtIpJuzRoYzU1wmZH8H/PyT4ljJIOvFSExlcF2N/Ne2ZR2 K5RCWml1cxF0xU0HAXFsG+HHbbva/gl+fhpFXGFVTHllvbzVPEkzauxq2 /HUou/CEEJ/qWHyexK79XFwNsjovJuDnbRm664n/q6rsZvV2yQF973C/7 Q==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="220556322" 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:27:15 +0800 IronPort-SDR: Yl75uL66N+WaumXgzEJAOyf4/Us2PuEBOFZ3CawzVYfclm06z35DegtWzCqLTti8icPDsXnqQG 8N/89XRRf6WIGBvwaOEeMxGnMitrB1xDdJ5OHFOMky+P2nB9NnZ6sAO233IqjroowwZc6mkg1M 2Slg5eaAoCeahQKvxitHSxWbIXRUsUoE/GZ8gKHFsK/92HwUBOexxdmVBeXBaCtZLeDSOCLEHf ZD9qoyhM4XvGN+IltRgGV2BG0wS+5UfRQv6aNlqo98Lz5FD2yHAAZPTN2UXcFo7hERbCj8QQFO ppk= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:39:22 -0800 IronPort-SDR: +O3bKDGh+kpmKiNCXvVbYNw9QT0RN4YLtuYIBBlk5ZGldC3mqTdWq6gWABGkMMdgtDfyAU2Uhi 5yzmXmNd6By6WCVvZqgh+uypDHP1uOGWVwn6ORGs5yyIJGCgTQYcg4o7r1wKzl4YIss0vo2DtZ sGonlfRi4EJHQSxUcoWk0kSNKA7aA7VPSoq7ekMQfHcjkx2jqBapPcihoVBuolBUBS1CM3EKMM NdND/U+HvnnMr9cKEXfv7yBsAYUvCmqF9cEpFhVnL+fQWzlVtp52XJQWPOJ5a3J0Mtf3i7NTzo dEk= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:27:16 -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 4Nrs6q71Gtz1RwtC for ; Tue, 10 Jan 2023 05:27:15 -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=1673357235; x=1675949236; bh=9NoQ954DbHhZGptKeI 7CVe5HvdsPZfAJoSreUyiSqMQ=; b=Vmnu+i171HpiBcTqWESdtDKLCNFOA4cz4r kHQIJJ13YxbvQpwf4HMm06pCNQobcCt6xXBYyPgGDI/BjvhOpm1ZrOn1dIfiLB9S AvMIRWAkjcvUCuc6THCfoxH1CoPZCrHS35TkDbsK0w5eNw0P2dGM+9QHhs24q6V6 IWHau9SXJjagDzYfBbOCUQCnuHMpQCMYQafzkcrAuOesTBxplh0p0p7nluj+Is1K nopqDaOHCTN2IdxFs281D1M98hL+SYHqzCVK0UKNeTl4/LqNm4egiWwjCRWrhKn5 cb5IwKp8PulrZ2DOEvXuHtJ7OShAakf4q2r1TXXrh0J0hh3OJhTA== 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 iYWEte6B0IIl for ; Tue, 10 Jan 2023 05:27:15 -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 4Nrs6p4glgz1RvLy; Tue, 10 Jan 2023 05:27:14 -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 v9 2/6] ata: libata: Introduce ata_ncq_supported() Date: Tue, 10 Jan 2023 22:27:06 +0900 Message-Id: <20230110132710.252015-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110132710.252015-1-damien.lemoal@opensource.wdc.com> References: <20230110132710.252015-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:27:07 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: 13095148 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 B4F78C54EBC for ; Tue, 10 Jan 2023 13:27:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233589AbjAJN1l (ORCPT ); Tue, 10 Jan 2023 08:27:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233134AbjAJN1S (ORCPT ); Tue, 10 Jan 2023 08:27:18 -0500 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F9A5BF1 for ; Tue, 10 Jan 2023 05:27:17 -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=1673357237; x=1704893237; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/IW0E0zt4+oK414/Fnxtbs0u089eGYcEATsrMArum+s=; b=bkI3ft/fidq98NUPEj9ie3beEEFrGC94fPQfrd+VHWlc1GdqcC+7jFOO j32b4qaWZYaFJ1bjgjJ7INVSkI/2airpvy1o9CxQm30AOw5y5B9MBL0eb e2eFNdQt40tM0lPIU1xvHfm2iLm450w3oc8XrYDPXca4MNxxYEx49BAFC gxgrsD0x9DGcyJLcIfshokpcpRBp+5NH41pm47B13HUuPo0ZVB7CYm1/g htqtrKdW9o4ERd9euwLkHq9We0Goqcq+eXLtDspgX2AvrC7u8K+ao0a4l brGUrgovh9Mw/nN4LA/LTntSNpiuJaUvxvq4b1ROQNoCFR9ng0hFmWIS/ g==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="220321122" 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:27:17 +0800 IronPort-SDR: jQJ/VrSkRTnU9C2URA3PNbF/eA94szeJbCJYFb1mi/cwjJca7dni3Bhm4BHYWlpyA4kgrz0H8n n73wojJC2Py1gk0qoEpFo3gv0D69Tbqr58s6/WwmRH0cMb7qX63HSotz1RQBmpWy5WI7xwwFTi XGy3ZOCBnRjUds61q2SHvQYRE/iQy2THGLmvMCWtecQS0Q6V1U/YHti/70SCmT3p+WjqdE7LUY uXz1ET0M4SXv4FayvwAinUQ1p2ZCr3rbhVA6yB4BW1wKgDPHdW9yMuaYR9xLKikkpKlxOkz/bA 8os= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:39:23 -0800 IronPort-SDR: i2lIOqKg1zAXniQmaAao+Hqt2n05DmXKmY2BZgWReY6Sli6E5EAn5qORI8ko9pQADvp5vhX1VV 83iOHSzKxFDHzkUQ+r7sES0d34RN9hf7x/mgKmMYtt8dsT5QG63wIVluPR7fhvMd1NYHjh5Pjc swn5TSiUzD7vWBcUJvDFJ5G+k3mJjp1mO8VFj6Tp5gzYhzkeeD67UShS/pRGQ3R7T8T7C5sypv 3JLsI21lI+MeopyPVXwcLxnFfCv4mZpqm3SzoBnBml/ZdZUfC8vsykgwVteCSSbhzxa846/vKX pIc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:27:17 -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 4Nrs6s0wYqz1RwqL for ; Tue, 10 Jan 2023 05:27:17 -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=1673357236; x=1675949237; bh=/IW0E0zt4+oK414/Fn xtbs0u089eGYcEATsrMArum+s=; b=MK2CxU/ZEzcf1au7Z2bvfttpHm9I2cNPKw PX3BHXPNgZKZpgwSJeIfUy/QcQySlZifexjcEvrRK2iXLqDxIW/2GSGxjkeEz5XY Z7trTCPKm7odrhLWbXpE3MzZA3wmGP35cZKlyuynDg4rUxs2bZPTI9vIq+Bjv8By Pz76YAq4J9DRfduLwDSJQ6pQpA+MJuH4OxsF0ycUPSBrUzF4V3J7HhBzbMRnjwpF Ui1d5DboQzqvGp9K5HoWi7j6m970ox8JCBOjuR/LsyWkPjRPs9376oQqrdIPizSn VLoGec4/49c432j9S88hHcx2xedj+Tq2a4QwF1P80oIlRH7e4GOQ== 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 IBc6y5x1qkRp for ; Tue, 10 Jan 2023 05:27:16 -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 4Nrs6q5SHhz1RvTp; Tue, 10 Jan 2023 05:27:15 -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 v9 3/6] ata: libata: Rename and cleanup ata_rwcmd_protocol() Date: Tue, 10 Jan 2023 22:27:07 +0900 Message-Id: <20230110132710.252015-4-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110132710.252015-1-damien.lemoal@opensource.wdc.com> References: <20230110132710.252015-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:27:08 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: 13095142 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 BDB83C63797 for ; Tue, 10 Jan 2023 13:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232697AbjAJN1d (ORCPT ); Tue, 10 Jan 2023 08:27:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233139AbjAJN1U (ORCPT ); Tue, 10 Jan 2023 08:27:20 -0500 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10F3FB8B for ; Tue, 10 Jan 2023 05:27:19 -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=1673357238; x=1704893238; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X3kzvQdGX1FhwiReGoda+divC3uvv6Zg1kXuu40s1fM=; b=T4QkB8bgiIBOlfFoYxXRktRtLWvvfc3pHT0t26ydknUuv1HMLL1pyU/0 8ZLyyZCnbL5/t8Bzsf59fNaz7O1O1wKVNXV9k51+fR2FKi7PHnFn839DW g+kqPr13EgrLkEDinOl8gQy3TpbgBLKWrJHjRNl6R2HWo58vtoO332XCq jF9gDc8KNMZwk7n6FF/8vOaKhtHFD7TYqXlq0Ir1umLHI5VuE35nzcjk/ aH3KQThu7II7vOuJ04NigokRNURQ3zZHNC/oJBgQFO+G14Q7yQbmOHrK4 jGcF0z/1Vvh01uKS5oZ4Oevq1jlE1j614k0g6yTaulQZ1z7kiF5upXXKy w==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="225493138" 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:27:18 +0800 IronPort-SDR: D3u/Vt5F/F081Gk00ijU+UzFi5bUzIjE+d+UTJoWJQ6MnQ/z7LsVU2oI2auJZPJv7fyz2AgKns nrDtshiZTxQV4OGL48S72xYoEKMIbTULt02fNcQzJFRSIFtfP/CiaDBhUx/lZ5z5RqClreMCO+ K4/oY1Jl9n+uP/DH4zzFRDDUFp87seRZ6WPPiRRf2UvP9JewqKXfFNt+GF90Teg/YvrayXiwPB Mliin3954LEoZeMVvkPhJm+CpJRZNfM2TvmErjrx1/MV7kDBvIijzwQEkPZzMJjUd4VqNlEEkj 9mE= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:39:24 -0800 IronPort-SDR: C+CcWyhOV3wJeZ0pLPcs3DV31qp4634rxpJBSMvRSHDQb16smbn7gJYdUT0uTz1SYtendhKNDb f9mnSchz6Rbn6IA+AlR/4yooShoeDe97Pzwaw9mFu+dg83Nyk1vwMMqmIHE5/7mFMR23v78WQW Qj/jwZfVrZQcNZHt15nnBFpyQEiQTiAiQA5AfK01da4gZtQMC2q8lAyd26RVjEui9dvBogLyJZ klexkqznslgCIFqyWcQ9MIbNdmYkC+bMgwMs2K1p5GZrW1yjyDwWqJ3JNhEnZY+20+10Szk5Kk yaQ= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:27:19 -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 4Nrs6t3v3nz1RwqL for ; Tue, 10 Jan 2023 05:27:18 -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=1673357237; x=1675949238; bh=X3kzvQdGX1FhwiReGo da+divC3uvv6Zg1kXuu40s1fM=; b=i0QnYU0dXOdK3ZjQmAJXdrFXkdPpN5nmgX nwmKK6kzaYQk4yevn/untFd9uX9aEs3StiMw196OkMsezMEGOFj4F9wxCF8/LReE JegYIsBYMFjRnv0oj9YgwyMlb6gQg5QUdbrHZDPxuSyz1ren1JtcgKqmpbIOKEWN D3LE+1xM1fTPflPl7NrLZnwxMamphd/D7fDn97Carw/d7bdTAOOPo2B4XCvrniKB M8W729b4RskpUAKVGdn0RbZx4ArE5WBkLjNAv4VBuaDII6kywGQuJ8ngT9poPJAy ZyVefVz9DOpxp2F2a+AEo4MhzojxlIdR1YEcACEYU+IyovjijoKg== 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 QMP2lhSyemZu for ; Tue, 10 Jan 2023 05:27:17 -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 4Nrs6r6jmkz1RvLy; Tue, 10 Jan 2023 05:27:16 -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 v9 4/6] ata: libata: cleanup fua support detection Date: Tue, 10 Jan 2023 22:27:08 +0900 Message-Id: <20230110132710.252015-5-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110132710.252015-1-damien.lemoal@opensource.wdc.com> References: <20230110132710.252015-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:27:09 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: 13095147 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 D51BAC63797 for ; Tue, 10 Jan 2023 13:27:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233904AbjAJN1k (ORCPT ); Tue, 10 Jan 2023 08:27:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233589AbjAJN1V (ORCPT ); Tue, 10 Jan 2023 08:27:21 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D1F3B3 for ; Tue, 10 Jan 2023 05:27:21 -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=1673357240; x=1704893240; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K+DjrBoMp8r4GmO2ND7jZ/tYn6dWl8LN/Wiw9iXU22w=; b=Y+aPc0OFCaikmLqc0nyVjiAg7K38IKvvKGpj4fgOJQ05aidBSf9ESc0v RHc+en4kJkuv5PWYJsAXGDp6+bOiJDloUMGBOnHjwJ+eKuatnvj3AXkJ3 emL6gzHOyJKSPIPmdPjIEK3lrMM1OaM2tTmOMxRaBDEon5EGezmUuH0kq BLgfmSyBx/XLgNgeH9em+hnzL4GwmJLa6BxKaXD4ctA6KXFXZT8O9R7OQ Y20ltNie4ToUtKKeK9RwpfdRBqyTLeiFR5eK5PzZ1jLrfvTZ+VNM8gMAr b0XcyocyIw3Uo8JDfzHiE35kAPcnFpUE8jx8A8s+/wfQUEfmOGsLWCtbk Q==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="324741509" 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:27:19 +0800 IronPort-SDR: CELzG8rAedRpPEte8TVThNaqb4OrmnGKSMhXdV2ZTJacYyRBeXiNpbF1caXJXeLTlxjMCO2H1T 32GMdFrR7MsJ+R8ZtUs2ixrkCuBQgvSGAg5zMtueCy8P41nejm6kwzJdRKGria0Iyd3E9uFt8u NycWsdmJz48R8OG3PIA8PcyvkDZza9PL7sg4JYqaGcB2EvvnkCT3lKM3G/EA5OujahskwiGux3 lFfX6ezrfN/MhHIaYutmqVTxiaJp7+zrVcNvOdw/L9wr+38OGt1VDpkyRk7DxVxu9BdReY3PEw yTI= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:39:25 -0800 IronPort-SDR: WOc7wsNBHiqrDTM4x0D/chT63zz8MF/+ye2KQ/MgpiJhjatZZyFLvNb7TKFiSDgFGTS9gABFV3 pDiqdwbKp6X6ab9iGh43YOlZsbNPmmcMY1ya0lwuHktxWCqNXZzUhGNRwVXWIJOvyNaMkpfkCh aCJuEFQPGuaNEEV6nU+Jbl6o08YwkYSW+JOWBDaIaqAz2mXn6G4oHHCeRcpLx7vYJoEzitUtYW GRmxzA5WqVY/1e7X/2pm/KIXZ4CugggagzalQDJCqNhOggJq4LyGkezaZFyGdc+IACqu9YZVvK SwE= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:27:20 -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 4Nrs6v4LBJz1RwtC for ; Tue, 10 Jan 2023 05:27:19 -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=1673357239; x=1675949240; bh=K+DjrBoMp8r4GmO2ND 7jZ/tYn6dWl8LN/Wiw9iXU22w=; b=D2KotuHLkbPHXUp/pbMm394dfGh5LFGUMP 94xKBgNFPOzbqXasz3zMTtds4/zESmB7M0NXYJfvy3B/fYCEc5Bt7lQCv5Ia+vTT 5cxQ7qnUtJ5r2ikrTIkrv3g2PuPcEQqHQt6Km+W/NovVukVOnbfLN9U+g3MUb/6O lw2+xjGmEcsz0D3YP5lZplORmgwqrJvR1x1wPJ6RAqIIgD2AHDo6eJmrJ3c1lid/ t0+EeeK+dYQqkeUGUg6nSdyc5ITaO6TUCtg7deIRC9j5iRNH2CvNlVjQRJFlU/yU jsVpvswaTlxPJfAqdal8S9J9W2SDzg2DivJwZlDboX/icWc9blpg== 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 MHgl2rpKfZ_6 for ; Tue, 10 Jan 2023 05:27:19 -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 4Nrs6t1GrTz1RvTp; Tue, 10 Jan 2023 05:27:17 -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 v9 5/6] ata: libata: Fix FUA handling in ata_build_rw_tf() Date: Tue, 10 Jan 2023 22:27:09 +0900 Message-Id: <20230110132710.252015-6-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110132710.252015-1-damien.lemoal@opensource.wdc.com> References: <20230110132710.252015-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 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:27:10 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: 13095144 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 70BE3C46467 for ; Tue, 10 Jan 2023 13:27:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233075AbjAJN1f (ORCPT ); Tue, 10 Jan 2023 08:27:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233904AbjAJN1X (ORCPT ); Tue, 10 Jan 2023 08:27:23 -0500 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7015D3B3 for ; Tue, 10 Jan 2023 05:27:22 -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=1673357242; x=1704893242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R2Z83dzCeZHKddXeuTUmcn0ovi37DfKGzvD49wy2LNI=; b=SE6/89SB6PPSiD99VzaMbySH0LXi7Li7OP3fly1xv48zwBfhT6GMAOhi JvVx/cCULz1EA198kLx8mRRzEtRbafVVAJ4y5oP7yyxUtfZ++BlznyzeB 4Rnz5rI2kpkFw1ELOFAUng1HA6yQnfo/FsDIV1FVnekIaRxj8TRFUV1rR Aph05/Nuk8AEhw2VqxLUKr3fmnBdJs4pBPQeAIKE0xXvPbFxlOHvFJRtE p2Mdi8KBnyPwUNCT3fv49tY/wDNZi89Gjkg65o3OirRxhzusWDJIP+Eqe wPsCWA0myXyVgW7gaYPMtSQ05LPqyoIDOvwiT9GEdVvzkXEGFxgipI65r A==; X-IronPort-AV: E=Sophos;i="5.96,315,1665417600"; d="scan'208";a="324741511" 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:27:20 +0800 IronPort-SDR: Q7kL7U8dA4sbh7ys3xL+C1ctsy+6zY0kxIvyXeA4YMTepr6++K1hUeJxHb9+trQzzAH/edXXJa 21mSolCVoWVmk6+p2F7AQv/9Lp+Tw56ONMJ7nDGv3GFzt3Cjj0mV1eH3pmv+AHGM/0NHIjMUeF WD9Z2m2/FiGcSBX2Z1Jgxa+4/tRhax5dkgUmr5QqQA705cT22pYQbTjF6tpCOSHFZWYcTej9qc 2UwFsx5aqYqXVypJ66FyQMOk75b0H8V5OsTcXt1X4wF9udBkEAWrZhkaC7ebKXjkQFL+g8vQNw ARM= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 04:39:26 -0800 IronPort-SDR: EfmPRZtYNT0V+qIyJJXf3fesxRR6uwNYZkhD3nDaQgudxEtiBoFMe2jI3d7g3SVAqF9xgg97Bw K9yRTBpdhl/8HMH4sm81eeTrTFnypGDXcVDRYOLEz9vSzN9PKFVOszWlgbEbnmc3jZJStFKJJj aWPEf1sRuGkt+K9JIROlbrjxsd49+QYZWswWW01iLdLsaYvXzg7063Q4dZ/n9RDSClOj/XbAc3 iNxuyK2dfW+obK8e6LghYD1Xh5CummkHeGPQH3ERHIzbLIxds1Fn+NsD8OvbS7Pwa1H9N6ogwd 0gY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 10 Jan 2023 05:27:21 -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 4Nrs6w5tkqz1Rwrq for ; Tue, 10 Jan 2023 05:27:20 -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=1673357240; x=1675949241; bh=R2Z83dzCeZHKddXeuT Umcn0ovi37DfKGzvD49wy2LNI=; b=ZJ+0O30axYCJ+x2trR1XYoFhrpq/aV2ttv jKGDDhHgt9mHLxqEY5YPGnVjkbC3LIVJ9aTJQ3QZW5db72btJvoJv3RlGoaxKyD0 uQfoQbv3rErZBsD3qjMbzTVqXhM9hILOMskdDAx+O9WJVQ2+CVqo6PIm8HV5etWp Ah0SJ68XAR49yjj2TSHdIwVAaLJYbi/XpIvqTbUKhYX7wgUd4BrCMeMxUrBzJCZN +FPP/1/B5Q5vQA5/tsTsd7liprMPNowc0/UERrSScnLjYdSlkOx36yo6GHKtQ147 wDZMT3dh4I3QY0BmRyQfwkpCXOO2/uV2m0pX0S/bnYahnfY3ezxg== 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 oF99lCA6hGml for ; Tue, 10 Jan 2023 05:27:20 -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 4Nrs6v2jnwz1RvLy; Tue, 10 Jan 2023 05:27:19 -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 v9 6/6] ata: libata: blacklist FUA support for known buggy drives Date: Tue, 10 Jan 2023 22:27:10 +0900 Message-Id: <20230110132710.252015-7-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230110132710.252015-1-damien.lemoal@opensource.wdc.com> References: <20230110132710.252015-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 */ { }