Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1022908pxb; Fri, 22 Jan 2021 05:29:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbf3suCUpVNt6Vy8Er1aM/88SiomNpCa5TSRrxN7QGYhoOKbtjn600psZbWf2zr23enWzS X-Received: by 2002:a17:906:8046:: with SMTP id x6mr3001204ejw.351.1611322185248; Fri, 22 Jan 2021 05:29:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611322185; cv=none; d=google.com; s=arc-20160816; b=ottIZ7QECfc51KIuvnFEHKhQ7pgfu02MHczE4Xg+rmb87NUgvqGlV3q45o99mbUCfT trD0iuS1+0RJKkCSYk4WTCG47LsLC6JbjcyM32mu3dxLmCD7SImua+oGBwGbhbR0zNC9 3yBU+r0sXO1NteUC8Kd7zOewJwBUzigAMfoh8vhFns5oapSoiDz+ooQymtyWOUmVDx6c THRgA3FzV9evucXorE3H6JL90dxvA74LuWJhl1q8YzV3zcvE+w6wQQwcVjz86ylYg69b c9iYgS/S9NHz372cfKVZhMHvf5O982Cuy2lpEp86XGG9URQhcVNBjBlcS9W4tE3ceXiC Gvcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wN4IcO50Gg/NZ5wYhKb541dw4POQIE/Jxhu/MyqbCJ0=; b=AG369nTYP6amaPOeVuyi/Hw0MfkUW9aTWv6w/yNKShX3u3Koie6rc+Ap4AGYrhk1uK q56CVfzCwTFMni2rH+YOch9TN9MKkXS/8p/NJwYIS8RHMBVEJDt++jUllkdti0si4CWR WvA5djeORu5ILc72pGMnhmA3dEvJBKkOJBuvO20iWQirHkwKNCgLtXrD/vWV2UL72NeA T+AEDAkhY7+40qSYj1xVaxoG/S8w54fWIUWXyFXpPw5MNCKm/BiG+/nrVVGdMv8lGlS2 MOnYlmkg0BtToMfWZGA1Tx0e/6Zea+HGvyePSofYrCtCYOOdIkaNJquZkSISImP0qIbV Lvtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WES5Cm1G; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si3730393edv.84.2021.01.22.05.29.21; Fri, 22 Jan 2021 05:29:45 -0800 (PST) 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=pass header.i=@kernel.org header.s=k20201202 header.b=WES5Cm1G; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727732AbhAVN2W (ORCPT + 99 others); Fri, 22 Jan 2021 08:28:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:53778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727723AbhAVN1m (ORCPT ); Fri, 22 Jan 2021 08:27:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 71C9C23437; Fri, 22 Jan 2021 13:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611322022; bh=TFRhEbqOYGrPg5oqvZVpaacX5O5OSugUVOmvFlNjpHU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WES5Cm1GzYFPymGEhfK8FTVVWR1u6M1vvW13aa9LwGcq3rhxId09iMjJocQDvk8hm iG1Sbab84JE57V4aIaKSycb5d1IxgqWLfDlpqcsYdlYW/r+3CFkyg5EZZPoi8pryad tfK1K/MHOVDOaiLC9aTyHscXWl+zhxwPiHHL0wBewy5GBjh8bQz84GgHpRSxOtNzgY /cz2yHVcmYMua4UV/bCQjZlA74eHzcPoyB3QGRvbfP/ssHCB/ADoBi3hcX1BkEEJIQ PX67b5+eXPGAwDZCS+35ypd0ENmdD27/qMkRwvBLLpU9w4GJyV02QzzSWzQqLVkKVE f6GtWRRs8geow== Date: Fri, 22 Jan 2021 13:26:57 +0000 From: Will Deacon To: "Leizhen (ThunderTown)" Cc: Robin Murphy , Joerg Roedel , Jean-Philippe Brucker , Jonathan Cameron , linux-arm-kernel , iommu , linux-kernel , Yang Yingliang Subject: Re: [PATCH 1/1] iommu/arm-smmu-v3: add support for BBML Message-ID: <20210122132657.GF24102@willie-the-truck> References: <20201126034230.777-1-thunder.leizhen@huawei.com> <20210122125132.GB24102@willie-the-truck> <34a9c164-389d-30cd-11a3-8796eb7bca93@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 22, 2021 at 09:21:20PM +0800, Leizhen (ThunderTown) wrote: > On 2021/1/22 21:00, Robin Murphy wrote: > > On 2021-01-22 12:51, Will Deacon wrote: > >> On Thu, Nov 26, 2020 at 11:42:30AM +0800, Zhen Lei wrote: > >>> ? -??????? tblp = ptep - ARM_LPAE_LVL_IDX(iova, lvl, data); > >>> -??????? if (__arm_lpae_unmap(data, NULL, iova, sz, lvl, tblp) != sz) { > >>> -??????????? WARN_ON(1); > >>> -??????????? return -EINVAL; > >>> +??????? switch (cfg->bbml) { > >>> +??????? case 0: > >>> +??????????? /* > >>> +???????????? * We need to unmap and free the old table before > >>> +???????????? * overwriting it with a block entry. > >>> +???????????? */ > >>> +??????????? tblp = ptep - ARM_LPAE_LVL_IDX(iova, lvl, data); > >>> +??????????? if (__arm_lpae_unmap(data, NULL, iova, sz, lvl, tblp) != sz) { > >>> +??????????????? WARN_ON(1); > >>> +??????????????? return -EINVAL; > >>> +??????????? } > >>> +??????????? break; > >>> +??????? case 1: > >>> +??????????? __arm_lpae_init_pte(data, paddr, prot, lvl, ptep, ARM_LPAE_PTE_nT); > >>> + > >>> +??????????? io_pgtable_tlb_flush_walk(iop, iova, sz, ARM_LPAE_GRANULE(data)); > >>> +??????????? tblp = iopte_deref(pte, data); > >>> +??????????? __arm_lpae_free_pgtable(data, lvl + 1, tblp); > >>> +??????????? break; > >>> +??????? case 2: > >>> +??????????? __arm_lpae_init_pte(data, paddr, prot, lvl, ptep, 0); > >>> + > >>> +??????????? io_pgtable_tlb_flush_walk(iop, iova, sz, ARM_LPAE_GRANULE(data)); > >>> +??????????? tblp = iopte_deref(pte, data); > >>> +??????????? __arm_lpae_free_pgtable(data, lvl + 1, tblp); > >>> +??????????? return 0; > >> > >> Sorry, but I really don't understand what you're trying to do here. The old > >> code uses BBM for the table -> block path so we don't need anything extra > >> here. The dodgy case is when we unmap part of a block, and end up installing > >> a table via arm_lpae_split_blk_unmap(). We can't use BBM there because there > >> could be ongoing DMA to parts of the block mapping that we want to remain in > >> place. > >> > >> Are you seeing a problem in practice? > > > > Right, I was under the assumption that we could ignore BBML because we > > should never have a legitimate reason to split blocks. I'm certainly not > > keen on piling any more complexity into split_blk_unmap, because the > > IOMMU API clearly doesn't have a well-defined behaviour for that case > > anyway - some other drivers will just unmap the entire block, and IIRC > > there was a hint somewhere in VFIO that it might actually expect that > > behaviour. > > I'm going home. I'll answer you two tomorrow. It can wait until Monday! Have a good weekend :) Will