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=-5.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 EBCB8C433E0 for ; Fri, 22 Jan 2021 13:28:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 A84F123433 for ; Fri, 22 Jan 2021 13:28:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A84F123433 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RX5f0N2sn4B0bJv+kpYwN4izg2SP4Xgd3aMRSr+vqTg=; b=coCs03zlJAThGpqf4ZxJWHzyf me1ZQ6JkaJr6M0t+3vgFJkXEd/jFE4NrXe2b1/iv5ng9yh9JewKMGXHlmXeOrnA5tjmf6jlbtkCcf 4Xx0oSjUkZL0TgInekKR+t/uE7wD72qnhsfEfPmyqw3OuJ+acRxACrqbG0ssRwMtCpHhGMW7E7p9g GKoMWXR+FYCnAIYE65B55sFuK2yV80h9TcXc9BSXn6mplx2GiO5wXBxRcicJZlqf2o3DybUF7Me2z 6ZzynsJ3w/4QhEmNcIt6hyQxJrKqt2NG+g4Kt9Ffj/9XfJ89G+uyTuRKZpmObmc/4BonoqWosWzev dQcO1GZ1A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2wSv-0005Je-3L; Fri, 22 Jan 2021 13:27:05 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2wSs-0005J8-Tw for linux-arm-kernel@lists.infradead.org; Fri, 22 Jan 2021 13:27:03 +0000 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)" 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210122_082703_093652_1D268993 X-CRM114-Status: GOOD ( 22.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean-Philippe Brucker , Joerg Roedel , Yang Yingliang , linux-kernel , iommu , Jonathan Cameron , Robin Murphy , linux-arm-kernel Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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: > >>> =A0 -=A0=A0=A0=A0=A0=A0=A0 tblp =3D ptep - ARM_LPAE_LVL_IDX(iova, lvl= , data); > >>> -=A0=A0=A0=A0=A0=A0=A0 if (__arm_lpae_unmap(data, NULL, iova, sz, lvl= , tblp) !=3D sz) { > >>> -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 WARN_ON(1); > >>> -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return -EINVAL; > >>> +=A0=A0=A0=A0=A0=A0=A0 switch (cfg->bbml) { > >>> +=A0=A0=A0=A0=A0=A0=A0 case 0: > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 * We need to unmap and free the= old table before > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 * overwriting it with a block e= ntry. > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 */ > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 tblp =3D ptep - ARM_LPAE_LVL_IDX(i= ova, lvl, data); > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if (__arm_lpae_unmap(data, NULL, i= ova, sz, lvl, tblp) !=3D sz) { > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 WARN_ON(1); > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return -EINVAL; > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 } > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break; > >>> +=A0=A0=A0=A0=A0=A0=A0 case 1: > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 __arm_lpae_init_pte(data, paddr, p= rot, lvl, ptep, ARM_LPAE_PTE_nT); > >>> + > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 io_pgtable_tlb_flush_walk(iop, iov= a, sz, ARM_LPAE_GRANULE(data)); > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 tblp =3D iopte_deref(pte, data); > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 __arm_lpae_free_pgtable(data, lvl = + 1, tblp); > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break; > >>> +=A0=A0=A0=A0=A0=A0=A0 case 2: > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 __arm_lpae_init_pte(data, paddr, p= rot, lvl, ptep, 0); > >>> + > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 io_pgtable_tlb_flush_walk(iop, iov= a, sz, ARM_LPAE_GRANULE(data)); > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 tblp =3D iopte_deref(pte, data); > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 __arm_lpae_free_pgtable(data, lvl = + 1, tblp); > >>> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return 0; > >> > >> Sorry, but I really don't understand what you're trying to do here. Th= e old > >> code uses BBM for the table -> block path so we don't need anything ex= tra > >> here. The dodgy case is when we unmap part of a block, and end up inst= alling > >> 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 rem= ain 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel