[Pdbg] [PATCH 1/3] target: Cache pib addresses
Joel Stanley
joel at jms.id.au
Tue May 22 16:06:26 AEST 2018
From: Benjamin Herrenschmidt <benh at kernel.crashing.org>
Avoids walking the tree for every xscom access
Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
Signed-off-by: Joel Stanley <joel at jms.id.au>
---
libpdbg/target.c | 30 +++++++++++++++++++++---------
libpdbg/target.h | 4 ++++
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/libpdbg/target.c b/libpdbg/target.c
index bcf4bb9b69bc..2050f273182a 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -109,13 +109,25 @@ static int pib_indirect_write(struct pib *pib, uint64_t addr, uint64_t data)
return 0;
}
-int pib_read(struct pdbg_target *pib_dt, uint64_t addr, uint64_t *data)
+static inline struct pib *check_update_pib_cache(struct pdbg_target *tgt_dt)
+{
+ struct pdbg_target *pib_dt;
+
+ if (tgt_dt->pib)
+ return tgt_dt->pib;
+ tgt_dt->pib_addr = 0;
+ pib_dt = get_class_target_addr(tgt_dt, "pib", &tgt_dt->pib_addr);
+ tgt_dt->pib = target_to_pib(pib_dt);
+ return tgt_dt->pib;
+}
+
+int pib_read(struct pdbg_target *tgt_dt, uint64_t addr, uint64_t *data)
{
struct pib *pib;
int rc;
- pib_dt = get_class_target_addr(pib_dt, "pib", &addr);
- pib = target_to_pib(pib_dt);
+ pib = check_update_pib_cache(tgt_dt);
+ addr += tgt_dt->pib_addr;
if (addr & PPC_BIT(0))
rc = pib_indirect_read(pib, addr, data);
else
@@ -123,13 +135,13 @@ int pib_read(struct pdbg_target *pib_dt, uint64_t addr, uint64_t *data)
return rc;
}
-int pib_write(struct pdbg_target *pib_dt, uint64_t addr, uint64_t data)
+int pib_write(struct pdbg_target *tgt_dt, uint64_t addr, uint64_t data)
{
struct pib *pib;
int rc;
- pib_dt = get_class_target_addr(pib_dt, "pib", &addr);
- pib = target_to_pib(pib_dt);
+ pib = check_update_pib_cache(tgt_dt);
+ addr += tgt_dt->pib_addr;
if (addr & PPC_BIT(0))
rc = pib_indirect_write(pib, addr, data);
else
@@ -138,14 +150,14 @@ int pib_write(struct pdbg_target *pib_dt, uint64_t addr, uint64_t data)
}
/* Wait for a SCOM register addr to match value & mask == data */
-int pib_wait(struct pdbg_target *pib_dt, uint64_t addr, uint64_t mask, uint64_t data)
+int pib_wait(struct pdbg_target *tgt_dt, uint64_t addr, uint64_t mask, uint64_t data)
{
struct pib *pib;
uint64_t tmp;
int rc;
- pib_dt = get_class_target_addr(pib_dt, "pib", &addr);
- pib = target_to_pib(pib_dt);
+ pib = check_update_pib_cache(tgt_dt);
+ addr += tgt_dt->pib_addr;
do {
if (addr & PPC_BIT(0))
diff --git a/libpdbg/target.h b/libpdbg/target.h
index 5541729983b0..db420c742ae5 100644
--- a/libpdbg/target.h
+++ b/libpdbg/target.h
@@ -49,6 +49,10 @@ struct pdbg_target {
bool probed;
struct list_node class_link;
void *priv;
+
+ /* Cache for most common targets */
+ struct pib *pib;
+ u64 pib_addr;
};
struct pdbg_target *require_target_parent(struct pdbg_target *target);
--
2.17.0
More information about the Pdbg
mailing list