Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp694475imm; Wed, 13 Jun 2018 07:00:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKfBhp/wWUhzeszoR5rdyMiocZo08m0cfUso/Z28DAKdEjBkqGvpCqc0UZ06VZYcq9obQTU X-Received: by 2002:a17:902:a508:: with SMTP id s8-v6mr5395806plq.223.1528898433736; Wed, 13 Jun 2018 07:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528898433; cv=none; d=google.com; s=arc-20160816; b=mdjaHdf4fqwXBrOwZ4dVp3pfluaMyoxIu7Bt6k+hhIIJcBaU+QaLpmVxOc3fNv3wFr He226CcKLX7Q8+R/BTdf5QbpyY9q1D8W31bFbwsEmswuBxsVtawUF/UGPGk3voRslZpH xWWTsy+3WVwB2rx0mKTvbl3nqcMW9yrguFqDaozVvnyBLRLGMJpyllwMzTSOgsRCEwUD 8DA+CEHB6S76HvqbNPLckN6Psx3IElQw2/wtHQ72Th7gD4ohKrfjvQ0wNEAG1oLfEHD9 tQ1YDO6ft7AtxrPGDcMLf5spiRz39TNiEwUiXAJb73zNR6XhbBl9yN8PW+3tYXwmR1Qr SMAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=j5qWD2WN0ebB4utuFuYy5Q025fH2KTk7rTiXNWvVROs=; b=OUbEN6KrXlQtr4Elhz9WZOl1nu05bvnykfjIyR3KOMGTg0XtiduAGdB9BCDa/2ea1b ovGm1rocYWnCrTlTMziKLX+frdv2BoTCLyH28vPrmzk5WvyCqzYwFEHx/IjcLi6tSE93 ksb0v83rdGUWoawXrdPQzykdCTtzNke0EhprGC0UNoxb+vKtPi9ML+5TmzifOEGDU771 dG/5E0VJgUX//A4UStIs85FOIkn8aesokJDzdsX8jyM+ij/eRqCHwCLk6uLj1xr31fGG BYP/2u8R4dTcwo3oSjrwfK9dR5r/Ptw53gryVdbwW7227hgmMq1EwNbqcjo03uPOYiJq YkAA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z63-v6si2539078pgb.456.2018.06.13.07.00.18; Wed, 13 Jun 2018 07:00:33 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935736AbeFMN7r (ORCPT + 99 others); Wed, 13 Jun 2018 09:59:47 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39730 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934436AbeFMN7o (ORCPT ); Wed, 13 Jun 2018 09:59:44 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A88F0818BAED; Wed, 13 Jun 2018 13:59:43 +0000 (UTC) Received: from redhat.com (ovpn-122-133.rdu2.redhat.com [10.10.122.133]) by smtp.corp.redhat.com (Postfix) with SMTP id 2869F2166BB2; Wed, 13 Jun 2018 13:59:42 +0000 (UTC) Date: Wed, 13 Jun 2018 16:59:41 +0300 From: "Michael S. Tsirkin" To: Christoph Hellwig Cc: Benjamin Herrenschmidt , Ram Pai , robh@kernel.org, pawel.moll@arm.com, Tom Lendacky , aik@ozlabs.ru, jasowang@redhat.com, cohuck@redhat.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, joe@perches.com, "Rustad, Mark D" , david@gibson.dropbear.id.au, linuxppc-dev@lists.ozlabs.org, elfring@users.sourceforge.net, Anshuman Khandual Subject: Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices Message-ID: <20180613164500-mutt-send-email-mst@kernel.org> References: <20180522063317.20956-1-khandual@linux.vnet.ibm.com> <20180523213703-mutt-send-email-mst@kernel.org> <20180524072104.GD6139@ram.oc3035372033.ibm.com> <0c508eb2-08df-3f76-c260-90cf7137af80@linux.vnet.ibm.com> <20180531204320-mutt-send-email-mst@kernel.org> <20180607052306.GA1532@infradead.org> <20180607185234-mutt-send-email-mst@kernel.org> <20180611023909.GA5726@ram.oc3035372033.ibm.com> <07b804fccd7373c650be79ac9fa77ae7f2375ced.camel@kernel.crashing.org> <20180613074141.GA12033@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180613074141.GA12033@infradead.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 13 Jun 2018 13:59:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 13 Jun 2018 13:59:43 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 13, 2018 at 12:41:41AM -0700, Christoph Hellwig wrote: > On Mon, Jun 11, 2018 at 01:29:18PM +1000, Benjamin Herrenschmidt wrote: > > At the risk of repeating myself, let's just do the first pass which is > > to switch virtio over to always using the DMA API in the actual data > > flow code, with a hook at initialization time that replaces the DMA ops > > with some home cooked "direct" ops in the case where the IOMMU flag > > isn't set. > > > > This will be equivalent to what we have today but avoids having 2 > > separate code path all over the driver. > > > > Then a second stage, I think, is to replace this "hook" so that the > > architecture gets a say in the matter. > > I don't think we can actually use dma_direct_ops. It still allows > architectures to override parts of the dma setup, which virtio seems > to blindly assume phys == dma and not cache flushing. > > I think the right way forward is to either add a new > VIRTIO_F_IS_PCI_DEVICE (or redefine the existing iommu flag if deemed > possible). Given this is exactly what happens now, this seems possible, but maybe we want a non-PCI specific name. > And then make sure recent qemu always sets it. I don't think that part is going to happen, sorry. Hypervisors can set it when they *actually have* a real PCI device. People emulate systems which have a bunch of overhead in the DMA API which is required for real DMA. Your proposal would double that overhead by first doing it in guest then re-doing it in host. I don't think it's justified when 99% of the world doesn't need it. -- MST