Thread (81 messages) 81 messages, 6 authors, 2021-05-11

Re: [PATCH 12/16] nvme-pci: Check DMA ops when indicating support for PCI P2PDMA

From: John Hubbard <jhubbard@nvidia.com>
Date: 2021-05-04 00:17:59
Also in: linux-block, linux-iommu, linux-nvme, linux-pci, lkml

On 5/3/21 10:17 AM, Logan Gunthorpe wrote:
...
quoted
quoted
   	blk_queue_flag_set(QUEUE_FLAG_NONROT, ns->queue);
-	if (ctrl->ops->flags & NVME_F_PCI_P2PDMA)
+	if (ctrl->ops->supports_pci_p2pdma &&
+	    ctrl->ops->supports_pci_p2pdma(ctrl))
This is a little excessive, as I suspected. How about providing a
default .supports_pci_p2pdma routine that returns false, so that
the op is always available (non-null)? By "default", maybe that
means either requiring an init_the_ops_struct() routine to be
used, and/or checking all the users of struct nvme_ctrl_ops.
Honestly that sounds much more messy to me than simply checking if it's
NULL before using it (which is a common, accepted pattern for ops).
OK, it's a minor suggestion, so feel free to ignore if you prefer it
the other way, sure.
quoted
Another idea: maybe you don't really need a bool .supports_pci_p2pdma()
routine at all, because the existing .flags really is about right.
You just need the flags to be filled in dynamically. So, do that
during nvme_pci setup/init time: that's when this module would call
dma_pci_p2pdma_supported().
If the flag is filled in dynamically, then the ops struct would have to
be non-constant. Ops structs should be constant for security reasons.
Hadn't thought about keeping ops structs constant. OK.

thanks,
-- 
John Hubbard
NVIDIA
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help