dev, arm: Implement the NoMali reset callback

Add a callback handler for the NoMali reset callback. This callback is
called whenever the GPU is reset using the register interface or the
NoMali API. The callback can be used to override ID registers using
the raw register API.
This commit is contained in:
Andreas Sandberg 2016-02-23 11:49:35 +00:00
parent 81a8ce3564
commit e2cea54deb
2 changed files with 55 additions and 0 deletions

View file

@ -92,6 +92,13 @@ NoMaliGpu::NoMaliGpu(const NoMaliGpuParams *p)
cbk_int.func.interrupt = NoMaliGpu::_interrupt; cbk_int.func.interrupt = NoMaliGpu::_interrupt;
setCallback(cbk_int); setCallback(cbk_int);
/* Setup a reset callback */
nomali_callback_t cbk_rst;
cbk_rst.type = NOMALI_CALLBACK_RESET;
cbk_rst.usr = (void *)this;
cbk_rst.func.reset = NoMaliGpu::_reset;
setCallback(cbk_rst);
panicOnErr( panicOnErr(
nomali_get_info(nomali, &nomaliInfo), nomali_get_info(nomali, &nomaliInfo),
"Failed to get NoMali information struct"); "Failed to get NoMali information struct");
@ -102,6 +109,18 @@ NoMaliGpu::~NoMaliGpu()
nomali_destroy(nomali); nomali_destroy(nomali);
} }
void
NoMaliGpu::init()
{
PioDevice::init();
/* Reset the GPU here since the reset callback won't have been
* installed when the GPU was reset at instantiation time.
*/
reset();
}
void void
NoMaliGpu::serialize(CheckpointOut &cp) const NoMaliGpu::serialize(CheckpointOut &cp) const
{ {
@ -267,6 +286,12 @@ NoMaliGpu::onInterrupt(nomali_int_t intno, bool set)
platform->gic->clearInt(it_int->second); platform->gic->clearInt(it_int->second);
} }
void
NoMaliGpu::onReset()
{
DPRINTF(NoMali, "Reset\n");
}
void void
NoMaliGpu::setCallback(const nomali_callback_t &callback) NoMaliGpu::setCallback(const nomali_callback_t &callback)
{ {
@ -287,6 +312,14 @@ NoMaliGpu::_interrupt(nomali_handle_t h, void *usr,
_this->onInterrupt(intno, !!set); _this->onInterrupt(intno, !!set);
} }
void
NoMaliGpu::_reset(nomali_handle_t h, void *usr)
{
NoMaliGpu *_this(static_cast<NoMaliGpu *>(usr));
_this->onReset();
}
NoMaliGpu * NoMaliGpu *
NoMaliGpuParams::create() NoMaliGpuParams::create()
{ {

View file

@ -54,6 +54,8 @@ class NoMaliGpu : public PioDevice
NoMaliGpu(const NoMaliGpuParams *p); NoMaliGpu(const NoMaliGpuParams *p);
virtual ~NoMaliGpu(); virtual ~NoMaliGpu();
void init() override;
public: /* Checkpointing */ public: /* Checkpointing */
void serialize(CheckpointOut &cp) const override; void serialize(CheckpointOut &cp) const override;
void unserialize(CheckpointIn &cp) override; void unserialize(CheckpointIn &cp) override;
@ -126,6 +128,14 @@ class NoMaliGpu : public PioDevice
*/ */
virtual void onInterrupt(nomali_int_t intno, bool set); virtual void onInterrupt(nomali_int_t intno, bool set);
/**
* Reset callback from the NoMali library
*
* This method is called whenever the GPU is reset through the
* register interface or the API (reset() or nomali_reset()).
*/
virtual void onReset();
/** @} */ /** @} */
private: /* Callback helpers */ private: /* Callback helpers */
@ -145,6 +155,18 @@ class NoMaliGpu : public PioDevice
*/ */
static void _interrupt(nomali_handle_t h, void *usr, static void _interrupt(nomali_handle_t h, void *usr,
nomali_int_t intno, int set); nomali_int_t intno, int set);
/**
* Reset callback from the NoMali library.
*
* This method calls onReset() on the NoMaliGpu owning this
* device.
*
* @param h NoMali library handle.
* @param usr Pointer to an instance of the NoMaliGpu
*/
static void _reset(nomali_handle_t h, void *usr);
protected: protected:
/** Device base address */ /** Device base address */
const Addr pioAddr; const Addr pioAddr;