From patchwork Thu Jan 12 23:42:13 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: 641911 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 E5844C54EBE for ; Thu, 12 Jan 2023 23:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232019AbjALXnG (ORCPT ); Thu, 12 Jan 2023 18:43:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbjALXnF (ORCPT ); Thu, 12 Jan 2023 18:43:05 -0500 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AB8313F97 for ; Thu, 12 Jan 2023 15:43:04 -0800 (PST) Received: by mail-pl1-f179.google.com with SMTP id d15so21775220pls.6 for ; Thu, 12 Jan 2023 15:43: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=/N+/ruISyJ/QTuV3Pc3v3ZnyxN1K341VKQia5HxB1Zk=; b=KsX2d3BrXKPe72QTQoIDaKS2tPhcR4nUIhMjsteaQ+FHBYXAPNe+xne2Fdx0sP7I/6 kmHGxl9H6FER5EawCQO0zmphFiFiu7G5MZhAR9ae5EmRPTnzy2Lr+3AaiPz7AQSvySfX 1LMiSVtEskj1MpmyJgJQFlQTKIzHrjU3ZvVAHqRGN+xRbPuTRDKKWij8lhfDKwwVvfdF rGsPTdaJeFeNIGT6E6dyJ2n474D2XqL5J0GyN+OhpEANt+CiVyOYdqyuvvS5hObfG4ao F8jq/MWWMSQ5pKljplfGmXkLQvHdOWUsfYXBKjFzYPP7oMvL25HaxIS1jDh5qk1CX3kB uU/g== X-Gm-Message-State: AFqh2krohv7bzCM8hycG1ulH/6c8zMZVE8mGO0nqNeLVsA/luCdO2TED DbNXSBP/U0WrViOEPzroVuokoPPlMbU= X-Google-Smtp-Source: AMrXdXtAYGu8VRbLoQlMwdQWZcSGAQO34UoPDZEulXs11jF7Eg/sVgcvW0Qp7XUuw4tyM+AtenL+JQ== X-Received: by 2002:a17:902:ec89:b0:18b:ed3f:c6ca with SMTP id x9-20020a170902ec8900b0018bed3fc6camr107067107plg.12.1673566983800; Thu, 12 Jan 2023 15:43:03 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:3345:7bfe:9541:882b]) by smtp.gmail.com with ESMTPSA id y3-20020a17090322c300b0017f8094a52asm12764795plg.29.2023.01.12.15.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 15:43:03 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , linux-scsi@vger.kernel.org, Adrian Hunter , Alim Akhtar , Bart Van Assche , Kiwoong Kim , "James E.J. Bottomley" , Krzysztof Kozlowski , Bean Huo , Avri Altman , Stanley Chu , Jinyoung Choi , Chanho Park , Keoseong Park , Arthur Simchaev Subject: [PATCH v2 1/3] scsi: ufs: Exynos: Fix DMA alignment for PAGE_SIZE != 4096 Date: Thu, 12 Jan 2023 15:42:13 -0800 Message-Id: <20230112234215.2630817-2-bvanassche@acm.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112234215.2630817-1-bvanassche@acm.org> References: <20230112234215.2630817-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The Exynos UFS controller only supports scatter/gather list elements that are aligned on a 4 KiB boundary. Fix DMA alignment in case PAGE_SIZE != 4096. Rename UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE into UFSHCD_QUIRK_4KB_DMA_ALIGNMENT. Reviewed-by: Alim Akhtar Tested-by: Alim Akhtar Cc: Kiwoong Kim Fixes: 2b2bfc8aa519 ("scsi: ufs: Introduce a quirk to allow only page-aligned sg entries") Signed-off-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 4 ++-- drivers/ufs/host/ufs-exynos.c | 2 +- include/ufs/ufshcd.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 0514669e03be..5fdbc983ce2e 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5029,8 +5029,8 @@ static int ufshcd_slave_configure(struct scsi_device *sdev) ufshcd_hpb_configure(hba, sdev); blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1); - if (hba->quirks & UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE) - blk_queue_update_dma_alignment(q, PAGE_SIZE - 1); + if (hba->quirks & UFSHCD_QUIRK_4KB_DMA_ALIGNMENT) + blk_queue_update_dma_alignment(q, 4096 - 1); /* * Block runtime-pm until all consumers are added. * Refer ufshcd_setup_links(). diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c index c3628a8645a5..3cdac89a28b8 100644 --- a/drivers/ufs/host/ufs-exynos.c +++ b/drivers/ufs/host/ufs-exynos.c @@ -1673,7 +1673,7 @@ static const struct exynos_ufs_drv_data exynos_ufs_drvs = { UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR | UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL | UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING | - UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE, + UFSHCD_QUIRK_4KB_DMA_ALIGNMENT, .opts = EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL | EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL | EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX | diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index fc7373a1a15e..ca32df0ce6ba 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -570,9 +570,9 @@ enum ufshcd_quirks { UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING = 1 << 13, /* - * This quirk allows only sg entries aligned with page size. + * Align DMA SG entries on a 4 KiB boundary. */ - UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE = 1 << 14, + UFSHCD_QUIRK_4KB_DMA_ALIGNMENT = 1 << 14, /* * This quirk needs to be enabled if the host controller does not From patchwork Thu Jan 12 23:42:14 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: 642521 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 748EFC54EBD for ; Thu, 12 Jan 2023 23:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232661AbjALXnR (ORCPT ); Thu, 12 Jan 2023 18:43:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbjALXnQ (ORCPT ); Thu, 12 Jan 2023 18:43:16 -0500 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99BDF13F97 for ; Thu, 12 Jan 2023 15:43:15 -0800 (PST) Received: by mail-pl1-f180.google.com with SMTP id 17so21819514pll.0 for ; Thu, 12 Jan 2023 15:43:15 -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=odjet1nvQzuOAlS4LvhxN9LGiz4ybZNsAPnnYL7GZyU=; b=JTqRGFTDah/29QKBi+Uz4LBe/nYU64col8SzYbT2w0fFlApKJ60aHcsRa/t9ueav+h bk6WtOgHCourFd7Yc5XD6KZuaQkRUqFm9spVRxy0QHuq2RYqzCUONI96iWzYKib5s6Xw FNNufXo8z/DmQNKy8TyrD31+mjDbKv1EE0+4MYyFvFUtSF5JtKmmPHeukEQCBBYF2H7g yyWDOxOE1tRz3xSN8GfDRkjb2ciUabtLG+wOOTcBPJJjyRaQXoKS0+82U4y/nFJ2vdUp XBYh47jDsn4E9SZIWl091vpCXv8iKu5hVHv8HhKZ4DMPgqJlWbC9I9MJcatwxucmaOcT 7ADA== X-Gm-Message-State: AFqh2koFpa38F9lkT7KmbfmpaUBrZsCt2JlV+WeBFYGemdmb+BxVI/JV yxy8QxWZKx92zO16XIQZkVw= X-Google-Smtp-Source: AMrXdXsMNJCzri8wGm8CVCVm8IippmGILAOqZNmnt99Dn9JDdpYYg2zc1++3rgmCU0ICsvlW/i6B8A== X-Received: by 2002:a17:902:d587:b0:194:457d:6dca with SMTP id k7-20020a170902d58700b00194457d6dcamr11085436plh.44.1673566995083; Thu, 12 Jan 2023 15:43:15 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:3345:7bfe:9541:882b]) by smtp.gmail.com with ESMTPSA id y3-20020a17090322c300b0017f8094a52asm12764795plg.29.2023.01.12.15.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 15:43:14 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , linux-scsi@vger.kernel.org, Adrian Hunter , Alim Akhtar , Bart Van Assche , Kiwoong Kim , "James E.J. Bottomley" , Krzysztof Kozlowski , Chanho Park , Bean Huo Subject: [PATCH v2 2/3] scsi: ufs: Exynos: Fix the maximum segment size Date: Thu, 12 Jan 2023 15:42:14 -0800 Message-Id: <20230112234215.2630817-3-bvanassche@acm.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112234215.2630817-1-bvanassche@acm.org> References: <20230112234215.2630817-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Prepare for enabling DMA clustering and also for supporting PAGE_SIZE != 4096 by declaring explicitly that the maximum segment size is 4096 bytes for Exynos UFS host controllers. Add this code in exynos_ufs_hce_enable_notify() such that it happens after scsi_host_alloc() and before __scsi_init_queue() is called by the LUN scanning code. Cc: Alim Akhtar Cc: Kiwoong Kim Signed-off-by: Bart Van Assche Reviewed-by: Alim Akhtar Tested-by: Alim Akhtar --- drivers/ufs/host/ufs-exynos.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c index 3cdac89a28b8..7c985fc38db1 100644 --- a/drivers/ufs/host/ufs-exynos.c +++ b/drivers/ufs/host/ufs-exynos.c @@ -1300,6 +1300,14 @@ static int exynos_ufs_hce_enable_notify(struct ufs_hba *hba, switch (status) { case PRE_CHANGE: + /* + * The maximum segment size must be set after scsi_host_alloc() + * has been called and before LUN scanning starts + * (ufshcd_async_scan()). Note: this callback may also be called + * from other functions than ufshcd_init(). + */ + hba->host->max_segment_size = 4096; + if (ufs->drv_data->pre_hce_enable) { ret = ufs->drv_data->pre_hce_enable(ufs); if (ret) From patchwork Thu Jan 12 23:42:15 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: 641910 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 D6BA6C54EBE for ; Thu, 12 Jan 2023 23:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230385AbjALXn1 (ORCPT ); Thu, 12 Jan 2023 18:43:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231833AbjALXnZ (ORCPT ); Thu, 12 Jan 2023 18:43:25 -0500 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EB6C13F97 for ; Thu, 12 Jan 2023 15:43:25 -0800 (PST) Received: by mail-pl1-f171.google.com with SMTP id jn22so21746636plb.13 for ; Thu, 12 Jan 2023 15:43:25 -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=in8QxhKYqG4kGyNbhqnqAwe065UiH75TZ6GdzajJjfQ=; b=khRgZ8mksKdPXDcJY5HjJKgsONf49wkeKaMkFgPx/E0F76/ZJEUCytQsfQMuxOEe5V X4RBYVrz/Z97dSiGk1QzW1sYEZ/i4ERQIEIA6mUje87Zs8XqQNTqTwQ0vBl9D9zt24J1 8M3LRU8mUUTW2BIjxVvoQpV3EOwDcOv8ze+3vJGZxhxx8Tqa+kpwamgKoPdIAE+cfnI9 QPgsmpyKfXbRYsaqNq/M88wO1IYiViIGvynA7yY5Qgbxafi0QRudrEyY/bEBiI7vJ2JO F/I9A8MPqrjBv/FomJiR3ETqRbbC0FxwlGCi7pn6lEvbGeUqKss3sFtXP3bjQ674sk/N WEtA== X-Gm-Message-State: AFqh2koZAlLvBlOCzEkHKggXRYGnoEBp/OF933TTa8pIGV1JTfHE0eVQ G4VaC8bj1RQOO9LGuIXMQ04= X-Google-Smtp-Source: AMrXdXsWv7djADvhLeL3Jz8sp1DHg7SVro9ttUF/jVCCILfK+cCFzMMgvqWoNEUCWriBnZZtNFWlsQ== X-Received: by 2002:a17:903:40c9:b0:194:45d0:3b21 with SMTP id t9-20020a17090340c900b0019445d03b21mr10796347pld.4.1673567004468; Thu, 12 Jan 2023 15:43:24 -0800 (PST) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:3345:7bfe:9541:882b]) by smtp.gmail.com with ESMTPSA id y3-20020a17090322c300b0017f8094a52asm12764795plg.29.2023.01.12.15.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 15:43:23 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: Jaegeuk Kim , linux-scsi@vger.kernel.org, Adrian Hunter , Alim Akhtar , Bart Van Assche , Avri Altman , Kiwoong Kim , "James E.J. Bottomley" , Bean Huo , Stanley Chu , Jinyoung Choi Subject: [PATCH v2 3/3] scsi: ufs: Enable DMA clustering Date: Thu, 12 Jan 2023 15:42:15 -0800 Message-Id: <20230112234215.2630817-4-bvanassche@acm.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112234215.2630817-1-bvanassche@acm.org> References: <20230112234215.2630817-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org All UFS host controllers support DMA clustering. Hence enable DMA clustering. Notes: - The max_segment_size parameter implements the 256 KiB limit for the PRDT. The dma_boundary parameter represents a boundary that must not be crossed by DMA scatter/gather lists. I'm not aware of any restrictions on DMA scatter/gather lists in the UFSHCI specification other than the 256 KiB limit for the PRDT and the 32-bit address restriction for controllers that only support 32-bits DMA. The latter restriction is already handled by ufshcd_set_dma_mask(). - Without patch "Exynos: Fix the maximum segment size", this patch breaks support for the Exynos controller. The history of the dma_boundary parameter in the UFS driver is as follows: * The initial UFS driver did not set the dma_boundary parameter. * Commit 4dd4130a722f ("scsi: make sure all drivers set the use_clustering flag") set the .use_clustering flag. * Commit 4af14d113bcf ("scsi: remove the use_clustering flag") removed the use_clustering flag and set the dma_boundary parameter instead. Acked-by: Adrian Hunter Cc: Avri Altman Cc: Alim Akhtar Cc: Kiwoong Kim Signed-off-by: Bart Van Assche Reviewed-by: Alim Akhtar --- drivers/ufs/core/ufshcd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 5fdbc983ce2e..d28b44a1ffcf 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -8460,7 +8460,6 @@ static struct scsi_host_template ufshcd_driver_template = { .max_host_blocked = 1, .track_queue_depth = 1, .sdev_groups = ufshcd_driver_groups, - .dma_boundary = PAGE_SIZE - 1, .rpm_autosuspend_delay = RPM_AUTOSUSPEND_DELAY_MS, };