From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA7CD336EC0; Thu, 6 Aug 2026 13:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022364; cv=none; b=kRFasMSDIQquGrtA1igI9Uc2hxV7DM6sYNZHlkoXRSqRzHgWitXh9JFoOTQ3jeVNArPpUSBNCxDuB+gITCbm1o5/qPMHv19s4hEnOKBFQ9Rd/kK14qGOOw6P8OtFIDYyJT7Tto3kvyf2w0KKUFoK4C6s2MvpBJPGHlXnoz/DiG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022364; c=relaxed/simple; bh=8qnas1z0yzFN13YNJ/JLjoAtaKWli/KcWEU4XZkGZg4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jsveZx9ELPWbph3rkzacppFTiLSDPjzC0J/8T3IC74tBTQyfJvA1SYMcq4S2kWY7mqOV2aL2O0pmiG2wt37rpvWbpXYwsM8jjbwqGD/mrm4Afo9Xjg4iZPhCYDnZjFedJyR+1PPlJYdIJANAXIh51akyqh+OVF/QTv1r74XTf94= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lXqWuE9C; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lXqWuE9C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022360; x=1817558360; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8qnas1z0yzFN13YNJ/JLjoAtaKWli/KcWEU4XZkGZg4=; b=lXqWuE9COGOAw4UA2n2IuItTXNIiWo9wyOMLHlCkecFxarZ6NLEUHVEU Z+qQucHVKB4XfAT5Dem9ajBj+rFUmUW0VX0ORgbXt1JhM3DsTpML+qSBT VNkLGf6XN5AjvGqV3u8eP+PXurnHvXTnCsagABMzkFk4/gttX6P2O+CR/ Zx6OLTsFtIhtIzuzE43F7YhAMl0fcbOcPDzfoE5l+FACof1MWfjH1S5jn kNnX8mmVgIBMLhyRyi9S3+eBsxw0rN/Tmm9V2UHNzFqw0WPZwn2GgoVlu /sXQ/0fdblGs1mOImBBLXHLIqoNrCL8OpS2FUAmzzzeVIdLfFAt+5DSwh Q==; X-CSE-ConnectionGUID: s2dDDLr+SKuxZW9BJ6q4EQ== X-CSE-MsgGUID: 4mIFs2lTQz2mTKKmOG4KqQ== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149511" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149511" 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:11 -0700 X-CSE-ConnectionGUID: 9ZPlh3lCTs6KcgQ5p0szrg== X-CSE-MsgGUID: vBveXvr1SjOXi5CNKQYXuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338057" 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:08 -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 01/14] i3c: master: Fix recursive locking during device registration Date: Thu, 6 Aug 2026 16:18:44 +0300 Message-ID: <20260806131857.119830-2-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" i3c_master_register_new_i3c_devs() registers newly discovered devices while holding i3c_bus_normaluse_lock(), a down_read(). device_register() can immediately probe the device, and probe callbacks typically invoke I3C helpers that take i3c_bus_normaluse_lock() again, leading to a recursive acquisition of the same rwsem. rwsems do not support recursive read locking and can deadlock when a writer is waiting. See the "Recursive read locks" section of Documentation/locking/lockdep-design.rst. For example, with Intel LPSS I3C, LOCKDEP generates a WARNING like: # echo intel-lpss-i3c.0 > /sys/bus/platform/drivers/mipi-i3c-hci/unbind # echo intel-lpss-i3c.0 > /sys/bus/platform/drivers/mipi-i3c-hci/bind WARNING: possible recursive locking detected kworker/5:1/94 is trying to acquire lock: ffff88811c810d78 (&i3cbus->lock){++++}-{4:4}, at: i3c_device_match_id+0x4= 5/0x370 but task is already holding lock: ffff88811c810d78 (&i3cbus->lock){++++}-{4:4}, at: i3c_master_reg_work_fn+= 0x21/0x5f0 Fix this by separating device creation from device registration. Populate desc->dev under the maintenance lock, collect the devices that still need registration into a local list, then release the lock before calling device_register(). Finally retake the lock and clean up any devices that failed to register. Use the maintenance lock rather than the normal-use lock while adding device objects. A write-side maintenance lock prevents readers from observing a partially initialized desc->dev during initial device population, or desc->dev disappearing if registration fails. The local list requires a list node, so add a list node member to struct i3c_device. Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Reviewed-by: Frank Li --- Changes in V4: Expanded the kernel-doc for the new struct i3c_device @node member to note that it is only for use by i3c_master_register_new_i3c_devs() and is not protected by a lock. Changes in V3: Added Cc: stable@vger.kernel.org Changes in V2: New patch drivers/i3c/master.c | 45 ++++++++++++++++++++++++++++---------- include/linux/i3c/master.h | 3 +++ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index f485b98805cf..d2fb1a110521 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2069,12 +2069,21 @@ static int i3c_master_early_i3c_dev_add(struct i3c_= master_controller *master, static void i3c_master_register_new_i3c_devs(struct i3c_master_controller *master) { + struct i3c_device *i3cdev, *tmp; struct i3c_dev_desc *desc; + LIST_HEAD(i3c_unreg_devs); int ret; =20 if (!master->init_done) return; =20 + i3c_bus_maintenance_lock(&master->bus); + + if (master->shutting_down) { + i3c_bus_maintenance_unlock(&master->bus); + return; + } + i3c_bus_for_each_i3cdev(&master->bus, desc) { if (desc->dev || !desc->info.dyn_addr || desc =3D=3D master->this) continue; @@ -2104,25 +2113,37 @@ i3c_master_register_new_i3c_devs(struct i3c_master_= controller *master) if (desc->boardinfo) device_set_node(&desc->dev->dev, desc->boardinfo->fwnode); =20 - ret =3D device_register(&desc->dev->dev); - if (ret) { - dev_err(&master->dev, - "Failed to add I3C device (err =3D %d)\n", ret); - desc->dev->desc =3D NULL; - put_device(&desc->dev->dev); - desc->dev =3D NULL; - } + list_add_tail(&desc->dev->node, &i3c_unreg_devs); + } + + i3c_bus_maintenance_unlock(&master->bus); + + list_for_each_entry_safe(i3cdev, tmp, &i3c_unreg_devs, node) { + ret =3D device_register(&i3cdev->dev); + if (ret) + dev_err(&master->dev, "Failed to add I3C device (err =3D %d)\n", ret); + else + list_del_init(&i3cdev->node); + } + + i3c_bus_maintenance_lock(&master->bus); + + list_for_each_entry_safe(i3cdev, tmp, &i3c_unreg_devs, node) { + list_del(&i3cdev->node); + desc =3D i3cdev->desc; + i3cdev->desc =3D NULL; + put_device(&i3cdev->dev); + desc->dev =3D NULL; } + + i3c_bus_maintenance_unlock(&master->bus); } =20 static void i3c_master_reg_work_fn(struct work_struct *work) { struct i3c_master_controller *master =3D container_of(work, typeof(*maste= r), reg_work); =20 - i3c_bus_normaluse_lock(&master->bus); - if (!master->shutting_down) - i3c_master_register_new_i3c_devs(master); - i3c_bus_normaluse_unlock(&master->bus); + i3c_master_register_new_i3c_devs(master); } =20 /** diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 2dc139a217bf..26535beb1e77 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -238,6 +238,8 @@ struct i3c_dev_desc { * every time the I3C device is rediscovered with a different dynamic * address assigned * @bus: I3C bus this device is attached to + * @node: unregistered device list node, only for use by + * i3c_master_register_new_i3c_devs(), it is not protected by a lock * * I3C device object exposed to I3C device drivers. The takes care of link= ing * this object to the relevant &struct_i3c_dev_desc one. @@ -248,6 +250,7 @@ struct i3c_device { struct device dev; struct i3c_dev_desc *desc; struct i3c_bus *bus; + struct list_head node; }; =20 /* --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6421E2F8EA1; Thu, 6 Aug 2026 13:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022373; cv=none; b=g/7fWd+ujtXgSLDXx766SMTb8aCyMdCvADZay1LuVLXWTZ6nzEx/IHX6PVBKQEafvVvZBTq+i7uvUQW6y0c03yX3+Db9iu6MIDZeGyBYOXysAZV/HKfYr1x4U6XHFc31kImPDgaZ0OfoANC6g8a2cX71zQ8HtVuTmg25SqmfWcI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022373; c=relaxed/simple; bh=m+vaP+hUhXQyQtti8rw2K8d44e4Og780oMqT54taEy0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PancwcQ7zhb21MzpOKCn/6RWg/BLKvzlfdWpQHhx9uOmpvmN6b20kWXU2r8T4rJn91/BKFx6Nibknl7lOekIusboTGiY34x4QUeQuT5gcpwA3TYu/r4haPVvfSC+YEQ8UCEI/QTeOx1MvZUPohz5HUL+9r7iBS4rC4MvVoJS4WA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=PlWj2KDx; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PlWj2KDx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022363; x=1817558363; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m+vaP+hUhXQyQtti8rw2K8d44e4Og780oMqT54taEy0=; b=PlWj2KDxNOjTtxHbHLml7T7gPJ0qn89zWx1rLHhYjlq1iuiMtyrjnbyJ 7N8hNBtr+I9liLrm3p6C4CNbklRtpONLLw8bILQR66TjR38zP9iPrM+L6 dyHg6hD6BXtGecSTXEgQSEk5NCJjtFFSEvxUbV1m2qU0zf+Qnk4+POq+5 9LJqk2H/F9yFYSeQzZGonbtnKKVQ77jCWEeIjtZhnVLPn4ZiB2zy0JYYT aP7VkA1gw7+6wi6Eu1TIC+srxII3mMxtKWJFSLxc1uA102GtVlgkSxdES skOWyj5IihbdWeDvea7ZOzkNRYgeirUfx4nmbPxMSFUtFSw9DIU8vR7MG Q==; X-CSE-ConnectionGUID: pAD6bb9lSOyFGPs8JjSHqQ== X-CSE-MsgGUID: rUf8cEIsRTym0qOBmLsh0A== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149526" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149526" 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:14 -0700 X-CSE-ConnectionGUID: MxIAstuiTqe+XZrgiAh09Q== X-CSE-MsgGUID: EAitVmDZRfeBsJWc2EOqCQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338080" 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:11 -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 02/14] i3c: Fix unlocked dereference of dev->desc in i3c_device_get_supported_xfer_mode() Date: Thu, 6 Aug 2026 16:18:45 +0300 Message-ID: <20260806131857.119830-3-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" i3c_device_get_supported_xfer_mode() uses dev->desc to obtain the master controller. However, dev->desc must not be dereferenced unless bus->lock is held, and this function does not take that lock. The function only needs access to the master controller associated with the device's bus. Use dev->bus instead, which is always valid for the lifetime of the device and does not require dereferencing dev->desc. Fixes: 256a21743d91 ("i3c: Add HDR API support") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Reviewed-by: Frank Li --- Changes in V4: None Changes in V3: New patch drivers/i3c/device.c | 2 +- drivers/i3c/internals.h | 5 +++++ drivers/i3c/master.c | 6 ------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c index 101eaa77de68..a3778282e84c 100644 --- a/drivers/i3c/device.c +++ b/drivers/i3c/device.c @@ -309,7 +309,7 @@ EXPORT_SYMBOL_GPL(i3c_device_match_id); */ u32 i3c_device_get_supported_xfer_mode(struct i3c_device *dev) { - return i3c_dev_get_master(dev->desc)->this->info.hdr_cap | BIT(I3C_SDR); + return i3c_bus_to_i3c_master(dev->bus)->this->info.hdr_cap | BIT(I3C_SDR); } EXPORT_SYMBOL_GPL(i3c_device_get_supported_xfer_mode); =20 diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h index 0f1f3f766623..86a36b951e0d 100644 --- a/drivers/i3c/internals.h +++ b/drivers/i3c/internals.h @@ -72,4 +72,9 @@ static inline void i3c_readl_fifo(const void __iomem *add= r, void *buf, } } =20 +static inline struct i3c_master_controller *i3c_bus_to_i3c_master(struct i= 3c_bus *i3cbus) +{ + return container_of(i3cbus, struct i3c_master_controller, bus); +} + #endif /* I3C_INTERNAL_H */ diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index d2fb1a110521..c7bb52b71d88 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -102,12 +102,6 @@ void i3c_bus_normaluse_unlock(struct i3c_bus *bus) up_read(&bus->lock); } =20 -static struct i3c_master_controller * -i3c_bus_to_i3c_master(struct i3c_bus *i3cbus) -{ - return container_of(i3cbus, struct i3c_master_controller, bus); -} - static struct i3c_master_controller *dev_to_i3cmaster(struct device *dev) { return container_of(dev, struct i3c_master_controller, dev); --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B6F0333439; Thu, 6 Aug 2026 13:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022371; cv=none; b=d1paPT22FKzCV6X2AdD3tYnFYWGzClKUUTtvLmJWBlYWuSMGD0HicEedX4R7GZvXxPNMmxrGxTEbSRE+q05jgcG7ANsS78RYd9PuBnhavD7NNr51FLCFs1k0jHBdNfDDlTEnZiCBOhoGAb5JGJZl93VCvLDVsyfpc0xHUSEQLxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022371; c=relaxed/simple; bh=Mggui0CLcJI+CXEJWoxkotbs7prYgBI6zApoIT2r0N4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tpMWWAJvHjHvJ/cvHQjiz2buPa9ld8XS3mp3DK6Ymh6ngXSw9XwOvw+uvIOBQpxnIdb/E+wAZXq5qDTzalQGwOaKDARxRUydevZW2hUGb+DXhFBSy2icVEoi+ISAv2jHx8iMpxcCqU3a3PGh85FkdQtRNpQUCgkIFd83y37HGAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EhOa7L5y; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EhOa7L5y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022367; x=1817558367; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Mggui0CLcJI+CXEJWoxkotbs7prYgBI6zApoIT2r0N4=; b=EhOa7L5yu924GgvduD0/WUjNLJYMngg8CZHnXtN8VCFUrRShuuEX5VRa tQK2Cj6c9xaYmOWpFRZBL18jkbThj1BP9++kXZ+YWROKrYdGWqT+d9RhW cOy8nyk7OyyAR3Yks3qAdME/jyqlDuQ2FXTmKWy1MrglkmuEPlJAUcvVG 4l5LFifDVKScVocDSf95reA4Wdbscn8nz/mXj/ugYBMAUrrJrD+s3Aoy8 RZX+FEFTY5rgEvZosEEDzBDNt2WrLZ1K2mpV19vEcfu6xblkYsRA64Jit L/in7qyP1rLrnSqO8qdm2HyCHMS36X7u3ebEEKQDmBmy4P6KtO98+IRZz A==; X-CSE-ConnectionGUID: +UwBV44lQcShBvBycxFQ2A== X-CSE-MsgGUID: Qw4DSP6LQiyYke8NA35rNQ== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149544" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149544" 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:17 -0700 X-CSE-ConnectionGUID: DIQmaE+GQOuhRgUD+m1RbQ== X-CSE-MsgGUID: o+XS/H4RSC2+lGKUsYIoxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338101" 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:14 -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 03/14] i3c: master: Do not treat master device as a duplicate target Date: Thu, 6 Aug 2026 16:18:46 +0300 Message-ID: <20260806131857.119830-4-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" i3c_master_search_i3c_dev_duplicate() searches the bus for another I3C device with the same PID as the reference device. The search can match master->this, causing the controller itself to be returned as a duplicate. Since the controller is not a target device, it cannot be a duplicate of one. Exclude master->this from matching so that the function only returns real duplicate target devices. Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Reviewed-by: Frank Li Acked-by: Mukesh Savaliya --- Changes in V4: Added Frank's Rev-by and Mukesh's Acked-by tags Changes in V3: New patch drivers/i3c/master.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index c7bb52b71d88..abb582645a2e 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2545,7 +2545,8 @@ i3c_master_search_i3c_dev_duplicate(struct i3c_dev_de= sc *refdev) =20 i3c_bus_for_each_i3cdev(&master->bus, i3cdev) { if (i3cdev !=3D refdev && i3cdev->info.pid && - i3cdev->info.pid =3D=3D refdev->info.pid) + i3cdev->info.pid =3D=3D refdev->info.pid && + i3cdev !=3D master->this) return i3cdev; } =20 --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1BFF1CEADB; Thu, 6 Aug 2026 13:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022374; cv=none; b=TvZa2UroVgeEKvpVEMb0Y45tCVYCSscFluNIAiT7tEwrIcDuyLE4iIYITR5lw+MOqJRXGYqQRDE5+wD+xIqLJ1gCwWrS+VdJUY9wWk5HhFXt/nVOSVDhA8c3teYSJ6nNpj5VB5LLVZ/3J+HuUQffoNmNoGps86d1TLsw9SMbyxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022374; c=relaxed/simple; bh=aAlpC53BvxqcWVxTMHsq4k18TBokrrycgeE2Ij9anUM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ma/cPbEhDgj/KR4P2WXjjlNy73CW1LRdZb5BMwDNxz/4VeVEP1qdoXEEKZ7EOtAx6ZJgm2Urb2xs7fWZ8WqHmADcc2x0jQYI7j0gNJVhF/Eict77a6c2lSn/QwQFnFi0s3ZkWgnxAfcvx4NxHOjb3AVW5sWmXlLRIGKO2zztzZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=O/L+8KOK; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="O/L+8KOK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022367; x=1817558367; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aAlpC53BvxqcWVxTMHsq4k18TBokrrycgeE2Ij9anUM=; b=O/L+8KOKjjfQ1lDphG4grTP2pnXigpH0i/wJWmU/RnJxDVoo2VAyySIp qOykaKs4eCMVFvbkN3q9wzZ/ZUEiZ/mdtotnd/HLQHoVATumTX2Ujll0p 23PdehHuSgYqj+GGQETWMMF/NZrM4gf9y3yh2966nxKKzhnXn6/wVhQow XTe1RKRJrCiR+mV4pN2XeLDA3iIASwnKlnXcI7NePsvzqJDyESgUDV95p 8pWPoD12zGw0ZfWfjs/kl13tQKkK7JAWp/76KINFJkNkyBMCqcGzRPNeA DrA0x80Ol9Ec1Us0JfkPRGwgc/MOhOvBJBr+B9MQJD9zyR/OLmJDNtvTd g==; X-CSE-ConnectionGUID: M1MdpKrtRx+PMruut42AGg== X-CSE-MsgGUID: fXyHN+k3RfKhxy+bjCiXVA== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149558" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149558" 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:20 -0700 X-CSE-ConnectionGUID: mSUQJ4j3R4e+2ONLuus+NQ== X-CSE-MsgGUID: 9Hoa0CYlR1aicsUq9ldLsA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338128" 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:17 -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 04/14] i3c: master: Fix use-after-free of master->this Date: Thu, 6 Aug 2026 16:18:47 +0300 Message-ID: <20260806131857.119830-5-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" sysfs attribute callbacks for the master controller device dereference master->this. However, master->this is freed in i3c_master_detach_free_devs() before the master device itself is released. As a result, sysfs accesses can dereference a freed master->this pointer, leading to a use-after-free. Keep master->this alive until i3c_masterdev_release(), which is called after the master device and its sysfs state are being torn down. Do not free master->this as part of the normal device detach path. On the error path in i3c_master_set_info(), reset master->this and bus.cur_master to NULL before freeing the allocated device. Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Reviewed-by: Frank Li --- Changes in V4: Also reset master->this and bus.cur_master to NULL on the i3c_master_set_info() error path before freeing the allocated device. Tidied up the commit message wording. Changes in V3: New patch drivers/i3c/master.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index abb582645a2e..2357874bb9d6 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -842,6 +842,11 @@ static struct attribute *i3c_masterdev_attrs[] =3D { }; ATTRIBUTE_GROUPS(i3c_masterdev); =20 +static void i3c_master_free_i3c_dev(struct i3c_dev_desc *dev) +{ + kfree(dev); +} + static void i3c_masterdev_release(struct device *dev) { struct i3c_master_controller *master =3D dev_to_i3cmaster(dev); @@ -854,6 +859,8 @@ static void i3c_masterdev_release(struct device *dev) i3c_bus_cleanup(bus); =20 fwnode_handle_put(dev->fwnode); + + i3c_master_free_i3c_dev(master->this); } =20 static const struct device_type i3c_masterdev_type =3D { @@ -1125,11 +1132,6 @@ static void i3c_device_release(struct device *dev) kfree(i3cdev); } =20 -static void i3c_master_free_i3c_dev(struct i3c_dev_desc *dev) -{ - kfree(dev); -} - static struct i3c_dev_desc * i3c_master_alloc_i3c_dev(struct i3c_master_controller *master, const struct i3c_device_info *info) @@ -2266,6 +2268,8 @@ int i3c_master_set_info(struct i3c_master_controller = *master, return 0; =20 err_free_dev: + master->bus.cur_master =3D NULL; + master->this =3D NULL; i3c_master_free_i3c_dev(i3cdev); =20 return ret; @@ -2286,7 +2290,8 @@ static void i3c_master_detach_free_devs(struct i3c_ma= ster_controller *master) i3cdev->boardinfo->init_dyn_addr, I3C_ADDR_SLOT_FREE); =20 - i3c_master_free_i3c_dev(i3cdev); + if (i3cdev !=3D master->this) + i3c_master_free_i3c_dev(i3cdev); } =20 list_for_each_entry_safe(i2cdev, i2ctmp, &master->bus.devs.i2c, --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E1FB3382DA; Thu, 6 Aug 2026 13:19:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022376; cv=none; b=EXbkYc7CBLDMM8jWuQZzJlxqBffGmcQiShIu2riGjEqpc3Jt7d9Fxr+7lkoLSO6eaIubgy+hl2kqlX2yVmDgiYPwHisMBADRlimXAJ9kGqpj0bwDFIO6v4x5P6a7f5OqkNrXRiScwFD+ldFpvm3Y9B9PMJUWAuphVpZfGTczduo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022376; c=relaxed/simple; bh=ABmprPYDSs94JgmPD621KnGiMs78sdq749qZ4lkLmek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rJpkIT4M/AxQsbhqNybrsoNLgDtHxxC6fMQh6yMZwe4+wECcdcrhSbIww5QPWFsZzq7fAaFD8/8ZtrZVVCqsJJSmKt7jcP7bAQ1387RfCQiUs+cfD7zuBzW9QaeDYWMNAG7wIpdNM7PylWKdJxFoMXcXfYwbXux7xX1uKfgTJf4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TtFIE6Jv; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TtFIE6Jv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022374; x=1817558374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ABmprPYDSs94JgmPD621KnGiMs78sdq749qZ4lkLmek=; b=TtFIE6JvJZbZz9tXcNLO5VZKQwawqCh9752i1jXbJC/FF+Z7AJKb3YWB LoCO2WIoABLZhRMnhymv20cJP8fclnHbTqS+yqNgbyLoT/5q1lX5vxWtJ 6J3xZV3O3Um0Xkh3+NWaE0DfVgjsc/odoIS5IKQIGTw9uQThR8I7sWZlP wdEsFj4TeZpsyHI33IZZoCnksviIimV5og6jmUe+wim52PaVqUNu1T+4L wSiR/YMt6wJZSlsEiaT8t+bu7ry+5hqtROSjUscUmkhAAZFmhaaeluBWh 2s/TkqskwBfPPnIzfnbC18vN+3CA7vYCfyDtV3Nt3U92499TKtLD9MbzR A==; X-CSE-ConnectionGUID: WBGFVekRRsWdqqPUwaCLIA== X-CSE-MsgGUID: qo1rvv+NTvKTTosQjl7GjA== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149567" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149567" 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:23 -0700 X-CSE-ConnectionGUID: hxxvVUh9TtWk+NcT2tyG7A== X-CSE-MsgGUID: GBW5ajFkQ7a/wN46BVX+NA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338139" 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:20 -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 05/14] i3c: Make dev->desc locking assumptions explicit Date: Thu, 6 Aug 2026 16:18:48 +0300 Message-ID: <20260806131857.119830-6-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" i3c_device_get_info() takes the bus normal-use lock before accessing dev->desc. Under that lock, the descriptor pointer is guaranteed to be valid for the duration of the access. Remove the unnecessary NULL check on dev->desc so the code more clearly reflects the locking rules and expected descriptor lifetime. Signed-off-by: Adrian Hunter Acked-by: Mukesh Savaliya Reviewed-by: Frank Li --- Changes in V4: Added Mukesh's Acked-by tag Changes in V3: New patch drivers/i3c/device.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c index a3778282e84c..5e6df6de0283 100644 --- a/drivers/i3c/device.c +++ b/drivers/i3c/device.c @@ -101,8 +101,7 @@ void i3c_device_get_info(const struct i3c_device *dev, return; =20 i3c_bus_normaluse_lock(dev->bus); - if (dev->desc) - *info =3D dev->desc->info; + *info =3D dev->desc->info; i3c_bus_normaluse_unlock(dev->bus); } EXPORT_SYMBOL_GPL(i3c_device_get_info); --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D92E331ECB; Thu, 6 Aug 2026 13:19:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022377; cv=none; b=DqoRBLrg6RN1AI8ch8yZSZ1V78nyosBeVKtiaNyU1mgX8hOp0w8Ag7Zy7KzVSfZ4wMNLILlEYLzLArhsGJFdWiOqRn0HXsXhd7VK/AqnxWyANfipX+Ztjbys5EnVDgzEWe/y+QW5hcAh++pjLQHt4blC6XH/Zq110Val1VK2Zfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022377; c=relaxed/simple; bh=HlQruraA7agKiqxVYRqDPlUkqImO4uUYgYC2j57DVk0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ggJuGLQnC667o9Acm4NBDmXfBhtv4tn9806kaxR0aesaO+S47hLTEfiZE8OrK+RNCQixyggIOaBa7jA6Gj+Ix+Fec/8R9zTISc7NS9lgfTEhu3vDEk0cogn2EpdVctbsH/4E6D6ejxfpeJ7ekCDHlH+W/ssEFSEDk15zeoR9M/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nZNWwiCe; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nZNWwiCe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022374; x=1817558374; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HlQruraA7agKiqxVYRqDPlUkqImO4uUYgYC2j57DVk0=; b=nZNWwiCe6dTqvBpkTV1Rik7MLN3yXYksHTVWBFV+wEtqBRlzTRpjEK4Q olbGU+QoRRaUGEs+keTewWWzhjR1csB9wN9cBKCG7gzVsuSec9Frt86QX aWsy6NJOxbPs+hjDvSEOIWaXObVGCt7453nDtL4BoZBB8l8lUi2DjjX5F YYJR+kREfAht+89/vxsXP4Tf5M9wNQL/zmjLONkNyvTmt72kXrmS4tbMi S4WwFqAAEeif5eUDBL4TpBAKBJL7HE5Hiu48OObC8A/rqQKCgQ2T+0XfC ODEs+6g1HdIyfTgGGuRlCYi1+zDTaxDIBETEavOO5wZ/teAqFGj1ldqsE A==; X-CSE-ConnectionGUID: zswBaQKxRFuRARiVjoxdrg== X-CSE-MsgGUID: by4cdbdoQ1SZDqNzzA14Gg== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149577" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149577" 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:26 -0700 X-CSE-ConnectionGUID: ECrO4ecXS0atukBeJI+Grw== X-CSE-MsgGUID: fXyMbzWIRK+RDz74/dKaqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338168" 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:23 -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 06/14] i3c: master: Fix potential UAF in i3c_device_uevent() Date: Thu, 6 Aug 2026 16:18:49 +0300 Message-ID: <20260806131857.119830-7-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" i3c_device_uevent() dereferences i3cdev->desc without holding the bus normal-use lock. Since the descriptor pointer can be replaced concurrently, including when a uevent is generated from sysfs, this can result in dereferencing a stale descriptor and lead to a use-after-free. Use i3c_device_get_info() instead, which protects access to the descriptor with the normal-use lock. Commit 6cf7b65f7029 ("i3c: Use i3cdev->desc->info instead of calling i3c_device_get_info() to avoid deadlock") replaced the accessor with a direct descriptor dereference because i3c_device_get_info() would recursively acquire bus->lock during device registration. This change depends on "i3c: master: Fix recursive locking during device registration", which moves device registration out from under bus->lock and removes the possibility of that deadlock. Without that change, restoring the i3c_device_get_info() call would reintroduce the deadlock. Fixes: 6cf7b65f7029 ("i3c: Use i3cdev->desc->info instead of calling i3c_de= vice_get_info() to avoid deadlock") Cc: stable@vger.kernel.org # requires "i3c: master: Fix recursive locking d= uring device registration" Signed-off-by: Adrian Hunter Acked-by: Mukesh Savaliya Reviewed-by: Frank Li --- Changes in V4: Added Mukesh's Acked-by tag Changes in V3: New patch drivers/i3c/master.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 2357874bb9d6..ee771ac0b203 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -316,8 +316,7 @@ static int i3c_device_uevent(const struct device *dev, = struct kobj_uevent_env *e struct i3c_device_info devinfo; u16 manuf, part, ext; =20 - if (i3cdev->desc) - devinfo =3D i3cdev->desc->info; + i3c_device_get_info(i3cdev, &devinfo); manuf =3D I3C_PID_MANUF_ID(devinfo.pid); part =3D I3C_PID_PART_ID(devinfo.pid); ext =3D I3C_PID_EXTRA_INFO(devinfo.pid); --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FAA7373BE0; Thu, 6 Aug 2026 13:19:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022380; cv=none; b=M9ecUfca1WMy3XloLpRz8HYZFLx2Lj3kZ+hOn+MAAE0oC4H7K+SaYpnC4lRaU9Sb/EIovXlB0Z57CB3/I3d3XPeFt7FxiM0ChbsldcUQr5kq5pb+jb819QYmYuJSfYlIFNxvmIN6UQMounm/HSWNDe00mMCY6UqMbrxyYEaKLLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022380; c=relaxed/simple; bh=dRpafqq+wNMr/EYQqjCT5QMFngA9hTqwKopSC/ZJKuc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OTA6DOZROnmhu/9w3gON6vSSUdWiV9SDz9CKjqHherCIksZWkgzCnz1NQKDA4NOW1EsVMp86en6Vhg/VJCzHdJbMXWS5W7q1BXEgNDvN6xic4G5sr7mTvgup6t3NNi/CtOEPVuWSC3/d5r7ItkWGDCqXzH2rosx3AAQD3YeOuZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AC5fFtkD; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AC5fFtkD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022376; x=1817558376; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dRpafqq+wNMr/EYQqjCT5QMFngA9hTqwKopSC/ZJKuc=; b=AC5fFtkDoEExmuktDl7U6Zi1C+a2T0FclDALLf5bfYaNow9GIlAH4gGb l3cpphExw2ldn55PYIUyU2xZKkj5zUvy58YhiVDL21NH5HETbck+0WOBU sogzD8qPeD2R+9oKIKp8KPsvVbqdh78a881QhEhsMkfdueW7Muv2htghP S5IXvJEF2EUopRFlQSRExYYLocAApRvOPgCUUh1QXKzG350W1M93x8Izx 174bGUeMQvAnj03xm5sTDq3Cfv//K5Z34PzuIFWJfjqflpsSy4vI0eHIA H9GtdeTwckOCHzc6xrbCiLafXw2bw0rE8ZCX0yvxhjqrq7MOsyIoRr+zO g==; X-CSE-ConnectionGUID: 2jct0b4lSZK+db6nFX+8Yg== X-CSE-MsgGUID: WCjHHs/XRPCuQeTUSrp+EQ== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149590" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149590" 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:29 -0700 X-CSE-ConnectionGUID: YwbflQISQ5GUyI0E/WfZEA== X-CSE-MsgGUID: /fyyX5WEStKvq9ym9PXVKw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338186" 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:26 -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 07/14] i3c: master: Fix potential UAF in i3c_device_match() Date: Thu, 6 Aug 2026 16:18:50 +0300 Message-ID: <20260806131857.119830-8-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" i3c_device_match() dereferences i3cdev->desc without holding the bus normal-use lock. Since the descriptor pointer can be replaced concurrently, the dereference can race with descriptor replacement and result in a use-after-free. Protect access to i3cdev->desc with the normal-use lock. While the lock is held, the descriptor is guaranteed to remain valid, so the NULL check is also unnecessary and can be removed. This change depends on "i3c: master: Fix recursive locking during device registration". Prior to that change, taking the normal-use lock in i3c_device_match() could recurse on bus->lock during device registration. This fixes "i3c: master: match I3C device through DT and ACPI". Signed-off-by: Adrian Hunter --- Changes in V4: None Changes in V3: New patch drivers/i3c/master.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index ee771ac0b203..83e04a2c202a 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -347,8 +347,10 @@ static int i3c_device_match(struct device *dev, const = struct device_driver *drv) i3cdev =3D dev_to_i3cdev(dev); i3cdrv =3D drv_to_i3cdrv(drv); =20 - if (i3cdev->desc && i3cdev->desc->boardinfo) + i3c_bus_normaluse_lock(i3cdev->bus); + if (i3cdev->desc->boardinfo) static_addr_method =3D i3cdev->desc->boardinfo->static_addr_method; + i3c_bus_normaluse_unlock(i3cdev->bus); =20 /* * SETAASA-based devices need not always have a matching ID since --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C78F73769E4; Thu, 6 Aug 2026 13:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022383; cv=none; b=TAWGCM2YU1oiQJ59JKdCLElHWGJaTCAQlFnaLetormRZIafYjYWoS0wbUqeOc+lWHMYHZKtEcLMhpHCWi5uLN/irmI4Vr2j6RBl/QS0lsuB4zU4wDdMb0d/vsdU5u13amiT0S7A0KRWc1kQ6maIyd41dUUPlJuD2LDsGF2bZWow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022383; c=relaxed/simple; bh=/i0Yn5fg2OAPraeuV4Q5SOyPrE1P3/F/uvz9vi20wXo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jARmrhEbnzogvmf3eFFOk+vrA0s2g76bjtS6wcnkem+5KZRLSuofF4z6g1m7c3dqF67yh24rvI7hMwDjpEDv8kWjSUGzcukU6oa21JpSe6VrzGwYZlsqstFHlWk68oaCrfG6fjsRb2th58lZ05SxsF1zbjoFL+f2tlJSbc62wbc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=cDBodqv1; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cDBodqv1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022378; x=1817558378; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/i0Yn5fg2OAPraeuV4Q5SOyPrE1P3/F/uvz9vi20wXo=; b=cDBodqv1lQRJR+8wFj9xC23Yuxpk5M7VCKOavFWDk31nyxG0w8wc6+e2 rIju1kDBa+Kb79AbzWEicKF26Ej5or7qpbUE3gpusw84rqzssP96L5TYg cTDmNZ8EXotZSl4iC9F5q9QezERFPKmht8IN1Ya4FAn1xOQCz+q4Czve9 YT7GvgKtqvklqFv8SB6XP4e+t1ijjOh7iM7nFZJnhMNVpmNNTZw8IUb2h l24Rv1BCGT+o6Rq0w8PXBfuyo7r+aYUSF+geRGD/HVec1GfqmxJ0Ct9CQ iNHmIdiohUiIH2RymojAgEChnSroAU3tagJfbpDIQk4DagdD1dVsQK4Uv g==; X-CSE-ConnectionGUID: atWiyGMAQfCHnPg9yukTgA== X-CSE-MsgGUID: 8gKqYH+cTxWjcuqoaSHeGQ== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149602" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149602" 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:31 -0700 X-CSE-ConnectionGUID: FIeopfLGQG29bRMHq5QZgQ== X-CSE-MsgGUID: YmKWhKUHR3qlAG8A/YfDJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338203" 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:29 -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 08/14] i3c: master: Support IBI-based wakeup capability Date: Thu, 6 Aug 2026 16:18:51 +0300 Message-ID: <20260806131857.119830-9-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An I3C controller acts as a bus controller for one or more I3C devices. If the controller can wake the system in response to an In-Band Interrupt (IBI), then any device on that bus that is capable of generating IBIs can potentially be used as a wakeup source. Add an ibi_wakeup flag to struct i3c_master_controller so controller drivers can advertise support for IBI-based wakeup. If set, mark IBI-capable I3C devices as wakeup capable when they are registered, allowing wakeup management through the standard device wakeup framework. Signed-off-by: Adrian Hunter Reviewed-by: Frank Li Acked-by: Mukesh Savaliya --- Changes in V4: Shortened the comment about IBI-capable devices being wakeup capable. Changes in V3: None Changes in V2: Dropped the redundant #include . That header must not be included directly, and linux/device.h, which is already included, provides device_set_wakeup_capable(). drivers/i3c/master.c | 4 ++++ include/linux/i3c/master.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 83e04a2c202a..2616354dbe54 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2110,6 +2110,10 @@ i3c_master_register_new_i3c_devs(struct i3c_master_c= ontroller *master) if (desc->boardinfo) device_set_node(&desc->dev->dev, desc->boardinfo->fwnode); =20 + /* If the device has IBI capability, set as wakeup capable */ + if (master->ibi_wakeup && (desc->info.bcr & I3C_BCR_IBI_REQ_CAP)) + device_set_wakeup_capable(&desc->dev->dev, true); + list_add_tail(&desc->dev->node, &i3c_unreg_devs); } =20 diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 26535beb1e77..9d675d01522c 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -524,6 +524,7 @@ struct i3c_master_controller_ops { * @hotjoin: true if the master support hotjoin * @rpm_allowed: true if Runtime PM allowed * @rpm_ibi_allowed: true if IBI and Hot-Join allowed while runtime suspen= ded + * @ibi_wakeup: IBI can wakeup the system * @shutting_down: set to true when master begins shutdown or unregister * @boardinfo.i3c: list of I3C boardinfo objects * @boardinfo.i2c: list of I2C boardinfo objects @@ -563,6 +564,7 @@ struct i3c_master_controller { unsigned int hotjoin: 1; unsigned int rpm_allowed: 1; unsigned int rpm_ibi_allowed: 1; + unsigned int ibi_wakeup: 1; bool shutting_down; struct { struct list_head i3c; --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80CA131F98F; Thu, 6 Aug 2026 13:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022383; cv=none; b=khKfjNso80Yy5s3eJkKpC6nGDdBmfFvnLFARKDQw1Ngy5OEve3eI3Ji05lvD/DNVp/SwCQ6kEVKJgJciMoNLceCR7kxuIt8hxeuSSW1vyNlEGvtvDnLUiUSyVdwENdsn1WVrh6N4FL6fasc52kDQyF9LErv83v4mlmaIN8ed5Bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022383; c=relaxed/simple; bh=8cXJv+a33kqp6eilmp46Qbbm+eANnhR9qHTgafUpDR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gCoid+7QBBM13k6HsCycbxIyregRjLsZOKNOaEcQUFeITq8eOLxrlEyXTRhBjsrQlDLMdaI0Z99PjNH/0ZE0Tc60u7IejiMZyUa8GcObL+/LUeiHKPabW4RKAlkSdlbR/sE1rStLAijNnRMkDzA03mieVikH1r2xdREGQ8zFZ1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mQWWOQOr; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mQWWOQOr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022379; x=1817558379; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8cXJv+a33kqp6eilmp46Qbbm+eANnhR9qHTgafUpDR0=; b=mQWWOQOr+bKhIZktjom3aRza1PqNPtIFAcQsXnB7uD7eQSjB6ONWYdkI EJjXqtbbiNg251DSEej5pjRBHcH8fvWmxTpMRI0MEI7Pn6xW/Kl2fqbNr n1IQwHVbiSvn7ZWKSWGLrdmr7yLr2bo/X7C/HT2WG77wqa3+p/k6YKZSk 51L7BkaWtb19v4y7ZRy4+HRwkTVLBQYCW3itY7tVE/RPzUHE85J1anUJa eportzEU5je1pGk9cqcAWIGanmIMP+fda2gsx/0UpvnXzfg83RXgKml4y rCBsIOrvdKLBKu8yl1CiADcx1EKV6uaaull5un63ApxQbhhHDWaoNY5Pu g==; X-CSE-ConnectionGUID: XyJrNK3jRGaAPcylkiMHtg== X-CSE-MsgGUID: xl+mZtgyR5Cfw3U3c2jIIQ== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149614" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149614" 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:34 -0700 X-CSE-ConnectionGUID: FDHh+cuwTpKvjBriPUT4PQ== X-CSE-MsgGUID: ZfkrfyC7SYiat7ESCcIxAg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338228" 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:32 -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 09/14] i3c: master: Report wakeup events for IBIs Date: Thu, 6 Aug 2026 16:18:52 +0300 Message-ID: <20260806131857.119830-10-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" An I3C device configured as a wakeup source can wake the system by generating an In-Band Interrupt (IBI). When an IBI is queued for processing, record a wakeup event for the device if wakeup is enabled. Use a 100 ms processing interval to give the I3C device driver time to process the IBI. Signed-off-by: Adrian Hunter Reviewed-by: Frank Li --- Changes in V4: None Changes in V2 and V3: None drivers/i3c/master.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 2616354dbe54..6c5341491944 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -3384,6 +3384,9 @@ static void i3c_master_unregister_i3c_devs(struct i3c= _master_controller *master) } } =20 +/* Approximate time for IBI handler to run */ +#define I3C_WAKEUP_PROCESSING_TIME_MS 100 + /** * i3c_master_queue_ibi() - Queue an IBI * @dev: the device this IBI is coming from @@ -3397,6 +3400,9 @@ void i3c_master_queue_ibi(struct i3c_dev_desc *dev, s= truct i3c_ibi_slot *slot) if (!dev->ibi || !slot) return; =20 + if (device_may_wakeup(&dev->dev->dev)) + pm_wakeup_event(&dev->dev->dev, I3C_WAKEUP_PROCESSING_TIME_MS); + atomic_inc(&dev->ibi->pending_ibis); queue_work(dev->ibi->wq, &slot->work); } --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55CB5381E88; Thu, 6 Aug 2026 13:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022388; cv=none; b=ZJGq2LQifdX6RyXOoOyiJ3ZvTjFySer90KL2TO3hz6y51ib9qaLYX9nowVKNGmjmttOFhvgK+pR0ylEUZufKX/ECOXfvSSdlb90100N4WVU/0GNhJNPhtvOVCuW5Ns4RhK0RC0ygzS7XeOCNIvh3b7nUVf6+vX91SAdg6po+0FM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022388; c=relaxed/simple; bh=EtxnJOm3NSmACaS/tiOPyFKADy79NbBD5bCrwvIqOZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fO/Nx45oj6x6WiDCoMIcMFu0AmNuKZd7KDzfn2f2AwFg/74Ug9UsKy0yRDd/miDyMQitXQ4wxU4YIzu6DZzWF1ykkwvzAkFB3nLsgNLy4vLH9RV3yJepwWSYQCyn6dMcxy45zv8RxIgcx2cGlE9HMPWm8xDbp8w7qCtLEAuYrKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SVcH2Mix; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SVcH2Mix" 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=EtxnJOm3NSmACaS/tiOPyFKADy79NbBD5bCrwvIqOZU=; b=SVcH2MixhlXgCewfACueeafwx57vmwrAFIkJYlkjpOla4rrL+ecZwVJg GKdbRMAT8rcvVrIRLUsWjgd/pHJx70dTOswEpXAltxrn+uZa1WHtchygP tGvgwHFJBYiMcbNhmPT1mpQAsPSkG6LvjnPaC+o+ZS2YvbRAtoafPo6sK Xa0bmMzoa6UYWgeM/4IZs60RX705aqO6UT/Ga1+Hp8lgj5XJxuQbQOJ4U proHkqwwdyviHXOY4V6p8+UPW8x4M2B1d0qN5Tjxvozesac9GOr62Db5K eWmXwKRsgS6rWUHWpKcJqAuecAGqgQ7mB2yWPdrcpjNbmXxXtoovr/OYs w==; X-CSE-ConnectionGUID: luHJPCLsTrebu+m9AfpTUg== X-CSE-MsgGUID: Sw0ZFnzvRJKWI7w7jL5xbQ== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149622" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149622" 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:37 -0700 X-CSE-ConnectionGUID: MHq4+90MSm6Hln4i+ou1gA== X-CSE-MsgGUID: DhgyIspyRsmuZLe3Jlw7vw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338248" 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:35 -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 10/14] i3c: master: Add helper to query bus wakeup requirements Date: Thu, 6 Aug 2026 16:18:53 +0300 Message-ID: <20260806131857.119830-11-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add i3c_master_has_wakeup_enabled_devs(), which iterates over the devices on an I3C bus and reports whether any of them are enabled for system wakeup and have IBI enabled. Controller drivers can use this helper to determine whether wakeup support must remain available while the system is suspended. Signed-off-by: Adrian Hunter Acked-by : Mukesh Savaliya Reviewed-by: Frank Li --- Changes in V4: Renamed i3c_master_any_wakeup_enabled() to i3c_master_has_wakeup_enabled_devs(). Changes in V3: Skip the master device explicitly. Added kernel-doc noting that wakeup enablement is user space policy, so the helper is meant to be called from a system suspend callback. Changes in V2: i3c_master_any_wakeup_enabled() now also requires the device to have IBI enabled, not just system wakeup enabled, so that a device with no active IBI request does not keep PCI PME enabled. desc->ibi_lock is taken while checking. The commit message and kernel-doc are updated to match. drivers/i3c/master.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/i3c/master.h | 1 + 2 files changed, 36 insertions(+) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 6c5341491944..afcd7a21a3e6 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2147,6 +2147,41 @@ static void i3c_master_reg_work_fn(struct work_struc= t *work) i3c_master_register_new_i3c_devs(master); } =20 +/** + * i3c_master_has_wakeup_enabled_devs() - check if any device can wake the= system + * @master: I3C master controller + * + * Iterate over devices on the bus and return true if any device has + * system wakeup enabled and IBI enabled. + * + * Whether a device is enabled for system wakeup is user space policy, + * settable at any time through the device's power/wakeup sysfs attribute, + * so the answer is only stable once user space is frozen. Call this from + * a system suspend callback. + * + * Return: true if any device may wake the system via IBI, false otherwise. + */ +bool i3c_master_has_wakeup_enabled_devs(struct i3c_master_controller *mast= er) +{ + struct i3c_dev_desc *desc; + bool wakeup =3D false; + + i3c_bus_normaluse_lock(&master->bus); + i3c_bus_for_each_i3cdev(&master->bus, desc) { + if (!desc->dev || desc =3D=3D master->this || !device_may_wakeup(&desc->= dev->dev)) + continue; + guard(mutex)(&desc->ibi_lock); + if (desc->ibi && desc->ibi->enabled) { + wakeup =3D true; + break; + } + } + i3c_bus_normaluse_unlock(&master->bus); + + return wakeup; +} +EXPORT_SYMBOL_GPL(i3c_master_has_wakeup_enabled_devs); + /** * i3c_master_dma_map_single() - Map buffer for single DMA transfer * @dev: device object of a device doing DMA diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 9d675d01522c..82d9886e7f12 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -765,6 +765,7 @@ void i3c_generic_ibi_recycle_slot(struct i3c_generic_ib= i_pool *pool, struct i3c_ibi_slot *slot); =20 void i3c_master_queue_ibi(struct i3c_dev_desc *dev, struct i3c_ibi_slot *s= lot); +bool i3c_master_has_wakeup_enabled_devs(struct i3c_master_controller *mast= er); =20 struct i3c_ibi_slot *i3c_master_get_free_ibi_slot(struct i3c_dev_desc *dev= ); =20 --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04680332EBD; Thu, 6 Aug 2026 13:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022391; cv=none; b=sFIkiirxlHadXidEQnduETc6/u9yIc1VcUUBhGoRW58zC9brpvS3K50L4kn1Yk2NQAK3MFS/4QYWgMN/vCEth6HOISbgLxfeBHpNmsLJn7FJ95bDB6Uu7ZiexYd30WdhbJoY/MzzUB4LvtgUlVFZzVbh3fFUz0Y+55xfzElFQO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022391; c=relaxed/simple; bh=nX3Q4Ck76KKHbqDDEK/0Elh/XWuHke9+jxodTd88M7I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EHp5RP7jA0pZwTeFbMdq7ikKfpvD7AaULppcyDmvetUoe3L30Uz/Dy+dH6y1o883hMgWR2Qk/Jt54eE6oyGcnfLnbgTjmWwTFHpQGdlXwvpyqhInE2J+XYOvllz8jcEKGNXJETNOVEWVwogoTc1oHMIV6ChZAyxHtKldWW/p6MA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SczSArBw; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SczSArBw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022386; x=1817558386; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nX3Q4Ck76KKHbqDDEK/0Elh/XWuHke9+jxodTd88M7I=; b=SczSArBwC7kOlWghLCNSKE47uYxCyY+7edQCJE98e8MmRNd1u6NfTIph D98w025ytH19VFyDzOCJLcFvV6BbeB/y1lrpd26C/IIDQM6BXZIrFK4TN XUU5SztX1STwrLj8Yx1vRjrUVrVS0bPVmuRSBJNXNuYnfbIGJKiywD292 HvgcOIk3E8QV4xv/OLsTFtouhSaAQahZsxYASQt8IyYU0Bcip++nesYWE SUSW6X7mow/5Sdy8D+4q67ng7O0BlzJDo5Bt9Ry2uGdVEVGgTOS8QsZTi 5UeQ1WnunpTUKhz1asIkDya8Sqcm2onWLQF8o1DImbd+75WMo0U7Ymbov g==; X-CSE-ConnectionGUID: q4MbZatMQJqTq3iZFjOqSg== X-CSE-MsgGUID: PsX9a8U7Qc6d1CBiCwQ3uQ== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149633" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149633" 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:40 -0700 X-CSE-ConnectionGUID: GJapqe8GTKqZ89quraQLnQ== X-CSE-MsgGUID: 89gP3eSOQPieWvbSTUp0Zw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338258" 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:38 -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 11/14] i3c: master: Reject IBI requests from non-IBI-capable devices Date: Thu, 6 Aug 2026 16:18:54 +0300 Message-ID: <20260806131857.119830-12-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" i3c_device_request_ibi() does not verify that a device advertises IBI support before attempting to set up IBI handling. Add a check for I3C_BCR_IBI_REQ_CAP and fail with -EOPNOTSUPP when IBI support is not reported by the device. This keeps IBI setup consistent with other IBI-related functionality, such as exposing wakeup capability only for IBI-capable devices. Signed-off-by: Adrian Hunter Reviewed-by: Frank Li --- Changes in V4: None Changes in V3: Added Frank's Rev-by tag Changes in V2: None drivers/i3c/device.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c index 5e6df6de0283..f1ba363b22a1 100644 --- a/drivers/i3c/device.c +++ b/drivers/i3c/device.c @@ -204,12 +204,14 @@ int i3c_device_request_ibi(struct i3c_device *dev, return ret; =20 i3c_bus_normaluse_lock(dev->bus); - if (dev->desc) { + if (!dev->desc) { + ret =3D -ENOENT; + } else if (!(dev->desc->info.bcr & I3C_BCR_IBI_REQ_CAP)) { + ret =3D -EOPNOTSUPP; + } else { mutex_lock(&dev->desc->ibi_lock); ret =3D i3c_dev_request_ibi_locked(dev->desc, req); mutex_unlock(&dev->desc->ibi_lock); - } else { - ret =3D -ENOENT; } i3c_bus_normaluse_unlock(dev->bus); =20 --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0990A3876A7; Thu, 6 Aug 2026 13:19:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022391; cv=none; b=f6EslhYUMNA6APp5OYwIrfoTbs4hm0G6VIDH1g3AM8Ees+plAq0glvnFAr4JOqFnrtujNKu3naHdNfRRU33CQa6sYgzfHBRu0uQt/wmzSJZ/b1yNPmj8RMM79YdROk8PjffpqJUHLmPXaeAUCIe2h9XFm2Ykf3W5rbWUWlJ4pvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022391; c=relaxed/simple; bh=ji4ie/GLcul7bTKGn4Ajt86KyBmM01v6SZFIoSAtN/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kur74SRGpS2wuhEPbW2LVRsoPGfrRD/InKSuZr6+ZE4qZRb2b0UY2ZJ0K4RaWGb+6OlC4CG9lebSeyx4Sd64ehIwrPQ74Nrh1MEDA3myGsstzpD031JY5yKA1sKK0NaUwzvjQ7kvS6Sut0WP/L5u1tZIAFcOx7OHUJAvKhH6kQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=celR4crP; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="celR4crP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022386; x=1817558386; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ji4ie/GLcul7bTKGn4Ajt86KyBmM01v6SZFIoSAtN/w=; b=celR4crPGrih9pxyP1lRbbhMC/T4omvc8K6U30LeyV0nBlpa+m9tB3Ql aZkY/1JQrgctn9HSe5WGpKA4HqC6wWx++K8fd0DJgAPPdL/GJl7UX/jqI ByIkKOTWwnrzqoGLim0Sj93DURrjcF1IKdtQGUzAQf3Oxd+ccxDJipCpu 1yc4pNotrMFMDaL1PCF80Saai1D0Ut4gDIpf77QegDQlEnNXMrWXg4Z74 0fkwp9e9VSxIkAlpYYneZDP/xHZ+gg81C19+tvBCu4gCLllG3Kon/sMs7 8rQiCI4EMGpdcyIBCYg+XbKvnRWn16/IuZsT6fdIJMbBp1KzIn87ob6Wg g==; X-CSE-ConnectionGUID: mVgcN7wKQ6ymcfpR52gRqA== X-CSE-MsgGUID: 4V47x0a+SWKQgX5qjuPGYg== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149642" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149642" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Frank Li --- 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/i= 3c/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 devi= ce *dev, bool update) struct mipi_i3c_hci_pci_pm_data { struct device *dev[INST_MAX]; int dev_cnt; + bool can_wakeup; + bool may_wakeup; }; =20 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)); } =20 +static bool mipi_i3c_hci_pci_any_wakeup_enabled(struct device *dev) +{ + struct i3c_hci *hci =3D 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 *dat= a) { struct mipi_i3c_hci_pci_pm_data *pm_data =3D data; @@ -287,6 +296,9 @@ static int mipi_i3c_hci_pci_suspend_instance(struct dev= ice *dev, void *data) =20 pm_data->dev[pm_data->dev_cnt++] =3D dev; =20 + if (pm_data->can_wakeup && mipi_i3c_hci_pci_any_wakeup_enabled(dev)) + pm_data->may_wakeup =3D true; + return 0; } =20 @@ -317,12 +329,19 @@ static int mipi_i3c_hci_pci_suspend(struct device *de= v) if (!hci->info->control_instance_pm) return 0; =20 + pm_data.can_wakeup =3D device_can_wakeup(dev); + ret =3D device_for_each_child_reverse(dev, &pm_data, mipi_i3c_hci_pci_sus= pend_instance); - if (ret) + if (ret) { for (int i =3D 0; i < pm_data.dev_cnt; i++) i3c_hci_rpm_resume(pm_data.dev[i]); + return ret; + } =20 - return ret; + if (device_may_wakeup(dev) !=3D pm_data.may_wakeup) + device_set_wakeup_enable(dev, pm_data.may_wakeup); + + return 0; } =20 static int mipi_i3c_hci_pci_resume(struct device *dev) --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDE7E36F421; Thu, 6 Aug 2026 13:19:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022394; cv=none; b=nXlBQd/KjRNzLOGAcE4XYw6gpFPSchO+icVQCcdonCc35unJMzo98xufFqQvVhtG1l1IDx0n2Gb5ZzFzUGDCAT6wUW6eJo+OLJ6dW+WuzclXIzbY6gT2TV2DnbTAV0fMtJB0rZSKRNxTQyh+rjGWiofxvl/BWEwvBfnhOgszX+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022394; c=relaxed/simple; bh=K7NPEV3ObsYKOG8K3U8wEY/ilmXqqMrt/n2CH0sksYg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A7Wx8CoX4NADV5OgCI5pybgYYSXu+P7g9bpRTAsD2YFyUIZpMI8z+VwSe7fNtBZcVCoKcx0b7I0Ruzzq85ToB59Fsex9L5OSRcnUUshvQyvernPSqNETiLgCnkGMZHWpx72hV8m/D1FJflbY5OKRCSZEz9NiC6osGEyhXpols+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=enI6yHfm; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="enI6yHfm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022389; x=1817558389; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K7NPEV3ObsYKOG8K3U8wEY/ilmXqqMrt/n2CH0sksYg=; b=enI6yHfmzhfAdtXaXi5vT93lUpp2uVBg8UdALAbUp6WZwi8kNCdVBb1D DAzDqqYrl3TyYXe56jf/T/E4nIgnHcxV9BThkDABxmjGeh1cMo49WwxgG cLxdrJz+3n+lzR4VfQPCBtWRMODWtIBc5PAmPqcqJnIrJfYVvRfuO4rqJ xVBfCJH2JIvh4xTQcEcP6V2J2ylPaxsvnU9cjCnpoYnOrMQb9QSt3EHAK DH9+VqxisgmIIB5/ya3SkBGpU3xJcKSc2YcyaWbMc0LYWXfCG09ZflmnX O2+U5t5okJcazrUll73SY5xfpXF2/N5+urzxXoMKRkrijdrbe0V9eWOlk g==; X-CSE-ConnectionGUID: OJUpaBDJT127OVZVJioVRA== X-CSE-MsgGUID: X6WNZEV9Q6i1KUYsdXB9oQ== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149652" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149652" 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:46 -0700 X-CSE-ConnectionGUID: AyVsNykyTlGGOBu/3kRn7g== X-CSE-MsgGUID: etoWJgFJQf6EY70zWJX3fw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338340" 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:43 -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 13/14] i3c: mipi-i3c-hci: Factor out i3c_hci_sysdev() Date: Thu, 6 Aug 2026 16:18:56 +0300 Message-ID: <20260806131857.119830-14-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The MIPI I3C HCI driver needs to identify the underlying system device used for DMA mapping and PM operations. The logic for determining that device is currently embedded in the DMA implementation. Factor this code out into i3c_hci_sysdev() so it can be shared by other parts of the driver and keep the device-selection logic in one place. The explanatory comment moves with the code, reworked as kernel-doc now that it documents a function rather than an inline block. Signed-off-by: Adrian Hunter Acked-by: Mukesh Savaliya Reviewed-by: Frank Li --- Changes in V4: Reworked the comment that moves with the code into kernel-doc, and mentioned that in the commit message. Changes in V2 and V3: None drivers/i3c/master/mipi-i3c-hci/core.c | 16 ++++++++++++++++ drivers/i3c/master/mipi-i3c-hci/dma.c | 15 +-------------- drivers/i3c/master/mipi-i3c-hci/hci.h | 2 ++ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mi= pi-i3c-hci/core.c index cfe9b5390b56..f95da427d7a9 100644 --- a/drivers/i3c/master/mipi-i3c-hci/core.c +++ b/drivers/i3c/master/mipi-i3c-hci/core.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -117,6 +118,21 @@ static inline struct i3c_hci *to_i3c_hci(struct i3c_ma= ster_controller *m) return container_of(m, struct i3c_hci, master); } =20 +/** + * i3c_hci_sysdev() - Get the device to use for DMA + * @dev: Device the HCI controller is bound to + * + * When an IOMMU is enabled, DMA API calls must use the device that IOMMU + * setup was done for. Under PCI enumeration that is the PCI device, not + * the "mipi-i3c-hci" platform device below it. + * + * Return: @dev's parent if it is a PCI device, otherwise @dev. + */ +struct device *i3c_hci_sysdev(struct device *dev) +{ + return dev->parent && dev_is_pci(dev->parent) ? dev->parent : dev; +} + static void i3c_hci_set_master_dyn_addr(struct i3c_hci *hci) { reg_write(MASTER_DEVICE_ADDR, diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mip= i-i3c-hci/dma.c index 0672ed1132f8..7c2b20474130 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dma.c +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c @@ -15,7 +15,6 @@ #include #include #include -#include =20 #include "hci.h" #include "cmd.h" @@ -301,23 +300,11 @@ static int hci_dma_init(struct i3c_hci *hci) { struct hci_rings_data *rings; struct hci_rh_data *rh; - struct device *sysdev; u32 regval; unsigned int i, nr_rings, xfers_sz, resps_sz; unsigned int ibi_status_ring_sz, ibi_data_ring_sz; int ret; =20 - /* - * Set pointer to a physical device that does DMA and has IOMMU setup - * done for it in case of enabled IOMMU and use it with the DMA API. - * Here such device is either - * "mipi-i3c-hci" platform device (OF/ACPI enumeration) parent or - * grandparent (PCI enumeration). - */ - sysdev =3D hci->master.dev.parent; - if (sysdev->parent && dev_is_pci(sysdev->parent)) - sysdev =3D sysdev->parent; - regval =3D rhs_reg_read(CONTROL); nr_rings =3D FIELD_GET(MAX_HEADER_COUNT_CAP, regval); dev_dbg(&hci->master.dev, "%d DMA rings available\n", nr_rings); @@ -332,7 +319,7 @@ static int hci_dma_init(struct i3c_hci *hci) return -ENOMEM; hci->io_data =3D rings; rings->total =3D nr_rings; - rings->sysdev =3D sysdev; + rings->sysdev =3D i3c_hci_sysdev(hci->master.dev.parent); =20 for (i =3D 0; i < rings->total; i++) { u32 offset =3D rhs_reg_read(RHn_OFFSET(i)); diff --git a/drivers/i3c/master/mipi-i3c-hci/hci.h b/drivers/i3c/master/mip= i-i3c-hci/hci.h index b3d9803b1968..b8d2a3d680f8 100644 --- a/drivers/i3c/master/mipi-i3c-hci/hci.h +++ b/drivers/i3c/master/mipi-i3c-hci/hci.h @@ -184,6 +184,8 @@ void amd_set_resp_buf_thld(struct i3c_hci *hci); void i3c_hci_sync_irq_inactive(struct i3c_hci *hci); int i3c_hci_process_xfer(struct i3c_hci *hci, struct hci_xfer *xfer, int n= ); =20 +struct device *i3c_hci_sysdev(struct device *dev); + #define DEFAULT_AUTOSUSPEND_DELAY_MS 1000 =20 int i3c_hci_rpm_suspend(struct device *dev); --=20 2.53.0 From nobody Fri Oct 2 01:12:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F387374721; Thu, 6 Aug 2026 13:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022406; cv=none; b=VycUu9Djz/87/CyT5beVJXHM/pargy6nm17OtHKTDmFRDELNhuW2shwlkuhuZgbDnDgIITflI9O/OnZJyBhED4HAlauRRWjXsesKzNma5a/8eVJljIvv5HodhdF7IRwdyS2+AaK7ZbETpJ45WHzBeNqOH1q9IRplSxJ7AlAKBAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786022406; c=relaxed/simple; bh=4rY7IGb0lt7RFyKVZ1S7RTS2cw+M31qnZC70CCtDg4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r5klNoni+hc7lWr6sG5fsm/DI7/onldFUtdVueiWqyDoaGd05vmCBB6VU2aaN9gi3EUXchgALgcWmJTxhkut3mTUIajpbOk7uu8xg9vD9Pdk0Tl4TA8Giw5Eyy5z9Z1X3Cw8Sjn651hCnUv0fLsQ2IvQ70X0Inx0BAqt5j/JjEU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=cedp3dY6; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cedp3dY6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786022394; x=1817558394; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4rY7IGb0lt7RFyKVZ1S7RTS2cw+M31qnZC70CCtDg4o=; b=cedp3dY6trMeCJLxyAagS+sRh6dvZnxbBvdX8FwQyac6oXWcWsKqziWo bsVjVZPiq4GukkOiRma8e3Us+snctV7Vm1b3w2ZAjM/L1kWDofNHxAg2R aJBsbh/CZp15km5Y6ckfThcIw9YrghFZTVK7v/YYZD30jq/myA3VBYMAx a3mHqVNevgmfo2C+S+Mk3CESAFufpRXSty+ybKjsrrae/gAQRA8CYTKVK 8VJ5xZVeJkQ8zaJU0DeUrxJSDe/SKT3dHTRJHu9+4S1vGXK4OTIVpfv/q u1JMQQM9YUFB3xK2ZzK92j9NAbQPh3ViE8t0QfchVwj2U1KuiO3vINxo2 Q==; X-CSE-ConnectionGUID: paKDBdEjTJmFjd7DFyrAyA== X-CSE-MsgGUID: MrEIhZ4pTlmvf5WJK7UhlQ== X-IronPort-AV: E=McAfee;i="6800,10657,11867"; a="74149661" X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="74149661" 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:49 -0700 X-CSE-ConnectionGUID: 6EkFM2hkTC+Y0OcbD5vnnw== X-CSE-MsgGUID: 20RDd/bkQNWGFcHBAdXucw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,208,1779174000"; d="scan'208";a="260338357" 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:46 -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 14/14] i3c: mipi-i3c-hci: Advertise IBI wakeup capability Date: Thu, 6 Aug 2026 16:18:57 +0300 Message-ID: <20260806131857.119830-15-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Set master->ibi_wakeup during probe when the associated system device advertises wakeup capability, allowing the I3C core to mark IBI-capable I3C devices as wakeup capable. Tweak the comment for i3c_hci_sysdev() to mention the new usage. Signed-off-by: Adrian Hunter Reviewed-by: Frank Li --- Changes in V4: Updated the i3c_hci_sysdev() kernel-doc to mention system PM and wakeup, in place of the old comment tweak. Changes in V3: Added Frank's Rev-by tag Changes in V2: None drivers/i3c/master/mipi-i3c-hci/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/core.c b/drivers/i3c/master/mi= pi-i3c-hci/core.c index f95da427d7a9..06acf6cf5a0d 100644 --- a/drivers/i3c/master/mipi-i3c-hci/core.c +++ b/drivers/i3c/master/mipi-i3c-hci/core.c @@ -119,12 +119,13 @@ static inline struct i3c_hci *to_i3c_hci(struct i3c_m= aster_controller *m) } =20 /** - * i3c_hci_sysdev() - Get the device to use for DMA + * i3c_hci_sysdev() - Get the device to use for DMA and system PM * @dev: Device the HCI controller is bound to * * When an IOMMU is enabled, DMA API calls must use the device that IOMMU * setup was done for. Under PCI enumeration that is the PCI device, not - * the "mipi-i3c-hci" platform device below it. + * the "mipi-i3c-hci" platform device below it. The same device owns + * system PM and wakeup configuration. * * Return: @dev's parent if it is a PCI device, otherwise @dev. */ @@ -1180,6 +1181,9 @@ static int i3c_hci_probe(struct platform_device *pdev) if (hci->quirks & HCI_QUIRK_RPM_IBI_ALLOWED) hci->master.rpm_ibi_allowed =3D true; =20 + if (device_can_wakeup(i3c_hci_sysdev(&pdev->dev))) + hci->master.ibi_wakeup =3D true; + return i3c_master_register(&hci->master, &pdev->dev, &i3c_hci_ops, false); } =20 --=20 2.53.0