Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp704630pxb; Fri, 8 Jan 2021 16:28:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeaBqBAKpfX9jds/FY6PnN5RHyBm0He2TL+waP0RAm5wHCrkezh4/MZ2agDdWBD16BpU5M X-Received: by 2002:a17:906:4985:: with SMTP id p5mr4238975eju.513.1610152118909; Fri, 08 Jan 2021 16:28:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610152118; cv=none; d=google.com; s=arc-20160816; b=VvgSe5hjeK+OtJCm6s1u1VFmRvhjy48jFj4fUXjx9o7tgwYGGgvIRgCpHvBPri9i1F ufyxtlEuzidbKg6QrGvcojzx+WqwCik0dZ8K+4y/7TjwIAULtCD6U2oHVGperBlw5Hya 8GlJJGH3pD2fDEkMvFwyZJePUqjxLvfFPvxULp1SlNbJdFx7oRdoTF2HzIgGcBxr1GrA Kx5Tl6Aw7o2XpLeYtRDxn4eIaoRfw9G1DPKbPgF/1Vqx9H5FzowMOA5i5CKy4XfJrp+g YlS1QQ5ITa5ZSyzfCGHySgUPo62L/7j0nT/ziAeZGAb58Bp9hFYGrqD9XRXhARvYEYfw DUCw== 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:dkim-signature; bh=HZWtqqmWXFQF6vFVo5YIcMITV5s0aEkVTtLeRZ9cL6A=; b=f8otPo+DOTmYtH3K57RTF2oRQMoSsR1lpZE/ckidxKkXx++ibUIhE2nmTAh66nhvRr EYHlf3vMhUGB2RlxbE8UZyGwTjjoYLl1XIKafcVRllOW2bdf3mjvKXfbkrcRsmf3Kchx DjIVy+VTSOWUrTQ2hvxklM061OZACYPzoMHdI3kramcJ7K+otn4CS2GIRqbTbdWmdPhP nTW+SGc2zb9H2ZZ4rjZnIa9fN/Jv/NVVpgmC7VcyJli3p7uYHMj7Y9EilStn2ojqTHNh TZU83AtDJjq128SNyLAXi6MKgUzZKrEHcy63dWjUE8RpUbFFOtWZT9EPVCRpOhI/mBUD KioA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CwzTe1m7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si4138098ejf.162.2021.01.08.16.28.14; Fri, 08 Jan 2021 16:28:38 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=CwzTe1m7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726078AbhAIA0r (ORCPT + 99 others); Fri, 8 Jan 2021 19:26:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbhAIA0o (ORCPT ); Fri, 8 Jan 2021 19:26:44 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1346FC061574 for ; Fri, 8 Jan 2021 16:26:04 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id o19so27160133lfo.1 for ; Fri, 08 Jan 2021 16:26:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HZWtqqmWXFQF6vFVo5YIcMITV5s0aEkVTtLeRZ9cL6A=; b=CwzTe1m7vCRdfJRtlHvio4kU535Zx+X6j1FpPIF968iK7L20sK2yraXj3zQvFYwk+w rO0jyCEMRnOY1fXVDCkA/tQB+bksqSmd4NU7VZE7+nwar4RoRFdn0yzS6vylg6U0kkxs B+8eZ/wlIVe7AihgRk/Ys7AOcNG28HiPV1LVDKeEyvUvZTTPaGUyNx9gHNElDl2IAnnI H1bxeRnoUmcrvxFz8oHzrIlswPCUngUJLz3RbFrQW72vKpkqutOGwBKcY8ZmprevI1gv rZm7VH4ly8+L89l0+HoXtamYRo8QKiq30zJ/9xmgPNmCrjmaKYiLwpdCuVgtpqBBJYhU rpjA== 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=HZWtqqmWXFQF6vFVo5YIcMITV5s0aEkVTtLeRZ9cL6A=; b=DQbbBNtUhx9Jn/GBBoGdKaxDafKjvRWH606RrNJCiUjpdswhfFPDGYgGnU/hMQ+r/D 2n8/YBvWIYMTbcKjVwmsyi+4fzzCgouS/yTQOcfIVAvFOBbrZtK4liYwKsd47BBD2AYL NUP3qCjHeAFySXuTZ9o/pNN7lWsyHGtR4/PiPOTmbTF5d8LaUftrQI0HISu0oAkfDY5u ePwYxcDLZXzSDt4hjrPpZ4p4zrnwmnceVlmaPQ5HxDCN9GDj0rA6WvF3Rvzr9EL8RC7C p7i2ri+znyTdpvTMyFT1lZD82difuMSdYZG0pYr2sHlXpRrnM2jcHqsbCFUe9dlo31lR eAkg== X-Gm-Message-State: AOAM530+b5yLq2u7iogzxZ6iz3brWSI5qwdPLQVMPO074u7bgru780Sc 354ufStt40OZ7oD/kOqsAk8JOOvXKkxRRJZ3b/Tvzw== X-Received: by 2002:a2e:b047:: with SMTP id d7mr2414795ljl.467.1610151962442; Fri, 08 Jan 2021 16:26:02 -0800 (PST) MIME-Version: 1.0 References: <1609936000-28378-1-git-send-email-srinivas.neeli@xilinx.com> <1609936000-28378-5-git-send-email-srinivas.neeli@xilinx.com> In-Reply-To: From: Linus Walleij Date: Sat, 9 Jan 2021 01:25:51 +0100 Message-ID: Subject: Re: [PATCH V4 4/5] gpio: gpio-xilinx: Add support for suspend and resume To: Srinivas Neeli Cc: Bartosz Golaszewski , Michal Simek , Shubhrajyoti Datta , Srinivas Goud , Robert Hancock , William Breathitt Gray , Syed Nayyar Waris , "open list:GPIO SUBSYSTEM" , Linux ARM , "linux-kernel@vger.kernel.org" , git Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 8, 2021 at 12:41 PM Srinivas Neeli wrote: > > On Wed, Jan 6, 2021 at 1:27 PM Srinivas Neeli > > wrote: > > > /** > > > * xgpio_remove - Remove method for the GPIO device. > > > * @pdev: pointer to the platform device @@ -289,7 +323,10 @@ static > > > int xgpio_remove(struct platform_device *pdev) { > > > struct xgpio_instance *gpio = platform_get_drvdata(pdev); > > > > > > - clk_disable_unprepare(gpio->clk); > > > + if (!pm_runtime_suspended(&pdev->dev)) > > > + clk_disable_unprepare(gpio->clk); > > > + > > > + pm_runtime_disable(&pdev->dev); > > > > This looks complex and racy. What if the device is resumed after you > > executed the first part of the statement. > > Could you please explain more on this. > What is the need to call pm_runtime_get_sync(); in remove API ? I explain that on the lines right below your comment ;D > > The normal sequence is: > > > > pm_runtime_get_sync(dev); > > pm_runtime_put_noidle(dev); > > pm_runtime_disable(dev); > > > > This will make sure the clock is enabled and pm runtime is disabled. > > After this you can unconditionally call clk_disable_unprepare(gpio->clk); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Yours, Linus Walleij