All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@denx.de>
To: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Cc: cip-dev@lists.cip-project.org,
	Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>,
	Pavel Machek <pavel@denx.de>,
	Biju Das <biju.das.jz@bp.renesas.com>
Subject: Re: [PATCH 5.10.y-cip 15/21] can: rcar_canfd: Add support for RZ/G2L family
Date: Thu, 23 Dec 2021 00:13:43 +0100	[thread overview]
Message-ID: <20211222231343.GA25345@amd> (raw)
In-Reply-To: <20211222134951.19432-16-prabhakar.mahadev-lad.rj@bp.renesas.com>

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

Hi!

> commit 76e9353a80e9e9ff65b362a6dd8545d84427ec30 upstream.
> 
> CANFD block on RZ/G2L SoC is almost identical to one found on
> R-Car Gen3 SoC's. On RZ/G2L SoC interrupt sources for each channel
> are split into different sources and the IP doesn't divide (1/2)
> CANFD clock within the IP.
> 
> This patch adds compatible string for RZ/G2L family and splits
> the irq handlers to accommodate both RZ/G2L and R-Car Gen3 SoC's.


> +++ b/drivers/net/can/rcar/rcar_canfd.c
> +
> +static irqreturn_t rcar_canfd_global_err_interrupt(int irq, void *dev_id)
> +{
> +	struct rcar_canfd_global *gpriv = dev_id;
> +	u32 ch;
> +
> +	for_each_set_bit(ch, &gpriv->channels_mask, RCANFD_NUM_CHANNELS)
> +		rcar_canfd_handle_global_err(gpriv, ch);
> +
> +	return IRQ_HANDLED;
> +}
> +

You are returning IRQ_HANDLED even when you do no handling. That
probably will not do harm as long as interrupts are not shared. Is
that guaranteed to be true?

> @@ -1577,6 +1653,53 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
>  	priv->can.clock.freq = fcan_freq;
>  	dev_info(&pdev->dev, "can_clk rate is %u\n", priv->can.clock.freq);
>  
> +	if (gpriv->chip_id == RENESAS_RZG2L) {
> +		char *irq_name;
> +		int err_irq;
> +		int tx_irq;
> +
> +		err_irq = platform_get_irq_byname(pdev, ch == 0 ? "ch0_err" : "ch1_err");
> +		if (err_irq < 0) {
> +			err = err_irq;
> +			goto fail;
> +		}

This leaks ndev; it should free_candev(ndev); before returning, AFAICT.

> @@ -1670,6 +1811,19 @@ static int rcar_canfd_probe(struct platform_device *pdev)
>  	gpriv->pdev = pdev;
>  	gpriv->channels_mask = channels_mask;
>  	gpriv->fdmode = fdmode;
> +	gpriv->chip_id = chip_id;
> +
> +	if (gpriv->chip_id == RENESAS_RZG2L) {
> +		gpriv->rstc1 = devm_reset_control_get_exclusive(&pdev->dev, "rstp_n");
> +		if (IS_ERR(gpriv->rstc1))
> +			return dev_err_probe(&pdev->dev, PTR_ERR(gpriv->rstc1),
> +					     "failed to get rstp_n\n");
> +
> +		gpriv->rstc2 = devm_reset_control_get_exclusive(&pdev->dev, "rstc_n");
> +		if (IS_ERR(gpriv->rstc2))
> +			return dev_err_probe(&pdev->dev, PTR_ERR(gpriv->rstc2),
> +					     "failed to get rstc_n\n");
> +	}
>  
>  	/* Peripheral clock */
>  	gpriv->clkp = devm_clk_get(&pdev->dev, "fck");

The code is correct but it mixes direct returns with "goto
fail_dev", which is just alias for return. I'd prefer just doing
returns directly, but it really should not mix direct returns with
goto return.

> -	err = devm_request_irq(&pdev->dev, g_irq,
> -			       rcar_canfd_global_interrupt, 0,
> -			       "canfd.gbl", gpriv);

Strange. New code variant no longer allocates canfd.gbl?

> +	err = reset_control_reset(gpriv->rstc1);
> +	if (err)
> +		goto fail_dev;
> +	err = reset_control_reset(gpriv->rstc2);
>  	if (err) {
> -		dev_err(&pdev->dev, "devm_request_irq(%d) failed, error %d\n",
> -			g_irq, err);
> +		reset_control_assert(gpriv->rstc1);
>  		goto fail_dev;
>  	}

I'd introduce new label here, so that you don't need to do
reset_control_assert(gpriv->rstc1); at two different places... like
below...

Best regards,

								Pavel

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 52629c6c19702..ce9b3a0032bf8 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1908,10 +1908,8 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 	if (err)
 		goto fail_dev;
 	err = reset_control_reset(gpriv->rstc2);
-	if (err) {
-		reset_control_assert(gpriv->rstc1);
-		goto fail_dev;
-	}
+	if (err)
+		goto fail_reset1;
 
 	/* Enable peripheral clock for register access */
 	err = clk_prepare_enable(gpriv->clkp);
@@ -1976,8 +1974,9 @@ static int rcar_canfd_probe(struct platform_device *pdev)
 fail_clk:
 	clk_disable_unprepare(gpriv->clkp);
 fail_reset:
-	reset_control_assert(gpriv->rstc1);
 	reset_control_assert(gpriv->rstc2);
+fail_reset1:
+	reset_control_assert(gpriv->rstc1);
 fail_dev:
 	return err;
 }




