From patchwork Fri Apr 23 09:51:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Kumar Gautam X-Patchwork-Id: 12220019 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=-16.8 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_BLOCKED, USER_AGENT_GIT 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 87ADBC43460 for ; Fri, 23 Apr 2021 09:54:35 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 2790B613C3 for ; Fri, 23 Apr 2021 09:54:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2790B613C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Oj0gkaBM7kuSRQ2RLKLPDt11GQJrTKo9wbHiYJrJUjA=; b=XU4PULBVIpngj+aQ5Qo/M9sXvE 8G/1EQ/5knhCG41BHhtPVJG7ISGb7lzhJGiZx2SlMGRprWgxtEcAXCp72CvY6Qx/rw74fKpOTacs3 jrqfjyCPVd9juv8c7EEgGGamATjADXldW5Cld4RX++opUugLscgtnl16sBcINcGD4oIjVFZ0ehIGm D5ifV07vqEzI+cNXuIXevaIkxXYYsrY8yZFuzJUChvMRLiQQUEv84/pMfeDEByHCBhnneopPvJp/e nkD2bsSVHIJ7yLp2j+FqPCJdY3Wk09+XB+H+OWad4A/cKZycecaiih2EeVotND1fK4GxGXWHH0//d Ft53aDSQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZsUZ-001DJq-Ii; Fri, 23 Apr 2021 09:52:55 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZsU1-001DFF-9b for linux-arm-kernel@desiato.infradead.org; Fri, 23 Apr 2021 09:52:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=rk0OSy1s/e2g/aJ95xvg/Ef78OORJoo6aLXYt+biNsA=; b=tm36g7ce/vS/IaAawAo4oTsjEM Nm9BEgPQkU9hEnfj3232K66gzWTzoeAOCKPkh4RAyGQWpsnwdSofAKiV1p+ehwYK0cmSxvpX9HeQI An5w7GTRRFdItnDC8M0lu7fze3JM4WBnnw9f0wJlUFkfp/vmOtHjoOBKBVkfCTZqdwEQ+5ni4I8hJ ZHPcjQ3HlGzV8e0MOezwmANR+opDuyUWdDuSvRbe4reiXgEERl4rTuU9sTJMhlR+7yGCpN0QYm2l5 f8IUIY0e6JUzKx3hylu6f7E97TBDi0pkXC6fJrcm8Dst268uBCZzWUO2BmLk85nHZ0r8s0edUPgC9 oLjNMx2Q==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZsTy-00EIfw-Nv for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 09:52:20 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 542591596; Fri, 23 Apr 2021 02:52:17 -0700 (PDT) Received: from usa.arm.com (a074945.blr.arm.com [10.162.16.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2C41B3F774; Fri, 23 Apr 2021 02:52:12 -0700 (PDT) From: Vivek Gautam To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org Cc: joro@8bytes.org, will.deacon@arm.com, mst@redhat.com, robin.murphy@arm.com, jean-philippe@linaro.org, eric.auger@redhat.com, kevin.tian@intel.com, jacob.jun.pan@linux.intel.com, yi.l.liu@intel.com, Lorenzo.Pieralisi@arm.com, shameerali.kolothum.thodi@huawei.com, Vivek Gautam Subject: [PATCH RFC v1 04/11] iommu/virtio: Add a io page fault queue Date: Fri, 23 Apr 2021 15:21:40 +0530 Message-Id: <20210423095147.27922-5-vivek.gautam@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210423095147.27922-1-vivek.gautam@arm.com> References: <20210423095147.27922-1-vivek.gautam@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_025218_845980_5E9FCC56 X-CRM114-Status: GOOD ( 11.11 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a io page fault queue to the driver so that it can be used to redirect faults to the handler. Signed-off-by: Vivek Gautam --- drivers/iommu/virtio-iommu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index fd237cad1ce5..3da5f0807711 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -58,6 +58,7 @@ struct viommu_dev { struct list_head endpoints; struct workqueue_struct *pri_wq; struct viommu_dev_pri_work *pri_work; + struct iopf_queue *iopf_pri; /* Device configuration */ struct iommu_domain_geometry geometry; @@ -581,6 +582,15 @@ static int viommu_add_pstf(struct viommu_endpoint *vdev, void *pstf, size_t len) return 0; } +static int viommu_init_queues(struct viommu_dev *viommu) +{ + viommu->iopf_pri = iopf_queue_alloc(dev_name(viommu->dev)); + if (!viommu->iopf_pri) + return -ENOMEM; + + return 0; +} + static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) { int ret; @@ -670,6 +680,15 @@ static int viommu_probe_endpoint(struct viommu_dev *viommu, struct device *dev) list_add(&ep->list, &viommu->endpoints); + ret = viommu_init_queues(viommu); + if (ret) + goto out_free_eps; + + kfree(probe); + return 0; + +out_free_eps: + kfree(ep); out_free: kfree(probe); return ret;