Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp367735lqs; Thu, 13 Jun 2024 12:19:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbGEIFAZkXXa7laOXVRshr46hwtTmpJUE4tEk4GQqJFpfkKFjMvjq23w12b0c0qx1qZdRvI/j2iXRxTcrja8ue7DHE5kThdLnW5/NuBw== X-Google-Smtp-Source: AGHT+IHy2gpBXOz3pdnVxRbN+vlhV6XwCF+Ch72kXKGgCjrNCHpofqqF1tTFGQNR2SoexPgDf1fQ X-Received: by 2002:a17:906:c0cc:b0:a6f:13fe:75d1 with SMTP id a640c23a62f3a-a6f60de6064mr51598866b.64.1718306360948; Thu, 13 Jun 2024 12:19:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718306360; cv=pass; d=google.com; s=arc-20160816; b=st/puePNUydVOKKbIC4ScSamGfGGZRIztmG274QgU3815UvyuYwjtPLIl7EAUhiX8c JPwsXpqz9V6mflBclsMpXVoyuLyMBmwqHEcgWQdYD/0vWUjiJQVvGbUDUxRjTe1h55EJ 7y76DPAXCIOxYWs1taMg6ckRFcrYTiUJZYkmw5xxcN1jmlzfmOpFpuEfRadpEs6V6n2N SP3aCQkXBvZ3uACreNHZF8uYvxUwuiUfK1ihq1FVpQmcXZ6IT5dxTDllGRC2i1pCPdKV PRjBVFZA/JODbXtEgLqs4lNqaNM7ZerzKG8UC+FTq8623fDfX6ZsP6ZhOFZfu1XfQ8H/ xAQg== 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=Ymbb4xgIW76kXGHw5TWCFYhXE4I4Ux1HKHbW5NQgehU=; fh=CqxT77qf7v0cyxcEfKNOSCPmdYyfEe8xwwY3GXvpCv4=; b=Z8PTcdV+7MvIVVnIu1nMi5TYu1jpt5ESDiE+wCw+/ah2jMFeAnWmWI12p1/jaYze7X Rh+GHHJZTIn4hRSQD6dCTx8XNQM7sTVnzJdmlTW9AhS3ms6PdZfJxFLVuya6o6rBANGc ecwayoSBkhkBpHtn8fExy5MwIQajb18hEnevILTLRtN5J7++wmdjpM/YMeRka4vrBGVW eyKH/HTFkNM1NQhMKsCAE1kop1nrp/xcFa3Uo9mudeCuB1AC8I3+JPkGvg/bBAmo4XUb Eo6m7uGL1JA2tg/0EK4b4NouCdOmoRaupih4Gh8Ds/2GxTmtqIUCcT7xSR/maxDuULJq viyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="F1ZH/T0E"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-213901-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213901-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 a640c23a62f3a-a6f56d21ed2si93602666b.202.2024.06.13.12.19.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 12:19:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213901-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="F1ZH/T0E"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-213901-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213901-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 78D751F2516A for ; Thu, 13 Jun 2024 19:19:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1ABCF156C7C; Thu, 13 Jun 2024 19:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="F1ZH/T0E" Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 65EAC156652 for ; Thu, 13 Jun 2024 19:17:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718306249; cv=none; b=iJ/zcG8wVR4Q65OH+yU3d9oSaXtwXHip6De5/TqYaqDqaKJDDsjv6FN9kYM4WSfBtswfYDOUX+syBB1mYowKMUF8vYdDKqgjDH8Ap2w77nNgsp/1fYcNFPz5RIchfaRsqLwBk92hmg21rZ9JF7Nd0QCDy/ESGyLuur0os/K6ViY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718306249; c=relaxed/simple; bh=wyd3unbCcjC0c5v/PRLsdXM3ug0np76A1JHXnQ/r8hY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KcMMxjiJd0BnJ2V0lwjDm6qhncFDK5i+8jx4SsZ/jLyET31TmDZbbh0PrimRP9NU9YDN5hKP/W2mtzf+dpTNG9spP0cPQQb8YBzPW4lJHjpF2e9LqhB+mmi1YWuiCEwVH7v/RqLjSAb3TY9Xv5N4P2UoU08MO/mVPFVqhRlZoC0= 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=F1ZH/T0E; arc=none smtp.client-ip=209.85.222.181 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-qk1-f181.google.com with SMTP id af79cd13be357-795ca45c54cso83500485a.0 for ; Thu, 13 Jun 2024 12:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1718306246; x=1718911046; 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=Ymbb4xgIW76kXGHw5TWCFYhXE4I4Ux1HKHbW5NQgehU=; b=F1ZH/T0EhT1C93SRDfXpPzjv8ZRdLyZlhfZW2+qb3yVMHYCG49heUgaNG5OlCmUsEL dJa7YmkWiXKrm3W+QIzqt8pqQe/OZ6RWBBb9ltRRY6KZha0qXMpkKo1AIBx/rBzbsObV CWmF4DbuWv2xo8ZEs/E1+/e9grpVaD4bvqtU4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718306246; x=1718911046; 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=Ymbb4xgIW76kXGHw5TWCFYhXE4I4Ux1HKHbW5NQgehU=; b=FoAUfxC+8EIKXs5W9tj42yydURWPN+Vd6XFrJN2+b2GpGsSVhkkGTW6/iPWNP9yMEZ 1tr4SNC2TNBCbeV/EfGHRZZM5QvQb8Qbaysl2Ga6qslXJ+AyAKIR2iFHwMeGHZ0pSOUb uRnCV0WWPXDItimGMDX8G2tHdj33qIWeO1Z+LYqopBgdPECnSv4u4iLvo5J0o051h4nS ze8PrgSWNCOIY79nuN7m9DQPf5wKL6Fx0OxSj9RhVsanKVFMpqqSs0sg2HTYbB70OgwR jjcPIjDqi/BC6mRqh/FsAohy5quUGj9lryTKQlt1HGUcEKz/XjzAxFBYrhP+mjjJWXZn k2ig== X-Gm-Message-State: AOJu0YwjWrNk2n6bHpGwL4ak/9s3SHWh9XX2zfmGHj7IFlzznyX9TEE1 8PSv7zpA02wjCU4UqqY1atPBLJZdQeGm1Y37EpMCHqkAAy181WqCwPzXqBMSJB97to8wAX9fumx pv5yRQx7kzIOPmxE7ynsWts8XfRlkxhN0RLPdpFYLJQdyBtPjBwIKtUbJlD1XGPxKzsL2hB6eK1 fVO8GPdhaHbW734LifNiDFgMQVQfgVHQ4aIM1ZOicLB9G6ovGBfYlR X-Received: by 2002:a05:6214:4216:b0:6b0:82fb:bdbd with SMTP id 6a1803df08f44-6b2b00bf9c8mr5501646d6.49.1718306245692; Thu, 13 Jun 2024 12:17:25 -0700 (PDT) Received: from amakhalov-build-vm.eng.vmware.com ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b2a5eb47f6sm9714106d6.82.2024.06.13.12.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 12:17:25 -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 Subject: [PATCH v11 3/8] input/vmmouse: Use VMware hypercall API Date: Thu, 13 Jun 2024 12:16:45 -0700 Message-Id: <20240613191650.9913-4-alexey.makhalov@broadcom.com> X-Mailer: git-send-email 2.39.4 In-Reply-To: <20240613191650.9913-1-alexey.makhalov@broadcom.com> References: <20240613191650.9913-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 --- drivers/input/mouse/vmmouse.c | 76 ++++++++++------------------------- 1 file changed, 22 insertions(+), 54 deletions(-) diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c index ea9eff7c8099..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,28 +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) : \ - "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 * @@ -145,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"); /* @@ -172,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 @@ -247,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"); } @@ -271,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); @@ -301,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; } @@ -342,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, @@ -351,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.4