diff --git a/zircon/system/core/devmgr/devhost/BUILD.gn b/zircon/system/core/devmgr/devhost/BUILD.gn index b57ac813f92acb22e22855bc194d54c36f8d4bf7..3660c41556874430ecce483f2cda29322f6b1876 100644 --- a/zircon/system/core/devmgr/devhost/BUILD.gn +++ b/zircon/system/core/devmgr/devhost/BUILD.gn @@ -42,7 +42,6 @@ library("driver") { "$zx/system/ulib/fbl", "$zx/system/ulib/fdio", "$zx/system/ulib/fidl", - "$zx/system/ulib/fit", "$zx/system/ulib/fs:fs-for-driver", "$zx/system/ulib/sync", "$zx/system/ulib/trace:trace-driver", diff --git a/zircon/system/core/devmgr/devhost/devhost.cpp b/zircon/system/core/devmgr/devhost/devhost.cpp index 9a69ebddd8d6802f3b1b96e492a3a399dfde3cf8..97b14bb99e0648ba7de0244de7ceb59fad9d4f8a 100644 --- a/zircon/system/core/devmgr/devhost/devhost.cpp +++ b/zircon/system/core/devmgr/devhost/devhost.cpp @@ -29,7 +29,6 @@ #include <fbl/auto_lock.h> #include <fbl/function.h> #include <fs/handler.h> -#include <fuchsia/device/c/fidl.h> #include <fuchsia/device/manager/c/fidl.h> #include <fuchsia/io/c/fidl.h> #include <lib/async-loop/cpp/loop.h> @@ -37,7 +36,6 @@ #include <lib/async/cpp/wait.h> #include <lib/fdio/fdio.h> #include <lib/fidl/coding.h> -#include <lib/fit/defer.h> #include <lib/zx/debuglog.h> #include <lib/zx/resource.h> #include <lib/zx/vmo.h> @@ -549,20 +547,6 @@ static zx_status_t fidl_CreateCompositeDevice(void* raw_ctx, zx_handle_t raw_rpc return fuchsia_device_manager_DevhostControllerCreateCompositeDevice_reply(txn, ZX_OK); } -// Handles outstanding calls to fuchsia.device.Controller/Bind. -static void BindReply(const fbl::RefPtr<zx_device_t>& dev) { - fs::FidlConnection conn(fidl_txn_t{}, ZX_HANDLE_INVALID, 0); - if (dev->PopBindConn(&conn)) { - // TODO(DNO-492): additional logging for debugging what looks like a - // deadlock. Remove once bug is resolved. - printf("DeviceControllerBind finished\n"); - // TODO(ZX-3431): We ignore the status from device_bind() for - // bug-compatibility reasons. Once this bug is resolved, we can - // return the actual status. - fuchsia_device_ControllerBind_reply(conn.Txn(), ZX_OK); - } -} - static zx_status_t fidl_BindDriver(void* raw_ctx, const char* driver_path_data, size_t driver_path_size, zx_handle_t raw_driver_vmo, fidl_txn_t* txn) { @@ -570,12 +554,6 @@ static zx_status_t fidl_BindDriver(void* raw_ctx, const char* driver_path_data, zx::vmo driver_vmo(raw_driver_vmo); fbl::StringPiece driver_path(driver_path_data, driver_path_size); - // We can now reply to calls to fuchsia.device.Controller/Bind, as we have - // completed the request to bind the driver. - auto defer = fit::defer([dev = ctx->conn->dev] { - BindReply(dev); - }); - // TODO: added to help debug DNO-492, remove when done if (driver_path == "/boot/driver/zxcrypt.so") { log(ERROR, "devhost[%s] bind zxcrypt\n", ctx->path); diff --git a/zircon/system/core/devmgr/devhost/rpc-server.cpp b/zircon/system/core/devmgr/devhost/rpc-server.cpp index 8fe32008e70dc54cb8f058eed0212607379400b9..7951a87d8eed43c050ae49bb64b8299a5a5f9d46 100644 --- a/zircon/system/core/devmgr/devhost/rpc-server.cpp +++ b/zircon/system/core/devmgr/devhost/rpc-server.cpp @@ -27,7 +27,6 @@ #include <zircon/syscalls.h> #include <zircon/types.h> -#include <fbl/auto_lock.h> #include <fs/connection.h> #include <fs/handler.h> #include <fuchsia/device/c/fidl.h> @@ -562,14 +561,6 @@ static zx_status_t fidl_DeviceControllerBind(void* ctx, const char* driver_data, memcpy(drv_libname, driver_data, driver_count); drv_libname[driver_count] = 0; - if (!strcmp(drv_libname, "/boot/driver/zxcrypt.so")) { - // TODO(DNO-492): Workaround, due to racing attempts to bind zxcrypt.so - // that results in a deadlock. - fuchsia_device_ControllerBind_reply(txn, ZX_OK); - } else { - conn->dev->PushBindConn(fs::FidlConnection::CopyTxn(txn)); - } - // TODO(DNO-492): additional logging for debugging what looks like a // deadlock. Remove once bug is resolved. printf("DeviceControllerBind running: %s\n", drv_libname); @@ -577,7 +568,10 @@ static zx_status_t fidl_DeviceControllerBind(void* ctx, const char* driver_data, // bug-compatibility reasons. Once this bug is resolved, we can return the // actual status. __UNUSED zx_status_t status = device_bind(conn->dev, drv_libname); - return ZX_OK; + // TODO(DNO-492): additional logging for debugging what looks like a + // deadlock. Remove once bug is resolved. + printf("DeviceControllerBind finished: %s %s\n", drv_libname, zx_status_get_string(status)); + return fuchsia_device_ControllerBind_reply(txn, ZX_OK); } static zx_status_t fidl_DeviceControllerUnbind(void* ctx, fidl_txn_t* txn) { diff --git a/zircon/system/core/devmgr/devhost/zx-device.cpp b/zircon/system/core/devmgr/devhost/zx-device.cpp index 1201f89a95d4c6276248fd06a1ef9dda1f4ea637..d00ea30d2668e6fc7ec2a3b1fdae2ee5638182ea 100644 --- a/zircon/system/core/devmgr/devhost/zx-device.cpp +++ b/zircon/system/core/devmgr/devhost/zx-device.cpp @@ -14,21 +14,6 @@ zx_status_t zx_device::Create(fbl::RefPtr<zx_device>* out_dev) { return ZX_OK; } -void zx_device::PushBindConn(const fs::FidlConnection& conn) { - fbl::AutoLock<fbl::Mutex> lock(&bind_conn_lock_); - bind_conn_.push_back(conn); -} - -bool zx_device::PopBindConn(fs::FidlConnection* conn) { - fbl::AutoLock<fbl::Mutex> lock(&bind_conn_lock_); - if (bind_conn_.is_empty()) { - return false; - } - *conn = bind_conn_[0]; - bind_conn_.erase(0); - return true; -} - // We must disable thread-safety analysis due to not being able to statically // guarantee the lock holding invariant. Instead, we acquire the lock if // it's not already being held by the current thread. diff --git a/zircon/system/core/devmgr/devhost/zx-device.h b/zircon/system/core/devmgr/devhost/zx-device.h index 90bf1a4bc8ffdb9a3c064fbda0119af6f0283863..26152085fc32b4c95aa930ece11505bd3efc9313 100644 --- a/zircon/system/core/devmgr/devhost/zx-device.h +++ b/zircon/system/core/devmgr/devhost/zx-device.h @@ -12,8 +12,6 @@ #include <fbl/recycler.h> #include <fbl/ref_counted_upgradeable.h> #include <fbl/ref_ptr.h> -#include <fbl/vector.h> -#include <fs/handler.h> #include <lib/zx/channel.h> #include <lib/zx/eventpair.h> #include <zircon/compiler.h> @@ -82,9 +80,6 @@ struct zx_device : fbl::RefCountedUpgradeable<zx_device>, fbl::Recyclable<zx_dev return Dispatch(ops->message, ZX_ERR_NOT_SUPPORTED, msg, txn); } - void PushBindConn(const fs::FidlConnection& conn); - bool PopBindConn(fs::FidlConnection* conn); - // Check if this devhost has a device with the given ID, and if so returns a // reference to it. static fbl::RefPtr<zx_device> GetDeviceFromLocalId(uint64_t local_id); @@ -185,10 +180,6 @@ private: // Identifier assigned by devmgr that can be used to assemble composite // devices. uint64_t local_id_ = 0; - - // The connection associated with a fuchsia.device.Controller/Bind. - fbl::Mutex bind_conn_lock_; - fbl::Vector<fs::FidlConnection> bind_conn_ TA_GUARDED(bind_conn_lock_); }; // zx_device_t objects must be created or initialized by the driver manager's diff --git a/zircon/system/core/devmgr/dmctl/BUILD.gn b/zircon/system/core/devmgr/dmctl/BUILD.gn index 010be79855ac2e9a4ad4d84ac57a1ad7a13d99eb..d702904df07e65a6236a8c227a6dac4eecc5d553 100644 --- a/zircon/system/core/devmgr/dmctl/BUILD.gn +++ b/zircon/system/core/devmgr/dmctl/BUILD.gn @@ -11,7 +11,6 @@ driver("dmctl") { "$zx/system/ulib/ddk", "$zx/system/ulib/ddktl", "$zx/system/ulib/fbl", - "$zx/system/ulib/fs:fs-for-driver", "$zx/system/ulib/zircon", "$zx/system/ulib/zx", "$zx/system/ulib/zxcpp", diff --git a/zircon/system/dev/test/ddk-test/ddk-test.c b/zircon/system/dev/test/ddk-test/ddk-test.c index 957d794d1bce037e91b818528473f74e2d89f09f..b1e0927b3e1f67a1d1231c3307576737771db8dd 100644 --- a/zircon/system/dev/test/ddk-test/ddk-test.c +++ b/zircon/system/dev/test/ddk-test/ddk-test.c @@ -6,7 +6,6 @@ #include <ddk/driver.h> #include <ddk/binding.h> #include <ddk/protocol/test.h> -#include <zircon/assert.h> #include <unittest/unittest.h> #include <stddef.h> @@ -58,32 +57,9 @@ static zx_status_t ddk_test_func(void* cookie, test_report_t* report) { return report->n_failed == 0 ? ZX_OK : ZX_ERR_INTERNAL; } -static zx_device_t* child_dev = NULL; - -static void child_unbind(void* ctx) { - device_remove(child_dev); -} - -static zx_protocol_device_t child_device_ops = { - .version = DEVICE_OPS_VERSION, - .unbind = child_unbind, -}; - zx_status_t ddk_test_bind(void* ctx, zx_device_t* parent) { - device_add_args_t args = { - .version = DEVICE_ADD_ARGS_VERSION, - .name = "child", - .ops = &child_device_ops, - .flags = DEVICE_ADD_NON_BINDABLE, - }; - ZX_ASSERT(child_dev == NULL); - zx_status_t status = device_add(parent, &args, &child_dev); - if (status != ZX_OK) { - return status; - } - test_protocol_t proto; - status = device_get_protocol(parent, ZX_PROTOCOL_TEST, &proto); + zx_status_t status = device_get_protocol(parent, ZX_PROTOCOL_TEST, &proto); if (status != ZX_OK) { return status; } diff --git a/zircon/system/ulib/ddktl/test/ddktl-test.cpp b/zircon/system/ulib/ddktl/test/ddktl-test.cpp index bad3ff2c81333c06c3bb3b51afba39670b913f3b..15cfa061583a1ca5af16293f54f2559bcc507fb8 100644 --- a/zircon/system/ulib/ddktl/test/ddktl-test.cpp +++ b/zircon/system/ulib/ddktl/test/ddktl-test.cpp @@ -6,11 +6,9 @@ #include <ddk/device.h> #include <ddk/driver.h> #include <ddk/protocol/test.h> -#include <ddktl/device.h> #include <lib/zx/socket.h> #include <limits.h> -#include <memory> #include <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -64,29 +62,12 @@ zx_status_t ddktl_test_func(void* cookie, test_report_t* report) { return report->n_failed == 0 ? ZX_OK : ZX_ERR_INTERNAL; } -class ChildDevice; -using ChildDeviceType = ddk::Device<ChildDevice, ddk::Unbindable>; - -class ChildDevice : public ChildDeviceType { -public: - ChildDevice(zx_device_t* parent) : ChildDeviceType(parent) {} - void DdkUnbind() { DdkRemove(); } - void DdkRelease() { delete this; } -}; - } // namespace extern "C" zx_status_t ddktl_test_bind(void* ctx, zx_device_t* parent) { - auto device = std::make_unique<ChildDevice>(parent); - zx_status_t status = device->DdkAdd("child", DEVICE_ADD_NON_BINDABLE); - if (status != ZX_OK) { - return status; - } - // devmgr now owns this - __UNUSED auto ptr = device.release(); - test_protocol_t proto; - status = device_get_protocol(parent, ZX_PROTOCOL_TEST, &proto); + auto status = + device_get_protocol(parent, ZX_PROTOCOL_TEST, reinterpret_cast<void*>(&proto)); if (status != ZX_OK) { return status; } diff --git a/zircon/system/ulib/fs/BUILD.gn b/zircon/system/ulib/fs/BUILD.gn index b0da9c3a736a362d606ec8264d5e585c820dccc7..c6535041c8f01fb232961517e2d73ae75072ea78 100644 --- a/zircon/system/ulib/fs/BUILD.gn +++ b/zircon/system/ulib/fs/BUILD.gn @@ -113,7 +113,7 @@ if (is_fuchsia) { library("fs-for-driver") { visibility = [ ":*", - "$zx/system/core/devmgr/*", + "$zx/system/core/devmgr/devhost:*", ] sources = [ "block-txn.cpp", diff --git a/zircon/system/utest/driver-test/main.cpp b/zircon/system/utest/driver-test/main.cpp index 1e95ba22de9fe0826359f796183d99c1ac3daa99..6e0ad8a51ecb1c9718b3e45afd35f0a6756e461d 100644 --- a/zircon/system/utest/driver-test/main.cpp +++ b/zircon/system/utest/driver-test/main.cpp @@ -105,15 +105,6 @@ void do_one_test(const IsolatedDevmgr& devmgr, const zx::channel& test_root, return; } - // Check that Bind was synchronous by looking for the child device. - char child_devpath[fuchsia_device_test_MAX_DEVICE_PATH_LEN+1]; - snprintf(child_devpath, sizeof(child_devpath), "%s/child", relative_devpath); - fd.reset(openat(devmgr.devfs_root().get(), child_devpath, O_RDWR)); - if (!fd.is_valid()) { - printf("driver-tests: error binding device %s %s\n", devpath, relative_devpath); - return; - } - zx::socket output_copy; status = output.duplicate(ZX_RIGHT_SAME_RIGHTS, &output_copy); if (status != ZX_OK) {