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 X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A93F1C43219 for ; Tue, 30 Apr 2019 08:53:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A4F421670 for ; Tue, 30 Apr 2019 08:53:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OAe1zycT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726668AbfD3Ixp (ORCPT ); Tue, 30 Apr 2019 04:53:45 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:42614 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725938AbfD3Ixp (ORCPT ); Tue, 30 Apr 2019 04:53:45 -0400 Received: by mail-oi1-f195.google.com with SMTP id k9so7593986oig.9 for ; Tue, 30 Apr 2019 01:53:44 -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=A8/NEuA9marorl0ixlh/3shrh19pr40I3KqHuo9ZWlE=; b=OAe1zycT9lDlKZVighchQ6eYIy0XmGyjFcKMqUYoeryriWN1KoF3rGGIXMpOm1MOSW wgUx0cDHR3zb0tvqC9URlP1WM45RF6izTv/+uwYLDj99eI5wPP8y+aaAyVKzmFAjqAlC feJmhPrZF31W8VYorttnQ6+BZVtwXGTJempUyobcpGMhYT7H22ZWlravqZqnJYUbV5zc ktSOYP9QtbDUpUQn5egp/kHSOzXG5SISQnQgsDJ8VlWbvz3pltax2xuK7zNlJFAiI1NR SVJrMACuAzxXNHg+e6TGZ7trsDl8ZQ+C7oJzDbnHWL+BKCgvV+oYmcq8ZJEaqWV8fZ27 IcdQ== 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=A8/NEuA9marorl0ixlh/3shrh19pr40I3KqHuo9ZWlE=; b=WOaUaEEQpe/5u4YH2udR2bbaOp8X6pkNmUEd8Wd/YIyuwaX9oSgxr0GnpiUufgw0tL +1akBHfExYviSsQ3fdkvsVaBcLrUyv0PcSZBg5o7Jr2tJu9NgIJ+MVDTp5TejOYTiG1n R3YjkVqOOnq/R+6DCUd82StquvcpzuHafX8ae6alWEz8ATBouUWtykY4dCSZkWeUh/UM 8+iX0sc300KRebL9hx9LnYg2Dc/lffFEuNFgywo/22z/CPsOtASIwwNJN0UDAeayhAyi 3yer1lBBtZBbKCbo+52acBAgzXUpSfuSXQDaGfKX7Tj7sIfXT0wNaPuEG/gfDFrvdnyU s9/w== X-Gm-Message-State: APjAAAVVRypkxZXRVoWSE7iyg0yX+fmMLfI6mnnNDb79b76C7bJ54ZpZ RL5vfPx5I+FWBpwLaO8StQxytejn7sxnSgi9+OpyYg== X-Google-Smtp-Source: APXvYqwtAPgDAo5ewm/8SWWaA1+o4UOZZmMGy268pyU4RTnAt8OUNfnqJVpWboYxwh48ndcMExsT4WmicraSu+Dg5hg= X-Received: by 2002:aca:ba0b:: with SMTP id k11mr2230922oif.57.1556614424087; Tue, 30 Apr 2019 01:53:44 -0700 (PDT) MIME-Version: 1.0 References: <20190429115723.GK3845@vkoul-mobl.Dlink> <20190429140537.GN3845@vkoul-mobl.Dlink> <20190430082954.GQ3845@vkoul-mobl.Dlink> In-Reply-To: From: Baolin Wang Date: Tue, 30 Apr 2019 16:53:32 +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: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Message-ID: <20190430085332.d9yd_jYT9XLQ4_8zj8omYR4z6LYP1n_J9V3nUuNVFfM@z> 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(). > 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 -- Baolin Wang Best Regards