linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] iommu/amd: set iommu for early mapped ioapic/hpet
@ 2014-09-01  6:17 Su, Friendy
  2014-09-03 15:05 ` joro
  0 siblings, 1 reply; 3+ messages in thread
From: Su, Friendy @ 2014-09-01  6:17 UTC (permalink / raw)
  To: joro; +Cc: iommu, linux-kernel


From: Su Friendy <friendy.su@sony.com.cn>

The early mapped ioapic/hpet specified by kernel boot parameter
ivrs_ioapic[ID]/ivrs_hpet[ID] always override the ioapic/hpet with
same ID reported by ACPI IVRS table. Therefore, the early mapped
should be always controlled by iommu.

Current driver did not set iommu for the early mapped. This causes
ivrs_ioapic[ID]/ivrs_hpet[ID] actually are not controlled by iommu.
This patch fixes this problem by setting iommu for early mapped.

Signed-off-by: Su Friendy <friendy.su@sony.com.cn>
Signed-off-by: Saeki Shusuke <shusuke.saeki@jp.sony.com>
Signed-off-by: Tamori Masahiro <Masahiro.Tamori@jp.sony.com>
---
 drivers/iommu/amd_iommu_init.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 3783e0b..148ab61 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -747,7 +747,7 @@ static int __init add_special_device(u8 type, u8 id, u16 devid, bool cmd_line)
 	return 0;
 }
 
-static int __init add_early_maps(void)
+static int __init add_early_maps(struct amd_iommu *iommu)
 {
 	int i, ret;
 
@@ -758,6 +758,11 @@ static int __init add_early_maps(void)
 					 early_ioapic_map[i].cmd_line);
 		if (ret)
 			return ret;
+		/*
+		 * early mapped ioapci overrides ACPI IVRS,
+		 * they should be always controlled by iommu.
+		 */
+		set_iommu_for_device(iommu, early_ioapic_map[i].devid);
 	}
 
 	for (i = 0; i < early_hpet_map_size; ++i) {
@@ -767,6 +772,11 @@ static int __init add_early_maps(void)
 					 early_hpet_map[i].cmd_line);
 		if (ret)
 			return ret;
+		/*
+		 * early mapped hpet overrides ACPI IVRS,
+		 * they should be always controlled by iommu.
+		 */
+		set_iommu_for_device(iommu, early_hpet_map[i].devid);
 	}
 
 	return 0;
@@ -811,7 +821,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
 	int ret;
 
 
-	ret = add_early_maps();
+	ret = add_early_maps(iommu);
 	if (ret)
 		return ret;
 
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] iommu/amd: set iommu for early mapped ioapic/hpet
  2014-09-01  6:17 [PATCH v1 1/1] iommu/amd: set iommu for early mapped ioapic/hpet Su, Friendy
@ 2014-09-03 15:05 ` joro
  2014-09-05 11:17   ` Su, Friendy
  0 siblings, 1 reply; 3+ messages in thread
From: joro @ 2014-09-03 15:05 UTC (permalink / raw)
  To: Su, Friendy; +Cc: iommu, linux-kernel

On Mon, Sep 01, 2014 at 02:17:44PM +0800, Su, Friendy wrote:
> diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
> index 3783e0b..148ab61 100644
> --- a/drivers/iommu/amd_iommu_init.c
> +++ b/drivers/iommu/amd_iommu_init.c
> @@ -747,7 +747,7 @@ static int __init add_special_device(u8 type, u8 id, u16 devid, bool cmd_line)
>  	return 0;
>  }
>  
> -static int __init add_early_maps(void)
> +static int __init add_early_maps(struct amd_iommu *iommu)
>  {
>  	int i, ret;
>  
> @@ -758,6 +758,11 @@ static int __init add_early_maps(void)
>  					 early_ioapic_map[i].cmd_line);
>  		if (ret)
>  			return ret;
> +		/*
> +		 * early mapped ioapci overrides ACPI IVRS,
> +		 * they should be always controlled by iommu.
> +		 */
> +		set_iommu_for_device(iommu, early_ioapic_map[i].devid);
>  	}
>  
>  	for (i = 0; i < early_hpet_map_size; ++i) {
> @@ -767,6 +772,11 @@ static int __init add_early_maps(void)
>  					 early_hpet_map[i].cmd_line);
>  		if (ret)
>  			return ret;
> +		/*
> +		 * early mapped hpet overrides ACPI IVRS,
> +		 * they should be always controlled by iommu.
> +		 */
> +		set_iommu_for_device(iommu, early_hpet_map[i].devid);

This doesn't work on machines with multiple IOMMUs in it. Also the
problem only exists if there is no IVHD entry in the IVRS table for the
device containing IOAPIC and HPET.

But if this IVHD entry is not present we can't reliably know which IOMMU
is responsible for a given IOAPIC/HPET.


	Joerg


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v1 1/1] iommu/amd: set iommu for early mapped ioapic/hpet
  2014-09-03 15:05 ` joro
