Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1253960pxv; Fri, 16 Jul 2021 05:23:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRbgk0VdKZ83rE6i3LPoXgea7Au9dUNJkivliphLhyevy2Owl69H3rzhdsMPdSQ5BxYOiS X-Received: by 2002:aa7:db54:: with SMTP id n20mr14301429edt.21.1626438185043; Fri, 16 Jul 2021 05:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626438185; cv=none; d=google.com; s=arc-20160816; b=BWyPcEu8voDUMuvbhNw4qp49FlQ8W1vhUSvA4o4uJEOqHqURD+UpZM5BZfyJdJHRMT hKf0II30+SbHt2ECziMmwKJ//PqE4U1myXbwa3awZnb5YxRb3Rr2gqnBvlkuue5k1ZfZ RiND7p31rhTKzP8A4wyrOmK6IrZD2HzFYMqE2OJiMb2PDMerjAv2Md/tYIl3iwsA5IgG bqC7a7sNR2P/KD54KEyoSoxGxBQxYzLZlT5dX/nDfCJ0O3Fcid5lXcdpzLdF8W5Af0DF VQilJ6yHRxIuqvyv3MRTBAkIYdXdYwkdfFwof6pfYbs0ZIPpCE9e+hFP9NPlGaqML5oN hkjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=wYwgn6rKYyqKws/j5Saqbk6P4ZStLSPHQrxtz7mEcOc=; b=oUaz0TDKd8Zb9W5ESbAcmCN+9efC5yOf81xRtyy+LhehKf9MHIgN2+IdXhzctrQwc8 XbiTntfaHzNYRNISqgtM+QWVgCouZxFskMTSsKoeNq+qylC40JXTtTkaXKoxImJfymA3 OZC9M04yVNY2lX89s8pVpfI3jJi8OlrwJodIzGnCLUgZYbsz90Onvcqln9Q+CXo37mmD Tmmge7dkU3Hgd+83kda9UbWQH/ktIgiqX5y43OsTxDDItSYgrDxXisMGQGMEy0WVJHw4 NAKcDhmddyy+wmT3SxwWrRr9OSzRDR7ug9jZ/CVKtTOBz/0luyE26XfA5dTpd4GZCvk0 Wm6A== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id md11si11283324ejb.466.2021.07.16.05.22.40; Fri, 16 Jul 2021 05:23:05 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237493AbhGPMW1 (ORCPT + 99 others); Fri, 16 Jul 2021 08:22:27 -0400 Received: from foss.arm.com ([217.140.110.172]:38338 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232024AbhGPMW0 (ORCPT ); Fri, 16 Jul 2021 08:22:26 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 08358D6E; Fri, 16 Jul 2021 05:19:31 -0700 (PDT) Received: from [10.57.36.240] (unknown [10.57.36.240]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BF0533F774; Fri, 16 Jul 2021 05:19:28 -0700 (PDT) Subject: Re: [PATCH v1 16/16] dma-mapping: Disallow .map_sg operations from returning zero on error To: Christoph Hellwig , Logan Gunthorpe Cc: linux-s390@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, Martin Oliveira , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-alpha@vger.kernel.org, sparclinux@vger.kernel.org, xen-devel@lists.xenproject.org, Stephen Bates , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org References: <20210715164544.6827-1-logang@deltatee.com> <20210715164544.6827-17-logang@deltatee.com> <20210716063332.GD13345@lst.de> From: Robin Murphy Message-ID: <21b7f2f1-ccac-4567-6933-a258dcad7099@arm.com> Date: Fri, 16 Jul 2021 13:19:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210716063332.GD13345@lst.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-07-16 07:33, Christoph Hellwig wrote: > On Thu, Jul 15, 2021 at 10:45:44AM -0600, Logan Gunthorpe wrote: >> @@ -194,6 +194,8 @@ static int __dma_map_sg_attrs(struct device *dev, struct scatterlist *sg, >> else >> ents = ops->map_sg(dev, sg, nents, dir, attrs); >> >> + WARN_ON_ONCE(ents == 0); > > Turns this into a negative error code while we're at it, just to keep > the callers sane? Right, by this point returning the 0 would pass through dma_map_sg_attrs() OK, but AFAICS dma_map_sgtable() would now get confused and return success but with sgt->nents = 0. Coercing it to an error code (which dma_map_sg_attrs() would then just change right back) seems sensible for the sake of easy robustness. Robin.