Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2006998imm; Sat, 18 Aug 2018 08:58:01 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwxYalKtnBND/9OiUm8lVZD7ptbQzYbSnde1YlOkr/5mrxbrB9ZVezu1DknXq7WIT/kA4oW X-Received: by 2002:a63:7a45:: with SMTP id j5-v6mr5921898pgn.363.1534607880965; Sat, 18 Aug 2018 08:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534607880; cv=none; d=google.com; s=arc-20160816; b=BfR15+kpl7GiLyju7laq0THJ/shEovHHWSuPbGFoVCVGYf574IvOeEB6XLvRERLRSb eIpEAwcdFngy9Y4GYq1e30cYYbyBr/9bSB7AxjFYHg4EIFEvSo93K7qZ0KqOPg0FowWQ byw2zNtg0vfv30gxjRCo+yjDkTuPB2QRYQUr/PvNMRDgGkHG5F9go1sZcBKTknwCnl5H Dglt4PIE0ygayYgPvdZ4P8Pl5P9D/UPLh1PQz+Be8/PCySGhT7SM7wIXRb6kSdRHW7JW Kkq2AoU/GCBOWoyPTksFcgQFbyW5P6DcTcqHgbnITCrcjic6yH30BDVa3i/MrF8edeGT hpeQ== 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:dkim-signature:arc-authentication-results; bh=WTxC9P0e187wMiz2N5iLPT4giNu311br0rXL91LJsD8=; b=d39TLDfgy5BUA/fDtemBa7JBKsKmhvJdcWUJ+tM2+KR9jMvghMCRDgn/4xL6Emm7EJ U66eI9DCQcfinoJ0uIp6lPOsJSLpqakgLA3yi5O2A3o6itUTCu0fJpSa1RTpDgHx3Oj2 93Doe+z8Q9CMOFa/WQLh5IijQ2pKc3t0Fc/0FDw8tV+xirT48SSlAZRto8Mlyipc2wFi /pQ77AS2NVGZ0TG1/qo1e5KjDXcfQKdCMr65yuotMeluSulM8JZCsFqEkeX1i+je5j8l D5yJKyVoRpdhmflD4Nb3+0B7z+WxWUWOmV7BbOOoNUu3Y1XmEZfoTzCeQCARm4N8w7w4 7DJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Xlc/uNhW"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q129-v6si4650537pga.217.2018.08.18.08.57.45; Sat, 18 Aug 2018 08:58:00 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Xlc/uNhW"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726966AbeHRTEJ (ORCPT + 99 others); Sat, 18 Aug 2018 15:04:09 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:46923 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726714AbeHRTEI (ORCPT ); Sat, 18 Aug 2018 15:04:08 -0400 Received: by mail-ed1-f68.google.com with SMTP id o8-v6so6099426edt.13; Sat, 18 Aug 2018 08:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WTxC9P0e187wMiz2N5iLPT4giNu311br0rXL91LJsD8=; b=Xlc/uNhWV6kCs0E5ny/Y/QSKdifMD87EHP9dOBuLeTzog2qGLRdSadxw6aVs5NXI9W xwFMv4jp4k8pmJqoElpu+9C+Z9CZB8sqYhXIa4EUF50/5ukn/z842nPVGu/Z0Ir4X1BQ yiyJLpuHgrs6PXRXeDzeUwlAbJlTfR8cRjXEg+HwK8exNeoT3Y0eU4RTavY7tt1rHlmV 22vU0WQBfKM6onmbArnJtdO8Q+hlHGYBx+JwAgKv7AueCeU58nCsiQ0Yp5MrGlF+shoE 0AOI9BgStOU364RyEGY0oKlu9++5wMA2bv6Y159uQBAIicKzhxuAxq1vZlpp4EbqaU6D BwPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WTxC9P0e187wMiz2N5iLPT4giNu311br0rXL91LJsD8=; b=HX7vKfI2Owc0RgruhhHFZCneuj+uH1nOXDS6PZU085IR3ETcOPmyA91dFZEdtfP5Sz O0fnhw01mstpRyTY5SCwuAf4EYZmWYWR3lqBaE1IahrUpGntIQITPWKKjJXYddZ8CmPM obyWkSC+i5b4xzSV+cdr3PoXGNYVI0lbFmOEQ5h7SjcIr+FQuIlBaT8HSdSKzoHNXCz9 CphJiVKk6SeZDLN8eD9M3qQ7yWXl/Iwgt7vnMz9C2xFWXrL8rWSeH4ghYQyDQzgHhav6 NPePt3un3YYQ6IjDQZ1O8eP9VJhjIqr0FGIG7GHPgD/1H4Fv9dWU/1m5n/rq/3km2IUE yTig== X-Gm-Message-State: AOUpUlHm8AylxROTvhF4lT6v8z0EKiBSp9clkh8Tt4GSS5k0tnMc0bG2 gzY2Yz/d4rnAzJTZWlwiF3U+SBdD X-Received: by 2002:a50:aa83:: with SMTP id q3-v6mr46823762edc.64.1534607758003; Sat, 18 Aug 2018 08:55:58 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id v8-v6sm2784014edr.48.2018.08.18.08.55.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Aug 2018 08:55:57 -0700 (PDT) From: Dmitry Osipenko To: Joerg Roedel , Robin Murphy , Thierry Reding , Jonathan Hunter , Rob Herring Cc: iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 17/19] iommu/tegra: gart: Don't detach devices from inactive domains Date: Sat, 18 Aug 2018 18:54:28 +0300 Message-Id: <20180818155430.5586-18-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180818155430.5586-1-digetx@gmail.com> References: <20180818155430.5586-1-digetx@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There could be unlimited number of allocated domains, but only one domain can be active at a time. Hence devices must be detached only from the active domain. Signed-off-by: Dmitry Osipenko --- drivers/iommu/tegra-gart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index 284cddf90888..306e9644a676 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -167,7 +167,7 @@ static int gart_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) { struct gart_domain *gart_domain = to_gart_domain(domain); - struct gart_device *gart = gart_domain->gart; + struct gart_device *gart = gart_handle; struct gart_client *client, *c; int err = 0; @@ -192,6 +192,7 @@ static int gart_iommu_attach_dev(struct iommu_domain *domain, goto fail; } gart->active_domain = domain; + gart_domain->gart = gart; list_add(&client->list, &gart->client); spin_unlock(&gart->client_lock); dev_dbg(gart->dev, "GART: Attached %s\n", dev_name(dev)); @@ -214,8 +215,10 @@ static void __gart_iommu_detach_dev(struct iommu_domain *domain, if (c->dev == dev) { list_del(&c->list); kfree(c); - if (list_empty(&gart->client)) + if (list_empty(&gart->client)) { gart->active_domain = NULL; + gart_domain->gart = NULL; + } dev_dbg(gart->dev, "GART: Detached %s\n", dev_name(dev)); return; @@ -253,7 +256,6 @@ static struct iommu_domain *gart_iommu_domain_alloc(unsigned type) if (!gart_domain) return NULL; - gart_domain->gart = gart; gart_domain->domain.geometry.aperture_start = gart->iovmm_base; gart_domain->domain.geometry.aperture_end = gart->iovmm_base + gart->page_count * GART_PAGE_SIZE - 1; -- 2.18.0