Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp111160lqb; Thu, 23 May 2024 12:16:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbZNjGWsv8SvwA79XYsxJ79AbSC4Fa0VJSA4MtBT4b7LOotI5GeWA9NL1lL6kyqiR223VM2aoy5wD62n+xNwtHTK60pPoXKpjqQ1yAcQ== X-Google-Smtp-Source: AGHT+IGpfylUBzTGmS1/6H/Mu6YNzEDq/4VRqU+RDBoLJNJc4WBktUxTl++7MLSo1mjOYfEYopYS X-Received: by 2002:ac8:57c5:0:b0:439:daae:d6a6 with SMTP id d75a77b69052e-43fb0e52935mr441841cf.15.1716491784645; Thu, 23 May 2024 12:16:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716491784; cv=pass; d=google.com; s=arc-20160816; b=EnkF9j3+RH0Rl/Wt0WDCPj+R+KHe9aIoNj6BHcjkeahnX26uUqTO0kI2+iMkLQar4O +X2EAvvxYl/7Dh90BK7XQvPIL6gRM1GBAReuux3nUAloDYnVXnrOe4gVEgXhiEDxA90a C4GFsQrwjQtrgRgMUGrVgO/6WjDLbNEuU0lUsabI55IlAo48O33S/WbffCS1n0/rlEfD m2/G8ctRLkvDOSRCe74Rvd+wZ9zF+eaW7LM5l5ZiRTkqCeZSE+JQSXybQd8nic3ijfRf I5OEmFuAO1zjXideoHA5IQTPlKNDjTOyCxMspAH3zwDeh3BGbU+SGqzMWy/5jfgBoa9K HtTA== 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=kMDlBkHYNZJZ00Aw4LJCkeS2iOpn6PFpMjzg2tGtKLs=; fh=CqxT77qf7v0cyxcEfKNOSCPmdYyfEe8xwwY3GXvpCv4=; b=uY+mgEhGppJvRJbbRdNsnjxtd70+UthwNoNF0/N8NffDG0TcjJLBkjA18EuCxwaJPa UxJud067+QVKCss+18it/f4QAB2Jc76Z06kmf8WrS/7z01wLpsqocq8L1DISUQz9Y6Xy kwb1LJpcenuIMTqKckxkVmPRSd5+3LzLE2sHVAyr68/VcJAj+mShQ8aC0XROU0WsUYcF oGTYH2dtBRH9OfrGmYzs78ZWDogVLcbd54YcW2QcfHMCrwZqRJDT50M8RIIf6T4A9/Vs JdFSnaogg4icBqTuUSAMFMAjQBrczDgrTjbM7bF00R7VeorBkgGNCSdWbCHt8thLg8Va UekQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=cvl1usmF; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-187915-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187915-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e172c5220si267038401cf.546.2024.05.23.12.16.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 12:16:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187915-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=cvl1usmF; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-187915-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187915-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4E11C1C223B5 for ; Thu, 23 May 2024 19:16:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EA8C84DEF; Thu, 23 May 2024 19:15:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="cvl1usmF" Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (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 C181583CA0 for ; Thu, 23 May 2024 19:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716491724; cv=none; b=KazbfSuLCppM3wNom55ZNJXHAstVYMyyJPEXtLTSL5D2u9tQ+ch/cCVuGMOvWYr+4FSGsiPZK1UU28BkUbTKPVLOn5tDNQrjXQiafSc95UNLwjrq9K6judRfOYpuWa4zkPnO/Xggd2kRr/YdZTjNn7v/nKShdk8JBlbEHP88pv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716491724; c=relaxed/simple; bh=wOdaL9hCVdyyYpYdkKQsVtqWJEQp+PnMxsYFtk8S13o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eI45Uh1EJrasmNeoA17KEd/AaQt9ikfD2y5XIdzzBT9wH03br0q5v7dpNniQszv/v92DrChjoy0SaAgVRMdfAhsqJukoy0FQshsY/BIlhArJ1M3bgdXVE4nrvaMsGIMLYkt62xXt/aP8UcGofFOE5+UDkUi74j1Fic6vfbTPv/U= 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=cvl1usmF; arc=none smtp.client-ip=209.85.160.175 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-qt1-f175.google.com with SMTP id d75a77b69052e-43e23ce7b07so36224331cf.1 for ; Thu, 23 May 2024 12:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1716491721; x=1717096521; 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=kMDlBkHYNZJZ00Aw4LJCkeS2iOpn6PFpMjzg2tGtKLs=; b=cvl1usmFguJPBOnEMoTYam/FegzzH4EraEufbW4kVjBozbclOpruov8oVgBIXK0tlZ j7Sv/I7RTMatSDlmZxg42R5F/Ba4sHAaDQxKqjuHWnJj9Th+nujejeijA42mFnyg9stA ejnznKK5egoiSe1yQ9ShF31LBtdl2mCTIss10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716491721; x=1717096521; 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=kMDlBkHYNZJZ00Aw4LJCkeS2iOpn6PFpMjzg2tGtKLs=; b=L6jJX1H5xGYZmq+R1AamZHNmoJ2cSqzYe/J50bIBR5mPJxaJv4zvVJlwmywDskC++x WhUsaesVDhb9l803qLyg0TRl53nfy7Vva6VIoDNPbzxAr+cLEIbtUw8yS7GiyOrKz1JZ rUq8XU7UEBLEaMvnI/EOgIO+suQaeCljz6E0/eYEpJmtaF9rnLeHJ3piB5Aw7erw/Kp6 BhAniHbv22W90KlPlWNkiw/xZsxhJ/0kdm+DbrjqHzxaKua6W2WVgidiDPQkeFVxgmrd fybsMiNlw5tV2ygslRW8c6B/s0eLZ5ymGaHCLioliOpT3MqU3Ogp7I7B9CTj0aT1ePFC PUKw== X-Gm-Message-State: AOJu0Yz6AqKm4eXw7vhp0k1QlDjp3JYYHeXQTO8ISVEt3clNJDBbbnoZ aWITYA7BxxgTu5GbcsZ5zMuJGPx6OWFxA5EnDhTQOCL1kd3Aow0NvsW9uQqO/D1UxZkGKwpBAku zUxrkMHpyA+ZmDANByPOoAWmwyWZIsly8yNPhBzQ8rc1vpmpAkkQUxdYAOjo1poXi5c0g4QorCp t89YlQM5IuYd3PVI0ikbRpKlvKk070fIvWTwyDY2FOFm0498GEPEG1 X-Received: by 2002:ac8:7f43:0:b0:43d:ec18:ade6 with SMTP id d75a77b69052e-43fb0ef8e78mr118691cf.55.1716491721241; Thu, 23 May 2024 12:15:21 -0700 (PDT) Received: from amakhalov-build-vm.eng.vmware.com ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43e4a89b61dsm21219821cf.45.2024.05.23.12.15.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 12:15:20 -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 v10 3/8] input/vmmouse: Use VMware hypercall API Date: Thu, 23 May 2024 12:14:41 -0700 Message-Id: <20240523191446.54695-4-alexey.makhalov@broadcom.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20240523191446.54695-1-alexey.makhalov@broadcom.com> References: <20240523191446.54695-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.0