Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp625537yba; Wed, 24 Apr 2019 07:05:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhHE5rQTDiJEkZ+4VEefiOeG/eJHwihsbprjIa7U8zRusJq6PNaGsB2/3vfAT0ImJHGQ+G X-Received: by 2002:a63:5560:: with SMTP id f32mr31120937pgm.334.1556114745379; Wed, 24 Apr 2019 07:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556114745; cv=none; d=google.com; s=arc-20160816; b=np3GGmfIOHtWOco2GwN82+T1K9ADiiz5VVER3W/I7lMosp/K87TNRFZ4nDALI/H0N6 TwQuMD3Bem5YhQQsyTkbrnJOzR72C9TFtv4dbpemAcStwXxxvcmGZ1ftKD8iUfYDEKnA VmT7er9rUazQwsy9r3WS89PjZiMMzRvj3QAmLir3Y2MLMoHggIfq8M4112iSMLGwJRse X4eulmMFpMx415HbHvXmB7hYvZQzzd/ZluUHQnQZqDmLReEkbQT4rzkThcO8d2BBccI3 V2Z06Y25fgYL8qSLyG/0cZ8GgSyI2WnH0NbJCuROp9BbjUHNq65nnbdfTHfCzWrJDdOW fEcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=YfLJvwnqOXqvkNbAE4SurmQwBInvQc141aPUo652m1g=; b=nXwokdbJqzYxEutrJUAEbpBo5/k49iuhHAgaxtjQcz5MO5ftrrVGSNwuFw6ULToyPf eK/Ka1L+xoDDNYIhDn2Hu+hD/DFnohRWzm5d9MtQJydc4j9lbP4vtVo1FKmdlgas4FJR 2mQO7U0fVSCLv8U/zVANu6fy/hA1t3MW3JyTSO5oL7bLbXQRLLiXLXH8c2R61baBH84j 2WUdQ2spFYmFSkm2VMgpbJLqRwrv7l9qv2LnJ5IJs+VbSS3w1v6wUnhl2iUyaBPU9gT7 3N3ticTY5MCOqn4+5ar7pATyQ53dMasLLx0wMx1OQ1Wb1muaA46E5MjWEWaV/HnvSBUj Z4pA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p85si19534603pfi.27.2019.04.24.07.05.27; Wed, 24 Apr 2019 07:05:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730844AbfDXNz0 (ORCPT + 99 others); Wed, 24 Apr 2019 09:55:26 -0400 Received: from laurent.telenet-ops.be ([195.130.137.89]:50580 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730290AbfDXNzX (ORCPT ); Wed, 24 Apr 2019 09:55:23 -0400 Received: from ramsan ([84.194.111.163]) by laurent.telenet-ops.be with bizsmtp id 4DvM2000F3XaVaC01DvMAB; Wed, 24 Apr 2019 15:55:21 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1hJIMr-000880-K5; Wed, 24 Apr 2019 15:55:21 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1hJIMr-0006YW-Ie; Wed, 24 Apr 2019 15:55:21 +0200 From: Geert Uytterhoeven To: Joerg Roedel , Magnus Damm Cc: Laurent Pinchart , iommu@lists.linux-foundation.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 1/6] iommu/ipmmu-vmsa: Link IOMMUs and devices in sysfs Date: Wed, 24 Apr 2019 15:55:13 +0200 Message-Id: <20190424135518.25150-2-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190424135518.25150-1-geert+renesas@glider.be> References: <20190424135518.25150-1-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As of commit 7af9a5fdb9e0ca33 ("iommu/ipmmu-vmsa: Use iommu_device_sysfs_add()/remove()"), IOMMU devices show up under /sys/class/iommu/, but their "devices" subdirectories are empty. Likewise, devices tied to an IOMMU do not have an "iommu" backlink. Make sure all links are created, on both arm32 and arm64. Signed-off-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart --- v3: - Fix sysfs path typo in patch description, v2: - Add Reviewed-by. --- drivers/iommu/ipmmu-vmsa.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 9a380c10655e182d..9f2b781e20a0eba6 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -885,27 +885,37 @@ static int ipmmu_init_arm_mapping(struct device *dev) static int ipmmu_add_device(struct device *dev) { + struct ipmmu_vmsa_device *mmu = to_ipmmu(dev); struct iommu_group *group; + int ret; /* * Only let through devices that have been verified in xlate() */ - if (!to_ipmmu(dev)) + if (!mmu) return -ENODEV; - if (IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_IOMMU_DMA)) - return ipmmu_init_arm_mapping(dev); + if (IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_IOMMU_DMA)) { + ret = ipmmu_init_arm_mapping(dev); + if (ret) + return ret; + } else { + group = iommu_group_get_for_dev(dev); + if (IS_ERR(group)) + return PTR_ERR(group); - group = iommu_group_get_for_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + iommu_group_put(group); + } - iommu_group_put(group); + iommu_device_link(&mmu->iommu, dev); return 0; } static void ipmmu_remove_device(struct device *dev) { + struct ipmmu_vmsa_device *mmu = to_ipmmu(dev); + + iommu_device_unlink(&mmu->iommu, dev); arm_iommu_detach_device(dev); iommu_group_remove_device(dev); } -- 2.17.1