@ 2014-09-05 11:17   ` Su, Friendy
  0 siblings, 0 replies; 3+ messages in thread
From: Su, Friendy @ 2014-09-05 11:17 UTC (permalink / raw)
  To: joro; +Cc: iommu, linux-kernel

Hi, Joerg,

> -----Original Message-----
> From: joro@8bytes.org [mailto:joro@8bytes.org]
> Sent: Wednesday, September 03, 2014 11:06 PM
> To: Su, Friendy
> Cc: iommu@lists.linux-foundation.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v1 1/1] iommu/amd: set iommu for early mapped
> ioapic/hpet
> 
> On Mon, Sep 01, 2014 at 02:17:44PM +0800, Su, Friendy wrote:
> > diff --git a/drivers/iommu/amd_iommu_init.c
> b/drivers/iommu/amd_iommu_init.c
> > index 3783e0b..148ab61 100644
> > --- a/drivers/iommu/amd_iommu_init.c
> > +++ b/drivers/iommu/amd_iommu_init.c
> > @@ -747,7 +747,7 @@ static int __init add_special_device(u8 type, u8 id,
> u16 devid, bool cmd_line)
> >  	return 0;
> >  }
> >
> > -static int __init add_early_maps(void)
> > +static int __init add_early_maps(struct amd_iommu *iommu)
> >  {
> >  	int i, ret;
> >
> > @@ -758,6 +758,11 @@ static int __init add_early_maps(void)
> >  					 early_ioapic_map[i].cmd_line);
> >  		if (ret)
> >  			return ret;
> > +		/*
> > +		 * early mapped ioapci overrides ACPI IVRS,
> > +		 * they should be always controlled by iommu.
> > +		 */
> > +		set_iommu_for_device(iommu, early_ioapic_map[i].devid);
> >  	}
> >
> >  	for (i = 0; i < early_hpet_map_size; ++i) {
> > @@ -767,6 +772,11 @@ static int __init add_early_maps(void)
> >  					 early_hpet_map[i].cmd_line);
> >  		if (ret)
> >  			return ret;
> > +		/*
> > +		 * early mapped hpet overrides ACPI IVRS,
> > +		 * they should be always controlled by iommu.
> > +		 */
> > +		set_iommu_for_device(iommu, early_hpet_map[i].devid);
> 
> This doesn't work on machines with multiple IOMMUs in it. Also the
> problem only exists if there is no IVHD entry in the IVRS table for the
> device containing IOAPIC and HPET.
> 
> But if this IVHD entry is not present we can't reliably know which IOMMU
> is responsible for a given IOAPIC/HPET.
> 
> 
> 	Joerg
> 
Thanks. You are correct, we should handle early mapped inside IOMMU whose IVHD reports the same ID. I will update.

Friendy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-05 11:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-01  6:17 [PATCH v1 1/1] iommu/amd: set iommu for early mapped ioapic/hpet Su, Friendy
2014-09-03 15:05 ` joro
2014-09-05 11:17   ` Su, Friendy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).