Devicetree
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: "Brüns, Stefan" <Stefan.Bruens-vA1bhqPz9FBZXbeN9DUtxg@public.gmane.org>
Cc: linux-sunxi <linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
	<vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH 1/3] dmaengine: sun6i: Correct DMA support on H3
Date: Mon, 4 Sep 2017 08:50:27 +0200	[thread overview]
Message-ID: <20170904065027.7splxlgxhpu5nj56@flea> (raw)
In-Reply-To: <5722405.lpx0YHbn2k@sbruens-linux>

[-- Attachment #1: Type: text/plain, Size: 3180 bytes --]

On Fri, Sep 01, 2017 at 02:42:47PM +0000, Brüns, Stefan wrote:
> On Freitag, 1. September 2017 15:35:49 CEST Maxime Ripard wrote:
> > On Fri, Sep 01, 2017 at 05:04:54AM +0200, Stefan Bruens wrote:
> > > On Donnerstag, 31. August 2017 16:51:35 CEST Maxime Ripard wrote:
> > > > Hi,
> > > > 
> > > > On Thu, Aug 31, 2017 at 01:36:07AM +0200, Stefan Brüns wrote:
> > > > > +/* Between SoC generations, there are some significant differences:
> > > > > + * - A23 added a clock gate register
> > > > > + * - the H3 burst length field has a different offset
> > > > > + */
> > > > 
> > > > This is not the proper comment style.
> > > > 
> > > > > +enum dmac_variant {
> > > > > +	DMAC_VARIANT_A31,
> > > > > +	DMAC_VARIANT_A23,
> > > > > +	DMAC_VARIANT_H3,
> > > > > +};
> > > > > +
> > > > 
> > > > And this is redundant with what we already have in our structures.
> > > 
> > > Actually, its not. For H3, there are currently at least 3 register
> > > compatible SoCs: H5 is identical, R40 has 16 dma channels, A64 has 8
> > > channels. So if the current config structure is kept, we need 3 different
> > > compatible strings. Same for the A23, which is register compatible to
> > > e.g. A83t and V3s, but with different numbers of DMA channels.
> > > 
> > > So either you decorate the code with a cascade of
> > > 
> > > if ((of_is_compatible(..A23..) || of_is_compatible(..A83T..) || ...) {
> > > } else if ((of_is_compatible(..H3..) || of_is_compatible(..A64..) || ...)
> > > {
> > > } else { /* A31 */
> > > }
> > > 
> > > in a number of places, or you do it just once.
> > 
> > That's not how you retrieve the structures. They are already
> > associated to the compatible, and you need to do a single lookup to
> > get them. So that's nowhere near what you're suggesting. You can have
> > a look at the of_match_device in the probe function.
> 
> Please have a look at the current implementation of how the clock autogating 
> in the probe function is done - it matches with the compatible string.

Yeah, and we should get rid of that as well.

> Of course we can replace this with a match between sdev->config and the 
> various sun6i_dma_config instances, but we would still have to do 3 matches 
> for the A23 register configuration (A23 || A83T || V3s) and 3 matches for the 
> H3 register configuration (H3 || R40 || A64). There are currently *7* 
> different configs (V3s, R40 and A64 taken into account), but only 3 different 
> register variants.
> 
> This is the same rationale as the "gate_needed" boolean property proposed by 
> Icenowy Zheng in the "Allwinner V3s DMA support" patch series. Obviously we 
> don't need a boolean, but a ternary option to cater for the gate_needed 
> differences - "NO_GATE", "A23_STYLE_GATE", "H3_STYLE_GATE".

Or we can just have an extra field in sun6i_dma_config that would set
the gate register offset? If it's non-zero, use whatever you have set
there, and then you just have to care about two cases, no matter how
many offsets we'll have in the wild.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  parent reply	other threads:[~2017-09-04  6:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 23:36 [PATCH 0/3] dmaengine: Fix DMA on current allwinner SoCs, add A64 support Stefan Brüns
2017-08-30 23:36 ` [PATCH 1/3] dmaengine: sun6i: Correct DMA support on H3 Stefan Brüns
2017-08-31 14:51   ` Maxime Ripard
     [not found]     ` <20170831145135.c6a2wubcf6xu34tz-ZC1Zs529Oq4@public.gmane.org>
2017-09-01  3:04       ` Stefan Bruens
2017-09-01 13:35         ` Maxime Ripard
2017-09-01 14:42           ` Brüns, Stefan
2017-09-01 14:51             ` taskboxtester
2017-09-04  6:50             ` Maxime Ripard [this message]
2017-08-30 23:36 ` [PATCH 2/3] arm64: allwinner: a64: Add device node for DMA controller Stefan Brüns
     [not found]   ` <20170830233609.13855-3-stefan.bruens-vA1bhqPz9FBZXbeN9DUtxg@public.gmane.org>
2017-09-11 22:00     ` Rob Herring
2017-08-30 23:36 ` [PATCH 3/3] dmaengine: sun6i: Add support for Allwinner A64 Stefan Brüns
2017-08-31 11:44   ` Code Kipper
     [not found]   ` <20170830233609.13855-4-stefan.bruens-vA1bhqPz9FBZXbeN9DUtxg@public.gmane.org>
2017-08-31 14:52     ` Maxime Ripard
     [not found]       ` <20170831145246.p4k3uakbn67na3pv-ZC1Zs529Oq4@public.gmane.org>
2017-08-31 16:35         ` Code Kipper
2017-09-01  0:31     ` Andre Przywara
     [not found]       ` <20170901003135.10058-1-andre.przywara-5wv7dgnIgG8@public.gmane.org>
2017-09-01  1:19         ` Stefan Bruens
2017-09-01 22:32           ` André Przywara
     [not found]             ` <d397d87b-5004-c8af-e590-037befc9b2b6-5wv7dgnIgG8@public.gmane.org>
2017-09-02  0:38               ` Stefan Bruens
2017-09-02  2:02             ` Stefan Bruens
     [not found]               ` <2607878.Us0MSlEf6n-KVr1ISHqF63jSbz6xCtQhw@public.gmane.org>
2017-09-03 23:14                 ` André Przywara
2017-09-01  6:04         ` Maxime Ripard
2017-09-01 22:35           ` André Przywara
     [not found]             ` <743ae23a-372a-762b-c345-b914f09fd718-5wv7dgnIgG8@public.gmane.org>
2017-09-04  7:04               ` Maxime Ripard
2017-09-04  8:14                 ` André Przywara
2017-09-08 14:39                   ` Maxime Ripard
2017-09-08 14:57                     ` Andre Przywara

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=20170904065027.7splxlgxhpu5nj56@flea \
    --to=maxime.ripard-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
    --cc=Stefan.Bruens-vA1bhqPz9FBZXbeN9DUtxg@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=wens-jdAy2FN1RRM@public.gmane.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