All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: ath9k-devel@lists.ath9k.org
Subject: [ath9k-devel] [PATCH 3/4] ath5k: define ath_common ops
Date: Sat, 12 Sep 2009 13:53:02 +0200	[thread overview]
Message-ID: <4AAB8B9E.1030508@gmail.com> (raw)
In-Reply-To: <43e72e890909110023k62a512bejd712a3449cc8328d@mail.gmail.com>

On 09/11/2009 09:23 AM, Luis R. Rodriguez wrote:
> On Thu, Sep 10, 2009 at 11:46 PM, Jiri Slaby <jirislaby@gmail.com> wrote:
>> I definitely agree with Nick here. Althought whole ath_ops will be hot
>> cache after the first operation, there is no need to prolong hot paths
>> by computing the op address and a call. Ok, read/write on PCI is pretty
>> slow, but still...
> 
> That is the way I had it originally before submission, and I
> completely agree its reasonable to not incur additional cost at the
> expense of having two separate read/write paths, and perhaps we should
> only incur the extra cost on routines shared between
> ath9k/ath9k/ath9k_htc. But -- is there really is a measurable cost
> penalty?

Hardly there is a measurable one. As I wrote earlier one will wait ages
for PCI in comparison to few load+call cycles.

> This is why I asked if someone can test and give measurable
> differences over this. If there really isn't then that's not strong
> point against it.

Well, honestly I see no strong point for it. It rather looks like an
obfuscation, not improvement.

> For example, long ago I had argued over the cost incurred over the
> unnecessary branching on ioread()/iowrite() when you know you have
> MMIO devices [1] -- the defense then, and IMHO reasonable now, was
> that the benefits of allowing cleaner drivers through the new
> interfaces outweigh the theoretical penalties imposed by them.

Ok, that one has benefits. You just needn't care about what is behind
that mapping. It will choose a PIO or MMIO op on its own.

When it's always MMIO I personally prefer simple ioremap though. (I
didn't at the time of merging the driver.)

> Granted you can argue these new interfaces between
> ath5k/ath9k/ath9k_htc would make things a little more complex, but I
> would expect sharing the code will help in the end. And if these
> interfaces are not acceptable I'm completely open to better suggested
> alternatives.

Ok, I think nothing more than this is needed:
+static u32 ath5k_ioread32(void *hw_priv, u32 reg_offset)
+{
+	return ath5k_hw_reg_read(hw_priv, reg_offset)
+}
+
+static void ath5k_iowrite32(void *hw_priv, u32 reg_offset, u32 val)
+{
+	ath5k_hw_reg_write(hw_priv, val, reg_offset);
+}
+
+static struct ath_ops ath5k_common_ops = {
+	.read = ath5k_ioread32,
+	.write = ath5k_iowrite32,
+};

What I wonder is why ath_ops has reg+val parameters in the opposite
manner than the rest of kernel? It is error-prone.

WARNING: multiple messages have this Message-ID (diff)
From: Jiri Slaby <jirislaby@gmail.com>
To: "Luis R. Rodriguez" <lrodriguez@atheros.com>
Cc: Nick Kossifidis <mickflemm@gmail.com>,
	devel@linuxdriverproject.org, ath9k-devel@lists.ath9k.org,
	linux-wireless@vger.kernel.org,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jeff Garzik <jeff@garzik.org>
Subject: Re: [PATCH 3/4] ath5k: define ath_common ops
Date: Sat, 12 Sep 2009 13:53:02 +0200	[thread overview]
Message-ID: <4AAB8B9E.1030508@gmail.com> (raw)
In-Reply-To: <43e72e890909110023k62a512bejd712a3449cc8328d@mail.gmail.com>

On 09/11/2009 09:23 AM, Luis R. Rodriguez wrote:
> On Thu, Sep 10, 2009 at 11:46 PM, Jiri Slaby <jirislaby@gmail.com> wrote:
>> I definitely agree with Nick here. Althought whole ath_ops will be hot
>> cache after the first operation, there is no need to prolong hot paths
>> by computing the op address and a call. Ok, read/write on PCI is pretty
>> slow, but still...
> 
> That is the way I had it originally before submission, and I
> completely agree its reasonable to not incur additional cost at the
> expense of having two separate read/write paths, and perhaps we should
> only incur the extra cost on routines shared between
> ath9k/ath9k/ath9k_htc. But -- is there really is a measurable cost
> penalty?

Hardly there is a measurable one. As I wrote earlier one will wait ages
for PCI in comparison to few load+call cycles.

> This is why I asked if someone can test and give measurable
> differences over this. If there really isn't then that's not strong
> point against it.

Well, honestly I see no strong point for it. It rather looks like an
obfuscation, not improvement.

> For example, long ago I had argued over the cost incurred over the
> unnecessary branching on ioread()/iowrite() when you know you have
> MMIO devices [1] -- the defense then, and IMHO reasonable now, was
> that the benefits of allowing cleaner drivers through the new
> interfaces outweigh the theoretical penalties imposed by them.

Ok, that one has benefits. You just needn't care about what is behind
that mapping. It will choose a PIO or MMIO op on its own.

When it's always MMIO I personally prefer simple ioremap though. (I
didn't at the time of merging the driver.)

> Granted you can argue these new interfaces between
> ath5k/ath9k/ath9k_htc would make things a little more complex, but I
> would expect sharing the code will help in the end. And if these
> interfaces are not acceptable I'm completely open to better suggested
> alternatives.

Ok, I think nothing more than this is needed:
+static u32 ath5k_ioread32(void *hw_priv, u32 reg_offset)
+{
+	return ath5k_hw_reg_read(hw_priv, reg_offset)
+}
+
+static void ath5k_iowrite32(void *hw_priv, u32 reg_offset, u32 val)
+{
+	ath5k_hw_reg_write(hw_priv, val, reg_offset);
+}
+
+static struct ath_ops ath5k_common_ops = {
+	.read = ath5k_ioread32,
+	.write = ath5k_iowrite32,
+};

What I wonder is why ath_ops has reg+val parameters in the opposite
manner than the rest of kernel? It is error-prone.

  parent reply	other threads:[~2009-09-12 11:53 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-11  1:34 [ath9k-devel] [PATCH 0/4] atheros: implement common read/write ops Luis R. Rodriguez
2009-09-11  1:34 ` Luis R. Rodriguez
2009-09-11  1:34 ` [ath9k-devel] [PATCH 1/4] atheros/ath9k: add common read/write ops and port ath9k to use it Luis R. Rodriguez
2009-09-11  1:34   ` Luis R. Rodriguez
2009-09-11  1:34 ` [ath9k-devel] [PATCH 2/4] ath5k: allocate ath5k_hw prior to initializing hw Luis R. Rodriguez
2009-09-11  1:34   ` Luis R. Rodriguez
2009-09-11  1:34 ` [ath9k-devel] [PATCH 3/4] ath5k: define ath_common ops Luis R. Rodriguez
2009-09-11  1:34   ` Luis R. Rodriguez
2009-09-11  1:42   ` [ath9k-devel] " Bob Copeland
2009-09-11  1:42     ` Bob Copeland
2009-09-11  1:46     ` [ath9k-devel] " Luis R. Rodriguez
2009-09-11  1:46       ` Luis R. Rodriguez
2009-09-11  6:16   ` [ath9k-devel] " Nick Kossifidis
2009-09-11  6:16     ` Nick Kossifidis
2009-09-11  6:46     ` [ath9k-devel] " Jiri Slaby
2009-09-11  6:46       ` Jiri Slaby
2009-09-11  7:23       ` [ath9k-devel] " Luis R. Rodriguez
2009-09-11  7:23         ` Luis R. Rodriguez
2009-09-11 11:35         ` [ath9k-devel] " Bob Copeland
2009-09-11 11:35           ` Bob Copeland
2009-09-11 17:53           ` [ath9k-devel] " Luis R. Rodriguez
2009-09-11 17:53             ` Luis R. Rodriguez
2009-09-11 14:24         ` [ath9k-devel] " Linus Torvalds
2009-09-11 14:24           ` Linus Torvalds
2009-09-11 17:43           ` [ath9k-devel] " Luis R. Rodriguez
2009-09-11 17:43             ` Luis R. Rodriguez
2009-09-11 20:11             ` [ath9k-devel] " Linus Torvalds
2009-09-11 20:11               ` Linus Torvalds
2009-09-12 11:53         ` Jiri Slaby [this message]
2009-09-12 11:53           ` Jiri Slaby
2009-09-13  0:56           ` [ath9k-devel] " Luis R. Rodriguez
2009-09-13  0:56             ` Luis R. Rodriguez
2009-09-11  1:34 ` [ath9k-devel] [PATCH 4/4] atheros: define shared bssidmask setting Luis R. Rodriguez
2009-09-11  1:34   ` Luis R. Rodriguez

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=4AAB8B9E.1030508@gmail.com \
    --to=jirislaby@gmail.com \
    --cc=ath9k-devel@lists.ath9k.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.