From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758824AbcG1V2a (ORCPT ); Thu, 28 Jul 2016 17:28:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46234 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758526AbcG1V22 (ORCPT ); Thu, 28 Jul 2016 17:28:28 -0400 Date: Fri, 29 Jul 2016 00:28:23 +0300 From: "Michael S. Tsirkin" To: Christoph Hellwig Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Jason Wang Subject: Re: [PATCH v4] virtio: new feature to detect IOMMU device quirk Message-ID: <20160729001244-mutt-send-email-mst@kernel.org> References: <1469659378-15957-1-git-send-email-mst@redhat.com> <20160728065918.GA22392@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160728065918.GA22392@infradead.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 28 Jul 2016 21:28:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 27, 2016 at 11:59:18PM -0700, Christoph Hellwig wrote: > Again, this is still the wrong way around. A "noiommu" feature is a > quirk and should not be the default. Christoph, I'm not sure what you mean by the default here. We read a register from the device (bit 33 in the feature qword) and act on it. The specific register value is 0 on noiommu quirky devices (it happened to be that way in the past), and 1 on clean iommu devices. static bool vring_use_dma_api(struct virtio_device *vdev) { + if (virtio_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) + return true; + + /* Otherwise, we are left to guess. */ As a hypothesis, do you object to use of virtio_has_feature? Yes this might be confusing but in fact that is just testing a cached register bit: at init time we read it: device_features = dev->config->get_features(dev); .... vdev->features = device_features and later return vdev->features & BIT_ULL(fbit); I'll add a comment clarifying that in the next version. -- MST