Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 339545
b: refs/heads/master
c: 0daa034
h: refs/heads/master
i:
  339543: 5f548c9
v: v3
  • Loading branch information
Will Deacon committed Nov 9, 2012
1 parent d6696f9 commit d178703
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5ad29ea24e58777aa1daaa2255670ffb40aefd99
refs/heads/master: 0daa034e696ac601061cbf60fda41ad39678ae14
28 changes: 15 additions & 13 deletions trunk/arch/arm/kernel/hw_breakpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ static int get_num_brps(void)
* be put into halting debug mode at any time by an external debugger
* but there is nothing we can do to prevent that.
*/
static int monitor_mode_enabled(void)
{
u32 dscr;
ARM_DBG_READ(c1, 0, dscr);
return !!(dscr & ARM_DSCR_MDBGEN);
}

static int enable_monitor_mode(void)
{
u32 dscr;
Expand Down Expand Up @@ -321,14 +328,9 @@ int arch_install_hw_breakpoint(struct perf_event *bp)
{
struct arch_hw_breakpoint *info = counter_arch_bp(bp);
struct perf_event **slot, **slots;
int i, max_slots, ctrl_base, val_base, ret = 0;
int i, max_slots, ctrl_base, val_base;
u32 addr, ctrl;

/* Ensure that we are in monitor mode and halting mode is disabled. */
ret = enable_monitor_mode();
if (ret)
goto out;

addr = info->address;
ctrl = encode_ctrl_reg(info->ctrl) | 0x1;

Expand All @@ -355,10 +357,8 @@ int arch_install_hw_breakpoint(struct perf_event *bp)
}
}

if (WARN_ONCE(i == max_slots, "Can't find any breakpoint slot\n")) {
ret = -EBUSY;
goto out;
}
if (WARN_ONCE(i == max_slots, "Can't find any breakpoint slot\n"))
return -EBUSY;

/* Override the breakpoint data with the step data. */
if (info->step_ctrl.enabled) {
Expand All @@ -376,9 +376,7 @@ int arch_install_hw_breakpoint(struct perf_event *bp)

/* Setup the control register. */
write_wb_reg(ctrl_base + i, ctrl);

out:
return ret;
return 0;
}

void arch_uninstall_hw_breakpoint(struct perf_event *bp)
Expand Down Expand Up @@ -589,6 +587,10 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp)
int ret = 0;
u32 offset, alignment_mask = 0x3;

/* Ensure that we are in monitor debug mode. */
if (!monitor_mode_enabled())
return -ENODEV;

/* Build the arch_hw_breakpoint. */
ret = arch_build_bp_info(bp);
if (ret)
Expand Down

0 comments on commit d178703

Please sign in to comment.