-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2021-12-22 23:13 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22 13:49 [PATCH 5.10.y-cip 00/21] RZ/G2L: Add support for USB/CANFD Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 01/21] dt-bindings: usb: generic-ehci: Document dr_mode property Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 02/21] dt-bindings: usb: generic-ohci: " Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 03/21] dt-bindings: reset: Document RZ/G2L USBPHY Control bindings Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 04/21] reset: renesas: Add RZ/G2L usbphy control driver Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 05/21] dt-bindings: usb: renesas,usbhs: Document RZ/G2L bindings Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 06/21] dt-bindings: phy: renesas,usb2-phy: Document RZ/G2L phy bindings Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 07/21] phy: renesas: convert to devm_platform_ioremap_resource Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 08/21] phy: renesas: phy-rcar-gen3-usb2: Add USB2.0 PHY support for RZ/G2L Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 09/21] clk: renesas: r9a07g044: Add USB clocks/resets Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 10/21] arm64: dts: renesas: r9a07g044: Add USB2.0 phy and host support Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 11/21] arm64: dts: renesas: r9a07g044: Add USB2.0 device support Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 12/21] arm64: dts: renesas: rzg2l-smarc: Enable USB2.0 support Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 13/21] dt-bindings: can: rcar_canfd: Group tuples in pin control properties Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 14/21] dt-bindings: can: rcar_canfd: Convert to json-schema Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 15/21] can: rcar_canfd: Add support for RZ/G2L family Lad Prabhakar
2021-12-22 23:13   ` Pavel Machek [this message]
2021-12-22 23:37     ` Prabhakar Mahadev Lad
2021-12-23 18:43       ` Pavel Machek
     [not found]       ` <16C376847BE1186B.4760@lists.cip-project.org>
2021-12-26 16:08         ` [cip-dev] " Pavel Machek
2021-12-27 13:45           ` Prabhakar Mahadev Lad
2021-12-22 13:49 ` [PATCH 5.10.y-cip 16/21] can: rcar_canfd: rcar_canfd_handle_channel_tx(): fix redundant assignment Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 17/21] dt-bindings: clock: r9a07g044-cpg: Add entry for P0_DIV2 core clock Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 18/21] clk: renesas: r9a07g044: Add entry for fixed clock P0_DIV2 Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 19/21] clk: renesas: r9a07g044: Add clock and reset entries for CANFD Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 20/21] arm64: dts: renesas: r9a07g044: Add CANFD node Lad Prabhakar
2021-12-22 13:49 ` [PATCH 5.10.y-cip 21/21] arm64: defconfig: Enable RZ/G2L USBPHY control driver Lad Prabhakar

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=20211222231343.GA25345@amd \
    --to=pavel@denx.de \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    /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.