Skip to contentSkip to conversation

libata: align ap->sector_buf

PATCH New Tejun Heo 1 participant 2 messages Mar 2, 2009 libata

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/2 libata: align ap->sector_buf

ap->sector_buf is used as DMA target and should at least be aligned on cacheline. This caused problems on some embedded machines.

---
 include/linux/libata.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/libata.h +2 -1
index c82695d..4234973 100644
@@ -750,7 +750,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 */
+	u8			sector_buf[ATA_SECT_SIZE] ____cacheline_aligned;
 };
 
 /* The following initializer overrides a method to NULL whether one of
author
#1 lore raw

PATCH 2/2 libata: don't use on-stack sense buffer

sense_buffer is used as DMA target and shouldn't be allocated on stack. Use ap->sector_buf instead. This problem is spotted by Chuck Ebbert.

---
 drivers/ata/libata-eh.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-eh.c +1 -1
index ce2ef04..009ccc7 100644
@@ -2901,7 +2901,7 @@ static int atapi_eh_clear_ua(struct ata_device *dev)
 	int i;
 
 	for (i = 0; i < ATA_EH_UA_TRIES; i++) {
-		u8 sense_buffer[SCSI_SENSE_BUFFERSIZE];
+		u8 *sense_buffer = dev->link->ap->sector_buf;
 		u8 sense_key = 0;
 		unsigned int err_mask;