Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp672936pxj; Fri, 14 May 2021 12:44:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2dKTc6ZvGyJVAbnyH8kwWsXMCdE0P96jgagZO2Sw9+RHQEeJyTMKklkHiwd95x9OAxxCm X-Received: by 2002:a17:906:7c9:: with SMTP id m9mr1158143ejc.98.1621021452585; Fri, 14 May 2021 12:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621021452; cv=none; d=google.com; s=arc-20160816; b=FGPwYDCJKDtwbwE4fN9IhHWIVGM58Py17J1Yuk5HCOM2EIx7i21GgrwRqTbCpLwuYT TC29Ww5Ky6Un8IWDKVNyM4b2cea5WSccMqhSeaJsku4rPEmK7RN2XUyMIiV3VUASBozN H5e84FX+8SiZdFCaEZtkqv1L3pQoDffQ6JNqjCNJXhCxPRiYIFchuaRfQNC2cnPlI+Ek Ciy/X44Vef94y7yOvKRk5Bgd7vtSZG/Pnfhl6ab8qdbNOAddMo06XtI3Xauhrb1b1tkb oWg3DbNYpwsZb3r7UHVTrdiUBdEJJYsSg2Tufjd901rDzjohht9lbgv2blRDV33e/oAr 4r5A== 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=UIw7EfWmD3A5GJzYN/3QOUOCIyHuFu16FWOPf7ANc9Y=; b=E3invhY7cV0LFr3EMovuch2w/6aieS98IamIP198CG7lbgYggMLSubHNJY4pA2N4Fx 9yyjg4ecw/SKcYd3Ht9MLW9nP34dNPFwCfN4mlbMbEz2hV4372OAebbee21UCcDn/QcR bvXq1CUe/JvR3Z+zdKinM1ZEE4HrhWUzFPJc/Ja3U55HpGWQnEmwmVWCUTMoiJxuMOCk +EsKKCRklmuvloA3SVQzSxaS0yK3yeA+vlN3IQt4RtImRtmilbYxaWZvyOtG9q7HLc16 26VxsQx2CJRSnzAW9f3+hVcL+NebAdxOT9T3Uoc1Xz9H4FQBqiGC8SkNevW90G50OvL1 ckrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=ifFUHGd+; 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 z8si7111415edd.542.2021.05.14.12.43.47; Fri, 14 May 2021 12:44:12 -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=ifFUHGd+; 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 S234489AbhENQTK (ORCPT + 99 others); Fri, 14 May 2021 12:19:10 -0400 Received: from ale.deltatee.com ([204.191.154.188]:60826 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229654AbhENQTJ (ORCPT ); Fri, 14 May 2021 12:19:09 -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=UIw7EfWmD3A5GJzYN/3QOUOCIyHuFu16FWOPf7ANc9Y=; b=ifFUHGd+/63UwWC7Lc9/oor7EB 2xjO0Kj1AlFEpeDAwbOKeW8D81UORdDKkPxs7CF9lZHYha50YtQkAW8SwcBLPjO/SrcXyl30YTRho MbfBoG89yDCZm/Gp8aa++DAJcvdvSRYMC7EbFLh8FinG05Ku9EKpgWTM/v4BVl4jTXyWC3/LqjVgu bdtOV6sJX1hy0+oEpb6EvH7KJiIfkE8Gl1VaVjCNeplN1uBeqW+034RUscz+xQLCn+ISPdE0nf+rC ggxbKXYoIRATTWu1GzOpzi2ZHRBR0QVMYKgJfXEoeRUmTpW6t1lgOr2s3tTG29i7Rquf1zkW1OwXB T6ym8TIw==; Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1lhaVY-000693-Pi; Fri, 14 May 2021 10:17:49 -0600 To: Christoph Hellwig 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 , Dan Williams , Jason Gunthorpe , =?UTF-8?Q?Christian_K=c3=b6nig?= , 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 References: <20210513223203.5542-1-logang@deltatee.com> <20210513223203.5542-16-logang@deltatee.com> <20210514135712.GD4715@lst.de> From: Logan Gunthorpe Message-ID: <6615c351-9c28-3a74-8c43-4aeb7993fb98@deltatee.com> Date: Fri, 14 May 2021 10:17:48 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210514135712.GD4715@lst.de> 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, jhubbard@nvidia.com, christian.koenig@amd.com, jgg@ziepe.ca, dan.j.williams@intel.com, 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, hch@lst.de 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.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH v2 15/22] dma-direct: Support PCI P2PDMA pages in dma-direct map_sg 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-14 7:57 a.m., Christoph Hellwig wrote: >> + for_each_sg(sgl, sg, nents, i) { >> + if (sg_is_dma_pci_p2pdma(sg)) { >> + sg_dma_unmark_pci_p2pdma(sg); >> + } else { > > Double space here. We also don't really need the curly braces to start > with. > >> + struct pci_p2pdma_map_state p2pdma_state = {}; >> + enum pci_p2pdma_map_type map; >> struct scatterlist *sg; >> + int i, ret; >> >> for_each_sg(sgl, sg, nents, i) { >> + if (is_pci_p2pdma_page(sg_page(sg))) { >> + map = pci_p2pdma_map_segment(&p2pdma_state, dev, sg); >> + switch (map) { > > Why not just: > > switch (pci_p2pdma_map_segment(&p2pdma_state, dev, > sg)) { > > (even better with a shorter name for p2pdma_state so that it all fits on > a single line)? > >> + case PCI_P2PDMA_MAP_BUS_ADDR: >> + continue; >> + case PCI_P2PDMA_MAP_THRU_HOST_BRIDGE: >> + /* >> + * Mapping through host bridge should be >> + * mapped normally, thus we do nothing >> + * and continue below. >> + */ > > I have a bit of a hard time parsing this comment. > >> + if (sg->dma_address == DMA_MAPPING_ERROR) { >> + ret = -EINVAL; >> goto out_unmap; >> + } >> sg_dma_len(sg) = sg->length; >> } >> >> @@ -411,7 +443,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents, >> >> out_unmap: >> dma_direct_unmap_sg(dev, sgl, i, dir, attrs | DMA_ATTR_SKIP_CPU_SYNC); >> - return -EINVAL; >> + return ret; > > Maybe just initialize ret to -EINVAL at declaration time to simplify this > a bit? > All fair points, will fix in v3. Logan