[prev in list] [next in list] [prev in thread] [next in thread]
List: win-pv-devel
Subject: Re: [win-pv-devel] [PATCH 3/4] xenvkbd: Read "feature-vkbd-standalone"
From: Paul Durrant <Paul.Durrant () citrix ! com>
Date: 2017-06-12 9:01:37
Message-ID: 429529179d2548d89454941ec8c5588a () AMSPEX02CL03 ! citrite ! net
[Download RAW message or body]
> -----Original Message-----
> From: win-pv-devel [mailto:win-pv-devel-bounces@lists.xenproject.org] On
> Behalf Of owen.smith@citrix.com
> Sent: 07 June 2017 16:52
> To: win-pv-devel@lists.xenproject.org
> Cc: Owen Smith <owen.smith@citrix.com>
> Subject: [win-pv-devel] [PATCH 3/4] xenvkbd: Read "feature-vkbd-
> standalone"
>
> From: Owen Smith <owen.smith@citrix.com>
>
> Read "feature-vkbd-standalone" and fail connect
> if it is not 1. Writes "request-vkbd-standalone" before
> transitioning to Connected.
>
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
Acked-by: Paul Durrant <paul.durrant@citrix.com>
> ---
> src/xenvkbd/frontend.c | 15 +++++++------
> src/xenvkbd/hid.c | 14 +++++--------
> src/xenvkbd/ring.c | 57
> +++++++++++++++++++++++++++++++++++++++++---------
> 3 files changed, 59 insertions(+), 27 deletions(-)
>
> diff --git a/src/xenvkbd/frontend.c b/src/xenvkbd/frontend.c
> index ea85cd2..1d6d360 100644
> --- a/src/xenvkbd/frontend.c
> +++ b/src/xenvkbd/frontend.c
> @@ -795,7 +795,7 @@ FrontendSetState(
> IN XENVKBD_FRONTEND_STATE State
> )
> {
> - BOOLEAN Failed;
> + NTSTATUS status;
> KIRQL Irql;
>
> KeAcquireSpinLock(&Frontend->Lock, &Irql);
> @@ -805,10 +805,8 @@ FrontendSetState(
> FrontendStateName(Frontend->State),
> FrontendStateName(State));
>
> - Failed = FALSE;
> - while (Frontend->State != State && !Failed) {
> - NTSTATUS status;
> -
> + status = STATUS_SUCCESS;
> + while (Frontend->State != State && NT_SUCCESS(status)) {
> switch (Frontend->State) {
> case FRONTEND_UNKNOWN:
> switch (State) {
> @@ -820,8 +818,6 @@ FrontendSetState(
> status = FrontendClose(Frontend);
> if (NT_SUCCESS(status)) {
> Frontend->State = FRONTEND_CLOSED;
> - } else {
> - Failed = TRUE;
> }
> break;
>
> @@ -860,6 +856,9 @@ FrontendSetState(
> Frontend->State = FRONTEND_CLOSED;
> }
> break;
> + case FRONTEND_UNKNOWN:
> + Frontend->State = FRONTEND_UNKNOWN;
> + break;
> default:
> ASSERT(FALSE);
> break;
> @@ -935,7 +934,7 @@ FrontendSetState(
>
> Info("%s: <=====\n", __FrontendGetPath(Frontend));
>
> - return (!Failed) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
> + return status;
> }
>
> static FORCEINLINE VOID
> diff --git a/src/xenvkbd/hid.c b/src/xenvkbd/hid.c
> index 03fc1a2..8a90dd1 100644
> --- a/src/xenvkbd/hid.c
> +++ b/src/xenvkbd/hid.c
> @@ -109,13 +109,11 @@ HidEnable(
> {
> PXENVKBD_HID_CONTEXT Context = Interface->Context;
> KIRQL Irql;
> - BOOLEAN Exclusive;
> NTSTATUS status;
>
> Trace("====>\n");
>
> AcquireMrswLockExclusive(&Context->Lock, &Irql);
> - Exclusive = TRUE;
>
> if (Context->Enabled)
> goto done;
> @@ -128,11 +126,12 @@ HidEnable(
> KeMemoryBarrier();
>
> status = FrontendSetState(Context->Frontend, FRONTEND_ENABLED);
> - if (!NT_SUCCESS(status))
> - goto fail1;
> + if (!NT_SUCCESS(status)) {
> + if (status != STATUS_DEVICE_NOT_READY)
> + goto fail1;
> + }
>
> done:
> - ASSERT(Exclusive);
> ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
>
> Trace("<====\n");
> @@ -149,10 +148,7 @@ fail1:
> Context->Argument = NULL;
> Context->Callback = NULL;
>
> - if (Exclusive)
> - ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
> - else
> - ReleaseMrswLockShared(&Context->Lock);
> + ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
>
> return status;
> }
> diff --git a/src/xenvkbd/ring.c b/src/xenvkbd/ring.c
> index da1bd17..914521c 100644
> --- a/src/xenvkbd/ring.c
> +++ b/src/xenvkbd/ring.c
> @@ -78,6 +78,7 @@ struct _XENVKBD_RING {
> BOOLEAN Connected;
> BOOLEAN Enabled;
> BOOLEAN AbsPointer;
> + BOOLEAN VkbdStandalone;
>
> XENVKBD_HID_KEYBOARD KeyboardReport;
> XENVKBD_HID_ABSMOUSE AbsMouseReport;
> @@ -497,6 +498,22 @@ RingReadFeatures(
> } else {
> Ring->AbsPointer = FALSE;
> }
> +
> + status = XENBUS_STORE(Read,
> + &Ring->StoreInterface,
> + NULL,
> + FrontendGetBackendPath(Ring->Frontend),
> + "feature-vkbd-standalone",
> + &Buffer);
> + if (NT_SUCCESS(status)) {
> + Ring->VkbdStandalone = (BOOLEAN)strtoul(Buffer, NULL, 2);
> +
> + XENBUS_STORE(Free,
> + &Ring->StoreInterface,
> + Buffer);
> + } else {
> + Ring->VkbdStandalone = FALSE;
> + }
> }
>
> NTSTATUS
> @@ -542,11 +559,15 @@ RingConnect(
> Ring->AbsMouseReport.ReportId = 2;
> RingReadFeatures(Ring);
>
> + status = STATUS_DEVICE_NOT_READY;
> + if (!Ring->VkbdStandalone)
> + goto fail6;
> +
> Ring->Mdl = __AllocatePage();
>
> status = STATUS_NO_MEMORY;
> if (Ring->Mdl == NULL)
> - goto fail6;
> + goto fail7;
>
> ASSERT(Ring->Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
> Ring->Shared = Ring->Mdl->MappedSystemVa;
> @@ -566,7 +587,7 @@ RingConnect(
> FALSE,
> &Ring->Entry);
> if (!NT_SUCCESS(status))
> - goto fail7;
> + goto fail8;
>
> Ring->Channel = XENBUS_EVTCHN(Open,
> &Ring->EvtchnInterface,
> @@ -578,7 +599,7 @@ RingConnect(
>
> status = STATUS_UNSUCCESSFUL;
> if (Ring->Channel == NULL)
> - goto fail8;
> + goto fail9;
>
> XENBUS_EVTCHN(Unmask,
> &Ring->EvtchnInterface,
> @@ -592,13 +613,13 @@ RingConnect(
> Ring,
> &Ring->DebugCallback);
> if (!NT_SUCCESS(status))
> - goto fail9;
> + goto fail10;
>
> Ring->Connected = TRUE;
> return STATUS_SUCCESS;
>
> -fail9:
> - Error("fail9\n");
> +fail10:
> + Error("fail10\n");
>
> XENBUS_EVTCHN(Close,
> &Ring->EvtchnInterface,
> @@ -607,8 +628,8 @@ fail9:
>
> Ring->Events = 0;
>
> -fail8:
> - Error("fail8\n");
> +fail9:
> + Error("fail9\n");
>
> (VOID) XENBUS_GNTTAB(RevokeForeignAccess,
> &Ring->GnttabInterface,
> @@ -617,13 +638,16 @@ fail8:
> Ring->Entry);
> Ring->Entry = NULL;
>
> -fail7:
> - Error("fail7\n");
> +fail8:
> + Error("fail8\n");
>
> Ring->Shared = NULL;
> __FreePage(Ring->Mdl);
> Ring->Mdl = NULL;
>
> +fail7:
> + Error("fail7\n");
> +
> fail6:
> Error("fail6\n");
>
> @@ -715,9 +739,21 @@ RingStoreWrite(
> if (!NT_SUCCESS(status))
> goto fail4;
>
> + status = XENBUS_STORE(Printf,
> + &Ring->StoreInterface,
> + Transaction,
> + FrontendGetPath(Ring->Frontend),
> + "request-vkbd-standalone",
> + "%u",
> + Ring->VkbdStandalone);
> + if (!NT_SUCCESS(status))
> + goto fail5;
> +
> Trace("<=====\n");
> return STATUS_SUCCESS;
>
> +fail5:
> + Error("fail5\n");
> fail4:
> Error("fail4\n");
> fail3:
> @@ -817,6 +853,7 @@ RingTeardown(
> Ring->Dpcs = 0;
>
> Ring->AbsPointer = FALSE;
> + Ring->VkbdStandalone = FALSE;
>
> RtlZeroMemory(&Ring->Dpc, sizeof (KDPC));
>
> --
> 2.8.3
>
>
> _______________________________________________
> win-pv-devel mailing list
> win-pv-devel@lists.xenproject.org
> https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
_______________________________________________
win-pv-devel mailing list
win-pv-devel@lists.xenproject.org
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic