linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@armlinux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 net-next 10/16] net: mvpp2: handle register mapping and access for PPv2.2
Date: Fri, 6 Jan 2017 14:46:48 +0000	[thread overview]
Message-ID: <20170106144648.GE14217@n2100.armlinux.org.uk> (raw)
In-Reply-To: <1482943592-12556-11-git-send-email-thomas.petazzoni@free-electrons.com>

On Wed, Dec 28, 2016 at 05:46:26PM +0100, Thomas Petazzoni wrote:
> This commit adjusts the mvpp2 driver register mapping and access logic
> to support PPv2.2, to handle a number of differences.
> 
> Due to how the registers are laid out in memory, the Device Tree binding
> for the "reg" property is different:
> 
>  - On PPv2.1, we had a first area for the common registers, and then one
>    area per port.
> 
>  - On PPv2.2, we have a first area for the common registers, and a
>    second area for all the per-ports registers.
> 
> In addition, on PPv2.2, the area for the common registers is split into
> so-called "address spaces" of 64 KB each. They allow to access the same
> registers, but from different CPUs. Hence the introduction of cpu_base[]
> in 'struct mvpp2', and the modification of the mvpp2_write() and
> mvpp2_read() register accessors. For PPv2.1, the compatibility is
> preserved by using an "address space" size of 0.

I'm not entirely sure this is the best solution - every register access
will be wrapped with a preempt_disable() and preempt_enable().  At
every site, when preempt is enabled, we will end up with code to:

- get the thread info
- increment the preempt count
- access the register
- decrement the preempt count
- test resulting preempt count and branch to __preempt_schedule()

If tracing is enabled, it gets much worse, because the increment and
decrement happen out of line, and are even more expensive.

If a function is going to make several register accesses, it's going
to be much more efficient to do:

	void __iomem *base = priv->cpu_base[get_cpu()];

	...

	put_cpu();

which means we don't end up with multiple instances of the preempt code
consecutive accesses.

I think this is an example where having driver-private accessors for
readl()/writel() is far from a good idea.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

  reply	other threads:[~2017-01-06 14:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-28 16:46 [PATCHv2 net-next 00/16] net: mvpp2: add basic support for PPv2.2 Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 01/16] dt-bindings: net: update Marvell PPv2 binding for PPv2.2 support Thomas Petazzoni
2017-01-03 20:18   ` Rob Herring
2017-02-02 16:56     ` Thomas Petazzoni
2017-02-03 16:48       ` Russell King - ARM Linux
2017-02-14 14:25         ` Thomas Petazzoni
2017-02-21 10:12           ` Thomas Petazzoni
2017-01-07  9:32   ` Russell King - ARM Linux
2017-02-02 16:44     ` Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 02/16] net: mvpp2: add and use accessors for TX/RX descriptors Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 03/16] net: mvpp2: add hw_version field in "struct mvpp2" Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 04/16] net: mvpp2: introduce an intermediate union for the TX/RX descriptors Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 05/16] net: mvpp2: introduce PPv2.2 HW descriptors and adapt accessors Thomas Petazzoni
2017-01-06 14:29   ` Russell King - ARM Linux
2017-01-06 14:44     ` Robin Murphy
2017-02-03 13:24       ` Thomas Petazzoni
2017-02-03 14:05         ` Robin Murphy
2017-02-03 15:02           ` Thomas Petazzoni
2017-02-03 16:31             ` Robin Murphy
2017-02-03 15:54           ` Russell King - ARM Linux
2017-02-04 13:59             ` Thomas Petazzoni
2017-02-06 12:43               ` David Laight
2016-12-28 16:46 ` [PATCHv2 net-next 06/16] net: mvpp2: adjust the allocation/free of BM pools for PPv2.2 Thomas Petazzoni
2017-01-06 14:32   ` Russell King - ARM Linux
2016-12-28 16:46 ` [PATCHv2 net-next 07/16] net: mvpp2: adapt the mvpp2_rxq_*_pool_set functions to PPv2.2 Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 08/16] net: mvpp2: adapt mvpp2_defaults_set() " Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 09/16] net: mvpp2: adjust mvpp2_{rxq, txq}_init for PPv2.2 Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 10/16] net: mvpp2: handle register mapping and access " Thomas Petazzoni
2017-01-06 14:46   ` Russell King - ARM Linux [this message]
2017-03-02  8:45     ` Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 11/16] net: mvpp2: handle misc PPv2.1/PPv2.2 differences Thomas Petazzoni
2017-01-07  9:38   ` Russell King - ARM Linux
2017-01-07 20:10     ` Russell King - ARM Linux
2017-02-14 14:53     ` Thomas Petazzoni
2017-01-07 11:03   ` Russell King - ARM Linux
2017-01-07 12:12     ` Marcin Wojtas
2017-01-07 13:50       ` Russell King - ARM Linux
2016-12-28 16:46 ` [PATCHv2 net-next 12/16] net: mvpp2: add AXI bridge initialization for PPv2.2 Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 13/16] net: mvpp2: rework RXQ interrupt group " Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 14/16] net: mvpp2: adapt rxq distribution to PPv2.2 Thomas Petazzoni
2016-12-28 16:46 ` [PATCHv2 net-next 15/16] net: mvpp2: add support for an additional clock needed for PPv2.2 Thomas Petazzoni
2017-01-07  9:29   ` Russell King - ARM Linux
2016-12-28 16:46 ` [PATCHv2 net-next 16/16] net: mvpp2: finally add the PPv2.2 compatible string Thomas Petazzoni
2016-12-28 17:06 ` [PATCHv2 net-next 00/16] net: mvpp2: add basic support for PPv2.2 David Miller
2016-12-28 21:08   ` Thomas Petazzoni

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=20170106144648.GE14217@n2100.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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).