Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp918344pxb; Wed, 3 Mar 2021 21:01:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZYU/iy9a3b4Tia7T+dljLNMS2CRUp0X1MJo5kQhGv69ItcgAFY0vT5bSofduh4C++GNqj X-Received: by 2002:a17:906:3750:: with SMTP id e16mr2256854ejc.75.1614834105003; Wed, 03 Mar 2021 21:01:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614834104; cv=none; d=google.com; s=arc-20160816; b=FOaetxJ4KIQ+5zvy55ZG9sdUzAfUK+B4Tz/oQOxcY6juZLF5RObOiLI6Jwb+z7Db5s NqUFxTsJUugYJVlKSRcby5Df2paqbaMS2h49KR11oxrketFTQLp3DlC51UV9A47p2FZS 8hIDykoS3FuPrHwu2oRewaNOxZF8GkJGegpZ5iqghR3A0Buu2ACTjcfjNyuaLpTP4Ebm cSESSQkiKmxYqYgrGCkC+AlVSzBoopSzniwuzuL8e1rqbT0jIrq1mXe3fR45otSxFYiY 2ScsGoUtQQqnn3TMwUQCtIymKP+SmUHxp5WiMIR6dErYnxogJB8g+k/AWeixqnpt4Q5j RV6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=LZHv/SE4BqMSsdCZN44qIZS7sFWYDv/b7ji/+j9/gTk=; b=CiDR/5BlheFEntZjHzuXXTxnPxFsYFjEWVRhQK584D7qBbZF0MsDtK86CNcQIMaeQy 8UCIoM7w20LI4DINw51XejWe5pckK+o2bMZFfDVDMa1vcY8u7EUumWvL/CuG7+Rs0WX+ iF0nfA0IYcel3zW/NbKowx85bsdYE+QZQ0NhiuKwENBFwc17QZe5+ukGPO3wX1/LU7l9 N9Svw1vC+T0G8lCBcqohNe5k8/GxoXT3Zz1red2tlMoh3VFZqcK24ElqzekDRhIwEZSY akxF2yWfvAx3AS/YmpNgEKSmpFHs3sMNOh3ESq95vpVguZD89VEcwY/bIvXXkC9vNgO3 U3/A== 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 o7si7072509edr.131.2021.03.03.21.01.22; Wed, 03 Mar 2021 21:01:44 -0800 (PST) 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 S1443842AbhCBChM (ORCPT + 99 others); Mon, 1 Mar 2021 21:37:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242179AbhCATwr (ORCPT ); Mon, 1 Mar 2021 14:52:47 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14D63C0617A9 for ; Mon, 1 Mar 2021 11:49:29 -0800 (PST) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lGoXg-0000JP-4c; Mon, 01 Mar 2021 20:49:20 +0100 Received: from pengutronix.de (unknown [IPv6:2a03:f580:87bc:d400:6e66:a1a4:a449:44cd]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 75B5A5EB9BE; Mon, 1 Mar 2021 15:08:41 +0000 (UTC) Date: Mon, 1 Mar 2021 16:08:40 +0100 From: Marc Kleine-Budde To: Tong Zhang Cc: Wolfgang Grandegger , "David S. Miller" , Jakub Kicinski , Vincent Mailhol , Oliver Hartkopp , YueHaibing , Zhang Qilong , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] can: c_can: move runtime PM enable/disable to c_can_platform Message-ID: <20210301150840.mqngl7og46o3nxjb@pengutronix.de> References: <20210301041550.795500-1-ztong0001@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5wy4kny7riwtnmwo" Content-Disposition: inline In-Reply-To: <20210301041550.795500-1-ztong0001@gmail.com> X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --5wy4kny7riwtnmwo Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 28.02.2021 23:15:48, Tong Zhang wrote: > Currently doing modprobe c_can_pci will make kernel complain > "Unbalanced pm_runtime_enable!", this is caused by pm_runtime_enable() > called before pm is initialized in register_candev() and doing so will I don't see where register_candev() is doing any pm related initialization. > also cause it to enable twice. > This fix is similar to 227619c3ff7c, move those pm_enable/disable code to > c_can_platform. As I understand 227619c3ff7c ("can: m_can: move runtime PM enable/disable to m_can_platform"), PCI devices automatically enable PM, when the "PCI device is added". Please clarify the above point, otherwise the code looks OK, small nitpick inline: > Signed-off-by: Tong Zhang > --- > drivers/net/can/c_can/c_can.c | 26 ++------------------------ > drivers/net/can/c_can/c_can_platform.c | 6 +++++- > 2 files changed, 7 insertions(+), 25 deletions(-) >=20 > diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c > index ef474bae47a1..04f783b3d9d3 100644 > --- a/drivers/net/can/c_can/c_can.c > +++ b/drivers/net/can/c_can/c_can.c > @@ -212,18 +212,6 @@ static const struct can_bittiming_const c_can_bittim= ing_const =3D { > .brp_inc =3D 1, > }; > =20 > -static inline void c_can_pm_runtime_enable(const struct c_can_priv *priv) > -{ > - if (priv->device) > - pm_runtime_enable(priv->device); > -} > - > -static inline void c_can_pm_runtime_disable(const struct c_can_priv *pri= v) > -{ > - if (priv->device) > - pm_runtime_disable(priv->device); > -} > - > static inline void c_can_pm_runtime_get_sync(const struct c_can_priv *pr= iv) > { > if (priv->device) > @@ -1335,7 +1323,6 @@ static const struct net_device_ops c_can_netdev_ops= =3D { > =20 > int register_c_can_dev(struct net_device *dev) > { > - struct c_can_priv *priv =3D netdev_priv(dev); > int err; > =20 > /* Deactivate pins to prevent DRA7 DCAN IP from being > @@ -1345,28 +1332,19 @@ int register_c_can_dev(struct net_device *dev) > */ > pinctrl_pm_select_sleep_state(dev->dev.parent); > =20 > - c_can_pm_runtime_enable(priv); > - > dev->flags |=3D IFF_ECHO; /* we support local echo */ > dev->netdev_ops =3D &c_can_netdev_ops; > =20 > err =3D register_candev(dev); > - if (err) > - c_can_pm_runtime_disable(priv); > - else > - devm_can_led_init(dev); > - > + if (!err) > + devm_can_led_init(dev); Please indent with two tabs here. regards, Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | --5wy4kny7riwtnmwo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEK3kIWJt9yTYMP3ehqclaivrt76kFAmA9A3YACgkQqclaivrt 76nuYgf/ZDCBnW3yY+g2dIjUY3j7qA4gy93sa/gHteqCR7eDyuE22thYiSfZ9r2G 3bTT1g75I/ikzX8VPV1aSzw1Wu5qgCIkf1yS2cK0Mtq3kFObNRYLomdf1hcFskDk sTC1/5+DOGvNQ7sxE9QBXFRMhzCGtAAUllXdQpTPeA9pSSedBkNclVuRHZ9stx54 JkenoFPsIxrGOQrZUCXu3/NSbx6aYW6s7JtKdb5FEo8ZfXj7CZNg9aK5InI/zzGs HiiEItzRAxodwho2bvRtdhqv5UgRj4uzuHPBVX7BJdA61GEgvtA6RL74tRj0muyG cfiCgOIIC+ZZ0VpanLKxz1+OxGg+6w== =zNL/ -----END PGP SIGNATURE----- --5wy4kny7riwtnmwo--