Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4784919pxy; Tue, 27 Apr 2021 12:33:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyha19b4v7qml62BjDqtKorvz0y4Yu4AOBzaYGP7xdYFVUL5oJJ56zGpCa9MdPa7sTJV1My X-Received: by 2002:a17:907:3e06:: with SMTP id hp6mr24771342ejc.273.1619552006819; Tue, 27 Apr 2021 12:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619552006; cv=none; d=google.com; s=arc-20160816; b=avkJjdin7f2jKRadvdpusuXTxQ26edPRDK1XaegcvH53veB4IJixX/b8yBPmKTY5n3 zHya6uSPVOcleKqzhUcxOjA/uK+XWX6yk443vIMvPmvqMkoiXOwR3NpTBLmoANsu/gnL DX8W6ribiQEyxMqnxblUn/KJ4aVLUjv2jCU8Lnaeu4UzlX7XC4WFc7sPcrlUBArMiL2I ngMS26BKw5QpSu+pTRvHZq82wfqtCuVAPYcxswXMm2CBsk+MNp34SQR9Sb0+XD6+mqZZ cgjISt2mPcdOcQ3WenCqCZ1QTIaFzuUbylF2zACGVjQHTy5U4i9f9v1irVA9UUzlTFpX dm6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Z2dfVSyAhAt8vgpBqMWbMDHuRDstq7cheYx2I0gCKqA=; b=D3qyirx+K/iht3gI4F4HkR92XKAdjUPtQKzZKqS5YFmX4f5ACJGka+OWmiaWZq2Zw2 MaBa4MovndF5kYuXD7S+0xNg1p/JcA1M9jsecZGp8mkIvXFZzPkL4qfTA44ZX1ekudB3 MtO5PfU5Qsu0rJjLEB9bNGzE/Fx0xd+8bhkQPjROTtNPqnjeMtL+Xs3LqRwe95cVaH2y yHJWPjhYXzMJL9YE6f166pUDid1jX0QF4C7AWy8UhFqZGHke/4m1Xs6XlRVSFG7DmAKi O7w6lUAtMraV0E4XRuhuFsEKR6YsmGvXahDSs4tG1/rdjQg99OJYjYP/kh59F2Jbky5F me7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=f+N9LA0t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si3374413edd.464.2021.04.27.12.33.02; Tue, 27 Apr 2021 12:33:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=f+N9LA0t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238690AbhD0Tco (ORCPT + 99 others); Tue, 27 Apr 2021 15:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238666AbhD0Tcn (ORCPT ); Tue, 27 Apr 2021 15:32:43 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89963C061574 for ; Tue, 27 Apr 2021 12:31:59 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id q25so17294338iog.5 for ; Tue, 27 Apr 2021 12:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Z2dfVSyAhAt8vgpBqMWbMDHuRDstq7cheYx2I0gCKqA=; b=f+N9LA0t4CUwDpMHIjT1MaiOY0YP0yEI1fdCq6n/9G2sApcPu0kfC7g65PrZSCas0q et2NNQvtx3ytlLSajvn/g9dwQLy9IwqF1tmAC4Z2Wbb5I+Ch5gtBC1EMrWz4jvcK7cRt BzVK1SMsB3tJk0fk7jkLyb2kxQrjE4ZWpPcEIZ7o4pMgr6mhJqYb+dQUMgERAwDuQnuT HZjT+3IRZb6PI3RPSgOlfb2kyWKwrBOn3yf7eoc9FCkyAhJ/Wgl0HqJKfJ1IUrN5ptMx F66dcUTstJRLGIfvFqeC68gHCYIb4UfUh4NvcMqsFPQso8Hhnq5J0oEUDdR/Ozo03mHZ ak0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Z2dfVSyAhAt8vgpBqMWbMDHuRDstq7cheYx2I0gCKqA=; b=Q2i8OqdWSNJ+uttVec0SFSM6jxgcMG6TN5ezV4bK4zieWVnyi/USgBcbdF+9Gaibol Dhvfl0/i4n0f5KpyVvZq3zNyMghVJsOg3KDcYYszSSpaCdNaoyMPoTk5vGRhnOwmjm00 6DQUod7GP3Gocuw6XIU6abJbKqEWJOUmAGaUBH+scEQjl/ckpQr/kPxvV+D4vWDU8nHW bTGHFQ7ZHYIAM51W/FH6+a1419zKlOeuFCKXAQ3oqhr8u90OaME4H6Zgjh30LGPlfqlD Vji6CCC4DV5bN1xBBeiryKVGR1le5eWcqHhEn+LMe0cTLYGDORDVTnxcUGVWDNHyUEbm YpWw== X-Gm-Message-State: AOAM532DFJ174u/SM5e47D1n1vMib02eqLNVeBuLxyIJVkKahNJ7OqPV c2lL9fZOEWf92Bn9yicePUv7mw== X-Received: by 2002:a5d:84c5:: with SMTP id z5mr20535269ior.33.1619551919040; Tue, 27 Apr 2021 12:31:59 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id d8sm340022iow.25.2021.04.27.12.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 12:31:58 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lbTR7-00Dgv4-Ig; Tue, 27 Apr 2021 16:31:57 -0300 Date: Tue, 27 Apr 2021 16:31:57 -0300 From: Jason Gunthorpe To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stephen Bates , Christoph Hellwig , Dan Williams , Christian =?utf-8?B?S8O2bmln?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy Subject: Re: [PATCH 05/16] dma-mapping: Introduce dma_map_sg_p2pdma() Message-ID: <20210427193157.GQ2047089@ziepe.ca> References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-6-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210408170123.8788-6-logang@deltatee.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 08, 2021 at 11:01:12AM -0600, Logan Gunthorpe wrote: > +/* > + * dma_maps_sg_attrs returns 0 on error and > 0 on success. > + * It should never return a value < 0. > + */ Also it is weird a function that can't return 0 is returning an int type > +int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, int nents, > + enum dma_data_direction dir, unsigned long attrs) > +{ > + int ents; > + > + ents = __dma_map_sg_attrs(dev, sg, nents, dir, attrs); > BUG_ON(ents < 0); if (WARN_ON(ents < 0)) return 0; instead of bug on? Also, I see only 8 users of this function. How about just fix them all to support negative returns and use this as the p2p API instead of adding new API? Add the opposite logic flag, 'DMA_ATTRS_NO_ERROR' and pass it through the other api entry callers that can't handle it? Jason