From patchwork Wed Feb 1 18:06:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 649565 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 597A0C636D4 for ; Wed, 1 Feb 2023 18:06:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231215AbjBASGw (ORCPT ); Wed, 1 Feb 2023 13:06:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbjBASGu (ORCPT ); Wed, 1 Feb 2023 13:06:50 -0500 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E6807DBF3 for ; Wed, 1 Feb 2023 10:06:49 -0800 (PST) Received: by mail-pf1-f174.google.com with SMTP id g9so13192466pfo.5 for ; Wed, 01 Feb 2023 10:06:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6gBZq0wYRHnGH4hjPubEjFbLxckfB/3To6qGi+QAYAg=; b=vOaGsZ3u1k+/Eljkq41q/cGTAk2tlE9hdYJClTMqPUwq0TpBXjfPfcnwUxbRx7qsL/ whf0ywTlJqujVZzsQMwO8QqmVyX/0YUI4SFhguXFzpNj6Xgckg/vltw3qNow4QXIDiA5 /AQAp2PXx0IPEVPMJCGjU8zWd7yJr7HBzwiCcKUGnWJ8dAleinUHp3nGZNdlfxXzajN8 ABSG/VKElMQvtXGeCBjPBBpcTfRH99nrYDkbdBScTxIR05NFx+TeWABsLFLk2N2eBJ5D vUsFMAyDdnbERfP0xWNi9QM6sR5GMA9G3otbTttys+lJ6JsnEo7lw3zFR6lE1H2GLgyh 845Q== X-Gm-Message-State: AO0yUKVsrsSgihFH0uyAEYqDLiSD5N3MLgWnYJkotBe/0eSHC2cTG4OH sqoWdqVY/e9Ar4Fh4soJfkk= X-Google-Smtp-Source: AK7set8h+bfhTclZBDCYOgxcrzUJ95RFs9ci5Mb1iZcvCGrbrxJ0MTmeqbaPfMOq5nv8vV5Zl+DIKQ== X-Received: by 2002:a05:6a00:1ad2:b0:582:a212:d92c with SMTP id f18-20020a056a001ad200b00582a212d92cmr3772031pfv.10.1675274808523; Wed, 01 Feb 2023 10:06:48 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f3cf:17ca:687:af15]) by smtp.gmail.com with ESMTPSA id x13-20020aa78f0d000000b005825b8e0540sm7021264pfr.204.2023.02.01.10.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 10:06:47 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Avri Altman , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Asutosh Das , "James E.J. Bottomley" Subject: [PATCH 1/2] scsi: core: Introduce the BLIST_BROKEN_FUA flag Date: Wed, 1 Feb 2023 10:06:36 -0800 Message-Id: <20230201180637.2102556-2-bvanassche@acm.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230201180637.2102556-1-bvanassche@acm.org> References: <20230201180637.2102556-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org UFS devices perform better when using SYNCHRONIZE CACHE command instead of the FUA flag. Introduce the BLIST_BROKEN_FUA flag for using SYNCHRONIZE CACHE instead of FUA. The BLIST_BROKEN_FUA flag can be set by using one of the following approaches: * From user space, by writing into /proc/scsi/device_info. * From the kernel, by setting sdev_bflags from the slave_alloc callback. For a prior version of this patch, see also https://lore.kernel.org/lkml/YpecaXfIxZBHIcfj@google.com/T/ Cc: Jaegeuk Kim Cc: Asutosh Das Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_scan.c | 3 +++ include/scsi/scsi_devinfo.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index a62925355c2c..c1eb6bfe7ed2 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1020,6 +1020,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, if (*bflags & BLIST_NO_RSOC) sdev->no_report_opcodes = 1; + if (*bflags & BLIST_BROKEN_FUA) + sdev->broken_fua = 1; + /* set the device running here so that slave configure * may do I/O */ mutex_lock(&sdev->state_mutex); diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h index 5d14adae21c7..f89e8d1a9d64 100644 --- a/include/scsi/scsi_devinfo.h +++ b/include/scsi/scsi_devinfo.h @@ -68,6 +68,8 @@ #define BLIST_RETRY_ITF ((__force blist_flags_t)(1ULL << 32)) /* Always retry ABORTED_COMMAND with ASC 0xc1 */ #define BLIST_RETRY_ASC_C1 ((__force blist_flags_t)(1ULL << 33)) +/* Use SYNCHRONIZE CACHE instead of FUA */ +#define BLIST_BROKEN_FUA ((__force blist_flags_t)(1ULL << 34)) #define __BLIST_LAST_USED BLIST_RETRY_ASC_C1 From patchwork Wed Feb 1 18:06:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 649564 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 5124FC05027 for ; Wed, 1 Feb 2023 18:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231211AbjBASHK (ORCPT ); Wed, 1 Feb 2023 13:07:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231482AbjBASHJ (ORCPT ); Wed, 1 Feb 2023 13:07:09 -0500 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3B381E2BD for ; Wed, 1 Feb 2023 10:07:04 -0800 (PST) Received: by mail-pg1-f179.google.com with SMTP id 78so13100605pgb.8 for ; Wed, 01 Feb 2023 10:07:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HLgqJs3CWjMWwmy6tt3q30R3AeoZpTnsb7sVFE148AI=; b=v0+5JJ/QUWYPb+yehkeI+pKO7+wN7TEZUhlxFEjnWQq5qPDshq3l8Nu9A6UBptGBDj ZlyZRI+cvtXwRheFxpifRaypb1QdqViDxtddCiAWDVVOU8o2iSWbvIdJsNIodRcl/5A1 CPbejLb8f9bOIZnmi66ccZASYMWSklhqHFu0J0Dfd1ViTl3eHS/z/otGICT+Cj1z6kRg hce5jNjTtOhore6CjSdBmsJPWCXQn8ug/iUiTxHTipsiVjhKZmDEI14XK2shni65uLtt e1LnPEoFUQBrJGw5P22m+7kn7QxoWQw80B5bYmuI1U8gBtqKX3ypzo0/v6JjGY9k21gT AvyA== X-Gm-Message-State: AO0yUKV/754tmmzmK5wrSjA18L7gc8V7TKbSJl+mX9jF4bLMMKnVQs2i SDywK2vSuXDz1N2465P/CK4= X-Google-Smtp-Source: AK7set9t+EimO0hoRlkDFVc1hfMUCT1pKD4xaGIpW7LtOCrM/isRZX8eVt7fOSp1bkKenTm9u/PO5Q== X-Received: by 2002:a62:1b8a:0:b0:593:b37c:c7ad with SMTP id b132-20020a621b8a000000b00593b37cc7admr2990521pfb.22.1675274824119; Wed, 01 Feb 2023 10:07:04 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:f3cf:17ca:687:af15]) by smtp.gmail.com with ESMTPSA id x13-20020aa78f0d000000b005825b8e0540sm7021264pfr.204.2023.02.01.10.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 10:07:03 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , Avri Altman , Adrian Hunter , linux-scsi@vger.kernel.org, Bart Van Assche , Asutosh Das , "James E.J. Bottomley" , Bean Huo , Stanley Chu , Jinyoung Choi Subject: [PATCH 2/2] scsi: ufs: Use SYNCHRONIZE CACHE instead of FUA Date: Wed, 1 Feb 2023 10:06:37 -0800 Message-Id: <20230201180637.2102556-3-bvanassche@acm.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230201180637.2102556-1-bvanassche@acm.org> References: <20230201180637.2102556-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Asutosh Das UFS devices perform better when using SYNCHRONIZE CACHE command instead of the FUA flag. Hence this patch. Signed-off-by: Asutosh Das Signed-off-by: Bart Van Assche [ bvanassche: modified a source code comment ] --- drivers/ufs/core/ufshcd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index bf3cb12ef02f..461aa51cfccc 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5056,6 +5056,9 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) /* WRITE_SAME command is not supported */ sdev->no_write_same = 1; + /* Use SYNCHRONIZE CACHE instead of FUA to improve performance */ + sdev->sdev_bflags = BLIST_BROKEN_FUA; + ufshcd_lu_init(hba, sdev); ufshcd_setup_links(hba, sdev);