Received: by 2002:a05:7208:31d3:b0:81:e143:7c29 with SMTP id v19csp420408rbd; Fri, 5 Apr 2024 08:20:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWlfLS7rhc0udjdaB3KtF2oEio1clCeTqfRaXxtV8x84ZEA5GP+yBv64z244YqEQBD9Q/RSrt7ibnMuuF6BjFBE/I2QwyGc2UUEyJS3kw== X-Google-Smtp-Source: AGHT+IFW3SvPw5qO7kOkbDjc+XrXiD/53DazU/EWnho+P/HQ4xCA6RB8jN5yTjI4kUYCFx935Std X-Received: by 2002:a17:90a:928e:b0:2a2:d9f5:a335 with SMTP id n14-20020a17090a928e00b002a2d9f5a335mr2583168pjo.21.1712330433347; Fri, 05 Apr 2024 08:20:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712330433; cv=pass; d=google.com; s=arc-20160816; b=azqvoFFgPkrbJCBNPXFo0X3h9OYwZlb9qC8XFqiC0P+FQS2EPdwO5nY1jwL9pEYNdF WFCNofJeVvMCROQ4cjc7ugBSwmX+IpMbzEtZbvNJ2j1IMH0nHGLEPwgwrGeLRnFvOIwA 2rASM+UN4puMh0rGJidraVM7O1G/TJRFJHzW8ZTWtzBGz3aYKD7B9hZju26EB/kD3MNU C/QE4sxGX++fiX6AznArFQwNc+uSYIS6fJzFyCwUimLxte8XF/LiIv5t4dHSOY/faUZ4 uvNXIK6jtq/ZvGgEclpo1vYz2w39TBB4Re72V1j4kno6fu9Fj8TSpt9HusMicqvzXTDo f/EQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ncxB/ucen8xf9GK05q5WGn6xgxfyQW7w7MNwVaEY0yE=; fh=K/XMwfp+HrQyDrgxHqshk421t+UX1kr+n8XMXAuSoOI=; b=x7SSHf/Oyd3cnFmK/VW5Ug4DmFHo7rBh7G6ahNfwsTIwviUmcfVwHV9b1noP7KQYkw 0nX7F0KURaK2St70S4YIBf+vWWGYaCy35UMW9n947IMlfmmmtrsjOObpvZN3bgLFMhJw eK3Uc0s0JCnpnpLj9hXzm2B5m8ZPsT1kzH3VoWupbE4+aHSaEATBef9d9WReHi+3pUbZ mUKoX9GYY8tIi4yptaetUHDdy2BVcWjWbmNmWOORvyx0RAuUkNMHwGDug5Cul/4gCVcb FFUDWF7WaznlQYRwQfe5kGq7lEoQkdcCghedgQc/wek7OI+PGVBFYAwvT05cjN+nZ/28 vIsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mGBrHVle; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-133228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id in9-20020a17090b438900b002a258632a7esi3670822pjb.82.2024.04.05.08.20.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 08:20:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mGBrHVle; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-133228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.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 5980AB23BE5 for ; Fri, 5 Apr 2024 15:19:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F20316F8F4; Fri, 5 Apr 2024 15:18:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mGBrHVle" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03F3A16D9B3; Fri, 5 Apr 2024 15:18:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712330336; cv=none; b=LyoGhpa9IJI9597tNwFRCJFyGgaexATbXDjwnoAnU/k0eFUl+2JNwAc9oJqGuDRYBHS+O+5ZOw8BnZht8qoHV8zC1cxfcO2J3Z4hpM24zpGFlZyAtVns9+xwjxI96or6MTgXy/nj7TPpxsyyD8H1rEc4HqoJX8QINA345XNI8as= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712330336; c=relaxed/simple; bh=UYOdpa/8pHqVym6VpaSkDbZAqFnWlJYd8BjyiDqqpn4=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Mv5qSAieo5OnC8zsL3YtKs0DqVho8XED9EQ0UIwEOEhoEeDXQxWtPot3r9CiT4/B84a51Lu69QBB6BOHfT6kUbRS8M7kTs51DQ73oImoiUrhDd5f8M8lxfeVfvSB+SXQ9VVMZq88kD2lxqdkv5ahaJZXcQ1gfK/oV4xzHra/Fag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=mGBrHVle; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 435Ahedp005076; Fri, 5 Apr 2024 15:18:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=qcppdkim1; bh=ncxB/ucen8xf9GK05q5WG n6xgxfyQW7w7MNwVaEY0yE=; b=mGBrHVleu+oRXvjsJqfkGxbHF6mYf1L1VcNGw WrsqFsAgGvblTGLGxDzR0eTUecPf47Kt9Q1oYsiYyIYnbO9+jqFeDAIMZ9RjHXXI e38H1x1ahk2N1f0jZAXzJ4egTxNj27rqqRutoec/a9gqViUYMu2VnyczjpS6MtKr E1HWbk6nWHBMWN7s+X/ZCZficNd17JEzA2+wFI+ccKh8pTVurRLwrpyuWkceHuiD R9aANR87MC0K8oCF6mmtBYf6qM6vI4RKIT7s7x5YGft5qlpkbxujVTHT+6EDczNM gKOgx5/VDUGeiA+OOA8BC+JmQ4RT1FySQEzYsL9PvBadTZnsA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xa8fc1hk0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Apr 2024 15:18:32 +0000 (GMT) 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 435FIVbG026932 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Apr 2024 15:18:31 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.1544.4; Fri, 5 Apr 2024 08:18:30 -0700 Date: Fri, 5 Apr 2024 08:18:30 -0700 From: Elliot Berman To: Pavan Kondeti CC: Alex Elder , Srinivas Kandagatla , Murali Nalajal , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Philip Derrin , Prakruthi Deepak Heragu , Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Catalin Marinas , Will Deacon , Konrad Dybcio , Bjorn Andersson , Dmitry Baryshkov , "Fuad Tabba" , Sean Christopherson , "Andrew Morton" , , , , , , Subject: Re: [PATCH v17 11/35] virt: gunyah: Translate gh_rm_hyp_resource into gunyah_resource Message-ID: <20240405081735319-0700.eberman@hu-eberman-lv.qualcomm.com> References: <20240222-gunyah-v17-0-1e9da6763d38@quicinc.com> <20240222-gunyah-v17-11-1e9da6763d38@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) 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: CjpQNiJgepbUe_PWBObBh6vdhvVm1JNM X-Proofpoint-ORIG-GUID: CjpQNiJgepbUe_PWBObBh6vdhvVm1JNM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-05_16,2024-04-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 mlxlogscore=901 bulkscore=0 suspectscore=0 clxscore=1011 priorityscore=1501 adultscore=0 phishscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404050110 On Fri, Apr 05, 2024 at 08:40:40AM +0530, Pavan Kondeti wrote: > On Thu, Feb 22, 2024 at 03:16:34PM -0800, Elliot Berman wrote: > > When booting a Gunyah virtual machine, the host VM may gain capabilities > > to interact with resources for the guest virtual machine. Examples of > > such resources are vCPUs or message queues. To use those resources, we > > need to translate the RM response into a gunyah_resource structure which > > are useful to Linux drivers. Presently, Linux drivers need only to know > > the type of resource, the capability ID, and an interrupt. > > > > On ARM64 systems, the interrupt reported by Gunyah is the GIC interrupt > > ID number and always a SPI or extended SPI. > > > > Signed-off-by: Elliot Berman > > --- > > arch/arm64/include/asm/gunyah.h | 36 ++++++++++++++++++++++ > > drivers/virt/gunyah/rsc_mgr.c | 67 +++++++++++++++++++++++++++++++++++++++++ > > drivers/virt/gunyah/rsc_mgr.h | 5 +++ > > include/linux/gunyah.h | 2 ++ > > 4 files changed, 110 insertions(+) > > > > diff --git a/arch/arm64/include/asm/gunyah.h b/arch/arm64/include/asm/gunyah.h > > new file mode 100644 > > index 0000000000000..0cd3debe22b64 > > --- /dev/null > > +++ b/arch/arm64/include/asm/gunyah.h > > @@ -0,0 +1,36 @@ > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > +/* > > + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. > > + */ > > +#ifndef _ASM_GUNYAH_H > > +#define _ASM_GUNYAH_H > > + > > +#include > > +#include > > + > > +static inline int arch_gunyah_fill_irq_fwspec_params(u32 virq, > > + struct irq_fwspec *fwspec) > > +{ > > + /* Assume that Gunyah gave us an SPI or ESPI; defensively check it */ > > + if (WARN(virq < 32, "Unexpected virq: %d\n", virq)) { > > + return -EINVAL; > > + } else if (virq <= 1019) { > > + fwspec->param_count = 3; > > + fwspec->param[0] = 0; /* GIC_SPI */ > > + fwspec->param[1] = virq - 32; /* virq 32 -> SPI 0 */ > > + fwspec->param[2] = IRQ_TYPE_EDGE_RISING; > > + } else if (WARN(virq < 4096, "Unexpected virq: %d\n", virq)) { > > + return -EINVAL; > > + } else if (virq < 5120) { > > + fwspec->param_count = 3; > > + fwspec->param[0] = 2; /* GIC_ESPI */ > > + fwspec->param[1] = virq - 4096; /* virq 4096 -> ESPI 0 */ > > + fwspec->param[2] = IRQ_TYPE_EDGE_RISING; > > + } else { > > + WARN(1, "Unexpected virq: %d\n", virq); > > + return -EINVAL; > > + } > > + return 0; > > +} > > + > > __get_intid_range() in gic-v3 driver looks more pleasing. Other than > that the logic for the translation looks good to me. Agreed, updated for v18. static inline int arch_gunyah_fill_irq_fwspec_params(u32 virq, struct irq_fwspec *fwspec) { /* Assume that Gunyah gave us an SPI or ESPI; defensively check it */ switch (virq) { case 32 ... 1019: fwspec->param_count = 3; fwspec->param[0] = 0; /* GIC_SPI */ fwspec->param[1] = virq - 32; /* virq 32 -> SPI 0 */ fwspec->param[2] = IRQ_TYPE_EDGE_RISING; break; case 4096 ... 5119: fwspec->param_count = 3; fwspec->param[0] = 2; /* GIC_ESPI */ fwspec->param[1] = virq - 4096; /* virq 4096 -> ESPI 0 */ fwspec->param[2] = IRQ_TYPE_EDGE_RISING; break; default: WARN(1, "Unexpected virq: %d\n", virq) return -EINVAL; } return 0; }