From nobody Sat Nov 30 03:34:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1618336765; cv=none; d=zohomail.com; s=zohoarc; b=EFdHKLUGM+jWaqQUm/YBNiiwlMAkuu5QwZBOc6IC/5/SvL6MAsSGBDarC6l7S+14zg8vvrJVV8WB/OVU44l1d7g4jud8R41xuPDMPfJwbdAU27SnSwkxFTO43zge+iKIjj4yOwQO+mlvoZmzSydz6JycHWl8LfoHyVaEGGlQ4lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618336765; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=W6RF/TxP+0gi12cR4o8s72njJCvINBhVWHA8O7f8NEI=; b=mtofqQs61ltg7MDyXpAeTDBt3VZR6OuesthtuJcidiHJkwmRr9zyz7Q5FCsrVPsZbJltaw2ANEOZOpuRc04MgE2FOg58Eb0VCTDrnkIEvZrelXWxsr326jU57BkfCZ44JmclkEkwpxyaSIg2jObPb+AxgYpS5Ecj/xMKbqfi1BQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1618336765670610.3519635175336; Tue, 13 Apr 2021 10:59:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.110068.210114 (Exim 4.92) (envelope-from ) id 1lWNJi-0005ts-Nw; Tue, 13 Apr 2021 17:59:14 +0000 Received: by outflank-mailman (output) from mailman id 110068.210114; Tue, 13 Apr 2021 17:59:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWNJi-0005tj-KK; Tue, 13 Apr 2021 17:59:14 +0000 Received: by outflank-mailman (input) for mailman id 110068; Tue, 13 Apr 2021 17:59:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lWNJh-0005mq-Kv for xen-devel@lists.xenproject.org; Tue, 13 Apr 2021 17:59:13 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 83ad58cc-c534-4bec-b2f5-aac17a5f7db3; Tue, 13 Apr 2021 17:59:08 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D5B4613BA; Tue, 13 Apr 2021 17:59:07 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 83ad58cc-c534-4bec-b2f5-aac17a5f7db3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618336748; bh=GPoJSocdsrvEwhHDE5FqQZWJ8Wf0LhPUhy+KObvq+MY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SJgdR9eqXI6OtzFJpsZ53jbb+ISgss34Mn6/Ysx84STntpdSsmX9C85F26xogi3N4 Z2Aq8HrqBntx+Z0OcTThf748vrJULUrplXvC2F5DYHGUDd0Dn8x3jLMHyJx6+tT3jR uy7VRuIJKyhM/FkVTIKfyxhOKIqWY6HjJseadtEQ9mVq3mSdhul+2CutYYIA6vTG4h IaTa6OfS10iYA+FmZvdJynd/9+aBdlXVg7YHQq0IeVr7zJ0zZaY1rs8uQbI99r7Aza 4JbTYvqD3WHB3Lq68bbRWqhFQR+eFPLu/PBOLlYpaJyvsMXCOB4n+ftGCj3f6wajQL 4xy2OWOQI/cTQ== From: Stefano Stabellini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, julien@xen.org, Bertrand.Marquis@arm.com, Volodymyr_Babchuk@epam.com, rahul.singh@arm.com, brian.woods@xilinx.com, Stefano Stabellini Subject: [PATCH RESEND v3 2/3] arm,smmu: restructure code in preparation to new bindings support Date: Tue, 13 Apr 2021 10:59:04 -0700 Message-Id: <20210413175905.15123-2-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ZohoMail-DKIM: pass (identity @kernel.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Brian Woods Restructure some of the code and add supporting functions for adding generic device tree (DT) binding support. This will allow for using current Linux device trees with just modifying the chosen field to enable Xen. Signed-off-by: Brian Woods Signed-off-by: Stefano Stabellini Reviewed-by: Rahul Singh Acked-by: Julien Grall --- xen/drivers/passthrough/arm/smmu.c | 62 +++++++++++++++++------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/a= rm/smmu.c index ac75e23268..f949c110ad 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -810,52 +810,36 @@ static int insert_smmu_master(struct arm_smmu_device = *smmu, return 0; } =20 -static int register_smmu_master(struct arm_smmu_device *smmu, - struct device *dev, - struct of_phandle_args *masterspec) +static int arm_smmu_dt_add_device_legacy(struct arm_smmu_device *smmu, + struct device *dev, + struct iommu_fwspec *fwspec) { - int i, ret =3D 0; + int i; struct arm_smmu_master *master; - struct iommu_fwspec *fwspec; + struct device_node *dev_node =3D dev_get_dev_node(dev); =20 - master =3D find_smmu_master(smmu, masterspec->np); + master =3D find_smmu_master(smmu, dev_node); if (master) { dev_err(dev, "rejecting multiple registrations for master device %s\n", - masterspec->np->name); + dev_node->name); return -EBUSY; } =20 master =3D devm_kzalloc(dev, sizeof(*master), GFP_KERNEL); if (!master) return -ENOMEM; - master->of_node =3D masterspec->np; - - ret =3D iommu_fwspec_init(&master->of_node->dev, smmu->dev); - if (ret) { - kfree(master); - return ret; - } - fwspec =3D dev_iommu_fwspec_get(dev); - - /* adding the ids here */ - ret =3D iommu_fwspec_add_ids(&masterspec->np->dev, - masterspec->args, - masterspec->args_count); - if (ret) - return ret; + master->of_node =3D dev_node; =20 /* Xen: Let Xen know that the device is protected by an SMMU */ - dt_device_set_protected(masterspec->np); + dt_device_set_protected(dev_node); =20 for (i =3D 0; i < fwspec->num_ids; ++i) { - u16 streamid =3D masterspec->args[i]; - if (!(smmu->features & ARM_SMMU_FEAT_STREAM_MATCH) && - (streamid >=3D smmu->num_mapping_groups)) { + (fwspec->ids[i] >=3D smmu->num_mapping_groups)) { dev_err(dev, "stream ID for master device %s greater than maximum allowed (%d)\n", - masterspec->np->name, smmu->num_mapping_groups); + dev_node->name, smmu->num_mapping_groups); return -ERANGE; } master->cfg.smendx[i] =3D INVALID_SMENDX; @@ -864,6 +848,30 @@ static int register_smmu_master(struct arm_smmu_device= *smmu, return insert_smmu_master(smmu, master); } =20 +static int register_smmu_master(struct arm_smmu_device *smmu, + struct device *dev, + struct of_phandle_args *masterspec) +{ + int ret =3D 0; + struct iommu_fwspec *fwspec; + + ret =3D iommu_fwspec_init(&masterspec->np->dev, smmu->dev); + if (ret) + return ret; + + fwspec =3D dev_iommu_fwspec_get(&masterspec->np->dev); + + ret =3D iommu_fwspec_add_ids(&masterspec->np->dev, + masterspec->args, + masterspec->args_count); + if (ret) + return ret; + + return arm_smmu_dt_add_device_legacy(smmu, + &masterspec->np->dev, + fwspec); +} + static struct arm_smmu_device *find_smmu_for_device(struct device *dev) { struct arm_smmu_device *smmu; --=20 2.17.1