Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4382788ybi; Mon, 3 Jun 2019 09:57:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzt87iwf4x5+dCtUZi3kB7xvJZrhrgP0bca8jim9epl1BkyIemBxVT/r50E+JSNZ8AF2Vwk X-Received: by 2002:a17:902:7206:: with SMTP id ba6mr24344433plb.86.1559581044674; Mon, 03 Jun 2019 09:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559581044; cv=none; d=google.com; s=arc-20160816; b=n5MaFQNL6gW44F7/2f833yf/5QhJtCF8+VAs01T+bT7OiXh+wnmZVkYSkoLMpZQf6Q 1oE5TYW6A00TirF5/mTdf23PhM8nV4krCoYzqagJKoNWeV9ZqnsjaZ3WXcji1Dx04zfi iqamYZNn0fOAyvYELDY8G4kQDcE8YKXOtTWQhVh4Y8pConk937tHms0lfWhP/Lw13kEt fHkPjSxblR7S6lhiQVYrO25CAs6IBnis7wD6JXvyg3yoLsgsQojbwQCLIvuqnSmKUw/y +pbDP93Z0iRwrOgZz1RR4rYPDt54i2SGojggklX4GVsgtVNF8Qmdj6hCMr1TBs9kvGPs Tgyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yge3w9rHbWgvobFZbFOeEgA2IlTICZ6Y6fbhlA0nby0=; b=AY4ilJyhqhPjccCZpNoZL9jqpzqhXAriTcjHBmWM27IHbk9dJWDHE/4NuxVKqa6zgP GzmSfV8PDyEXy9l4qzwSmulN/JE6lYMekKUYr94ZSbUdDKkBYoY2I6D0fcj1rzb9GcUP bCsUKH8q3UcpkVm8Zz/ABWVJi2Q+dXAN/12a1NAikb1YeAbW9xTy16n8trUgc1radC4F Wol1W1LnT8bhANVCzZGM8jqrDqIJwe0Gr1W3bCAbUDBQwwluaY8GnJTw+YJkV3rl4Fbf N7lvnWcKSrmEnDstvQ2McQbUx6IKlPnY6FJNwBjC+hTV3v1UY/YBYHslIp+5V4n65crO s1kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=Y+yacQIv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si15524329pls.303.2019.06.03.09.57.09; Mon, 03 Jun 2019 09:57:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=Y+yacQIv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728327AbfFCL1u (ORCPT + 99 others); Mon, 3 Jun 2019 07:27:50 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:33225 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727599AbfFCL1t (ORCPT ); Mon, 3 Jun 2019 07:27:49 -0400 Received: by mail-pf1-f194.google.com with SMTP id x15so650908pfq.0 for ; Mon, 03 Jun 2019 04:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yge3w9rHbWgvobFZbFOeEgA2IlTICZ6Y6fbhlA0nby0=; b=Y+yacQIvPCAiHgjTQHZU0FVoG9I2CbtFWh1hmP9jN5AY8VLFjiX+k6xtFzH0HNGzit O8+HuDE7HRrRPCKpVtBjzFEjUib45UJWNrACrI5dtMn5dhL7BYlOQviAmeCacyysnT/n Xvty8zwlPZ+u8dVb5gfg1+6bj4mdWhGmOj9ZV4LWheZdjBeBpOVrxXrNWXT+AbiGMNl2 Yu+vBF4TlQWGZi8Dq4zfPpETqkKfLGxVZb/314XRDJcA/hQwkyrur5b+hi4Dx4U2BziM nnSr7BJ7sU2o9o3B6SunhLofFsrm83s3EU1wt5ZiCI98JrmP0w6INx6y8G5bvgNUiRxA ZVIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yge3w9rHbWgvobFZbFOeEgA2IlTICZ6Y6fbhlA0nby0=; b=iEgFTv2Z4Vqg8nqV9qkbJSlaHlC6pMtQasq/ZPVC2IX82eUcBxbFylWaYsW1lFOtoY yhdAe7yDA09VNjRiG4rLPzhsNVR7BQLA2zqRpq9hmsO1qOH91xd/yHtp/vA16CMkw4tz rFAHAx38opUgt2/DegT0bXQoAbiauhj9/u/1Cxg+IZSqSiPmiv4qu2qqXIZgRS2wLx72 u/Hp045rOf8B81V9SUx/WUty9x2fSchC8VLhWqxLoM1mCoq71ckUL0W9PmBPUTLOqo/n SIod5Z7g5niW4T0dlYRtdWIBTr6AOgNgwxHegl5OjQaxQAG/OWnsPQpoIwGk78Gu7XOI E4vQ== X-Gm-Message-State: APjAAAVw/f1RLVcZcbqjZtxAY25jVTjAktxy5OT9txMDejZRs8CVkrYE VaBMZnfRdEKzrJxvMzLJydaq3EOTMp0N1jxbRA25tg== X-Received: by 2002:a62:4d03:: with SMTP id a3mr30832487pfb.2.1559561268802; Mon, 03 Jun 2019 04:27:48 -0700 (PDT) MIME-Version: 1.0 References: <20190506185207.31069-1-tmurphy@arista.com> <20190603105158.GL12745@8bytes.org> In-Reply-To: <20190603105158.GL12745@8bytes.org> From: Tom Murphy Date: Mon, 3 Jun 2019 12:27:37 +0100 Message-ID: Subject: Re: [PATCH v3 0/4] iommu/amd: Convert the AMD iommu driver to the dma-iommu api To: Joerg Roedel Cc: iommu@lists.linux-foundation.org, Tom Murphy , Will Deacon , Robin Murphy , Marek Szyprowski , Kukjin Kim , Krzysztof Kozlowski , David Woodhouse , Andy Gross , David Brown , Matthias Brugger , Rob Clark , Heiko Stuebner , Gerald Schaefer , Thierry Reding , Jonathan Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-tegra@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 3, 2019 at 11:52 AM Joerg Roedel wrote: > > Hi Tom, > > On Mon, May 06, 2019 at 07:52:02PM +0100, Tom Murphy wrote: > > Convert the AMD iommu driver to the dma-iommu api. Remove the iova > > handling and reserve region code from the AMD iommu driver. > > Thank you for your work on this! I appreciate that much, but I am not > sure we are ready to make that move for the AMD and Intel IOMMU drivers > yet. > > My main concern right now is that these changes will add a per-page > table lock into the fast-path for dma-mapping operations. There has been > much work in the past to remove all locking from these code-paths and > make it scalable on x86. Where is the locking introduced? intel doesn't use a lock in it's iommu_map function: https://github.com/torvalds/linux/blob/f2c7c76c5d0a443053e94adb9f0918fa2fb85c3a/drivers/iommu/intel-iommu.c#L5302 because it cleverly uses cmpxchg64 to avoid using locks: https://github.com/torvalds/linux/blob/f2c7c76c5d0a443053e94adb9f0918fa2fb85c3a/drivers/iommu/intel-iommu.c#L900 And the locking in AMD's iommu_map function can be removed (and i have removed it in my patch set) because it does that same thing as intel: https://github.com/torvalds/linux/blob/f2c7c76c5d0a443053e94adb9f0918fa2fb85c3a/drivers/iommu/amd_iommu.c#L1486 Is there something I'm missing? > > The dma-ops implementations in the x86 IOMMU drivers have the benefit > that they can call their page-table manipulation functions directly and > without locks, because they can make the necessary assumptions. The > IOMMU-API mapping/unmapping path can't make these assumptions because it > is also used for non-DMA-API use-cases. > > So before we can move the AMD and Intel drivers to the generic DMA-API > implementation we need to solve this problem to not introduce new > scalability regressions. > > Regards, > > Joerg >