Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp245530lqh; Mon, 6 May 2024 18:53:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUPFhbK9cDykotpfJAVDHVJX1VWwPLu+BEiQRce/pe3TTnFVhXTFB1wxUKwMBx4j3oczm2BWEu3Wx8SXr5bYA64681Wro4M8KGJnOW5jQ== X-Google-Smtp-Source: AGHT+IEbT1tCnTGOXc+b2Ci2WzqwOxMd8dD27cl5Jvwzog3P24Xhg9nE5kryY+E38oMoAGTmKKFZ X-Received: by 2002:a05:6a20:a111:b0:1ad:729e:db22 with SMTP id adf61e73a8af0-1afbdca77femr2135594637.8.1715046832693; Mon, 06 May 2024 18:53:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715046832; cv=pass; d=google.com; s=arc-20160816; b=NecxjnbbGbfip3pCd0b2zNd8RQiYwO5n7NiBEqdWVwltQCHqMCXqwvD58bIjYjxRpQ DZVYkBg94Du735mjJWKKftQ2YNW5uv9s9ER7cxwCP4v34kNJj4eGKyH2r14Xk8dQ5VW2 WK/DoH9iCQjyxTenT+DyFzr4/pvWqMLY75IQVt2tkyagCsUxQm6VMuk+fHU3qlcYI1gN D1X4IiCtqjnd+Vpb2g66z3yLA/XsZI3GSrPoSl+Ub37BQLz7UpPES2F2xDD8N6xPJTXE /iz8BC8LTjwOz3ifFL4gRdbjOmvywypkvlPiLePpbR3st6Yyf6LiYXWANuGOQ6D0hBLx IP0g== ARC-Message-Signature: i=2; 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=fJPGtZqzdd9ZJG8gTToIxNsoCLvLLMCdMU2sH61J3oA=; fh=H4PkKbYzNYfPp0vKgXgp4AgspqmoGzHqxMUk3AXzHgg=; b=k0JxKQ7YpCJCOUiKcFuwwRXUw0uLDQ/T2mgeNU6miGbpzns23/mSVV7YI4ga+ZJ4Ou rwCkb1K1Ir4hJHIzDJyQ2m2Hi4HM6wGclABAQQ+zvHWf6JtUjDgGutY8Wa0VcVvAE/4e Vwo71/ujbIosFcCsLCIo+q2KAm1IU62z5RA9LtsP2D2QluXPqSA/Rf5lsymfC0652dSe 0FqXKVJHtHnZGkZu3o25ghrGnWdcswW6af5oIiPGgxm/Q9F/jnDmxqHM33VRmtWw39+I wNbeuTcX1I14SonVC6vON/fXa6tmeGCksi623uBLKZ3EGD7F/iQXyS9uWmgu2ljLXrkC Ja6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="gfh/j+d+"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-170458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s135-20020a63778d000000b0061e56fa0e40si7277874pgc.59.2024.05.06.18.53.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 18:53:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="gfh/j+d+"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-170458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170458-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E5E04B21E3A for ; Mon, 6 May 2024 21:56:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3972915ECFD; Mon, 6 May 2024 21:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="gfh/j+d+" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 A734F15ECD5 for ; Mon, 6 May 2024 21:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715032432; cv=none; b=L6B7wfgBQT4PLN9yJUfPsWDmiwY7KIAH+kdiWPDHlF94hS/ohT6OJayud1ZxHBBWSm69w0nGd1gR1E8/OxtEwedi8O3b97GMCAc1pFc/E+IlQ+ge0/Bn7nxDTtT98BtrimVS2++3baCJy41XurueK/4Wgpy4/lHc5fKqy5V3BMs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715032432; c=relaxed/simple; bh=bfFhpQ5EYefCcVR9G/dMzMdiH6v/IsMO66uK+uCQ3MU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lRDfcbal0gpuVisc1aT2UXZQfVrdk9nZIOk6OU+gFYbC79z5WpxuWAuefBELmaB2aJsL20JF62ooHfaJ0yqPZ8i//2beMRx1Z/mE90QKPnDYGs5mylwkAAyceJE4YD1/cVfX8Nw57E9b3MhgtrI+Sg52/R3sEXLPjtMzM3LZbLE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=gfh/j+d+; arc=none smtp.client-ip=209.85.214.178 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-pl1-f178.google.com with SMTP id d9443c01a7336-1e4c4fb6af3so13891345ad.0 for ; Mon, 06 May 2024 14:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1715032430; x=1715637230; 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=fJPGtZqzdd9ZJG8gTToIxNsoCLvLLMCdMU2sH61J3oA=; b=gfh/j+d+tVUodvcXlM8A+t976BMSjpsAUSx4QmbRm/afOWY2pPisBPYuu10n+pUfTq LtHZIGTxw3ovNjHDj3RoBoXm82AogFdl/g5ESoTa3CEeZX6XN9Q2fkxZvyk36kdMQSLR Izx7eBXkL/3tBoCxi/L4e3yvWai3cKX+uaY94= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715032430; x=1715637230; 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=fJPGtZqzdd9ZJG8gTToIxNsoCLvLLMCdMU2sH61J3oA=; b=Q+eFWR0qXoFrERvrxspn5I76uYXW+UVvoVSEk7J8UvfQLgB7vqXppe0AL718JEdLed qQAzUWA6fzfVuHVLWo9IR401vZF3Pa3iOh6PqZ+DPI3U3CrkaNIHo8Ugzi+Tx3TyNxqS Aa3cOv77JuY9SYukZa3tE7gUvJx6Qd0pV+qSSt1VMN+vmpOQprY4NJ9TQgOytx3Xfzjo mLvGCrq9/Fbv6MN6AbbSAfKiSW5iK/+0LKsnD96pA+5PMHVGgThHKKrI6frITa/mRJia TdYEENQoQNL8t3BG5JTU6fHgynOj7bdZJGEICIQprt9NGHzlWKrNQ9x0d4o1cmhCTzRU E7fQ== X-Gm-Message-State: AOJu0YwbWKaw/fRf+wmyRPhXJuYs8YA8T5CefYxTKaJ5HbnEoN6g15a+ JZEQ/GKhMMc887NvzNytG5pva5KM4xLViRMR3t+qb15gqWxQUgFA5DJOQM+jakCspTRNZyY79L0 cEFh24aFqflSQMSOSXOqcYE0XF9J0W5ulzh2x5B5JeJ0hbSJLn4bdQGSczJ+qpUfLt9cyxaD8Vs et7eggS7mLxsF9m8FQ+LOaC49BWr1ToGmMPIfelZtErHB7IUCFNwsx X-Received: by 2002:a17:902:e547:b0:1e5:1041:7ed4 with SMTP id d9443c01a7336-1ee63069c04mr14175565ad.14.1715032429112; Mon, 06 May 2024 14:53:49 -0700 (PDT) Received: from amakhalov-build-vm.eng.vmware.com ([128.177.82.146]) by smtp.gmail.com with ESMTPSA id h8-20020a170902f54800b001ed6868e257sm5664008plf.123.2024.05.06.14.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 14:53:48 -0700 (PDT) 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, timothym@vmware.com, akaher@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, Alexey Makhalov , Nadav Amit , Zack Rusin Subject: [PATCH v9 5/8] input/vmmouse: Use VMware hypercall API Date: Mon, 6 May 2024 14:53:02 -0700 Message-Id: <20240506215305.30756-6-alexey.makhalov@broadcom.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20240506215305.30756-1-alexey.makhalov@broadcom.com> References: <20240505182829.GBZjfPzeEijTsBUth5@fat_crate.local> <20240506215305.30756-1-alexey.makhalov@broadcom.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