From patchwork Sat Aug 5 06:37:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 9882915 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCFEE602B6 for ; Sat, 5 Aug 2017 06:40:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4A80201F3 for ; Sat, 5 Aug 2017 06:40:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9AD227CEA; Sat, 5 Aug 2017 06:40:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DDD0288C9 for ; Sat, 5 Aug 2017 06:40:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751144AbdHEGkL (ORCPT ); Sat, 5 Aug 2017 02:40:11 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36450 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751394AbdHEGi3 (ORCPT ); Sat, 5 Aug 2017 02:38:29 -0400 Received: by mail-pg0-f67.google.com with SMTP id y129so3669970pgy.3; Fri, 04 Aug 2017 23:38:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wT6Z8Ump47MiT4EEBTAtjxYUF8sp6q0gqOBIi/4sWNE=; b=BBqzBbVM0WcLRMsl0kJu+ilHe1rvFK5mAK9B/soyiK5AHgdA4BLxVdG2iJ2XEHWMyO Z3U4NmzgOrNUv5izAdUcNzlFwm6Ng1LaGftNEFkKA7gliPlW2RjLJ7jRLvpya/R8H0sr DBF8Y9jU8lYKjYm5anSG+ETiH+9A8izzNPnHedWM9OqSm555FIKlSi5l7znC07ixKEvT 5JWjJRA15+x+n7z75qcFB19b8Y8NRuwWMuH1UHWpJGThk2PdqmqM+b2cMu4I2BdnnGkB HBO8MDkEXUL39uReU9eOCUMERU3XMmu3MHrrqROlup3HAeMpu9UBkOpUcdZe4OOhjqVR ouSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=wT6Z8Ump47MiT4EEBTAtjxYUF8sp6q0gqOBIi/4sWNE=; b=uOE4vMXVUW/4oqxzQGEM0E/cLJJpdmUqNKHcjwsU2xYD4LNeyAHHVW4tQTgfDtZ4Q0 90XcD+8+SKP5RdASy8r1WDI8AVdg9yKPGL+uPXJ4ZrRskLbqMwKKDJIxiUE/0xzULmFm wha/aWdycRsVucHo0Eml0y7hdMvkA6f9mj40aUMA3ttJetUJWCRwKikLPV2k87TgcsxB bRwu3p04rG668CIAZ9RXMDIb4jHIKZX1AkmnwMumm9lJk1ikiB/luQmzACxEHWCH7Vp2 eVbyRfhDBGUSMMXZs1VYkk3lAeM/DBMNLnE9kHz/6Ih958xlC9oJVD5vA8UAFYfEwJIg /+Ag== X-Gm-Message-State: AIVw110DbAz++Qj/u2nQoFSDuIJ0A4BKrcBiftDe7lHad1IGljFvXM75 Yy7USZcXMidJMw== X-Received: by 10.98.43.78 with SMTP id r75mr4913925pfr.269.1501915109415; Fri, 04 Aug 2017 23:38:29 -0700 (PDT) Received: from dhcp-whq-twvpn-3-vpnpool-10-159-238-106.vpn.oracle.com (c-69-181-250-163.hsd1.ca.comcast.net. [69.181.250.163]) by smtp.gmail.com with ESMTPSA id j124sm6131387pfc.78.2017.08.04.23.38.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 23:38:28 -0700 (PDT) From: Yinghai Lu To: Bjorn Helgaas Cc: Linus Torvalds , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH 04/10] PCI: extend pci device match_driver state Date: Fri, 4 Aug 2017 23:37:55 -0700 Message-Id: <20170805063801.15880-5-yinghai@kernel.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170805063801.15880-1-yinghai@kernel.org> References: <20170805063801.15880-1-yinghai@kernel.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change it from false/true to -1/0/1. If it is set from -1, then it will never get change to 1 later. For PCI_TEST, the simulated device does not have realy function support except bus number and BAR setting. Signed-off-by: Yinghai Lu --- drivers/iommu/amd_iommu_init.c | 2 +- drivers/pci/bus.c | 3 ++- drivers/pci/pci-driver.c | 2 +- drivers/pci/probe.c | 2 +- include/linux/pci.h | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 3723037..6d706ca 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -1558,7 +1558,7 @@ static int iommu_init_pci(struct amd_iommu *iommu) return -ENODEV; /* Prevent binding other PCI device drivers to IOMMU devices */ - iommu->dev->match_driver = false; + iommu->dev->match_driver = 0; pci_read_config_dword(iommu->dev, cap_ptr + MMIO_CAP_HDR_OFFSET, &iommu->cap); diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index bc56cf1..e2c0bda 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -322,7 +322,8 @@ void pci_bus_add_device(struct pci_dev *dev) pci_proc_attach_device(dev); pci_bridge_d3_update(dev); - dev->match_driver = true; + if (dev->match_driver == 0) + dev->match_driver = 1; retval = device_attach(&dev->dev); if (retval < 0 && retval != -EPROBE_DEFER) { dev_warn(&dev->dev, "device attach failed (%d)\n", retval); diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index d51e873..c67b872 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -1373,7 +1373,7 @@ static int pci_bus_match(struct device *dev, struct device_driver *drv) struct pci_driver *pci_drv; const struct pci_device_id *found_id; - if (!pci_dev->match_driver) + if (pci_dev->match_driver != 1) return 0; pci_drv = to_pci_driver(drv); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 1811016..34ffbdf 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2021,7 +2021,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) pci_set_msi_domain(dev); /* Notifier could use PCI capabilities */ - dev->match_driver = false; + dev->match_driver = 0; ret = device_add(&dev->dev); WARN_ON(ret < 0); } diff --git a/include/linux/pci.h b/include/linux/pci.h index c58a635..6e81d64 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -344,7 +344,7 @@ struct pci_dev { unsigned int irq; struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ - bool match_driver; /* Skip attaching driver */ + int match_driver; /* Skip attaching driver */ /* These fields are used by common fixups */ unsigned int transparent:1; /* Subtractive decode PCI bridge */ unsigned int multifunction:1;/* Part of multi-function device */