[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9b4f4602-55c6-40cd-5bf9-a47c16cec1a3@linux.intel.com>
Date: Fri, 13 Jan 2023 14:02:35 -0500
From: "Liang, Kan" <kan.liang@...ux.intel.com>
To: Baolu Lu <baolu.lu@...ux.intel.com>, joro@...tes.org,
will@...nel.org, dwmw2@...radead.org, robin.murphy@....com,
robert.moore@...el.com, rafael.j.wysocki@...el.com,
lenb@...nel.org, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/7] iommu/vt-d: Support Enhanced Command Interface
On 2023-01-13 9:12 a.m., Baolu Lu wrote:
> On 2023/1/13 21:55, Baolu Lu wrote:
>>> +/*
>>> + * Function to submit a command to the enhanced command interface. The
>>> + * valid enhanced command descriptions are defined in Table 47 of the
>>> + * VT-d spec. The VT-d hardware implementation may support some but not
>>> + * all commands, which can be determined by checking the Enhanced
>>> + * Command Capability Register.
>>> + *
>>> + * Return values:
>>> + * - 0: Command successful without any error;
>>> + * - Negative: software error value;
>>> + * - Nonzero positive: failure status code defined in Table 48.
>>> + */
>>> +int ecmd_submit_sync(struct intel_iommu *iommu, u8 ecmd,
>>> + u64 oa, bool has_ob, u64 ob)
>>> +{
>>> + unsigned long flags;
>>> + u64 res;
>>> + int ret;
>>> +
>>> + if (!cap_ecmds(iommu->cap))
>>> + return -ENODEV;
>>> +
>>> + raw_spin_lock_irqsave(&iommu->register_lock, flags);
>>> +
>>> + res = dmar_readq(iommu->reg + DMAR_ECRSP_REG);
>>> + if (res & DMA_ECMD_ECRSP_IP) {
>>> + ret = -EBUSY;
>>> + goto err;
>>> + }
>>> +
>>> + if (has_ob)
>>> + dmar_writeq(iommu->reg + DMAR_ECEO_REG, ob);
>>
>> The ecmds that require a Operand B are statically defined in the spec,
>> right? What will it look like if we define a static ignore_ob(ecmd)?
>
If so, I think we have to maintain a table of ecmd in the ignore_ob(),
and check the given ecmd at runtime, right?
That sounds hard to maintain and low efficiency with more and more ecmds
are introduced.
> Or simply remove has_ob parameter? The least case is an unnecessary
> write to a register. It's fine as far as I can see since we should avoid
> using it in any critical path.
I was told in the internal review that a MMIO write may trigger a VM
exit, if in a guest. We should avoid such unnecessary MMIO write.
For PMU, right, I don't think we use it at critical path. Now the PMU is
the only customer for ecmd. I think the extra MMIO write can be tolerant.
I will remove has_ob and add some comments in V2.
Thanks,
Kan
>
> --
> Best regards,
> baolu
Powered by blists - more mailing lists