From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49041C433EF for ; Wed, 29 Sep 2021 21:16:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BFCC761504 for ; Wed, 29 Sep 2021 21:16:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BFCC761504 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=deltatee.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id F18E4940057; Wed, 29 Sep 2021 17:16:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC86694003A; Wed, 29 Sep 2021 17:16:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9061940057; Wed, 29 Sep 2021 17:16:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id CC15094003A for ; Wed, 29 Sep 2021 17:16:09 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7DBDE2DEC8 for ; Wed, 29 Sep 2021 21:16:09 +0000 (UTC) X-FDA: 78641868858.16.5891E38 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by imf13.hostedemail.com (Postfix) with ESMTP id 156381036A2F for ; Wed, 29 Sep 2021 21:16:04 +0000 (UTC) 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=RfrWfjCRN+UowtRVbNA3b2L6enFhSnjdcCuQt0d3QdI=; b=sx8iDLgZqm9oV/jPtvYl6hWxOJ izKJEIZpDyBIKLWz8FDerUW5k2MT7pPtfUTyZiEU6bE7HoV7pneW/CZR2zMIxsytGbyq8vFegsKGv 49LSCi3qE6cFcuu3ANDMzF0wHUfqas6dQodjbfxt/8zHWnBhP9N8kOEENBNUjLrsTXNl90Sahn8H0 HAUhhk1jLu1tfiA5AYOXEg4lkZh0pmHiPlunotwWT39n20HVUlZzMB6xXhNwz+2qZPfnc/8Ia0J5E FZIAlxHcWmAecE99N9j4B2rg3AG9XIO/VHcG1DdeZNocY4lVPpt+WxirDMZKAHuss1OBzFQ0yFB23 svZcaJZQ==; Received: from s0106a84e3fe8c3f3.cg.shawcable.net ([24.64.144.200] helo=[192.168.0.10]) by ale.deltatee.com with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mVgvW-0006Bq-H1; Wed, 29 Sep 2021 15:15:43 -0600 To: Jason 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 , =?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 , Martin Oliveira , Chaitanya Kulkarni References: <20210916234100.122368-1-logang@deltatee.com> <20210916234100.122368-2-logang@deltatee.com> <20210928183219.GJ3544071@ziepe.ca> From: Logan Gunthorpe Message-ID: <3f3abc6b-0a80-dbb6-f9dc-8a4cc33c975c@deltatee.com> Date: Wed, 29 Sep 2021 15:15:34 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210928183219.GJ3544071@ziepe.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA X-SA-Exim-Connect-IP: 24.64.144.200 X-SA-Exim-Rcpt-To: ckulkarnilinux@gmail.com, martin.oliveira@eideticom.com, 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, 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, jgg@ziepe.ca X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH v3 01/20] lib/scatterlist: add flag for indicating P2PDMA segments in an SGL 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) X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 156381036A2F X-Stat-Signature: cn6u853kwugng36izzo1aipb5u5ary9c Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=deltatee.com header.s=20200525 header.b=sx8iDLgZ; dmarc=pass (policy=none) header.from=deltatee.com; spf=pass (imf13.hostedemail.com: domain of logang@deltatee.com designates 204.191.154.188 as permitted sender) smtp.mailfrom=logang@deltatee.com X-HE-Tag: 1632950164-420978 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2021-09-28 12:32 p.m., Jason Gunthorpe wrote: > On Thu, Sep 16, 2021 at 05:40:41PM -0600, Logan Gunthorpe wrote: >> config PCI_P2PDMA >> bool "PCI peer-to-peer transfer support" >> - depends on ZONE_DEVICE >> + depends on ZONE_DEVICE && 64BIT >=20 > Perhaps a comment to explain what the 64bit is doing? Added. >> select GENERIC_ALLOCATOR >> help >> Enable=D1=95 drivers to do PCI peer-to-peer transactions to and fr= om >> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h >> index 266754a55327..e62b1cf6386f 100644 >> +++ b/include/linux/scatterlist.h >> @@ -64,6 +64,21 @@ struct sg_append_table { >> #define SG_CHAIN 0x01UL >> #define SG_END 0x02UL >> =20 >> +/* >> + * bit 2 is the third free bit in the page_link on 64bit systems whic= h >> + * is used by dma_unmap_sg() to determine if the dma_address is a PCI >> + * bus address when doing P2PDMA. >> + * Note: CONFIG_PCI_P2PDMA depends on CONFIG_64BIT because of this. >> + */ >> + >> +#ifdef CONFIG_PCI_P2PDMA >> +#define SG_DMA_PCI_P2PDMA 0x04UL >=20 > Add a=20 > static_assert(__alignof__(void *) =3D=3D 8); >=20 > ? Good idea. Though, I think your line isn't quite correct. I've added: static_assert(__alignof__(struct page) >=3D 8); >> +#define sg_is_dma_pci_p2pdma(sg) ((sg)->page_link & SG_DMA_PCI_P2PDMA= ) >=20 > I've been encouraging people to use static inlines more.. I also prefer static inlines, but I usually follow the style of the code I'm changing. In any case, I've changed to static inlines similar to your example. >> /** >> * sg_assign_page - Assign a given page to an SG entry >> @@ -86,13 +103,13 @@ struct sg_append_table { >> **/ >> static inline void sg_assign_page(struct scatterlist *sg, struct page= *page) >> { >> - unsigned long page_link =3D sg->page_link & (SG_CHAIN | SG_END); >> + unsigned long page_link =3D sg->page_link & SG_PAGE_LINK_MASK; >=20 > I think this should just be '& SG_END', sg_assign_page() doesn't look > like it should ever be used on a sg_chain entry, so this is just > trying to preserve the end stamp. Perhaps, but I'm not comfortable making that change in this patch or series. Though, I've reverted this specific change in my patch so sg_assign_page() will clear SG_DMA_PCI_P2PDMA. Logan