From: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Geert Uytterhoeven <geert+renesas@glider.be>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Biju Das <biju.das.jz@bp.renesas.com>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
"linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>
Subject: RE: [PATCH 4/7] irqchip/renesas-rzv2h: Add rzv2h_icu_register_dma_req_ack
Date: Fri, 7 Feb 2025 16:27:28 +0000 [thread overview]
Message-ID: <TYCPR01MB12093B5AF218BEFF2F2FEC08FC2F12@TYCPR01MB12093.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <87ed0amby0.ffs@tglx>
Hi Thomas,
Thank you for your feedback!
> From: Thomas Gleixner <tglx@linutronix.de>
> Sent: 07 February 2025 07:49
> Subject: Re: [PATCH 4/7] irqchip/renesas-rzv2h: Add rzv2h_icu_register_dma_req_ack
>
> On Thu, Feb 06 2025 at 22:03, Fabrizio Castro wrote:
>
> https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#function-references-in-changelogs
>
> > On the Renesas RZ/V2H(P) family of SoCs, DMAC IPs are connected
> > to the Interrupt Control Unit (ICU).
> > +#define ICU_DMkSELy(k, y) (0x420 + (k) * 0x20 + (y) * 4)
> > +#define ICU_DMACKSELk(k) (0x500 + (k) * 4)
> >
> > /* NMI */
> > #define ICU_NMI_EDGE_FALLING 0
> > @@ -80,6 +83,19 @@
> > #define ICU_TINT_EXTRACT_GPIOINT(x) FIELD_GET(GENMASK(31, 16), (x))
> > #define ICU_PB5_TINT 0x55
> >
> > +/* DMAC */
> > +#define ICU_DMAC_DkSEL_CLRON_MASK BIT(15)
> > +#define ICU_DMAC_DkRQ_SEL_MASK GENMASK(9, 0)
> > +#define ICU_DMAC_DMAREQ_MASK (ICU_DMAC_DkRQ_SEL_MASK | \
> > + ICU_DMAC_DkSEL_CLRON_MASK)
> > +
> > +#define ICU_DMAC_PREP_DkSEL_CLRON(x) FIELD_PREP(ICU_DMAC_DkSEL_CLRON_MASK, (x))
> > +#define ICU_DMAC_PREP_DkRQ_SEL(x) FIELD_PREP(ICU_DMAC_DkRQ_SEL_MASK, (x))
> > +#define ICU_DMAC_PREP_DMAREQ(sel, clr) (ICU_DMAC_PREP_DkRQ_SEL(sel) | \
> > + ICU_DMAC_PREP_DkSEL_CLRON(clr))
>
> That's a pretty convoluted way to create a mask whihc has the CLRON bit
> always set to 0 according to the only usage site.
Indeed, it can be simplified.
>
> > +#define ICU_DMAC_DACK_SEL_MASK GENMASK(6, 0)
>
> > +void rzv2h_icu_register_dma_req_ack(struct platform_device *icu_dev, u8 dmac_index, u8
> dmac_channel,
> > + u16 req_no, u8 ack_no)
> > +{
> > + struct rzv2h_icu_priv *priv = platform_get_drvdata(icu_dev);
> > + u32 icu_dmackselk, dmaack, dmaack_mask;
> > + u32 icu_dmksely, dmareq, dmareq_mask;
> > + u8 k, field_no;
> > + u8 y, upper;
> > +
> > + if (req_no >= 0x1b5)
>
> In the DMA part you use proper defines for this, but here you put magic
> numbers into the code. Please share the defines and use them consistently.
Thanks for pointing it out, I'll fix it in v2.
>
> > + req_no = RZV2H_ICU_DMAC_REQ_NO_DEFAULT;
> > +
> > + if (ack_no >= 0x50)
> > + ack_no = RZV2H_ICU_DMAC_ACK_NO_DEFAULT;
> > +
> > + y = dmac_channel / 2;
> > + upper = dmac_channel % 2;
> > +
> > + dmareq = ICU_DMAC_PREP_DMAREQ(req_no, 0);
> > + dmareq_mask = ICU_DMAC_DMAREQ_MASK;
> > +
> > + if (upper) {
> > + dmareq <<= 16;
> > + dmareq_mask <<= 16;
> > + }
>
> You already have macros for this, so the obvious thing to do is to put
> the shift magic into them:
>
> /* Two 16 bit fields per register */
> #define ICU_DMAC_DMAREQ_SHIFT(ch) ((ch & 0x01) * 16)
>
> #define ICU_DMAC_PREP_DMAREQ(sel, ch) (ICU_DMAC_PREP_DkRQ_SEL(sel) \
> << ICU_DMAC_DMAREQ_SHIFT(ch))
> #define ICU_DMAC_DMAREQ_MASK(ch) (ICU_DMAC_DkRQ_SEL_MASK \
> << ICU_DMAC_DMAREQ_SHIFT(ch))
>
> dmareq = ICU_DMAC_PREP_DMAREQ(req_no, ch);
> dmareq_mask = ICU_DMAC_DMAREQ_MASK(ch);
Thank you, I'll adjust accordingly.
>
> > + k = ack_no / 4;
> > + field_no = ack_no % 4;
> > +
> > + dmaack_mask = ICU_DMAC_DACK_SEL_MASK << (field_no * 8);
> > + dmaack = ack_no << (field_no * 8);
>
> Same here.
Will do.
Cheers,
Fab
>
> > + guard(raw_spinlock_irqsave)(&priv->lock);
> > +
> > + icu_dmksely = readl(priv->base + ICU_DMkSELy(dmac_index, y));
> > + icu_dmksely = (icu_dmksely & ~dmareq_mask) | dmareq;
> > + writel(icu_dmksely, priv->base + ICU_DMkSELy(dmac_index, y));
> > +
> > + icu_dmackselk = readl(priv->base + ICU_DMACKSELk(k));
> > + icu_dmackselk = (icu_dmackselk & ~dmaack_mask) | dmaack;
> > + writel(icu_dmackselk, priv->base + ICU_DMACKSELk(k));
>
> Thanks,
>
> tglx
next prev parent reply other threads:[~2025-02-07 16:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 22:03 [PATCH 0/7] Add DMAC support to the RZ/V2H(P) Fabrizio Castro
2025-02-06 22:03 ` [PATCH 1/7] clk: renesas: r9a09g057: Add entries for the DMACs Fabrizio Castro
2025-02-06 22:03 ` [PATCH 2/7] dt-bindings: dma: rz-dmac: Restrict properties for RZ/A1H Fabrizio Castro
2025-02-06 22:03 ` [PATCH 3/7] dt-bindings: dma: rz-dmac: Document RZ/V2H(P) family of SoCs Fabrizio Castro
2025-02-11 22:26 ` Rob Herring
2025-02-12 18:27 ` Fabrizio Castro
2025-02-06 22:03 ` [PATCH 4/7] irqchip/renesas-rzv2h: Add rzv2h_icu_register_dma_req_ack Fabrizio Castro
2025-02-07 7:49 ` Thomas Gleixner
2025-02-07 16:27 ` Fabrizio Castro [this message]
2025-02-06 22:03 ` [PATCH 5/7] dmaengine: sh: rz-dmac: Allow for multiple DMACs Fabrizio Castro
2025-02-06 22:03 ` [PATCH 6/7] dmaengine: sh: rz-dmac: Add RZ/V2H(P) support Fabrizio Castro
2025-02-06 22:03 ` [PATCH 7/7] arm64: dts: renesas: r9a09g057: Add DMAC nodes Fabrizio Castro
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=TYCPR01MB12093B5AF218BEFF2F2FEC08FC2F12@TYCPR01MB12093.jpnprd01.prod.outlook.com \
--to=fabrizio.castro.jz@renesas.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=geert+renesas@glider.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®