From patchwork Tue Jun 2 07:48:25 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: 1302218 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 49bkj90Gwnz9sSy; Tue, 2 Jun 2020 17:50:05 +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 1jg1gL-0005uG-VO; Tue, 02 Jun 2020 07:49:57 +0000 Received: from mail-pl1-f193.google.com ([209.85.214.193]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jg1gG-0005oh-Je for kernel-team@lists.ubuntu.com; Tue, 02 Jun 2020 07:49:52 +0000 Received: by mail-pl1-f193.google.com with SMTP id q16so1030493plr.2 for ; Tue, 02 Jun 2020 00:49:52 -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=7yZ6pARFJeNew8ZAWNiPwGrWVuViaCOecCsQhw2owZE=; b=aGAHFpRc7I3N6i2u1w5Giw42uXJoLK9cefsmPms4RkbDw+7NGz6PYla9OUpS9jNQZR CMX1ZN8Tthtkc1t0lmbJ+a9L4OdpoxjfPF9CMiu+b0nQp2UP+8YhgbQs0NTsZ/wtcvJr UMEnMOV9v8TDuvgeZtQOsQ8WIy8WBk9LXf5LtE6h1qzp/sIaV6DZN6NBGprvQl2Uhgbn G16/pxKdwzOI/CmhDZNBxOUVAhOrrGIAOZVzvE2ssnBAieJhd5/2olE03W0uD7QzFS4N 0qRNFvJvTkyAMtzXxbHqXWsqCXLA99kgXDiXvkfd7tOF4P6ovtvBghEy+b9Xbb1dA4qp 3KMw== X-Gm-Message-State: AOAM5316r4hCJCb+4M9tGeKg6vrcW1l4gnPuN0e4p5i9GM/bQHZE/v1W bONN8bVzbqJd1Wd5SsMlQaxr/dUE+Fc= X-Google-Smtp-Source: ABdhPJxQ5HaSB2W8DducxiwApBXUQ27eBc6UTknMRTSdp4pFNBiJZb9ZuLV7eg90RvCnqgiwZ+rbUw== X-Received: by 2002:a17:90a:22cc:: with SMTP id s70mr4151940pjc.2.1591084190064; Tue, 02 Jun 2020 00:49:50 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id b23sm1361925pgs.33.2020.06.02.00.49.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 00:49:49 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH v2 24/42][SRU][U] iommu/qcom: Convert to probe/release_device() call-backs Date: Tue, 2 Jun 2020 15:48:25 +0800 Message-Id: <20200602074843.1743493-25-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200602074843.1743493-1-vicamo.yang@canonical.com> References: <20200602074843.1743493-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 Convert the QCOM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel Link: https://lore.kernel.org/r/20200429133712.31431-25-joro@8bytes.org Signed-off-by: Joerg Roedel (cherry picked from commit bfe3bd493b3d3f9a08d1751338ccc711840e4590 linux-next) Signed-off-by: You-Sheng Yang --- drivers/iommu/qcom_iommu.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/iommu/qcom_iommu.c b/drivers/iommu/qcom_iommu.c index 5b3b270972f8..c3e1fbd1988c 100644 --- a/drivers/iommu/qcom_iommu.c +++ b/drivers/iommu/qcom_iommu.c @@ -524,14 +524,13 @@ static bool qcom_iommu_capable(enum iommu_cap cap) } } -static int qcom_iommu_add_device(struct device *dev) +static struct iommu_device *qcom_iommu_probe_device(struct device *dev) { struct qcom_iommu_dev *qcom_iommu = to_iommu(dev); - struct iommu_group *group; struct device_link *link; if (!qcom_iommu) - return -ENODEV; + return ERR_PTR(-ENODEV); /* * Establish the link between iommu and master, so that the @@ -542,28 +541,19 @@ static int qcom_iommu_add_device(struct device *dev) if (!link) { dev_err(qcom_iommu->dev, "Unable to create device link between %s and %s\n", dev_name(qcom_iommu->dev), dev_name(dev)); - return -ENODEV; + return ERR_PTR(-ENODEV); } - group = iommu_group_get_for_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); - - iommu_group_put(group); - iommu_device_link(&qcom_iommu->iommu, dev); - - return 0; + return &qcom_iommu->iommu; } -static void qcom_iommu_remove_device(struct device *dev) +static void qcom_iommu_release_device(struct device *dev) { struct qcom_iommu_dev *qcom_iommu = to_iommu(dev); if (!qcom_iommu) return; - iommu_device_unlink(&qcom_iommu->iommu, dev); - iommu_group_remove_device(dev); iommu_fwspec_free(dev); } @@ -619,8 +609,8 @@ static const struct iommu_ops qcom_iommu_ops = { .flush_iotlb_all = qcom_iommu_flush_iotlb_all, .iotlb_sync = qcom_iommu_iotlb_sync, .iova_to_phys = qcom_iommu_iova_to_phys, - .add_device = qcom_iommu_add_device, - .remove_device = qcom_iommu_remove_device, + .probe_device = qcom_iommu_probe_device, + .release_device = qcom_iommu_release_device, .device_group = generic_device_group, .of_xlate = qcom_iommu_of_xlate, .pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M,