Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6867522yba; Wed, 1 May 2019 23:04:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7KEfPb6mxS9fzKCy1dPfIP9dBEXcM+uHhU9pKlRxEmYz75MbEbvdm0QUiHBSAV+qWJNHm X-Received: by 2002:a63:4c45:: with SMTP id m5mr2144346pgl.78.1556777069520; Wed, 01 May 2019 23:04:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556777069; cv=none; d=google.com; s=arc-20160816; b=wKoo766abzcRqQggqcRKGQ9heVWQfR5hVPLAOuxYOtI4iPVIU9huKMHfR1p34f366I 5qHGtH92/sjgp/9mB+quNAFWZXaYdKLuNpjiqIYU+6fZI6ihyXW0UaHVmIgmS2iyOG4W y/h4SjNVqtthAjb7M00HVTYXy7mmqziAPzeoJUbzy4wTHXST8HzJqG81hmr/eqbrRdzT aVA28jPXlgE86k1EBOLVi5IEW4ZXQoBuIraMVbd/sXH3X6bAV8YpxsgzIBxKZYqVK8qR x/uN9AkKBoCyu+24yhL3m1LrfCtaeaswui9LX6t6HPUjiqirVoN8SRuEcT8SXqhR+aYH ppjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=y5F6pWpTnloXRgfOzDUWQh205LEr6RoMaZfy5CJoBHQ=; b=z0lfV4yylYw1yjXKKtxsfNW6htVY+46bK9ZE9AqWSsb6i6eypCI62p4Z2DmaHTXUZJ zKZ7AKmadaAMNFninJ5017z/qEATpGcnyklfs3kuKf2HxZtoSmGKP0d7O8qhv6UfIICi aKFJw1kLky4zSmvAHLxEOn+pHNnR3Yc3jl1TzZNt2vTq7hNyNmDfkwvNuTRAewp6i5Wg WhqELtB9Tw5DtgrPOgarw7wk8Lv9cCqK2YGgLpKdvvRO0o8F/E/8hHD9yKazB/yfHI5v cTEogbmR2bcqGejiIU+5qzV/jwbr8a7pibvmNKB8sB4Np4KVTqkyCbmQ6WyTHYF21ltR ZDUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=boIvWZkb; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4si40675682pga.366.2019.05.01.23.04.14; Wed, 01 May 2019 23:04:29 -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=@kernel.org header.s=default header.b=boIvWZkb; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725764AbfEBGCB (ORCPT + 99 others); Thu, 2 May 2019 02:02:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:45552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726350AbfEBGB6 (ORCPT ); Thu, 2 May 2019 02:01:58 -0400 Received: from localhost (unknown [171.76.113.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D73D92081C; Thu, 2 May 2019 06:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556776917; bh=xmjxao6gRvI0En8WAcAajp9T9eQuqoeRuLndvm8vViw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=boIvWZkbucoiyvNMWxqclmo/Fs0qts4OTUKYY+8APJoiVzsa5XrYJhW7hfk4oebkF CdHHpvwXRn3s1XDD/aq29tRuySJU1R8oxQf0SpdnehnAyYdjEtg1UwEg1UlXHf1Shv x1KZseE93lglj3m7oCALHkd1hlsTskBQE91BZRiI= Date: Thu, 2 May 2019 11:31:48 +0530 From: Vinod Koul To: Baolin Wang Cc: Dan Williams , eric.long@unisoc.com, Orson Zhai , Chunyan Zhang , Mark Brown , dmaengine@vger.kernel.org, LKML Subject: Re: [PATCH 4/7] dmaengine: sprd: Add device validation to support multiple controllers Message-ID: <20190502060148.GH3845@vkoul-mobl.Dlink> References: <20190429115723.GK3845@vkoul-mobl.Dlink> <20190429140537.GN3845@vkoul-mobl.Dlink> <20190430082954.GQ3845@vkoul-mobl.Dlink> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 :) -- ~Vinod