Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1686842ybz; Thu, 16 Apr 2020 13:41:59 -0700 (PDT) X-Google-Smtp-Source: APiQypKVb5IFIEEmqCKHazr5IAratStAt2H7Kta+AHYSZJYeGoYQynz+LGPiU8QGH9tC0U8I7PGy X-Received: by 2002:a17:906:4c98:: with SMTP id q24mr11195588eju.140.1587069719346; Thu, 16 Apr 2020 13:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587069719; cv=none; d=google.com; s=arc-20160816; b=aNy7hBFRuxPpd/L//vD9NvcVGi6v0VjnPq1JnBAxSZbc/pZ2HBtUS/Y0Xe19Ss4kHC dVyGyem9pVwPwxjpio3Kdi1cqO0LKleRzhe87Tz5sGWHWXBMw6cuZd1BrqH02ggDgAK2 BErDQ/SUQWAj2liaBr1s0djtQVxI6GJNmwwzmvdeMBjy1oJLnEhoCJ700+1ctgSHMKfc QgHQzqJtDxbhZh6oclpCcvRIaZABn9t+VQSW4V16rYxyJygQ0pmdkMtDEiq6UNPYYIWC XnJ1yoXkGuZMcK+Ye3Zo2t/leToJsjnzQOtNCY3KjHYqszUoxFImIYzrZFQsO9ifg95E aVIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=JC4ZwghNo+JEiak2hmqi7d8kddFUllqOr9vrtZr5HYE=; b=R20S7ifS6on4mWnlMVZUjBqoW1uT0JkgitiYRtONBZHFERv8Y4g8tyyGBoLIGIpa0k HZ0zXAq08NnjNq2lN+4U8eeA5WOA/DUdorwpI/KLOEdzttKyN4MVI/UkHGyKlL+pO5Ss y/gypz8+EKy0GnMsrtdiRx7WyXW+7jrdNtft6jCmzQdKAlhaXCBhjJqCDKIXA13EkKkH 7RE53xGsEyZWgBP7L/puKqfldsHa+W9tyotIBrK7ghhSx4RROvo91bwwCp55/XOg91Uz B9IP8E/zPz2XBKP4CJ/MaXWJcoAlGAQ3Iwfph2IFJBunILtwoBxm+K5MnLmfGPshHXvI pAAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=afwk6coV; 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 e15si6420422ejc.208.2020.04.16.13.41.35; Thu, 16 Apr 2020 13:41:59 -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; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=afwk6coV; 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 S2389330AbgDPRoK (ORCPT + 99 others); Thu, 16 Apr 2020 13:44:10 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:38180 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391311AbgDPRoC (ORCPT ); Thu, 16 Apr 2020 13:44:02 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1587059042; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=JC4ZwghNo+JEiak2hmqi7d8kddFUllqOr9vrtZr5HYE=; b=afwk6coVdZhTMoEQJIv6rZTTYRZP4rVG0M3seHvu3hykmRZKfryOho16krnvL/v3gvKB4cPR 9FHQLtEjgf5qXYLf0eKdinitXBIvoOVWD8zhLyWPONRkTA3JjAs+aNhi4hgVqmQgt6e3zH1o NwtXeUN1CYmHoBOV9zJnmD84zjo= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e989958.7f80986531b8-smtp-out-n03; Thu, 16 Apr 2020 17:43:52 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 65AEEC44795; Thu, 16 Apr 2020 17:43:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7D284C4478C; Thu, 16 Apr 2020 17:43:50 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Thu, 16 Apr 2020 23:13:50 +0530 From: Sai Prakash Ranjan To: Robin Murphy 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 Subject: Re: [PATCH 2/2] iommu/arm-smmu: Allow client devices to select direct mapping In-Reply-To: References: <813cc5b2da10c27db982254b274bf26008a9e6da.1579692800.git.saiprakash.ranjan@codeaurora.org> <3f12cefb-3887-859c-ddf5-c7a0fc755152@arm.com> <540fc55811d0a60a929ff1f694d6d271@codeaurora.org> Message-ID: X-Sender: saiprakash.ranjan@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robin, On 2020-04-16 22:47, Robin Murphy wrote: > 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. > Thanks for explaining *this thing* :) I will update the patch to follow the 2nd pattern as it makes more sense to do_this or do_that directly. I'm not expecting anything other than domain type atleast for now but hey we can always add the functionality if the need arises. Thanks, Sai -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation