All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Ashish Kalra <ashish.kalra@amd.com>
Cc: Konrad Rzeszutek Wilk <konrad@darnok.org>,
	hch@lst.de, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	hpa@zytor.com, x86@kernel.org, luto@kernel.org,
	peterz@infradead.org, dave.hansen@linux-intel.com,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	brijesh.singh@amd.com, Thomas.Lendacky@amd.com
Subject: Re: [PATCH v2] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.
Date: Wed, 24 Jun 2020 17:11:32 -0400	[thread overview]
Message-ID: <20200624211132.GB14137@char.us.oracle.com> (raw)
In-Reply-To: <20200624070509.GA13381@ashkalra_ubuntu_server>

.snip..
> > Actually as per the boot flow :
> > 
> > setup_arch() calls reserve_crashkernel() and pci_iommu_alloc() is
> > invoked through mm_init()/mem_init() and not via initmem_init().
> > 
> > start_kernel:
> > ...
> > setup_arch()
> > 	reserve_crashkernel
> > 		reserve_crashkernel_low
> > 			-> swiotlb_size_or_default
> > 
> > ...
> > ...
> > mm_init()
> > 	mem_init()
> > 		pci_iommu_alloc
> > 			-> pci_swiotlb_detect_4gb
> > 			-> swiotlb_init
> > 
> > So as per the above boot flow, reserve_crashkernel() can get called
> > before swiotlb_detect/init, and hence, if we don't fixup or adjust
> > the SWIOTLB buffer size in swiotlb_size_or_default() then crash kernel
> > will reserve memory which will conflict/overlap with any SWIOTLB bounce
> > buffer allocated memory (adjusted or fixed up later).
> > 
> > Therefore, we need to adjust/fixup SWIOTLB bounce buffer memory in
> > swiotlb_size_or_default() function itself, before swiotlb detect/init
> > funtions get invoked.
> > 
> 
> Also to add here, it looks like swiotlb_size_or_default() is an
> interface function to get the SWIOTLB bounce buffer size for components
> which are initialized before swiotlb_detect/init, so that these 
> components can reserve or allocate their memory requirements with the
> knowledge of how much SWIOTLB bounce buffers are going to use, so
> therefore, any fixups or adjustments to SWIOTLB buffer size will need
> to be made as part of swiotlb_size_or_default(). 

That was never its purpose. It was meant as way to figure out the segment
size for DMA requests and to be used for runtime components. In fact to
be idempotent.

This is why I am disliking this usage and leaning towards something else.

But you pointed out something interesting - you are in fact needing to
adjust the size of the swiotlb based on your needs at bootup. Not any different
from say 'swiotlb' paramter.

Why not have an 'swiotlb_adjust' that is an __init that modifies the
internal swiotlb buffer sizes? Obviously we have to account for 'swiotlb'
parsing as well. The swiotlb_adjust would pick the max from those.


WARNING: multiple messages have this Message-ID (diff)
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Ashish Kalra <ashish.kalra@amd.com>
Cc: Thomas.Lendacky@amd.com, brijesh.singh@amd.com,
	dave.hansen@linux-intel.com, peterz@infradead.org,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	iommu@lists.linux-foundation.org, mingo@redhat.com, bp@alien8.de,
	luto@kernel.org, hpa@zytor.com,
	Konrad Rzeszutek Wilk <konrad@darnok.org>,
	tglx@linutronix.de, hch@lst.de
Subject: Re: [PATCH v2] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.
Date: Wed, 24 Jun 2020 17:11:32 -0400	[thread overview]
Message-ID: <20200624211132.GB14137@char.us.oracle.com> (raw)
In-Reply-To: <20200624070509.GA13381@ashkalra_ubuntu_server>

