Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1672148 > unrolled thread
| Started by | Doug Berger <opendmb@gmail.com> |
|---|---|
| First post | 2017-06-22 01:30 +0200 |
| Last post | 2017-06-22 22:20 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/3] libata: prevent writes to read-only registers Doug Berger <opendmb@gmail.com> - 2017-06-22 01:30 +0200
[PATCH 1/3] libata: Add the AHCI_HFLAG_YES_ALPM flag Doug Berger <opendmb@gmail.com> - 2017-06-22 01:30 +0200
[PATCH 2/3] libata: Add the AHCI_HFLAG_NO_WRITE_TO_RO flag Doug Berger <opendmb@gmail.com> - 2017-06-22 01:30 +0200
Re: [PATCH 0/3] libata: prevent writes to read-only registers Tejun Heo <tj@kernel.org> - 2017-06-22 22:20 +0200
| From | Doug Berger <opendmb@gmail.com> |
|---|---|
| Date | 2017-06-22 01:30 +0200 |
| Subject | [PATCH 0/3] libata: prevent writes to read-only registers |
| Message-ID | <tUXep-4FF-9@gated-at.bofh.it> |
Recent Broadcom SoCs allow for the trapping of write accesses to read-only registers. This is only useful if such accesses are exceptional, so it is desirable to prevent such accesses in normal operation. To that end, this set of commits proposes adding two flags to the libata core. The first allows for a quirk that exists in some Broadcom devices that are capable of supporting Aggresive Link Power Management even though it is not reported by their read-only capability register. This removes a need for the Broadcom driver to write to it's read-only capability register. The second is a notification to the libata-core that it should not write to any standard registers that are defined to be read-only. The Broadcom driver is then modified to use these two general purpose flags. Doug Berger (3): libata: Add the AHCI_HFLAG_YES_ALPM flag libata: Add the AHCI_HFLAG_NO_WRITE_TO_RO flag ata: ahci_brcm: Avoid writing to read-only registers drivers/ata/ahci.h | 3 +++ drivers/ata/ahci_brcm.c | 12 ++++-------- drivers/ata/libahci.c | 8 +++++++- 3 files changed, 14 insertions(+), 9 deletions(-) -- 2.13.0
[toc] | [next] | [standalone]
| From | Doug Berger <opendmb@gmail.com> |
|---|---|
| Date | 2017-06-22 01:30 +0200 |
| Subject | [PATCH 1/3] libata: Add the AHCI_HFLAG_YES_ALPM flag |
| Message-ID | <tUXep-4FF-7@gated-at.bofh.it> |
| In reply to | #1672148 |
Some hardware is capable of supporting Aggresive Link Power Management
even though it is not indicated by the Host Capability register.
This commit adds the AHCI_HFLAG_YES_ALPM flag to the AHCI library to
allow indication of this quirk when the Host Capability register is
Read Only and therefore cannot be changed.
Signed-off-by: Doug Berger <opendmb@gmail.com>
---
drivers/ata/ahci.h | 1 +
drivers/ata/libahci.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 30f67a1a4f54..ee176e4af97a 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -248,6 +248,7 @@ enum {
AHCI_HFLAG_MULTI_MSI = 0,
#endif
AHCI_HFLAG_WAKE_BEFORE_STOP = (1 << 22), /* wake before DMA stop */
+ AHCI_HFLAG_YES_ALPM = (1 << 23), /* force ALPM cap on */
/* ap->flags bits */
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index b3a685ad9b87..4462f8a8cf2c 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -504,6 +504,11 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
cap &= ~HOST_CAP_FBS;
}
+ if (!(cap & HOST_CAP_ALPM) && (hpriv->flags & AHCI_HFLAG_YES_ALPM)) {
+ dev_info(dev, "controller can do ALPM, turning on CAP_ALPM\n");
+ cap |= HOST_CAP_ALPM;
+ }
+
if (hpriv->force_port_map && port_map != hpriv->force_port_map) {
dev_info(dev, "forcing port_map 0x%x -> 0x%x\n",
port_map, hpriv->force_port_map);
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Doug Berger <opendmb@gmail.com> |
|---|---|
| Date | 2017-06-22 01:30 +0200 |
| Subject | [PATCH 2/3] libata: Add the AHCI_HFLAG_NO_WRITE_TO_RO flag |
| Message-ID | <tUXep-4FF-13@gated-at.bofh.it> |
| In reply to | #1672148 |
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>
---
drivers/ata/ahci.h | 2 ++
drivers/ata/libahci.c | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index ee176e4af97a..8b61123d2c3c 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -249,6 +249,8 @@ enum {
#endif
AHCI_HFLAG_WAKE_BEFORE_STOP = (1 << 22), /* wake before DMA stop */
AHCI_HFLAG_YES_ALPM = (1 << 23), /* force ALPM cap on */
+ AHCI_HFLAG_NO_WRITE_TO_RO = (1 << 24), /* don't write to read
+ only registers */
/* ap->flags bits */
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 4462f8a8cf2c..3e286d86ab42 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -945,7 +945,8 @@ int ahci_reset_controller(struct ata_host *host)
/* Some registers might be cleared on reset. Restore
* initial values.
*/
- ahci_restore_initial_config(host);
+ if (!(hpriv->flags & AHCI_HFLAG_NO_WRITE_TO_RO))
+ ahci_restore_initial_config(host);
} else
dev_info(host->dev, "skipping global host reset\n");
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Date | 2017-06-22 22:20 +0200 |
| Message-ID | <tVgK5-10A-11@gated-at.bofh.it> |
| In reply to | #1672148 |
On Wed, Jun 21, 2017 at 04:20:11PM -0700, Doug Berger wrote: > Recent Broadcom SoCs allow for the trapping of write accesses to > read-only registers. This is only useful if such accesses are > exceptional, so it is desirable to prevent such accesses in normal > operation. To that end, this set of commits proposes adding two > flags to the libata core. > > The first allows for a quirk that exists in some Broadcom devices > that are capable of supporting Aggresive Link Power Management even > though it is not reported by their read-only capability register. > This removes a need for the Broadcom driver to write to it's > read-only capability register. > > The second is a notification to the libata-core that it should not > write to any standard registers that are defined to be read-only. > > The Broadcom driver is then modified to use these two general > purpose flags. Applied 1-3 to libata/for-4.13. Thanks. -- tejun
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web