linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] agpgart-amd64 not initialized in 2.6.33-rc2
@ 2009-12-27 15:19 Marin Mitov
  2009-12-28  6:37 ` FUJITA Tomonori
  0 siblings, 1 reply; 6+ messages in thread
From: Marin Mitov @ 2009-12-27 15:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

Hi all,

Recently (2.6.33-rc2 kernel, x86_64, 4GB RAM) I found (in dmesg):

[drm:mga_do_agp_dma_bootstrap] *ERROR* Unable to acquire AGP: -19

and there is no /dev/agpgart device on the machine while all is OK 
if booting 2.6.32.2. 

In both kernels I have:

CONFIG_AGP=y
CONFIG_AGP_AMD64=y

CONFIG_GART_IOMMU=y

but nevertheless dmesg shows:

PCI-DMA: Using software bounce buffering for IO (SWIOTLB)

due to quirks in via K8T800Pro host bridge.

Looking for the reason I found that agp_amd64_init() appears in:

#ifndef CONFIG_GART_IOMMU
module_init(agp_amd64_init);
module_exit(agp_amd64_cleanup);
#endif

 /*  so it is not invoked here due to CONFIG_GART_IOMMU=y   */

and also appears in:
 
arch/x86/kernel/pci-gart_64.c, function: gart_iommu_init()

The last one is part of the struct x86_init_ops(struct x86_init_iommu, as a function pointer) 
only if gart-iommu is successfully detected, which is not the case here due to the quirk, 
so agp_amd64_init() is not invoked here neither. 

Sure, configuring the kernel without CONFIG_GART_IOMMU=y (which is not user selectable)

should solve the problem, but usually users do not know about quirks, so it should
work even as set here (and it works up to 2.6.32.2). I believe the bug is introduced
with the changes in the order iommu detect/init works for 2.6.33.

I am here for additional info/tests.

Best regards

Marin Mitov



 

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

* Re: [BUG] agpgart-amd64 not initialized in 2.6.33-rc2
  2009-12-27 15:19 [BUG] agpgart-amd64 not initialized in 2.6.33-rc2 Marin Mitov
@ 2009-12-28  6:37 ` FUJITA Tomonori
  2009-12-28  7:18   ` Marin Mitov
  0 siblings, 1 reply; 6+ messages in thread
From: FUJITA Tomonori @ 2009-12-28  6:37 UTC (permalink / raw)
  To: mitov; +Cc: linux-kernel, tglx, mingo, hpa

On Sun, 27 Dec 2009 17:19:39 +0200
Marin Mitov <mitov@issp.bas.bg> wrote:

> Hi all,
> 
> Recently (2.6.33-rc2 kernel, x86_64, 4GB RAM) I found (in dmesg):
> 
> [drm:mga_do_agp_dma_bootstrap] *ERROR* Unable to acquire AGP: -19
> 
> and there is no /dev/agpgart device on the machine while all is OK 
> if booting 2.6.32.2. 
> 
> In both kernels I have:
> 
> CONFIG_AGP=y
> CONFIG_AGP_AMD64=y
> 
> CONFIG_GART_IOMMU=y
> 
> but nevertheless dmesg shows:
> 
> PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
> 
> due to quirks in via K8T800Pro host bridge.
> 
> Looking for the reason I found that agp_amd64_init() appears in:
> 
> #ifndef CONFIG_GART_IOMMU
> module_init(agp_amd64_init);
> module_exit(agp_amd64_cleanup);
> #endif
> 
>  /*  so it is not invoked here due to CONFIG_GART_IOMMU=y   */
> 
> and also appears in:
>  
> arch/x86/kernel/pci-gart_64.c, function: gart_iommu_init()
> 
> The last one is part of the struct x86_init_ops(struct x86_init_iommu, as a function pointer) 
> only if gart-iommu is successfully detected, which is not the case here due to the quirk, 
> so agp_amd64_init() is not invoked here neither. 
> 
> Sure, configuring the kernel without CONFIG_GART_IOMMU=y (which is not user selectable)
> 
> should solve the problem, but usually users do not know about quirks, so it should
> work even as set here (and it works up to 2.6.32.2). I believe the bug is introduced
> with the changes in the order iommu detect/init works for 2.6.33.
> 
> I am here for additional info/tests.

Sorry about the regression. Does this works?

Thanks,

diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 2fb2e6c..5aa7a58 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -725,9 +725,14 @@ static struct pci_driver agp_amd64_pci_driver = {
 int __init agp_amd64_init(void)
 {
 	int err = 0;
+	static int done = 0;
 
 	if (agp_off)
 		return -EINVAL;
+
+	if (done++)
+		return agp_bridges_found ? 0 : -ENODEV;
+
 	err = pci_register_driver(&agp_amd64_pci_driver);
 	if (err < 0)
 		return err;
@@ -771,12 +776,8 @@ static void __exit agp_amd64_cleanup(void)
 	pci_unregister_driver(&agp_amd64_pci_driver);
 }
 
-/* On AMD64 the PCI driver needs to initialize this driver early
-   for the IOMMU, so it has to be called via a backdoor. */
-#ifndef CONFIG_GART_IOMMU
 module_init(agp_amd64_init);
 module_exit(agp_amd64_cleanup);
-#endif
 
 MODULE_AUTHOR("Dave Jones <davej@redhat.com>, Andi Kleen");
 module_param(agp_try_unsupported, bool, 0);

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

* Re: [BUG] agpgart-amd64 not initialized in 2.6.33-rc2
  2009-12-28  6:37 ` FUJITA Tomonori
@ 2009-12-28  7:18   ` Marin Mitov
  2009-12-28  8:10     ` Ingo Molnar
  0 siblings, 1 reply; 6+ messages in thread
From: Marin Mitov @ 2009-12-28  7:18 UTC (permalink / raw)
  To: FUJITA Tomonori; +Cc: linux-kernel, tglx, mingo, hpa

On Monday 28 December 2009 08:37:33 am FUJITA Tomonori wrote:
> On Sun, 27 Dec 2009 17:19:39 +0200
> Marin Mitov <mitov@issp.bas.bg> wrote:
> 
> > Hi all,
> > 
> > Recently (2.6.33-rc2 kernel, x86_64, 4GB RAM) I found (in dmesg):
> > 
> > [drm:mga_do_agp_dma_bootstrap] *ERROR* Unable to acquire AGP: -19
> > 
> > and there is no /dev/agpgart device on the machine while all is OK 
> > if booting 2.6.32.2. 
> > 
> > In both kernels I have:
> > 
> > CONFIG_AGP=y
> > CONFIG_AGP_AMD64=y
> > 
> > CONFIG_GART_IOMMU=y
> > 
> > but nevertheless dmesg shows:
> > 
> > PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
> > 
> > due to quirks in via K8T800Pro host bridge.
> > 
> > Looking for the reason I found that agp_amd64_init() appears in:
> > 
> > #ifndef CONFIG_GART_IOMMU
> > module_init(agp_amd64_init);
> > module_exit(agp_amd64_cleanup);
> > #endif
> > 
> >  /*  so it is not invoked here due to CONFIG_GART_IOMMU=y   */
> > 
> > and also appears in:
> >  
> > arch/x86/kernel/pci-gart_64.c, function: gart_iommu_init()
> > 
> > The last one is part of the struct x86_init_ops(struct x86_init_iommu, as a function pointer) 
> > only if gart-iommu is successfully detected, which is not the case here due to the quirk, 
> > so agp_amd64_init() is not invoked here neither. 
> > 
> > Sure, configuring the kernel without CONFIG_GART_IOMMU=y (which is not user selectable)
> > 
> > should solve the problem, but usually users do not know about quirks, so it should
> > work even as set here (and it works up to 2.6.32.2). I believe the bug is introduced
> > with the changes in the order iommu detect/init works for 2.6.33.
> > 
> > I am here for additional info/tests.
> 
> Sorry about the regression. Does this works?

Yes, it works for me, thank you.

Marin Mitov

> diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
> index 2fb2e6c..5aa7a58 100644
> --- a/drivers/char/agp/amd64-agp.c
> +++ b/drivers/char/agp/amd64-agp.c
> @@ -725,9 +725,14 @@ static struct pci_driver agp_amd64_pci_driver = {
>  int __init agp_amd64_init(void)
>  {
>  	int err = 0;
> +	static int done = 0;
>  
>  	if (agp_off)
>  		return -EINVAL;
> +
> +	if (done++)
> +		return agp_bridges_found ? 0 : -ENODEV;
> +
>  	err = pci_register_driver(&agp_amd64_pci_driver);
>  	if (err < 0)
>  		return err;
> @@ -771,12 +776,8 @@ static void __exit agp_amd64_cleanup(void)
>  	pci_unregister_driver(&agp_amd64_pci_driver);
>  }
>  
> -/* On AMD64 the PCI driver needs to initialize this driver early
> -   for the IOMMU, so it has to be called via a backdoor. */
> -#ifndef CONFIG_GART_IOMMU
>  module_init(agp_amd64_init);
>  module_exit(agp_amd64_cleanup);
> -#endif
>  
>  MODULE_AUTHOR("Dave Jones <davej@redhat.com>, Andi Kleen");
>  module_param(agp_try_unsupported, bool, 0);
> 

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

* Re: [BUG] agpgart-amd64 not initialized in 2.6.33-rc2
  2009-12-28  7:18   ` Marin Mitov
@ 2009-12-28  8:10     ` Ingo Molnar
  2009-12-28  9:11       ` FUJITA Tomonori
  0 siblings, 1 reply; 6+ messages in thread
From: Ingo Molnar @ 2009-12-28  8:10 UTC (permalink / raw)
  To: Marin Mitov, Dave Jones; +Cc: FUJITA Tomonori, linux-kernel, tglx, mingo, hpa


* Marin Mitov <mitov@issp.bas.bg> wrote:

> On Monday 28 December 2009 08:37:33 am FUJITA Tomonori wrote:
> > On Sun, 27 Dec 2009 17:19:39 +0200
> > Marin Mitov <mitov@issp.bas.bg> wrote:
> > 
> > > Hi all,
> > > 
> > > Recently (2.6.33-rc2 kernel, x86_64, 4GB RAM) I found (in dmesg):
> > > 
> > > [drm:mga_do_agp_dma_bootstrap] *ERROR* Unable to acquire AGP: -19
> > > 
> > > and there is no /dev/agpgart device on the machine while all is OK 
> > > if booting 2.6.32.2. 
> > > 
> > > In both kernels I have:
> > > 
> > > CONFIG_AGP=y
> > > CONFIG_AGP_AMD64=y
> > > 
> > > CONFIG_GART_IOMMU=y
> > > 
> > > but nevertheless dmesg shows:
> > > 
> > > PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
> > > 
> > > due to quirks in via K8T800Pro host bridge.
> > > 
> > > Looking for the reason I found that agp_amd64_init() appears in:
> > > 
> > > #ifndef CONFIG_GART_IOMMU
> > > module_init(agp_amd64_init);
> > > module_exit(agp_amd64_cleanup);
> > > #endif
> > > 
> > >  /*  so it is not invoked here due to CONFIG_GART_IOMMU=y   */
> > > 
> > > and also appears in:
> > >  
> > > arch/x86/kernel/pci-gart_64.c, function: gart_iommu_init()
> > > 
> > > The last one is part of the struct x86_init_ops(struct x86_init_iommu, as a function pointer) 
> > > only if gart-iommu is successfully detected, which is not the case here due to the quirk, 
> > > so agp_amd64_init() is not invoked here neither. 
> > > 
> > > Sure, configuring the kernel without CONFIG_GART_IOMMU=y (which is not user selectable)
> > > 
> > > should solve the problem, but usually users do not know about quirks, so it should
> > > work even as set here (and it works up to 2.6.32.2). I believe the bug is introduced
> > > with the changes in the order iommu detect/init works for 2.6.33.
> > > 
> > > I am here for additional info/tests.
> > 
> > Sorry about the regression. Does this works?
> 
> Yes, it works for me, thank you.

Great! Fujita-san, mind sending a fully changelogged version of the patch with 
Tested-by and your Signed-off-by?

Dave, do you want to push this fix to Linus, or should we do it via 
x86/urgent?

Thanks,

	Ingo

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

* Re: [BUG] agpgart-amd64 not initialized in 2.6.33-rc2
  2009-12-28  8:10     ` Ingo Molnar
@ 2009-12-28  9:11       ` FUJITA Tomonori
  2009-12-30 12:21         ` [tip:x86/urgent] x86/agp: Fix agp_amd64_init() initialization with CONFIG_GART_IOMMU enabled tip-bot for FUJITA Tomonori
  0 siblings, 1 reply; 6+ messages in thread
From: FUJITA Tomonori @ 2009-12-28  9:11 UTC (permalink / raw)
  To: mingo; +Cc: mitov, davej, fujita.tomonori, linux-kernel, tglx, mingo, hpa

On Mon, 28 Dec 2009 09:10:21 +0100
Ingo Molnar <mingo@elte.hu> wrote:

> 
> * Marin Mitov <mitov@issp.bas.bg> wrote:
> 
> > On Monday 28 December 2009 08:37:33 am FUJITA Tomonori wrote:
> > > On Sun, 27 Dec 2009 17:19:39 +0200
> > > Marin Mitov <mitov@issp.bas.bg> wrote:
> > > 
> > > > Hi all,
> > > > 
> > > > Recently (2.6.33-rc2 kernel, x86_64, 4GB RAM) I found (in dmesg):
> > > > 
> > > > [drm:mga_do_agp_dma_bootstrap] *ERROR* Unable to acquire AGP: -19
> > > > 
> > > > and there is no /dev/agpgart device on the machine while all is OK 
> > > > if booting 2.6.32.2. 
> > > > 
> > > > In both kernels I have:
> > > > 
> > > > CONFIG_AGP=y
> > > > CONFIG_AGP_AMD64=y
> > > > 
> > > > CONFIG_GART_IOMMU=y
> > > > 
> > > > but nevertheless dmesg shows:
> > > > 
> > > > PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
> > > > 
> > > > due to quirks in via K8T800Pro host bridge.
> > > > 
> > > > Looking for the reason I found that agp_amd64_init() appears in:
> > > > 
> > > > #ifndef CONFIG_GART_IOMMU
> > > > module_init(agp_amd64_init);
> > > > module_exit(agp_amd64_cleanup);
> > > > #endif
> > > > 
> > > >  /*  so it is not invoked here due to CONFIG_GART_IOMMU=y   */
> > > > 
> > > > and also appears in:
> > > >  
> > > > arch/x86/kernel/pci-gart_64.c, function: gart_iommu_init()
> > > > 
> > > > The last one is part of the struct x86_init_ops(struct x86_init_iommu, as a function pointer) 
> > > > only if gart-iommu is successfully detected, which is not the case here due to the quirk, 
> > > > so agp_amd64_init() is not invoked here neither. 
> > > > 
> > > > Sure, configuring the kernel without CONFIG_GART_IOMMU=y (which is not user selectable)
> > > > 
> > > > should solve the problem, but usually users do not know about quirks, so it should
> > > > work even as set here (and it works up to 2.6.32.2). I believe the bug is introduced
> > > > with the changes in the order iommu detect/init works for 2.6.33.
> > > > 
> > > > I am here for additional info/tests.
> > > 
> > > Sorry about the regression. Does this works?
> > 
> > Yes, it works for me, thank you.
> 
> Great! Fujita-san, mind sending a fully changelogged version of the patch with 
> Tested-by and your Signed-off-by?

=
From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Subject: [PATCH] x86/agp: fix agp_amd64_init() initialization with CONFIG_GART_IOMMU enabled

drivers/char/agp/amd64-agp.c has:

#ifndef CONFIG_GART_IOMMU
module_init(agp_amd64_init);
module_exit(agp_amd64_cleanup);
#endif

agp_amd64_init() was called via gart_iommu_init with CONFIG_GART_IOMMU=y
agp_amd64_init() was called via module_init with CONFIG_GART_IOMMU=n

The commit 75f1cdf1dda92cae037ec848ae63690d91913eac changes the x86
dma initialization routine: gart_iommu_init() is called only when GART
IOMMU is detected. So when GART IOMMU isn't detected, agp_amd64_init
isn't called.

Marin Mitov reported this issue:

http://marc.info/?l=linux-kernel&m=126192729110083&w=2

With this patch, agp_amd64_init() is always called via module_init
(the above ifndef is removed). If agp_amd64_init() is called via
gart_iommu_init() earlier, agp_amd64_init() finishes without doing
anything (when it is called via module_init).

Reported-by: Marin Mitov <mitov@issp.bas.bg>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tested-by: Marin Mitov <mitov@issp.bas.bg>
---
 drivers/char/agp/amd64-agp.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 2fb2e6c..5aa7a58 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -725,9 +725,14 @@ static struct pci_driver agp_amd64_pci_driver = {
 int __init agp_amd64_init(void)
 {
 	int err = 0;
+	static int done = 0;
 
 	if (agp_off)
 		return -EINVAL;
+
+	if (done++)
+		return agp_bridges_found ? 0 : -ENODEV;
+
 	err = pci_register_driver(&agp_amd64_pci_driver);
 	if (err < 0)
 		return err;
@@ -771,12 +776,8 @@ static void __exit agp_amd64_cleanup(void)
 	pci_unregister_driver(&agp_amd64_pci_driver);
 }
 
-/* On AMD64 the PCI driver needs to initialize this driver early
-   for the IOMMU, so it has to be called via a backdoor. */
-#ifndef CONFIG_GART_IOMMU
 module_init(agp_amd64_init);
 module_exit(agp_amd64_cleanup);
-#endif
 
 MODULE_AUTHOR("Dave Jones <davej@redhat.com>, Andi Kleen");
 module_param(agp_try_unsupported, bool, 0);
-- 
1.5.6.5


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

* [tip:x86/urgent] x86/agp: Fix agp_amd64_init() initialization with CONFIG_GART_IOMMU enabled
  2009-12-28  9:11       ` FUJITA Tomonori
@ 2009-12-30 12:21         ` tip-bot for FUJITA Tomonori
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for FUJITA Tomonori @ 2009-12-30 12:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, fujita.tomonori, tglx, mingo, mitov

Commit-ID:  f405d2c02395a74d3883bd03ded36457aa3697ad
Gitweb:     http://git.kernel.org/tip/f405d2c02395a74d3883bd03ded36457aa3697ad
Author:     FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
AuthorDate: Mon, 28 Dec 2009 18:11:56 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 30 Dec 2009 11:52:04 +0100

x86/agp: Fix agp_amd64_init() initialization with CONFIG_GART_IOMMU enabled

with CONFIG_GART_IOMMU enabled drivers/char/agp/amd64-agp.c has:

 #ifndef CONFIG_GART_IOMMU
 module_init(agp_amd64_init);
 module_exit(agp_amd64_cleanup);
 #endif

agp_amd64_init() was called via gart_iommu_init with
CONFIG_GART_IOMMU=y agp_amd64_init() was called via module_init
with CONFIG_GART_IOMMU=n

The commit 75f1cdf1dda92cae037ec848ae63690d91913eac changes the
x86 dma initialization routine: gart_iommu_init() is called only
when GART IOMMU is detected. So when GART IOMMU isn't detected,
agp_amd64_init isn't called.

Marin Mitov reported this issue:

 http://marc.info/?l=linux-kernel&m=126192729110083&w=2

With this patch, agp_amd64_init() is always called via
module_init (the above ifndef is removed). If agp_amd64_init()
is called via gart_iommu_init() earlier, agp_amd64_init()
finishes without doing anything (when it is called via
module_init).

Reported-by: Marin Mitov <mitov@issp.bas.bg>
Tested-by: Marin Mitov <mitov@issp.bas.bg>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: davej@redhat.com
LKML-Reference: <20091228181118C.fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 drivers/char/agp/amd64-agp.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 2fb2e6c..5aa7a58 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -725,9 +725,14 @@ static struct pci_driver agp_amd64_pci_driver = {
 int __init agp_amd64_init(void)
 {
 	int err = 0;
+	static int done = 0;
 
 	if (agp_off)
 		return -EINVAL;
+
+	if (done++)
+		return agp_bridges_found ? 0 : -ENODEV;
+
 	err = pci_register_driver(&agp_amd64_pci_driver);
 	if (err < 0)
 		return err;
@@ -771,12 +776,8 @@ static void __exit agp_amd64_cleanup(void)
 	pci_unregister_driver(&agp_amd64_pci_driver);
 }
 
-/* On AMD64 the PCI driver needs to initialize this driver early
-   for the IOMMU, so it has to be called via a backdoor. */
-#ifndef CONFIG_GART_IOMMU
 module_init(agp_amd64_init);
 module_exit(agp_amd64_cleanup);
-#endif
 
 MODULE_AUTHOR("Dave Jones <davej@redhat.com>, Andi Kleen");
 module_param(agp_try_unsupported, bool, 0);

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

end of thread, other threads:[~2009-12-30 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-27 15:19 [BUG] agpgart-amd64 not initialized in 2.6.33-rc2 Marin Mitov
2009-12-28  6:37 ` FUJITA Tomonori
2009-12-28  7:18   ` Marin Mitov
2009-12-28  8:10     ` Ingo Molnar
2009-12-28  9:11       ` FUJITA Tomonori
2009-12-30 12:21         ` [tip:x86/urgent] x86/agp: Fix agp_amd64_init() initialization with CONFIG_GART_IOMMU enabled tip-bot for FUJITA Tomonori

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).