[PATCH v2 1/3] coresight: catu: Introduce refcount and spinlock for enabling/disabling

Leo Yan leo.yan at arm.com
Wed Apr 2 06:01:45 PDT 2025


Hi Yabin,

On Tue, Apr 01, 2025 at 06:21:59PM -0700, Yabin Cui wrote:

[...]

> > @@ -486,12 +491,17 @@ static int catu_disable_hw(struct catu_drvdata *drvdata)
> >
> >  static int catu_disable(struct coresight_device *csdev, void *__unused)
> >  {
> > -       int rc;
> > +       int rc = 0;
> >         struct catu_drvdata *catu_drvdata = csdev_to_catu_drvdata(csdev);
> > +       guard(raw_spinlock_irqsave)(&catu_drvdata->spinlock);
> >
> > -       CS_UNLOCK(catu_drvdata->base);
> > -       rc = catu_disable_hw(catu_drvdata);
> > -       CS_LOCK(catu_drvdata->base);
> > +       if (--csdev->refcnt == 0) {
> > +               CS_UNLOCK(catu_drvdata->base);
> > +               rc = catu_disable_hw(catu_drvdata);
> > +               CS_LOCK(catu_drvdata->base);
> > +       } else {
> > +               rc = -EBUSY;

This is not an error if the decremented reference counter is not zero.
It should return 0.  Otherwise, the change looks good to me.

Thanks,
Leo



More information about the linux-arm-kernel mailing list