Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2601598rdb; Mon, 12 Feb 2024 09:53:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVYoVMrWRC/lSjIGABuyIF5rFj1+8nUjLr+c6X8IfRcvtn27NmAShA/RZHHweO5Lx/SMi4 X-Received: by 2002:a05:6808:1183:b0:3bf:d775:616e with SMTP id j3-20020a056808118300b003bfd775616emr7765405oil.53.1707760432587; Mon, 12 Feb 2024 09:53:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707760432; cv=pass; d=google.com; s=arc-20160816; b=mOR1FGVkyp7TnZUWxrdfauHRYiDXSMFfJdnE6DcKR+L86hW7UtwVu3is9WUT6YSVg3 RLp9UJJWWMs//UCPZwb8nFG0E9c+SWtFmvxXV0MMR245AfPjeZQau0TAHwehYf92CiUn TrW9/fu6EkBER1sf9W5mJMmhKZ44b/6drRRZwJstbpvd6lZ5yWXkIZN+NAqBCJLnPo4h 2uWYFxXEu5PxsYqKtfRPcFUUXrNrLRKCTHi+4IcqiJSwavmDBCgC3QC9CeTsRdZrXybR pzeC+x8VScVKSdnMn7bYnI9EESFHwo5/3STn7jX2knEPbj6fVkMLVVo2+OzQ0DUv0TM/ hDWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7EgcsVO6falgJZLPBOMxl9PtlOXDfK5LsUZXJt7kC2w=; fh=wC+Z8i0p1BkHHaU0fa0AsIzoJDKmfhJzGBYOgtcZ5rs=; b=o6Mt7q1nel8UqIQHS8b/z4WXNnjFbOMvzzWCp93is4g7i3pXnLjOup79Paj7Wuuvi3 jfITO76X538OGqcjItFXal1JkElqKI31YDTGd+Shx/SivdnpOMKgEbHKl9lJ9gs8u9Ae uvpk5GduruEMZzzAVrhN/aXaXkBPjwcyhaUX9LzQhBBNTpw0plTQS98CkVQFkmmNPwQe Cwi70TuSin/fwo2p5z102l+HUr69BZU1azoXfvFdR1TfDVK1EgrLcd3vfV5fxPIuocQI SoC4QsqOVh7ENNfQcdpHXazl0MpU/scVaX69ORnK5t9FoicUkP8K8m+0hfoJaOfv3meq yqOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=dfJ186Zk; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-62140-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62140-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com X-Forwarded-Encrypted: i=2; AJvYcCWhQsm4pN59ommEDfNLNJuzuO/n4slL1wyR47AyLIClNrE5dug+uWuUR1pZGfzlryu49XS81JdecO5dy2FTeHRb/o8BwYRxq7sBuadpoQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e13-20020ac84e4d000000b0042da78ced67si843293qtw.172.2024.02.12.09.53.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 09:53:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62140-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=dfJ186Zk; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-62140-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62140-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2402F1C21857 for ; Mon, 12 Feb 2024 17:53:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D26946426; Mon, 12 Feb 2024 17:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="dfJ186Zk" Received: from mx08-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9AAA40C09; Mon, 12 Feb 2024 17:51:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.207.212.93 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707760312; cv=none; b=u9b6f1rzKRtK31cTuoVUXFmELJgoZXrNfnAj+qE2z3dl77pHuc460EH04OiFlqALJAkcpXVZJURiQ5DzMM+XtCDj6whRUUbIhF1l2RAQ+parNqDUasKlPYkKcAIgvb5QO+TSzg+Kq+DNJbLSmu/C74xZGagS5r7o/EWvZVJfI4U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707760312; c=relaxed/simple; bh=FxpiC9oLFHKvYMkoKKpXU246PDSXAZQkVh+bWJnRQFk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V8e/647vZSwpAr3S0Niyq8hyMSrAl+5G6QX7VibgCCcnE4NLfJduZbTZdhc4KslUiY4Gj658i+vBoQC6hqup2x0e8Z1DtTvHC7e+fWpKq3PFHcYkdiECwH7uN9hAWQLK1noqq6rDTtfjULTk9oSkBd8fXKix5eVxDzSKgi8e6XE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=dfJ186Zk; arc=none smtp.client-ip=91.207.212.93 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0369457.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41CHPxGr027428; Mon, 12 Feb 2024 18:51:38 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= selector1; bh=7EgcsVO6falgJZLPBOMxl9PtlOXDfK5LsUZXJt7kC2w=; b=df J186ZkfxPnp6+AaHR4CZsMPB2hNYQkaF9c3ANzqr+l36qlxZGrcYI/pG75iAj53D 4bStrMflP9gYRzTrbcfQJ3rsFxJJgA3+v+zUpMppGxo9NpiErlcokRERlxnjvFpf 3F5m96sMZZhpqHjsglG92FCC2Ka66kMv8yGx4ese4eiTcwLdk76aRzZQxszBPtDE S93W5zWXaqP92yksyjFmp5/8GcPikfv319clDVDUzA49+MtNvWoWZgaHFVsElKxM w6hsEthYhAfmt9Ju6QjjKU+vz2yL7CgHpGrpcoLMsBrIiicE/LnPmQbgieuIPn/k UuCmy6ghnrWYP9W5LXDQ== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3w6mynd48m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Feb 2024 18:51:37 +0100 (CET) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 927234002D; Mon, 12 Feb 2024 18:51:34 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D898C257A8E; Mon, 12 Feb 2024 18:50:51 +0100 (CET) Received: from localhost (10.201.22.200) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 12 Feb 2024 18:50:51 +0100 From: Christophe Kerello To: , , , , , , CC: , , , , Christophe Kerello Subject: [PATCH 09/12] mtd: rawnand: stm32_fmc2: use dma_get_slave_caps to get DMA max burst Date: Mon, 12 Feb 2024 18:48:19 +0100 Message-ID: <20240212174822.77734-10-christophe.kerello@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240212174822.77734-1-christophe.kerello@foss.st.com> References: <20240212174822.77734-1-christophe.kerello@foss.st.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-12_15,2024-02-12_03,2023-05-22_02 use dma_get_slave_caps API to get the max burst size of a DMA channel. For MP1 SOCs, MDMA is used and the max burst size is 128. For MP25 SOC, DMA3 is used and the max burst size is 64. Signed-off-by: Christophe Kerello --- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 29 +++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c index 88811139aaf5..a7db7b675514 100644 --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c @@ -264,6 +264,8 @@ struct stm32_fmc2_nfc { struct sg_table dma_ecc_sg; u8 *ecc_buf; int dma_ecc_len; + u32 tx_dma_max_burst; + u32 rx_dma_max_burst; struct completion complete; struct completion dma_data_complete; @@ -347,20 +349,26 @@ static int stm32_fmc2_nfc_select_chip(struct nand_chip *chip, int chipnr) stm32_fmc2_nfc_setup(chip); stm32_fmc2_nfc_timings_init(chip); - if (nfc->dma_tx_ch && nfc->dma_rx_ch) { + if (nfc->dma_tx_ch) { memset(&dma_cfg, 0, sizeof(dma_cfg)); - dma_cfg.src_addr = nfc->data_phys_addr[nfc->cs_sel]; dma_cfg.dst_addr = nfc->data_phys_addr[nfc->cs_sel]; - dma_cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; dma_cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; - dma_cfg.src_maxburst = 32; - dma_cfg.dst_maxburst = 32; + dma_cfg.dst_maxburst = nfc->tx_dma_max_burst / + dma_cfg.dst_addr_width; ret = dmaengine_slave_config(nfc->dma_tx_ch, &dma_cfg); if (ret) { dev_err(nfc->dev, "tx DMA engine slave config failed\n"); return ret; } + } + + if (nfc->dma_rx_ch) { + memset(&dma_cfg, 0, sizeof(dma_cfg)); + dma_cfg.src_addr = nfc->data_phys_addr[nfc->cs_sel]; + dma_cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + dma_cfg.src_maxburst = nfc->rx_dma_max_burst / + dma_cfg.src_addr_width; ret = dmaengine_slave_config(nfc->dma_rx_ch, &dma_cfg); if (ret) { @@ -1545,6 +1553,7 @@ static int stm32_fmc2_nfc_setup_interface(struct nand_chip *chip, int chipnr, static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc) { + struct dma_slave_caps caps; int ret = 0; nfc->dma_tx_ch = dma_request_chan(nfc->dev, "tx"); @@ -1557,6 +1566,11 @@ static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc) goto err_dma; } + ret = dma_get_slave_caps(nfc->dma_tx_ch, &caps); + if (ret) + return ret; + nfc->tx_dma_max_burst = caps.max_burst; + nfc->dma_rx_ch = dma_request_chan(nfc->dev, "rx"); if (IS_ERR(nfc->dma_rx_ch)) { ret = PTR_ERR(nfc->dma_rx_ch); @@ -1567,6 +1581,11 @@ static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc) goto err_dma; } + ret = dma_get_slave_caps(nfc->dma_rx_ch, &caps); + if (ret) + return ret; + nfc->rx_dma_max_burst = caps.max_burst; + nfc->dma_ecc_ch = dma_request_chan(nfc->dev, "ecc"); if (IS_ERR(nfc->dma_ecc_ch)) { ret = PTR_ERR(nfc->dma_ecc_ch); -- 2.25.1