Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp2006692pxy; Sat, 24 Apr 2021 02:14:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxecNgOpRh6h0pbvq8fZ2aCs07VTDLUGIVkgKkjh5YDTG1LLLMBfudxnzpCe6/Hoi86FcLk X-Received: by 2002:aa7:82cc:0:b029:213:db69:18d9 with SMTP id f12-20020aa782cc0000b0290213db6918d9mr7902518pfn.36.1619255657987; Sat, 24 Apr 2021 02:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619255657; cv=none; d=google.com; s=arc-20160816; b=chgBf0i/g9f2uyD808bm4nzh/qaZJkuSeDPkqbjmJaw4Kx6Dc2zMA7biTAC9yUff/j GyVkvoh4RydPcq3sttlVIjK3pM1BlMl4pufVMul01m2lPuW2HWkzonKLMIwc4IlaMjbc 5ABtzA6scn711FyLBy56nzwU2UtscAwtOngxCX20bo0iADzhYS42WXFMl3mhg/VesvQs nUfS6+jlK2XGhRKM9bHWK+fYpOGiFk7TEEyaGlsHAZDgmVaM5Fk1jr4BSE8xiHJHdhN3 U8gQ565ljItcXUCv6L2gGJOBLrgKRfCwwDOdMvdrF7dSh4AzArRZl0v2Jckki3AosD7d 8zVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=YeTmoO42uoi3i60Ai3NZHOpwkktNr+Lql55GBGVHTYI=; b=wKayACJX0dCG/44Xp1WHGXAX0Tm6H4M+p4TznLMwCf8IHVpGdWbX5ZGC5gG0K8BpCV k/qIU/hVZvjPyGrWtpOJlyI1jBydOfrIdl0AD/7gHtmw1pbWtTT9Pg5UFEthB+f9pKWn ARsty+/3MeC1ro9f/TZOHl/CNGr9VjsgiubEo6kgovOW3FzhlAlBxWGVMDTTYfEVcUU8 McZIg5CP9u9hGeJPQM8soBqnCyhGvttJEUP7+Cf8GwHFA1uwLg470famQalXPAH5pxBE EoXPltkCT3zQz2WrXbrVAinKvvkmsKJlJqHJynmkA7YobEsQlvIRKfeFSG/bbIZ5P+Ak MEiQ== 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 h22si9853221pfn.35.2021.04.24.02.14.05; Sat, 24 Apr 2021 02:14:17 -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 S232251AbhDXJNW (ORCPT + 99 others); Sat, 24 Apr 2021 05:13:22 -0400 Received: from mail-ua1-f46.google.com ([209.85.222.46]:39450 "EHLO mail-ua1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbhDXJNU (ORCPT ); Sat, 24 Apr 2021 05:13:20 -0400 Received: by mail-ua1-f46.google.com with SMTP id a12so12197540uak.6; Sat, 24 Apr 2021 02:12:42 -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=YeTmoO42uoi3i60Ai3NZHOpwkktNr+Lql55GBGVHTYI=; b=Tn/JYODhFN55O00xPkixb5hIH38UBUx/HhnOqIyyC7BeDDtK1SaICtowEucadPLMMR trJcu1JMuOW8H2AMedILs+uVsriTwEQ9xaQQASkV/Bz1GNKrOyrNUB4vRE7n2eRBmNMK 91i4JlZYnr6AsjLXnD2LsQewy/tYYrhqaWUBrhfeEPnygo7iU3HQ6HylCj4nKjMO4j1F s4YdUAMu4+sah55oYo84INlk0+wChhFF5EWlz4iOuVtCFeCv+EGm8VXJMzzfaNh2n+4Y LPjF+ly6051AAWoQPQkXEdJm3YwWViOMqKrWW8myUbAHTzTEMo8rJu3YrgKPaCxR4sjf z/5Q== X-Gm-Message-State: AOAM533OxUIIsR7mNHsgxYJF3D931HhP8ZqTmtIEIL1BTOhimeqvcNKO wXAxXO0LKnO2h0h0XmaYts35VfXTHRkYbKur9Pyv2V1Oqjk= X-Received: by 2002:ab0:6306:: with SMTP id a6mr6210257uap.2.1619255562481; Sat, 24 Apr 2021 02:12:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Geert Uytterhoeven Date: Sat, 24 Apr 2021 11:12:31 +0200 Message-ID: Subject: Re: [PATCH 69/78] media: rcar-vin: use pm_runtime_resume_and_get() To: Mauro Carvalho Chehab Cc: Linuxarm , mauro.chehab@huawei.com, =?UTF-8?Q?Niklas_S=C3=B6derlund?= , Mauro Carvalho Chehab , Linux Kernel Mailing List , Linux Media Mailing List , Linux-Renesas Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mauro, On Sat, Apr 24, 2021 at 8:46 AM Mauro Carvalho Chehab wrote: > Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") > added pm_runtime_resume_and_get() in order to automatically handle > dev->power.usage_count decrement on errors. > > Use the new API, in order to cleanup the error check logic. > > Signed-off-by: Mauro Carvalho Chehab Thanks for your patch! > --- a/drivers/media/platform/rcar-vin/rcar-csi2.c > +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c > @@ -408,7 +408,7 @@ static void rcsi2_enter_standby(struct rcar_csi2 *priv) > > static void rcsi2_exit_standby(struct rcar_csi2 *priv) > { > - pm_runtime_get_sync(priv->dev); > + pm_runtime_resume_and_get(priv->dev); I believe this part is incorrect: on failure[*], the refcount will now be decremented, and in a subsequent call to rcsi2_enter_standby(), the refcount will be decremented again due to the call to pm_runtime_put(). [*] On e.g. R-Car SoCs, this can never fail. This is the reason why many R-Car (and SuperH) drivers never check the result of pm_runtime_get_sync(). So the refcount "imbalances" were actually introduced by the various "clean up" patches to add return value checking, which now need another round of fixing... > reset_control_deassert(priv->rstc); > } > --- a/drivers/media/platform/rcar-vin/rcar-dma.c > +++ b/drivers/media/platform/rcar-vin/rcar-dma.c > @@ -1458,11 +1458,9 @@ int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel) > u32 vnmc; > int ret; > > - ret = pm_runtime_get_sync(vin->dev); > - if (ret < 0) { > - pm_runtime_put_noidle(vin->dev); > + ret = pm_runtime_resume_and_get(vin->dev); > + if (ret < 0) > return ret; > - } This change (and the change below) is correct, as the logic before/after is equivalent. 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