From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752635AbbJFPMF (ORCPT ); Tue, 6 Oct 2015 11:12:05 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:34369 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751443AbbJFPMD (ORCPT ); Tue, 6 Oct 2015 11:12:03 -0400 Subject: Re: [PATCH v3 0/3] uio: add MSI/MSI-X support to uio_pci_generic driver To: "Michael S. Tsirkin" , Vlad Zolotarov References: <1443991398-23761-1-git-send-email-vladz@cloudius-systems.com> <20151005221651-mutt-send-email-mst@redhat.com> <56138867.4000006@cloudius-systems.com> <20151006171940-mutt-send-email-mst@redhat.com> Cc: linux-kernel@vger.kernel.org, hjk@hansjkoch.de, corbet@lwn.net, gregkh@linuxfoundation.org, bruce.richardson@intel.com, gleb@cloudius-systems.com, stephen@networkplumber.org, alexander.duyck@gmail.com From: Avi Kivity Message-ID: <5613E4BE.6060802@cloudius-systems.com> Date: Tue, 6 Oct 2015 18:11:58 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151006171940-mutt-send-email-mst@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/06/2015 05:30 PM, Michael S. Tsirkin wrote: > On Tue, Oct 06, 2015 at 11:37:59AM +0300, Vlad Zolotarov wrote: >> Bus mastering is easily enabled from the user space (taken from DPDK code): >> >> static int >> pci_uio_set_bus_master(int dev_fd) >> { >> uint16_t reg; >> int ret; >> >> ret = pread(dev_fd, ®, sizeof(reg), PCI_COMMAND); >> if (ret != sizeof(reg)) { >> RTE_LOG(ERR, EAL, >> "Cannot read command from PCI config space!\n"); >> return -1; >> } >> >> /* return if bus mastering is already on */ >> if (reg & PCI_COMMAND_MASTER) >> return 0; >> >> reg |= PCI_COMMAND_MASTER; >> >> ret = pwrite(dev_fd, ®, sizeof(reg), PCI_COMMAND); >> if (ret != sizeof(reg)) { >> RTE_LOG(ERR, EAL, >> "Cannot write command to PCI config space!\n"); >> return -1; >> } >> >> return 0; >> } >> >> So, this is a non-issue. ;) > There might be valid reasons for DPDK to do this, e.g. if using VFIO. DPDK does this when using vfio, and when using uio_pci_generic. All of the network cards that DPDK supports require DMA. > I'm guessing it doesn't enable MSI though, does it? It does not enable MSI, because the main kernel driver used for interacting with the device, pci_uio_generic, does not support MSI. In some configurations, PCI INTA is not available, while MSI(X) is, hence the desire that pci_uio_generic support MSI. While it is possible that userspace malfunctions and accidentally programs MSI incorrectly, the risk is dwarfed by the ability of userspace to program DMA incorrectly. Under normal operation userspace programs tens of millions of DMA operations per second, while it never touches the MSI BARs (it is the kernel that programs them).