.snip..
> > Actually as per the boot flow :
> > 
> > setup_arch() calls reserve_crashkernel() and pci_iommu_alloc() is
> > invoked through mm_init()/mem_init() and not via initmem_init().
> > 
> > start_kernel:
> > ...
> > setup_arch()
> > 	reserve_crashkernel
> > 		reserve_crashkernel_low
> > 			-> swiotlb_size_or_default
> > 
> > ...
> > ...
> > mm_init()
> > 	mem_init()
> > 		pci_iommu_alloc
> > 			-> pci_swiotlb_detect_4gb
> > 			-> swiotlb_init
> > 
> > So as per the above boot flow, reserve_crashkernel() can get called
> > before swiotlb_detect/init, and hence, if we don't fixup or adjust
> > the SWIOTLB buffer size in swiotlb_size_or_default() then crash kernel
> > will reserve memory which will conflict/overlap with any SWIOTLB bounce
> > buffer allocated memory (adjusted or fixed up later).
> > 
> > Therefore, we need to adjust/fixup SWIOTLB bounce buffer memory in
> > swiotlb_size_or_default() function itself, before swiotlb detect/init
> > funtions get invoked.
> > 
> 
> Also to add here, it looks like swiotlb_size_or_default() is an
> interface function to get the SWIOTLB bounce buffer size for components
> which are initialized before swiotlb_detect/init, so that these 
> components can reserve or allocate their memory requirements with the
> knowledge of how much SWIOTLB bounce buffers are going to use, so
> therefore, any fixups or adjustments to SWIOTLB buffer size will need
> to be made as part of swiotlb_size_or_default(). 

That was never its purpose. It was meant as way to figure out the segment
size for DMA requests and to be used for runtime components. In fact to
be idempotent.

This is why I am disliking this usage and leaning towards something else.

But you pointed out something interesting - you are in fact needing to
adjust the size of the swiotlb based on your needs at bootup. Not any different
from say 'swiotlb' paramter.

Why not have an 'swiotlb_adjust' that is an __init that modifies the
internal swiotlb buffer sizes? Obviously we have to account for 'swiotlb'
parsing as well. The swiotlb_adjust would pick the max from those.

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2020-06-24 21:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 23:13 [PATCH v2] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests Ashish Kalra
2019-12-09 23:13 ` Ashish Kalra
2019-12-20  1:52 ` Konrad Rzeszutek Wilk
2019-12-20  1:52   ` Konrad Rzeszutek Wilk
2020-01-21 20:09   ` Ashish Kalra
2020-01-21 20:09     ` Ashish Kalra
2020-01-21 20:54     ` Konrad Rzeszutek Wilk
2020-01-21 20:54       ` Konrad Rzeszutek Wilk
2020-01-24 23:00       ` Ashish Kalra
2020-01-24 23:00         ` Ashish Kalra
2020-02-04 19:35         ` Ashish Kalra
2020-02-04 19:35           ` Ashish Kalra
2020-03-03 17:03           ` Konrad Rzeszutek Wilk
2020-03-03 17:03             ` Konrad Rzeszutek Wilk
2020-03-12  0:43             ` Ashish Kalra
2020-03-12  0:43               ` Ashish Kalra
2020-03-30 22:25             ` Ashish Kalra
2020-03-30 22:25               ` Ashish Kalra
2020-04-27 18:53               ` Ashish Kalra
2020-04-27 18:53                 ` Ashish Kalra
2020-06-23 13:38                 ` Konrad Rzeszutek Wilk
2020-06-23 13:38                   ` Konrad Rzeszutek Wilk
2020-06-24  0:23                   ` Ashish Kalra
2020-06-24  0:23                     ` Ashish Kalra
2020-06-24  7:05                     ` Ashish Kalra
2020-06-24  7:05                       ` Ashish Kalra
2020-06-24 21:11                       ` Konrad Rzeszutek Wilk [this message]
2020-06-24 21:11                         ` Konrad Rzeszutek Wilk

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=20200624211132.GB14137@char.us.oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=bp@alien8.de \
    --cc=brijesh.singh@amd.com \
    --cc=dave.hansen@linux-intel.com \
    --cc=hch@lst.de \
    --cc=hpa@zytor.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=konrad@darnok.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.