From nobody Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 4CC503F1662; Fri, 7 Aug 2026 14:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114648; cv=none; b=Pb4qHyUYl5CfUzf75243sepqDbAToQBBWzO9Rq0kqQILX85JZmVB9q0wcfXLKh7zh7qP3Exmq3WuBkk5IbPc64GRQoz7nzXS5jJIjo6EgRAiajLPRIVtCCf5KQ8jTVgng7xOfxdx9cHXMILBjU6nFAHHSGyAGUodeRs5Hmz58Aw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114648; c=relaxed/simple; bh=iUf7XrtbaGTZLGwnhEqDqVPZQrqJ/bjk10K3AhMjNNw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f1wxO5CaIKWGVUXSx7EQTeUclt4HUnxhB8WSQBiPa2/TIDRqJrARTdZlQlRCMUnhihiwZfM0Bxf0/elbvyWboOsOapF/otWKZm/mkAYe1+x8noJNhQ4HQiOZLG5BSGHZrYOxDLGXGLgMYl0WVYMAQZhmylyvOpvwBwNnQeU29/0= 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=Epl47hQA; arc=none smtp.client-ip=198.175.65.20 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="Epl47hQA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114647; x=1817650647; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iUf7XrtbaGTZLGwnhEqDqVPZQrqJ/bjk10K3AhMjNNw=; b=Epl47hQAKkyREpgv5rJ2Y1I7Ixf06RU9SDpffOmAWD+z50x3e5oiIARX UiO1ooIJ63FEqh/tI0ssjm4oR0PY9sqlGCmrDyFZbzuNjibLdET05swzp Q4dd/7bWS9sTuDIHk00DJk4Tq75A77XaBxb3I2JXodGk1l/1viDFsb61B Bxz5VyRLfwycDOe5V1Vy3ubB9ADLqzTagRV1Scqs3Tp5sBqjuf5ocDm3B 1q+IkLU3uimQwLZGVsRXu+Tg6Fl5h3CT6UBqy14MNBv5uMtlAqeWUqjzD XYCGqFl4xqUIEXAnVzAcRWsEI/bJ30vJzCIOVJaOjPaBLGfZtBR4KeGQR w==; X-CSE-ConnectionGUID: wwsFgmtlSfCJuTpwrG4ZUQ== X-CSE-MsgGUID: gk37rzbbQ9Oxhj6Plvv1BA== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485184" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485184" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:25 -0700 X-CSE-ConnectionGUID: MiaaZ06gQ6KmppPlDM5SPg== X-CSE-MsgGUID: M0Ah3gm0RiSsebDU/Co6Qg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809875" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:56:48 -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 V5 01/14] i3c: master: Fix recursive locking during device registration Date: Fri, 7 Aug 2026 17:56:25 +0300 Message-ID: <20260807145638.168865-2-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: Added Frank's Rev'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 ADD74412C05; Fri, 7 Aug 2026 14:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114649; cv=none; b=TZEFSwjbGmP2UAcCnHjHG41ySVC19Cnhjp1b1XuIHwTv3rJOklfNPEYRzEHMpBj5heMdBqQCRQnEwwczDwWd6qAdrCjusG7EpVsbC5WhjDMEWgVIlyLLdWswCvBbVjFG5XYk/c4CKHqbhYEhtN3QSeFI9xed0f2Q71uI9oRhKEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114649; c=relaxed/simple; bh=6uWV/4a7ou9YlS2DldAkICXYmliziER5KKT2Q7nsl78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J6l5KJrh96O4k+LdTDUVcRySjBNyDljISQE8YOUrETo2cm3cs0xEbu0QRI1Q+aw4988GyaTQQH6+dreoHjQKsPe6Mm3ec5QWdWpKXClrHZY2JIj95JUpLDZiMCEGgrNyRBVOoDtn7gbsWNbS+0Tsk2wf6538VVFI24no34cAyNs= 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=Ussxp+Gl; arc=none smtp.client-ip=198.175.65.20 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="Ussxp+Gl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114648; x=1817650648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6uWV/4a7ou9YlS2DldAkICXYmliziER5KKT2Q7nsl78=; b=Ussxp+GlAb2POL+WCBJUfksUyXzFWFIpVDffyU4JAkAjnyyLjxOJJjmi LXVPrb6YYxwCR2r6u9CYRyAaNQQ0C58nF0/6lhqRfFQZJEoBBFRy8Y4H9 g94BJNJ1ktfftgn7N6+L3AQ/TiG58bA358cH1Rg3PhTQaAaJeIyn69FUy zgAyGGG8xZya9RHJoPIP8FGaANQpmjqPe5hK+oNKIx94jX4QSVSGLpZ64 ie6u4rsPJ7I9xYd8fdUYdz2le3L4PVAG6LWa8dxvm9ZczKIrUci9UtU8A E5KKjzbBBalxfYug7WevfmyIxar9G+F+WqVFDk1hgZwWiat+YEaCWabYK g==; X-CSE-ConnectionGUID: ohc333BbTbOBDXlFxT1ZAg== X-CSE-MsgGUID: oRHiXug/TGWM0wzmNbT1DQ== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485191" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485191" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:25 -0700 X-CSE-ConnectionGUID: lo7Te4SoToqvDB3tdFxQGw== X-CSE-MsgGUID: wBvOWhNHRdOEYhu6B9xuGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809878" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:56:51 -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 V5 02/14] i3c: Fix unlocked dereference of dev->desc in i3c_device_get_supported_xfer_mode() Date: Fri, 7 Aug 2026 17:56:26 +0300 Message-ID: <20260807145638.168865-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: Added Frank's Rev'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 E0A5F41A909; Fri, 7 Aug 2026 14:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114650; cv=none; b=oMRxx9F/JsTVmGweDtGD/AutVzgcLQMXD+hhv/B78z+OhzfO5h2Yw1Zge1dl+RLsqascG+Ig9YlcvyY38SBB8Gkgh2masHjKJ9ThI1IUraN6Sy4l0cTJ/C2YCVIO0qIx4qbO4PptTU9W5U6/Q+GvfyNS2aGY9hbLjYtfdkpwbXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114650; c=relaxed/simple; bh=ctrlY3FM28tivUxIv2sCpxma8DQO19RH1AD6gnz/0ck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n2E7JP3loJUBhO/PyJcsVNpwHRWl6suCkNl5Ty3l09L0SEiVjgJLjngLttKdglCfmn2j7kNuVGOpIbjvcTlP4QZCRstPCq5dB4tck+l4iUvbpt5XQWXU8MTN1mqGOPlGat9Ar2tiUHGni4y8DEl6pYtd/8U2mjU1nvt82RtrblA= 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=Ti94ir1W; arc=none smtp.client-ip=198.175.65.20 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="Ti94ir1W" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114649; x=1817650649; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ctrlY3FM28tivUxIv2sCpxma8DQO19RH1AD6gnz/0ck=; b=Ti94ir1WdVoWn93JQKie1d1t8/xdtesQ7qAwo7L1QkuxABT9N2zJOhvG iVnQlMD78CkiHjAz8FNJjNE9+jGqjdzkiCsbrGcY5En9xvTtNDsZXopC8 CNEXCctBlEGPdPqbK6XCoDhlJt7LtwXgMLajrUkRT+fiI4AlHj6E+V+AO +OYqQqbnpoofmhtp9o0eExjyiGSFvXpOvE6x29JAFKKqA0axrfRq9vafq OC8TRmYe+FVVNWm6YMcATLytpUkq+bYy8cY++0QbqvRRq8F6LD+klW+dZ AEq3Hi5nMBDpMgWXG5mOzu7XWT0GKvV9K60FM4uIKx+WT0V0nKVucOvsf w==; X-CSE-ConnectionGUID: 5pMFbz0JQKC++9mUAvqLEw== X-CSE-MsgGUID: y/VcPs1OT7K0+aTXq9NmQQ== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485196" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485196" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:25 -0700 X-CSE-ConnectionGUID: JLBFR8nDTG6LJmPzP2Hqog== X-CSE-MsgGUID: vwoskQALRtORVlH9McSGhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809880" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:56:54 -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 V5 03/14] i3c: master: Do not treat master device as a duplicate target Date: Fri, 7 Aug 2026 17:56:27 +0300 Message-ID: <20260807145638.168865-4-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: None 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 31A7B42C4E9; Fri, 7 Aug 2026 14:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114650; cv=none; b=Ac1uEK7Dk0meRvjF0TdClAWyWmLKpy+wzzGcimaKVxIXgYYmuj2FK923Qx7jRm7TwKcZkCKAhPir97uK/8uNt/vX33tRlHebtoW49NXOczoF74tSDPPbu3kBwWpE4OkbMoI7vh4RdxdILSHpoA4Dn4TRcaex+9ArftLRI0tolf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114650; c=relaxed/simple; bh=OGrdA5Klzo2kaMa21Wjnl35OoqbyuQ/aauwhgyOink4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YSw025u2QWhH/FXD1GhHMFAGkhKlnT9yYGsCkGHFEvXd+e4yAlQne/4NW/+kzCy0FkYjiaIRjCTzJfnvSF+CfxXUKr4bV+LIHe6hC2nhyB5O0eatybqvV+pMZ6ydLuVv1VY53hK4XKuLV4kEqegsqk2MhgEwSvLxvLxkXIqBoq0= 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=YJNsbP1P; arc=none smtp.client-ip=198.175.65.20 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="YJNsbP1P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114649; x=1817650649; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OGrdA5Klzo2kaMa21Wjnl35OoqbyuQ/aauwhgyOink4=; b=YJNsbP1PHRgKF/ecoy97CrycQ2oGeoRftXEtGHPVVVugRJ3saCFgkHVm 5h7DYUDA9rSGIsqQ1nJjeM1LTXojxtRNbqeYOi5F026yGk0hxxoeDvNfu FxSWbZWZrINT++TNPfpxsCBBNbZ8gHIXuFZTs6Q09CuZaVtCCWtjSwmwb S6TDVQkqkHgN+Qx0ZiNFvmAYuZ1hMCFut/MFYwogQX8WN0fSmaqfQqnJS XvVr2Z3IpRya7YEmJS7BNHTVPPSOP3oe131DOEUCZcFOvJL+ErzykiBov ftMeNeaiiOjDoYZIOOQiBTGXukzZsZAsZbY3BH8xxrcCQfwNHkOxY1ikO A==; X-CSE-ConnectionGUID: RMbVzUAHRxSiU6UXDmBSnQ== X-CSE-MsgGUID: 4cJO+/6aQ7Se5TyO8XZbUg== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485199" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485199" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:25 -0700 X-CSE-ConnectionGUID: poz2XnVMTzS2a3Ok3YvMQQ== X-CSE-MsgGUID: L4Uac10bShyw1EAGv6GOwg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809885" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:56:57 -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 V5 04/14] i3c: master: Fix use-after-free of master->this Date: Fri, 7 Aug 2026 17:56:28 +0300 Message-ID: <20260807145638.168865-5-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: Added Frank's Rev'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 1008642A15B; Fri, 7 Aug 2026 14:57:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114658; cv=none; b=kjBEweVenTiZQZdk+gtH+Pd2DE75gB1woNKhR2DVmzbgRGYqy821fknGBRxcSu5IsNdRQNTdPl0JytklJyoX75GwUso/WutiRrhgTLhhzEKVy9Kg7spNnpY3S84NvHFEMR3nunVUpQNtqu3p6wYopsUYQwcTmjPKec1kXELsE30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114658; c=relaxed/simple; bh=6Rl+Rgm264AjO8qM07awhvbwkMrjgpE41Tf0eFaZ47E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uhsGIixOtu9HLrlC3bbOkKTYgWeOlkY4irbVp7SGTKZ2dV/qfNfeQsyIJrdQcWYcQGemHdlxQ0EzKOGXWwWivFal3g9kvqhJkjgKHUKc+hMb+/orUX/ZN1DadX2QVr3e0rj7Zjn59FrdLMMMdET7unk8BvpEp0r8pJHjS8pF48o= 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=Tga+gBku; arc=none smtp.client-ip=198.175.65.20 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="Tga+gBku" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114657; x=1817650657; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6Rl+Rgm264AjO8qM07awhvbwkMrjgpE41Tf0eFaZ47E=; b=Tga+gBkuA9cNxTz/DGz97g4L7/Kj648U8VQ2rUb8LHz4U+8RzazG1tzg Tfe4cA+PJ1EcWGKiiU7yKUSE+ifykLWZkBmqXGZr0oTI+tbcY6myLUOxX TBqHx4iKoi+hJRD1IOOwmNz/QfKY9/Ae3MUP9Et8GA39aaZhcq50VsBjj Ppi9esfOEtisR8LudSU9HL3Jf1+gowPX/3d09ORXX2RliwF9V5eaFf5bj xyUOlH73mJuXeTuKpVe4S//IHQ1di6k4VkKZ1Ulpp+SfDZIDtlVIUkavV IbVALaeN1yKKwdPq1FnBFx1Tl/eT5KMCCgx+3vCK8BeY5nqU+9lgylt6b w==; X-CSE-ConnectionGUID: aUEQ6zRzRcK04rDNem9fKQ== X-CSE-MsgGUID: +xLxwFA/SfuA3h6JmHR2Qw== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485218" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485218" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:36 -0700 X-CSE-ConnectionGUID: /JuiAGbPSRqY0HkiARNztw== X-CSE-MsgGUID: EIcZxlcATkyr+d3TASXtoA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809896" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:00 -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 V5 05/14] i3c: Make dev->desc locking assumptions explicit Date: Fri, 7 Aug 2026 17:56:29 +0300 Message-ID: <20260807145638.168865-6-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: Added Frank's Rev'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 704AA442371; Fri, 7 Aug 2026 14:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114659; cv=none; b=YX0RIRZ4cjdkMfeie/iMlA99xzszG3koDlMJ6yH68hEN54TH4hElTtaOEpeaqmKKF0/aHRxwQsdjNwnimWRzwi9fOEgq00s2hDWkJhPGw97Bq3PXWqLSOtqUD0O8JS9eKbVCt/4PveSerH64qqgjWEjlKQN96uPw/eidm0/U/iI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114659; c=relaxed/simple; bh=PoBnNTY7R/7wvVAa6p1CUs45T33ETASB2I+FQ3ox3a0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=edvS4z2XXlP2bw1800dX/mcpUQMbAjR9GeDvuk1ro6Y2DabePmGoHraFQUjVFpwdN4yE9FOQxDrIakniG8dF7CIJIK2bdOfuvuIuO0zvaTlOlqqSvWvC83Pcj7roJBjdy7dkBh7oVSXHxOG+Gj92OZMkR5ic2pIlTDOzDvUM0Ps= 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=CBp3VJEa; arc=none smtp.client-ip=198.175.65.20 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="CBp3VJEa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114658; x=1817650658; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PoBnNTY7R/7wvVAa6p1CUs45T33ETASB2I+FQ3ox3a0=; b=CBp3VJEaVtar8zfNrLZSA1M1lpw+WOloimwhN93XC71L/aXjBC55TBiw t/4ikXB5tJXRNRqeYB1YMkGmzDTBf2SX24GUJVeQJjrLgN6VzlA9vuL9O NSZekrtOjaR7aYsGtCoAJ/LjxzHcCE8fh1+APhHLiFX0ki8gFN15oqh5i 53i8unnBwlduKQZ0d3mgNYOCAj3qmZBb35UzV5E3GCil7ZUXdC5kujSS1 XtP+hj0uo///vvkq8zZrgEl3SCguRJW0Dtt0gadEvzVOn8ZE9xF762j8/ hn2KQkFnlvhpK6pPum5Zz0zDmWjnVOF2dwLpzAFgTUVznN62E1g+NWfv/ g==; X-CSE-ConnectionGUID: 8SjHeyZwTsm2TMxjd6Ztlw== X-CSE-MsgGUID: NjsEkIcqQH+hYZGPgM/HkA== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485225" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485225" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:36 -0700 X-CSE-ConnectionGUID: fcbCQuZMTpCidWeSh80EIw== X-CSE-MsgGUID: vrqrhy+mT5Wzk+6M8ae88Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809898" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:03 -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 V5 06/14] i3c: master: Fix potential UAF in i3c_device_uevent() Date: Fri, 7 Aug 2026 17:56:30 +0300 Message-ID: <20260807145638.168865-7-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: Added Frank's Rev'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 CCF274746AE; Fri, 7 Aug 2026 14:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114660; cv=none; b=cUxc6y+f9vPkTvlG4qlHFOB7JTWshsupTjvZPWQu7B/pQSU0hSz+7XpC18Z3E2doLoDnAqtvIErEYjLnHOPtJZ7cemIB5tE3k2Cm8M7ICXlHF6jpCz80tquA4atjmZC3VD9QoZ3hn3lpqYHN2hJ7vufJirgyQ42JGOfXI/LZbek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114660; c=relaxed/simple; bh=GXla3rEiuoVy1r6X2ffYoXaqd7/8Dw7PH/mGtXsD/VQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U3e8LtKpaUqpGz2gCnYRj5Vzz7JNqqWMzhWRLkAWqn6J9h0sLswRaCgFkM/fPfyNFw2ad1J7LC5wcjatGDN1Xc1itpGk4qaAeSTFzDTd7G0wLFtUDzq8eVJo8hzvIYags/8yheojFY+WwuQp7/NvBKjcBsK6jV2Mpi8xeQ1rw+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=Cc98RoWm; arc=none smtp.client-ip=198.175.65.20 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="Cc98RoWm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114659; x=1817650659; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GXla3rEiuoVy1r6X2ffYoXaqd7/8Dw7PH/mGtXsD/VQ=; b=Cc98RoWmUCZfKHGXvnKJ/mjk97muZ8CaX8vpHLREkp6JhwM4SGqKtKDG y9S4iPjZiZr5C4Y6rGDfrmCpN5nYZwweeW6CMW/pYKCmTdfAFfIpiFX8z z4ss4amer1cta3jXuv8KL2ZxF4XbA8jn46xzEYoZyba8+aPJBqCZiVbD+ LdwfV+ZLaVist13WevlATlYsajr0Jzd7QkA1Uv0Tx4h5upllHFWQI5MYG c3yHj15/sJRDVhyioeta6e270v6bZeBRKlPOCTgP6D8JGOm7eBNJ3Kvu6 PzqiLga4MBLZfZRew21QWgeIR53P4Jymy7R023cwrG2yCtolvF1eisYZ6 w==; X-CSE-ConnectionGUID: FIEDZ6fbT1+4P+XMJEuJ7A== X-CSE-MsgGUID: Ybe+CbuLQ6+BflilYcSY1g== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485235" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485235" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:37 -0700 X-CSE-ConnectionGUID: Pw3PS3EnSdCoM/ktTPGfNQ== X-CSE-MsgGUID: KSHIWB1ST56hZfekZ230Sw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809936" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:05 -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 V5 07/14] i3c: master: Fix potential UAF in i3c_device_match() Date: Fri, 7 Aug 2026 17:56:31 +0300 Message-ID: <20260807145638.168865-8-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 Reviewed-by: Frank Li --- Changes in V4 and V5: 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 348354749EF; Fri, 7 Aug 2026 14:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114661; cv=none; b=V+EvYzsAc29CEzEJs8n+rNfB6++Xw7yMKiG90RxB5yT25aZAlTARU54dlcAl9NAJDSV5xeuNHU5D68p8pqTLsLE+traREmnz+o2J2Q0VDwu6LWFb80KjpKfYip9dKYL9zWq17ueiRji92bKcW1HeLnV7UZAxJZbM6u2JN00h2jM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114661; c=relaxed/simple; bh=3YumbivJ97gedr33UQLGzZZ9HmKGhUq7z+4nWTxukeo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nBBx/7hiyeookdKdazALYoKGBYvwVXOJlsC5cLMT4vKwlix2wrn/tWsZ0a01KNcIJdIIOUtAfuKxf9gf6l01r6sQqkPpuAlByDb9ykBtsjtQpURoLXEev+8Rei8MXrIkm3g6bmbsltQhrt+tNFWurCMyxrZ/lyt5c2xx0HEE9pQ= 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=VO3YoW5D; arc=none smtp.client-ip=198.175.65.20 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="VO3YoW5D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114660; x=1817650660; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3YumbivJ97gedr33UQLGzZZ9HmKGhUq7z+4nWTxukeo=; b=VO3YoW5DtORaAga4DynmrNayK+fmn+ZtboGXMOa9YREg/Oz6LEVF46qb /es5ZC7F2Ckx4O0x5RvpAkd5t/H7rjbY46rIKNijq1+Dik2uHS1MO/y9h M0jxnTQPimNM6A1T7WG/eIRghc/ELhIq6080wqezLNBHUVV4DuyNeUYx7 xBO90EPKD7PeDSkPGnMZO2DalQkrD7WiZ9e9mqrt2JA7x4y7tGmcVouHt BUOWZztMrcM3dppk8JHrXP7AQS/6B0hWvT8SuSuAv96gETqnhZA5Ym55m YKnM1zCe8JdyO0gtgyfrLq+0/T2fASihEkJB8Aly44ihMFIu+fswOVpIv A==; X-CSE-ConnectionGUID: R3Pb47Q4RgCxntZsYBO+MA== X-CSE-MsgGUID: z4tvnLkHRfSzuVPNRfTT4w== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485239" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485239" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:40 -0700 X-CSE-ConnectionGUID: 4fbKvVegQLK4jH6l8hSZMg== X-CSE-MsgGUID: Vz6NQqQ5Sl2PQMy0eTRKJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809938" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57: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 V5 08/14] i3c: master: Support IBI-based wakeup capability Date: Fri, 7 Aug 2026 17:56:32 +0300 Message-ID: <20260807145638.168865-9-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: Added Mukesh's Ack'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 5E89B4756AB; Fri, 7 Aug 2026 14:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114662; cv=none; b=BF0QtgowCiGeuZ9SQn2cpKpDtLhpu1IfVS99tifwDOj64GrP4+qKwT8q3hZrmXTEqSKjCTWORvEPQ4L4De5J8AQXt42J0fp9mwuWuX0rvCLTHmWWwBpMaoKCXZC8GHeHwM0+gE11HfN12Hlm4n0dSl5hmjjQIH97iFnkWht7Ieg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114662; c=relaxed/simple; bh=6kbZmNFhv7aKt6TdJXjjhnORc9iTFg+AGsRdFJWwHEs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D+0PldP2Twwslcrm01R4jei8YMX2RQRocLHcMJq0C02vSp3pSwFyvWv1nIypRPSwBGp/PYGh58K5Im+oaZtX8xx0YhBiDdmPXaFJlZ+0GG30M4rgDYDXCxg/rFGx/KD2KPI1MojCI9J+KK1voZB0hT6j/vLDUSfWkjtMcml8J40= 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=dlKMO+hA; arc=none smtp.client-ip=198.175.65.20 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="dlKMO+hA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114660; x=1817650660; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6kbZmNFhv7aKt6TdJXjjhnORc9iTFg+AGsRdFJWwHEs=; b=dlKMO+hAyn5sLovbsVccoTwbPskI9pD2oA1tIX1kbJiAixrqobKv7p03 erbawkOV9a+BgW32J6oW1xuZTfMFOWmfH5xzVCEAy0SDhMp+NukS/mTrv SXdY/MWztZU+35/EmiodQBkXkG/MA5kZTg+yGCp3BQv1zChDTCk6mEdVr vY6H7fIpFLwWIU88Phy0GuwOYV+KtOd5wnEZL4d3r8aARw++IFxvJnqYh ej7KFYvYyzSEHZgou+7fOGN8WPqi6XpXs8+WRmOuOzFq7chIy62WY0hAI dvHuu16dULKGPv++oVCdDrHOuT2xLg9Cvc4CuFPBxOxTyA0Kz+jO7qDBr g==; X-CSE-ConnectionGUID: Pl5O7OovRDamtOvNxJRVVg== X-CSE-MsgGUID: 3FECLPKdSs+HceHa9j3Vhw== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485251" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485251" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:40 -0700 X-CSE-ConnectionGUID: Q79F2LcjTM68E0/8njSe1w== X-CSE-MsgGUID: wM5X+FphR5KikkO78S22ZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809941" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57: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 V5 09/14] i3c: master: Report wakeup events for IBIs Date: Fri, 7 Aug 2026 17:56:33 +0300 Message-ID: <20260807145638.168865-10-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: Added Frank's Rev'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 4129C43B3DE; Fri, 7 Aug 2026 14:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114663; cv=none; b=HiseHGNGpsnvOje9Y4dPDjTfdamKFALTg1xcVk+VkJ/MBmZYpB74ecGNgkSWzHAhB2yLSnci0IppF/DZSoQj3wOSKGJeqSyWF2yyL8z17XZaLIG1Gv0Qv02tXiNWVqwStP3NUcm1zeU/Y9kUz01P3bnTdYg4VfPSlYIWBjDd1M4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114663; c=relaxed/simple; bh=HMfkNYlkMl4nYVHY/HGi+CKtxHkiK63zKh72UBnUWHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AIQxRf6pqtTasbb4Nzq/1n1KpRHBKLDUCS2PhIAx83ANLkwIr/7P2pqDvqG8npgM2TsltYY+L3dvZWFwM5hEROqZGNXLvbIZxNpzGo1MPcXBg5z4HE/42QjTMl5dRekameqmdqSOpkUV2TPmSEaqsBPVwfFKcYjiLfyfMZdrZsI= 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=Yp27lzE7; arc=none smtp.client-ip=198.175.65.20 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="Yp27lzE7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114661; x=1817650661; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HMfkNYlkMl4nYVHY/HGi+CKtxHkiK63zKh72UBnUWHg=; b=Yp27lzE7siGlmxBh7fjuA25QFQMLNEOLOpiA9IpQDHSHonbVPq12bbxb aQNXba3MyXenT2FZ9qN8F67yTZ22+qL7FqIBLjnL26iMWdfY4T2LkP+Km K/X1cJQ5352Um6yzEuIeXtE+rMnoEjc7KRKy7WURzjTWWzqMSjrddeswW ms7pQtNWfTPCJailkyVDR6jZ2FCrv6V2gfy9b5Fm/KOLY7wASlBCa2t/E EBoUYM4PBA4/kbcCO8AmNvi4dxyQlul4bGV5u7M16rZtQICYtTTQrDKqG CB2wij3rLFR+n9C/PT/Rgo1qFWil44enyfTnwrxh7tLeWp3tBAT4YKSc0 w==; X-CSE-ConnectionGUID: Io9nFzhQQRa6dt0bAPWK3g== X-CSE-MsgGUID: QkqV80zUS7iYlcmG6tL7uA== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485264" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485264" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:40 -0700 X-CSE-ConnectionGUID: M5a2VntuQ8+qmc8ar+QlJA== X-CSE-MsgGUID: rZAJ2+MZT0esXdwK98x56w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809945" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57: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 V5 10/14] i3c: master: Add helper to query bus wakeup requirements Date: Fri, 7 Aug 2026 17:56:34 +0300 Message-ID: <20260807145638.168865-11-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 Reviewed-by: Frank Li Acked-by : Mukesh Savaliya Acked-by : Mukesh Savaliya --- Changes in V5: Added Frank's Rev'd-by Added Mukesh's Ack'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 C1DD0476690; Fri, 7 Aug 2026 14:57:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114663; cv=none; b=aFBn4AEFVsIR+5hIRvpovvW6dr3FDRJNkGzjWja7adisVEsyfRAWjd5oNWK5V6WGcFgd1Mm35mQhppjW7VCypbhf4sNeWSulcNF+lM74mh2patdSurMd9VXFaVOAsNWsF8+2ceDHol0sq1HIPIyg8so7af9+F10E5f4W74XzQPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114663; c=relaxed/simple; bh=b/3nCbbeIos8TapZNKsjIUGLe8mZz8XEWaAijxlyQEE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MhOu1dmZyWowCnvVFo6S4n2TwiEyf62GOlZa+eN8vCworjykERI4CfWjTmLEeO8WLhBoihX3OrtEwHWQRajLeGMKXYG96BZk9qi/0sNWLEVygEXiHcQ4hoss0RAvMONnCZdHflJ9CmpF5uPTwO3IYOoQvl31xPKgHan2AochduU= 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=LvFF4bCE; arc=none smtp.client-ip=198.175.65.20 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="LvFF4bCE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114662; x=1817650662; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b/3nCbbeIos8TapZNKsjIUGLe8mZz8XEWaAijxlyQEE=; b=LvFF4bCEkxbbx1kX2L1kPc/G8ZXGP9xrUWVdSS764LmpQfyGntxLK+x3 4FiCyxe2Eye2euFdh/d3EIbjIFYLV9bFr3ZjY+vmoKWjVqPIdDkuxfTZ1 gDC2oV2WFno72LtoCPbUBlgqYojS/Xbgmpf6wQqhEFF78glYvFNJSdgkP 6LT2OuUHs8KWZklyTzEmXCOw9bOoA/pAaSs4tw/cTT+XYQg9K/isOJdtu lRAe1najbE/VCl47aUSQhsH3Kvs4wb9AwP8q8a48QB3YWjpHK6mLEQxBW itZwQ+QUPQm+HGk85Y9HpBpghCtJppDEsH8CAtpJAXma1SDAS/IXCh0dT Q==; X-CSE-ConnectionGUID: eMtI7tjkTnepN7nUcLq9Qw== X-CSE-MsgGUID: Qf64Fiw8T7WF8nCnU2+knQ== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485267" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485267" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:41 -0700 X-CSE-ConnectionGUID: Wd2TuOILQeG9Ed81BLZv5Q== X-CSE-MsgGUID: 5VsMs/PrQ1yu+yejmSZrrw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809948" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:16 -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 V5 11/14] i3c: master: Reject IBI requests from non-IBI-capable devices Date: Fri, 7 Aug 2026 17:56:35 +0300 Message-ID: <20260807145638.168865-12-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 and V5: 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 ED4AA46D09D; Fri, 7 Aug 2026 14:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114665; cv=none; b=nNlt3TxYYalV3kfegbMiMIytvS9Mp1F4mUCtBNjebfU0nyy+IzzR3000UcwpSyDusZkQA7Wx1FwA8Uz/22OrFeDOhJm8qm39jN0jE584ZajtKb+HThelSG7SJIeIoi49xwIM7PrZfGidPQ618rbPY8fn3sjcEqA+79TyfX8FpyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114665; c=relaxed/simple; bh=jOVtTW9wwrB/Tbivp2qvW3WNeKIS8rhNwvpYL9jBfuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WU3fwwQTvhp9urwrJ+IYYA3JDv118Ayl2MrRLwvJJH6+KJwtJEJkg7cakAuCpQSwe5ygvRiAUNnAInMZn6qkhKUBWab+QrmQhTOqjjyTmlo9UR2sp1JO4lLjQBtUTbMkq1+8OzpCMXaoJ5Wsq1oSm6dYI+gh3Q8HCBuuz06rNKc= 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=hH0nch5b; arc=none smtp.client-ip=198.175.65.20 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="hH0nch5b" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114663; x=1817650663; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jOVtTW9wwrB/Tbivp2qvW3WNeKIS8rhNwvpYL9jBfuM=; b=hH0nch5bErbj9yU3V+4t3n9uNReGBmi9XDoVVN0U9PbpsxrxK0mkSMe/ n5sNJ8ULH12BpJs7PVy3lvgPW/ar+RVah2aE9+yJ832MWX9NE+RZy8ZCn JMfAqXL1RhLRCU9xbl1NQMBruXs+TaQQXZzSjSy06fW582Is6Gh+JMseC Dz+Fkw4zLcFXWabVzT0QznJX69iBpf0MMNoTEQ11bcX3iyxZJqHDTbAj1 jKMnCUsrQnVwnvBDQE6M99GrSO4KIk6dBxzXQY7m8cye95ExvM0FiQjCH HfJlHYSJ2G3R+KgLqzN2UPmXzwfItuYDizkghUBXGUUlWqWLFWtWa9FH6 Q==; X-CSE-ConnectionGUID: ejOAAJ+FQ+OXIIYRYuYFQA== X-CSE-MsgGUID: ZJxDI87MQlW2fmelQHfGpg== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485279" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485279" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:41 -0700 X-CSE-ConnectionGUID: iiuIm0ZUS1Wz/1DMOdxc4g== X-CSE-MsgGUID: v2Qiivh7RAiz464WX3TEJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809950" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:19 -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 V5 12/14] i3c: mipi-i3c-hci-pci: Propagate I3C wakeup requirements to PCI Date: Fri, 7 Aug 2026 17:56:36 +0300 Message-ID: <20260807145638.168865-13-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: Added Frank's Rev'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 D213F46D09D; Fri, 7 Aug 2026 14:57:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114673; cv=none; b=ktz3R0SCbh7ubyDIqXn8/7K1BKE2WFHL552zk+wwOwwQiv7CTyVHu8BQQmtoQDcMNbwK5NJciuBn7TcIGh9xtgU61GwqXiqFMa7C4kLJEeSfJUIF7ebuBF6wAIlltesHEPMTIRkmap1uvXC6hI45bXXZi2VSIjOu4o/z+FyvCxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114673; c=relaxed/simple; bh=umdniyFg/qqA1LNU9pxljLDd0VTYT8cJTJzAEkiC6Hk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h5jsZPsI6Vbb/KJYlg6TAwabxZRLnOL3cW4rJpDW81CR8oHWW5s1EK7+eWKJqphGOKUXndBIGqNlcOHFB09O7zGUg4nHhLlhmdoohkSS8Fh2AREVsjD/6F//4p9JhJ11Rzfm25wb0LTz3Ay8T2mlVbdhY/dW0Cbfzc9aTDVxnLU= 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=S4lXz3i0; arc=none smtp.client-ip=198.175.65.20 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="S4lXz3i0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114671; x=1817650671; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=umdniyFg/qqA1LNU9pxljLDd0VTYT8cJTJzAEkiC6Hk=; b=S4lXz3i0mPVp4BUHfX+DtIuCF6Pg8DLTL3iP3ZolaPClldIuj0b1KXTJ 22LLZf04VzWljvg2ZhskFM3YEbhX/MSGF/M99LkzjoPCEIbgnvQzmOb91 Z3508ZNYeM/rJP1JwCGIZUX/mmf9s6N7cO5otnvqH4Fx6u6+/VSSV+FoV PYpKw3ixLvDKQOGR/NbpZ4bylqmhUUl+SIViS5LCH4w5IS5i2NYueSZYw qHuwPuND6EHj35Zsu15yDpKd1qPqqPLHkOM9yuNf5iPTwmuYGU02/CniT kOSm4ugsS3JEbYM6/F87zUDGJ1mS2RvGbEptg9j8mycCw+puXiMmYyFTk g==; X-CSE-ConnectionGUID: IAp9obotQiqH9iuL4A1p8g== X-CSE-MsgGUID: gvOi9DDDR6CG9+lsVRFukw== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485295" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485295" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:50 -0700 X-CSE-ConnectionGUID: QAlhtbX4RNuHvLsbTYLMOA== X-CSE-MsgGUID: 9f/Q1UDCQY+7kUtCw80+Aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809953" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57: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 V5 13/14] i3c: mipi-i3c-hci: Factor out i3c_hci_sysdev() Date: Fri, 7 Aug 2026 17:56:37 +0300 Message-ID: <20260807145638.168865-14-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 Reviewed-by: Frank Li Acked-by: Mukesh Savaliya --- Changes in V5: Added Frank's Rev'd-by Added Mukesh's Ack'd-by 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 Tue Sep 29 13:19:14 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 27C42435EF2; Fri, 7 Aug 2026 14:57:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114674; cv=none; b=DNvfn80tZMOUVXODjYsL+VVXxy/y323Jp1IWdCXbRNrQtjNnrm2EzfcXD6tJYkoRB7jgGSBgv5SHfS0EV1HJ1G3jnWZgvD5/Oncw7S4R3ncFIYd6T9QHDlG6dHA7EFQmg7lSozzq+xsScU1tGGSyB2RMRx7a7ssH9tdRMEgG5Aw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114674; c=relaxed/simple; bh=WCBP3RYMvYq8dw77nVtVu31W3Qa1sdE1j3BBwSPtGt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZBqKl1JFWcjYf4VuWIIv4KGkDVDdjdkTMJpMcrnSQx4TtGawzA36kPUnHkHPJNcjF2dOOLqZ3dVejxJDbxkdhQt9nDlBgSGjJnDfvxKHl75FsKlnpiA58jCptd9KJdLASLTHaG1NX7sIhyDqm1xKVaIjH9nfGFryLuSrZ7GvEqM= 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=fiv7E5zS; arc=none smtp.client-ip=198.175.65.20 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="fiv7E5zS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786114673; x=1817650673; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WCBP3RYMvYq8dw77nVtVu31W3Qa1sdE1j3BBwSPtGt0=; b=fiv7E5zSDS/iEnfVEHfgj+rf6QlnWwC0PA2HYauz3Cjgf24FjT46h22z uyYbjfXwSsPGVcrfh73jQBL3lX9XKym2N374+1/DGZ4M8Gn8t8RTbPfeT x61AaI8b0vlDT0DU76RCq1ORngAHufxqdsRMmvZwuIoRwIv8c4r3zc0VK 7NF6TP+W0HWApmBbJiorYD7douxVB+lu7w3khAZ907oRPPc0UX7fVhlee aLkDE9ENZ/FrdtI+2mfU1+94Y/lITOCCogpGJRqnc02xNLG6Ec2HjAw/p c2JHPdXp+dzZONE11dWyV03wtDksyPzhtqGaJo0eznBik61cAlPYCICzI Q==; X-CSE-ConnectionGUID: jRREpk2MQaORw5RjTvp40A== X-CSE-MsgGUID: bjOSRlFHTVmTfDG4T43RjA== X-IronPort-AV: E=McAfee;i="6800,10657,11868"; a="86485300" X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="86485300" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:50 -0700 X-CSE-ConnectionGUID: ozuY+Q+DSiSnCvilsCLGDw== X-CSE-MsgGUID: lKRgqdkhROupl7Yov/of0g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,210,1779174000"; d="scan'208";a="259809956" Received: from amilburn-desk.amilburn-desk (HELO ahunter6-desk) ([10.245.245.114]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2026 07:57:27 -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 V5 14/14] i3c: mipi-i3c-hci: Advertise IBI wakeup capability Date: Fri, 7 Aug 2026 17:56:38 +0300 Message-ID: <20260807145638.168865-15-adrian.hunter@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260807145638.168865-1-adrian.hunter@intel.com> References: <20260807145638.168865-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 V5: None 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