[PW_SID:1157817] dma: swiotlb: Centralize default pool policy and sizing - #2590
Open
linux-riscv-bot wants to merge 4 commits into
Open
[PW_SID:1157817] dma: swiotlb: Centralize default pool policy and sizing#2590linux-riscv-bot wants to merge 4 commits into
linux-riscv-bot wants to merge 4 commits into
Conversation
The addressing_limited argument to swiotlb_init() describes only one reason for allocating a default SWIOTLB pool. A pool may also be needed for memory encryption, unaligned kmalloc bouncing, or swiotlb=force. Replace the boolean argument with the SWIOTLB_INIT_ADDRESSING_LIMIT flag and have architectures report their DMA addressing constraints through the initialization flags. Introduce SWIOTLB pool policies and select the policy in the core before allocating the default pool. This separates the decision to allocate a pool from the policy used to size it, allowing subsequent changes to centralize minimal and confidential-guest sizing. Set the shared-pool state before memory attributes are updated. Also move the pseries secure-guest setup before swiotlb_init() so its initialization flags are available when the policy is selected. Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
A default SWIOTLB pool used only for unaligned kmalloc bouncing can be smaller than one required for limited DMA addressing. Arm64 and RISC-V currently implement this sizing independently, using 1 MiB of SWIOTLB space per GiB of RAM. The SWIOTLB core now identifies this case with SWIOTLB_POOL_MINIMAL. Size that policy in swiotlb_adjust_pool_size() and remove the architecture-specific adjustments. Explicit swiotlb= sizing remains unchanged because swiotlb_adjust_size() preserves a user-configured size. NOTE: We lose the RISC-V SWIOTLB_ANY setting in this patch. It will be reinstated in a follow-up patch where we make SWIOTLB_ANY redundant. Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Memory-encrypted guests use shared or unencrypted memory for DMA and may route all DMA through SWIOTLB. The default pool can therefore be too small for I/O-intensive workloads. Move the existing x86 guest-sizing policy into the SWIOTLB core. For SWIOTLB_POOL_CC_GUEST, size the pool to 6% of guest memory, clamped between the normal default and 1 GiB. Preserve an explicit swiotlb= size. Provide swiotlb_adjusted_size() so early users, including the x86 crash kernel reservation, can account for the prospective guest pool size before SWIOTLB initialization. Use the same area-aware alignment for both the prospective and allocated sizes. Host memory encryption still selects a normal-sized shared pool and does not use the guest-sizing policy. A restricted DMA pool already provides shared bounce buffers for its devices. Record its presence during reserved-memory initialization and do not select the confidential-guest default-pool policy solely because guest memory encryption is active. Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
SWIOTLB_ANY permits the swiotlb pool to be allocated outside the architecture's low address limit. This is already implied when SWIOTLB_INIT_ADDRESSING_LIMIT is not set, making SWIOTLB_ANY redundant. Use SWIOTLB_INIT_ADDRESSING_LIMIT as the sole indication that the default pool and any dynamically allocated pools must reside below ARCH_LOW_ADDRESS_LIMIT. Otherwise, allow the pools to use any directly mapped memory. Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR for series 1157817 applied to workflow__riscv__fixes
Name: dma: swiotlb: Centralize default pool policy and sizing
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1157817
Version: 3