Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp194652rdd; Tue, 9 Jan 2024 00:44:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyRXH/cSvE42KyCl3HBszuvuvFQhXgcQyy5wC1ngaRO14NdSXjsPVB3a1ByilopO8oGu8d X-Received: by 2002:a17:907:9686:b0:a26:db5e:1f2f with SMTP id hd6-20020a170907968600b00a26db5e1f2fmr362386ejc.35.1704789863018; Tue, 09 Jan 2024 00:44:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704789863; cv=none; d=google.com; s=arc-20160816; b=iXNWWaCCzKUnmJ5azN6wL5jCMijFSxkLvE0g5O4VNA8dfYu8+zNX8xozIl9x7evAoq wT0ZqCQnUHRimm2oAKfhO1lQ3M0ROoA2j4g1dbRZBDGbcvWabbQ3wPLG8Oi/2kIQ9Llu OWxA9bm7IxR4XEA67UW9duymt2b5o5WWd3CAk72C9Q9xGh3CgHGl5YEio7sLsto65wUc m7DTCQfQ4holeRwr7jsSEZkueVB+8tOWEkerp7SkEoCNZke+2NQolhQ5Ku/B5HWIwjIW z1gQzDKLpcjy7xJ5cMgPHAkZ7gqM59uHDI/feewjgQfREdR12Ahux2h38NIxKcDFtWES UXuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=SEgaCDdnwo0fD24sb4/z6MOqtwJ556s/e7KBa+2g7Wk=; fh=6RQVJhUadVlbCYQO8WbwFdcKs3+SddxIKFPo/gACb1Y=; b=qDi2HalpNsirgLeOdU0oZtRZK3St+bgr0xeITjfSHnDpILeaTZAkqswdVRzI8x2+2F RiQJAc7nmCucMRm6i7ndUxO1Yslngzv2Ef7mZDhXcyPCNQ8Vnbl83pNCMJG83v1/UFm9 oUZo9KHaHmMtJihObOL6UfmjOL1j1Uq2elxjMja3lF9cBIq+nUGGwnWTpDa3rxn2exFY zeEf2p4ceJ+jeJJIUSpNZ5QlMgdkYVy2Zoy3vyb7Tgcxz49uKo7G6no6CKrybrA7qaBI 7FVxfSCCdOCtZm/pHN/sjTbzwfrC9Btxh2pkZOP6Sm5Dl6DAGC0sFkw61lGJIFGbsvZU m8hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=PVdwNc7v; spf=pass (google.com: domain of linux-kernel+bounces-20605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c21-20020a50d655000000b00557748eacecsi564140edj.545.2024.01.09.00.44.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 00:44:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=PVdwNc7v; spf=pass (google.com: domain of linux-kernel+bounces-20605-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 825671F251AA for ; Tue, 9 Jan 2024 08:44:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0943C2D60D; Tue, 9 Jan 2024 08:41:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="PVdwNc7v" Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EA4537144 for ; Tue, 9 Jan 2024 08:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-28bc870c540so2363456a91.2 for ; Tue, 09 Jan 2024 00:41:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704789671; x=1705394471; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SEgaCDdnwo0fD24sb4/z6MOqtwJ556s/e7KBa+2g7Wk=; b=PVdwNc7vpkZoU8b8ai6hLKFKYd1pOeng6wjjcCWU4ucR+iQ62Jmwe8h8LR6PKm/inf dR8yQ5HwI2bxDRlI+ox2uHTYEI+fQhbRItIlfQNscdfcytFOvz/hf2BekFaQfSStccJi eq4Hy+sFj8EwJUibMDtWDcbxwJMWPjce3qTWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704789671; x=1705394471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SEgaCDdnwo0fD24sb4/z6MOqtwJ556s/e7KBa+2g7Wk=; b=Y05zj3MtWhaVRKMV6yKLKtO6/K/1+LSTrtzg38UPARUiSHY6MUMiBSVFmJqJbIV+VS sScsIiNiDVgKZdGynGeH6ESaXxXAT/0JLnrrHEozNY195j7LIdt7Xw7Ppvl6nbThVDhi 63uh9MH5L5ee1lJoaOSqRmgBTohEf601tSohvnZZ2OUqa0jHfCoUv1C9QRgcawkW5yuj WZ96eslfNQBN5FNyfjC65lkvZ3p5eI1j0SrVq28tDy5fJwYNO43amOOD217vVIfMdkEG K1eJnPXbofDBkU6FwRHStd8uObIzkRiW7nzcsgKZINm1wHzldfOokPNP9OtIQjgupVKb nLsg== X-Gm-Message-State: AOJu0YzmMmnjo/LjmSf9W3X7zpQcPV6tobjVTB9hl8PvKK+jkr7CxT+E Y8BE9HGoyACPJVXA80b6rgMV56vdWKuvj23tC6ntEdZ134i/1k1vCyu1z0C9x7omPssWmQvrCJz W8o6ZJOSQHQBooSaq0Ow4XhpfDwzXQmIMRjpH++0IVo+XvOF+Ozhev/n3gvTsp7cuWWFOJUpiuj 1OOFI4wiaESL1UyH4VhnQq5uA= X-Received: by 2002:a17:90b:468e:b0:285:b78a:dbce with SMTP id ir14-20020a17090b468e00b00285b78adbcemr2589756pjb.37.1704789670702; Tue, 09 Jan 2024 00:41:10 -0800 (PST) Received: from amakhalov-build-vm.eng.vmware.com ([128.177.82.146]) by smtp.gmail.com with ESMTPSA id sf15-20020a17090b51cf00b0028d435cc2cbsm4772293pjb.15.2024.01.09.00.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 00:41:10 -0800 (PST) From: Alexey Makhalov X-Google-Original-From: Alexey Makhalov To: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, bp@alien8.de, hpa@zytor.com, dave.hansen@linux.intel.com, mingo@redhat.com, tglx@linutronix.de Cc: x86@kernel.org, netdev@vger.kernel.org, richardcochran@gmail.com, linux-input@vger.kernel.org, dmitry.torokhov@gmail.com, zackr@vmware.com, linux-graphics-maintainer@vmware.com, pv-drivers@vmware.com, namit@vmware.com, timothym@vmware.com, akaher@vmware.com, jsipek@vmware.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch, airlied@gmail.com, tzimmermann@suse.de, mripard@kernel.org, maarten.lankhorst@linux.intel.com, horms@kernel.org, kirill.shutemov@linux.intel.com Subject: [PATCH v6 4/7] input/vmmouse: Use VMware hypercall API Date: Tue, 9 Jan 2024 00:40:49 -0800 Message-Id: <20240109084052.58661-5-amakhalov@vmware.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20240109084052.58661-1-amakhalov@vmware.com> References: <20240109084052.58661-1-amakhalov@vmware.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Switch from VMWARE_HYPERCALL macro to vmware_hypercall API. Eliminate arch specific code. No functional changes intended. Signed-off-by: Alexey Makhalov Reviewed-by: Nadav Amit Reviewed-by: Zack Rusin Acked-by: Dmitry Torokhov --- drivers/input/mouse/vmmouse.c | 78 ++++++++++------------------------- 1 file changed, 22 insertions(+), 56 deletions(-) diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c index ad94c835ee66..fb1d986a6895 100644 --- a/drivers/input/mouse/vmmouse.c +++ b/drivers/input/mouse/vmmouse.c @@ -21,19 +21,16 @@ #include "psmouse.h" #include "vmmouse.h" -#define VMMOUSE_PROTO_MAGIC 0x564D5868U - /* * Main commands supported by the vmmouse hypervisor port. */ -#define VMMOUSE_PROTO_CMD_GETVERSION 10 -#define VMMOUSE_PROTO_CMD_ABSPOINTER_DATA 39 -#define VMMOUSE_PROTO_CMD_ABSPOINTER_STATUS 40 -#define VMMOUSE_PROTO_CMD_ABSPOINTER_COMMAND 41 -#define VMMOUSE_PROTO_CMD_ABSPOINTER_RESTRICT 86 +#define VMWARE_CMD_ABSPOINTER_DATA 39 +#define VMWARE_CMD_ABSPOINTER_STATUS 40 +#define VMWARE_CMD_ABSPOINTER_COMMAND 41 +#define VMWARE_CMD_ABSPOINTER_RESTRICT 86 /* - * Subcommands for VMMOUSE_PROTO_CMD_ABSPOINTER_COMMAND + * Subcommands for VMWARE_CMD_ABSPOINTER_COMMAND */ #define VMMOUSE_CMD_ENABLE 0x45414552U #define VMMOUSE_CMD_DISABLE 0x000000f5U @@ -76,30 +73,6 @@ struct vmmouse_data { char dev_name[128]; }; -/* - * Hypervisor-specific bi-directional communication channel - * implementing the vmmouse protocol. Should never execute on - * bare metal hardware. - */ -#define VMMOUSE_CMD(cmd, in1, out1, out2, out3, out4) \ -({ \ - unsigned long __dummy1, __dummy2; \ - __asm__ __volatile__ (VMWARE_HYPERCALL : \ - "=a"(out1), \ - "=b"(out2), \ - "=c"(out3), \ - "=d"(out4), \ - "=S"(__dummy1), \ - "=D"(__dummy2) : \ - [port] "i" (VMWARE_HYPERVISOR_PORT), \ - [mode] "m" (vmware_hypercall_mode), \ - "a"(VMMOUSE_PROTO_MAGIC), \ - "b"(in1), \ - "c"(VMMOUSE_PROTO_CMD_##cmd), \ - "d"(0) : \ - "memory"); \ -}) - /** * vmmouse_report_button - report button state on the correct input device * @@ -147,14 +120,12 @@ static psmouse_ret_t vmmouse_report_events(struct psmouse *psmouse) struct input_dev *abs_dev = priv->abs_dev; struct input_dev *pref_dev; u32 status, x, y, z; - u32 dummy1, dummy2, dummy3; unsigned int queue_length; unsigned int count = 255; while (count--) { /* See if we have motion data. */ - VMMOUSE_CMD(ABSPOINTER_STATUS, 0, - status, dummy1, dummy2, dummy3); + status = vmware_hypercall1(VMWARE_CMD_ABSPOINTER_STATUS, 0); if ((status & VMMOUSE_ERROR) == VMMOUSE_ERROR) { psmouse_err(psmouse, "failed to fetch status data\n"); /* @@ -174,7 +145,8 @@ static psmouse_ret_t vmmouse_report_events(struct psmouse *psmouse) } /* Now get it */ - VMMOUSE_CMD(ABSPOINTER_DATA, 4, status, x, y, z); + status = vmware_hypercall4(VMWARE_CMD_ABSPOINTER_DATA, 4, + &x, &y, &z); /* * And report what we've got. Prefer to report button @@ -249,14 +221,10 @@ static psmouse_ret_t vmmouse_process_byte(struct psmouse *psmouse) static void vmmouse_disable(struct psmouse *psmouse) { u32 status; - u32 dummy1, dummy2, dummy3, dummy4; - - VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_DISABLE, - dummy1, dummy2, dummy3, dummy4); - VMMOUSE_CMD(ABSPOINTER_STATUS, 0, - status, dummy1, dummy2, dummy3); + vmware_hypercall1(VMWARE_CMD_ABSPOINTER_COMMAND, VMMOUSE_CMD_DISABLE); + status = vmware_hypercall1(VMWARE_CMD_ABSPOINTER_STATUS, 0); if ((status & VMMOUSE_ERROR) != VMMOUSE_ERROR) psmouse_warn(psmouse, "failed to disable vmmouse device\n"); } @@ -273,26 +241,24 @@ static void vmmouse_disable(struct psmouse *psmouse) static int vmmouse_enable(struct psmouse *psmouse) { u32 status, version; - u32 dummy1, dummy2, dummy3, dummy4; /* * Try enabling the device. If successful, we should be able to * read valid version ID back from it. */ - VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_ENABLE, - dummy1, dummy2, dummy3, dummy4); + vmware_hypercall1(VMWARE_CMD_ABSPOINTER_COMMAND, VMMOUSE_CMD_ENABLE); /* * See if version ID can be retrieved. */ - VMMOUSE_CMD(ABSPOINTER_STATUS, 0, status, dummy1, dummy2, dummy3); + status = vmware_hypercall1(VMWARE_CMD_ABSPOINTER_STATUS, 0); if ((status & 0x0000ffff) == 0) { psmouse_dbg(psmouse, "empty flags - assuming no device\n"); return -ENXIO; } - VMMOUSE_CMD(ABSPOINTER_DATA, 1 /* single item */, - version, dummy1, dummy2, dummy3); + version = vmware_hypercall1(VMWARE_CMD_ABSPOINTER_DATA, + 1 /* single item */); if (version != VMMOUSE_VERSION_ID) { psmouse_dbg(psmouse, "Unexpected version value: %u vs %u\n", (unsigned) version, VMMOUSE_VERSION_ID); @@ -303,11 +269,11 @@ static int vmmouse_enable(struct psmouse *psmouse) /* * Restrict ioport access, if possible. */ - VMMOUSE_CMD(ABSPOINTER_RESTRICT, VMMOUSE_RESTRICT_CPL0, - dummy1, dummy2, dummy3, dummy4); + vmware_hypercall1(VMWARE_CMD_ABSPOINTER_RESTRICT, + VMMOUSE_RESTRICT_CPL0); - VMMOUSE_CMD(ABSPOINTER_COMMAND, VMMOUSE_CMD_REQUEST_ABSOLUTE, - dummy1, dummy2, dummy3, dummy4); + vmware_hypercall1(VMWARE_CMD_ABSPOINTER_COMMAND, + VMMOUSE_CMD_REQUEST_ABSOLUTE); return 0; } @@ -344,7 +310,7 @@ static bool vmmouse_check_hypervisor(void) */ int vmmouse_detect(struct psmouse *psmouse, bool set_properties) { - u32 response, version, dummy1, dummy2; + u32 response, version, type; if (!vmmouse_check_hypervisor()) { psmouse_dbg(psmouse, @@ -353,9 +319,9 @@ int vmmouse_detect(struct psmouse *psmouse, bool set_properties) } /* Check if the device is present */ - response = ~VMMOUSE_PROTO_MAGIC; - VMMOUSE_CMD(GETVERSION, 0, version, response, dummy1, dummy2); - if (response != VMMOUSE_PROTO_MAGIC || version == 0xffffffffU) + response = ~VMWARE_HYPERVISOR_MAGIC; + version = vmware_hypercall3(VMWARE_CMD_GETVERSION, 0, &response, &type); + if (response != VMWARE_HYPERVISOR_MAGIC || version == 0xffffffffU) return -ENXIO; if (set_properties) { -- 2.39.0