Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2066828yba; Sun, 5 May 2019 21:52:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIt3lcV/93Yi6Ue93CM37rh02FPmdFTLoONLYS5z5Ip8j2bm5XQXEFXkCL+JQ2iHlpLo/+ X-Received: by 2002:a63:e94e:: with SMTP id q14mr28450954pgj.110.1557118327320; Sun, 05 May 2019 21:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557118327; cv=none; d=google.com; s=arc-20160816; b=AEQK3rjEvnbEe6+n3YERj9pJeLuIGKGREP8VR3/8cZ9OUi3OhmO2mRtGsUsxfkePw0 Gony2A2qj23DCBf8m6SfWTA0IaGEEitdznud5X/+frZjtV0Nd6K9hC6V9kiwQl9bzY/f RGUVnsl+yK2RvMES5v5qzl3ZWKidwn9tgo7OmuE4kTqR7QWcDmVGCYVOyHA8smF0lY4A ibwsmOKPC78PtCfZgGHOR48IQcMHrTa6Rn9ElUMqqSDBb0mm8JI+npN1g5O4Gjmeq2Do xEigkhtBvjLJ9I50VOkyZAsmDURkFgIGKYwxZNjFDwQrlTWJZJFSqPQaXTLEtqSaJYMA m64A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=GzaHgoeX6HRTRXwU9I5H6cKQKwKQ7SwKMXfF2Gqzjfc=; b=MpVlAx0NATRxO/w7sZx7qniLsGaXazBKEsBOstcWbYM/WyBgO0aNrxakb1J0EbuLx8 Nr68nzT/vwaERy+EdRx0fzcZiEp/8jkN1g+gVD/tAAPkmRlDdrLtGVr47JROSPjoj+XI HN0t5z1BClgawsWhjYSA9Sptc06jaXK62LYsL9G2+hDBIXr4JBg9GRNV5uM4nCSRbmA3 0hHgQSuwVzcRb1PFNWzQorZTdSaIG5KgZK1hFU60EVbb29klpGkefIHIlELAvh+j8KQ8 TT3Q+b5GmubHcxdvZeEUwqg++5APmK6VtzYr3Q9/Mlh/ulai0s+YCzzTdKnnp6PHPfsU 603Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QPwyQ3h2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si13539957plv.33.2019.05.05.21.51.21; Sun, 05 May 2019 21:52:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QPwyQ3h2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbfEFEtH (ORCPT + 99 others); Mon, 6 May 2019 00:49:07 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:46458 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbfEFEtH (ORCPT ); Mon, 6 May 2019 00:49:07 -0400 Received: by mail-oi1-f195.google.com with SMTP id a7so3353325oie.13 for ; Sun, 05 May 2019 21:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GzaHgoeX6HRTRXwU9I5H6cKQKwKQ7SwKMXfF2Gqzjfc=; b=QPwyQ3h2uEHwPxv8iaZf6hrszwXTPil84uK8d64fjkCax7hPZu7Le2VNv/hIoCcg30 KMJzCQm3rouXV//peObIT94XlBSxQsh91n8kAWxkGxmgwVppGJXGYQRXFod4N/A9u6tS 9+6B2UwXK33scEKkmtgt9CzMCSSGLW10NDv4E1dViftGBsiNLkfgN+FduotdRoEFC8IE wjnGk3+2Wfgd9JRtSkqkU0z7lucy4I3ELmbOMj9XHR6w+u1vkw25sJfJuiVCU5P0nSVu 1jg0wONRtHLRum8M38z3Mftl5XVgtSpUjhFiqJggjYZLJCwitUsKUhxbhA2aOrio2o1C ESgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GzaHgoeX6HRTRXwU9I5H6cKQKwKQ7SwKMXfF2Gqzjfc=; b=DiaCWA/OaA/OmP0aL59nv10Z0D8lwrsTNyfjK1sksuXvbXXxVj0HMhm6nBAWxJ59Ub feU3SdXYSTZMC6kxx9hTOGufzmhvH/RBvRMiSbjicjR9fDfw4ZpOYCF+SbYkNOXRc6qV fzppzqnCJ9ZKCjnujA2mdNgDiCGlwYk181RSskTk2l/18EoUrH7pe58Z2pjTX27KKWT1 yuNENyF+w4q0ZgsBa1nvBlu0HP68234Ia6SJHl34tP2IxGq5oKtxp+CKKebkRoHhZ0Nx LujhVLM71WP4MwNLuP0hC6WGr/ZGe34J3ZvLAoCUAh+g7N7XGDKMsQbgMdGrFtPRaUeI l2aA== X-Gm-Message-State: APjAAAWGDD2gkUCZVR9Gzidee5JM1NKXRHjpic6351Ndx2ifvm3BxIYF RS3pE96xNcIKXeXA7cKGgIcALB8eUhfE4b77WC5Vyw== X-Received: by 2002:aca:61c3:: with SMTP id v186mr7223512oib.27.1557118146389; Sun, 05 May 2019 21:49:06 -0700 (PDT) MIME-Version: 1.0 References: <20190429115723.GK3845@vkoul-mobl.Dlink> <20190429140537.GN3845@vkoul-mobl.Dlink> <20190430082954.GQ3845@vkoul-mobl.Dlink> <20190502060148.GH3845@vkoul-mobl.Dlink> In-Reply-To: <20190502060148.GH3845@vkoul-mobl.Dlink> From: Baolin Wang Date: Mon, 6 May 2019 12:48:54 +0800 Message-ID: Subject: Re: [PATCH 4/7] dmaengine: sprd: Add device validation to support multiple controllers To: Vinod Koul Cc: Dan Williams , eric.long@unisoc.com, Orson Zhai , Chunyan Zhang , Mark Brown , dmaengine@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vinod, On Thu, 2 May 2019 at 14:01, Vinod Koul wrote: > > On 30-04-19, 16:53, Baolin Wang wrote: > > Hi Vinod, > > > > On Tue, 30 Apr 2019 at 16:34, Baolin Wang wrote: > > > > > > On Tue, 30 Apr 2019 at 16:30, Vinod Koul wrote: > > > > > > > > On 30-04-19, 13:30, Baolin Wang wrote: > > > > > On Mon, 29 Apr 2019 at 22:05, Vinod Koul wrote: > > > > > > > > > > > > On 29-04-19, 20:20, Baolin Wang wrote: > > > > > > > On Mon, 29 Apr 2019 at 19:57, Vinod Koul wrote: > > > > > > > > > > > > > > > > On 15-04-19, 20:14, Baolin Wang wrote: > > > > > > > > > From: Eric Long > > > > > > > > > > > > > > > > > > Since we can support multiple DMA engine controllers, we should add > > > > > > > > > device validation in filter function to check if the correct controller > > > > > > > > > to be requested. > > > > > > > > > > > > > > > > > > Signed-off-by: Eric Long > > > > > > > > > Signed-off-by: Baolin Wang > > > > > > > > > --- > > > > > > > > > drivers/dma/sprd-dma.c | 5 +++++ > > > > > > > > > 1 file changed, 5 insertions(+) > > > > > > > > > > > > > > > > > > diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c > > > > > > > > > index 0f92e60..9f99d4b 100644 > > > > > > > > > --- a/drivers/dma/sprd-dma.c > > > > > > > > > +++ b/drivers/dma/sprd-dma.c > > > > > > > > > @@ -1020,8 +1020,13 @@ static void sprd_dma_free_desc(struct virt_dma_desc *vd) > > > > > > > > > static bool sprd_dma_filter_fn(struct dma_chan *chan, void *param) > > > > > > > > > { > > > > > > > > > struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); > > > > > > > > > + struct of_phandle_args *dma_spec = > > > > > > > > > + container_of(param, struct of_phandle_args, args[0]); > > > > > > > > > u32 slave_id = *(u32 *)param; > > > > > > > > > > > > > > > > > > + if (chan->device->dev->of_node != dma_spec->np) > > > > > > > > > > > > > > > > Are you not using of_dma_find_controller() that does this, so this would > > > > > > > > be useless! > > > > > > > > > > > > > > Yes, we can use of_dma_find_controller(), but that will be a little > > > > > > > complicated than current solution. Since we need introduce one > > > > > > > structure to save the node to validate in the filter function like > > > > > > > below, which seems make things complicated. But if you still like to > > > > > > > use of_dma_find_controller(), I can change to use it in next version. > > > > > > > > > > > > Sorry I should have clarified more.. > > > > > > > > > > > > of_dma_find_controller() is called by xlate, so you already run this > > > > > > check, so why use this :) > > > > > > > > > > The of_dma_find_controller() can save the requested device node into > > > > > dma_spec, and in the of_dma_simple_xlate() function, it will call > > > > > dma_request_channel() to request one channel, but it did not validate > > > > > the device node to find the corresponding dma device in > > > > > dma_request_channel(). So we should in our filter function to validate > > > > > the device node with the device node specified by the dma_spec. Hope I > > > > > make things clear. > > > > > > > > But dma_request_channel() calls of_dma_request_slave_channel() which > > > > invokes of_dma_find_controller() why is it broken for you if that is the > > > > case.. > > > > > > No,the calling process should be: > > > dma_request_slave_channel() > > > --->dma_request_chan()--->of_dma_request_slave_channel()---->of_dma_simple_xlate() > > > ----> dma_request_channel(). > > The thing is that this is a generic issue, so fix should be in the core > and not in the driver. Agree in you case of_dma_find_controller() is not > invoked, so we should fix that in core > > > > > You can check other drivers, they also will save the device node to > > validate in their filter function. > > For example the imx-sdma driver: > > https://elixir.bootlin.com/linux/v5.1-rc6/source/drivers/dma/imx-sdma.c#L1931 > > Exactly, more the reason this should be in core :) Sorry for late reply due to my holiday. OK, I can move the fix into the core. So I think I will drop this patch from my patchset, and I will create another patch set to fix the device node validation issue with converting other drivers which did the similar things. Thanks. -- Baolin Wang Best Regards