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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEAECC43331 for ; Tue, 19 Jan 2021 14:26:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1F2C207FB for ; Tue, 19 Jan 2021 14:26:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403848AbhASOTP (ORCPT ); Tue, 19 Jan 2021 09:19:15 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2377 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391131AbhASM3q (ORCPT ); Tue, 19 Jan 2021 07:29:46 -0500 Received: from fraeml737-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DKnqj5cwwz67cwg; Tue, 19 Jan 2021 20:23:13 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml737-chm.china.huawei.com (10.206.15.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 19 Jan 2021 13:28:40 +0100 Received: from localhost (10.47.77.36) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 19 Jan 2021 12:28:39 +0000 Date: Tue, 19 Jan 2021 12:27:59 +0000 From: Jonathan Cameron To: Jean-Philippe Brucker CC: , , , , , , , , , , , , , , , , , , , , "Arnd Bergmann" , Greg Kroah-Hartman , Zhou Wang Subject: Re: [PATCH v9 05/10] uacce: Enable IOMMU_DEV_FEAT_IOPF Message-ID: <20210119122759.000048f9@Huawei.com> In-Reply-To: <20210108145217.2254447-6-jean-philippe@linaro.org> References: <20210108145217.2254447-1-jean-philippe@linaro.org> <20210108145217.2254447-6-jean-philippe@linaro.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.77.36] X-ClientProxiedBy: lhreml735-chm.china.huawei.com (10.201.108.86) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Fri, 8 Jan 2021 15:52:13 +0100 Jean-Philippe Brucker wrote: > The IOPF (I/O Page Fault) feature is now enabled independently from the > SVA feature, because some IOPF implementations are device-specific and > do not require IOMMU support for PCIe PRI or Arm SMMU stall. > > Enable IOPF unconditionally when enabling SVA for now. In the future, if > a device driver implementing a uacce interface doesn't need IOPF > support, it will need to tell the uacce module, for example with a new > flag. > > Signed-off-by: Jean-Philippe Brucker Hi Jean-Philippe, A minor suggestion inline but I'm not that bothered so either way looks good to me. > --- > Cc: Arnd Bergmann > Cc: Greg Kroah-Hartman > Cc: Zhangfei Gao > Cc: Zhou Wang > --- > drivers/misc/uacce/uacce.c | 32 +++++++++++++++++++++++++------- > 1 file changed, 25 insertions(+), 7 deletions(-) > > diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c > index d07af4edfcac..41ef1eb62a14 100644 > --- a/drivers/misc/uacce/uacce.c > +++ b/drivers/misc/uacce/uacce.c > @@ -385,6 +385,24 @@ static void uacce_release(struct device *dev) > kfree(uacce); > } > > +static unsigned int uacce_enable_sva(struct device *parent, unsigned int flags) > +{ > + if (!(flags & UACCE_DEV_SVA)) > + return flags; > + > + flags &= ~UACCE_DEV_SVA; > + > + if (iommu_dev_enable_feature(parent, IOMMU_DEV_FEAT_IOPF)) > + return flags; > + > + if (iommu_dev_enable_feature(parent, IOMMU_DEV_FEAT_SVA)) { > + iommu_dev_disable_feature(parent, IOMMU_DEV_FEAT_IOPF); > + return flags; > + } > + > + return flags | UACCE_DEV_SVA; > +} I'm a great fan of paired enable / disable functions. Whilst it would be trivial, maybe it is worth introducing uacce_disable_sva()? Also make that do the flags check internally to make it match up with the enable path. > + > /** > * uacce_alloc() - alloc an accelerator > * @parent: pointer of uacce parent device > @@ -404,11 +422,7 @@ struct uacce_device *uacce_alloc(struct device *parent, > if (!uacce) > return ERR_PTR(-ENOMEM); > > - if (flags & UACCE_DEV_SVA) { > - ret = iommu_dev_enable_feature(parent, IOMMU_DEV_FEAT_SVA); > - if (ret) > - flags &= ~UACCE_DEV_SVA; > - } > + flags = uacce_enable_sva(parent, flags); > > uacce->parent = parent; > uacce->flags = flags; > @@ -432,8 +446,10 @@ struct uacce_device *uacce_alloc(struct device *parent, > return uacce; > > err_with_uacce: > - if (flags & UACCE_DEV_SVA) > + if (flags & UACCE_DEV_SVA) { > iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_SVA); > + iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_IOPF); > + } > kfree(uacce); > return ERR_PTR(ret); > } > @@ -487,8 +503,10 @@ void uacce_remove(struct uacce_device *uacce) > mutex_unlock(&uacce->queues_lock); > > /* disable sva now since no opened queues */ > - if (uacce->flags & UACCE_DEV_SVA) > + if (uacce->flags & UACCE_DEV_SVA) { > iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_SVA); > + iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_IOPF); > + } > > if (uacce->cdev) > cdev_device_del(uacce->cdev, &uacce->dev); 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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BC13C433E0 for ; Tue, 19 Jan 2021 12:28:53 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D35A522D2A for ; Tue, 19 Jan 2021 12:28:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D35A522D2A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=Huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 747FB8657C; Tue, 19 Jan 2021 12:28:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VtjX97XAoSdR; Tue, 19 Jan 2021 12:28:51 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 571C286416; Tue, 19 Jan 2021 12:28:51 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 37E1AC08A1; Tue, 19 Jan 2021 12:28:51 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4D927C013A for ; Tue, 19 Jan 2021 12:28:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 395DD2046C for ; Tue, 19 Jan 2021 12:28:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i9fbkUOFF73M for ; Tue, 19 Jan 2021 12:28:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by silver.osuosl.org (Postfix) with ESMTPS id 2EE2C20454 for ; Tue, 19 Jan 2021 12:28:44 +0000 (UTC) Received: from fraeml737-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DKnqj5cwwz67cwg; Tue, 19 Jan 2021 20:23:13 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml737-chm.china.huawei.com (10.206.15.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 19 Jan 2021 13:28:40 +0100 Received: from localhost (10.47.77.36) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 19 Jan 2021 12:28:39 +0000 Date: Tue, 19 Jan 2021 12:27:59 +0000 From: Jonathan Cameron To: Jean-Philippe Brucker Subject: Re: [PATCH v9 05/10] uacce: Enable IOMMU_DEV_FEAT_IOPF Message-ID: <20210119122759.000048f9@Huawei.com> In-Reply-To: <20210108145217.2254447-6-jean-philippe@linaro.org> References: <20210108145217.2254447-1-jean-philippe@linaro.org> <20210108145217.2254447-6-jean-philippe@linaro.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.47.77.36] X-ClientProxiedBy: lhreml735-chm.china.huawei.com (10.201.108.86) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Cc: vivek.gautam@arm.com, guohanjun@huawei.com, will@kernel.org, linux-acpi@vger.kernel.org, zhangfei.gao@linaro.org, lenb@kernel.org, devicetree@vger.kernel.org, Arnd Bergmann , robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , rjw@rjwysocki.net, iommu@lists.linux-foundation.org, sudeep.holla@arm.com, robin.murphy@arm.com, linux-accelerators@lists.ozlabs.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Fri, 8 Jan 2021 15:52:13 +0100 Jean-Philippe Brucker wrote: > The IOPF (I/O Page Fault) feature is now enabled independently from the > SVA feature, because some IOPF implementations are device-specific and > do not require IOMMU support for PCIe PRI or Arm SMMU stall. > > Enable IOPF unconditionally when enabling SVA for now. In the future, if > a device driver implementing a uacce interface doesn't need IOPF > support, it will need to tell the uacce module, for example with a new > flag. > > Signed-off-by: Jean-Philippe Brucker Hi Jean-Philippe, A minor suggestion inline but I'm not that bothered so either way looks good to me. > --- > Cc: Arnd Bergmann > Cc: Greg Kroah-Hartman > Cc: Zhangfei Gao > Cc: Zhou Wang > --- > drivers/misc/uacce/uacce.c | 32 +++++++++++++++++++++++++------- > 1 file changed, 25 insertions(+), 7 deletions(-) > > diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c > index d07af4edfcac..41ef1eb62a14 100644 > --- a/drivers/misc/uacce/uacce.c > +++ b/drivers/misc/uacce/uacce.c > @@ -385,6 +385,24 @@ static void uacce_release(struct device *dev) > kfree(uacce); > } > > +static unsigned int uacce_enable_sva(struct device *parent, unsigned int flags) > +{ > + if (!(flags & UACCE_DEV_SVA)) > + return flags; > + > + flags &= ~UACCE_DEV_SVA; > + > + if (iommu_dev_enable_feature(parent, IOMMU_DEV_FEAT_IOPF)) > + return flags; > + > + if (iommu_dev_enable_feature(parent, IOMMU_DEV_FEAT_SVA)) { > + iommu_dev_disable_feature(parent, IOMMU_DEV_FEAT_IOPF); > + return flags; > + } > + > + return flags | UACCE_DEV_SVA; > +} I'm a great fan of paired enable / disable functions. Whilst it would be trivial, maybe it is worth introducing uacce_disable_sva()? Also make that do the flags check internally to make it match up with the enable path. > + > /** > * uacce_alloc() - alloc an accelerator > * @parent: pointer of uacce parent device > @@ -404,11 +422,7 @@ struct uacce_device *uacce_alloc(struct device *parent, > if (!uacce) > return ERR_PTR(-ENOMEM); > > - if (flags & UACCE_DEV_SVA) { > - ret = iommu_dev_enable_feature(parent, IOMMU_DEV_FEAT_SVA); > - if (ret) > - flags &= ~UACCE_DEV_SVA; > - } > + flags = uacce_enable_sva(parent, flags); > > uacce->parent = parent; > uacce->flags = flags; > @@ -432,8 +446,10 @@ struct uacce_device *uacce_alloc(struct device *parent, > return uacce; > > err_with_uacce: > - if (flags & UACCE_DEV_SVA) > + if (flags & UACCE_DEV_SVA) { > iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_SVA); > + iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_IOPF); > + } > kfree(uacce); > return ERR_PTR(ret); > } > @@ -487,8 +503,10 @@ void uacce_remove(struct uacce_device *uacce) > mutex_unlock(&uacce->queues_lock); > > /* disable sva now since no opened queues */ > - if (uacce->flags & UACCE_DEV_SVA) > + if (uacce->flags & UACCE_DEV_SVA) { > iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_SVA); > + iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_IOPF); > + } > > if (uacce->cdev) > cdev_device_del(uacce->cdev, &uacce->dev); _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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 X-Spam-Level: X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED, USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE23CC433E0 for ; Tue, 19 Jan 2021 12:30:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7BBFC22D2A for ; Tue, 19 Jan 2021 12:30:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7BBFC22D2A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=Huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FHDGl147hu8KZCHWkjyNQTw1UgczcTiI4WducpxtCOA=; b=2hJ3JBJtnHwpWs4U5sff8IeYQ Wmt1ZE9gCNGlTVuTtf+cxLESEpMyMXAIHRLoNJGih/Fbcn9c32QrhzFhCONIIZc7MZ6JX6aNgp/eX UEuvseyKNOHt1soAyv212juIdsPPRQ5ReRac0qK4YYUwJakbgu0xBkk3Mv8s6vlNNMgmPr+SR1D7y rGijui3zf6WS1XccOWkHShLhA5U7HUvttAEhu81Uv8Z0GRiHbweXHA++XSd6ycCnLWrNcuvxrq1yH kg9FRvi8eTeex84pE6Vnjph3ww3V831u5Atwb7+UBYP87H+EcTFReoB7cjrxoJerFZLLxig4wyX9v ccQ/PG8ew==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l1q7p-0001mf-Dd; Tue, 19 Jan 2021 12:28:45 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l1q7n-0001lt-72 for linux-arm-kernel@lists.infradead.org; Tue, 19 Jan 2021 12:28:44 +0000 Received: from fraeml737-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DKnqj5cwwz67cwg; Tue, 19 Jan 2021 20:23:13 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml737-chm.china.huawei.com (10.206.15.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 19 Jan 2021 13:28:40 +0100 Received: from localhost (10.47.77.36) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 19 Jan 2021 12:28:39 +0000 Date: Tue, 19 Jan 2021 12:27:59 +0000 From: Jonathan Cameron To: Jean-Philippe Brucker Subject: Re: [PATCH v9 05/10] uacce: Enable IOMMU_DEV_FEAT_IOPF Message-ID: <20210119122759.000048f9@Huawei.com> In-Reply-To: <20210108145217.2254447-6-jean-philippe@linaro.org> References: <20210108145217.2254447-1-jean-philippe@linaro.org> <20210108145217.2254447-6-jean-philippe@linaro.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.47.77.36] X-ClientProxiedBy: lhreml735-chm.china.huawei.com (10.201.108.86) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210119_072843_468795_41F52F7A X-CRM114-Status: GOOD ( 21.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: vivek.gautam@arm.com, guohanjun@huawei.com, will@kernel.org, lorenzo.pieralisi@arm.com, joro@8bytes.org, Zhou Wang , linux-acpi@vger.kernel.org, zhangfei.gao@linaro.org, lenb@kernel.org, devicetree@vger.kernel.org, Arnd Bergmann , eric.auger@redhat.com, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , rjw@rjwysocki.net, shameerali.kolothum.thodi@huawei.com, iommu@lists.linux-foundation.org, sudeep.holla@arm.com, robin.murphy@arm.com, linux-accelerators@lists.ozlabs.org, baolu.lu@linux.intel.com 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 On Fri, 8 Jan 2021 15:52:13 +0100 Jean-Philippe Brucker wrote: > The IOPF (I/O Page Fault) feature is now enabled independently from the > SVA feature, because some IOPF implementations are device-specific and > do not require IOMMU support for PCIe PRI or Arm SMMU stall. > > Enable IOPF unconditionally when enabling SVA for now. In the future, if > a device driver implementing a uacce interface doesn't need IOPF > support, it will need to tell the uacce module, for example with a new > flag. > > Signed-off-by: Jean-Philippe Brucker Hi Jean-Philippe, A minor suggestion inline but I'm not that bothered so either way looks good to me. > --- > Cc: Arnd Bergmann > Cc: Greg Kroah-Hartman > Cc: Zhangfei Gao > Cc: Zhou Wang > --- > drivers/misc/uacce/uacce.c | 32 +++++++++++++++++++++++++------- > 1 file changed, 25 insertions(+), 7 deletions(-) > > diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c > index d07af4edfcac..41ef1eb62a14 100644 > --- a/drivers/misc/uacce/uacce.c > +++ b/drivers/misc/uacce/uacce.c > @@ -385,6 +385,24 @@ static void uacce_release(struct device *dev) > kfree(uacce); > } > > +static unsigned int uacce_enable_sva(struct device *parent, unsigned int flags) > +{ > + if (!(flags & UACCE_DEV_SVA)) > + return flags; > + > + flags &= ~UACCE_DEV_SVA; > + > + if (iommu_dev_enable_feature(parent, IOMMU_DEV_FEAT_IOPF)) > + return flags; > + > + if (iommu_dev_enable_feature(parent, IOMMU_DEV_FEAT_SVA)) { > + iommu_dev_disable_feature(parent, IOMMU_DEV_FEAT_IOPF); > + return flags; > + } > + > + return flags | UACCE_DEV_SVA; > +} I'm a great fan of paired enable / disable functions. Whilst it would be trivial, maybe it is worth introducing uacce_disable_sva()? Also make that do the flags check internally to make it match up with the enable path. > + > /** > * uacce_alloc() - alloc an accelerator > * @parent: pointer of uacce parent device > @@ -404,11 +422,7 @@ struct uacce_device *uacce_alloc(struct device *parent, > if (!uacce) > return ERR_PTR(-ENOMEM); > > - if (flags & UACCE_DEV_SVA) { > - ret = iommu_dev_enable_feature(parent, IOMMU_DEV_FEAT_SVA); > - if (ret) > - flags &= ~UACCE_DEV_SVA; > - } > + flags = uacce_enable_sva(parent, flags); > > uacce->parent = parent; > uacce->flags = flags; > @@ -432,8 +446,10 @@ struct uacce_device *uacce_alloc(struct device *parent, > return uacce; > > err_with_uacce: > - if (flags & UACCE_DEV_SVA) > + if (flags & UACCE_DEV_SVA) { > iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_SVA); > + iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_IOPF); > + } > kfree(uacce); > return ERR_PTR(ret); > } > @@ -487,8 +503,10 @@ void uacce_remove(struct uacce_device *uacce) > mutex_unlock(&uacce->queues_lock); > > /* disable sva now since no opened queues */ > - if (uacce->flags & UACCE_DEV_SVA) > + if (uacce->flags & UACCE_DEV_SVA) { > iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_SVA); > + iommu_dev_disable_feature(uacce->parent, IOMMU_DEV_FEAT_IOPF); > + } > > if (uacce->cdev) > cdev_device_del(uacce->cdev, &uacce->dev); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel