linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wilken Gottwalt <wilken.gottwalt@posteo.net>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: linux-kernel@vger.kernel.org, Ohad Ben-Cohen <ohad@wizery.com>,
	Baolin Wang <baolin.wang7@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Maxime Ripard <mripard@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@siol.net>
Subject: Re: [PATCH 2/2] hwspinlock: add sunxi hardware spinlock support
Date: Thu, 26 Nov 2020 14:31:43 +0100	[thread overview]
Message-ID: <20201126143143.06107cf4@monster.powergraphx.local> (raw)
In-Reply-To: <20201124145425.GB185852@builder.lan>

On Tue, 24 Nov 2020 08:54:25 -0600
Bjorn Andersson <bjorn.andersson@linaro.org> wrote:

> On Mon 23 Nov 12:17 CST 2020, Wilken Gottwalt wrote:
> 
> > On Sat, 21 Nov 2020 23:19:00 -0600
> > Bjorn Andersson <bjorn.andersson@linaro.org> wrote:
> > > > +static int hwlocks_inuse_show(struct seq_file *seqf, void *unused)
> > > > +{
> > > > +	struct sunxi_hwspinlock_data *priv = seqf->private;
> > > > +	int inuse;
> > > > +
> > > > +	/* getting the status of only the main 32 spinlocks is supported */
> > > > +	inuse = hweight32(readl(priv->io_base + SPINLOCK_STATUS_REG));
> > > 
> > > So this returns how many of the locks are taken? How is that useful?
> > 
> > It is a way to see if locks were taken from linux or the arisc core without
> > touching the actual hwspinlock abi or the locks. So it is a nice way to debug
> > hwspinlocks, hence it is part of debugfs.
> > 
> 
> So in a scenario where two remote processors ping-pong the lock between
> them, this will always read 1 and you won't know why?

I know it is not perfect. I will change it to actually report which locks are
taken. And currently the crust firmware does not use the locks and on the
Linux side there are only a handful of driver/components using hwspinlocks,
and none of them are active in a kernel compiled for a H5. So it really is a
nice way to check/debug the hwspinlocks. I already have a simple test running
where crust sets a spinlock and I can see it on Linux without touching the
actuall locks thanks to this status register.

> > > > +	seq_printf(seqf, "%d\n", inuse);
> [..]
> > > > +
> > > > +	return 0;
> > > > +}
> > > > +
> > > > +static const struct of_device_id sunxi_hwspinlock_ids[] = {
> > > > +	{ .compatible = "allwinner,sun8i-hwspinlock", },
> > > > +	{ .compatible = "allwinner,sun50i-hwspinlock", },
> > > > +	{},
> > > > +};
> > > > +MODULE_DEVICE_TABLE(of, sunxi_hwspinlock_ids);
> > > > +
> > > > +static struct platform_driver sunxi_hwspinlock_driver = {
> > > > +	.probe	= sunxi_hwspinlock_probe,
> > > > +	.remove	= sunxi_hwspinlock_remove,
> > > > +	.driver	= {
> > > > +		.name		= DRIVER_NAME,
> > > > +		.of_match_table	= of_match_ptr(sunxi_hwspinlock_ids),
> > > 
> > > Please avoid of_match_ptr, as this will cause warnings about unused
> > > variables when COMPILE_TEST without OF.
> > 
> > So did you mean to leave it out completely?
> > 
> 
> Yes, "worst case" is that you include the reference to
> sunxi_hwspinlock_ids on a build without CONFIG_OF and wasting a little
> bit of memory.
> 
> Using of_match_ptr() with CONFIG_OF=n will result in NULL and as such
> we'll get a compile warning that nothing references sunxi_hwspinlock_ids
> - so then that will have to be marked __maybe_unused, or wrapped in an
> #if...
> 
> So better just leave it as:
> 	.of_match_table = sunxi_hwspinlock_ids,

Thank you for the explanation. I really like to know the details and reasons
behind this.

greetings,
Wilken

> Regards,
> Bjorn


      reply	other threads:[~2020-11-26 13:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18 10:01 [PATCH 0/2] hwspinlock: add sunxi hardware spinlock support Wilken Gottwalt
2020-11-18 10:01 ` [PATCH 1/2] dt-bindings: hwlock: sunxi: add sunxi_hwspinlock documentation Wilken Gottwalt
2020-11-18 10:02 ` [PATCH 2/2] hwspinlock: add sunxi hardware spinlock support Wilken Gottwalt
2020-11-18 15:37   ` Maxime Ripard
2020-11-18 19:36     ` Wilken Gottwalt
2020-11-19  7:15       ` Maxime Ripard
2020-11-19 10:13         ` Wilken Gottwalt
2020-11-20 16:42           ` Maxime Ripard
2020-11-21 12:22             ` fuyao
2020-11-21 16:44               ` Maxime Ripard
2020-11-23 18:32                 ` Wilken Gottwalt
2020-11-24  3:35                   ` Samuel Holland
2020-11-24 14:28                     ` Maxime Ripard
2020-11-26 13:10                     ` Wilken Gottwalt
2020-11-22  5:19   ` Bjorn Andersson
2020-11-23 18:17     ` Wilken Gottwalt
2020-11-24 14:54       ` Bjorn Andersson
2020-11-26 13:31         ` Wilken Gottwalt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201126143143.06107cf4@monster.powergraphx.local \
    --to=wilken.gottwalt@posteo.net \
    --cc=baolin.wang7@gmail.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=jernej.skrabec@siol.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=ohad@wizery.com \
    --cc=robh+dt@kernel.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).