[Pdbg] [PATCH 12/14] libpdbg/p9chip.c: ram allow ram to be used on running threads

Nicholas Piggin npiggin at gmail.com
Thu Apr 12 19:00:47 AEST 2018


On Thu, 12 Apr 2018 14:27:47 +1000
Alistair Popple <alistair at popple.id.au> wrote:

> On Monday, 9 April 2018 5:35:20 PM AEST Nicholas Piggin wrote:
> > Like the sreset change. The global state isn't nice, we may have to
> > find a good way to move these bits into targets in the longer term.  
> 
> Not quite sure what you mean here? It should be possible to add per-target state
> variables to the targets. Eg. see `struct thread` in libpdbg/target.h. Does that
> help?

A matter of me not being lazy, I guess. I'll have a look and do a pass
to clean this up as much as possible.

Thanks,
Nick


> 
> - Alistair
> 
> > Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
> > ---
> >  libpdbg/p9chip.c | 22 ++++++++++++++++++++--
> >  1 file changed, 20 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c
> > index ab0e9a1..e3f6d8a 100644
> > --- a/libpdbg/p9chip.c
> > +++ b/libpdbg/p9chip.c
> > @@ -150,6 +150,8 @@ static int p9_thread_sreset(struct thread *thread)
> >  	return 0;
> >  }
> >  
> > +static bool ram_setup_did_stop = false;
> > +
> >  static int p9_ram_setup(struct thread *thread)
> >  {
> >  	struct dt_node *dn;
> > @@ -165,8 +167,11 @@ static int p9_ram_setup(struct thread *thread)
> >  		   so do that now. This will also update the thread status */
> >  		p9_thread_probe(dn->target);
> >  		tmp = target_to_thread(dn->target);
> > -		if (tmp->status != (THREAD_STATUS_QUIESCE | THREAD_STATUS_ACTIVE))
> > -			return 1;
> > +		if (tmp->status != (THREAD_STATUS_QUIESCE | THREAD_STATUS_ACTIVE)) {
> > +			if (p9_thread_stop(tmp))
> > +				return 1;
> > +			ram_setup_did_stop = true;
> > +		}
> >  	}
> >  
> >  	/* Wait or NEST_ACTIVE to clear */
> > @@ -234,9 +239,22 @@ static int p9_ram_instruction(struct thread *thread, uint64_t opcode, uint64_t *
> >  
> >  static int p9_ram_destroy(struct thread *thread)
> >  {
> > +	struct dt_node *dn;
> > +	struct core *chip = target_to_core(thread->target.dn->parent->target);
> > +
> >  	/* Disable ram mode */
> >  	CHECK_ERR(thread_write(thread, P9_RAM_MODEREG, 0));
> >  
> > +	dt_for_each_compatible(chip->target.dn, dn, "ibm,power9-thread") {
> > +		struct thread *tmp;
> > +
> > +		tmp = target_to_thread(dn->target);
> > +		if (ram_setup_did_stop)
> > +			p9_thread_start(tmp);
> > +	}
> > +
> > +	ram_setup_did_stop = false;
> > +
> >  	return 0;
> >  }
> >  
> >   
> 
> 



More information about the Pdbg mailing list