On Tue, Aug 23, 2016 at 5:37 AM, Tom Yan <tom.ty89@xxxxxxxxx> wrote: > On 22 August 2016 at 04:23, Shaun Tancheff <shaun@xxxxxxxxxxxx> wrote: >> +/** >> + * ata_format_dsm_trim_descr() - SATL Write Same to ATA SCT Write Same >> + * @cmd: SCSI command being translated >> + * @lba: Starting sector >> + * @num: Number of logical sectors to be zero'd. >> + * >> + * Rewrite the WRITE SAME descriptor to be an SCT Write Same formatted >> + * descriptor. >> + * NOTE: Writes a pattern (0's) in the foreground. >> + * Large write-same requents can timeout. >> + */ >> +static void ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num) >> +{ >> + u16 *sctpg; >> + unsigned long flags; >> + >> + spin_lock_irqsave(&ata_scsi_rbuf_lock, flags); >> + sctpg = ((void *)ata_scsi_rbuf); > > Because ata_scsi_rbuf is of a fixed size of ATA_SCSI_RBUF_SIZE. > > #define ATA_SCSI_RBUF_SIZE 4096 > ... > static u8 ata_scsi_rbuf[ATA_SCSI_RBUF_SIZE]; > >> + >> + put_unaligned_le16(0x0002, &sctpg[0]); /* SCT_ACT_WRITE_SAME */ >> + put_unaligned_le16(0x0101, &sctpg[1]); /* WRITE PTRN FG */ >> + put_unaligned_le64(lba, &sctpg[2]); >> + put_unaligned_le64(num, &sctpg[6]); >> + put_unaligned_le32(0u, &sctpg[10]); >> + >> + sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), sctpg, 512); > > You have no reason to use 512 here instead of ATA_SCSI_RBUF_SIZE this time. Ah .. because SCT Write Same is a fixed 512 byte transfer? Ah .. because I only have 512 bytes to copy? >> + spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags); >> +} -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html