[haiku-commits] haiku: hrev53946 - src/add-ons/kernel/drivers/disk/nvme

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 7 Mar 2020 17:18:42 -0500 (EST)

hrev53946 adds 3 changesets to branch 'master'
old head: d447d747817f39734bdabdd4ac5337a0db55dde3
new head: f87a7ab0f72e2bc0b93f66023fff39207c025c35
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=f87a7ab0f72e+%5Ed447d747817f

----------------------------------------------------------------------------

475c3b42e2bd: nvme_disk: Remove do_nvme_segmented_io.
  
  It appears that libnvme handles breaking up I/O operations already
  and submit them in a more organized fashion, so this is not needed.

0bf26bd17eb3: nvme_disk: Poll before checking the "status" again.
  
  Otherwise, we may have missed an interrupt and wind up in
  a dead-wait.

f87a7ab0f72e: nvme_disk: Add missing linebreaks in error messages.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

1 file changed, 8 insertions(+), 45 deletions(-)
.../kernel/drivers/disk/nvme/nvme_disk.cpp       | 53 +++-----------------

############################################################################

Commit:      475c3b42e2bdc31df1cf9c77e5952cc62ed4add3
URL:         https://git.haiku-os.org/haiku/commit/?id=475c3b42e2bd
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Mar  7 22:16:34 2020 UTC

nvme_disk: Remove do_nvme_segmented_io.

