From patchwork Mon Sep 9 12:56:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11137903 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5F3816C1 for ; Mon, 9 Sep 2019 12:57:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A243D21920 for ; Mon, 9 Sep 2019 12:57:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F9VNdLOA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728960AbfIIM5F (ORCPT ); Mon, 9 Sep 2019 08:57:05 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35631 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbfIIM5E (ORCPT ); Mon, 9 Sep 2019 08:57:04 -0400 Received: by mail-wr1-f65.google.com with SMTP id g7so13780854wrx.2; Mon, 09 Sep 2019 05:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MPHSShEVgX1o3hoQrHIRgOlZyiwWjYnloOHsAiyPNjI=; b=F9VNdLOA8XjYjrsC7+AwkfLub3TsiRkARzX4PXB6kh1oZ6gnmiCIUBuEWnLSrq5Ye9 dW2otbl0bWImTd3MgOj5qSzNUnte+paWlk1fr4RDgZTfx9KWsdVoF1PP16DOoSNR58h5 n+W38KZkIUnxvv0Br9VQjXxLXHOPbuOmFA9f+pKVBJKGVXN3+/f6kk/+yrQ0ejCKiFYA iocFpc9QPUu3b/w11P7jJtVYguEarsX83N/W/SNzjPjbBmxS9EHOrNv9V9iju0r+q0oE 2Yc53y0JntSs410kodXn7UmnDe9x5jDdppLq7jipLVdbUvqEyq5YOpr9oeLgc5r1d9d2 5dhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MPHSShEVgX1o3hoQrHIRgOlZyiwWjYnloOHsAiyPNjI=; b=WdIiFVfOQWlGrXzZQVMg/xjBUC1u++Kfwh2D3m8fjW/3j4UCdJgVvEbUav/e387vKY Av+1MFmbkTYqM0YdSzUpX4pAtNcnGzaohcxIVAY/M522DbuWC0B6/zglPGXcItJf5VYT bgKnlAkpYjdPQsnEQOOJcuaYb/WPEiybozY6QzgR740yEsPSXUYqJI8KOlJ3WodT46A1 hdk1FZNhpIKhM1/z1c/iFQ+qbsMZ7311y0GCR8WKlwqxKcYi0h1CgxCTH3MTKJ8JDpGl x55xFTfSb4qUmaZjRSlt16JY2yksmAztIzpUEJ13y/67XuIh7voinFyBAjq94VMP3Ftt N2DQ== X-Gm-Message-State: APjAAAUzqw2k/rDrK0f3xrCqJ3dAzp2qDYhPhta+R1x9ZV7oOD2QVCaA pTmFsjKyaPtfJ/al4vUz3wk= X-Google-Smtp-Source: APXvYqx73APToU6Hahs0k7eqcalmsnDikGPQwWdcHU66pqu16WZ7ydCQs8MHpdYJdkUdfx2uXGxo5Q== X-Received: by 2002:adf:ff8a:: with SMTP id j10mr19983012wrr.334.1568033822637; Mon, 09 Sep 2019 05:57:02 -0700 (PDT) Received: from localhost (p2E5BE0B8.dip0.t-ipconnect.de. [46.91.224.184]) by smtp.gmail.com with ESMTPSA id m3sm12917929wmc.44.2019.09.09.05.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 05:57:01 -0700 (PDT) From: Thierry Reding To: Jens Axboe , Ulf Hansson , Adrian Hunter Cc: Yoshihiro Shimoda , Christoph Hellwig , Simon Horman , Jon Hunter , linux-block@vger.kernel.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 1/3] block: Respect the device's maximum segment size Date: Mon, 9 Sep 2019 14:56:56 +0200 Message-Id: <20190909125658.30559-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190909125658.30559-1-thierry.reding@gmail.com> References: <20190909125658.30559-1-thierry.reding@gmail.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Thierry Reding When enabling the DMA map merging capability for a queue, ensure that the maximum segment size does not exceed the device's limit. Signed-off-by: Thierry Reding --- block/blk-settings.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 70b39f14e974..9fb1288fbc12 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -738,12 +738,8 @@ void blk_queue_segment_boundary(struct request_queue *q, unsigned long mask) } EXPORT_SYMBOL(blk_queue_segment_boundary); -/** - * blk_queue_virt_boundary - set boundary rules for bio merging - * @q: the request queue for the device - * @mask: the memory boundary mask - **/ -void blk_queue_virt_boundary(struct request_queue *q, unsigned long mask) +void __blk_queue_virt_boundary(struct request_queue *q, unsigned long mask, + unsigned int max_segment_size) { q->limits.virt_boundary_mask = mask; @@ -754,7 +750,17 @@ void blk_queue_virt_boundary(struct request_queue *q, unsigned long mask) * of that they are not limited by our notion of "segment size". */ if (mask) - q->limits.max_segment_size = UINT_MAX; + q->limits.max_segment_size = max_segment_size; +} + +/** + * blk_queue_virt_boundary - set boundary rules for bio merging + * @q: the request queue for the device + * @mask: the memory boundary mask + **/ +void blk_queue_virt_boundary(struct request_queue *q, unsigned long mask) +{ + __blk_queue_virt_boundary(q, mask, UINT_MAX); } EXPORT_SYMBOL(blk_queue_virt_boundary); @@ -843,13 +849,13 @@ EXPORT_SYMBOL_GPL(blk_queue_write_cache); bool blk_queue_can_use_dma_map_merging(struct request_queue *q, struct device *dev) { + unsigned int max_segment_size = dma_get_max_seg_size(dev); unsigned long boundary = dma_get_merge_boundary(dev); if (!boundary) return false; - /* No need to update max_segment_size. see blk_queue_virt_boundary() */ - blk_queue_virt_boundary(q, boundary); + __blk_queue_virt_boundary(q, boundary, max_segment_size); return true; } From patchwork Mon Sep 9 12:56:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11137907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFE611395 for ; Mon, 9 Sep 2019 12:57:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF2DC21924 for ; Mon, 9 Sep 2019 12:57:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GKecVQdo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728963AbfIIM5I (ORCPT ); Mon, 9 Sep 2019 08:57:08 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:55344 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbfIIM5H (ORCPT ); Mon, 9 Sep 2019 08:57:07 -0400 Received: by mail-wm1-f68.google.com with SMTP id g207so13723088wmg.5; Mon, 09 Sep 2019 05:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I9dOAoF+NVQifcpb/BbgRzIPKsZ1zx/+IZ0bgP9rlPU=; b=GKecVQdo5QlW/zjjYlOyec6TpmIU9rYRk6sGaQ4C85qEoGFeVADlrwkNfV+e0SmtpA Hcf9MSjmF6GuLrhv8jkFeypMzR8QOjwVNvwV763nEcLEFft8mf5xuCn3j6mDTsCKg/xv ZPcsgpcBY1cwAlQm+FCUNtIk3Ew+Uv+lbjfaalcXoGtfT/axRAeH1El3e784ONPfSrCu 0HcqCgF/VeSFcGmIce18RLXHReTd/2eZ21krOzPVncukV77O4QWn661C7fUs1wvDBT9f toZBMb/R8L76N5EdFfiem+4zNhqnwcGBAIMzLz/aMv9HbZmeAHVPB9w6trFAH6nv7rQI 5zig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I9dOAoF+NVQifcpb/BbgRzIPKsZ1zx/+IZ0bgP9rlPU=; b=a3qZIcZqgx9Ut/DPdN9U7kJPux6+VCkLPwtKXhpRc6rs/iTp2ol52qEAb5iZ0Ri4v1 hTG7DXjdDAGUCxEaruA9/d0u41pEXPmNvXrHMigmBwzA3GetPBzoSiZvARpv/epdxA/m qP1n5YuLm7w8gtY9zZsz8yDTqK6aaqQHf66/Otgbf2R60yRW1pegjUQtHSZ5C3p7MMxr eQZ+SHAtHz3o5Z0Zyxn58vmXb9Xt8wGCDNonQDrAEh5sCVWImwY/lxshrKowSe8oC8WH wzGNFV1z95gDzbcZsWuHkYTTxhUaZTE5x4uiyfogvI3kchXX+Zg4yxeoClMUBu5u93fs 6oRQ== X-Gm-Message-State: APjAAAUl8s3iYXSaWp6CJu2xzpStJJ+KnmLOwXl8d9yjmOtXiRju/2JU 5kOm5QVuv1C9KgAkfC7iTgk= X-Google-Smtp-Source: APXvYqxfR39uvTELiXDUIBV8O0QVMGbRh9Q7Xqc/ClttWuFq3LAk3zxHhGtXnG50kIBA0mILD0eVow== X-Received: by 2002:a7b:cf25:: with SMTP id m5mr18408055wmg.25.1568033824301; Mon, 09 Sep 2019 05:57:04 -0700 (PDT) Received: from localhost (p2E5BE0B8.dip0.t-ipconnect.de. [46.91.224.184]) by smtp.gmail.com with ESMTPSA id l62sm18297104wml.13.2019.09.09.05.57.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 05:57:03 -0700 (PDT) From: Thierry Reding To: Jens Axboe , Ulf Hansson , Adrian Hunter Cc: Yoshihiro Shimoda , Christoph Hellwig , Simon Horman , Jon Hunter , linux-block@vger.kernel.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 2/3] mmc: core: Respect MMC host's maximum segment size Date: Mon, 9 Sep 2019 14:56:57 +0200 Message-Id: <20190909125658.30559-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190909125658.30559-1-thierry.reding@gmail.com> References: <20190909125658.30559-1-thierry.reding@gmail.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Thierry Reding Do not overwrite the MMC host's configured maximum segment size for DMA transfers. For devices behind an IOMMU, the queue's maximum segment size may be larger than that of the MMC host, but that doesn't mean that the MMC host actually supports it. Signed-off-by: Thierry Reding --- drivers/mmc/core/queue.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index 1e29b305767e..987b01f4cfb3 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -389,8 +389,6 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card) blk_queue_max_segment_size(mq->queue, round_down(host->max_seg_size, block_size)); - dma_set_max_seg_size(mmc_dev(host), queue_max_segment_size(mq->queue)); - INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler); INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work); From patchwork Mon Sep 9 12:56:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11137909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3CD31395 for ; Mon, 9 Sep 2019 12:57:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D2A6E21924 for ; Mon, 9 Sep 2019 12:57:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iP8VGgpj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391087AbfIIM5J (ORCPT ); Mon, 9 Sep 2019 08:57:09 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55348 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbfIIM5I (ORCPT ); Mon, 9 Sep 2019 08:57:08 -0400 Received: by mail-wm1-f67.google.com with SMTP id g207so13723222wmg.5; Mon, 09 Sep 2019 05:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wiEmvqYHezDokAQjgi5F2Bz251GFyvgk91GEKkm7bgA=; b=iP8VGgpjh5evX+wubxCKl7++5k3igSiHYCGLdmun2KD+etOCUES7KuvAqQDXVKxy+h h+03FoIKfMknRbS7Py+Zb+6oeKNCSmXrgLubvsUprOJYoiHXmZQM55O2NBMIEYqWjS9o YXDoIVK+zo8KvP2Ee5z9vXnESWNrcwwXrS1L0D3QEaQJ5s35GZmtZYVfCQ9x1KKPOV33 yeam+Qb0dMIYtutaGkl+4rqyj7wPv5YMd+69WsEUSrBQJ3o3ENMyluLcIQKiL4avQ93N 2AsJc9LOYboUmQz+OA3LdOPvOhjqxgrw6bxAeaUPmVb8ew/B2+bYWxVLKwqybW/2Tnei WFEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wiEmvqYHezDokAQjgi5F2Bz251GFyvgk91GEKkm7bgA=; b=cyVmiwLKqCYGpA/GN+aePCwk7g7LrPon4YKh0IYtIbtSazeemKEiLg1R6gNO7RTYFV O2xB3aL3Ofdw++IUciT1c4YW8PEkJVSH26PL+fBlnzIj15CVrSfcjebHvXinlrtVkM61 2giPZoGm4NywtD8yqnphkHZwHiojaw6Zma3NNLqHaaACW3e3z+ngeA8+PdRFYrjqwr8Q rIMe2UpSG//f4vvs2EXe5WcP69d9quy5IvuWyTWwjWkbfRYGd03pWlKnYJRvOV+vK5tF CsZJUT5Cv6/rW3mCKjOOojAXShVADjBFCXWdIypYy5y5hHZbTNAiXrsLAMiGZh1RltB9 vsVw== X-Gm-Message-State: APjAAAVJMeK002gsNI9/ZME/967u2bCUbZC4ymOEFGzk1x/tXuFrqKOs wVCHhxn3JYRoVaEnXs3EiyI= X-Google-Smtp-Source: APXvYqwLjezjywoAPHgx7CY1NFZiNpD7zOOAE5ZJ7jcWkYO7AuQCSFbS50Vhfw2LtFbQb0kXhEmj1w== X-Received: by 2002:a1c:4383:: with SMTP id q125mr17508299wma.122.1568033826252; Mon, 09 Sep 2019 05:57:06 -0700 (PDT) Received: from localhost (p2E5BE0B8.dip0.t-ipconnect.de. [46.91.224.184]) by smtp.gmail.com with ESMTPSA id q15sm12601630wmb.28.2019.09.09.05.57.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 05:57:05 -0700 (PDT) From: Thierry Reding To: Jens Axboe , Ulf Hansson , Adrian Hunter Cc: Yoshihiro Shimoda , Christoph Hellwig , Simon Horman , Jon Hunter , linux-block@vger.kernel.org, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH 3/3] mmc: sdhci: Set DMA maximum segment size to 64 KiB Date: Mon, 9 Sep 2019 14:56:58 +0200 Message-Id: <20190909125658.30559-4-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190909125658.30559-1-thierry.reding@gmail.com> References: <20190909125658.30559-1-thierry.reding@gmail.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Thierry Reding DMA descriptors used with SDHCI have a 16-bit field that specifies the number of bytes to transfer per segment. A segment's size may therefore never exceed 64 KiB. Signed-off-by: Thierry Reding --- drivers/mmc/host/sdhci.c | 5 +++++ drivers/mmc/host/sdhci.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index d814dc004bad..b59d063646bf 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3555,6 +3555,10 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, */ host->adma_table_cnt = SDHCI_MAX_SEGS * 2 + 1; + /* ADMA supports a maximum of 64 KiB per descriptor */ + dev->dma_parms = &host->dma_params; + dma_set_max_seg_size(dev, SZ_64K); + return host; } @@ -4410,6 +4414,7 @@ EXPORT_SYMBOL_GPL(sdhci_remove_host); void sdhci_free_host(struct sdhci_host *host) { + host->mmc->parent->dma_parms = NULL; mmc_free_host(host->mmc); } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index cf3d1ed91909..b543d31bbcdb 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -494,6 +494,7 @@ struct sdhci_host { /* Internal data */ struct mmc_host *mmc; /* MMC structure */ struct mmc_host_ops mmc_host_ops; /* MMC host ops */ + struct device_dma_parameters dma_params; /* DMA parameters */ u64 dma_mask; /* custom DMA mask */ #if IS_ENABLED(CONFIG_LEDS_CLASS)