From patchwork Fri Sep 6 21:44:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11136083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79D501398 for ; Fri, 6 Sep 2019 21:48:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 63F192082C for ; Fri, 6 Sep 2019 21:48:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63F192082C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FDEF6E14E; Fri, 6 Sep 2019 21:48:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC36A6E14E for ; Fri, 6 Sep 2019 21:48:48 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id s12so5450323pfe.6 for ; Fri, 06 Sep 2019 14:48:48 -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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PmbeXR16EILkjisUuUV6rfWxt0BghSuM480d7BBoObE=; b=OqJoKl2co+erZyXHD0phMZQpWtT2O9f74nj2znq4heQ0BOF3cpmWO4DsLiK0ApdeP8 mo2Dqjk13JWYjKLcN/RxAVtKlhK8rIyukYdtu8jlW2qcJCTQ2O+Q1tJ6p0oziXQ4ZaVp E8w36H9+KWp5BQdO0pobZv/8PRLqplX0Werd/ZQzNjbFhmQSOf4DDdZkqQnlAout7PK2 8HtOy9a2GfsGsumTGoWudiO8QKMXFe+LN0ZLQPpsNgvJlK0B4WORoERATiNqiyhI4N5G Z5REzP0LwnTeiDsNVcwHPE17yO0i+lR233mDSRcy/tSt8Ll7NJ+LmW0jy4WHAE96W8Be OXeQ== X-Gm-Message-State: APjAAAXz0WCFLpmur5Mx2tTAZKd3y5wQ3rWx8I/e5VberznH7yzKISRi 5N5oTb5ZRET6K8iwkmVi35E= X-Google-Smtp-Source: APXvYqxQCd7WFr1bk2mCpZ+S1Nv/UOSK0AKJu6DLOAfsUfGckUthB3lN7nqi/NUB8YzjJgdlC0+ugA== X-Received: by 2002:a63:4823:: with SMTP id v35mr9858403pga.138.1567806528190; Fri, 06 Sep 2019 14:48:48 -0700 (PDT) Received: from localhost ([100.118.89.196]) by smtp.gmail.com with ESMTPSA id j9sm6894230pfi.128.2019.09.06.14.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 14:48:47 -0700 (PDT) From: Rob Clark To: iommu@lists.linux-foundation.org Subject: [PATCH v2 1/2] iommu: add support for drivers that manage iommu explicitly Date: Fri, 6 Sep 2019 14:44:01 -0700 Message-Id: <20190906214409.26677-2-robdclark@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190906214409.26677-1-robdclark@gmail.com> References: <20190906214409.26677-1-robdclark@gmail.com> MIME-Version: 1.0 X-Mailman-Original-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 :mime-version:content-transfer-encoding; bh=PmbeXR16EILkjisUuUV6rfWxt0BghSuM480d7BBoObE=; b=l9KS64BP1B0VVFLP3cG+Fu9U3dUbCksmelSZOoyogDcNDZW7sjsm328l7B9JP6x26f DZaO/ojDzSUVS4Il84HxoyaRZCseDaFTbt0s08wXIhLhOunAvz314/stiuohiLGFMmpE o3ol62LvFBaKO08hIXHcKu89nLOnrucM/f4gr9kbmXTL/db0eQb2NfDz1gsUIVqf14t0 QS0EoD8cKG4EdIQwYJ9KgSsGFyxXBCE3mbcRtamjbEN+ffrHwSzbUJ5ryEqWsTz7LGFr PJrVc19D7lpchjdUYFkmeYBA9fAiwKYdQ49Fv5Gw7pcbMrSl95PcHvVJdZOvz2bGBBlT Gx5w== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Heikki Krogerus , Arnd Bergmann , Suzuki K Poulose , linux-arm-msm@vger.kernel.org, "Rafael J. Wysocki" , Rasmus Villemoes , Robin Murphy , dri-devel@lists.freedesktop.org, Sudeep Holla , Greg Kroah-Hartman , Joe Perches , Andrew Morton , Will Deacon , Bartosz Golaszewski , open list Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark Avoid attaching any non-driver managed domain if the driver indicates that it manages the iommu directly. Signed-off-by: Rob Clark --- drivers/iommu/iommu.c | 2 +- drivers/iommu/of_iommu.c | 3 +++ include/linux/device.h | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 0c674d80c37f..2ac5e8d48cae 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -674,7 +674,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev) mutex_lock(&group->mutex); list_add_tail(&device->list, &group->devices); - if (group->domain) + if (group->domain && !(dev->driver && dev->driver->driver_manages_iommu)) ret = __iommu_attach_device(group->domain, dev); mutex_unlock(&group->mutex); if (ret) diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 614a93aa5305..62b47e384a77 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -221,6 +221,9 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, } else if (err < 0) { dev_dbg(dev, "Adding to IOMMU failed: %d\n", err); ops = NULL; + } else if (dev->driver && dev->driver->driver_manages_iommu) { + dev_dbg(dev, "Driver manages IOMMU\n"); + ops = NULL; } return ops; diff --git a/include/linux/device.h b/include/linux/device.h index 1aa341b2a0db..b77a11b8d9bb 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -284,7 +284,8 @@ struct device_driver { struct module *owner; const char *mod_name; /* used for built-in modules */ - bool suppress_bind_attrs; /* disables bind/unbind via sysfs */ + bool suppress_bind_attrs:1; /* disables bind/unbind via sysfs */ + bool driver_manages_iommu:1; /* driver manages IOMMU explicitly */ enum probe_type probe_type; const struct of_device_id *of_match_table;