Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp358576ybl; Fri, 24 Jan 2020 01:34:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxj/4S2C8JH/ewECzMYu3fx+IKIMMIk8rOIZeoFOxJoTihSFo5csIrXvx5BB1g/tlCxRaP3 X-Received: by 2002:a9d:66c1:: with SMTP id t1mr1848511otm.73.1579858458092; Fri, 24 Jan 2020 01:34:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579858458; cv=none; d=google.com; s=arc-20160816; b=T5+TvjPK7/4w3En5NQk9g9olCeKeHC9/0yCBy/iMLHg8Bl0STExPsnckZoz9u+gH6a tGtcrTxX+i6GqBLlRc3aKBnyH8aA4ufXjJM6hN/IvnP6Wk7qlIDGm0hV+aEe71vYoasl JYXlbqa8VcD7chzIeqvF03H/+paiXvajuO4g1RdcCXAvC+wtvmX/0e8MKmhsfmIRfXD/ p/qKxKKEoaMZUgU7kukfKNJi5MRtVa74+N63WnGLNS3Er/jWpGU/Jyoilt0mNAWk/1Zl /93LUVeWkXRNaz0OvK7QdAi30gUkRz+SPSSi2V5OgslgJ6Iwh0N6md80GGGfcY5kh8Tx QpNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=7aoEWgOMrsENsyCSERE4iOvClQ10ZBvAeKGx7j04F0Y=; b=d8UVhmgMo56X1AyA/EpCD6CrK1/gEM9zGJ3xfzxX9ZFtm77md8jPTUbS5eFSBAg6S7 RICHTwPAa8NPE+aKUmTZLMVLTFNrcOZEKGrlbQ1MhcXCVYqA3QSVsB2WSPUcVsoosPEE tEOoXQyLsR4cq8bnQFCrHABO2Vz2iYim0iVxly3pUkiUJUUiNql/1XTsrb219d/wASON eYCUEKSExd7DMV7jU3wGcTuI3n/VKkZ/Zz2/m/ch4UXeqRRqbq6v2x9pe4BFuNURGw7Q /NxvPzk3EocdVhbKRkTRxmPL2lZDn7ZT5rKYc0eGvbcaZ6/S9g3+iC3X/bU/7/ZJQPVN af9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=QwVgTRUk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l204si2104040oif.261.2020.01.24.01.34.06; Fri, 24 Jan 2020 01:34:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=QwVgTRUk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729623AbgAXJHd (ORCPT + 99 others); Fri, 24 Jan 2020 04:07:33 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:8311 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbgAXJHd (ORCPT ); Fri, 24 Jan 2020 04:07:33 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 24 Jan 2020 01:06:46 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 24 Jan 2020 01:07:32 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 24 Jan 2020 01:07:32 -0800 Received: from [10.21.133.51] (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 24 Jan 2020 09:07:24 +0000 Subject: Re: [alsa-devel] [PATCH 4/9] ASoC: tegra: add Tegra210 based I2S driver To: Dmitry Osipenko , Sameer Pujar CC: , , , , , , , , , , , , , , References: <1579530198-13431-1-git-send-email-spujar@nvidia.com> <1579530198-13431-5-git-send-email-spujar@nvidia.com> <0c571858-d72c-97c2-2d6a-ead6fdde06eb@nvidia.com> <444731da-c4cd-8578-a732-c803eef31ef0@gmail.com> <598fe377-5b95-d30a-eb64-89a645166d42@gmail.com> <3f51939d-cf4b-f69b-728a-7eb99bbae458@nvidia.com> <34ac1fd3-ae0f-07f2-555f-a55087a2c9dc@nvidia.com> <1a84b393-938f-8bed-d08e-cc3bb6ed4844@gmail.com> <0fc814c2-0dc6-7741-b954-463381ff7fb9@nvidia.com> From: Jon Hunter Message-ID: <9f73afdf-1e9a-cdbd-f972-a022d503ef51@nvidia.com> Date: Fri, 24 Jan 2020 09:07:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1579856806; bh=7aoEWgOMrsENsyCSERE4iOvClQ10ZBvAeKGx7j04F0Y=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=QwVgTRUkTeKYuVdIF7IWb8Lx6v4QxDRL3CI5bRnrYOJwXFYDVgMmPs5XFiEQ0Qfk4 wqx0DGl28wvYoC4xC0tkZah++mlIsfR8UrL12MvIgBntdJ0oA57208JrBcXNZRb2xF bxrjLt4MAxLDlMn5/rcnn5er2CGH8stTdmDBAOImYAtrUnk2DOBgU7xWuuOyBrqesr rOkiqEckCbQJwpbwZgu+MuDnK2VVPRFAAitb253LPKwCb3SFyUV1vjYzXrw2hosS7R MZciu+P9Zy8jm+skB8HZ97Q2LK9OiU77dRSKfnIM4aQj72Mnb7bHsjN/hOgGr6jHGA KVmJjRE4Uf0dA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/01/2020 15:16, Dmitry Osipenko wrote: > 23.01.2020 12:22, Sameer Pujar =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> >> >> On 1/22/2020 9:57 PM, Dmitry Osipenko wrote: >>> External email: Use caution opening links or attachments >>> >>> >>> 22.01.2020 14:52, Jon Hunter =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >>>> On 22/01/2020 07:16, Sameer Pujar wrote: >>>> >>>> ... >>>> >>>>>>>>>>> +static int tegra210_i2s_remove(struct platform_device *pdev) >>>>>>>>>>> +{ >>>>>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0 pm_runtime_disable(&pdev->dev); >>>>>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0 if (!pm_runtime_status_suspended(&pde= v->dev)) >>>>>>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 tegra210_i2s_runtime_suspend(&pdev->dev); >>>>>>>>>> This breaks device's RPM refcounting if it was disabled in the >>>>>>>>>> active >>>>>>>>>> state. This code should be removed. At most you could warn >>>>>>>>>> about the >>>>>>>>>> unxpected RPM state here, but it shouldn't be necessary. >>>>>>>>> I guess this was added for safety and explicit suspend keeps cloc= k >>>>>>>>> disabled. >>>>>>>>> Not sure if ref-counting of the device matters when runtime PM is >>>>>>>>> disabled and device is removed. >>>>>>>>> I see few drivers using this way. >>>>>>>> It should matter (if I'm not missing something) because RPM should >>>>>>>> be in >>>>>>>> a wrecked state once you'll try to re-load the driver's module. >>>>>>>> Likely >>>>>>>> that those few other drivers are wrong. >>>>>>>> >>>>>>>> [snip] >>>>>>> Once the driver is re-loaded and RPM is enabled, I don't think it >>>>>>> would use >>>>>>> the same 'dev' and the corresponding ref count. Doesn't it use the >>>>>>> new >>>>>>> counters? >>>>>>> If RPM is not working for some reason, most likely it would be the >>>>>>> case >>>>>>> for other >>>>>>> devices. What best driver can do is probably do a force suspend >>>>>>> during >>>>>>> removal if >>>>>>> already not done. I would prefer to keep, since multiple drivers >>>>>>> still >>>>>>> have it, >>>>>>> unless there is a real harm in doing so. >>>>>> I took a closer look and looks like the counter actually should be >>>>>> reset. Still I don't think that it's a good practice to make changes >>>>>> underneath of RPM, it may strike back. >>>>> If RPM is broken, it probably would have been caught during device >>>>> usage. >>>>> I will remove explicit suspend here if no any concerns from other >>>>> folks. >>>>> Thanks. >>>> I recall that this was the preferred way of doing this from the RPM >>>> folks. Tegra30 I2S driver does the same and Stephen had pointed me to >>>> this as a reference. >>>> I believe that this is meant to ensure that the >>>> device is always powered-off regardless of it RPM is enabled or not an= d >>>> what the current state is. >>> Yes, it was kinda actual for the case of unavailable RPM. >> >>> Anyways, /I think/ variant like this should have been more preferred: >>> >>> if (!pm_runtime_enabled(&pdev->dev)) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tegra210_i2s_runtime_s= uspend(&pdev->dev); >>> else >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pm_runtime_disable(&pd= ev->dev); >> >> I think it looks to be similar to what is there already. >> >> pm_runtime_disable(&pdev->dev); // it would turn out to be a dummy call >> if !RPM >> if (!pm_runtime_status_suspended(&pdev->dev)) // it is true always if !R= PM >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tegra210_i2s_runtime_suspend(= &pdev->dev); >=20 > Maybe this is fine for !RPM, but not really fine in a case of enabled > RPM. Device could be in resumed state after pm_runtime_disable() if it > wasn't suspended before the disabling. I don't see any problem with this for the !RPM case. Jon --=20 nvpublic