Ticket #1784: scsinvme.cpp-sntasmedia-nvme_admin_get_log_page-fix.patch

File scsinvme.cpp-sntasmedia-nvme_admin_get_log_page-fix.patch, 2.2 KB (added by cyrozap, 5 months ago)
  • smartmontools/ChangeLog

    diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog
    index a7525366..c53e847e 100644
    a b  
    11$Id$
    22
     32023-12-21  cyrozap  <cyrozap@gmail.com>
     4
     5        scsinvme.cpp: Fix sntasmedia "Get Log Page" passthrough
     6
    372023-12-19  Christian Franke  <franke@computer.org>
    48
    59        os_win32/update-smart-drivedb.ps1.in: Fix call of external commands.
  • smartmontools/scsinvme.cpp

    diff --git a/smartmontools/scsinvme.cpp b/smartmontools/scsinvme.cpp
    index f4fda25f..10f8eec3 100644
    a b bool sntasmedia_device::nvme_pass_through(const nvme_cmd_in & in, nvme_cmd_out &  
    7272    case smartmontools::nvme_admin_get_log_page:
    7373      if (!(in.nsid == 0xffffffff || !in.nsid))
    7474        return set_err(ENOSYS, "NVMe Get Log Page with NSID=0x%x not supported", in.nsid);
    75       if (size > 0x200) { // Reading more results in command timeout
    76         // TODO: Add ability to return short reads to caller
    77         size = 0x200;
    78         cdw10_hi = (size / 4) - 1;
    79         pout("Warning: NVMe Get Log truncated to 0x%03x bytes, 0x%03x bytes zero filled\n", size, in.size - size);
    80       }
    8175      break;
    8276    default:
    8377      return set_err(ENOSYS, "NVMe admin command 0x%02x not supported", in.opcode);
    8478    break;
    8579  }
    86   if (in.cdw11 || in.cdw12 || in.cdw13 || in.cdw14 || in.cdw15)
    87     return set_err(ENOSYS, "Nonzero NVMe command dwords 11-15 not supported");
     80  if (in.cdw11 || in.cdw14 || in.cdw15)
     81    return set_err(ENOSYS, "Nonzero NVMe command dwords 11, 14, or 15 not supported");
    8882
    8983  uint8_t cdb[16] = {0, };
    9084  cdb[0] = 0xe6;
    9185  cdb[1] = in.opcode;
    92   //cdb[2] = ?
     86  //cdb[2] = 0
    9387  cdb[3] = (uint8_t)in.cdw10;
    94   //cdb[4..6] = ?
     88  //cdb[4..5] = 0
     89  cdb[6] = (uint8_t)(cdw10_hi >> 8);
    9590  cdb[7] = (uint8_t)cdw10_hi;
    96   //cdb[8..15] = ?
     91  cdb[8] = (uint8_t)(in.cdw13 >> 24);
     92  cdb[9] = (uint8_t)(in.cdw13 >> 16);
     93  cdb[10] = (uint8_t)(in.cdw13 >> 8);
     94  cdb[11] = (uint8_t)in.cdw13;
     95  cdb[12] = (uint8_t)(in.cdw12 >> 24);
     96  cdb[13] = (uint8_t)(in.cdw12 >> 16);
     97  cdb[14] = (uint8_t)(in.cdw12 >> 8);
     98  cdb[15] = (uint8_t)in.cdw12;
    9799
    98100  scsi_cmnd_io io_hdr = {};
    99101  io_hdr.cmnd = cdb;