It appears that libnvme handles breaking up I/O operations already
and submit them in a more organized fashion, so this is not needed.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp 
b/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
index c0d88b038f..f900588ad5 100644
--- a/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
+++ b/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
@@ -83,7 +83,6 @@ typedef struct {
        struct nvme_ns*                 ns;
        uint64                                  capacity;
        uint32                                  block_size;
-       size_t                                  max_transfer_size;
        status_t                                media_status;
 
        struct qpair_info {
@@ -225,8 +224,6 @@ nvme_disk_init_device(void* _info, void** _cookie)
 
        // store capacity information
        nvme_disk_set_capacity(info, nsstat.sectors, nsstat.sector_size);
-       info->max_transfer_size = ROUNDDOWN(cstat.max_xfer_size,
-               nsstat.sector_size);
 
        TRACE("capacity: %" B_PRIu64 ", block_size %" B_PRIu32 "\n",
                info->capacity, info->block_size);
@@ -438,42 +435,6 @@ do_nvme_io(nvme_disk_driver_info* info, off_t rounded_pos, 
void* buffer,
 }
 
 
-static status_t
-do_nvme_segmented_io(nvme_disk_driver_info* info, off_t rounded_pos,
-       void* buffer, size_t* rounded_len, bool write = false)
-{
-       // The max transfer size is already a multiple of the block size,
-       // so divide and iterate appropriately. In the case where the length
-       // is less than the maximum transfer size, we'll wind up with 0 in the
-       // division, and only one transfer to take care of.
-       const size_t max_xfer = info->max_transfer_size;
-       int32 transfers = *rounded_len / max_xfer;
-       if ((*rounded_len % max_xfer) != 0)
-               transfers++;
-
-       size_t transferred = 0;
-       for (int32 i = 0; i < transfers; i++) {
-               size_t transfer_len = max_xfer;
-               // The last transfer will usually be smaller.
-               if (i == (transfers - 1))
-                       transfer_len = *rounded_len - transferred;
-
-               status_t status = do_nvme_io(info, rounded_pos, buffer,
-                       &transfer_len, write);
-               if (status != B_OK) {
-                       *rounded_len = transferred;
-                       return transferred > 0 ? (write ? B_PARTIAL_WRITE : 
B_PARTIAL_READ)
-                               : status;
-               }
-
-               transferred += transfer_len;
-               rounded_pos += transfer_len;
-               buffer = ((int8*)buffer) + transfer_len;
-       }
-       return B_OK;
-}
-
-
 static status_t
 nvme_disk_read(void* cookie, off_t pos, void* buffer, size_t* length)
 {
@@ -494,7 +455,7 @@ nvme_disk_read(void* cookie, off_t pos, void* buffer, 
size_t* length)
                        return B_NO_MEMORY;
                }
 
-               status_t status = do_nvme_segmented_io(handle->info, 
rounded_pos,
+               status_t status = do_nvme_io(handle->info, rounded_pos,
                        bounceBuffer, &rounded_len);
                if (status != B_OK) {
                        // The "rounded_len" will be the actual transferred 
length, but
@@ -515,7 +476,7 @@ nvme_disk_read(void* cookie, off_t pos, void* buffer, 
size_t* length)
 
        // If we got here, that means the arguments are already rounded to LBAs
        // and the buffer is a kernel one, so just do the I/O directly.
-       return do_nvme_segmented_io(handle->info, pos, buffer, length);
+       return do_nvme_io(handle->info, pos, buffer, length);
 }
 
 
@@ -571,7 +532,7 @@ nvme_disk_write(void* cookie, off_t pos, const void* 
buffer, size_t* length)
                        return status;
                }
 
-               status = do_nvme_segmented_io(handle->info, rounded_pos, 
bounceBuffer,
+               status = do_nvme_io(handle->info, rounded_pos, bounceBuffer,
                        &rounded_len, true);
                if (status != B_OK) {
                        *length = std::min(*length, (size_t)std::max((off_t)0,
@@ -582,7 +543,7 @@ nvme_disk_write(void* cookie, off_t pos, const void* 
buffer, size_t* length)
 
        // If we got here, that means the arguments are already rounded to LBAs,
        // so just do the I/O directly.
-       return do_nvme_segmented_io(handle->info, pos, (void*)buffer, length, 
true);
+       return do_nvme_io(handle->info, pos, (void*)buffer, length, true);
 }
 
 

############################################################################

Commit:      0bf26bd17eb3b271280a7c2c6cc4d2bb5376ee36
URL:         https://git.haiku-os.org/haiku/commit/?id=0bf26bd17eb3
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Mar  7 22:17:28 2020 UTC

nvme_disk: Poll before checking the "status" again.

Otherwise, we may have missed an interrupt and wind up in
a dead-wait.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp 
b/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
index f900588ad5..7ade5ae993 100644
--- a/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
+++ b/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
@@ -387,6 +387,8 @@ await_status(nvme_disk_driver_info* info, struct 
nvme_qpair* qpair, status_t& st
        while (status == EINPROGRESS) {
                info->interrupt.Add(&entry);
 
+               nvme_ioqp_poll(qpair, 0);
+
                if (status != EINPROGRESS)
                        return;
 

############################################################################

Revision:    hrev53946
Commit:      f87a7ab0f72e2bc0b93f66023fff39207c025c35
URL:         https://git.haiku-os.org/haiku/commit/?id=f87a7ab0f72e
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Mar  7 22:18:16 2020 UTC

nvme_disk: Add missing linebreaks in error messages.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp 
b/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
index 7ade5ae993..6be08e6e74 100644
--- a/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
+++ b/src/add-ons/kernel/drivers/disk/nvme/nvme_disk.cpp
@@ -422,14 +422,14 @@ do_nvme_io(nvme_disk_driver_info* info, off_t 
rounded_pos, void* buffer,
        mutex_unlock(&qpinfo->mtx);
        if (ret != 0) {
                TRACE_ERROR("attempt to queue %s I/O at %" B_PRIdOFF " of %" 
B_PRIuSIZE
-                       " bytes failed!", write ? "write" : "read", 
rounded_pos, *rounded_len);
+                       " bytes failed!\n", write ? "write" : "read", 
rounded_pos, *rounded_len);
                return ret;
        }
 
        await_status(info, qpinfo->qpair, status);
 
        if (status != B_OK) {
-               TRACE_ERROR("%s at %" B_PRIdOFF " of %" B_PRIuSIZE " bytes 
failed!",
+               TRACE_ERROR("%s at %" B_PRIdOFF " of %" B_PRIuSIZE " bytes 
failed!\n",
                        write ? "write" : "read", rounded_pos, *rounded_len);
                *rounded_len = 0;
        }


Other related posts:

  • » [haiku-commits] haiku: hrev53946 - src/add-ons/kernel/drivers/disk/nvme - waddlesplash