Skip to content

Commit 2f85944

Browse files
lsgunthChristoph Hellwig
authored andcommitted
nvme-pci: check DMA ops when indicating support for PCI P2PDMA
Introduce a supports_pci_p2pdma() operation in nvme_ctrl_ops to replace the fixed NVME_F_PCI_P2PDMA flag such that the dma_map_ops flags can be checked for PCI P2PDMA support. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 30280ee commit 2f85944

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

drivers/nvme/host/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3982,7 +3982,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
39823982
blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue);
39833983

39843984
blk_queue_flag_set(QUEUE_FLAG_NONROT, ns->queue);
3985-
if (ctrl->ops->flags & NVME_F_PCI_P2PDMA)
3985+
if (ctrl->ops->supports_pci_p2pdma &&
3986+
ctrl->ops->supports_pci_p2pdma(ctrl))
39863987
blk_queue_flag_set(QUEUE_FLAG_PCI_P2PDMA, ns->queue);
39873988

39883989
ns->ctrl = ctrl;

drivers/nvme/host/nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ struct nvme_ctrl_ops {
495495
unsigned int flags;
496496
#define NVME_F_FABRICS (1 << 0)
497497
#define NVME_F_METADATA_SUPPORTED (1 << 1)
498-
#define NVME_F_PCI_P2PDMA (1 << 2)
499498
int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val);
500499
int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val);
501500
int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val);
@@ -504,6 +503,7 @@ struct nvme_ctrl_ops {
504503
void (*delete_ctrl)(struct nvme_ctrl *ctrl);
505504
int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
506505
void (*print_device_info)(struct nvme_ctrl *ctrl);
506+
bool (*supports_pci_p2pdma)(struct nvme_ctrl *ctrl);
507507
};
508508

509509
/*

drivers/nvme/host/pci.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,7 +2984,6 @@ static int nvme_pci_get_address(struct nvme_ctrl *ctrl, char *buf, int size)
29842984
return snprintf(buf, size, "%s\n", dev_name(&pdev->dev));
29852985
}
29862986

2987-
29882987
static void nvme_pci_print_device_info(struct nvme_ctrl *ctrl)
29892988
{
29902989
struct pci_dev *pdev = to_pci_dev(to_nvme_dev(ctrl)->dev);
@@ -2999,18 +2998,25 @@ static void nvme_pci_print_device_info(struct nvme_ctrl *ctrl)
29992998
subsys->firmware_rev);
30002999
}
30013000

3001+
static bool nvme_pci_supports_pci_p2pdma(struct nvme_ctrl *ctrl)
3002+
{
3003+
struct nvme_dev *dev = to_nvme_dev(ctrl);
3004+
3005+
return dma_pci_p2pdma_supported(dev->dev);
3006+
}
3007+
30023008
static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {
30033009
.name = "pcie",
30043010
.module = THIS_MODULE,
3005-
.flags = NVME_F_METADATA_SUPPORTED |
3006-
NVME_F_PCI_P2PDMA,
3011+
.flags = NVME_F_METADATA_SUPPORTED,
30073012
.reg_read32 = nvme_pci_reg_read32,
30083013
.reg_write32 = nvme_pci_reg_write32,
30093014
.reg_read64 = nvme_pci_reg_read64,
30103015
.free_ctrl = nvme_pci_free_ctrl,
30113016
.submit_async_event = nvme_pci_submit_async_event,
30123017
.get_address = nvme_pci_get_address,
30133018
.print_device_info = nvme_pci_print_device_info,
3019+
.supports_pci_p2pdma = nvme_pci_supports_pci_p2pdma,
30143020
};
30153021

30163022
static int nvme_dev_map(struct nvme_dev *dev)

0 commit comments

Comments
 (0)