Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libata: Add the AHCI_HFLAG_NO_WRITE_TO_RO flag

While most hardware will simply ignore a write to a read-only register,
some hardware will signal an abort if this occurs.

This commit introduces the flag AHCI_HFLAG_NO_WRITE_TO_RO to prevent the
AHCI library from attempting to write to the HOST_CAP, HOST_CAP2, and
HOST_PORTS_IMPL registers which may be read-only.

Signed-off-by: Doug Berger <opendmb@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Doug Berger and committed by
Tejun Heo
7fab72f8 ef0da1bf

+4 -1
+2
drivers/ata/ahci.h
··· 249 249 #endif 250 250 AHCI_HFLAG_WAKE_BEFORE_STOP = (1 << 22), /* wake before DMA stop */ 251 251 AHCI_HFLAG_YES_ALPM = (1 << 23), /* force ALPM cap on */ 252 + AHCI_HFLAG_NO_WRITE_TO_RO = (1 << 24), /* don't write to read 253 + only registers */ 252 254 253 255 /* ap->flags bits */ 254 256
+2 -1
drivers/ata/libahci.c
··· 945 945 /* Some registers might be cleared on reset. Restore 946 946 * initial values. 947 947 */ 948 - ahci_restore_initial_config(host); 948 + if (!(hpriv->flags & AHCI_HFLAG_NO_WRITE_TO_RO)) 949 + ahci_restore_initial_config(host); 949 950 } else 950 951 dev_info(host->dev, "skipping global host reset\n"); 951 952