From patchwork Mon Feb 12 17:48:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Kerello X-Patchwork-Id: 199966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp73788dyb; Mon, 12 Feb 2024 09:54:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBD8qDsDlqul0GGZmBNzpmB+uW5ojIEp4hQsJX6UZUaPLRajpo+lPbmxrONj+0r0V1ebzp X-Received: by 2002:a17:906:3b9a:b0:a3c:d053:1272 with SMTP id u26-20020a1709063b9a00b00a3cd0531272mr1252026ejf.15.1707760444676; Mon, 12 Feb 2024 09:54:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707760444; cv=pass; d=google.com; s=arc-20160816; b=freqN2kqAubPZbs71XEdLZxHn1u32yZtOtPKI/umSGYcVFt7cbW/Uyee2KNAubnAsT WYSiv4F3ytX7wD235Y0V4YhjeLveUJVuFuIkRKefdxH6reJDXMppHC1iAjifLjBEQfjg qZJnpvRFw6BTJx+PpNJ+e8Ti6jiiE1hfnAnldnAyXpacXdJFh8cWWkREcoapRu5BSs46 DLCiu/WT5jiXLOM4h33Qc4ZYwurUWGR3aJWzE3HTRNxK2rer8VGf/EmYkTuBJSjJh08I LgX3XwGhwH8O7neXkRz5qJs6s+86G8EaxdllRb+bxDWRs+nZ4JhDaP7vss99BGFbgXcX R7FA== 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=RhTg+iZ6T+zChqgXFRizf5y7tzKVpWgaIVOkjO1Gzeo=; b=FmqvV2OquVW2k/DOi5LejdbVo2De7oq6zDUt/O66pZvAJRHXkod4ARG9Xw3Lw0un/q xTNhG89A85k5mZBBtlYraayEqZllInACRLtjGtxwFNhkq7+xSw12aoJLKjaVlPWO1P5/ SmryptAsNU+5t3VemU0b2FxNalZCh7xcMmFivo0iDTfDgH/7BNAZm8N+MkNlFa7FjFbo Uhei39Bea4HtbbxyXvmn/9QqxldzYYzCU5NaTc+IH08PmVbNYO9K3s9VAxWToTVZp8mL amk5c8vpgsDzhbQgp5JrF0s+BHteT1RAwlvjVMaw5T4X7kpn2wJMm4P6yZA1j8JC8sRA HS8w==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62140-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com X-Forwarded-Encrypted: i=2; AJvYcCUQsSMHSWE5A7WByZk0aSeosuJ5QuCsYuy8EtMR4gDrAXqCNNoGx10Tgaxs4U1ZIOc/dqSlf3NAfWiqc41lL1Eyg/Bn4Q== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qa31-20020a170907869f00b00a37f3e33007si413238ejc.619.2024.02.12.09.54.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 09:54:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62140-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62140-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4BE731F22DAB for ; Mon, 12 Feb 2024 17:54:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2511F4653C; Mon, 12 Feb 2024 17:51:55 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790716616099649492 X-GMAIL-MSGID: 1790716616099649492 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);