Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp702129imm; Wed, 13 Jun 2018 07:04:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ2F95rXs0VLZKVc/4RmTXhZG9Bi0+D6KNYMrTAaNfAllr13yO92DXtjqeL1JpRHX3eU7Fx X-Received: by 2002:a17:902:585c:: with SMTP id f28-v6mr5392993plj.206.1528898687584; Wed, 13 Jun 2018 07:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528898687; cv=none; d=google.com; s=arc-20160816; b=Td69o7IUDa3lF4N1KAnZo98d51jaeF1MwNS22JlRQux/+ATe6SHO87gFbpbNllh5BL QzussrEgpMPpO2bNNcpPVQ1LJJiahQMlspq6ePljJSkNbqLtARWBi1/tJs8+P6j3gl3p 5t1tEbXd1fSYtuuowOsYSbnBkdlEb0LQ5LvO0qSnbU7H9rboyJubQ9gHwJ1gns5MeYPK XAs6O4VV7jOpLig4MM5ZzV4RjxwkH+au/bIVur6P1p9ZMqrZhGHzbFJ5XDzmEsgMRu1E VfLwCd7DmjvCY1tk387KgbblxS7sGh6w8cwlV8Tja1/wMSy3LXIEXFXCLvDpkZAOHVNe 31Mg== 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=+p30eSzNIgw7AC2XzYgRUyN1OMb59wockBh5dYyH4F0=; b=d8VlhZk6QyBJ9yqJrP3GJF1K+XshpZuMGBSbbVSQ3nNN7IjBj5YXHl/oalYWVtjcxA 1LAE7uYBEsxnei5aQMFqIBrpFyE1quuH0OBmZDPA1wdwZE6NMpK6bjJs9tIA20FWHGCG 31adkaVr+ZVQnpIxBt76uViaYHCdXnwl+CrFCnbUl6CrEoZpkVy55V3qLdmZysQbFTAZ CMz9YX0NNzh2QuUx5a90OGaxKOCI0drsESAaZcohlwTuy0Pm81lnHQVOjarVgVcDG99o 06crplf44AU+Fc8bP0dlFdXZav95nYqMlwR5mFBo4ZvT4BISl+TR4LL1aB2DOITWtAR0 Q5YQ== 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 s7-v6si2431607pgq.230.2018.06.13.07.04.32; Wed, 13 Jun 2018 07:04:47 -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 S935790AbeFMODH (ORCPT + 99 others); Wed, 13 Jun 2018 10:03:07 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48812 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935348AbeFMODG (ORCPT ); Wed, 13 Jun 2018 10:03:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B9E7401EF08; Wed, 13 Jun 2018 14:03:05 +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 314791C65F; Wed, 13 Jun 2018 14:03:04 +0000 (UTC) Date: Wed, 13 Jun 2018 17:03:03 +0300 From: "Michael S. Tsirkin" To: Benjamin Herrenschmidt Cc: Ram Pai , Christoph Hellwig , 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: <20180613170050-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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <07b804fccd7373c650be79ac9fa77ae7f2375ced.camel@kernel.crashing.org> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 13 Jun 2018 14:03:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 13 Jun 2018 14:03:05 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 Mon, Jun 11, 2018 at 01:29:18PM +1000, Benjamin Herrenschmidt wrote: > On Sun, 2018-06-10 at 19:39 -0700, Ram Pai wrote: > > > > However if the administrator > > ignores/forgets/deliberatey-decides/is-constrained to NOT enable the > > flag, virtio will not be able to pass control to the DMA ops associated > > with the virtio devices. Which means, we have no opportunity to share > > the I/O buffers with the hypervisor/qemu. > > > > How do you suggest, we handle this case? > > 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. I'm not sure I understand all of the details, will have to see the patch, but superficially it sounds good to me. > 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. > > Basically, something like: > > arch_virtio_update_dma_ops(pci_dev, qemu_direct_mode). > > IE, virtio would tell the arch whether the "other side" is in fact QEMU > in a mode that bypasses the IOMMU and is cache coherent with the guest. > This is our legacy "qemu special" mode. If the performance is > sufficient we may want to deprecate it over time and have qemu enable > the iommu by default but we still need it. > > A weak implementation of the above will be provied that just puts in > the direct ops when qemu_direct_mode is set, and thus provides today's > behaviour on any arch that doesn't override it. If the flag is not set, > the ops are left to whatever the arch PCI layer already set. > > This will provide the opportunity for architectures that want to do > something special, such as in our case, when we want to force even the > "qemu_direct_mode" to go via bounce buffers, to put our own ops in > there, while retaining the legacy behaviour otherwise. > > It also means that the "gunk" is entirely localized in that one > function, the rest of virtio just uses the DMA API normally. > > Christoph, are you actually hacking "stage 1" above already or should > we produce patches ? > > Cheers, > Ben.