From: Logan Gunthorpe <logang@deltatee.com> To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org Cc: Bjorn Helgaas <bhelgaas@google.com>, Christoph Hellwig <hch@lst.de>, Christian Koenig <Christian.Koenig@amd.com>, Jason Gunthorpe <jgg@mellanox.com>, Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@fb.com>, Dan Williams <dan.j.williams@intel.com>, Eric Pilmore <epilmore@gigaio.com>, Stephen Bates <sbates@raithlin.com>, Logan Gunthorpe <logang@deltatee.com> Subject: [PATCH v2 01/14] PCI/P2PDMA: Introduce private pagemap structure Date: Tue, 30 Jul 2019 10:35:32 -0600 [thread overview] Message-ID: <20190730163545.4915-2-logang@deltatee.com> (raw) In-Reply-To: <20190730163545.4915-1-logang@deltatee.com> Move the PCI bus offset from the generic dev_pagemap structure to a specific pci_p2pdma_pagemap structure. This structure will grow in subsequent patches. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> --- drivers/pci/p2pdma.c | 26 ++++++++++++++++++++------ include/linux/memremap.h | 1 - 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 234476226529..03e9c887bdfb 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -25,6 +25,16 @@ struct pci_p2pdma { bool p2pmem_published; }; +struct pci_p2pdma_pagemap { + struct dev_pagemap pgmap; + u64 bus_offset; +}; + +static struct pci_p2pdma_pagemap *to_p2p_pgmap(struct dev_pagemap *pgmap) +{ + return container_of(pgmap, struct pci_p2pdma_pagemap, pgmap); +} + static ssize_t size_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -135,6 +145,7 @@ static int pci_p2pdma_setup(struct pci_dev *pdev) int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, u64 offset) { + struct pci_p2pdma_pagemap *p2p_pgmap; struct dev_pagemap *pgmap; void *addr; int error; @@ -157,14 +168,17 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, return error; } - pgmap = devm_kzalloc(&pdev->dev, sizeof(*pgmap), GFP_KERNEL); - if (!pgmap) + p2p_pgmap = devm_kzalloc(&pdev->dev, sizeof(*p2p_pgmap), GFP_KERNEL); + if (!p2p_pgmap) return -ENOMEM; + + pgmap = &p2p_pgmap->pgmap; pgmap->res.start = pci_resource_start(pdev, bar) + offset; pgmap->res.end = pgmap->res.start + size - 1; pgmap->res.flags = pci_resource_flags(pdev, bar); pgmap->type = MEMORY_DEVICE_PCI_P2PDMA; - pgmap->pci_p2pdma_bus_offset = pci_bus_address(pdev, bar) - + + p2p_pgmap->bus_offset = pci_bus_address(pdev, bar) - pci_resource_start(pdev, bar); addr = devm_memremap_pages(&pdev->dev, pgmap); @@ -720,7 +734,7 @@ EXPORT_SYMBOL_GPL(pci_p2pmem_publish); int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { - struct dev_pagemap *pgmap; + struct pci_p2pdma_pagemap *p2p_pgmap; struct scatterlist *s; phys_addr_t paddr; int i; @@ -736,10 +750,10 @@ int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents, return 0; for_each_sg(sg, s, nents, i) { - pgmap = sg_page(s)->pgmap; + p2p_pgmap = to_p2p_pgmap(sg_page(s)->pgmap); paddr = sg_phys(s); - s->dma_address = paddr - pgmap->pci_p2pdma_bus_offset; + s->dma_address = paddr - p2p_pgmap->bus_offset; sg_dma_len(s) = s->length; } diff --git a/include/linux/memremap.h b/include/linux/memremap.h index f8a5b2a19945..b459518ce475 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -112,7 +112,6 @@ struct dev_pagemap { struct device *dev; enum memory_type type; unsigned int flags; - u64 pci_p2pdma_bus_offset; const struct dev_pagemap_ops *ops; }; -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: logang@deltatee.com (Logan Gunthorpe) Subject: [PATCH v2 01/14] PCI/P2PDMA: Introduce private pagemap structure Date: Tue, 30 Jul 2019 10:35:32 -0600 [thread overview] Message-ID: <20190730163545.4915-2-logang@deltatee.com> (raw) In-Reply-To: <20190730163545.4915-1-logang@deltatee.com> Move the PCI bus offset from the generic dev_pagemap structure to a specific pci_p2pdma_pagemap structure. This structure will grow in subsequent patches. Signed-off-by: Logan Gunthorpe <logang at deltatee.com> --- drivers/pci/p2pdma.c | 26 ++++++++++++++++++++------ include/linux/memremap.h | 1 - 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 234476226529..03e9c887bdfb 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -25,6 +25,16 @@ struct pci_p2pdma { bool p2pmem_published; }; +struct pci_p2pdma_pagemap { + struct dev_pagemap pgmap; + u64 bus_offset; +}; + +static struct pci_p2pdma_pagemap *to_p2p_pgmap(struct dev_pagemap *pgmap) +{ + return container_of(pgmap, struct pci_p2pdma_pagemap, pgmap); +} + static ssize_t size_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -135,6 +145,7 @@ static int pci_p2pdma_setup(struct pci_dev *pdev) int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, u64 offset) { + struct pci_p2pdma_pagemap *p2p_pgmap; struct dev_pagemap *pgmap; void *addr; int error; @@ -157,14 +168,17 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, return error; } - pgmap = devm_kzalloc(&pdev->dev, sizeof(*pgmap), GFP_KERNEL); - if (!pgmap) + p2p_pgmap = devm_kzalloc(&pdev->dev, sizeof(*p2p_pgmap), GFP_KERNEL); + if (!p2p_pgmap) return -ENOMEM; + + pgmap = &p2p_pgmap->pgmap; pgmap->res.start = pci_resource_start(pdev, bar) + offset; pgmap->res.end = pgmap->res.start + size - 1; pgmap->res.flags = pci_resource_flags(pdev, bar); pgmap->type = MEMORY_DEVICE_PCI_P2PDMA; - pgmap->pci_p2pdma_bus_offset = pci_bus_address(pdev, bar) - + + p2p_pgmap->bus_offset = pci_bus_address(pdev, bar) - pci_resource_start(pdev, bar); addr = devm_memremap_pages(&pdev->dev, pgmap); @@ -720,7 +734,7 @@ EXPORT_SYMBOL_GPL(pci_p2pmem_publish); int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction dir) { - struct dev_pagemap *pgmap; + struct pci_p2pdma_pagemap *p2p_pgmap; struct scatterlist *s; phys_addr_t paddr; int i; @@ -736,10 +750,10 @@ int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents, return 0; for_each_sg(sg, s, nents, i) { - pgmap = sg_page(s)->pgmap; + p2p_pgmap = to_p2p_pgmap(sg_page(s)->pgmap); paddr = sg_phys(s); - s->dma_address = paddr - pgmap->pci_p2pdma_bus_offset; + s->dma_address = paddr - p2p_pgmap->bus_offset; sg_dma_len(s) = s->length; } diff --git a/include/linux/memremap.h b/include/linux/memremap.h index f8a5b2a19945..b459518ce475 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -112,7 +112,6 @@ struct dev_pagemap { struct device *dev; enum memory_type type; unsigned int flags; - u64 pci_p2pdma_bus_offset; const struct dev_pagemap_ops *ops; }; -- 2.20.1
next prev parent reply other threads:[~2019-07-30 16:37 UTC|newest] Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-30 16:35 [PATCH v2 00/14] PCI/P2PDMA: Support transactions that hit the host bridge Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe [this message] 2019-07-30 16:35 ` [PATCH v2 01/14] PCI/P2PDMA: Introduce private pagemap structure Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 02/14] PCI/P2PDMA: Add the provider's pci_dev to the pci_p2pdma_pagemap struct Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 03/14] PCI/P2PDMA: Add constants for not-supported result upstream_bridge_distance() Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-08-07 5:54 ` Christoph Hellwig 2019-08-07 5:54 ` Christoph Hellwig 2019-08-07 15:58 ` Logan Gunthorpe 2019-08-07 15:58 ` Logan Gunthorpe 2019-08-08 7:31 ` Christoph Hellwig 2019-08-08 7:31 ` Christoph Hellwig 2019-08-08 15:58 ` Logan Gunthorpe 2019-08-08 15:58 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 04/14] PCI/P2PDMA: Factor out __upstream_bridge_distance() Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 05/14] PCI/P2PDMA: Apply host bridge white list for ACS Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 06/14] PCI/P2PDMA: Factor out host_bridge_whitelist() Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 07/14] PCI/P2PDMA: Add whitelist support for Intel Host Bridges Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 08/14] PCI/P2PDMA: Add attrs argument to pci_p2pdma_map_sg() Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 09/14] PCI/P2PDMA: Introduce pci_p2pdma_unmap_sg() Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 10/14] PCI/P2PDMA: Factor out __pci_p2pdma_map_sg() Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 11/14] PCI/P2PDMA: Store mapping method in an xarray Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-08-07 5:59 ` Christoph Hellwig 2019-08-07 5:59 ` Christoph Hellwig 2019-07-30 16:35 ` [PATCH v2 12/14] PCI/P2PDMA: dma_map P2PDMA map requests that traverse the host bridge Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-07-30 16:35 ` [PATCH v2 13/14] PCI/P2PDMA: No longer require no-mmu for host bridge whitelist Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-08-07 5:59 ` Christoph Hellwig 2019-08-07 5:59 ` Christoph Hellwig 2019-08-07 12:43 ` Bjorn Helgaas 2019-08-07 12:43 ` Bjorn Helgaas 2019-08-08 7:29 ` Christoph Hellwig 2019-08-08 7:29 ` Christoph Hellwig 2019-07-30 16:35 ` [PATCH v2 14/14] PCI/P2PDMA: Update documentation for pci_p2pdma_distance_many() Logan Gunthorpe 2019-07-30 16:35 ` Logan Gunthorpe 2019-08-06 23:44 ` [PATCH v2 00/14] PCI/P2PDMA: Support transactions that hit the host bridge Bjorn Helgaas 2019-08-06 23:44 ` Bjorn Helgaas 2019-08-07 0:31 ` Logan Gunthorpe 2019-08-07 0:31 ` Logan Gunthorpe 2019-08-07 19:29 ` Bjorn Helgaas 2019-08-07 19:29 ` Bjorn Helgaas
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190730163545.4915-2-logang@deltatee.com \ --to=logang@deltatee.com \ --cc=Christian.Koenig@amd.com \ --cc=axboe@fb.com \ --cc=bhelgaas@google.com \ --cc=dan.j.williams@intel.com \ --cc=epilmore@gigaio.com \ --cc=hch@lst.de \ --cc=jgg@mellanox.com \ --cc=kbusch@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-nvme@lists.infradead.org \ --cc=linux-pci@vger.kernel.org \ --cc=linux-rdma@vger.kernel.org \ --cc=sagi@grimberg.me \ --cc=sbates@raithlin.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.