From dabc6dd962f44a6d4ec6b86bce4dfc76328aa6fd Mon Sep 17 00:00:00 2001 From: Pankaj Raghav Date: Wed, 17 May 2023 20:21:00 +0200 Subject: [PATCH] Kernel/ScatterGatherList: Add region_name as a part of try_create API Remove the hardcoded "AHCI Scattered DMA" for region name as it is a part of a common API. Add region_name parameter to the try_create API so that this API can be used by other drivers with the correct Memory region name. --- Kernel/Memory/ScatterGatherList.cpp | 4 ++-- Kernel/Memory/ScatterGatherList.h | 2 +- Kernel/Storage/ATA/AHCI/Port.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Kernel/Memory/ScatterGatherList.cpp b/Kernel/Memory/ScatterGatherList.cpp index d4ff52d692..9a97f43989 100644 --- a/Kernel/Memory/ScatterGatherList.cpp +++ b/Kernel/Memory/ScatterGatherList.cpp @@ -8,11 +8,11 @@ namespace Kernel::Memory { -ErrorOr> ScatterGatherList::try_create(AsyncBlockDeviceRequest& request, Span> allocated_pages, size_t device_block_size) +ErrorOr> ScatterGatherList::try_create(AsyncBlockDeviceRequest& request, Span> allocated_pages, size_t device_block_size, StringView region_name) { auto vm_object = TRY(AnonymousVMObject::try_create_with_physical_pages(allocated_pages)); auto size = TRY(page_round_up((request.block_count() * device_block_size))); - auto region = TRY(MM.allocate_kernel_region_with_vmobject(vm_object, size, "AHCI Scattered DMA"sv, Region::Access::Read | Region::Access::Write, Region::Cacheable::Yes)); + auto region = TRY(MM.allocate_kernel_region_with_vmobject(vm_object, size, region_name, Region::Access::Read | Region::Access::Write, Region::Cacheable::Yes)); return adopt_lock_ref_if_nonnull(new (nothrow) ScatterGatherList(vm_object, move(region))); } diff --git a/Kernel/Memory/ScatterGatherList.h b/Kernel/Memory/ScatterGatherList.h index fb8fe49b7c..2f6fb18533 100644 --- a/Kernel/Memory/ScatterGatherList.h +++ b/Kernel/Memory/ScatterGatherList.h @@ -19,7 +19,7 @@ namespace Kernel::Memory { class ScatterGatherList final : public AtomicRefCounted { public: - static ErrorOr> try_create(AsyncBlockDeviceRequest&, Span> allocated_pages, size_t device_block_size); + static ErrorOr> try_create(AsyncBlockDeviceRequest&, Span> allocated_pages, size_t device_block_size, StringView region_name); VMObject const& vmobject() const { return m_vm_object; } VirtualAddress dma_region() const { return m_dma_region->vaddr(); } size_t scatters_count() const { return m_vm_object->physical_pages().size(); } diff --git a/Kernel/Storage/ATA/AHCI/Port.cpp b/Kernel/Storage/ATA/AHCI/Port.cpp index c6b55c9cd3..6497820a0f 100644 --- a/Kernel/Storage/ATA/AHCI/Port.cpp +++ b/Kernel/Storage/ATA/AHCI/Port.cpp @@ -429,7 +429,7 @@ Optional AHCIPort::prepare_and_set_scatter_li allocated_dma_regions.append(m_dma_buffers.at(index)); } - m_current_scatter_list = Memory::ScatterGatherList::try_create(request, allocated_dma_regions.span(), m_connected_device->block_size()).release_value_but_fixme_should_propagate_errors(); + m_current_scatter_list = Memory::ScatterGatherList::try_create(request, allocated_dma_regions.span(), m_connected_device->block_size(), "AHCI Scattered DMA"sv).release_value_but_fixme_should_propagate_errors(); if (!m_current_scatter_list) return AsyncDeviceRequest::Failure; if (request.request_type() == AsyncBlockDeviceRequest::Write) {