From nobody Fri Nov 29 22:43:01 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=1626997027; cv=none; d=zohomail.com; s=zohoarc; b=MLM6dKBItcVlmPGrf8nISKgLNRZ/eUfQOK7nN6PW3Eqz5nvw8IJNbQdRIMf4ivsRCAFli+/Cl64QzDXQCBgNbV72LZ01sQh4H77AE3+1pVqwu3iluO71N7nyDuRQ3sHwm952Sk4v96XmI41YyIE4d8no25RwoJ74CgC+VPcDgNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626997027; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=E7MaqfElVxr31TuPt12UpYFhxweyJuek32ryUq16V6Y=; b=Zha9CCXB0lunWyNIbmR8TYDMHjD2GB+RPrJIdHjkfUDj+okkgaEFiAyqhZxQnkvHFrx6L1L9tcmILMEyoIAaEmm/l+djp3l0Pb0n3NL4le+t0QielX3yBHw/7di00lUgPlY9dv/o/0KUfzgaNYaJOv+w2N/6fRl1HcBPnCNxr0o= 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) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1626997027869187.90754904061248; Thu, 22 Jul 2021 16:37:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.159904.294092 (Exim 4.92) (envelope-from ) id 1m6iFJ-00029R-C5; Thu, 22 Jul 2021 23:36:53 +0000 Received: by outflank-mailman (output) from mailman id 159904.294092; Thu, 22 Jul 2021 23:36:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m6iFJ-00029I-8S; Thu, 22 Jul 2021 23:36:53 +0000 Received: by outflank-mailman (input) for mailman id 159904; Thu, 22 Jul 2021 23:36:51 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m6iFH-0001Fn-Cg for xen-devel@lists.xenproject.org; Thu, 22 Jul 2021 23:36:51 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ad21ea5a-eb45-11eb-915d-12813bfff9fa; Thu, 22 Jul 2021 23:36:45 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id E7F2960EB9; Thu, 22 Jul 2021 23:36:44 +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: ad21ea5a-eb45-11eb-915d-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626997005; bh=6TReV4Pdjfx3WD5lh4CLVkGlPCvVlrwBPMhSYNdvOVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lYd1xnzV0XCaves7HoNXnS/51OFkEUGhQNQpW03IZ1wp4dWpCpTvl4zRdCH2Fb3V7 0jt4o/EI0KhbBIFX7YYfX6xqF5bknn60kmzBTduspXEGonyUXr94Jrf+YbU+yqADOM ZsMY/JaseJrRHDGMQkeTKjzi5D5bb4RuiZvBwnYUkYNTIanEfttj1dSuU9ZKyi3hAQ oJ4OJJWcKBXarAMawwoKUcquuBXb3D95gYeksrP4NS+O4DCLmf6nbkZ0Vr0kQeubcn gP+1qxnXoToT621XZbVzdQ4VOl9aHXlwu+kUU5oOctTXJk2sMXlC9nALkOFLE8VwiD l5R/NsAHX1ozA== 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 v5 3/4] arm,smmu: restructure code in preparation to new bindings support Date: Thu, 22 Jul 2021 16:36:41 -0700 Message-Id: <20210722233642.22515-3-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1626997028799100005 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, 34 insertions(+), 28 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/a= rm/smmu.c index 09773702c3..4aa3ecec57 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -812,53 +812,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; - } - - /* adding the ids here */ - ret =3D iommu_fwspec_add_ids(&masterspec->np->dev, - masterspec->args, - masterspec->args_count); - if (ret) - return ret; - - fwspec =3D dev_iommu_fwspec_get(dev); + 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; @@ -866,6 +849,29 @@ 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; + + ret =3D iommu_fwspec_add_ids(&masterspec->np->dev, + masterspec->args, + masterspec->args_count); + if (ret) + return ret; + + fwspec =3D dev_iommu_fwspec_get(&masterspec->np->dev); + 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