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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B4ECC55ABF for ; Thu, 6 Aug 2026 13:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EnFcnLAcovYGuxQ3SryQHb+OF7wEqtNgeLy+mnxohuU=; b=Hs2O6i0ofy0ZFy POKwkK3U7/MzV1oD/qILNH3bsVl8+73NGZRZh/qhTgCCynp944hiEwdfuF/QFbqzyr1iE/jw59k3R 1hyXIafLpyCOsU8xhsHAH7q3wKJFx1zNMWUwUhsDurmj/toGN1GxFqLp0mxEc71t9McBv/r2oLeQm 2gsw/2FVFj/r/M65VC1mO9nVBoyuG5WaBiaDK6LWj8YQeFldcfETWFDiKR06bGB8TZ7laX857kjBV xtkySLoeQEg5l/JObJYf+nf+6N2J61klITTtSAaWy3OeGioZ4I2XB0WCDW1eFSahKDumKlTpi16xg ulRnTH8jYjobjC0nLP5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wry0f-00000005sDU-3QEo; Thu, 06 Aug 2026 13:19:45 +0000 Received: from mgamail.intel.com ([192.198.163.16]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wry0d-00000005s3x-3PDU for linux-i3c@lists.infradead.org; Thu, 06 Aug 2026 13:19:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022383; x=1817558383; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ji4ie/GLcul7bTKGn4Ajt86KyBmM01v6SZFIoSAtN/w=; b=LqeCnqlI6S5pLPjocIqxvD2cRHO78oPvk0HZ+dCrsT8BWDjL/0KM6zr9 o8c//C+4XacBT7bJYF77X/z354FxfVzVLo1VV5jnjXWOPIKvAGs0aZKwf 1otxeIeKKYNLopj8Z/ps+FH8Vc6m3lT9L8xrZZH9ne9yePOsa/DigzKrO CXxmrA+zXgbA0QKIo4Z7biteRa5X2w3qjH9NBPR3MOuFoDX0oe5b7XVtm JoS5q5cJ+nlGeNMe/xz8x7ZDSM4IdsOSv+JXSJ1yXri7e1nqMP2gwVcq5 Tv8vyEzeRuB+JGM2utdcz1wlYfugAWXlePuK16xTaymavx47l91g25kNi w==; X-CSE-ConnectionGUID: By0Wi0cJQY6VjfXENgmYDQ== X-CSE-MsgGUID: YJsernEwSFKMfSHjyKdB9g== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149648" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149648" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2026 06:19:43 -0700 X-CSE-ConnectionGUID: fi91vDf2S8mKpSD13rHn/Q== X-CSE-MsgGUID: 6gQmgClgR9Cd1z+4xp65tQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338283" Received: from mkosciow-mobl1.ger.corp.intel.com (HELO ahunter6-desk) ([10.245.244.200]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2026 06:19:41 -0700 From: Adrian Hunter To: alexandre.belloni@bootlin.com Cc: Frank.Li@nxp.com, akhilrajeev@nvidia.com, mukesh.savaliya@oss.qualcomm.com, rafael@kernel.org, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH V4 12/14] i3c: mipi-i3c-hci-pci: Propagate I3C wakeup requirements to PCI Date: Thu, 6 Aug 2026 16:18:55 +0300 Message-ID: <20260806131857.119830-13-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260806131857.119830-1-adrian.hunter@intel.com> References: <20260806131857.119830-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260806_061943_858888_71769A60 X-CRM114-Status: GOOD ( 15.25 ) X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Keep the PCI wakeup state aligned with the wakeup requirements of the devices served by the controller(s). The PCI function is the wakeup source for HCI instances exposed beneath it. However, wakeup is only needed when at least one attached I3C device is enabled as a wakeup source. During suspend, check whether any HCI instance has a wakeup-enabled I3C device and enable wakeup for the PCI function only in that case. Otherwise leave PCI wakeup disabled. Note, the suspend callback is used for both system and runtime suspend. Although this change may update the PCI wakeup state during runtime suspend, it does so only when the required wakeup state changes. Moreover, PCI wakeup-capable devices already have PME wakeup armed for runtime suspend, so changing the wakeup-enabled state does not affect runtime PM wakeup behavior. Note also, since the PCI wakeup state is derived from the wakeup configuration of the attached I3C devices, the PCI device power/wakeup sysfs attribute no longer provides independent wakeup control. Signed-off-by: Adrian Hunter --- Changes in V4: Updated for the rename of i3c_master_any_wakeup_enabled() to i3c_master_has_wakeup_enabled_devs(). Changes in V2 and V3: None .../master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c index 5a9e2a43eff8..42c172e82622 100644 --- a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c +++ b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c @@ -265,6 +265,8 @@ static bool mipi_i3c_hci_pci_is_operational(struct device *dev, bool update) struct mipi_i3c_hci_pci_pm_data { struct device *dev[INST_MAX]; int dev_cnt; + bool can_wakeup; + bool may_wakeup; }; static bool mipi_i3c_hci_pci_is_mfd(struct device *dev) @@ -272,6 +274,13 @@ static bool mipi_i3c_hci_pci_is_mfd(struct device *dev) return dev_is_platform(dev) && mfd_get_cell(to_platform_device(dev)); } +static bool mipi_i3c_hci_pci_any_wakeup_enabled(struct device *dev) +{ + struct i3c_hci *hci = dev_get_drvdata(dev); + + return i3c_master_has_wakeup_enabled_devs(&hci->master); +} + static int mipi_i3c_hci_pci_suspend_instance(struct device *dev, void *data) { struct mipi_i3c_hci_pci_pm_data *pm_data = data; @@ -287,6 +296,9 @@ static int mipi_i3c_hci_pci_suspend_instance(struct device *dev, void *data) pm_data->dev[pm_data->dev_cnt++] = dev; + if (pm_data->can_wakeup && mipi_i3c_hci_pci_any_wakeup_enabled(dev)) + pm_data->may_wakeup = true; + return 0; } @@ -317,12 +329,19 @@ static int mipi_i3c_hci_pci_suspend(struct device *dev) if (!hci->info->control_instance_pm) return 0; + pm_data.can_wakeup = device_can_wakeup(dev); + ret = device_for_each_child_reverse(dev, &pm_data, mipi_i3c_hci_pci_suspend_instance); - if (ret) + if (ret) { for (int i = 0; i < pm_data.dev_cnt; i++) i3c_hci_rpm_resume(pm_data.dev[i]); + return ret; + } - return ret; + if (device_may_wakeup(dev) != pm_data.may_wakeup) + device_set_wakeup_enable(dev, pm_data.may_wakeup); + + return 0; } static int mipi_i3c_hci_pci_resume(struct device *dev) -- 2.53.0 -- linux-i3c mailing list linux-i3c@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-i3c