From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ED8BC43461 for ; Mon, 7 Sep 2020 15:27:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 613682078E for ; Mon, 7 Sep 2020 15:27:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XQhMAxv5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730076AbgIGP1l (ORCPT ); Mon, 7 Sep 2020 11:27:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730163AbgIGP01 (ORCPT ); Mon, 7 Sep 2020 11:26:27 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2567C061573; Mon, 7 Sep 2020 08:25:49 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id t23so16587234ljc.3; Mon, 07 Sep 2020 08:25:49 -0700 (PDT) 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=vxm2Igun/q6T7+g3CyW4TzjR0caFh2BccAiRyp7KFRc=; b=XQhMAxv5UsGUTaP2gmJE18daXqUxUWTx2Ljtg8zGmSkHctgKcSN68V1y/EygGunyym gKF4d3Rya/8NfaXPXpDOMeW8So24G35TLf46QaibDfcj2qDulM9B3FfL7WTv5QwL7/k3 4/6/8eacW42A74NZX1FYbAJ0B37aZrW2SqitpKsiOvUdEKxmFrGoCPp+HnR2+EfXQVyF Nwbb4P/ZFcj71iYr41v7z4AunCZkuH0mhk2ZLL9yjnxqgxStDRNncccchlKFL+CnRWfa wHLnyklBYHXxYBEhro3Mv81hQvr2ArNt2Jx8uS+jmb7xLvT1REOoXsi+G9B1UHRV8iPa P8CQ== 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=vxm2Igun/q6T7+g3CyW4TzjR0caFh2BccAiRyp7KFRc=; b=jGLHRR8N5MYe2k2myM4Qzpicz3ukWOx7t46iETPfwxhD1cDQq12FOeAT9B+XbN6kVt x/MtyvJrCCfiTkM8tefPaXUESDtiYwz1QrPw3dBeiVJ5IhKwECjv1Kk//QwZc7XR27Cd 5/2Xb9kUeuEcbNNydywvYnsuIf8Qzsd0Iic2gpNibJsWEBOhgQoe0m+iYs+pDQ0RiM7S wXpv5HmFcXwsMSvpudKs7/mAB7yQz00JCNBw6YKxboTc58HWTySPfEZM8NBkXJcLt2bG FErLtdIxeeG+v4Zba9mwHQVamEQZg5os6fSeHdt45kG1YvHugTF5/ncbmLqct6pi3wNz 3wgQ== X-Gm-Message-State: AOAM53341QDDjBKwjHGElsXaLVZ/569yIC4TByZnAE4fGf37sp7aBwvN MqN2H0me1na6Q8K9TPKhJOxKxUuJLnY= X-Google-Smtp-Source: ABdhPJz0H0iTo6lShlk9NFmHJSQJCBX4QEcBRHy/X8PPCY4GZ5/vdmdtv+ropjfF4ZPboEYRwdCS5A== X-Received: by 2002:a2e:3013:: with SMTP id w19mr2709739ljw.339.1599492348213; Mon, 07 Sep 2020 08:25:48 -0700 (PDT) Received: from [192.168.2.145] (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.googlemail.com with ESMTPSA id x17sm7267990lja.10.2020.09.07.08.25.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Sep 2020 08:25:47 -0700 (PDT) Subject: Re: [PATCH v5 06/36] i2c: tegra: Runtime PM always available on Tegra To: Andy Shevchenko Cc: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , linux-i2c , linux-tegra@vger.kernel.org, Linux Kernel Mailing List References: <20200906185039.22700-1-digetx@gmail.com> <20200906185039.22700-7-digetx@gmail.com> From: Dmitry Osipenko Message-ID: Date: Mon, 7 Sep 2020 18:25:46 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: 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 07.09.2020 18:05, Andy Shevchenko пишет: > On Mon, Sep 7, 2020 at 5:32 PM Dmitry Osipenko wrote: >> 07.09.2020 11:10, Andy Shevchenko пишет: >>> On Sun, Sep 6, 2020 at 9:51 PM Dmitry Osipenko wrote: >>>> >>>> The runtime PM is guaranteed to be always available on Tegra after commit >>>> 40b2bb1b132a ("ARM: tegra: enforce PM requirement"). Hence let's remove >>>> all the RPM-availability checking and handling from the code. >>> >>>> + ret = pm_runtime_get_sync(i2c_dev->dev); >>>> + if (ret < 0) { >>>> + dev_err(dev, "runtime resume failed\n"); >>>> + goto disable_rpm; >>> >>> As in the original code here is a refcount leak. >>> Should call pm_runtime_put_noidle(). (Possible to use goto put_rpm; >>> but in that case the code a bit confusing to the reader) >> >> Good point! I already forgot about this RPM API problem! I'll add a >> patch to address this. >> >> Would be great if anyone could put effort into changing the default >> get_sync() behaviour and add get_sync_nofail(). Otherwise this will be a >> never ending problem. > > I didn't get this. For time being the API (yes, with its all cons) has > the clear usage: > a) don't check for errors -- you are fine > b) if you start checking errors, keep in mind refcounting. > > So, I don't see how nofail() can fix b) case. > It's a very unintuitive behaviour which none of other APIs have. I would never expect the refcount to be bumped in a case of error, this is a clear drawback of the API, IMO. Perhaps this is not seen as a problem by people who have excellent memory and can easily remember about existence of such non-standard quirks, or by people who're touching the RPM code frequently.