From patchwork Thu Jan 25 12:27:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 125825 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1078954ljf; Thu, 25 Jan 2018 04:27:54 -0800 (PST) X-Google-Smtp-Source: AH8x226aDVMuoHzenho5bNK54MoCF3ddz4CpqCYpi/qQYEsLENNs3hvdgjRPK3vqaH4Z212iZXJj X-Received: by 2002:a17:902:1683:: with SMTP id h3-v6mr9986503plh.433.1516883274539; Thu, 25 Jan 2018 04:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516883274; cv=none; d=google.com; s=arc-20160816; b=pibbe8ABDm/TL1L4a7FLu7++r17nDhxzTYur4Oqz0HU5ts1xeqCY9669T93l0MXP7P iUUBBdawE4OdKbG1ySPCjbpatYXWBNLS6z2snuC0xhMtLLK9sI/IghquFb2HtJ+VQdg3 17gesd+Dz0wWu5rAi9YvfVyzS+gePti9e7UQCYEET0PDd7AvGw6672wTh+/vPa8i1lIC zUuw9frs6c+G8Silh+9LuJxxPpxrKeb9bqJnFfpgaea9s7O8dd+NAaDhUtPTfhL96Njz IsOCE2CNTna2JsAW4/YNLfnwIEndMLdy70tWwVkDdYxZD6EClVhXc4iHIZNDXSNkQohR KCqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=jALQrmjuI+kbvXHCgw2I+DBv+iyMyphbykznkQ6vWPE=; b=lQDa6M0gw4fruXugVgzlYJtI6GTOmf0Z00VO8h4txXTVYrIqmrL+hWRA7TSKz9gWA8 60AINeU3R/Qr5N7reLrMwqfqihYxCr9vQAOibNO3Td6mubd5lYhS+Ht0iZA22OkC9DVE Iigm4NLTlgJ5u7ZrbmB0SmcRx6SvwgUXDYsqGtInh+szkIVI5X6SJusE+CN0ghwLqxb8 7BxDUaBENv2KrtoFAWcgTfcI10zvzh8BwlQ1VvAWMzjn8pPXrY44mmwTaSVQP6cZWbzf gcyDV6yOw0AakkAY9EoRDpcSP2DVyisEhT8Tvzz0jXT0IBbIyRkmA2iqly5rjSycWwcq KL5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=PQQ6rorO; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id m184si4540215pfb.373.2018.01.25.04.27.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 04:27:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=PQQ6rorO; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1B166222CF1B2; Thu, 25 Jan 2018 04:22:22 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 395AB222A3356 for ; Thu, 25 Jan 2018 04:22:21 -0800 (PST) Received: by mail-wm0-x242.google.com with SMTP id j21so22389296wmh.1 for ; Thu, 25 Jan 2018 04:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mYfkUwmOQm2oWGvmPBoBYxum1hPxS1NW1MLnfykGhRY=; b=PQQ6rorOnTZuuiPQkDXm62Y8nv8EdV9DKw62wWVybfLwojYZbfzYtEMeNRjXNT7gZA YWL+goRaS61n/pgPVp0GVdSe5GHMO+nniLJix/0468/kcKv2hytL7HFnULWdHjRi32Ld cjnEytK05j1J0lVDu+AQFhLTNyMe0zWXZ/H7U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mYfkUwmOQm2oWGvmPBoBYxum1hPxS1NW1MLnfykGhRY=; b=REPfA8a1eIir1W2t4wAkzyc4Kw0oYJud3/h/D3tlgfZJod9PNjdZbDmTSlucSfGMRM 70Gfklk4HSgAyYNhOpTllZui204xhbNBozjJVR9ompon7H9tXyG6DUjOYz/rYpliyR4f DYrXkritFmfaHnxMsyyYelt48HknWtfAUIXb2kUccFMUCGKSDPD8HppohfcSZBOp4v1t c6zvR/o+9A0EPSrL+mqJQuGwdeTkJmLOjFHm5f+ksHq4Cjuyz/RkAfuWvUMsc/fyyp1d Lw3hv+qpTdm4OAciNt3Ho+7leskgV771BTNMul/mqk0vBSA58LKmNm+gamT6SAUgtCjw mDbw== X-Gm-Message-State: AKwxytfeb8cq/scNTWOGb8Z3ztu0bp4AXpm9hx1cN3xvGOnXCtPdzMKE 6LzF24teO1WC96YIyOIY+KvoQpS83oA= X-Received: by 10.28.125.19 with SMTP id y19mr6989556wmc.101.1516883268946; Thu, 25 Jan 2018 04:27:48 -0800 (PST) Received: from localhost.localdomain ([160.167.127.168]) by smtp.gmail.com with ESMTPSA id v75sm5510001wrc.45.2018.01.25.04.27.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 04:27:48 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 25 Jan 2018 12:27:31 +0000 Message-Id: <20180125122736.5427-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180125122736.5427-1-ard.biesheuvel@linaro.org> References: <20180125122736.5427-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms 3/8] Silicon/NXP/Pcf8563RealTimeClockLib: avoid driver binding protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Instead of registering a notification callback on the driver binding protocol, and attempting to connect our I2C master handle each time a new driver is registered, switch to the more obvious approach of registering a notification callback on the I2C master protocol directly. The original code was written under the assumption that it would make the RTC available at an earlier time, but given that all handles that are created during the execution of a driver entry point are connected by DXE core right away (i.e., before StartImage() returns), this is not really necessary, and in fact, may result in the driver already having been connected by the time we attempt to connect it. Note that it is now up to the platform to ensure that ConnectController() is called for the handle if DXE core does not call it by itself, or does call it but at a time when no I2C master protocol driver is available yet. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c | 31 ++++++++------------ Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf | 1 - 2 files changed, 13 insertions(+), 19 deletions(-) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c index 6bc4aef28849..fb58e1feb424 100644 --- a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c +++ b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.c @@ -41,7 +41,7 @@ #define EPOCH_BASE 2000 STATIC EFI_HANDLE mI2cMasterHandle; -STATIC VOID *mDriverEventRegistration; +STATIC VOID *mI2cMasterEventRegistration; STATIC EFI_I2C_MASTER_PROTOCOL *mI2cMaster; STATIC EFI_EVENT mRtcVirtualAddrChangeEvent; @@ -263,12 +263,12 @@ LibSetWakeupTime ( STATIC VOID -DriverRegistrationEvent ( +I2cMasterRegistrationEvent ( IN EFI_EVENT Event, IN VOID *Context ) { - EFI_HANDLE Handle[2]; + EFI_HANDLE Handle; UINTN BufferSize; EFI_STATUS Status; EFI_I2C_MASTER_PROTOCOL *I2cMaster; @@ -280,10 +280,10 @@ DriverRegistrationEvent ( do { BufferSize = sizeof (EFI_HANDLE); Status = gBS->LocateHandle (ByRegisterNotify, - &gEfiDriverBindingProtocolGuid, - mDriverEventRegistration, + &gEfiI2cMasterProtocolGuid, + mI2cMasterEventRegistration, &BufferSize, - Handle); + &Handle); if (EFI_ERROR (Status)) { if (Status != EFI_NOT_FOUND) { DEBUG ((DEBUG_WARN, "%a: gBS->LocateHandle () returned %r\n", @@ -292,12 +292,7 @@ DriverRegistrationEvent ( break; } - // - // Check if we can connect our handle to this driver. - // - Handle[1] = NULL; - Status = gBS->ConnectController (mI2cMasterHandle, Handle, NULL, FALSE); - if (EFI_ERROR (Status)) { + if (Handle != mI2cMasterHandle) { continue; } @@ -378,16 +373,16 @@ LibRtcInitialize ( ASSERT_EFI_ERROR (Status); // - // Register a protocol registration notification callback on the driver - // binding protocol so we can attempt to connect our I2C master to it - // as soon as it appears. + // Register a protocol registration notification callback on the I2C master + // protocol. This will notify us even if the protocol instance we are looking + // for has already been installed. // EfiCreateProtocolNotifyEvent ( - &gEfiDriverBindingProtocolGuid, + &gEfiI2cMasterProtocolGuid, TPL_CALLBACK, - DriverRegistrationEvent, + I2cMasterRegistrationEvent, NULL, - &mDriverEventRegistration); + &mI2cMasterEventRegistration); // // Register for the virtual address change event diff --git a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf index 1a9a6f6c9cf3..e232902c6b5d 100644 --- a/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf +++ b/Silicon/NXP/Library/Pcf8563RealTimeClockLib/Pcf8563RealTimeClockLib.inf @@ -40,7 +40,6 @@ [Guids] gEfiEventVirtualAddressChangeGuid [Protocols] - gEfiDriverBindingProtocolGuid ## CONSUMES gEfiI2cMasterProtocolGuid ## CONSUMES gPcf8563RealTimeClockLibI2cMasterProtocolGuid ## CONSUMES