Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3203669rwb; Fri, 9 Dec 2022 11:15:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf5q2SG70n4Mcl5MhvUKGqQj5uQxW+oq8EZeCrkSfMUlVwf6YRo1URXhTbUgOgAXR+as6g/a X-Received: by 2002:a05:6402:380a:b0:467:7b2e:88a2 with SMTP id es10-20020a056402380a00b004677b2e88a2mr5980562edb.19.1670613312777; Fri, 09 Dec 2022 11:15:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670613312; cv=none; d=google.com; s=arc-20160816; b=mDLwff1sutaIB0REtXp1HJr5iMfP16pS7GnEEtDNca5LL6uaCUbiZrkv7x6KOZPzmP kI+np7P3hYJZdR56bOcRVaJ/jqNXInn3bkkf+6bOwWLrdE7uQrHAvaMFFUILAJXE97GH 4QGpQD9b3jDnpTcyQWYiIYsWBX2ZWuuAOfxpaFGmOU7n0MvueUUHC7+HwkzsDu8eXuRO leajmt38sbjcqjgBpjVNHHs0grWZ2ng4huqeR+AZrNKqmjhfQ/iiz7x7QHKTKic6UJ5U tbwIPEWPvJk+rX36as0KwyhtpIyPcctltCggI7Y0FdT8A7lNZ30B7f2dWS1oFGMv2IH0 77cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=570D9M8P8VwH+5u6QVwudCE9N1qA2/b8uaboQLq/EEU=; b=GLV8ZX8tcOVJVq47eHYgLbHaclWU8rO2VIyS8mebHpwnY6GWmNjd4nDBdt6Zcd/7BR iCnBRRBWRitQ/8X41wgdbzCLP5bZYwizSH1km8EllwOwjWJebZ9SGiU/FRzqvT0gxb21 t+pIegUbM6oRZqo+gQWVpCkzph7iW2ZE7Va4jLPiGndQH4auhioEWmqG6nBCFeBKqzTm skXmGzOhnYNtRyrf0efMdfiWg+rO8KoI7MVNG9aJ2ziJEK3FK8mGCmzypGb8PrIpJ0b8 b8KhrSJ9SWVNqpSWDYOxCOY4mf6TPqDtJN0NepFdPofTedNyfWHqoq2ssRde/9kTx+vN mCkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JkTgu47B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz5-20020a1709072ce500b007ae127c6c7asi545064ejc.176.2022.12.09.11.14.55; Fri, 09 Dec 2022 11:15:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JkTgu47B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229981AbiLISRm (ORCPT + 74 others); Fri, 9 Dec 2022 13:17:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbiLISRX (ORCPT ); Fri, 9 Dec 2022 13:17:23 -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 96950A56C4 for ; Fri, 9 Dec 2022 10:16:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670609785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=570D9M8P8VwH+5u6QVwudCE9N1qA2/b8uaboQLq/EEU=; b=JkTgu47BFeWBNQhJ/1yRwmo8Cg0Kxc6zyugLtgZkvnelVy8135Ti4Jd80PYy4ivNWihH2g c4o6B5OcIb5kffcUWt757PbOTBozFdgTDxt6JqxlIYoeFZAPU1+/Zh4PMJ68/1MnWEMXcS Eg6o2X3EMIcLwbs/WKpBAYtQi8V/ZQ8= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-205-sl44lSvqNoGna0mXL7gJDA-1; Fri, 09 Dec 2022 13:16:24 -0500 X-MC-Unique: sl44lSvqNoGna0mXL7gJDA-1 Received: by mail-ed1-f71.google.com with SMTP id y18-20020a056402359200b004635f8b1bfbso1830163edc.17 for ; Fri, 09 Dec 2022 10:16:24 -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:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=570D9M8P8VwH+5u6QVwudCE9N1qA2/b8uaboQLq/EEU=; b=THa/huuPRJhRAeXbDD+9f3f9uT/dlby6x70QG9tN7DmvTJtlYOXs4r2WJCfHNXqVQB ybo9SWilvn1DUthBvXgsPyVZ9xpy4W0NxjXH9k4v8RrRvH9x4rldHYTE69YTjNL2Fhyw PD9OqmMJLPpQvNV+5mmFkqnL1hISvd8YwIDmKLeM67zqMTulc5oisgBrhI9VJnSpoah+ sV1RcKv361C3SNfUc2KAAl+r6LMFZVTErbaow1AWTgc+XVS+l4BtvOTMW9wqoCMsciZW gE2I2CUH/ui9cMaWr1dHwicuCoLot6P7nvYZN+JuB9zMQ1aNkfjx555zf5NOqSg5qy15 Xphw== X-Gm-Message-State: ANoB5pn9YtEkLlX0Yho+Tk0xpegwc0aVEzPTvKN3HWfNgA4pijgRuCJc LQoR+klwvwvP7vnaZKyla9DaVdb35p0XogCKv4xCerng/BSDUjsmf1IXGU7R5YIYRO7KDYPDdfa NxGE9vAIF9irN//rx3XLqzpmv X-Received: by 2002:a17:906:7158:b0:7c0:fa2c:fd5d with SMTP id z24-20020a170906715800b007c0fa2cfd5dmr6024811ejj.59.1670609783215; Fri, 09 Dec 2022 10:16:23 -0800 (PST) X-Received: by 2002:a17:906:7158:b0:7c0:fa2c:fd5d with SMTP id z24-20020a170906715800b007c0fa2cfd5dmr6024801ejj.59.1670609783020; Fri, 09 Dec 2022 10:16:23 -0800 (PST) Received: from ?IPV6:2001:1c00:2a07:3a01:67e5:daf9:cec0:df6? (2001-1c00-2a07-3a01-67e5-daf9-cec0-0df6.cable.dynamic.v6.ziggo.nl. [2001:1c00:2a07:3a01:67e5:daf9:cec0:df6]) by smtp.gmail.com with ESMTPSA id j10-20020a17090623ea00b007c081cf2d25sm175268ejg.204.2022.12.09.10.16.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 10:16:22 -0800 (PST) Message-ID: <6338cce6-c13d-bda3-6f0b-06767122076c@redhat.com> Date: Fri, 9 Dec 2022 19:16:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH] i2c: designware: Fix unbalanced suspended flag To: Richard Fitzgerald , wsa@kernel.org, jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, jsd@semihalf.com Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com References: <20221209114034.18025-1-rf@opensource.cirrus.com> Content-Language: en-US From: Hans de Goede In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 12/9/22 15:22, Richard Fitzgerald wrote: > On 9/12/22 13:36, Richard Fitzgerald wrote: >> On 9/12/22 12:15, Hans de Goede wrote: >>> Hi Richard, >>> >>> On 12/9/22 12:40, Richard Fitzgerald wrote: >>>> Ensure that i2c_mark_adapter_suspended() is always balanced by a call to >>>> i2c_mark_adapter_resumed(). >> >> >> >>> >>> It is not entirely clear to me where the unbalance you claim to see comes >>> from? When runtime-suspended SMART_SUSPEND should keep it suspended at which point >>> the system suspend callback will never run ? >>> >>> Are you sure that you are not maybe seeing a suspend/resume ordering issue? >>> >>> Did you add printk messages to the suspend/resume callbacks of >>> i2c-designware-platdrv.c which show the system suspend callback >>> being called but not the system resume one ? >>> >> >> With messages in strategic places. >> >> [  169.607358] i2c_designware i2c_designware.2: PM: dev_pm_skip_suspend: SMART_SUSPEND=0 pm_runtime_status_suspended=1 >> [  169.607361] i2c_designware i2c_designware.2: PM: __device_suspend_late: dev_pm_skip_suspend:false >> [  169.607364] i2c_designware i2c_designware.2: dw_i2c_plat_suspend >> ... >> [  169.702511] i2c_designware i2c_designware.2: PM: dev_pm_skip_resume: 1 because !power.must_resume >> [  169.706241] i2c_designware i2c_designware.2: PM: dev_pm_skip_resume: 1 because !power.must_resume >> [  169.706244] i2c_designware i2c_designware.2: PM: device_resume_early: dev_pm_skip_resume:true >> ... >> [  175.254832] i2c i2c-2: Transfer while suspended >> >> (Just to prove my logging isn't lying, for i2c3 it reports >> SMART_SUSPEND=1) >> > > Oh, that's embarrassing. After confidently telling you my logging > is perfect, actually there was a bug in it... > > New log summary: > > [  162.253431] i2c_designware i2c_designware.2: PM: dev_pm_skip_suspend: SMART_SUSPEND=1 pm_runtime_status_suspended=0 Ok, so the device's pm_runtime_get() count is 0 here (otherwise must_resume should be 1 later on) but the device is not run-time suspended yet. Probably because of some timeout; or because of runtime pm getting disabled durig suspend before the count dropped to 0. And this scenario will indeed cause the system-level suspend callback to get called, but not the resume one ... > [  162.253438] i2c_designware i2c_designware.2: PM: __device_suspend_late: dev_pm_skip_suspend:false > [  162.253445] i2c_designware i2c_designware.2: dw_i2c_plat_suspend > [  162.273115] i2c_designware i2c_designware.2: PM: dev_pm_skip_suspend: SMART_SUSPEND=1 pm_runtime_status_suspended=0 > [  162.362547] i2c_designware i2c_designware.2: PM: dev_pm_skip_resume: 1 because !power.must_resume > [  162.369216] i2c_designware i2c_designware.2: PM: dev_pm_skip_resume: 1 because !power.must_resume > [  162.369220] i2c_designware i2c_designware.2: PM: device_resume_early: dev_pm_skip_resume:true > [  167.901269] i2c i2c-2: Transfer while suspended > > Same result that it doesn't skip suspend but does skip resume. From your other email: > Ok, what do you suggest as the fix? > If you post an alternate fix I can test it. I don't really see a better solution, so lets go with your solution, but then: 1. Simply drop the flag but don't add the if (!pm_runtime_suspended(dev)) check. The runtime status is always going to be set to active at this point so the check does not do anything. 2. Drop the dw_i2c_plat_complete() callback since we now always resume the controller on system resume. Regards, Hans