[PATCH] libata: align ap->sector_buf to cacheline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ap->sector_buf is used as DMA target and misalignment can cause data
corruption on non-coherent architectures.  This problem is spotted and
initial patch is submitted by Mark Mason.

Signed-off-by: Tejun Heo <htejun@xxxxxxxxx>
Cc: Mark Mason <mason@xxxxxxxxxxxxxxxx>
---
I thought about it more and marking up with ___cacheline_aligned seems
to be the right thing to do.  For older ones where ata_port is
allocated as part of scsi_host, I think what should be done is to
align private area of scsi_host to cacheline.  Will post another patch
for that.

Thanks.

 include/linux/libata.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
diff --git a/include/linux/libata.h b/include/linux/libata.h
index bc5a8d0..7604763 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -671,7 +671,8 @@ struct ata_port {
 	acpi_handle		acpi_handle;
 	struct ata_acpi_gtm	__acpi_init_gtm; /* use ata_acpi_init_gtm() */
 #endif
-	u8			sector_buf[ATA_SECT_SIZE]; /* owned by EH */
+	/* owned by EH, must be cache line aligned as it's used as DMA target */
+	u8			sector_buf[ATA_SECT_SIZE] ____cacheline_aligned;
 };
 
 struct ata_port_operations {
-
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

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux