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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41F6AC54EBD for ; Mon, 9 Jan 2023 12:04:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237098AbjAIMD5 (ORCPT ); Mon, 9 Jan 2023 07:03:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237080AbjAIMDv (ORCPT ); Mon, 9 Jan 2023 07:03:51 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BEC91A208 for ; Mon, 9 Jan 2023 04:03:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673265782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q4zLyIG7p1EQVcpYB9xbouaznWvWNmBJl4w7V/27n8I=; b=CLlhK3Fcu0M7LanOcaLb5TqSqNVt5dixjd09XHwRqiAdxgeyTZWvxevVjdTCgrbGm94moO kLK0Hj4kuEe401deMYeAnUOTv+1/j1a8Nn5jo+vCN8UddrdFk7Niy8uVAvVq3KNlHXclgS jqNHNmJq8AaxowCe6ErAqc1SaO/MnkY= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-187-UnhgApa6MCWoeEz_BaQCgg-1; Mon, 09 Jan 2023 07:03:00 -0500 X-MC-Unique: UnhgApa6MCWoeEz_BaQCgg-1 Received: by mail-ej1-f71.google.com with SMTP id dr5-20020a170907720500b00808d17c4f27so5227721ejc.6 for ; Mon, 09 Jan 2023 04:03:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=q4zLyIG7p1EQVcpYB9xbouaznWvWNmBJl4w7V/27n8I=; b=oBEK+sECzPoBgK4ynbsoxjNUOfuo1tBDcQXOtTcRqo3UaPblx2+Sxa+f03aKw0lC0e 9LEG4sXicnQsv0Gyzq27McBASJYK52nkeW6ztISKVzJQ4kpd8okiam6/5XLYhP7FaimA 1eioduvvASITeySOwJlKlAoj0GwfhIya0M2B1pYsxz14lIu5KrjHzLPH1CdM6rsnEpPU Hkk/Yx5ojsIBqx2nVVqUDA/AC4Q3Via+WEqXMDX5QxQyTlXPEIWPSSk4x3avf4WtSvhS iWjzN3OE10/SZMhUrfa3hxhIGX9z+XesA5wY4apm2P21AJZGrh6Bg011vtVfPsXlWRNn fmhw== X-Gm-Message-State: AFqh2krCprOf/z2xjhnMSuc+vZmPGr1NKPZXcIAo8eVArDN9cF5f3iX7 qNQ2wwmgsI9YszsZi9bND2BCj1VqOZTzxwIy53aWS8Lakp3BgTk+hV/h7dmNkI/+PquyyYjTkTz qVQqbwLQtQBDnk0SlFNJTd9dk X-Received: by 2002:a17:907:a0cc:b0:78d:f455:b5fa with SMTP id hw12-20020a170907a0cc00b0078df455b5famr54858189ejc.58.1673265779403; Mon, 09 Jan 2023 04:02:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXunflF7rFCOUFP3DL+Uc+xS5o03+N3JiS2BecKqY3RR6YoRGrgqnfqDT/Z6AlX9El9oeWoAvA== X-Received: by 2002:a17:907:a0cc:b0:78d:f455:b5fa with SMTP id hw12-20020a170907a0cc00b0078df455b5famr54858176ejc.58.1673265779238; Mon, 09 Jan 2023 04:02:59 -0800 (PST) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id c39-20020a509faa000000b00483cccdfeaesm3712742edf.38.2023.01.09.04.02.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Jan 2023 04:02:58 -0800 (PST) Message-ID: Date: Mon, 9 Jan 2023 13:02:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v4] i2c: designware: Fix unbalanced suspended flag Content-Language: en-US, nl To: Wolfram Sang , Richard Fitzgerald , jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, jsd@semihalf.com, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com References: <20221219130145.883309-1-rf@opensource.cirrus.com> From: Hans de Goede In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 1/9/23 13:01, Wolfram Sang wrote: > On Mon, Dec 19, 2022 at 01:01:45PM +0000, Richard Fitzgerald wrote: >> Ensure that i2c_mark_adapter_suspended() is always balanced by a call to >> i2c_mark_adapter_resumed(). >> >> dw_i2c_plat_resume() must always be called, so that >> i2c_mark_adapter_resumed() is called. This is not compatible with >> DPM_FLAG_MAY_SKIP_RESUME, so remove the flag. >> >> Since the controller is always resumed on system resume the >> dw_i2c_plat_complete() callback is redundant and has been removed. >> >> The unbalanced suspended flag was introduced by commit c57813b8b288 >> ("i2c: designware: Lock the adapter while setting the suspended flag") >> >> Before that commit, the system and runtime PM used the same functions. The >> DPM_FLAG_MAY_SKIP_RESUME was used to skip the system resume if the driver >> had been in runtime-suspend. If system resume was skipped, the suspended >> flag would be cleared by the next runtime resume. The check of the >> suspended flag was _after_ the call to pm_runtime_get_sync() in >> i2c_dw_xfer(). So either a system resume or a runtime resume would clear >> the flag before it was checked. >> >> Having introduced the unbalanced suspended flag with that commit, a further >> commit 80704a84a9f8 >> ("i2c: designware: Use the i2c_mark_adapter_suspended/resumed() helpers") >> >> changed from using a local suspended flag to using the >> i2c_mark_adapter_suspended/resumed() functions. These use a flag that is >> checked by I2C core code before issuing the transfer to the bus driver, so >> there was no opportunity for the bus driver to runtime resume itself before >> the flag check. >> >> Signed-off-by: Richard Fitzgerald >> Fixes: c57813b8b288 ("i2c: designware: Lock the adapter while setting the suspended flag") >> Reviewed-by: Hans de Goede > > Does this fix a bug when runtime resuming? This is not clear to me. I > tend to put it to for-next rather than for-current. This fixes a system suspend/resume bug, so this really should go to for-current. Regards, Hans