From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 141FFC4360F for ; Fri, 5 Apr 2019 10:02:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 DA20521738 for ; Fri, 5 Apr 2019 10:02:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WcgR/GYr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA20521738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:References: To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=elJMVtxkiXXDQQSIoAYbhNUG9L4rLiuTt8rbm8w6HxA=; b=WcgR/GYr8zuWUHYYI2s0sHfoa FMed/jKBOz5TifC+aH2iex+uPRnpRnA7YlAFjiVUFcvVxJCmj/u1TFX4E6b4aSsLbDxAWMRr54pn3 Ik3Q6HOQUfE2PujZ9cpPdlLDpXxhKD5GVdj02KITIJu5uzBUpwyw8eCklDc/48qBORWSv3MpZabML sVhnUy+OcV/K4WxYqT4PHk7XPhwIQFZUi6O7k4GesHizCtMp42fNFE2gdWfx06vBtqP/WV+DPN+Lu eoVLqrLRp+NSfvGqmAjNotw1Ozw1CkonxZUYxf1IoYh0ah6n70BaoFlS8MWcT14us5i/AdP+9JUIZ 91CacfSfQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hCLgE-00074q-GL; Fri, 05 Apr 2019 10:02:38 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hCLgB-00074H-KY for linux-arm-kernel@lists.infradead.org; Fri, 05 Apr 2019 10:02:37 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 10303168F; Fri, 5 Apr 2019 03:02:35 -0700 (PDT) Received: from [10.1.196.75] (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A4DEE3F721; Fri, 5 Apr 2019 03:02:32 -0700 (PDT) Subject: Re: [PATCH v3 1/3] iommu: io-pgtable: Add ARM Mali midgard MMU page table format From: Robin Murphy To: Rob Herring , dri-devel@lists.freedesktop.org References: <20190401074730.12241-1-robh@kernel.org> <20190401074730.12241-2-robh@kernel.org> <8d091874-11b0-e348-c4f1-dd1bcfa4bf97@arm.com> Message-ID: <85471882-3044-eba7-8351-fb01330004d8@arm.com> Date: Fri, 5 Apr 2019 11:02:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <8d091874-11b0-e348-c4f1-dd1bcfa4bf97@arm.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190405_030235_687018_A948A00C X-CRM114-Status: GOOD ( 22.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lyude Paul , Neil Armstrong , Maxime Ripard , Will Deacon , David Airlie , Maarten Lankhorst , linux-kernel@vger.kernel.org, Eric Anholt , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, Daniel Vetter , Sean Paul , Alyssa Rosenzweig Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 01/04/2019 20:11, Robin Murphy wrote: > On 01/04/2019 08:47, Rob Herring wrote: >> ARM Mali midgard GPU is similar to standard 64-bit stage 1 page >> tables, but >> have a few differences. Add a new format type to represent the format. >> The >> input address size is 48-bits and the output address size is 40-bits (and >> possibly less?). Note that the later bifrost GPUs follow the standard >> 64-bit stage 1 format. >> >> The differences in the format compared to 64-bit stage 1 format are: >> >> The 3rd level page entry bits are 0x1 instead of 0x3 for page entries. >> >> The access flags are not read-only and unprivileged, but read and write. >> This is similar to stage 2 entries, but the memory attributes field >> matches >> stage 1 being an index. >> >> The nG bit is not set by the vendor driver. This one didn't seem to >> matter, >> but we'll keep it aligned to the vendor driver. >> >> Cc: Will Deacon >> Cc: Robin Murphy >> Cc: Joerg Roedel >> Cc: linux-arm-kernel@lists.infradead.org >> Cc: iommu@lists.linux-foundation.org >> Signed-off-by: Rob Herring >> --- >> Please ack this as I need to apply it to the drm-misc tree. Or we need a >> stable branch with this patch. > > With the diff below squashed in to address my outstanding style nits, > > Acked-by: Robin Murphy > > I don't foresee any conflicting io-pgtable changes to prevent this going > via DRM, but I'll leave the final say up to Joerg. Urgh, sorry, turns out I flipped one condition too many there. On reflection I may also forget my clever trick in future and inadvertently break it, so it probably warrants a comment. Please supersede my previous request with the (actually tested) diff below :) Thanks, Robin. ----->8----- diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 98551d0cff59..4f7be5a3e19b 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -197,12 +197,13 @@ struct arm_lpae_io_pgtable { typedef u64 arm_lpae_iopte; -static inline bool iopte_leaf(arm_lpae_iopte pte, int l, enum io_pgtable_fmt fmt) +static inline bool iopte_leaf(arm_lpae_iopte pte, int lvl, + enum io_pgtable_fmt fmt) { - if ((l == (ARM_LPAE_MAX_LEVELS - 1)) && (fmt != ARM_MALI_LPAE)) - return iopte_type(pte,l) == ARM_LPAE_PTE_TYPE_PAGE; + if (lvl == (ARM_LPAE_MAX_LEVELS - 1) && fmt != ARM_MALI_LPAE) + return iopte_type(pte, lvl) == ARM_LPAE_PTE_TYPE_PAGE; - return iopte_type(pte,l) == ARM_LPAE_PTE_TYPE_BLOCK; + return iopte_type(pte, lvl) == ARM_LPAE_PTE_TYPE_BLOCK; } static arm_lpae_iopte paddr_to_iopte(phys_addr_t paddr, @@ -310,12 +311,9 @@ static void __arm_lpae_init_pte(struct arm_lpae_io_pgtable *data, if (data->iop.cfg.quirks & IO_PGTABLE_QUIRK_ARM_NS) pte |= ARM_LPAE_PTE_NS; - if (lvl == ARM_LPAE_MAX_LEVELS - 1) { - if (data->iop.fmt == ARM_MALI_LPAE) - pte |= ARM_LPAE_PTE_TYPE_BLOCK; - else - pte |= ARM_LPAE_PTE_TYPE_PAGE; - } else + if (data->iop.fmt != ARM_MALI_LPAE && lvl == ARM_LPAE_MAX_LEVELS - 1) + pte |= ARM_LPAE_PTE_TYPE_PAGE; + else pte |= ARM_LPAE_PTE_TYPE_BLOCK; if (data->iop.fmt != ARM_MALI_LPAE) @@ -452,7 +450,10 @@ static arm_lpae_iopte arm_lpae_prot_to_pte(struct arm_lpae_io_pgtable *data, if (prot & IOMMU_WRITE) pte |= ARM_LPAE_PTE_HAP_WRITE; } - + /* + * Note that this logic is structured to accommodate Mali LPAE + * having stage-1-like attributes but stage-2-like permissions. + */ if (data->iop.fmt == ARM_64_LPAE_S2 || data->iop.fmt == ARM_32_LPAE_S2) { if (prot & IOMMU_MMIO) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel