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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 A0ED2C83F21 for ; Tue, 15 Jul 2025 09:15:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ubbkf-0005NV-CY; Tue, 15 Jul 2025 05:15:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubbkd-0005Me-7v; Tue, 15 Jul 2025 05:15:03 -0400 Received: from [185.176.79.56] (helo=frasgout.his.huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubbkX-0007JG-G7; Tue, 15 Jul 2025 05:15:02 -0400 Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bhD510sQPz6DKwX; Tue, 15 Jul 2025 17:13:41 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 52386140137; Tue, 15 Jul 2025 17:14:48 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 15 Jul 2025 11:14:47 +0200 Date: Tue, 15 Jul 2025 10:14:45 +0100 To: Shameer Kolothum , CC: , , , , , , , , , , , , , , , , Subject: Re: [RFC PATCH v3 01/15] backends/iommufd: Introduce iommufd_backend_alloc_viommu Message-ID: <20250715101445.00005fa5@huawei.com> In-Reply-To: <20250714155941.22176-2-shameerali.kolothum.thodi@huawei.com> References: <20250714155941.22176-1-shameerali.kolothum.thodi@huawei.com> <20250714155941.22176-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To frapeml500008.china.huawei.com (7.182.85.71) X-Host-Lookup-Failed: Reverse DNS lookup failed for 185.176.79.56 (deferred) Received-SPF: pass client-ip=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonathan Cameron From: Jonathan Cameron via Errors-To: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org On Mon, 14 Jul 2025 16:59:27 +0100 Shameer Kolothum wrote: > From: Nicolin Chen > > Add a helper to allocate a viommu object. > > Signed-off-by: Nicolin Chen > Reviewed-by: Eric Auger > Signed-off-by: Shameer Kolothum One trivial comment inline. Feel free to ignore. > --- > backends/iommufd.c | 25 +++++++++++++++++++++++++ > backends/trace-events | 1 + > include/system/iommufd.h | 4 ++++ > 3 files changed, 30 insertions(+) > > diff --git a/backends/iommufd.c b/backends/iommufd.c > index 2a33c7ab0b..f3b95ee321 100644 > --- a/backends/iommufd.c > +++ b/backends/iommufd.c > @@ -446,6 +446,31 @@ bool iommufd_backend_invalidate_cache(IOMMUFDBackend *be, uint32_t id, > return !ret; > } > > +bool iommufd_backend_alloc_viommu(IOMMUFDBackend *be, uint32_t dev_id, > + uint32_t viommu_type, uint32_t hwpt_id, > + uint32_t *out_viommu_id, Error **errp) > +{ > + int ret, fd = be->fd; Not sure the fd local variable is worth bothering with given be->fd is very short and you only have a couple of users. > + struct iommu_viommu_alloc alloc_viommu = { > + .size = sizeof(alloc_viommu), > + .type = viommu_type, > + .dev_id = dev_id, > + .hwpt_id = hwpt_id, > + }; > + > + ret = ioctl(fd, IOMMU_VIOMMU_ALLOC, &alloc_viommu); > + > + trace_iommufd_backend_alloc_viommu(fd, viommu_type, dev_id, hwpt_id, > + alloc_viommu.out_viommu_id, ret); > + if (ret) { > + error_setg_errno(errp, errno, "IOMMU_VIOMMU_ALLOC failed"); > + return false; > + } > + > + *out_viommu_id = alloc_viommu.out_viommu_id; > + return true; > +} 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 284DEC83F21 for ; Tue, 15 Jul 2025 09:15:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ubbkf-0005NS-EM; Tue, 15 Jul 2025 05:15:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubbkd-0005Me-7v; Tue, 15 Jul 2025 05:15:03 -0400 Received: from [185.176.79.56] (helo=frasgout.his.huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubbkX-0007JG-G7; Tue, 15 Jul 2025 05:15:02 -0400 Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bhD510sQPz6DKwX; Tue, 15 Jul 2025 17:13:41 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 52386140137; Tue, 15 Jul 2025 17:14:48 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 15 Jul 2025 11:14:47 +0200 Date: Tue, 15 Jul 2025 10:14:45 +0100 To: Shameer Kolothum , CC: , , , , , , , , , , , , , , , , Subject: Re: [RFC PATCH v3 01/15] backends/iommufd: Introduce iommufd_backend_alloc_viommu Message-ID: <20250715101445.00005fa5@huawei.com> In-Reply-To: <20250714155941.22176-2-shameerali.kolothum.thodi@huawei.com> References: <20250714155941.22176-1-shameerali.kolothum.thodi@huawei.com> <20250714155941.22176-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To frapeml500008.china.huawei.com (7.182.85.71) X-Host-Lookup-Failed: Reverse DNS lookup failed for 185.176.79.56 (deferred) Received-SPF: pass client-ip=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonathan Cameron From: Jonathan Cameron via Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Mon, 14 Jul 2025 16:59:27 +0100 Shameer Kolothum wrote: > From: Nicolin Chen > > Add a helper to allocate a viommu object. > > Signed-off-by: Nicolin Chen > Reviewed-by: Eric Auger > Signed-off-by: Shameer Kolothum One trivial comment inline. Feel free to ignore. > --- > backends/iommufd.c | 25 +++++++++++++++++++++++++ > backends/trace-events | 1 + > include/system/iommufd.h | 4 ++++ > 3 files changed, 30 insertions(+) > > diff --git a/backends/iommufd.c b/backends/iommufd.c > index 2a33c7ab0b..f3b95ee321 100644 > --- a/backends/iommufd.c > +++ b/backends/iommufd.c > @@ -446,6 +446,31 @@ bool iommufd_backend_invalidate_cache(IOMMUFDBackend *be, uint32_t id, > return !ret; > } > > +bool iommufd_backend_alloc_viommu(IOMMUFDBackend *be, uint32_t dev_id, > + uint32_t viommu_type, uint32_t hwpt_id, > + uint32_t *out_viommu_id, Error **errp) > +{ > + int ret, fd = be->fd; Not sure the fd local variable is worth bothering with given be->fd is very short and you only have a couple of users. > + struct iommu_viommu_alloc alloc_viommu = { > + .size = sizeof(alloc_viommu), > + .type = viommu_type, > + .dev_id = dev_id, > + .hwpt_id = hwpt_id, > + }; > + > + ret = ioctl(fd, IOMMU_VIOMMU_ALLOC, &alloc_viommu); > + > + trace_iommufd_backend_alloc_viommu(fd, viommu_type, dev_id, hwpt_id, > + alloc_viommu.out_viommu_id, ret); > + if (ret) { > + error_setg_errno(errp, errno, "IOMMU_VIOMMU_ALLOC failed"); > + return false; > + } > + > + *out_viommu_id = alloc_viommu.out_viommu_id; > + return true; > +}