Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp28753rdb; Mon, 18 Dec 2023 08:05:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGaEkx/ROtUV0ZFZDddUnlng0UsHenmnvCq83EPACNoGoMMISKPWmqI8uzaoVx+3OAgVZwB X-Received: by 2002:a17:903:643:b0:1d3:c40b:25fc with SMTP id kh3-20020a170903064300b001d3c40b25fcmr1081241plb.92.1702915549739; Mon, 18 Dec 2023 08:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702915549; cv=none; d=google.com; s=arc-20160816; b=pBi7jX9NRt018swH9E5SZMr3ngbx/xIMJEU2WWf6CgxRiiDP/eZ2XX2KHsDozwuh+m C/Ic6O5MMrLJie1zT8y/k1lmVwXV5x22mVIoXNmARgMkBf6/Hh/qFneuNESoClhakSvl XQdAHuXBHIrOFi+X2BNyAGhyShg1yzkwANGki3mxhesJskMH+vf0eyErojTCMwbegfQT hJzuFcr0+ffgZcQhazwRU272WL3zixKRNu+66FEKTWECahJL3YaLUdAI3y8fUVu0B0/F IRrsmfFeWdJd/2i/bmXtEVK+ypCr9XbAH8Yza12ivu5f2EBC50UCKUPKpgSsUttmJXlu BQtw== ARC-Message-Signature: i=1; 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=yj46/ACvrF3eiwd4hCymUiupYoe7vW9H5bxHq0bCwGw=; fh=TW+iiIgb5TcPr1uj0fBlPjJd6ndS1XBVlnLPYbFKeWI=; b=pjX8GowBSXr8RRlQ4gp7mbqDEG8eHS64n69odhMVRYZGHyxyLVakUNcKZAz50DvhOf OaLTDUV/H7OmNtynDa8Zk6JaokgCcPbOEVdZK2fYh/E7n4E9mWV9bRam9P5McKsaZFP/ VJama/sCHT8kZS4NWkJotlzf8zdnQ+EZyTHbQihUo9QNg4kf3dWIv+LxkLdpQJwMwqc0 6ccl01tp2elNt/Y4e5FJ5xYkOtDjftiAGsabMDl+Jdwt4pLUMmFy0s6zqzNO9EFtsNQ2 5q10+PxlLY7nfqtV6l728RgXPeJXy2B5jgrl29gZpUzrXc0qboR1ODlascyb/Klp39LC szhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=P0CPv0pp; spf=pass (google.com: domain of linux-kernel+bounces-4000-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4000-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h2-20020a170902f54200b001cfa70f3a2asi18526393plf.245.2023.12.18.08.05.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:05:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4000-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=P0CPv0pp; spf=pass (google.com: domain of linux-kernel+bounces-4000-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4000-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D11C9B23D84 for ; Mon, 18 Dec 2023 15:59:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F100498B6; Mon, 18 Dec 2023 15:58:28 +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="P0CPv0pp" X-Original-To: linux-kernel@vger.kernel.org Received: from mx07-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 D9D6B498B2; Mon, 18 Dec 2023 15:58:24 +0000 (UTC) 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 (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BIBg0j4000513; Mon, 18 Dec 2023 16:57:59 +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=yj46/ACvrF3eiwd4hCymUiupYoe7vW9H5bxHq0bCwGw=; b=P0 CPv0pp674iXIQqAO1rHmVTSlvHlctgf+t0Nh5ZGsq3m9njB0NBHsdYGTrWKDEO6+ f23srofghPpiOr9voBctmnTXgjMw+RDvwItCZmRWQYnGhIvM6BNJDfXYy/bSlQK4 pE8DwLMgJWj/+KBdyw4S/XHf9OAoN9eIezYTKpRpQQyLohu6U6p4TuVe03dnX8wA etpIu+BhQcb15AwkSrrP8qvP+Xx4kM7onAAC6B7twjshW2vJz93uNEtrJSql4p4g zO4R1OhEBHm2DhLM0bjyQR3UTcBk2NL8HfE8+zcLIOvu8+VOQueLpJZFkTOHhZ4o EA8yt31h/FdfcT+KpM2w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3v11w8rv8q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Dec 2023 16:57:59 +0100 (CET) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 17C4F10005E; Mon, 18 Dec 2023 16:57:59 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0CB9F25F4AE; Mon, 18 Dec 2023 16:57:59 +0100 (CET) Received: from localhost (10.129.178.213) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 18 Dec 2023 16:57:58 +0100 From: Alain Volmat To: Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , Alexandre Torgue , Alain Volmat , Erwan Leray , Fabrice Gasnier CC: , , , , Subject: [PATCH 1/6] spi: stm32: use dma_get_slave_caps prior to configuring dma channel Date: Mon, 18 Dec 2023 16:57:13 +0100 Message-ID: <20231218155721.359198-2-alain.volmat@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218155721.359198-1-alain.volmat@foss.st.com> References: <20231218155721.359198-1-alain.volmat@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: EQNCAS1NODE4.st.com (10.75.129.82) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-18_11,2023-12-14_01,2023-05-22_02 First check the dma channel capabilities (max burst) before configuring the dma channel. Signed-off-by: Alain Volmat --- drivers/spi/spi-stm32.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index f48e4dcc29fc..af0c27d8d704 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -1157,15 +1157,19 @@ static void stm32_spi_dma_rx_cb(void *data) * stm32_spi_dma_config - configure dma slave channel depending on current * transfer bits_per_word. * @spi: pointer to the spi controller data structure + * @dma_chan: pointer to the DMA channel * @dma_conf: pointer to the dma_slave_config structure * @dir: direction of the dma transfer */ static void stm32_spi_dma_config(struct stm32_spi *spi, + struct dma_chan *dma_chan, struct dma_slave_config *dma_conf, enum dma_transfer_direction dir) { enum dma_slave_buswidth buswidth; + struct dma_slave_caps caps; u32 maxburst; + int ret; if (spi->cur_bpw <= 8) buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; @@ -1184,6 +1188,11 @@ static void stm32_spi_dma_config(struct stm32_spi *spi, maxburst = 1; } + /* Get the DMA channel caps, and adjust maxburst if possible */ + ret = dma_get_slave_caps(dma_chan, &caps); + if (!ret) + maxburst = min(maxburst, caps.max_burst); + memset(dma_conf, 0, sizeof(struct dma_slave_config)); dma_conf->direction = dir; if (dma_conf->direction == DMA_DEV_TO_MEM) { /* RX */ @@ -1366,7 +1375,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi, rx_dma_desc = NULL; if (spi->rx_buf && spi->dma_rx) { - stm32_spi_dma_config(spi, &rx_dma_conf, DMA_DEV_TO_MEM); + stm32_spi_dma_config(spi, spi->dma_rx, &rx_dma_conf, DMA_DEV_TO_MEM); dmaengine_slave_config(spi->dma_rx, &rx_dma_conf); /* Enable Rx DMA request */ @@ -1382,7 +1391,7 @@ static int stm32_spi_transfer_one_dma(struct stm32_spi *spi, tx_dma_desc = NULL; if (spi->tx_buf && spi->dma_tx) { - stm32_spi_dma_config(spi, &tx_dma_conf, DMA_MEM_TO_DEV); + stm32_spi_dma_config(spi, spi->dma_tx, &tx_dma_conf, DMA_MEM_TO_DEV); dmaengine_slave_config(spi->dma_tx, &tx_dma_conf); tx_dma_desc = dmaengine_prep_slave_sg( -- 2.25.1