Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5000237ybl; Wed, 22 Jan 2020 08:28:26 -0800 (PST) X-Google-Smtp-Source: APXvYqyfVsNwNV6QRL2VCXJur4P6MzTWZ2c3v0hLj+QsepoPSPAZM43174bHwl6wwbdvIo36tB7K X-Received: by 2002:aca:d985:: with SMTP id q127mr7196158oig.132.1579710506404; Wed, 22 Jan 2020 08:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579710506; cv=none; d=google.com; s=arc-20160816; b=SfyeV6nXVzci4dHdrFi7KWDuty72h3gCNyh07jV33SYtyt/PlU3iNN1VniJx6qpmrc 8b/L8I0L2ut48OlOAYM8OD6ch53xVqfjt5utNrwxVuXlHqKRNurskptCjzLbE8DEBEgA 8FX0a0Y1szW/0UGUWPk/+WOmogGsx0r2tuTvbdiKNPdNdtKSA32Ks1uvSghM4aCNPuj3 qAuhzNeUuOXikIoBHp0TWmfRT50p9QAk7LLZWswPHQau9G3GN0FFE1Ol46eENCOa1xr0 EbSSfzsoeM+ZPbhpeMafvYSRefS9K61DXg3bfSjoXdoRA5qmzzkASdA8NQJqfv+w3mmJ +UIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=gyeCH9xGtCulfFDHcJD6zCd/sMhVJQbBdrtw8jLxavk=; b=gRXQsS4xsLmrq6wHIbqOw8KLmM1+QXcQlOBSKNiF9jE8jw+P3SrzBcKZ0N5o9xAa3N tlhcdhrDwztbs7l75gja9kgQ+Cn1P1XvqNTXDEE4fAt2R4jjEBCxRgh3y5YlrMiGGmRZ bF22oM4f/7lgjReOwvsU0g4MVxsW/HsvczZaGkOu6dAqIvWZ6JWnkCCcTEmYz0mESnra BNyjy4DwzF7ssTxPOTCMKbEyH7h5blN24OZ/ls9LKVwcPOU0pCi+sHHwZs2lz4cDmkz9 NTEi3iL2r+iTcIckKHUyHKnwRtmsORRKhoek3xZ0DdRcE5f+03NmShDuI6qFGNtlmZgn r5lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uEtDzy3t; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g138si22399265oib.190.2020.01.22.08.28.12; Wed, 22 Jan 2020 08:28:26 -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=@gmail.com header.s=20161025 header.b=uEtDzy3t; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726181AbgAVQ1P (ORCPT + 99 others); Wed, 22 Jan 2020 11:27:15 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38683 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbgAVQ1P (ORCPT ); Wed, 22 Jan 2020 11:27:15 -0500 Received: by mail-lj1-f193.google.com with SMTP id w1so7528199ljh.5; Wed, 22 Jan 2020 08:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gyeCH9xGtCulfFDHcJD6zCd/sMhVJQbBdrtw8jLxavk=; b=uEtDzy3tbP7MsHzt2WKoG6BRGtVK2Z09+1dHcrHzh7vZ/n9aqi1sVDPUD3jFHn/Fak F04w2Be300xT1Wx9qQWla58A82e78mL8ujsvwUrQq+oj4K6OunfdG9EtvpK8NYBJh/L0 XOr/kW9OKoX6OmBudv8C7Mh0sOCUmprEq3fAaq3d+SiTbM6c1ZyVYhQzrM7VkJ5/odPb 8Rj/S+FEGevAfVKwXP01EgXi479QiOacmP4NlP07jWCULhAGUX8DQaH4y5qGVMIlEq9v k2Oi6GXjQM/KI6+j5t+opM27PQ7WBcmP36lECVtZ+5iF5NiPpzqWtgjrUjlPIT/TZCXg /QuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=gyeCH9xGtCulfFDHcJD6zCd/sMhVJQbBdrtw8jLxavk=; b=FZ7mq6kYJJIIUx3/08muYuK9Lcprf5e78RPU27BEVf9XbuV/Zt+7iEE1HxCrWGzN4+ wOd7o3I/ORH81TzF3DUU9VKQgV+k9fQtvX8l7NwETPehQxWQW6IwfFKYcHcBw2dOLF1p jHS4Rgf0on9ObbYVK0Viu4STZ/k2Z5Y9wgZ1sHSCvRG9eI9n6DXXnLr6+30KJIlzy0z8 hnsf7nZ3Wx/V59Jd1C0b3GsMQT/xFeMd9f66tmbRk2c1l/leif1YdpyN2LCMBarKVzoO CfxHaa4PketyMcTAYFNK4nu96whGfkb8KJqlp5ClbpzXsKdcrotHbEDsDtXCDQoZFEsP eWqw== X-Gm-Message-State: APjAAAV/ehQQWlfmDqaRbhYi2UWp8VRe9Wx4QY4mcmW4NgiG50CeRs8R fGCbhHwcGzvsUHzQu47GUi0= X-Received: by 2002:a05:651c:2046:: with SMTP id t6mr20273717ljo.180.1579710433017; Wed, 22 Jan 2020 08:27:13 -0800 (PST) Received: from [192.168.2.145] (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.googlemail.com with ESMTPSA id d20sm20510706ljg.95.2020.01.22.08.27.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jan 2020 08:27:12 -0800 (PST) Subject: Re: [alsa-devel] [PATCH 4/9] ASoC: tegra: add Tegra210 based I2S driver To: Jon Hunter , Sameer Pujar , perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, atalambedu@nvidia.com, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, viswanathl@nvidia.com, sharadg@nvidia.com, broonie@kernel.org, thierry.reding@gmail.com, linux-tegra@vger.kernel.org, rlokhande@nvidia.com, mkumard@nvidia.com, dramesh@nvidia.com 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> From: Dmitry Osipenko Message-ID: <1a84b393-938f-8bed-d08e-cc3bb6ed4844@gmail.com> Date: Wed, 22 Jan 2020 19:27:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <34ac1fd3-ae0f-07f2-555f-a55087a2c9dc@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 22.01.2020 14:52, Jon Hunter пишет: > > On 22/01/2020 07:16, Sameer Pujar wrote: > > ... > >>>>>>>> +static int tegra210_i2s_remove(struct platform_device *pdev) >>>>>>>> +{ >>>>>>>> +     pm_runtime_disable(&pdev->dev); >>>>>>>> +     if (!pm_runtime_status_suspended(&pdev->dev)) >>>>>>>> +             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 clock >>>>>> 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 and > 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)) tegra210_i2s_runtime_suspend(&pdev->dev); else pm_runtime_disable(&pdev->dev); > Now for Tegra210 (or actually 64-bit Tegra) RPM is always enabled and so > we don't need to worry about the !RPM case. However, I still don't see > the harm in this. There is no real harm today, but: 1. I'd prefer to be very careful with RPM in general, based on previous experience. 2. It should be a bug if device isn't RPM-suspended during of driver's removal. Thus the real problem needs to be fixed rather than worked around.