The reverted patch isn't the best solution. I have updated another fix, and the 
built kernel image is here: 
https://drive.google.com/file/d/1GDjdyq14rG74vC-ge6UfbQg8FiifXyFP/view?usp=sharing
 
could you like to try it.
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index ac71ea4898b2..443b4008b4c5 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1973,12 +1973,28 @@ megasas_set_nvme_device_properties(struct scsi_device 
*sdev,
 {
        struct megasas_instance *instance;
        u32 mr_nvme_pg_size;
+       u32 max_prp, prp_per_page, max_prp_io_size;
 
        instance = (struct megasas_instance *)sdev->host->hostdata;
        mr_nvme_pg_size = max_t(u32, instance->nvme_page_size,
                                MR_DEFAULT_NVME_PAGE_SIZE);
 
-       lim->max_hw_sectors = max_io_size / 512;
+       /*
+        * The firmware reports the drive's MDTS, but PRP lists are built into
+        * the fixed-size per-command chain frame. That frame holds at most
+        * max_chain_frame_sz / sizeof(u64) entries, and megasas_make_prp_nvme()
+        * spends one entry per NVMe page as a next-list pointer whenever the
+        * list crosses a page boundary. An I/O larger than what the frame can
+        * describe makes that loop walk past the end of the frame and corrupt
+        * memory, so cap the transfer size at the frame's real PRP capacity.
+        */
+       max_prp = instance->max_chain_frame_sz / sizeof(u64);
+       prp_per_page = mr_nvme_pg_size / sizeof(u64);
+       if (prp_per_page > 1)
+               max_prp -= DIV_ROUND_UP(max_prp, prp_per_page);
+       max_prp_io_size = max_prp * mr_nvme_pg_size;
+
+       lim->max_hw_sectors = min(max_io_size, max_prp_io_size) >> SECTOR_SHIFT;
        lim->virt_boundary_mask = mr_nvme_pg_size - 1;
 }

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2148534

Title:
  [Ubuntu 26.04] Failed install OS onto JBOD disk on B540d-2HS M.2
  controller

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2148534/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to