From patchwork Mon Mar 30 21:27:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 1264324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48rlsM5yl8z9sRR for ; Tue, 31 Mar 2020 08:27:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729076AbgC3V1C (ORCPT ); Mon, 30 Mar 2020 17:27:02 -0400 Received: from mga02.intel.com ([134.134.136.20]:41450 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728407AbgC3V1C (ORCPT ); Mon, 30 Mar 2020 17:27:02 -0400 IronPort-SDR: MUoy9PvJ8BKQmGQyQbsEW0lg7OFJoAjobQAsfh/wYCF/bPAknTBIDyORQ0rCgFE2kSinkJy3wV N0sFUTUp5RTg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2020 14:27:01 -0700 IronPort-SDR: olP2QS3KsmLaFeNlsXhAiE1rO0ai1i7Lm/qWvwgWcEJZpaTpV61AdP4RVCqIEg4a8YKxDMyA05 BuP8MrUNS6Ug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,325,1580803200"; d="scan'208";a="283774254" Received: from djiang5-desk3.ch.intel.com ([143.182.136.137]) by fmsmga002.fm.intel.com with ESMTP; 30 Mar 2020 14:27:01 -0700 Subject: [PATCH 2/6] device/pci: add cmdmem cap to pci_dev From: Dave Jiang To: vkoul@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, bhelgaas@google.com, gregkh@linuxfoundation.org, arnd@arndb.de Cc: linux-kernel@vger.kernel.org, x86@kernel.org, dmaengine@vger.kernel.org, dan.j.williams@intel.com, ashok.raj@intel.com, fenghua.yu@intel.com, linux-pci@vger.kernel.org, tony.luck@intel.com, jing.lin@intel.com, sanjay.k.kumar@intel.com Date: Mon, 30 Mar 2020 14:27:00 -0700 Message-ID: <158560362090.6059.1762280705382158736.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <158560290392.6059.16921214463585182874.stgit@djiang5-desk3.ch.intel.com> References: <158560290392.6059.16921214463585182874.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/unknown-version MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Since the current accelerator devices do not have standard PCIe capability enumeration for accepting ENQCMDS yet, for now an attribute of pdev->cmdmem has been added to struct pci_dev. Currently a PCI quirk must be used for the devices that have such cap until the PCI cap is standardized. Add a helper function to provide the check if a device supports the cmdmem capability. Such capability is expected to be added to PCIe device cap enumeration in the future. Signed-off-by: Dave Jiang --- drivers/base/core.c | 13 +++++++++++++ include/linux/device.h | 2 ++ include/linux/pci.h | 1 + 3 files changed, 16 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index dbb0f9130f42..cd9f5b040ed4 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "base.h" #include "power/power.h" @@ -3790,3 +3791,15 @@ int device_match_any(struct device *dev, const void *unused) return 1; } EXPORT_SYMBOL_GPL(device_match_any); + +bool device_supports_cmdmem(struct device *dev) +{ + struct pci_dev *pdev; + + if (!dev_is_pci(dev)) + return false; + + pdev = to_pci_dev(dev); + return pdev->cmdmem; +} +EXPORT_SYMBOL_GPL(device_supports_cmdmem); diff --git a/include/linux/device.h b/include/linux/device.h index fa04dfd22bbc..3e787d3de435 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -809,6 +809,8 @@ static inline bool dev_has_sync_state(struct device *dev) return false; } +extern bool device_supports_cmdmem(struct device *dev); + /* * High level routines for use by the bus drivers */ diff --git a/include/linux/pci.h b/include/linux/pci.h index 3840a541a9de..0bc5d581f20e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -422,6 +422,7 @@ struct pci_dev { unsigned int is_probed:1; /* Device probing in progress */ unsigned int link_active_reporting:1;/* Device capable of reporting link active */ unsigned int no_vf_scan:1; /* Don't scan for VFs after IOV enablement */ + unsigned int cmdmem:1; /* MMIO writes support command mem region with synchronous write notification */ pci_dev_flags_t dev_flags; atomic_t enable_cnt; /* pci_enable_device has been called */