diff options
author | Pankaj Raghav <pankydev8@gmail.com> | 2022-03-26 18:39:47 +0100 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-03-27 08:54:32 -0700 |
commit | 4b2094506b136be79430439fcb159cedc6d1ad17 (patch) | |
tree | b26a9f46e52705e9224d5083d91b3e8f7d38c070 /Kernel/Storage | |
parent | 4ecc695a65a062865d27271cbd58cdebe3fe6d9a (diff) | |
download | serenity-4b2094506b136be79430439fcb159cedc6d1ad17.zip |
Kernel: Use buffer_size from AsyncBlockDevice struct
The underlying driver does not need to recalculate the buffer size as
it is passed in the AsyncBlockDevice struct anyway. This also helps in
removing any assumptions of the underlying block size of the device.
Diffstat (limited to 'Kernel/Storage')
-rw-r--r-- | Kernel/Storage/ATA/BMIDEChannel.cpp | 8 | ||||
-rw-r--r-- | Kernel/Storage/NVMe/NVMeInterruptQueue.cpp | 2 | ||||
-rw-r--r-- | Kernel/Storage/NVMe/NVMePollQueue.cpp | 2 | ||||
-rw-r--r-- | Kernel/Storage/NVMe/NVMeQueue.cpp | 2 |
4 files changed, 7 insertions, 7 deletions
diff --git a/Kernel/Storage/ATA/BMIDEChannel.cpp b/Kernel/Storage/ATA/BMIDEChannel.cpp index b87b9c8854..f46251f53b 100644 --- a/Kernel/Storage/ATA/BMIDEChannel.cpp +++ b/Kernel/Storage/ATA/BMIDEChannel.cpp @@ -130,7 +130,7 @@ void BMIDEChannel::complete_current_request(AsyncDeviceRequest::RequestResult re if (result == AsyncDeviceRequest::Success) { if (current_request->request_type() == AsyncBlockDeviceRequest::Read) { - if (auto result = current_request->write_to_buffer(current_request->buffer(), m_dma_buffer_region->vaddr().as_ptr(), 512 * current_request->block_count()); result.is_error()) { + if (auto result = current_request->write_to_buffer(current_request->buffer(), m_dma_buffer_region->vaddr().as_ptr(), current_request->buffer_size()); result.is_error()) { lock.unlock(); current_request->complete(AsyncDeviceRequest::MemoryFault); return; @@ -157,9 +157,9 @@ void BMIDEChannel::ata_write_sectors(bool slave_request, u16 capabilities) dbgln_if(PATA_DEBUG, "BMIDEChannel::ata_write_sectors ({} x {})", m_current_request->block_index(), m_current_request->block_count()); prdt().offset = m_dma_buffer_page->paddr().get(); - prdt().size = 512 * m_current_request->block_count(); + prdt().size = m_current_request->buffer_size(); - if (auto result = m_current_request->read_from_buffer(m_current_request->buffer(), m_dma_buffer_region->vaddr().as_ptr(), 512 * m_current_request->block_count()); result.is_error()) { + if (auto result = m_current_request->read_from_buffer(m_current_request->buffer(), m_dma_buffer_region->vaddr().as_ptr(), m_current_request->buffer_size()); result.is_error()) { complete_current_request(AsyncDeviceRequest::MemoryFault); return; } @@ -210,7 +210,7 @@ void BMIDEChannel::ata_read_sectors(bool slave_request, u16 capabilities) IO::delay(10); prdt().offset = m_dma_buffer_page->paddr().get(); - prdt().size = 512 * m_current_request->block_count(); + prdt().size = m_current_request->buffer_size(); VERIFY(prdt().size <= PAGE_SIZE); diff --git a/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp b/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp index f3e5752c66..0cc00ccc08 100644 --- a/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp +++ b/Kernel/Storage/NVMe/NVMeInterruptQueue.cpp @@ -43,7 +43,7 @@ void NVMeInterruptQueue::complete_current_request(u16 status) return; } if (current_request->request_type() == AsyncBlockDeviceRequest::RequestType::Read) { - if (auto result = current_request->write_to_buffer(current_request->buffer(), m_rw_dma_region->vaddr().as_ptr(), 512 * current_request->block_count()); result.is_error()) { + if (auto result = current_request->write_to_buffer(current_request->buffer(), m_rw_dma_region->vaddr().as_ptr(), current_request->buffer_size()); result.is_error()) { lock.unlock(); current_request->complete(AsyncDeviceRequest::MemoryFault); return; diff --git a/Kernel/Storage/NVMe/NVMePollQueue.cpp b/Kernel/Storage/NVMe/NVMePollQueue.cpp index 8b1340a9b4..7219034666 100644 --- a/Kernel/Storage/NVMe/NVMePollQueue.cpp +++ b/Kernel/Storage/NVMe/NVMePollQueue.cpp @@ -33,7 +33,7 @@ void NVMePollQueue::complete_current_request(u16 status) return; } if (current_request->request_type() == AsyncBlockDeviceRequest::RequestType::Read) { - if (auto result = current_request->write_to_buffer(current_request->buffer(), m_rw_dma_region->vaddr().as_ptr(), 512 * current_request->block_count()); result.is_error()) { + if (auto result = current_request->write_to_buffer(current_request->buffer(), m_rw_dma_region->vaddr().as_ptr(), current_request->buffer_size()); result.is_error()) { current_request->complete(AsyncDeviceRequest::MemoryFault); return; } diff --git a/Kernel/Storage/NVMe/NVMeQueue.cpp b/Kernel/Storage/NVMe/NVMeQueue.cpp index cde68a0c9d..1892f6e6f8 100644 --- a/Kernel/Storage/NVMe/NVMeQueue.cpp +++ b/Kernel/Storage/NVMe/NVMeQueue.cpp @@ -157,7 +157,7 @@ void NVMeQueue::write(AsyncBlockDeviceRequest& request, u16 nsid, u64 index, u32 SpinlockLocker m_lock(m_request_lock); m_current_request = request; - if (auto result = m_current_request->read_from_buffer(m_current_request->buffer(), m_rw_dma_region->vaddr().as_ptr(), 512 * m_current_request->block_count()); result.is_error()) { + if (auto result = m_current_request->read_from_buffer(m_current_request->buffer(), m_rw_dma_region->vaddr().as_ptr(), m_current_request->buffer_size()); result.is_error()) { complete_current_request(AsyncDeviceRequest::MemoryFault); return; } |