Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp880969ybt; Sun, 14 Jun 2020 03:02:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvkdIWC7/Y2yvquw0sqZRG012Ou9kgBIhfDoSDK9YOq23+vNqQhViwj7HE0SeWjfzkbw9e X-Received: by 2002:a50:ee08:: with SMTP id g8mr18436546eds.267.1592128967126; Sun, 14 Jun 2020 03:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592128967; cv=none; d=google.com; s=arc-20160816; b=h9ouwFWjqwqlWhv3r4xdals+bI8FgXLKNUWN1jchvI1JmNZRoBQWh/RljA0koqal4v tH4cCH3SbjYtI/usM+Q4T1z5QoHKCofbQ2ZM1MEwYfEBBzas3AQKOTHXTiFxNnbE8lLm io/dHE6pxSprdf9UXHUvLCBEzn/hWz3etM3n2PhhbMNpMwJHb8CuwRSNwqAJw1+5VKzZ U/j/SW3Wyl8x/9nRV/BQvg50hzYGP3yxv/vBZXB5V3PvuI7AiWuTHyDTiY7NpzjhSpzm XiorrWzbFq/44oSt2n0P7OPlflyEvKYoteRsEGn8KGm8MWkEmX5JmMczoT2b/XhU73g3 mEpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=4WULzJxTJOdxHO2znjN8tpLfUL4wqN9JR3P9Ps2LSWs=; b=R1KXJg95AxWTaUJiBWp1m+UaI9BwqoeK8dpnMnZw/jH+Kz2Ue3CiADqBNN/k7zQNsb VmwKcYq02MvcTpObtt9qBd3Ihtr3wf9XAMjYh/VDv2s3ZokM7QX8M5o5d7MZRJ9MHxju 5LKwN7iGZeXO4k//iULOagqAhR+MHAPn2MfmvK818rLgxtHlZUY4QWuTCX0mkAt7WVOD 8MjvEt0RbOex+0MfyHKFtHSDJHdIGRSMzKYU3iP4ipc7L/3C1RxXYoBmvmn7aMefcJcF nBym0SjGaiUGi6oZ8RjZfkRatzQZzst7ym/pybqwpxyx8wZSGqijUbS7TOgG5tsIia5l 18Ig== 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 p13si7144993eji.495.2020.06.14.03.02.22; Sun, 14 Jun 2020 03:02:47 -0700 (PDT) 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 S1726830AbgFNKAe (ORCPT + 99 others); Sun, 14 Jun 2020 06:00:34 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:40685 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725265AbgFNKAd (ORCPT ); Sun, 14 Jun 2020 06:00:33 -0400 Received: by mail-ot1-f67.google.com with SMTP id s13so10813532otd.7; Sun, 14 Jun 2020 03:00:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4WULzJxTJOdxHO2znjN8tpLfUL4wqN9JR3P9Ps2LSWs=; b=YrVDWFHserxJQXNp0eapr0JjntpvJzBmaLHJ9ZAjBUx8uB4ikFjMR6NnbzruHX8fT+ aIGh8ArGM5du8tGWH65rAqroTZuR1Nwu/O/keAU6LEvHfyL3buGw7veVOHxmx2Yrsuo3 SjM6ZLqQdiK0LvHVW6epY9V9fwl63koUOv0IG7iplkWr7YV4U4LxKAFZmE1LuzR54zWj RQXhK8y/jfpGCzfwHcLWAkMY6vm0CbNcWiX+JsxAQg+feTuTL5pfiEP7VGxuqZGRdTeG kzEcp1CZjgaXloU8YnUKqkTZ7CuvAwN0Vs0aQEjMcyEz4Hzw7Tj6A5z6zU4WID3sDFuA bNTw== X-Gm-Message-State: AOAM533oEMHQ0o/UdscF7mqiJvksYhyqxDh2FpCuBHa6XUHPbSCjSNJ8 op5Lry8adsphmNwCUaoS0g2efiYuEYxqAPeN3zk= X-Received: by 2002:a05:6830:141a:: with SMTP id v26mr17553666otp.250.1592128832339; Sun, 14 Jun 2020 03:00:32 -0700 (PDT) MIME-Version: 1.0 References: <20200614090751.GA2878@kunai> In-Reply-To: From: Geert Uytterhoeven Date: Sun, 14 Jun 2020 12:00:21 +0200 Message-ID: Subject: Re: RFC: a failing pm_runtime_get increases the refcnt? To: Andy Shevchenko Cc: Wolfram Sang , Linux PM , "Rafael J. Wysocki" , Linux-Renesas , Linux Kernel Mailing List , linux-i2c Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On Sun, Jun 14, 2020 at 11:43 AM Andy Shevchenko wrote: > On Sun, Jun 14, 2020 at 12:34 PM Andy Shevchenko > wrote: > > > > On Sun, Jun 14, 2020 at 12:10 PM Wolfram Sang wrote: > > > both in the I2C subsystem and also for Renesas drivers I maintain, I am > > > starting to get boilerplate patches doing some pm_runtime_put_* variant > > > because a failing pm_runtime_get is supposed to increase the ref > > > counters? Really? This feels wrong and unintuitive to me. > > > > Yeah, that is a well known issue with PM (I even have for a long time > > a coccinelle script, when I realized myself that there are a lot of > > cases like this, but someone else discovered this recently, like > > opening a can of worms). > > > > > I expect there > > > has been a discussion around it but I couldn't find it. > > > > Rafael explained (again) recently this. I can't find it quickly, unfortunately. > > I _think_ this discussion, but may be it's simple another tentacle of > the same octopus. > https://patchwork.ozlabs.org/project/linux-tegra/patch/20200520095148.10995-1-dinghao.liu@zju.edu.cn/ Thanks, hadn't read that one! (so I was still at -1 from http://sweng.the-davies.net/Home/rustys-api-design-manifesto ;-) So "pm_runtime_put_noidle()" is the (definitive?) one to pair with a pm_runtime_get_sync() failure? > > > I wonder why we > > > don't fix the code where the incremented refcount is expected for some > > > reason. > > > > The main idea behind API that a lot of drivers do *not* check error > > codes from runtime PM, so, we need to keep balance in case of > > > > pm_runtime_get(...); > > ... > > pm_runtime_put(...); I've always[*] considered a pm_runtime_get_sync() failure to be fatal (or: cannot happen), and that there's nothing that can be done to recover. Hence I never checked the function's return value. Was that wrong? [*] at least on Renesas SoCs with Clock and/or Power Domains. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds