Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1002031pxb; Wed, 29 Sep 2021 14:36:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKB3RmO9YAzbA3yHk8yDUYf0jZ84Qtqm5iIIwrMafmyYPXR/K/yJWndpfJZ8Q/y9ATa58s X-Received: by 2002:a17:906:4482:: with SMTP id y2mr2449754ejo.484.1632951389013; Wed, 29 Sep 2021 14:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632951389; cv=none; d=google.com; s=arc-20160816; b=n8Me1vrBjwIOutPlMblhRveLNFD1ugCLaO+bY6byi/GBECrpEnbW8WqH/Mmlj9Q3g1 gxxxRExr9s4IyY3ZYBMQJfWA+AYP3YVcgGMaonFhCUeW2lrKGUyfqk1npra8A0TGXxKV crLS4LKUYgM27RP8NevnuY7fMFH/RupMyasM31qmnw2Jv4OYak1yBmdU5eCJW2crNy/U 0iC7IFRSrlhrKrsKzjjaTx60yQBx4S6VTTsc2DEIAE+HJ1zYjrlx09wz3hCwQtUlLFx/ fwoZsEru8BwlKh3I6A/ho/4tDSjinWgEE3tMi+Ccw6S6vJYNcdHnSx2U9B8XKFfxITtK PwMw== 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=RfrWfjCRN+UowtRVbNA3b2L6enFhSnjdcCuQt0d3QdI=; b=LGB/z89/DknBw7NB/ZpjvkJk4sMJM2Te0UE45crVh44XaAeccwoS4rgFYs8NuJNx2z xtvE1tZr2ynUZ4ZCbD2jhS6YNXUqqlrMq4yPFD9yg7tXPSS1mZsre1W+CCMuJjdHeeL3 YC1hBH06Pmp9aViVYmx+9cYByLVlnVwVQ4gpFyUc5yTFY1/UNNaDz94uoaAOdkMm2gOo pL/qoeqlqxwRQdwyJpMfyEu1hAoM8TklgacAWAWp0rL076QRy2FMO7csanV0QYjPWNw6 /GoEuGfA4WRz2HsM274/trpNECAkA1etqhm72fcyzoeK6YOTmaH/EBROeBe0AZ8zN5ig TnJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=sx8iDLgZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si1276850edi.151.2021.09.29.14.36.00; Wed, 29 Sep 2021 14:36:28 -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=sx8iDLgZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346876AbhI2VR5 (ORCPT + 99 others); Wed, 29 Sep 2021 17:17:57 -0400 Received: from ale.deltatee.com ([204.191.154.188]:58738 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232258AbhI2VR4 (ORCPT ); Wed, 29 Sep 2021 17:17:56 -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=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 Content-Transfer-Encoding: 8bit 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 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-11.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 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > Perhaps a comment to explain what the 64bit is doing? Added. >> select GENERIC_ALLOCATOR >> help >> Enableѕ drivers to do PCI peer-to-peer transactions to and from >> 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 >> >> +/* >> + * bit 2 is the third free bit in the page_link on 64bit systems which >> + * 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 > > Add a > static_assert(__alignof__(void *) == 8); > > ? Good idea. Though, I think your line isn't quite correct. I've added: static_assert(__alignof__(struct page) >= 8); >> +#define sg_is_dma_pci_p2pdma(sg) ((sg)->page_link & SG_DMA_PCI_P2PDMA) > > 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 = sg->page_link & (SG_CHAIN | SG_END); >> + unsigned long page_link = sg->page_link & SG_PAGE_LINK_MASK; > > 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