[PATCH] intel-iommu: Synchronize gcmd value with global command register

Takao Indoh indou.takao at jp.fujitsu.com
Mon Apr 1 01:45:18 EDT 2013

(2013/03/27 19:31), Joerg Roedel wrote:
> On Wed, Mar 27, 2013 at 02:02:44PM +0900, Takao Indoh wrote:
>> The root cause of this problem is mismatch between iommu->gcmd and
>> global command register in the case of kdump. At boot time, initial
>> value of iommu->gcmd is zero as I wrote above, but actual global command
>> register is *not* zero because some bits like IRE/TE/QIE are already set
>> in *first* kernel. Therefore this patch synchronize them to fix this
>> problem.
> Ok, I understand, but I still don't see why this is a problem. There is
> no point for the kdump kernel to preserve hardware state from the
> previous kernel. So I think the way it is implemented is correct.

Sorry, my explanation was misleading. The purpose is not preserving
hardware state, but cleaning up hardware status at appropriate place.

kdump kernel boots up without power-on-reset, so we have to disable
hardware functions like DMAR before initializing them.

<Current flow on kdump boot>
    iommu_disable_irq_remapping  <== IRES/QIES/TES disabled here
    dmar_disable_qi              <== do nothing
    dmar_enable_qi               <== QIES enabled
    intel_setup_irq_remapping    <== IRES enabled

    iommu_enable_translation     <== TES enabled

<New flow on kdump boot after applying patch>
    iommu_disable_irq_remapping  <== IRES disabled
    dmar_disable_qi              <== QIES disabled
    dmar_enable_qi               <== QIES enabled
    intel_setup_irq_remapping    <== IRES enabled

    iommu_disable_translation    <== TES disabled (added by patch)
    iommu_enable_translation     <== TES enabled

I want to change flow like this to avoid misunderstanding. In that sense,
this patch is a kind of cleanup rather than fixing problem.

I'm working on kdump problem with iommu and investigated when DMAR and
IR are disabled in kdump kernel boot. As for IR, I can easily find the
code in intel_enable_irq_remapping() since there is good comment for

                 * Disable intr remapping and queued invalidation, if already
                 * enabled prior to OS handover.


However, there is no code to disable DMAR on startup, but it is actually
disabled somewhere during bootup. And finally I found out is is done in
intel_enable_irq_remapping(). This is very misleading. Why
"iommu_disable_irq_remapping" is disabling bits other than IR? After
applying patch, it is easy to understand because it disables only IR, as
the name suggests.

Takao Indoh

More information about the kexec mailing list