Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp915883imu; Fri, 4 Jan 2019 09:25:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/WJt0azABI/7qP6xIH8NPhdM9uzuW6jAE2ZbRrdaocupnGgeEBapZHghJTh2k12rapO9doJ X-Received: by 2002:a62:e30d:: with SMTP id g13mr52739241pfh.151.1546622731203; Fri, 04 Jan 2019 09:25:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546622731; cv=none; d=google.com; s=arc-20160816; b=LwTQrpF1VTFg+p/oHgzz56tEddZ+PMbbskXLR75aS7ZvY0GcawSDo8HsdS2Ug7ELKo 13h+pt2rl3fTSv76DqnnfGbQuzUN1pyp3Q0q9kh6kA4/JxK7CbyGIVyVGbptC5/XM9Mb CPpFyfq6s5MompuaFstvCdjW4r0oDqolhfyEB5pQvaVyTQSdpzeg/Dsp/YRKZzQo8I3E qYlxGu5HI6CX6RATEmZv9XCUtYc0TfkCc5gvXyGbHdFcHSdhWiQH1s7DoigNrVbnXLDe tu9jpgxTW2+/I7qocl1QT54HhBqO+NIAXqR+BjnIAOpt/6AT1y2jGyM31MuOe0Z4FzYU lVXw== 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=wqLDihXsTvoWObfUgr8x6iUM6s1utriUIFErVFtBWY0=; b=bta6tjiB3H2M3jAEHC/8rSAl04fIR0GhmfjqalLUVQK21v0EZsUvqAkK6IjtdJOh2F eqEXp8e9x9sPhH+O8+M6IkLWr/ZlAmvfAJwwOc4tenr3B+S/KrIoeKu6mbthwCumdL0G Iqng0HjfFo8p5ZCMrF22ipda9dMM5NXva60jyXm3Goxf0mPVvMYAPv1pjTi0iTflKWz4 Qg0jYxJ1V/NBbrwvEALNDnVNuE1ZZCxbUV9ohr7/jc4NeDt+2ihalvWdPiQNUbmpzfht Ta2j/wcjRo826vonn3vqDpDkO3yqIFcuwwetnQKkyfjwODZAkLBbtUqHofccjEXQfHh9 Uy+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2VCzf+6I; 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 b186si15115015pfb.24.2019.01.04.09.25.16; Fri, 04 Jan 2019 09:25:31 -0800 (PST) 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=2VCzf+6I; 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 S1726620AbfADOwt (ORCPT + 99 others); Fri, 4 Jan 2019 09:52:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:57918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726296AbfADOwt (ORCPT ); Fri, 4 Jan 2019 09:52:49 -0500 Received: from localhost (unknown [171.76.109.220]) (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 CDCA120874; Fri, 4 Jan 2019 14:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546613568; bh=oxnPiKqNrGpgXVuQ/xVm7GV2F9pdvUbv6H5DBd+XypA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2VCzf+6Igjar4jGUuYHm515CUEqQSszV7ZtPXHAuAFIvvPOkfIrTLmwb31ltGPdbz FkalKEIGtSPQ1qMoSpT3mKM0EPL/QBRfkU6BQ0ybRQ7cLDVVNqKZ/OvKPiLtz2tl2Y lT3ZxGYTSV7kvWWEbmXfDalnYhkU2p/phYXoatXE= Date: Fri, 4 Jan 2019 20:21:10 +0530 From: Vinod Koul To: Andrea Merello Cc: dan.j.williams@intel.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, radhey.shyam.pandey@xilinx.com Subject: Re: [PATCH] dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result Message-ID: <20190104145110.GF13372@vkoul-mobl.Dlink> References: <20181116135628.19388-1-andrea.merello@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181116135628.19388-1-andrea.merello@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16-11-18, 14:56, Andrea Merello wrote: > There are two flavors of DMA completion callbacks: callback() and > callback_result(); the latter takes an additional parameter that carries > result information. > > Most dmaengine helper functions that work with callbacks take care of both > flavors i.e. dmaengine_desc_get_callback_invoke() first checks for > callback_result() to be not NULL, and eventually it calls this one; > otherwise it goes on checking for callback(). > > It seems however that dmaengine_desc_callback_valid() does not care about > callback_result(), and it returns false in case callback() is NULL but > callback_result() is not; unless there is a (hidden to me) reason for doing > so then I'd say this is wrong. > > I've hit this by using a DMA controller driver (xilinx_dma) that doesn't > trigger any callback invocation unless dmaengine_desc_callback_valid() > returns true, while I had only callback_result() implemented in my client > driver (which AFAICT is always fine since dmaengine documentation says that > callback() will be deprecated). > > This patch fixes this by making dmaengine_desc_callback_valid() to return > true in the said scenario. > > Signed-off-by: Andrea Merello > --- > drivers/dma/dmaengine.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h > index 501c0b063f85..0ba2c1f3c55d 100644 > --- a/drivers/dma/dmaengine.h > +++ b/drivers/dma/dmaengine.h > @@ -168,7 +168,7 @@ dmaengine_desc_get_callback_invoke(struct dma_async_tx_descriptor *tx, > static inline bool > dmaengine_desc_callback_valid(struct dmaengine_desc_callback *cb) > { > - return (cb->callback) ? true : false; > + return (cb->callback || cb->callback_result); So I do not think this one should take care of callback_result, it is supposed to check if the callback is valid or not.. Nothing more. Ofcourse usage of this maybe incorrect which should be fixed. We do have dmaengine_desc_callback_invoke() which propagates the callback_result to user -- ~Vinod