Message ID | 20221122105455.39294-2-vivek.2311@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2605907wrr; Tue, 22 Nov 2022 21:35:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf63/rRyFJNsV3tfbE8H1VJNHLE9qf03CsU8OSqBTIY+C0jc00qJ1xEX4WViPxk3CrzKGr7k X-Received: by 2002:a17:906:d1c7:b0:7ad:fd3e:7762 with SMTP id bs7-20020a170906d1c700b007adfd3e7762mr7887498ejb.717.1669181714938; Tue, 22 Nov 2022 21:35:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669181714; cv=none; d=google.com; s=arc-20160816; b=Be8LcJlqH0SzrVHjlFhJ2DPnJEqAH9fytA1j3rGNqodGYBNcfrDohkC03ZDS8vwDso i14mE757ft2zCSV7Kn7VLdAd0eDmeJM7RWYGgcq3i6+NYZrT0qY4R1nVs5dr0GZXdDn6 bVZcrk2okMgCaHp6MAvdaYQYqWbgVYsab9K52C0K79IPkaacNSuXDcO8b19aW4u2Hr1m HM0ITa9bASFr2bftKquX1S9cerroFCh7hM2bkxIJjzTh05JIgyLp+VTw/3mYckL2/lGI kKOiFzsuSd6+LoeYDI2GyqqgHrUW7nGlaI6XIP4WfZCvYQi/xaR1VfcLQQ9pCshz6/Ou hc/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=uNgkOuD3RPHcSBkSiq6pg/mVd4Fv7cnPoyYY63AMJPU=; b=fuW9QeoGj5Co12XcVp8y+QdEhl4dDFfZB03nyy3PZ6IMu/HkOkXbqIwvGgoAahaFOK BnDqOYfDoJ1YsGJWiCmuIquXyaBxnX1sX5+/mOS1dtmc7duoz73hJj8OGlE2JltxZMow LPYTUSFPdPoz6JpTrIFr+GWdkuEzYwnZZeXdD1gYK0awX5v6ZPEeBkZdzIolnGen31Md 8qyR+1+sNriFLPTt5HskxP3UE5Kzfw9wZeT14DAbSgfTp6TU+vbwaFKDtDOpDJ2VThcU 2UCKfrmc+wTDIP/F02hpnVQ270pYbuIBpzUUXOYtaD2FQJ/Drmh1maHTyQQyF9qQXZF7 WUNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=jRC1OQVw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz35-20020a1709077da300b007b5ce4a4360si8235222ejc.151.2022.11.22.21.34.51; Tue, 22 Nov 2022 21:35:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=jRC1OQVw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235823AbiKWFbH (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Wed, 23 Nov 2022 00:31:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235741AbiKWFbC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 23 Nov 2022 00:31:02 -0500 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BB2CED714 for <linux-kernel@vger.kernel.org>; Tue, 22 Nov 2022 21:30:56 -0800 (PST) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20221123053054epoutp0397fa8e4ee93c68764afe492473adef93~qH7CGHno60030700307epoutp032 for <linux-kernel@vger.kernel.org>; Wed, 23 Nov 2022 05:30:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20221123053054epoutp0397fa8e4ee93c68764afe492473adef93~qH7CGHno60030700307epoutp032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1669181454; bh=uNgkOuD3RPHcSBkSiq6pg/mVd4Fv7cnPoyYY63AMJPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jRC1OQVwG8SXLa5jAG+w5IgGefdc/fMBXKMa+lWJJR0v5Ip2YBNBCGzPv1ISN5vcT IlUfI3IP67yx31JOOp6Ye2CEP6la9p80mXvyXo5NQMgLtk88SOUiagHOsGTowlRMdt ltvL8EESgLh34hwZKLgzT6B6s4B32skUDwxTzohA= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20221123053054epcas5p314c5706d2a650b1ccb7e7046bde2854e~qH7BWnxEq2606226062epcas5p3Z; Wed, 23 Nov 2022 05:30:54 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.181]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4NH8qH2Nsvz4x9QL; Wed, 23 Nov 2022 05:30:51 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 9A.FF.39477.B00BD736; Wed, 23 Nov 2022 14:30:51 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20221122105022epcas5p3f5db1c5790b605bac8d319fe06ad915b~p4orKHLp42891928919epcas5p3H; Tue, 22 Nov 2022 10:50:22 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20221122105022epsmtrp2b68721a6754af3ac3845ff1df5c78888~p4orIvhDV3232832328epsmtrp2S; Tue, 22 Nov 2022 10:50:22 +0000 (GMT) X-AuditID: b6c32a4a-259fb70000019a35-f1-637db00bd847 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 09.72.14392.E69AC736; Tue, 22 Nov 2022 19:50:22 +0900 (KST) Received: from cheetah.sa.corp.samsungelectronics.net (unknown [107.109.115.53]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20221122105019epsmtip1b22090c23b59f16edbbbe6ac857a6127~p4ooOtWSA0765207652epsmtip1b; Tue, 22 Nov 2022 10:50:19 +0000 (GMT) From: Vivek Yadav <vivek.2311@samsung.com> To: rcsekar@samsung.com, krzysztof.kozlowski+dt@linaro.org, wg@grandegger.com, mkl@pengutronix.de, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pankaj.dubey@samsung.com, ravi.patel@samsung.com, alim.akhtar@samsung.com, linux-fsd@tesla.com, robh+dt@kernel.org Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, aswani.reddy@samsung.com, sriranjani.p@samsung.com, Vivek Yadav <vivek.2311@samsung.com> Subject: [PATCH v3 1/2] can: m_can: Move mram init to mcan device setup Date: Tue, 22 Nov 2022 16:24:54 +0530 Message-Id: <20221122105455.39294-2-vivek.2311@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221122105455.39294-1-vivek.2311@sams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YqEQM+jXNrmWMePY26Htoh/nBH+er1gj8qHNND55vMDJ7xsHbdyY+b/3zffeuh 3wS/Ob+zJv3ufPGw0cXdnn1yUf3i55dW/tl3Sv0n5+0FZ+N38p9/m8z74M7kFXmBOe6Sun+L CsO385Ub7W6LPBOS2/t3I9dh9xCepUdWOSeY7DdmrQ9oltt+JU/mTM66Axd0rGVLNXi/ymik TI2ZfzLxlc6V2xynf8dMezrjwR2nN2wzNZRmrnN7futwyLYYvk97L99b0LVx5mvWeBExZq7Q sMeNq7wiSxUWBmX9nbNRiaU4I9FQi7moOBEAm1k9ARADAAA= X-CMS-MailID: 20221122105022epcas5p3f5db1c5790b605bac8d319fe06ad915b X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20221122105022epcas5p3f5db1c5790b605bac8d319fe06ad915b References: <20221122105455.39294-1-vivek.2311@samsung.com> <CGME20221122105022epcas5p3f5db1c5790b605bac8d319fe06ad915b@epcas5p3.samsung.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750263885673412901?= X-GMAIL-MSGID: =?utf-8?q?1750263885673412901?= |
Series |
can: mcan: Add MCAN support for FSD SoC
|
|
Commit Message
Vivek Yadav
Nov. 22, 2022, 10:54 a.m. UTC
When we try to access the mcan message ram addresses, hclk is gated by any other drivers or disabled, because of that probe gets failed. Move the mram init functionality to mcan device setup called by mcan class register from mcan probe function, by that time clocks are enabled. Signed-off-by: Chandrasekar R <rcsekar@samsung.com> Signed-off-by: Vivek Yadav <vivek.2311@samsung.com> --- drivers/net/can/m_can/m_can.c | 4 ++-- drivers/net/can/m_can/m_can.h | 1 + drivers/net/can/m_can/m_can_platform.c | 21 +++++++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-)
Comments
On 22.11.2022 16:24:54, Vivek Yadav wrote: > When we try to access the mcan message ram addresses, hclk is > gated by any other drivers or disabled, because of that probe gets > failed. > > Move the mram init functionality to mcan device setup called by > mcan class register from mcan probe function, by that time clocks > are enabled. Why not call the RAM init directly from m_can_chip_config()? Marc
> -----Original Message----- > From: Marc Kleine-Budde <mkl@pengutronix.de> > Sent: 24 November 2022 04:12 > To: Vivek Yadav <vivek.2311@samsung.com> > Cc: rcsekar@samsung.com; krzysztof.kozlowski+dt@linaro.org; > wg@grandegger.com; davem@davemloft.net; edumazet@google.com; > kuba@kernel.org; pabeni@redhat.com; pankaj.dubey@samsung.com; > ravi.patel@samsung.com; alim.akhtar@samsung.com; linux-fsd@tesla.com; > robh+dt@kernel.org; linux-can@vger.kernel.org; netdev@vger.kernel.org; > linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux- > samsung-soc@vger.kernel.org; devicetree@vger.kernel.org; > aswani.reddy@samsung.com; sriranjani.p@samsung.com > Subject: Re: [PATCH v3 1/2] can: m_can: Move mram init to mcan device > setup > > On 22.11.2022 16:24:54, Vivek Yadav wrote: > > When we try to access the mcan message ram addresses, hclk is gated by > > any other drivers or disabled, because of that probe gets failed. > > > > Move the mram init functionality to mcan device setup called by mcan > > class register from mcan probe function, by that time clocks are > > enabled. > > Why not call the RAM init directly from m_can_chip_config()? > m_can_chip_config function is called from m_can open. Configuring RAM init every time we open the CAN instance is not needed, I think only once during the probe is enough. If message RAM init failed then fifo Transmit and receive will fail and there will be no communication. So there is no point to "open and Configure CAN chip". From my understanding it's better to keep RAM init inside the probe and if there is a failure happened goes to CAN probe failure. > Marc Thanks for reviewing the patch. > > -- > Pengutronix e.K. | Marc Kleine-Budde | > Embedded Linux | > https://protect2.fireeye.com/v1/url?k=818c3690-e0f1dc13-818dbddf- > 74fe48600158-a08b6a4bfa0b043e&q=1&e=315ed8d1-1645-4c16-b5e7- > 2a250ae36941&u=https%3A%2F%2Fwww.pengutronix.de%2F | > Vertretung West/Dortmund | Phone: +49-231-2826-924 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On 24.11.2022 14:36:48, Vivek Yadav wrote: > > Why not call the RAM init directly from m_can_chip_config()? > > > m_can_chip_config function is called from m_can open. > > Configuring RAM init every time we open the CAN instance is not > needed, I think only once during the probe is enough. That probably depends on you power management. If I add a regulator to power the external tcan4x5x chip and power it up during open(), I need to initialize the RAM. > If message RAM init failed then fifo Transmit and receive will fail > and there will be no communication. So there is no point to "open and > Configure CAN chip". For mmio devices the RAM init will probably not fail. There are return values and error checking for the SPI attached devices. Where the SPI communication will fail. However if this is problem, I assume the chip will not be detected in the first place. > From my understanding it's better to keep RAM init inside the probe > and if there is a failure happened goes to CAN probe failure. Marc
> -----Original Message----- > From: Marc Kleine-Budde <mkl@pengutronix.de> > Sent: 24 November 2022 20:24 > To: Vivek Yadav <vivek.2311@samsung.com> > Cc: rcsekar@samsung.com; krzysztof.kozlowski+dt@linaro.org; > wg@grandegger.com; davem@davemloft.net; edumazet@google.com; > kuba@kernel.org; pabeni@redhat.com; pankaj.dubey@samsung.com; > ravi.patel@samsung.com; alim.akhtar@samsung.com; linux-fsd@tesla.com; > robh+dt@kernel.org; linux-can@vger.kernel.org; netdev@vger.kernel.org; > linux-kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux- > samsung-soc@vger.kernel.org; devicetree@vger.kernel.org; > aswani.reddy@samsung.com; sriranjani.p@samsung.com > Subject: Re: RE: [PATCH v3 1/2] can: m_can: Move mram init to mcan device > setup > > On 24.11.2022 14:36:48, Vivek Yadav wrote: > > > Why not call the RAM init directly from m_can_chip_config()? > > > > > m_can_chip_config function is called from m_can open. > > > > Configuring RAM init every time we open the CAN instance is not > > needed, I think only once during the probe is enough. > > That probably depends on you power management. If I add a regulator to > power the external tcan4x5x chip and power it up during open(), I need to > initialize the RAM. > Thanks for the clarification, There is one doubt for which I need clarity if I add ram init in m_can_chip_config. In the current implementation, m_can_ram_init is added in the probe and m_can_class_resume function. If I add the ram init function in chip_config which is getting called from m_can_start, then m_can_init_ram will be called two times, once in resume and next from m_can_start also. Can we add ram init inside the m_can_open function itself? Because it is independent of m_can resume functionality. > > If message RAM init failed then fifo Transmit and receive will fail > > and there will be no communication. So there is no point to "open and > > Configure CAN chip". > > For mmio devices the RAM init will probably not fail. There are return values > and error checking for the SPI attached devices. Where the SPI > communication will fail. However if this is problem, I assume the chip will not > be detected in the first place. > > > From my understanding it's better to keep RAM init inside the probe > > and if there is a failure happened goes to CAN probe failure. > > Marc > > -- > Pengutronix e.K. | Marc Kleine-Budde | > Embedded Linux | > https://protect2.fireeye.com/v1/url?k=2053d9ab-7fc8e0b4-205252e4- > 000babdfecba-a8c309c53e3358f5&q=1&e=c0cfd0e2-a422-4821-a49d- > 113cfa4da9cb&u=https%3A%2F%2Fwww.pengutronix.de%2F | > Vertretung West/Dortmund | Phone: +49-231-2826-924 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On 01.12.2022 09:40:50, Vivek Yadav wrote: > > That probably depends on you power management. If I add a regulator > > to power the external tcan4x5x chip and power it up during open(), I > > need to initialize the RAM. > > > Thanks for the clarification, > > There is one doubt for which I need clarity if I add ram init in > m_can_chip_config. > > In the current implementation, m_can_ram_init is added in the probe > and m_can_class_resume function. > > If I add the ram init function in chip_config which is getting called > from m_can_start, then m_can_init_ram will be called two times, once > in resume and next from m_can_start also. As m_can_start() is called from resume, remove the direct call to m_can_init_ram() from m_can_class_resume(). > Can we add ram init inside the m_can_open function itself? Because it > is independent of m_can resume functionality. See above. mainline implementation: m_can_class_resume() -> m_can_init_ram() m_can_open() -> m_can_start() -> m_can_chip_config() -> ops->init m_can_init_ram() (for tcan only) proposed: m_can_class_resume() -> m_can_start() -> m_can_chip_config() -> m_can_init_ram() m_can_open() -> m_can_start() -> m_can_chip_config() -> m_can_init_ram() In mainline m_can_init_ram() is called for the tcan during open(). So if you call m_can_init_ram() from m_can_chip_config(), remove it from the tcan's tcan4x5x_init() functions, and from m_can_class_resume() it should only be called once for open and once for resume. regards, Marc
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index a776cab1a5a4..5956f0b4d5b1 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1516,9 +1516,9 @@ static int m_can_dev_setup(struct m_can_classdev *cdev) } if (cdev->ops->init) - cdev->ops->init(cdev); + err = cdev->ops->init(cdev); - return 0; + return err; } static void m_can_stop(struct net_device *dev) diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index 401410022823..c6e77b93f4a2 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -93,6 +93,7 @@ struct m_can_classdev { int is_peripheral; struct mram_cfg mcfg[MRAM_CFG_NUM]; + bool mram_cfg_flag; }; struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, int sizeof_priv); diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c index b5a5bedb3116..1a65b0d256fb 100644 --- a/drivers/net/can/m_can/m_can_platform.c +++ b/drivers/net/can/m_can/m_can_platform.c @@ -67,11 +67,28 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset, return 0; } +static int plat_init(struct m_can_classdev *cdev) +{ + int ret = 0; + + if (!cdev->mram_cfg_flag) { + /* Initialize mcan message ram */ + ret = m_can_init_ram(cdev); + if (ret) + return ret; + + cdev->mram_cfg_flag = true; + } + + return 0; +} + static struct m_can_ops m_can_plat_ops = { .read_reg = iomap_read_reg, .write_reg = iomap_write_reg, .write_fifo = iomap_write_fifo, .read_fifo = iomap_read_fifo, + .init = plat_init, }; static int m_can_plat_probe(struct platform_device *pdev) @@ -140,10 +157,6 @@ static int m_can_plat_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mcan_class); - ret = m_can_init_ram(mcan_class); - if (ret) - goto probe_fail; - pm_runtime_enable(mcan_class->dev); ret = m_can_class_register(mcan_class); if (ret)