Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5771371imm; Wed, 12 Sep 2018 10:49:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbfzWeLEGWhToWotWFP5xF40ULF+7n0FeHsqv8ThCKHSWoLZiYyq8ytpzF0Or/4PyyKi9/2 X-Received: by 2002:a63:6746:: with SMTP id b67-v6mr3557182pgc.330.1536774593300; Wed, 12 Sep 2018 10:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536774593; cv=none; d=google.com; s=arc-20160816; b=BDXkpdEpyN3FtCQ/rIdgmS4R1PvIQW74X53fzGkD3fMd9DHf2DXUqU3nN/ft42W05B nVAYMOLBYOhh72+sugpeMtJYahAdmKp8oTAgACpkBbYnkjooInddW58+V+nEGGZj/wj9 D0KyCBTCqJSFzBCRyP0bZ8m7yw2Rs4lWyPvoptvgh6dPy/xnVvUMEU5Hk9mVB7lSxYXM 1VJGIP6ktFjcMvQmv5GCxvpuW9ps5j90y+OlPArBU+mwnJWdBhUzpS4fjxmLAe33mFy+ vUdqYVm5wHRRpnAblXlXVwoMB1cdaMGs+f00XtqDP09Khcuwolji5gJl0J7Sq+kdjsxN 36yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=pLCoNnS3BqC6S7zQnRg3W9NlcPCqQhsl+UCV0VF0I8M=; b=AGBk7yif6Rknd0xj295KwmezwcqxS932whmvmeyJ5ghkeAFe+tGpSoPDoaPI2TN86S JgC5UDzORH4VtBVsu2nduQnurstcgDmeVXpj0B1pVWfwvH1vksJtzv0XbsB8wjcPcaY4 jkHkKn+Je495jCKJlXCY0Ljn5QWXoqaDmI2TejHpcrsg5GOFUjD5bepm3GTzOe14o7Xc eYNQcgfkMAOwlpSBN0zbxK4/Ra5OGsVoIuRHDZYbrjMAwpLI5oKrSMQdB5pTGVv21apE PhBlQtt9wNanbNfX4ZEUDoiygoVHrdpEkxcWKmGUFBa24d1LLxBDidU1woznPpDpFk7m NriA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19-v6si1567046plp.25.2018.09.12.10.49.37; Wed, 12 Sep 2018 10:49:53 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728048AbeILWxV (ORCPT + 99 others); Wed, 12 Sep 2018 18:53:21 -0400 Received: from mga11.intel.com ([192.55.52.93]:4927 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbeILWxV (ORCPT ); Wed, 12 Sep 2018 18:53:21 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2018 10:47:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,365,1531810800"; d="scan'208";a="256643494" Received: from araj-mobl1.jf.intel.com ([10.7.201.29]) by orsmga005.jf.intel.com with ESMTP; 12 Sep 2018 10:46:19 -0700 Date: Wed, 12 Sep 2018 10:46:19 -0700 From: "Raj, Ashok" To: Alex Williamson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Joerg Roedel , Bjorn Helgaas , Gage Eads , Ashok Raj Subject: Re: [PATCH] vfio/pci: Some buggy virtual functions incorrectly report 1 for intx. Message-ID: <20180912174618.GA19551@araj-mobl1.jf.intel.com> References: <1533843426-79170-1-git-send-email-ashok.raj@intel.com> <20180809134417.50de7fe7@t450s.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180809134417.50de7fe7@t450s.home> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 09, 2018 at 01:44:17PM -0600, Alex Williamson wrote: > On Thu, 9 Aug 2018 12:37:06 -0700 > Ashok Raj wrote: > > > PCI_INTERRUPT_PIN should always read 0 for SRIOV Virtual Functions. > > > > Some SRIOV devices have some bugs in RTL and VF's end up reading 1 > > instead of 0 for the PIN. > > Hi Ashok, > > One question, can we identify which VFs are known to have this issue so > that users (and downstreams) can know how to prioritize this patch? Hi Alex Sorry it took some time to hunt this down. The offending VF has a device ID : 0x270C The corresponding PF has a device ID: 0x270B. > Thanks, > > Alex > > > Since this is a spec required value, rather than having a device specific > > quirk, we could fix it permanently in vfio. > > > > Reworked suggestions from Alex https://lkml.org/lkml/2018/7/16/1052 > > > > Reported-by: Gage Eads > > Tested-by: Gage Eads > > Signed-off-by: Ashok Raj > > Cc: kvm@vger.kernel.org > > Cc: linux-kernel@vger.kernel.org > > Cc: iommu@lists.linux-foundation.org > > Cc: Joerg Roedel > > Cc: Bjorn Helgaas > > Cc: Gage Eads > > --- > > drivers/vfio/pci/vfio_pci.c | 12 +++++++++--- > > drivers/vfio/pci/vfio_pci_config.c | 3 ++- > > 2 files changed, 11 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > > index b423a30..32943dd 100644 > > --- a/drivers/vfio/pci/vfio_pci.c > > +++ b/drivers/vfio/pci/vfio_pci.c > > @@ -433,10 +433,16 @@ static int vfio_pci_get_irq_count(struct vfio_pci_device *vdev, int irq_type) > > { > > if (irq_type == VFIO_PCI_INTX_IRQ_INDEX) { > > u8 pin; > > - pci_read_config_byte(vdev->pdev, PCI_INTERRUPT_PIN, &pin); > > - if (IS_ENABLED(CONFIG_VFIO_PCI_INTX) && !vdev->nointx && pin) > > - return 1; > > + /* > > + * INTx must be 0 for all VF's. Enforce that for all > > + * VF's since this is a spec requirement. > > + */ > > + if (!IS_ENABLED(CONFIG_VFIO_PCI_INTX) || vdev->nointx || > > + vdev->pdev->is_virtfn) > > + return 0; > > > > + pci_read_config_byte(vdev->pdev, PCI_INTERRUPT_PIN, &pin); > > + return (pin ? 1 : 0); > > } else if (irq_type == VFIO_PCI_MSI_IRQ_INDEX) { > > u8 pos; > > u16 flags; > > diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c > > index 115a36f..e36b7c3 100644 > > --- a/drivers/vfio/pci/vfio_pci_config.c > > +++ b/drivers/vfio/pci/vfio_pci_config.c > > @@ -1676,7 +1676,8 @@ int vfio_config_init(struct vfio_pci_device *vdev) > > *(__le16 *)&vconfig[PCI_DEVICE_ID] = cpu_to_le16(pdev->device); > > } > > > > - if (!IS_ENABLED(CONFIG_VFIO_PCI_INTX) || vdev->nointx) > > + if (!IS_ENABLED(CONFIG_VFIO_PCI_INTX) || vdev->nointx || > > + pdev->is_virtfn) > > vconfig[PCI_INTERRUPT_PIN] = 0; > > > > ret = vfio_cap_init(vdev); >