Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3377082pxv; Mon, 26 Jul 2021 02:55:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztLp8nT0BLHymgccTYFHVq9hqv9ekI52fiHBcom/wu1piC1LrDlBPD4rlYSAWAWzUY9+nz X-Received: by 2002:a17:906:af7c:: with SMTP id os28mr16444511ejb.341.1627293312879; Mon, 26 Jul 2021 02:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627293312; cv=none; d=google.com; s=arc-20160816; b=oq4x/utmKsv7KSiYd4FQAhVPV3wCNzTtdsr571Rd9tWYWkmK+7tu4IlXR8EE4mASTQ KN6Md4LUGPgnFTJ4dNV536axVGZAJE61pOqG7g86jAGbvLPRxFcRWuyD4Yx59uGMKqCk rG2V0K54grozMiWW6lkuS+cRi/dF/r5szkKKyMNiLng7RkND3noCl3r2uYdDCE2zLQD8 g2YIr5pF5rHOLa1cjuUqBnO+DwhgzJbOGMwa2Yz3ZCrRcI4wFulgTJbA39ghnX97d+2A wbSrZv7R7k+S/9v9x1OnFXOeKypW1NJ0G5eydo8NeD1CiW3mWJTnItiMKc6SJtjWBuvv aViA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=mo44UZHj7UyEbhGMPjthYrR+6cIV8nYK59wZuJbcwls=; b=BI8Empa6rZXNdmK5dB8+KfqzRxRKnR/sqbo08WQ4Li7LJS69VdrBDRCnL3dCN+VwCO dtow78gTOCqHrmEWTR7zRqml5EnftOHXtz88GoVCEqxElrZs6fClDqlUSYTxvIj0uqGm hiWU3iR26BBBmlvuNm/WR4Dtpq23IHy+EQzziDNUxbpUifANbFzbEuvEUdAMIivV2u75 xvGSvzKeID06/rg/KuaDRYXc8XoWgh8lTiK8143ImoS8ZOUBMMFgDWghfmu5Kcn1wZs+ MiONPG/kiAETiYTFhQ/y38ColqP6197NAL/jTAd+I1lnc4eNX+Tz5L+4hrnAeX5s48xy ILew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v9si3445211ejx.705.2021.07.26.02.54.49; Mon, 26 Jul 2021 02:55:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233132AbhGZJMt (ORCPT + 99 others); Mon, 26 Jul 2021 05:12:49 -0400 Received: from mail-vs1-f54.google.com ([209.85.217.54]:35660 "EHLO mail-vs1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233040AbhGZJMt (ORCPT ); Mon, 26 Jul 2021 05:12:49 -0400 Received: by mail-vs1-f54.google.com with SMTP id p13so4896517vsg.2; Mon, 26 Jul 2021 02:53:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mo44UZHj7UyEbhGMPjthYrR+6cIV8nYK59wZuJbcwls=; b=HgT7Zh+m8LxQ6fsspwMqyvmFuRyAEl+TNC3Lg+FIvfu/Bcm1mCZur3f9yNmpFAHaai JucuO1ei6gPV8eCSRXAU+JiuwItK7V7yM2xVK5TkqF7DZczRMkSCjW1yjvhb/GBq9fIc qF/QkVmliwHslLamKkA10AhHonKxbOED8LuFnGt1bYzpaR6sZIsOKeviPh+ekDgQEI7V ji1nBtmjTuBr0GKyfBzvG3GTxEV3kbf0oWJcq9R9INY4BAONhfguIr15ehnzQW6OnjSF padF1BCs0X0yptruDVDXiJriaul+5iBE3AmpM9ECOmVLU34THI5GGtevWJoNcvV1zSmi vxlA== X-Gm-Message-State: AOAM532OmBMfE3vMjHkIRJICAIAMtSeplElCpP207jNA0dNdgDKmMYSt VIrGp4YtPx5qFAQVT8aecKNXgJsW7NJ9ceCikdY= X-Received: by 2002:a05:6102:2828:: with SMTP id ba8mr11359232vsb.18.1627293196190; Mon, 26 Jul 2021 02:53:16 -0700 (PDT) MIME-Version: 1.0 References: <20210721194951.30983-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20210721194951.30983-3-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: <20210721194951.30983-3-prabhakar.mahadev-lad.rj@bp.renesas.com> From: Geert Uytterhoeven Date: Mon, 26 Jul 2021 11:53:04 +0200 Message-ID: Subject: Re: [PATCH v3 2/3] can: rcar_canfd: Add support for RZ/G2L family To: Lad Prabhakar Cc: Rob Herring , Fabrizio Castro , Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Jakub Kicinski , Philipp Zabel , linux-can@vger.kernel.org, netdev , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List , Linux-Renesas , Prabhakar , Biju Das Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prabhakar, On Wed, Jul 21, 2021 at 9:50 PM Lad Prabhakar wrote: > 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 registers > the irq handlers required for CANFD operation. IRQ numbers are now > fetched based on names instead of indices. For backward compatibility > on non RZ/G2L SoC's we fallback reading based on indices. > > Signed-off-by: Lad Prabhakar Thanks for the update! I think you misunderstood my comment on v1 about the interrupt handlers, cfr. below. > --- a/drivers/net/can/rcar/rcar_canfd.c > +++ b/drivers/net/can/rcar/rcar_canfd.c > @@ -1577,6 +1586,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; > + } > + > + tx_irq = platform_get_irq_byname(pdev, ch == 0 ? "ch0_trx" : "ch1_trx"); > + if (tx_irq < 0) { > + err = tx_irq; > + goto fail; > + } > + > + irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, > + "canfd.ch%d_err", ch); > + if (!irq_name) { > + err = -ENOMEM; > + goto fail; > + } > + err = devm_request_irq(&pdev->dev, err_irq, > + rcar_canfd_channel_interrupt, 0, This is the same interrupt handler... > + irq_name, gpriv); > + if (err) { > + dev_err(&pdev->dev, "devm_request_irq CH Err(%d) failed, error %d\n", > + err_irq, err); > + goto fail; > + } > + irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, > + "canfd.ch%d_trx", ch); > + if (!irq_name) { > + err = -ENOMEM; > + goto fail; > + } > + err = devm_request_irq(&pdev->dev, tx_irq, > + rcar_canfd_channel_interrupt, 0, ... as this one. > + irq_name, gpriv); > + if (err) { > + dev_err(&pdev->dev, "devm_request_irq Tx (%d) failed, error %d\n", > + tx_irq, err); > + goto fail; > + } > + } > + > if (gpriv->fdmode) { > priv->can.bittiming_const = &rcar_canfd_nom_bittiming_const; > priv->can.data_bittiming_const = > @@ -1711,20 +1798,51 @@ static int rcar_canfd_probe(struct platform_device *pdev) > gpriv->base = addr; > > /* Request IRQ that's common for both channels */ > - err = devm_request_irq(&pdev->dev, ch_irq, > - rcar_canfd_channel_interrupt, 0, > - "canfd.chn", gpriv); > - if (err) { > - dev_err(&pdev->dev, "devm_request_irq(%d) failed, error %d\n", > - ch_irq, err); > - goto fail_dev; > + if (gpriv->chip_id == RENESAS_RCAR_GEN3) { > + err = devm_request_irq(&pdev->dev, ch_irq, > + rcar_canfd_channel_interrupt, 0, > + "canfd.ch_int", gpriv); > + if (err) { > + dev_err(&pdev->dev, "devm_request_irq(%d) failed, error %d\n", > + ch_irq, err); > + goto fail_dev; > + } > + > + err = devm_request_irq(&pdev->dev, g_irq, > + rcar_canfd_global_interrupt, 0, > + "canfd.g_int", gpriv); > + if (err) { > + dev_err(&pdev->dev, "devm_request_irq(%d) failed, error %d\n", > + g_irq, err); > + goto fail_dev; > + } > + } else { > + err = devm_request_irq(&pdev->dev, g_recc_irq, > + rcar_canfd_global_interrupt, 0, This is the same interrupt handler... > + "canfd.g_recc", gpriv); > + > + if (err) { > + dev_err(&pdev->dev, "devm_request_irq(%d) failed, error %d\n", > + g_recc_irq, err); > + goto fail_dev; > + } > + > + err = devm_request_irq(&pdev->dev, g_err_irq, > + rcar_canfd_global_interrupt, 0, ... as this one. > + "canfd.g_err", gpriv); > + if (err) { > + dev_err(&pdev->dev, "devm_request_irq(%d) failed, error %d\n", > + g_err_irq, err); > + goto fail_dev; > + } > } > - err = devm_request_irq(&pdev->dev, g_irq, > - rcar_canfd_global_interrupt, 0, > - "canfd.gbl", gpriv); > + > + 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 did not object to having fine-grained interrupt handlers on RZ/G2L. I did object to duplicating code in global and fine-grained interrupt handlers. The trick to have both is to let the global interrupt handlers call (conditionally) into the fine-grained handlers. In pseudo-code: global_interrupt_handler() { if (...) fine_grained_handler1(); if (...) fine_grained_handler2(); ... } On R-Car Gen3, you register the global interrupt handlers, as before. On RZ/G2L, you register the fine-grained interrupt handlers instead. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds