[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170614105057.GA7236@leverpostej>
Date: Wed, 14 Jun 2017 11:50:58 +0100
From: Mark Rutland <mark.rutland@....com>
To: Will Deacon <will.deacon@....com>
Cc: dikshit.n@...wei.com, shyju.pv@...wei.com, anurupvasu@...il.com,
gabriele.paoloni@...wei.com, huangdaode@...ilicon.com,
John Garry <john.garry@...wei.com>,
linux-kernel@...r.kernel.org, xuwei5@...ilicon.com,
linuxarm@...wei.com, Shaokun Zhang <zhangshaokun@...ilicon.com>,
sanil.kumar@...ilicon.com, linux-arm-kernel@...ts.infradead.org,
shiju.jose@...wei.com, tanxiaojun@...wei.com, anurup.m@...wei.com
Subject: Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon
Djtag driver
On Wed, Jun 14, 2017 at 11:42:30AM +0100, Mark Rutland wrote:
> On Wed, Jun 14, 2017 at 11:06:58AM +0100, Will Deacon wrote:
> > Apologies, I misunderstood your algorithm (I thought step (a) was on one CPU
> > and step (b) was on another). Still, I don't understand the need for the
> > timeout. If you instead read back the flag immediately, wouldn't it still
> > work? e.g.
> >
> >
> > lock:
> > Readl_relaxed flag
> > if (locked)
> > goto lock;
> >
> > Writel_relaxed unique ID to flag
> > Readl flag
> > if (locked by somebody else)
> > goto lock;
> >
> > <critical section>
> >
> > unlock:
> > Writel unlocked value to flag
> >
> >
> > Given that we're dealing with iomem, I think it will work, but I could be
> > missing something obvious.
>
> Don't we have the race below where both threads can enter the critical
> section?
>
> // flag f initial zero (unlocked)
>
> // t1, flag 1 // t2, flag 2
> readl(f); // reads 0 l = readl(f); // reads 0
>
> <thinks lock is free> <thinks lock is free>
>
> writel(1, f);
> readl(f); // reads 1
> <thinks lock owned>
> writel(2, f);
> readl(f) // reads 2
> <thinks lock owned>
>
> <crticial section> <critical section>
>
> Thanks,
> Mark.
> IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose
> the contents to any other person, use it for any purpose, or store or
> copy the information in any medium. Thank you.
Please ignore the disclaimer on this mail; my client was mis-configured.
I will ensure I avoid sending bogus disclaimers in future.
Thanks,
Mark.
Powered by blists - more mailing lists