From patchwork Fri Jan 20 22:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 46662 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp465152wrn; Fri, 20 Jan 2023 14:48:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXvxNzvBfIdGj5qDc1dRlvfsT40BPKFueSTbusXVZIKbbDzvVxI9GAAUwNmAcM6n5XaJfSNW X-Received: by 2002:a05:6a20:4417:b0:b2:310a:9fd2 with SMTP id ce23-20020a056a20441700b000b2310a9fd2mr54202762pzb.43.1674254928129; Fri, 20 Jan 2023 14:48:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674254928; cv=none; d=google.com; s=arc-20160816; b=kMQ2Po+DG99BSeQ0moj4CO2z2Qc39M7L+xdNM777zwFqjvkOzAnCCiMVG7ySmhsDEO QkDeZ6GMlxwyCDI+hjOiPHMJ8JhNR4dwwblneN5CQDKdE2ugPliK0WzHA2NMPHaECPz5 5fzeOe2KKvzdhQSg8OO7Y/fVzyliSbH02VANEAFObc8PNxElQSJhn7yglBWInNZbV7Dx 2/Gm+BMspHIeErzNnIazrvzzBsmz6NvnqRg7Lr/NGf38b1E3xVh5IqA5hEtKa4htYuCL XU5TUH51zvVfR0vYjJBzzKuC6qW8dzhtwGSDWdC+9lgJ7MzvtYbDrsBOKzwdOx1VzGhx c7JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kyuLsPAltQCv9R8fMJCTXGUe/Z7HvJ7ZAS2S9ubamac=; b=cNM3FozVSyTP07ZaUJH1dG2mhQnclgwHTo9rbbspRksHYukRpnVTshIChhPAaCcx9/ ZMABPhACHAAX7KWa/9rTZa9g69EnknDom+ClPGFYYPRWVqkF4rLAk4SDJcOZXzJHZH2P xfod+inoj2gys8nhnKiehnK3Dn4UKbxaKZjIzS5h73un2fTke0ejCwWNAPasM1s74QH5 JeKdm/mK9N5JlZ0oKU84ZOKznpfV/f52J3yQizj+cqJosuzy9g9w/vrky3EDmxxaq6oQ V05rScyUwpEei6vL5HAxUgk3bWA4wBAp+gxGFY5hzKTxOstbXCApvVnqRNhxA0WJnpQD hkGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=VbYEZEP5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s190-20020a632cc7000000b004c782ce6f7esi20847806pgs.157.2023.01.20.14.48.35; Fri, 20 Jan 2023 14:48:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=VbYEZEP5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229950AbjATWsI (ORCPT + 99 others); Fri, 20 Jan 2023 17:48:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjATWsA (ORCPT ); Fri, 20 Jan 2023 17:48:00 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF56013525; Fri, 20 Jan 2023 14:47:47 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30KM03cg024187; Fri, 20 Jan 2023 22:47:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=kyuLsPAltQCv9R8fMJCTXGUe/Z7HvJ7ZAS2S9ubamac=; b=VbYEZEP5SGIKWcsXW7QlWAHR9E3qTX47HYJOAg42uaQiuj6GVwc6lh3W55eDVmeND9FE 8Hn9V7Uc4oRxDoEWau3BTiijD5+S94SheoYP1XcOZtl4XV89aL7+GbYZ5fXkGVJlEkcU nLE69+G5rzlC8LrmSnqfVNeAGeEZCveki2xoMBndoQ1xFg/PTTvJ2xkmHbVmcrLfkf06 OGS0chNgEB2N2afaBH91IgfaxCBrgaGaScl+VfmqVoOAvUIwolQjPfUdmwxH0TSgsq2b GD3DZudKUqRRbwKoWXxX9n954iBE7cqlFc7BgoPtlaMnTB8wSdJrURZRS3XPMNX+s+RW hg== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n7c28jrek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 22:47:34 +0000 Received: from nasanex01b.na.qualcomm.com (nasanex01b.na.qualcomm.com [10.46.141.250]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30KMlX9T017493 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Jan 2023 22:47:33 GMT Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 20 Jan 2023 14:47:32 -0800 From: Elliot Berman To: Bjorn Andersson , Alex Elder , Elliot Berman , Murali Nalajala CC: Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Prakruthi Deepak Heragu , Dmitry Baryshkov , Arnd Bergmann , "Greg Kroah-Hartman" , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Bagas Sanjaya , Catalin Marinas , Will Deacon , Marc Zyngier , Jassi Brar , Sudeep Holla , , , , , Subject: [PATCH v9 03/27] gunyah: Common types and error codes for Gunyah hypercalls Date: Fri, 20 Jan 2023 14:46:02 -0800 Message-ID: <20230120224627.4053418-4-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120224627.4053418-1-quic_eberman@quicinc.com> References: <20230120224627.4053418-1-quic_eberman@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01b.na.qualcomm.com (10.46.141.250) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: mHdx1hBxo0GmSzimkzOTJNpb6eCL3Tqh X-Proofpoint-ORIG-GUID: mHdx1hBxo0GmSzimkzOTJNpb6eCL3Tqh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-20_11,2023-01-20_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 mlxlogscore=810 clxscore=1015 mlxscore=0 suspectscore=0 malwarescore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301200218 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755583535387301710?= X-GMAIL-MSGID: =?utf-8?q?1755583535387301710?= Add architecture-independent standard error codes, types, and macros for Gunyah hypercalls. Reviewed-by: Dmitry Baryshkov Signed-off-by: Elliot Berman --- MAINTAINERS | 1 + include/linux/gunyah.h | 74 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 include/linux/gunyah.h diff --git a/MAINTAINERS b/MAINTAINERS index d9205cb9e988..f1e07e39b2f5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9048,6 +9048,7 @@ L: linux-arm-msm@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/firmware/gunyah-hypervisor.yaml F: Documentation/virt/gunyah/ +F: include/linux/gunyah.h HABANALABS PCI DRIVER M: Oded Gabbay diff --git a/include/linux/gunyah.h b/include/linux/gunyah.h new file mode 100644 index 000000000000..985c6086348e --- /dev/null +++ b/include/linux/gunyah.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef _LINUX_GUNYAH_H +#define _LINUX_GUNYAH_H + +#include +#include + +/* Common Gunyah macros */ +#define GH_CAPID_INVAL U64_MAX +#define GH_VMID_ROOT_VM 0xff + +#define GH_ERROR_OK 0 + +#define GH_ERROR_UNIMPLEMENTED -1 +#define GH_ERROR_RETRY -2 + +#define GH_ERROR_ARG_INVAL 1 +#define GH_ERROR_ARG_SIZE 2 +#define GH_ERROR_ARG_ALIGN 3 + +#define GH_ERROR_NOMEM 10 + +#define GH_ERROR_ADDR_OVFL 20 +#define GH_ERROR_ADDR_UNFL 21 +#define GH_ERROR_ADDR_INVAL 22 + +#define GH_ERROR_DENIED 30 +#define GH_ERROR_BUSY 31 +#define GH_ERROR_IDLE 32 + +#define GH_ERROR_IRQ_BOUND 40 +#define GH_ERROR_IRQ_UNBOUND 41 + +#define GH_ERROR_CSPACE_CAP_NULL 50 +#define GH_ERROR_CSPACE_CAP_REVOKED 51 +#define GH_ERROR_CSPACE_WRONG_OBJ_TYPE 52 +#define GH_ERROR_CSPACE_INSUF_RIGHTS 53 +#define GH_ERROR_CSPACE_FULL 54 + +#define GH_ERROR_MSGQUEUE_EMPTY 60 +#define GH_ERROR_MSGQUEUE_FULL 61 + +static inline int gh_remap_error(int gh_error) +{ + switch (gh_error) { + case GH_ERROR_OK: + return 0; + case GH_ERROR_NOMEM: + return -ENOMEM; + case GH_ERROR_DENIED: + case GH_ERROR_CSPACE_CAP_NULL: + case GH_ERROR_CSPACE_CAP_REVOKED: + case GH_ERROR_CSPACE_WRONG_OBJ_TYPE: + case GH_ERROR_CSPACE_INSUF_RIGHTS: + case GH_ERROR_CSPACE_FULL: + return -EACCES; + case GH_ERROR_BUSY: + case GH_ERROR_IDLE: + return -EBUSY; + case GH_ERROR_IRQ_BOUND: + case GH_ERROR_IRQ_UNBOUND: + case GH_ERROR_MSGQUEUE_FULL: + case GH_ERROR_MSGQUEUE_EMPTY: + return -EPERM; + default: + return -EINVAL; + } +} + +#endif