Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jun 2022 15:23:14 GMT
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ae3ffc006006 - stable/13 - linuxkpi: Acquire giant when adding/removing i2c adapters
Message-ID:  <202206211523.25LFNEHs062956@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=ae3ffc006006dedb3cd7ddc329b663d02b354e3b

commit ae3ffc006006dedb3cd7ddc329b663d02b354e3b
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2022-06-14 11:23:26 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-06-21 15:13:57 +0000

    linuxkpi: Acquire giant when adding/removing i2c adapters
    
    We need Giant as we run in a taskqueue_thread via linux_work.
    This fix detaching amdgpu and i915kms.
    
    Reviewed by:    bz, hselasky, imp
    Sponsored by:   Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D35478
    
    (cherry picked from commit d87fad36330b6faf657e7ee8faaa52feeaaff68a)
---
 sys/compat/linuxkpi/common/src/linux_i2c.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/compat/linuxkpi/common/src/linux_i2c.c b/sys/compat/linuxkpi/common/src/linux_i2c.c
index eedd877f0e0f..80b47a74c2e5 100644
--- a/sys/compat/linuxkpi/common/src/linux_i2c.c
+++ b/sys/compat/linuxkpi/common/src/linux_i2c.c
@@ -223,7 +223,9 @@ lkpi_i2c_add_adapter(struct i2c_adapter *adapter)
 		return (ENXIO);
 	}
 
+	bus_topo_lock();
 	error = bus_generic_attach(adapter->dev.parent->bsddev);
+	bus_topo_unlock();
 	if (error) {
 		device_printf(adapter->dev.parent->bsddev,
 		  "failed to attach child: error %d\n", error);
@@ -251,7 +253,9 @@ lkpi_i2c_del_adapter(struct i2c_adapter *adapter)
 	while ((child = device_find_child(adapter->dev.parent->bsddev, "lkpi_iic", unit++)) != NULL) {
 
 		if (adapter == LKPI_IIC_GET_ADAPTER(child)) {
+			bus_topo_lock();
 			device_delete_child(adapter->dev.parent->bsddev, child);
+			bus_topo_unlock();
 			rv = 0;
 			goto out;
 		}
@@ -261,7 +265,9 @@ lkpi_i2c_del_adapter(struct i2c_adapter *adapter)
 	while ((child = device_find_child(adapter->dev.parent->bsddev, "lkpi_iicbb", unit++)) != NULL) {
 
 		if (adapter == LKPI_IIC_GET_ADAPTER(child)) {
+			bus_topo_lock();
 			device_delete_child(adapter->dev.parent->bsddev, child);
+			bus_topo_unlock();
 			rv = 0;
 			goto out;
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202206211523.25LFNEHs062956>