Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1686929ybz; Thu, 16 Apr 2020 13:42:05 -0700 (PDT) X-Google-Smtp-Source: APiQypKLyyysDcYUF/ceDRGcIf8AQQql+6YaCN9qC1KFsyDYVSPEjAK8nqCNtAD/zbHKRIqIpKFn X-Received: by 2002:a17:906:35d0:: with SMTP id p16mr11216783ejb.77.1587069725785; Thu, 16 Apr 2020 13:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587069725; cv=none; d=google.com; s=arc-20160816; b=Pa7z2vI6sra61eTG2XHz4C20O3ctJAWGKtLLm9nib3wZhvB+hGiUB6aCFODM1zCLvU HNfO48dXWBxQp5SFH92Zt04g0nGu9/U0J12+H3BtqMiYPCXFRyM7gg4V24vs/oQMwehy pQBvNtBbUGYyjEa055s5yv18rR925QH6uO+Gc5a//nNvafiicngxU34s6qf+mZyB8HMl IOmRRgaP09GL3k+li4SyELoSV0BqM3Jyln743ba2VUbO6S4uFej8BilYZXUe5GWKzVc3 rIlTrl+XCet101S0LDo2qT33IZv6fNS5IRIVAQw+W/mNiQM3qkdU5D9tw3+EsCwPPpIg DHgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=q3+L2Ck0CNCU/MVt14aLgYHKf/NypYjv4K+/4vMAVsk=; b=lC/tvnbgLmggbA8o+s7MRAVahI57jczwX8APpYSzOtx/wmb0UMJftB/f3HvPM/Wvoo N0728swDlOm9mvU/XOQ+e1NPhzcbP8FTbPt1ox44Q/OkHsrS09/ZG/8oEpvn5G6PTZq6 Ub0/TgcSCOgIN6F2EtJwsj7RdVRUQYk/DQuRnSwYFbsoS4XYAd8X4lfcK82pnOJUlW5E Zaao3VKhu9nfl0njam7xuPWx8h56r/CmIVeixbP2WEEEs0iNL5cH5KpfMcDbQCho95Ec jzIi8RmB7nWA87oTdTow20NhoL/v5PeiEqJQDGmIybCD1Q07r+yZhm1DFjY9LYwvKzqm Umwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by26si4845415edb.144.2020.04.16.13.41.42; Thu, 16 Apr 2020 13:42:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731176AbgDPRRj (ORCPT + 99 others); Thu, 16 Apr 2020 13:17:39 -0400 Received: from foss.arm.com ([217.140.110.172]:38344 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728863AbgDPRRi (ORCPT ); Thu, 16 Apr 2020 13:17:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7287730E; Thu, 16 Apr 2020 10:17:37 -0700 (PDT) Received: from [10.57.59.184] (unknown [10.57.59.184]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5CBA23F73D; Thu, 16 Apr 2020 10:17:35 -0700 (PDT) Subject: Re: [PATCH 2/2] iommu/arm-smmu: Allow client devices to select direct mapping To: Sai Prakash Ranjan Cc: Will Deacon , Joerg Roedel , Jordan Crouse , Rob Clark , Tomasz Figa , Rajendra Nayak , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Boyd , iommu@lists.linux-foundation.org, Matthias Kaehlcke , Bjorn Andersson , linux-arm-kernel@lists.infradead.org References: <813cc5b2da10c27db982254b274bf26008a9e6da.1579692800.git.saiprakash.ranjan@codeaurora.org> <3f12cefb-3887-859c-ddf5-c7a0fc755152@arm.com> <540fc55811d0a60a929ff1f694d6d271@codeaurora.org> From: Robin Murphy Message-ID: Date: Thu, 16 Apr 2020 18:17:33 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <540fc55811d0a60a929ff1f694d6d271@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-16 5:23 pm, Sai Prakash Ranjan wrote: > Hi Robin, > > On 2020-04-16 19:28, Robin Murphy wrote: >> On 2020-01-22 11:48 am, Sai Prakash Ranjan wrote: >>> From: Jordan Crouse >>> >>> Some client devices want to directly map the IOMMU themselves instead >>> of using the DMA domain. Allow those devices to opt in to direct >>> mapping by way of a list of compatible strings. >>> >>> Signed-off-by: Jordan Crouse >>> Co-developed-by: Sai Prakash Ranjan >>> Signed-off-by: Sai Prakash Ranjan >>> --- >>>   drivers/iommu/arm-smmu-qcom.c | 39 +++++++++++++++++++++++++++++++++++ >>>   drivers/iommu/arm-smmu.c      |  3 +++ >>>   drivers/iommu/arm-smmu.h      |  5 +++++ >>>   3 files changed, 47 insertions(+) >>> >>> diff --git a/drivers/iommu/arm-smmu-qcom.c >>> b/drivers/iommu/arm-smmu-qcom.c >>> index 64a4ab270ab7..ff746acd1c81 100644 >>> --- a/drivers/iommu/arm-smmu-qcom.c >>> +++ b/drivers/iommu/arm-smmu-qcom.c >>> @@ -3,6 +3,7 @@ >>>    * Copyright (c) 2019, The Linux Foundation. All rights reserved. >>>    */ >>>   +#include >>>   #include >>>     #include "arm-smmu.h" >>> @@ -11,6 +12,43 @@ struct qcom_smmu { >>>       struct arm_smmu_device smmu; >>>   }; >>>   +static const struct arm_smmu_client_match_data qcom_adreno = { >>> +    .direct_mapping = true, >>> +}; >>> + >>> +static const struct arm_smmu_client_match_data qcom_mdss = { >>> +    .direct_mapping = true, >>> +}; >> >> Might it make sense to group these by the desired SMMU behaviour >> rather than (apparently) what kind of device the client happens to be, >> which seems like a completely arbitrary distinction from the SMMU >> driver's PoV? >> > > Sorry, I did not get the "grouping by the desired SMMU behaviour" thing. > Could you please give some more details? I mean this pattern: device_a_data { .thing = this; } device_b_data { .thing = this; } device_c_data { .thing = that; } match[] = { { .compatible = "A", .data = &device_a_data }, { .compatible = "B", .data = &device_b_data }, { .compatible = "C", .data = &device_c_data }, }; ...vs. this pattern: do_this { .thing = this; } do_that { .thing = that; } match[] = { { .compatible = "A", .data = &do_this }, { .compatible = "B", .data = &do_this }, { .compatible = "C", .data = &do_that }, }; From the perspective of the thing doing the thing, grouping the data by device is meaningless if all that matters is whether to do this or that. The second pattern expresses that more naturally. Of course if every device turns out to need a unique combination of several behaviours, then there ends up being no practical difference except that it's probably easier to come up with nice names under the first pattern. I guess it's up to how you see this developing in future; whether you're likely to need fine-grained per-device control, or don't expect it to go much beyond domain type. Robin.