Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp781139pxb; Mon, 25 Oct 2021 18:51:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgRKzkHPYv9YgPPCBJb9nURHp30AwJsI4xHgcX3HPAbXMwVL2wX15Y1BVuaHaLzJlI/IBa X-Received: by 2002:a17:907:9727:: with SMTP id jg39mr26845910ejc.533.1635213093964; Mon, 25 Oct 2021 18:51:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635213093; cv=none; d=google.com; s=arc-20160816; b=X0YLKJKNeUJbs9WI5FM4yfk0KYKy/22oqn8v53FMwvMv63aJVSnbh4F6vd73LfmYd7 op97shYYJw0uPu1VpPQCppoc1sIr+riU6TKv308tWxWeeGXiQaISxGXq6PMlq0drDV15 /U7vrTpWQMQakAg9zn4zLQGOVoyY4cF+RNXObpn6QqrW839aAM+1DXpuEPX+siC+gO/x 0D0r+N4IOzp49qBimJZ1LgBL2u+Nrs9CQbvP7SQq6szYWfEJvUD6WSWC6FouU9iG9OS7 V6BgFnIi+N8hQrJCEVaYsZrq41m1UQJ1v0LiSP5Yw52m/LdpJJ1UtBctYaCY17e/30vJ IVTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=IsG+1m99AvoR1yZKJQrlzvDKdWHsv+YhZuLrk/U7nqM=; b=gMLLa+8Oyx1+8Jn2MHCj2T+B42CfzuyT5GYBaeKwTfnmSpVmrMbNC5qJ/mKEVVeh40 2DHTCtyperzu7MYPPiF2leH1P/VFkGz0BQiLcEmg/pozp2cUYln80jpOqZq9Cbcph1V6 1gfwRZtALAOy8fZaIwTZvxlM0J533hFeDwz0SUYV5e+3ADtUPlUYGJ0uL7lXBWujWSIy f8As64RNelWWYBNvP3VDWr/QuI9d2DMBx7FNeBKdjX3so3x/p56LGpXb1QblaDWDw8uk bUbdu6fARx7xMeQX0c7LNSan9VEY4Bef14+aaimss7Yb8swCYqDMWEJKaT17fKKYWnFO fu2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nb3VuU7N; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sh40si19273359ejc.146.2021.10.25.18.51.11; Mon, 25 Oct 2021 18:51:33 -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; dkim=pass header.i=@google.com header.s=20210112 header.b=nb3VuU7N; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233569AbhJYVh7 (ORCPT + 99 others); Mon, 25 Oct 2021 17:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233805AbhJYVh6 (ORCPT ); Mon, 25 Oct 2021 17:37:58 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62ABCC061348 for ; Mon, 25 Oct 2021 14:35:36 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id n9-20020a63e049000000b002951886c1c5so6859923pgj.0 for ; Mon, 25 Oct 2021 14:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=IsG+1m99AvoR1yZKJQrlzvDKdWHsv+YhZuLrk/U7nqM=; b=nb3VuU7Ntj1eqgLyfUJOmSueS+kzxRn5xRwY2HECFl95yc1ZFK+33rTVSGkm5KfuYY adNJ7rNi0AiA209QwvG6tbsGzzvPOVTZZKPdFHfXOEllvEjM4Bx5sGSe4m+euxR6plwK oZPIfDsk8DuutC6BSByCbYpo1UVU5yYINtqZWEwqmK4sKpPskC0y4DR9tLLWCo1c+Qa4 gxa9PwtlkKpe+ke0HbEqiUVMJQgWdCM4me3E3AZMBF4Jxkz9irB8lW4RExijrsIx8a2p AYlatBnzdMBxWZZY3O4urwqHW561D0s7fUlKTosWiWk4pr8fgUKCpj079qfn/6vCizpO 6Rwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=IsG+1m99AvoR1yZKJQrlzvDKdWHsv+YhZuLrk/U7nqM=; b=7eVNvIYQHow/0u/8rhxfhPtoVAepBm4m3YM9pWleLUqmaGRu8mHAFf4lEgns99UV5l EKB/QfhM1wflxrmEaBfPRJctCqW48a1LXPHWJ9caq/mVtAtqsbQZPV5gpgL/mExldxQr +czujqZ1qDffG+csSewvqA/7W8TTo5B2WdCOi0a0eRhChxe2qvq+NGy/sihdSExo2Zs/ O4jQRqRiLurDbPYSVmvEDcvmt6k+SL0UbqCIurs84C0sy6MABgTFiw5pq+EmyMI5gqmZ ttXG4nQMKenpOhTJtxHeqSaca/EPOVSNlnfdXNfZtsiJFzOYcPTaleD6F9fK1x2ofUSh esRw== X-Gm-Message-State: AOAM533YCmmN3EdqXXpmO0KoqbbhvHYH6fJ9/pJ4vI1AH7WNclzC1Ggt EVN+DvbDTrdifaSMoxtoEtkLKtgna2BA X-Received: from rajat2.mtv.corp.google.com ([2620:15c:202:201:5478:3d15:6893:1074]) (user=rajatja job=sendgmr) by 2002:a17:90a:eb18:: with SMTP id j24mr22613368pjz.196.1635197735729; Mon, 25 Oct 2021 14:35:35 -0700 (PDT) Date: Mon, 25 Oct 2021 14:35:28 -0700 Message-Id: <20211025213532.2349161-1-rajatja@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog Subject: [PATCH v2 0/3] i2c: Enable asynchronous suspend/resume From: Rajat Jain To: Jarkko Nikula , Andy Shevchenko , Mika Westerberg , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dtor@google.com Cc: Rajat Jain , rajatxjain@gmail.com, dbasehore@chromium.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (The only change in v2 is to add Jarkko's ack / tested-by) PM Core allows buses and drivers to specify if they'd like their devices to suspend/resume synchronously or asynchronously. When resuming: 1) SYNCHRONOUS DEVICES: - All synchronous devices (system wide!) are resumed in a single thread, serially i.e. one after the other. So their resume latencies add up, and also, this results in unnecessary and unnatural waiting order. In my current system (total resume time ~895ms) and this is the trend on almost all chromebooks in the past 3-4 years (we carry patch3 in our tree already, without which it would be even more worse): https://rajatxjain.github.io/public_shared/resume_before_patches.html As you can see I2C devices do not even begin to resume until 450ms, waiting unnaturally for another device i915 to finish resuming: I2C touchscreen device (resume latency = 374 ms) - asynchronous -> (waiting on) I2C adapter resume (synchronous) -> (waiting on) Designware resume (synchronous) -> (waiting on) intel_backlight resume (synchronous) -> (waiting on) its PARENT i915 resume (asynchronous resume time = 376ms) As you can see the two biggest resume routines are both run serially after one another (even though they don't have any real dependency) thus increasing the system critical resume path. If we can run them concurrently, we can cut down the system resume time considerably. 2) ASYNCHRONOUS DEVICES: - On the other hand, all asynchronous devices's resume routines are scheduled so they can run in parallel with other asynchronous routines. PM core still ensures for both async/sync devices that: - All parent child relations are honored. - Any device dependencies are honored. Device dependencies between any 2 unrelated devices can be specified using device_link_add(). - Async resume devices are sychnronized at the end of each suspend/resume phase, before moving onto next. With these patches in place, the I2C devices can resume in parallel with i915: https://rajatxjain.github.io/public_shared/resume_after_patch.html As far as I understand, the only reason we might not want a device to be marked for asynchronous resume is if we suspect it cannot handle concurrent resume with other devices, which does not look to be the case. This patchset marks the designware, the I2c adapters, and the i2c clients for asynchronous suspend/resume. In case it helps to gain any confidence, the patch 3 (for i2c clients) has been included and shipping on all our chromebooks for the past 3+ years, and has not shown any issues. The designware and i2c adapters should be easier. Derek Basehore (1): i2c: enable async suspend/resume on i2c client devices Rajat Jain (2): i2c: designware: Enable async suspend / resume of designware devices i2c: enable async suspend/resume for i2c adapters drivers/i2c/busses/i2c-designware-platdrv.c | 2 ++ drivers/i2c/i2c-core-base.c | 2 ++ 2 files changed, 4 insertions(+) -- 2.33.0.1079.g6e70778dc9-goog