* [PATCH 1/1] intel-iommu: Disable DMA Remapping when intel_iommu=off
@ 2013-04-20 6:58 Wei Hu
2013-04-22 5:31 ` Takao Indoh
0 siblings, 1 reply; 5+ messages in thread
From: Wei Hu @ 2013-04-20 6:58 UTC (permalink / raw)
To: David Woodhouse; +Cc: iommu, linux-kernel, Wei Hu
On a VT-d capable machine Linux will enable IOMMU by default. If it
then kexec's a second kernel with intel_iommu=off, this second kernel
will leave the DMA remapping engine on with no code handling it. The
symptom is at least USB and SATA drives stop working. This patch fixes
the problem by always disabling DMA remapping when intel_iommu=off.
Signed-off-by: Wei Hu <wei@aristanetworks.com>
---
drivers/iommu/intel-iommu.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 0099667..0b8f8bb 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3681,8 +3681,12 @@ int __init intel_iommu_init(void)
return -ENODEV;
}
- if (no_iommu || dmar_disabled)
+ if (no_iommu || dmar_disabled) {
+ struct dmar_drhd_unit *drhd;
+ for_each_drhd_unit(drhd)
+ iommu_disable_translation(drhd->iommu);
return -ENODEV;
+ }
if (iommu_init_mempool()) {
if (force_on)
--
1.7.4.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] intel-iommu: Disable DMA Remapping when intel_iommu=off
2013-04-20 6:58 [PATCH 1/1] intel-iommu: Disable DMA Remapping when intel_iommu=off Wei Hu
@ 2013-04-22 5:31 ` Takao Indoh
2013-04-22 6:50 ` Wei Hu
0 siblings, 1 reply; 5+ messages in thread
From: Takao Indoh @ 2013-04-22 5:31 UTC (permalink / raw)
To: wei; +Cc: dwmw2, iommu, linux-kernel
(2013/04/20 15:58), Wei Hu wrote:
> On a VT-d capable machine Linux will enable IOMMU by default. If it
> then kexec's a second kernel with intel_iommu=off, this second kernel
> will leave the DMA remapping engine on with no code handling it. The
> symptom is at least USB and SATA drives stop working. This patch fixes
> the problem by always disabling DMA remapping when intel_iommu=off.
Even when second kernel boots up with intel_iommu=on, dma-remapping need
to be disabled as well before it is initialized and enabled again in
init_dmars(). So, how about something like this?
for_each_drhd_unit(drhd) {
struct dmar_drhd_unit *drhd;
if (drhd->ignored)
continue;
iommu = drhd->iommu;
if (iommu->gcmd & DMA_GCMD_TE)
iommu_disable_translation(iommu);
}
Note, if you agree above code and fix your patch like this, you need
additinal fix to set iommu->gcmd flag sinse gcmd is always zero here.
See first hunk of this patch.
https://lkml.org/lkml/2013/3/20/707
Thanks,
Takao Indoh
>
> Signed-off-by: Wei Hu <wei@aristanetworks.com>
> ---
> drivers/iommu/intel-iommu.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 0099667..0b8f8bb 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -3681,8 +3681,12 @@ int __init intel_iommu_init(void)
> return -ENODEV;
> }
>
> - if (no_iommu || dmar_disabled)
> + if (no_iommu || dmar_disabled) {
> + struct dmar_drhd_unit *drhd;
> + for_each_drhd_unit(drhd)
> + iommu_disable_translation(drhd->iommu);
> return -ENODEV;
> + }
>
> if (iommu_init_mempool()) {
> if (force_on)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] intel-iommu: Disable DMA Remapping when intel_iommu=off
2013-04-22 5:31 ` Takao Indoh
@ 2013-04-22 6:50 ` Wei Hu
2013-04-22 7:06 ` Takao Indoh
0 siblings, 1 reply; 5+ messages in thread
From: Wei Hu @ 2013-04-22 6:50 UTC (permalink / raw)
To: Takao Indoh; +Cc: dwmw2, iommu, linux-kernel
On Sun, Apr 21, 2013 at 10:31 PM, Takao Indoh
<indou.takao@jp.fujitsu.com> wrote:
> (2013/04/20 15:58), Wei Hu wrote:
>> On a VT-d capable machine Linux will enable IOMMU by default. If it
>> then kexec's a second kernel with intel_iommu=off, this second kernel
>> will leave the DMA remapping engine on with no code handling it. The
>> symptom is at least USB and SATA drives stop working. This patch fixes
>> the problem by always disabling DMA remapping when intel_iommu=off.
>
> Even when second kernel boots up with intel_iommu=on, dma-remapping need
> to be disabled as well before it is initialized and enabled again in
> init_dmars(). So, how about something like this?
>
> for_each_drhd_unit(drhd) {
> struct dmar_drhd_unit *drhd;
> if (drhd->ignored)
> continue;
>
> iommu = drhd->iommu;
> if (iommu->gcmd & DMA_GCMD_TE)
> iommu_disable_translation(iommu);
> }
>
> Note, if you agree above code and fix your patch like this, you need
> additinal fix to set iommu->gcmd flag sinse gcmd is always zero here.
> See first hunk of this patch.
> https://lkml.org/lkml/2013/3/20/707
Thanks for your reply. I reviewed your patch. Are you suggesting
keeping your change to dmar.c, and moving your change to intel-iommu.c
(i.e. the code you just showed) up after the call to
dmar_table_init()?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] intel-iommu: Disable DMA Remapping when intel_iommu=off
2013-04-22 6:50 ` Wei Hu
@ 2013-04-22 7:06 ` Takao Indoh
2013-04-22 7:11 ` Wei Hu
0 siblings, 1 reply; 5+ messages in thread
From: Takao Indoh @ 2013-04-22 7:06 UTC (permalink / raw)
To: wei; +Cc: dwmw2, iommu, linux-kernel
(2013/04/22 15:50), Wei Hu wrote:
> On Sun, Apr 21, 2013 at 10:31 PM, Takao Indoh
> <indou.takao@jp.fujitsu.com> wrote:
>> (2013/04/20 15:58), Wei Hu wrote:
>>> On a VT-d capable machine Linux will enable IOMMU by default. If it
>>> then kexec's a second kernel with intel_iommu=off, this second kernel
>>> will leave the DMA remapping engine on with no code handling it. The
>>> symptom is at least USB and SATA drives stop working. This patch fixes
>>> the problem by always disabling DMA remapping when intel_iommu=off.
>>
>> Even when second kernel boots up with intel_iommu=on, dma-remapping need
>> to be disabled as well before it is initialized and enabled again in
>> init_dmars(). So, how about something like this?
>>
>> for_each_drhd_unit(drhd) {
>> struct dmar_drhd_unit *drhd;
>> if (drhd->ignored)
>> continue;
>>
>> iommu = drhd->iommu;
>> if (iommu->gcmd & DMA_GCMD_TE)
>> iommu_disable_translation(iommu);
>> }
>>
>> Note, if you agree above code and fix your patch like this, you need
>> additinal fix to set iommu->gcmd flag sinse gcmd is always zero here.
>> See first hunk of this patch.
>> https://lkml.org/lkml/2013/3/20/707
>
> Thanks for your reply. I reviewed your patch. Are you suggesting
> keeping your change to dmar.c, and moving your change to intel-iommu.c
> (i.e. the code you just showed) up after the call to
> dmar_table_init()?
>
Yes, exactly.
Thanks,
Takao Indoh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] intel-iommu: Disable DMA Remapping when intel_iommu=off
2013-04-22 7:06 ` Takao Indoh
@ 2013-04-22 7:11 ` Wei Hu
0 siblings, 0 replies; 5+ messages in thread
From: Wei Hu @ 2013-04-22 7:11 UTC (permalink / raw)
To: Takao Indoh; +Cc: dwmw2, iommu, linux-kernel
On Mon, Apr 22, 2013 at 12:06 AM, Takao Indoh
<indou.takao@jp.fujitsu.com> wrote:
> (2013/04/22 15:50), Wei Hu wrote:
>> On Sun, Apr 21, 2013 at 10:31 PM, Takao Indoh
>> <indou.takao@jp.fujitsu.com> wrote:
>>> (2013/04/20 15:58), Wei Hu wrote:
>>>> On a VT-d capable machine Linux will enable IOMMU by default. If it
>>>> then kexec's a second kernel with intel_iommu=off, this second kernel
>>>> will leave the DMA remapping engine on with no code handling it. The
>>>> symptom is at least USB and SATA drives stop working. This patch fixes
>>>> the problem by always disabling DMA remapping when intel_iommu=off.
>>>
>>> Even when second kernel boots up with intel_iommu=on, dma-remapping need
>>> to be disabled as well before it is initialized and enabled again in
>>> init_dmars(). So, how about something like this?
>>>
>>> for_each_drhd_unit(drhd) {
>>> struct dmar_drhd_unit *drhd;
>>> if (drhd->ignored)
>>> continue;
>>>
>>> iommu = drhd->iommu;
>>> if (iommu->gcmd & DMA_GCMD_TE)
>>> iommu_disable_translation(iommu);
>>> }
>>>
>>> Note, if you agree above code and fix your patch like this, you need
>>> additinal fix to set iommu->gcmd flag sinse gcmd is always zero here.
>>> See first hunk of this patch.
>>> https://lkml.org/lkml/2013/3/20/707
>>
>> Thanks for your reply. I reviewed your patch. Are you suggesting
>> keeping your change to dmar.c, and moving your change to intel-iommu.c
>> (i.e. the code you just showed) up after the call to
>> dmar_table_init()?
>>
>
> Yes, exactly.
>
> Thanks,
> Takao Indoh
>
Sounds great. If you want to make the change and get your patch
accepted that's fine with me.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-04-22 7:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-20 6:58 [PATCH 1/1] intel-iommu: Disable DMA Remapping when intel_iommu=off Wei Hu
2013-04-22 5:31 ` Takao Indoh
2013-04-22 6:50 ` Wei Hu
2013-04-22 7:06 ` Takao Indoh
2013-04-22 7:11 ` Wei Hu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox