Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9671860imu; Wed, 5 Dec 2018 08:27:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/XDLuQ9+/vCvYamrlBoa3DUo8Qa2BXKSnwQJ3MhtFUb1aukrqVmJYgaPiJpx4wVrCMfsmOU X-Received: by 2002:a63:990a:: with SMTP id d10mr19976780pge.279.1544027276550; Wed, 05 Dec 2018 08:27:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544027276; cv=none; d=google.com; s=arc-20160816; b=wwdGiqqNNTi+Pabc4tJrvd6KXYobkF4z2EeTyOcc+5iEdfdFunzOIB+E6u6rGF+fnI qyNl16yEKMX4HgkNiP6RILup8PevaSTTQvQ2QmT2VlMaKQcbqD4QGuSHhFD0Ch599ImG fhDJpp8F9CF+jc0i2bPG2ZiajT068/7s6vbo6H/CMGZZSDD7tICswq4jIze1Al/SX8Fn gQepYtLYwK12cfxh3UtAHnj0c26lf+EdX1kALyBbRyPd2XA4FRYeO09E7yF2z4/VbDFQ Ft9+bnNrEHEqRM7tZL9giBaP3oTWbthQhZtUW8sIDxFEqL5HwZS2F3KtQP5ak+dWnTJc Qbww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:in-reply-to:references :subject:cc:to:from:date:message-id; bh=37LWmRBpsCE36BE8yRePg+E6alyf1vxBNkYAqAlSQqw=; b=T63xnXY+xcAi9mN6IolmkNx2Xsexi1p78Nc/9MbAI9vdVNHhemdjX/z5GDeMUQWL4z +TqN8BSRNHQHZ9QrxwqRMRxeNvPLc/+hn9sgPT/LQlIqF6pLaCuZR/H4sIOUNouSi+86 6QOL59b1KsaE8rSz67da6n4TEYJQEFNRCrizaB0vGz3kDxMzkixblIwPmZkOy2bFrxdK zrsidM/KrkXNlV0a8qTtuBCEuqMEMUc5Oc6FcbBJc8kLDcXRfkn4DgZlOl9RtdyeghcG R7t8022uTtpJfDpi/9/MReCWVmvJUV/lYFBxBc23w/mABiamtHkzrendc9Jr2MY3+Wm4 KYgw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j187si21767397pfg.160.2018.12.05.08.27.40; Wed, 05 Dec 2018 08:27:56 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728293AbeLEQ0j convert rfc822-to-8bit (ORCPT + 99 others); Wed, 5 Dec 2018 11:26:39 -0500 Received: from prv1-mh.provo.novell.com ([137.65.248.33]:49953 "EHLO prv1-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727177AbeLEQ0j (ORCPT ); Wed, 5 Dec 2018 11:26:39 -0500 Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Wed, 05 Dec 2018 09:26:37 -0700 Message-Id: <5C07FC380200007800203394@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.1.0 Date: Wed, 05 Dec 2018 09:26:32 -0700 From: "Jan Beulich" To: "Chao Gao" Cc: "Roger Pau Monne" , "Jia-Ju Bai" , "Stefano Stabellini" , "xen-devel" , "Boris Ostrovsky" , "Juergen Gross" , Subject: Re: [PATCH] xen: xen-pciback: Reset MSI-X state when exposing a device References: <1543976357-1053-1-git-send-email-chao.gao@intel.com> In-Reply-To: <1543976357-1053-1-git-send-email-chao.gao@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> On 05.12.18 at 03:19, wrote: > --- a/drivers/xen/xen-pciback/pci_stub.c > +++ b/drivers/xen/xen-pciback/pci_stub.c > @@ -87,6 +87,55 @@ static struct pcistub_device *pcistub_device_alloc(struct pci_dev *dev) > return psdev; > } > > +/* > + * Reset Xen internal MSI-X state by invoking PHYSDEVOP_{release, prepare}_msix. > + */ > +int pcistub_msix_reset(struct pci_dev *dev) > +{ > +#ifdef CONFIG_PCI_MSI > + if (dev->msix_cap) { > + struct physdev_pci_device ppdev = { > + .seg = pci_domain_nr(dev->bus), > + .bus = dev->bus->number, > + .devfn = dev->devfn > + }; > + int err; > + u16 val; > + > + /* > + * Do a write first to flush Xen's internal state to hardware > + * such that the following read can infer whether MSI-X maskall > + * bit is set by Xen. > + */ > + pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &val); > + pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, val); > + > + pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &val); > + if (!(val & PCI_MSIX_FLAGS_MASKALL)) > + return 0; I'm agreeing with prior comments: I don't see why you need this conditional. > + pr_info("Reset MSI-X state for device %04x:%02x:%02x.%d\n", > + ppdev.seg, ppdev.bus, PCI_SLOT(ppdev.devfn), > + PCI_FUNC(ppdev.devfn)); > + > + err = HYPERVISOR_physdev_op(PHYSDEVOP_release_msix, &ppdev); > + if (err) { > + dev_warn(&dev->dev, "MSI-X release failed (%d)\n", > + err); > + return err; > + } > + > + err = HYPERVISOR_physdev_op(PHYSDEVOP_prepare_msix, &ppdev); > + if (err) { > + dev_err(&dev->dev, "MSI-X preparation failed (%d)\n", > + err); Please can you make both log messages distinguishable from the pre-existing ones, to aid diagnosis of possible probelms? Jan