From patchwork Tue May 26 13:01:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1298026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49WZ0L2nysz9sSt; Tue, 26 May 2020 23:03:46 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jdZF5-00069f-RB; Tue, 26 May 2020 13:03:39 +0000 Received: from mail-pj1-f68.google.com ([209.85.216.68]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jdZEA-0005VF-Nl for kernel-team@lists.ubuntu.com; Tue, 26 May 2020 13:02:42 +0000 Received: by mail-pj1-f68.google.com with SMTP id ci21so1401885pjb.3 for ; Tue, 26 May 2020 06:02:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zvtutW1G6jRyHAeI2LBvP72UDHxToYKrwtDczQ58LV4=; b=LZiEyAQ8Kjc4KWQzJwr4BLHFtf8JOKWjBw6lds9K3Idh2KiZpxsEf/FTIErfNguPVr js7pOwBSthix8KNt7RepwFcJNqituSW1U0eCDErq77Z87h9y3pZ5bcx6oyASs6JUrgG7 Etl8QjDVWwnbNBSp2DigQa5d1TESERPUTE+mOR6/F3l3U7LGm16dFv5Al3w2NMr6GEdu TbeFsQPBb/qAMf7yJVPnRkgqCcyUQXDnSxSuaIe3X+cXwKmVCSKKGqZX86smI0WDulA4 IJYeppJAV63IOOuVcxgOfBSM4QfGMtrhaQ2YGBSGsJNZ2pu4IS+5IRTPZr46o7wkKWhT 768A== X-Gm-Message-State: AOAM531AZpsMRVBAf1FEmVrfkQEyTYClFfsxBOJNGLcfOxSaXL8N5J4t PD2edudFu30sEtY60qJM0UvO/WAuN40= X-Google-Smtp-Source: ABdhPJxfpMdyab2/zyxHpadD12vX3KhjpINYYW4ZBKd1AaFjMtzOQMObfW+6nsr0r5tIf72iXMLGiw== X-Received: by 2002:a17:90a:e38f:: with SMTP id b15mr27948219pjz.206.1590498157556; Tue, 26 May 2020 06:02:37 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id c12sm15741321pjm.46.2020.05.26.06.02.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 06:02:36 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 12/60][SRU][OEM-5.6] iommu/arm-smmu: Use accessor functions for iommu private data Date: Tue, 26 May 2020 21:01:16 +0800 Message-Id: <20200526130204.238445-13-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200526130204.238445-1-vicamo.yang@canonical.com> References: <20200526130204.238445-1-vicamo.yang@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Joerg Roedel BugLink: https://bugs.launchpad.net/bugs/1876707 Make use of dev_iommu_priv_set/get() functions and simplify the code where possible with this change. Signed-off-by: Joerg Roedel Tested-by: Will Deacon # arm-smmu Link: https://lore.kernel.org/r/20200326150841.10083-12-joro@8bytes.org (cherry picked from commit c84500a365b4b4b29b7ec31b8e29a3f97b68cb3e) Signed-off-by: You-Sheng Yang --- drivers/iommu/arm-smmu.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 3cef2bfd6f3e..a6a5796e9c41 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1059,7 +1059,7 @@ static bool arm_smmu_free_sme(struct arm_smmu_device *smmu, int idx) static int arm_smmu_master_alloc_smes(struct device *dev) { struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); - struct arm_smmu_master_cfg *cfg = fwspec->iommu_priv; + struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); struct arm_smmu_device *smmu = cfg->smmu; struct arm_smmu_smr *smrs = smmu->smrs; struct iommu_group *group; @@ -1159,11 +1159,11 @@ static int arm_smmu_domain_add_master(struct arm_smmu_domain *smmu_domain, static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) { - int ret; - struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); struct arm_smmu_master_cfg *cfg; struct arm_smmu_device *smmu; + int ret; if (!fwspec || fwspec->ops != &arm_smmu_ops) { dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n"); @@ -1177,7 +1177,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) * domains, just say no (but more politely than by dereferencing NULL). * This should be at least a WARN_ON once that's sorted. */ - cfg = fwspec->iommu_priv; + cfg = dev_iommu_priv_get(dev); if (!cfg) return -ENODEV; @@ -1430,7 +1430,7 @@ static int arm_smmu_add_device(struct device *dev) goto out_free; cfg->smmu = smmu; - fwspec->iommu_priv = cfg; + dev_iommu_priv_set(dev, cfg); while (i--) cfg->smendx[i] = INVALID_SMENDX; @@ -1468,7 +1468,7 @@ static void arm_smmu_remove_device(struct device *dev) if (!fwspec || fwspec->ops != &arm_smmu_ops) return; - cfg = fwspec->iommu_priv; + cfg = dev_iommu_priv_get(dev); smmu = cfg->smmu; ret = arm_smmu_rpm_get(smmu); @@ -1480,15 +1480,16 @@ static void arm_smmu_remove_device(struct device *dev) arm_smmu_rpm_put(smmu); + dev_iommu_priv_set(dev, NULL); iommu_group_remove_device(dev); - kfree(fwspec->iommu_priv); + kfree(cfg); iommu_fwspec_free(dev); } static struct iommu_group *arm_smmu_device_group(struct device *dev) { + struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); - struct arm_smmu_master_cfg *cfg = fwspec->iommu_priv; struct arm_smmu_device *smmu = cfg->smmu; struct iommu_group *group = NULL; int i, idx;