Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4648767yba; Tue, 30 Apr 2019 01:55:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqy67hGYpYb0SvSx5XDLd8wVUe2pxVQQIG9WpYNjtJ+c2vYcONKzXfkifvUxOWQxFc3UsJS5 X-Received: by 2002:a17:902:a01:: with SMTP id 1mr67289915plo.36.1556614550178; Tue, 30 Apr 2019 01:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556614550; cv=none; d=google.com; s=arc-20160816; b=CK75D5mIxLfxEVnq/v6jdOuX+XXz/4Aj0K120Q81q/Km3a8AZxo4n9iuLBMbwGSShJ y1zkyJfb518JdLAT0ldOzWPDqOce09jUjwjV50po8+mblqpVecqN+WAJB8h/qDitrzLt pLZafVXBN6YKKIwBfRsnNds6xWsfnVlTCyjEwwv89tOGxmH8ayXZKWSjWavIOC5XaEEJ JxNKIwKd7FzKs6lCa86rTAwOP6aAyhrY0kg2gHu14irWyqUgBm1qYVMbj+IZAZpCrX88 vbNRX9cPdX0RUStuG054p3KH1kZ1cHPWMyAF6aQkj9I07V03DzMJ8kt0ijtqhBPzCzz4 M3gA== 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=A8/NEuA9marorl0ixlh/3shrh19pr40I3KqHuo9ZWlE=; b=NY4w0DzapToGZYo0BFVGFZeiEBZOYUI6QO9ek41R2fZdU4bYAW1iOj+6MrisKMMEB2 ecctT9PckrlxxKXoxigd4JzM6H/CFhyV0YK80tPM7xyR0yYzCF9Uju1LXwu0YzfLIlkS 1+Q70rKLXhEEa+IdRVmclDmBIQblyekSamDapLYJfz3WCY7ZCHSj0dHR8uZ0jtWuwLm3 fCRK5wadg41uGA9RYRQTjvd+ZA8LP/UKyz1lt30cTQSOIhccT+y/Xp+PZz+tQI3qdy10 FSnehVQ7xM6Lm+8jAszr8yaba0wijoSuvzlzRpMqatfIdbhR6x1Dd657F6QYJ3NJw/d8 p9jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OAe1zycT; 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 w3si37221992plp.260.2019.04.30.01.55.34; Tue, 30 Apr 2019 01:55:50 -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=OAe1zycT; 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 S1726646AbfD3Ixp (ORCPT + 99 others); Tue, 30 Apr 2019 04:53:45 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:45708 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbfD3Ixp (ORCPT ); Tue, 30 Apr 2019 04:53:45 -0400 Received: by mail-oi1-f195.google.com with SMTP id t189so7589245oih.12 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=RdGHKvkiONnjNb7jG5waiG0F0kU+1SLaTFYVLpZqgqahS1bdc5gxOJMqHBSjuQgxRw uxAV/AR11Z5Ew/wFbtfzFMu5s8cvPrsveeC+wBt0WijRoLA05wv+LDPNQWFAyV9kR9xr +KKYbLdPslS54HHxX7B3pSe1X2UpiJS+4GTkhBZOLhBfB0tOMGEwZ02xR3x54Vz++ZLK cGr+vkCYCecUW05F+wRKJslQQLRO0taV1h7RTyyvP3LQGX+h5MnRcp2b8zmlkzS9zWKE jPQnUbX82vIRGFXB8nrKfu80v72I92KdAu/9OvHRCt8h1ZZE3L3l3dVDMmeB2IMlxBm1 EAfg== X-Gm-Message-State: APjAAAXyF/1Aseu92CgC+ZXmnIwmCxagfd5Ci4ORVnmrwOt6Re2M+xX5 OS9gGrpz3rlkdxvxxQ9vJz4KqAwoxC5hJ5uqv3h99Q== 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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