From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43074C433EF for ; Wed, 23 Feb 2022 10:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:CC:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=skBv2j0xaIyUArUiw0CG7inUngucdoqrqlwiApa4tJg=; b=MHCDELp7JJj/t5 D1I2Wj9EkEKdVlXcA3ZylYTQ29biqoq60IEvdQ+Q8yq9EECBrfee/y9NtxBJdck5ZfIYFqIo+Nd8K RYHA+B8izJbuyKcKxAayuMTVwAsgpFBD4VyFByq/HsoCLjyJACBeq1pt/bZ09VBTkE2N45j1MksYE SE3THEX+HzVcFnVoKp63QrL8IRaxJwCO0x70UFc/5XP+TLQYK0OlL7GHTSXEXyKzlXz1w+91ywW8c kNh9k0lqFPA0JxW9P6No+3LL0FJAWpDKINO5qmNi4aLCNpFx+XEdo0MMm41wIB7MSDb1NZsmxj5P6 9OcsxnUvZXvnjCVTmM1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMpAy-00Djse-GM; Wed, 23 Feb 2022 10:47:17 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMpAq-00Djof-Rf for linux-arm-kernel@lists.infradead.org; Wed, 23 Feb 2022 10:47:11 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21N7j1I6022524; Wed, 23 Feb 2022 11:46:51 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=g5cIGSQtNpUVPRLqm3DZCyx3XoXCarlJubY2NLyvtxs=; b=sTg4NpGyMlza/KSk5m5jlpN01FvxR8SbwEpwfyIKwCpx7bQxEaWvrtADvvmq54sE7Cim FtKtaNFOcuWfdp8pAhFbi6djXudPsMfDKboxc6YyzjtwtH1E9GF1QEiQ8ApqV/H1SSRq gZTvI9W/DszKa4zKQm0ZHnGsCVFwt8w+zgmoqSEVMasx/JIuZucFKVvgOne6Dp5fF/O5 9fVbwAQ+nelcWOh7TbbdgR87/Mf4on2bycba9/3p2IcxK5dEgN7qvV+hpfm7TYyIOaYm cHJw+h4g1MXHw6vkYnat9N5IhchK03DYfz1REdmwPi8LtqM/e2KkLdKbQ47oLjVK/R2I uA== 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 3edgte16a6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Feb 2022 11:46:51 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B8FDF100034; Wed, 23 Feb 2022 11:46:49 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B147321E660; Wed, 23 Feb 2022 11:46:49 +0100 (CET) Received: from [10.211.4.186] (10.75.127.50) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Wed, 23 Feb 2022 11:46:48 +0100 Message-ID: <903027b2-46b7-4dd4-0baa-5d66c424fe9c@foss.st.com> Date: Wed, 23 Feb 2022 11:46:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] dmaengine: stm32-mdma: check the channel availability (secure or not) Content-Language: en-US To: Vinod Koul , Maxime Coquelin , Alexandre Torgue CC: , , , References: <20220117100300.14150-1-amelie.delaunay@foss.st.com> From: Amelie DELAUNAY In-Reply-To: <20220117100300.14150-1-amelie.delaunay@foss.st.com> X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-02-23_03,2022-02-23_01,2022-02-23_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220223_024709_723224_A7720BAA X-CRM114-Status: GOOD ( 27.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, Kind reminder. Regards, Amelie On 1/17/22 11:03, Amelie Delaunay wrote: > STM32_MDMA_CCR bit[8] is used to enable Secure Mode (SM). If this bit is > set, it means that all the channel registers are write-protected. So the > channel is not available for Linux use. > > Add stm32_mdma_filter_fn() callback filter and give it to > __dma_request_chan (instead of dma_get_any_slave_channel()), to exclude the > channel if it is marked Secure. > > Signed-off-by: Amelie Delaunay > --- > drivers/dma/stm32-mdma.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c > index 6f57ff0e7b37..95e5831e490a 100644 > --- a/drivers/dma/stm32-mdma.c > +++ b/drivers/dma/stm32-mdma.c > @@ -73,6 +73,7 @@ > #define STM32_MDMA_CCR_WEX BIT(14) > #define STM32_MDMA_CCR_HEX BIT(13) > #define STM32_MDMA_CCR_BEX BIT(12) > +#define STM32_MDMA_CCR_SM BIT(8) > #define STM32_MDMA_CCR_PL_MASK GENMASK(7, 6) > #define STM32_MDMA_CCR_PL(n) FIELD_PREP(STM32_MDMA_CCR_PL_MASK, (n)) > #define STM32_MDMA_CCR_TCIE BIT(5) > @@ -248,6 +249,7 @@ struct stm32_mdma_device { > u32 nr_channels; > u32 nr_requests; > u32 nr_ahb_addr_masks; > + u32 chan_reserved; > struct stm32_mdma_chan chan[STM32_MDMA_MAX_CHANNELS]; > u32 ahb_addr_masks[]; > }; > @@ -1456,10 +1458,23 @@ static void stm32_mdma_free_chan_resources(struct dma_chan *c) > chan->desc_pool = NULL; > } > > +static bool stm32_mdma_filter_fn(struct dma_chan *c, void *fn_param) > +{ > + struct stm32_mdma_chan *chan = to_stm32_mdma_chan(c); > + struct stm32_mdma_device *dmadev = stm32_mdma_get_dev(chan); > + > + /* Check if chan is marked Secure */ > + if (dmadev->chan_reserved & BIT(chan->id)) > + return false; > + > + return true; > +} > + > static struct dma_chan *stm32_mdma_of_xlate(struct of_phandle_args *dma_spec, > struct of_dma *ofdma) > { > struct stm32_mdma_device *dmadev = ofdma->of_dma_data; > + dma_cap_mask_t mask = dmadev->ddev.cap_mask; > struct stm32_mdma_chan *chan; > struct dma_chan *c; > struct stm32_mdma_chan_config config; > @@ -1485,7 +1500,7 @@ static struct dma_chan *stm32_mdma_of_xlate(struct of_phandle_args *dma_spec, > return NULL; > } > > - c = dma_get_any_slave_channel(&dmadev->ddev); > + c = __dma_request_channel(&mask, stm32_mdma_filter_fn, &config, ofdma->of_node); > if (!c) { > dev_err(mdma2dev(dmadev), "No more channels available\n"); > return NULL; > @@ -1615,6 +1630,10 @@ static int stm32_mdma_probe(struct platform_device *pdev) > for (i = 0; i < dmadev->nr_channels; i++) { > chan = &dmadev->chan[i]; > chan->id = i; > + > + if (stm32_mdma_read(dmadev, STM32_MDMA_CCR(i)) & STM32_MDMA_CCR_SM) > + dmadev->chan_reserved |= BIT(i); > + > chan->vchan.desc_free = stm32_mdma_desc_free; > vchan_init(&chan->vchan, dd); > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel