mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	scsi: mpt3sas: Force request partial completion alignment
The firmware or device, possibly under a heavy I/O load, can return on a partial unaligned boundary. Scsi-ml expects these requests to be completed on an alignment boundary. Scsi-ml blindly requeues the I/O without checking the alignment boundary of the I/O request for the remaining bytes. This leads to errors, since devices cannot perform non-aligned read/write operations. This patch fixes the issue in the driver. It aligns unaligned completions of FS requests, by truncating them to the nearest alignment boundary. [mkp: simplified if statement] Reported-by: Mauricio Faria De Oliveira <mauricfo@linux.vnet.ibm.com> Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com> Signed-off-by: Ram Pai <linuxram@us.ibm.com> Acked-by: Sreekanth Reddy <Sreekanth.Reddy@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
		
							parent
							
								
									2780f3c8f0
								
							
						
					
					
						commit
						f2e767bb5d
					
				
					 1 changed files with 15 additions and 0 deletions
				
			
		| 
						 | 
					@ -4657,6 +4657,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
 | 
				
			||||||
	struct MPT3SAS_DEVICE *sas_device_priv_data;
 | 
						struct MPT3SAS_DEVICE *sas_device_priv_data;
 | 
				
			||||||
	u32 response_code = 0;
 | 
						u32 response_code = 0;
 | 
				
			||||||
	unsigned long flags;
 | 
						unsigned long flags;
 | 
				
			||||||
 | 
						unsigned int sector_sz;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
 | 
						mpi_reply = mpt3sas_base_get_reply_virt_addr(ioc, reply);
 | 
				
			||||||
	scmd = _scsih_scsi_lookup_get_clear(ioc, smid);
 | 
						scmd = _scsih_scsi_lookup_get_clear(ioc, smid);
 | 
				
			||||||
| 
						 | 
					@ -4715,6 +4716,20 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xfer_cnt = le32_to_cpu(mpi_reply->TransferCount);
 | 
						xfer_cnt = le32_to_cpu(mpi_reply->TransferCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* In case of bogus fw or device, we could end up having
 | 
				
			||||||
 | 
						 * unaligned partial completion. We can force alignment here,
 | 
				
			||||||
 | 
						 * then scsi-ml does not need to handle this misbehavior.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						sector_sz = scmd->device->sector_size;
 | 
				
			||||||
 | 
						if (unlikely(scmd->request->cmd_type == REQ_TYPE_FS && sector_sz &&
 | 
				
			||||||
 | 
							     xfer_cnt % sector_sz)) {
 | 
				
			||||||
 | 
							sdev_printk(KERN_INFO, scmd->device,
 | 
				
			||||||
 | 
							    "unaligned partial completion avoided (xfer_cnt=%u, sector_sz=%u)\n",
 | 
				
			||||||
 | 
								    xfer_cnt, sector_sz);
 | 
				
			||||||
 | 
							xfer_cnt = round_down(xfer_cnt, sector_sz);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt);
 | 
						scsi_set_resid(scmd, scsi_bufflen(scmd) - xfer_cnt);
 | 
				
			||||||
	if (ioc_status & MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE)
 | 
						if (ioc_status & MPI2_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE)
 | 
				
			||||||
		log_info =  le32_to_cpu(mpi_reply->IOCLogInfo);
 | 
							log_info =  le32_to_cpu(mpi_reply->IOCLogInfo);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue