Re: [PATCH v11 5/6] iommu/dma: Allow a single FQ in addition to per-CPU FQs

From: Robin Murphy
Date: Tue Aug 29 2023 - 11:40:47 EST


On 2023-08-23 15:21, Niklas Schnelle wrote:
[...]
+struct dma_iommu_options {
+#define IOMMU_DMA_OPTS_PER_CPU_QUEUE 0L

Nit: if the intent is to add more flags then that will no longer make
sense, and if not then we may as well just have a bool ;)

+#define IOMMU_DMA_OPTS_SINGLE_QUEUE BIT(0)

My thinking was that the above two options are mutually exclusive with
per-CPU encoded as BIT(0) unset and single queue as set. Then other
options could still use the other bits. It's true though that the below
use of IOMMU_DMA_OPTS_PER_CPU_QUEUE is a nop so maybe just drop that?
Or we could use an enum even if I don't forsee more than these 2 queue
types.

My point was that the value 0 can only mean "all flags not set", so while we can very much have the semantic of "single queue flag not set means percpu queue", we cannot infer "0 means percpu queue" unless "all flags" and "single queue flag" are the same thing. As soon as any additional flag is defined, 0 then has a different meaning which may well not even be a combination that's useful to put a specific name to.

I'd like to hope it's sufficiently obvious from the implementation that the opposite of a single queue is multiple queues, since contextually this is already all happening in distinct paths from the case of no queue.

Thanks,
Robin.