From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6AD6C61DA4 for ; Mon, 6 Feb 2023 09:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version: References:Message-ID:Subject:CC:To:From:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Epw0QMrW2symjjQdDtZNVRW9oD9BQoOAZ7gAW9K4GyU=; b=kbvJ/WIVTptuV8 Imysg3vLFEHxgbSGlv9CCwzv5SV1/cSU/20PdP8kUaZcQ9eMxcpuhqyuMP/aWxUaXPfKnuVHJbuiF ObUSpaf/iolgVZT0FG6Mt9Yfn6HsLc4px2clkA9HeoaEUqemlsCBJ+KaaZkp3iVbljQg5Cta3qMWF 6ch9XROf5PsP/VY17Oif0VVu5MDPTCnCtoN4RfN+UtbjHfizit3sfGxjUYhUnqVX9x+w9YjKV3LbB 4gZdN0W5yovOEHS5CPZ2hGCSvpvXp/pEwSiwC3C4SI39SCxngDgVIF1PeHrRA5EFtMxyt+j/GJQ7I sMnTj+HyRh/jJ4160+rQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pOy91-007wdW-Nm; Mon, 06 Feb 2023 09:50:39 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pOy8y-007wcL-IJ for linux-arm-kernel@lists.infradead.org; Mon, 06 Feb 2023 09:50:38 +0000 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3166EZe1020951; Mon, 6 Feb 2023 09:50:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=date : from : to : cc : subject : message-id : reply-to : references : mime-version : content-type : in-reply-to; s=qcppdkim1; bh=GaXGShalBdR+4E7bscfprSnkG+lkWmy3o6V2yYDA6PY=; b=Zrk6nqBDqN5oq2nTszs4+V0FJSulZ+KVuX6pz+WHaCAu2hS+WiCgRKtRe1FfJ/afN2ef 7iNmjva7YYUPy7Yp75h+uk4wLm8j3olStVZ4ydKepJtaMaOE6FDfEUsLSf+ZDnvykQKg L2LeNIfritgZNnPXFGegvRIh7BK55I04r89JbfSv7fgn0G6GgExSpjj0hJsAfH0wCjFl Kp0hUjkeNRTd8HUbAQh0AhGW6NGM7C0uo0KcDplvHB8+NZeQBsz2nHYrsXdbW0f+SGWW IKkuQBzQ1wNu3uYnTssPjp4f+OLVPvuvOthV8BmOQkZC5wG/4EbOegzW/P6yH1bDNNHd KQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nhff2kc39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Feb 2023 09:50:22 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3169oL47010875 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 6 Feb 2023 09:50:21 GMT Received: from quicinc.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 6 Feb 2023 01:50:14 -0800 Date: Mon, 6 Feb 2023 15:20:10 +0530 From: Srivatsa Vaddagiri To: Elliot Berman CC: Bjorn Andersson , Alex Elder , Murali Nalajala , Trilok Soni , 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: Re: [PATCH v9 22/27] virt: gunyah: Add resource tickets Message-ID: <20230206095010.GF332@quicinc.com> References: <20230120224627.4053418-1-quic_eberman@quicinc.com> <20230120224627.4053418-23-quic_eberman@quicinc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230120224627.4053418-23-quic_eberman@quicinc.com> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: C0UKRVdLXcQCDHmW3cy3GisLir22OZNU X-Proofpoint-GUID: C0UKRVdLXcQCDHmW3cy3GisLir22OZNU 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-02-06_05,2023-02-03_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 spamscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 suspectscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302060085 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230206_015036_763412_2E1155C7 X-CRM114-Status: GOOD ( 22.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Srivatsa Vaddagiri Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org * Elliot Berman [2023-01-20 14:46:21]: > +int ghvm_add_resource_ticket(struct gunyah_vm *ghvm, struct gunyah_vm_resource_ticket *ticket) > +{ > + struct gunyah_vm_resource_ticket *iter; > + struct gunyah_resource *ghrsc; > + int ret = 0; > + > + mutex_lock(&ghvm->resources_lock); > + list_for_each_entry(iter, &ghvm->resource_tickets, list) { > + if (iter->resource_type == ticket->resource_type && iter->label == ticket->label) { > + ret = -EEXIST; > + goto out; > + } > + } > + > + if (!try_module_get(ticket->owner)) { > + ret = -ENODEV; > + goto out; > + } > + > + list_add(&ticket->list, &ghvm->resource_tickets); > + INIT_LIST_HEAD(&ticket->resources); > + > + list_for_each_entry(ghrsc, &ghvm->resources, list) { > + if (ghrsc->type == ticket->resource_type && ghrsc->rm_label == ticket->label) { > + if (!ticket->populate(ticket, ghrsc)) > + list_move(&ghrsc->list, &ticket->resources); Do we need the search to continue in case of a hit? 'gh_vm_add_resource' seems to break loop on first occurrence. Also do we have examples of more than one 'gunyah_resource' being associated with same 'gunyah_vm_resource_ticket'? Both vcpu and irqfd tickets seem to deal with just one resource? > static int gh_vm_start(struct gunyah_vm *ghvm) > { > struct gunyah_vm_memory_mapping *mapping; > u64 dtb_offset; > u32 mem_handle; > - int ret; > + struct gunyah_resource *ghrsc; > + struct gh_rm_hyp_resources *resources; > + int ret, i; > > down_write(&ghvm->status_lock); > if (ghvm->vm_status != GH_RM_VM_STATUS_NO_STATE) { > @@ -241,6 +314,22 @@ static int gh_vm_start(struct gunyah_vm *ghvm) > goto err; > } > > + ret = gh_rm_get_hyp_resources(ghvm->rm, ghvm->vmid, &resources); > + if (ret) { > + pr_warn("Failed to get hypervisor resources for VM: %d\n", ret); > + goto err; > + } > + > + for (i = 0; i < le32_to_cpu(resources->n_entries); i++) { minor nit: not sure if we can rely on compiler to optimize this, but it would be better if we run le32_to_cpu once and use the result in loop. > + ghrsc = gh_rm_alloc_resource(ghvm->rm, &resources->entries[i]); > + if (!ghrsc) { > + ret = -ENOMEM; > + goto err; > + } > + > + gh_vm_add_resource(ghvm, ghrsc); Shouldn't we have gh_vm_add_resource()-> ticket->populate() return a result and in case of failure we should bail out from this loop? > + } > + > ret = gh_rm_vm_start(ghvm->rm, ghvm->vmid); > if (ret) { > pr_warn("Failed to start VM: %d\n", ret); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel