mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: mingo@elte.hu, hpa@zytor.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: fix gart iommu using for amd 64 bit system
Date: Tue, 24 Nov 2009 01:19:21 -0800	[thread overview]
Message-ID: <4B0BA519.9090100@kernel.org> (raw)
In-Reply-To: <20091124174608Y.fujita.tomonori@lab.ntt.co.jp>

FUJITA Tomonori wrote:
> On Sat, 21 Nov 2009 20:24:52 -0800
> Yinghai Lu <yinghai@kernel.org> wrote:
> 
>> amd 64 systems that
>> 1. do not have  AGP
>> 2. do not have IOMMU
>> 3. mem > 4g
>> 4. BIOS do not allocate  correct gart in NB.
>> will leave them to use SWIOTLB forcely.
> 
> Sorry, I forgot about this GART workaround.
> 
> 
>> Index: linux-2.6/arch/x86/kernel/pci-dma.c
>> ===================================================================
>> --- linux-2.6.orig/arch/x86/kernel/pci-dma.c
>> +++ linux-2.6/arch/x86/kernel/pci-dma.c
>> @@ -124,11 +124,12 @@ void __init pci_iommu_alloc(void)
>>  	/* free the range so iommu could get some range less than 4G */
>>  	dma32_free_bootmem();
>>  #endif
>> +	if (!swiotlb_force)
>> +		gart_iommu_hole_init();
>> +
>>  	if (pci_swiotlb_init())
>>  		return;
>>  
>> -	gart_iommu_hole_init();
>> -
>>  	detect_calgary();
>>  
>>  	detect_intel_iommu();
> 
> I prefer to detect all the IOMMU drivers in a consistent way;
> detecting only GART before swioltb doesn't look nice.
> 
> As we did before, we could detect all the IOMMU driver before
> swiotlb. However, I think that it's better to simply change
> pci_swiotlb_init() not to steal the preallocate GART workaround memory.
> 
> btw, initializing swiotlb before IOMMU detection is useful to GART
> too? If GART can't allocate the workaround memory, then the kernel
> panic now. We can use swiotlb instead in that case?
> 
> =
> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> Subject: [PATCH] x86: stop swiotlb stealing the GART workaround memory
> 
> swiotlb wrongly uses the GART workaround memory (for bad BIOS) that
> dma32_reserv_bootmem allocates. We need to initialize swiotlb before
> dma32_free_bootmem().
> 
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> ---
>  arch/x86/kernel/pci-dma.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
> index afcc58b..26fe2cd 100644
> --- a/arch/x86/kernel/pci-dma.c
> +++ b/arch/x86/kernel/pci-dma.c
> @@ -120,11 +120,15 @@ static void __init dma32_free_bootmem(void)
>  
>  void __init pci_iommu_alloc(void)
>  {
> +	int use_swiotlb;
> +
> +	use_swiotlb = pci_swiotlb_init();
> +
>  #ifdef CONFIG_X86_64
>  	/* free the range so iommu could get some range less than 4G */
>  	dma32_free_bootmem();
>  #endif
> -	if (pci_swiotlb_init())
> +	if (use_swiotlb)
>  		return;
>  
>  	gart_iommu_hole_init();

pci_swiotlb_init need be called after dma32_free_bootmem
otherwise it could fail for system with lots of memory and numa=off

so dma32_free_bootmem will work for gart_iommu_hole_init and pci_swiotlb_init..
make sure they can get RAM < 4g.

also in gart_iommu_hole_init we need check swiotlb and !valid_agp...
-       } else if (!valid_agp) {
+       } else if (swiotlb && !valid_agp) {

otherwise the the workaround will be skipped...

YH

  reply	other threads:[~2009-11-24  9:20 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-10 10:46 [PATCH v2 0/9] x86: handle HW IOMMU initialization failure gracefully FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 1/9] add iommu_init to x86_init_ops FUJITA Tomonori
2009-11-10 13:22   ` [tip:core/iommu] x86: Add " tip-bot for FUJITA Tomonori
2009-11-10 13:42   ` [tip:core/iommu] x86: Add iommu_init to x86_init_ops, fix build tip-bot for Ingo Molnar
2009-11-10 10:46 ` [PATCH -v2 2/9] Calgary: convert detect_calgary to use iommu_init hook FUJITA Tomonori
2009-11-10 13:22   ` [tip:core/iommu] x86: Calgary: Convert detect_calgary() " tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 3/9] GART: convert gart_iommu_hole_init " FUJITA Tomonori
2009-11-10 13:23   ` [tip:core/iommu] x86: GART: Convert gart_iommu_hole_init() " tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 4/9] amd_iommu: convert amd_iommu_detect " FUJITA Tomonori
2009-11-10 13:23   ` [tip:core/iommu] x86: amd_iommu: Convert amd_iommu_detect() " tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 5/9] intel-iommu: convert detect_intel_iommu " FUJITA Tomonori
2009-11-10 11:12   ` Ingo Molnar
2009-11-10 13:23   ` [tip:core/iommu] x86: intel-iommu: Convert " tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 6/9] bootmem: add free_bootmem_late FUJITA Tomonori
2009-11-10 12:00   ` Johannes Weiner
2009-11-14 12:50     ` FUJITA Tomonori
2009-11-10 13:23   ` [tip:core/iommu] bootmem: Add free_bootmem_late() tip-bot for FUJITA Tomonori
2009-11-11 23:56   ` [PATCH -v2 6/9] bootmem: add free_bootmem_late Andrew Morton
2009-11-12  7:47     ` Ingo Molnar
2009-11-10 10:46 ` [PATCH -v2 7/9] swiotlb: add swiotlb_free function FUJITA Tomonori
2009-11-10 11:27   ` Ingo Molnar
2009-11-10 13:24   ` [tip:core/iommu] swiotlb: Add swiotlb_free() function tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 8/9] swiotlb: export swiotlb_print_info FUJITA Tomonori
2009-11-10 13:24   ` [tip:core/iommu] swiotlb: Defer swiotlb init printing, export swiotlb_print_info() tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 9/9] x86: handle HW IOMMU initialization failure gracely FUJITA Tomonori
2009-11-10 11:27   ` Ingo Molnar
2009-11-10 13:24   ` [tip:core/iommu] x86: Handle HW IOMMU initialization failure gracefully tip-bot for FUJITA Tomonori
2009-11-22  4:24     ` [PATCH] x86: fix gart iommu using for amd 64 bit system Yinghai Lu
2009-11-22  5:19       ` [PATCH] x86: fix gart iommu using for amd 64 bit system -v2 Yinghai Lu
2009-11-24  8:46       ` [PATCH] x86: fix gart iommu using for amd 64 bit system FUJITA Tomonori
2009-11-24  9:19         ` Yinghai Lu [this message]
2009-11-24  9:35           ` FUJITA Tomonori
2009-11-24  9:48             ` Yinghai Lu
2009-11-24 10:31               ` FUJITA Tomonori
2009-11-24 10:42                 ` Yinghai Lu
2009-11-24 13:50                   ` FUJITA Tomonori
2009-11-24 15:26                     ` Ingo Molnar
2009-11-24 18:28                       ` Yinghai Lu
2009-11-24 23:57                       ` FUJITA Tomonori
2009-11-25  7:25                         ` Ingo Molnar
2009-11-25  7:56                           ` FUJITA Tomonori
2009-11-24 18:48                     ` Yinghai Lu
2009-11-24 23:48                       ` FUJITA Tomonori
2009-11-10 11:19 ` [PATCH v2 0/9] x86: handle HW IOMMU initialization failure gracefully Ingo Molnar
2009-11-10 11:55   ` Ingo Molnar
2009-11-10 12:35     ` FUJITA Tomonori
2009-11-22  3:17   ` Yinghai Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B0BA519.9090100@kernel.org \
    --to=yinghai@kernel.org \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome