Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2895367pxy; Mon, 3 May 2021 10:21:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeag35FNrNoiYc1sZRoaVJrHHQCLfuSDAU+9GICl/Mlz92NrajbTAVD/QnVBiTfULk94Pz X-Received: by 2002:a17:906:4d50:: with SMTP id b16mr17803944ejv.53.1620062508265; Mon, 03 May 2021 10:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620062508; cv=none; d=google.com; s=arc-20160816; b=NNILf6nNQ2EeZJJEC8isCSg4dxYWrQdmeEbCQm0FHiWIz92QRyelp4qvdiZfQACdxQ 9Ipnn6BqcdiVSFezXfSsTmPtSa3Ah9z531LE09o0+ckz1PNB1qESLp578gT13VlzTZ42 CMNJih2tMdgAd2cuYNfPUOVM1KOvIKPGEMwchNsr02J1CMHAZVhyAiuu6GVl1LGAuqIS FQlHHmN0xW0ksyjbyvoa6lmSL5d3dJWDdvy4Uq4bLzD1zrqXzEzWV8duiBSGn54r9oL0 XX5ozp3MEONUuQKQQzizRli8c4St8qkPJcOBooW8bJIOBD4jLEkM0WQk8tDGBsPMuyHS j0Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:dkim-signature; bh=Xgskyepw/lHRcKmwXdhV8lu3qVd1TfZZh6M74Jlngas=; b=ZA2asSL44y3slETerJ/s5yV++lJT8jVaCWb3vEpgzzrLShnHjKWHrZjc1XxKqLBP9q 0HYrit8rAt2wlL/kuHG+dFZwCIVetMgVpJESN/YiG7eR9dG/UCZik+HP8cBYotbVmiXP dUHg8kJLtpR1SwUlvsipqOMNCHhXsmlqbHMO9cqhzWTRORdv0jPNONfb0ghSvFyXkcfF nqvIDO8cXMx1Wbr7Z0P+/6xvDjfAdA427+Z0LNmHguDO77QUxImFPG4oe3fnzMQ+OtmV 6GMlZOZ2nu+q3UvGyX/FFrpb9kcbHlmzJMSQlXwXeGK9x1X1NQEhbRf2+wVU6OZwl4+I sSPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=QqAwmeJn; 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 d13si10273785ede.118.2021.05.03.10.21.21; Mon, 03 May 2021 10:21:48 -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=@deltatee.com header.s=20200525 header.b=QqAwmeJn; 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 S232010AbhECRUi (ORCPT + 99 others); Mon, 3 May 2021 13:20:38 -0400 Received: from ale.deltatee.com ([204.191.154.188]:58958 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbhECRUg (ORCPT ); Mon, 3 May 2021 13:20:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:content-disposition; bh=Xgskyepw/lHRcKmwXdhV8lu3qVd1TfZZh6M74Jlngas=; b=QqAwmeJngpzHhZ/sdMQj3UlLTL rC/1Y3ph6DV1kkJjARvToJ6QRKEfJDGAt2iQpPoawvtTM+fMCs6n5bVz+292DJzzv2C+T87D91M2V 4wQ42/crm5YKsUUkp1hzvaTN17qEVQ+9oQ5Geo3ecq6vpk8odJrImqmZK5cpK3vHJJj9E+WmPg9Vq PNjtWNXdgJrO7pQU42Bzcn/2z9aPF7saV5+TkwUTbLKY2ssS41V1zdma+gltt/IQ92sPJS4wSu9fA qs7uDvdjdZjyuEC+dg4iSsxKIllszekl4Ujify/+NQ8fbP/N5UrU3OAn3vie0yC4GaRvbbT11kmeF NOTlVoCw==; Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1ldcEG-0005Bx-Lz; Mon, 03 May 2021 11:19:33 -0600 To: John Hubbard , 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 Cc: Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , =?UTF-8?Q?Christian_K=c3=b6nig?= , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-14-logang@deltatee.com> <78a165e1-657b-c284-d31a-adc8c9ded55d@nvidia.com> From: Logan Gunthorpe Message-ID: <4ad9c1d9-ec2a-1fe1-c5d9-19d2053da912@deltatee.com> Date: Mon, 3 May 2021 11:19:32 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <78a165e1-657b-c284-d31a-adc8c9ded55d@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: robin.murphy@arm.com, ira.weiny@intel.com, helgaas@kernel.org, jianxin.xiong@intel.com, dave.hansen@linux.intel.com, jason@jlekstrand.net, dave.b.minturn@intel.com, andrzej.jakowski@intel.com, daniel.vetter@ffwll.ch, willy@infradead.org, ddutile@redhat.com, christian.koenig@amd.com, jgg@ziepe.ca, dan.j.williams@intel.com, hch@lst.de, sbates@raithlin.com, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, jhubbard@nvidia.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_FREE,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH 13/16] nvme-pci: Convert to using dma_map_sg_p2pdma for p2pdma pages X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-05-02 7:34 p.m., John Hubbard wrote: >> if (iod->npages == 0) >> dma_pool_free(dev->prp_small_pool, nvme_pci_iod_list(req)[0], >> iod->first_dma); >> @@ -868,14 +857,13 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req, >> if (!iod->nents) >> goto out_free_sg; >> >> - if (is_pci_p2pdma_page(sg_page(iod->sg))) >> - nr_mapped = pci_p2pdma_map_sg_attrs(dev->dev, iod->sg, >> - iod->nents, rq_dma_dir(req), DMA_ATTR_NO_WARN); >> - else >> - nr_mapped = dma_map_sg_attrs(dev->dev, iod->sg, iod->nents, >> - rq_dma_dir(req), DMA_ATTR_NO_WARN); >> - if (!nr_mapped) >> + nr_mapped = dma_map_sg_p2pdma_attrs(dev->dev, iod->sg, iod->nents, >> + rq_dma_dir(req), DMA_ATTR_NO_WARN); >> + if (nr_mapped < 0) { >> + if (nr_mapped != -ENOMEM) >> + ret = BLK_STS_TARGET; >> goto out_free_sg; >> + } > > But now the "nr_mapped == 0" case is no longer doing an early out_free_sg. > Is that OK? dma_map_sg_p2pdma_attrs() never returns zero. It will return -ENOMEM in the same situation and results in the same goto out_free_sg. Logan