Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2187006iof; Tue, 7 Jun 2022 22:34:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5TrOosITAml0vyMPb5VwVbRZN2PWQ5adEv/oNxZWT+uBRe6NndWn2JilqvNabcbqI/4pf X-Received: by 2002:a05:6a00:1705:b0:51c:26ae:569c with SMTP id h5-20020a056a00170500b0051c26ae569cmr11905465pfc.28.1654666456877; Tue, 07 Jun 2022 22:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666456; cv=none; d=google.com; s=arc-20160816; b=VnF2wUE5pET2bahrvyz8QW+pVDP3wCrUum9vggtr46CkNKCZV6+M41y/weVEuGEqIA 4O6trFKgbCapNa6JFrYBsSv+n1vbrBvP6zJgKQi6ENfI0ZzPRrF1YhwLxRhp1Aow+Dvf 5Rb+kq7iNGXL5f3NKwIcpCSNL163yqT2xrzSBbMR6NtRXAp9ZeUmfbe+Q3+VcmZswREX 4Vo9jDz3Y6eRUZnVSgZIsNs3gsPocT2IKO7FjAC32JNooCLZyUTBBZFOoXvN01/OOvB+ BZPNFpUBXLz6t0dIHgD3krVUEoyVfTMhBPtNKMJFOcADninSpYP+X+fBJu23R5/M0orW ct2g== 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=16niDiHxWd5A2jZryAsHXIVjK2n2e8eNSR5f6HSrIEE=; b=VHjBkPm37YE1i0BxLtjZjXWXidJ760qjeaGEUrqyIzShSxpmMLxlkGlvh8G3brNPbT bcu08gYF5+Z1UNZ7Fa00eB0jJxMc0tuR1WwW0NXCsmhNdo1kBAyIp2CZ/ZJZXKeGzWXQ XEoYnsi99BPcDVWAqn1t40bJZo4YkzkYo3xc/ClI+rmtQd1ojg+hfUsK60ZirN4TIyQa 0s/ezBXSwAamp8rEge4U4139LfcV/hckvIDHHMGvwkXHB7jEIOTKASrhZ+FY0ezr9fou ZlXkbhy7kF+nxXMWe9MbMpRZwao1hR++8QBnxTeD9shsd3JkX/wFV/Q1KL9HA/EqhYA2 Y1Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rWyzZg+J; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i1-20020a170902cf0100b0016793c0e3dcsi5129998plg.545.2022.06.07.22.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:34:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rWyzZg+J; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 869352DF113; Tue, 7 Jun 2022 22:01:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384138AbiFGWRm (ORCPT + 99 others); Tue, 7 Jun 2022 18:17:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379994AbiFGVLW (ORCPT ); Tue, 7 Jun 2022 17:11:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80EF7217345; Tue, 7 Jun 2022 11:52:48 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 0BCF961579; Tue, 7 Jun 2022 18:52:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CF06C385A2; Tue, 7 Jun 2022 18:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627967; bh=Dz8ai7iKPglweNQzZKbSzXedFDeTrb0db8t40QK1R4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rWyzZg+JzzhZiElCl3VS/dv4gDALHBPkAUW/q7jiaS+jFj7snTLzDwyaip44CzfWn 2YqeXRvRG+hWqTVHpEAnlXtoWi8hMifSLKRhWJ1V0+0JXp2SyOoNF3KX0iXHZRAkhV 7acVgui8b6kM8K2UP/ruTdGQgm+mWa/6I+XugYtY= 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.18 107/879] mmc: jz4740: Apply DMA engine limits to maximum segment size Date: Tue, 7 Jun 2022 18:53:45 +0200 Message-Id: <20220607165005.800346734@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 7ab1b38a7be5..b1d563b2ed1b 100644 --- a/drivers/mmc/host/jz4740_mmc.c +++ b/drivers/mmc/host/jz4740_mmc.c @@ -247,6 +247,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