Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp587841iog; Mon, 13 Jun 2022 08:40:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6udx2yEmzTWonEHJh515qLHX9Hdvj3biiPKik7/2jZdGQGpzKDgUiy+AwvuvVRqbvGr+/ X-Received: by 2002:a63:d806:0:b0:408:9e5d:68b9 with SMTP id b6-20020a63d806000000b004089e5d68b9mr221238pgh.22.1655134807337; Mon, 13 Jun 2022 08:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134807; cv=none; d=google.com; s=arc-20160816; b=yamBfBEO/sEGGeW1XUFAJzjc88SZDZrlEQA0tBdeYpsKAH/A4zt956sJBtC1jtWHAr Tj+RVGfBJ93Qx27stUu84ReJqybmyMrAl/F+yYTNXCiaSIFTwoFUY6kbV2GXlGr1bBvx +ank0SnVHmJF7a7cXWWF6wXoi3xeAi9SUpcZwaOqSWAa23l6U53f8+ewgqjpdk7Pxbak eEAseawk2Y/RekqjrEB3rmnQiy5wDJGWDtD0mLY5lyUT4ZK4BESE1HqipiLcHR6SjZKl g7I1P8LlnF7/GCVNtUaC/fN8H9h5hG90e0y74xGSqa85Lrh7S96kjrqll4cadVo8iTA9 uPOg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KlU/ytYpx/MnrnOUFHlhxXK6n3552oB80eEMFcHSzuU=; b=LMxUGLYW900RiITDEc1we1rOq9geevdp2pqObcu4+PytwM5BbNX0DWyAvjLKHnezE9 IP2ftrmaEDK5aZFDvE0+7UjGxUHp6QifF7Jo2gGZS+MlVEyb9GFJ5n1SOWj3SywfXY35 Pzi0cT2YZk+cVwf+VvOXzr/i7MxaVo42AS6pURQd5DvGOW16vMIeJGqMPyM3C5v5tIOh XDhzftUeVzIeSXCQOJhk0CmN7trva5Fj9xpmRxFgNq4BhXqosOvovvmg/V3FGyFHJEjh jOLBGfCPqdO2iAW6QQwgB8V7f1SvjbTf3IEOT2Wong6EYxGbDRBWFeYM/GNXALkG9cgO WlhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XQYMmWBC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a170902ec8300b00168a4ef6a67si11980266plg.17.2022.06.13.08.39.53; Mon, 13 Jun 2022 08:40:07 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XQYMmWBC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351373AbiFMK7w (ORCPT + 99 others); Mon, 13 Jun 2022 06:59:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350175AbiFMKyo (ORCPT ); Mon, 13 Jun 2022 06:54:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD71EDFC2; Mon, 13 Jun 2022 03:29:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 55DD5B80E5E; Mon, 13 Jun 2022 10:29:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4BFBC34114; Mon, 13 Jun 2022 10:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116193; bh=RNeHE94BSj+4gptWB0XYtF6cAVaNg9bbvHZewnS9el8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQYMmWBCetOzAnQ7oLGgKZ0534YGQ1RYHHXCRUsOt0Pf11CEN8TibFcJOom2oMpow +b3GTl2T1cPp/Rcfq9CZWLrr41X//A/gZStc0iDj2QBiAGFbI/DG4MZX//fjJ5hCqN rfYhccFulWlZq8D/9iae2gQHmdA1pj2YlpCjprqI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aidan MacDonald , Ulf Hansson , Sasha Levin Subject: [PATCH 5.4 030/411] mmc: jz4740: Apply DMA engine limits to maximum segment size Date: Mon, 13 Jun 2022 12:05:03 +0200 Message-Id: <20220613094929.408384514@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: Aidan MacDonald [ Upstream commit afadb04f1d6e74b18a253403f5274cde5e3fd7bd ] Do what is done in other DMA-enabled MMC host drivers (cf. host/mmci.c) and limit the maximum segment size based on the DMA engine's capabilities. This is needed to avoid warnings like the following with CONFIG_DMA_API_DEBUG=y. ------------[ cut here ]------------ WARNING: CPU: 0 PID: 21 at kernel/dma/debug.c:1162 debug_dma_map_sg+0x2f4/0x39c DMA-API: jz4780-dma 13420000.dma-controller: mapping sg segment longer than device claims to support [len=98304] [max=65536] CPU: 0 PID: 21 Comm: kworker/0:1H Not tainted 5.18.0-rc1 #19 Workqueue: kblockd blk_mq_run_work_fn Stack : 81575aec 00000004 80620000 80620000 80620000 805e7358 00000009 801537ac 814c832c 806276e3 806e34b4 80620000 81575aec 00000001 81575ab8 09291444 00000000 00000000 805e7358 81575958 ffffffea 8157596c 00000000 636f6c62 6220646b 80387a70 0000000f 6d5f6b6c 80620000 00000000 81575ba4 00000009 805e170c 80896640 00000001 00010000 00000000 00000000 00006098 806e0000 ... Call Trace: [<80107670>] show_stack+0x84/0x120 [<80528cd8>] __warn+0xb8/0xec [<80528d78>] warn_slowpath_fmt+0x6c/0xb8 [<8016f1d4>] debug_dma_map_sg+0x2f4/0x39c [<80169d4c>] __dma_map_sg_attrs+0xf0/0x118 [<8016a27c>] dma_map_sg_attrs+0x14/0x28 [<804f66b4>] jz4740_mmc_prepare_dma_data+0x74/0xa4 [<804f6714>] jz4740_mmc_pre_request+0x30/0x54 [<804f4ff4>] mmc_blk_mq_issue_rq+0x6e0/0x7bc [<804f5590>] mmc_mq_queue_rq+0x220/0x2d4 [<8038b2c0>] blk_mq_dispatch_rq_list+0x480/0x664 [<80391040>] blk_mq_do_dispatch_sched+0x2dc/0x370 [<80391468>] __blk_mq_sched_dispatch_requests+0xec/0x164 [<80391540>] blk_mq_sched_dispatch_requests+0x44/0x94 [<80387900>] __blk_mq_run_hw_queue+0xb0/0xcc [<80134c14>] process_one_work+0x1b8/0x264 [<80134ff8>] worker_thread+0x2ec/0x3b8 [<8013b13c>] kthread+0x104/0x10c [<80101dcc>] ret_from_kernel_thread+0x14/0x1c ---[ end trace 0000000000000000 ]--- Signed-off-by: Aidan MacDonald Link: https://lore.kernel.org/r/20220411153753.50443-1-aidanmacdonald.0x0@gmail.com Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/jz4740_mmc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c index f816c06ef916..a316c912a118 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -224,6 +224,26 @@ static int jz4740_mmc_acquire_dma_channels(struct jz4740_mmc_host *host) return PTR_ERR(host->dma_rx); } + /* + * Limit the maximum segment size in any SG entry according to + * the parameters of the DMA engine device. + */ + if (host->dma_tx) { + struct device *dev = host->dma_tx->device->dev; + unsigned int max_seg_size = dma_get_max_seg_size(dev); + + if (max_seg_size < host->mmc->max_seg_size) + host->mmc->max_seg_size = max_seg_size; + } + + if (host->dma_rx) { + struct device *dev = host->dma_rx->device->dev; + unsigned int max_seg_size = dma_get_max_seg_size(dev); + + if (max_seg_size < host->mmc->max_seg_size) + host->mmc->max_seg_size = max_seg_size; + } + return 0; } -- 2.35.1