Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp838015ybh; Tue, 21 Jul 2020 09:05:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk9+E10oV4RhCp5VfuYpl6E8uhVHgSOeQqvw+DGCFfyC1qh9tN/bBrs1LvysbycAlk+Gr8 X-Received: by 2002:a17:906:5657:: with SMTP id v23mr26754495ejr.196.1595347521188; Tue, 21 Jul 2020 09:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595347521; cv=none; d=google.com; s=arc-20160816; b=GaON5J+Twc7hSsHigLTxCqBbZNG5Y8m3RJgnNVGjVEHsoLREmIl0nhi5PbDYUWkD/s x5jN5Cc+XzDTeMzbObVwYbmn4tblwtflw1+fEMvEMPxV1bHvNajYml2DHjXfkRJCwqcc wglHLS9QKsKBoVNfXW0+TrPBCtEMFRECL7O+4/4qeIJoxCxTq0KvPrdPB9ruhEQafyna dbUWjlODGFF0kvjTswu9NE5pKemlymk5V3kJODhG/TwxLPlqaxfpPl8PVFkDjI6mofl0 PTSqMETTvpRmTFbQzPmz25MvgbKGcRJWhBtl9D8BRiVXayByxZBzwDJHIwtLdkucdQq0 iJ2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=mhggbLY1VTpeu2Up1U4vmaslbtl2IqrRLqNyQ5iA9WE=; b=BQXLXKznczBv0/YLg6U2wFh4QOi1FLHL5CuJoN2k2nJAcrwV3s6sive2/pgSRW0Iz+ vObPc0IfVnH5ae/bL6LxY+rLFrahECtBMak3yTDBOIon8w6wr97PJTj4wImSU736ZqTd w+LUqr1CeuAoz07xH97PCJwmU4uyICDVGGO8USeaCzC18u6p0Gk3VDkXveCsmO2BJpjF ijZuTyRHUt9xc17WLV28s+q58J1N0msANJ0LGkAzg69aejc9ovKrsmVHfzTpolg3cVoI cTdd3kO/sHohcctml/lSAqXdEtTSiKeOZorcAtGTmHvtlG+bkoumkni1uH3T+ktDcK5H Xwgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id ov7si11771598ejb.224.2020.07.21.09.04.58; Tue, 21 Jul 2020 09:05:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730283AbgGUQDt (ORCPT + 99 others); Tue, 21 Jul 2020 12:03:49 -0400 Received: from mga11.intel.com ([192.55.52.93]:9860 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbgGUQDt (ORCPT ); Tue, 21 Jul 2020 12:03:49 -0400 IronPort-SDR: mT8yMac5VWnWmqcNRDp7w8T5XNLSma1VsrjjGNI8gsY6K5qZLaIWmqeygrQPkjnipyaO91Mqt/ N8+YtquiNJww== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="148100754" X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="148100754" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 09:03:48 -0700 IronPort-SDR: 0oyIdad1lxDFJNYjQZK8aIhpAdXIs04RAE6PYdWPXVFD8P0lQpJHwvS0/LaL43Mmz4E/cYPjqi /e3oekyyyIRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,379,1589266800"; d="scan'208";a="310293846" Received: from djiang5-desk3.ch.intel.com ([143.182.136.137]) by fmsmga004.fm.intel.com with ESMTP; 21 Jul 2020 09:03:47 -0700 Subject: [PATCH RFC v2 14/18] dmaengine: idxd: add mdev type as a new wq type From: Dave Jiang To: vkoul@kernel.org, megha.dey@intel.com, maz@kernel.org, bhelgaas@google.com, rafael@kernel.org, gregkh@linuxfoundation.org, tglx@linutronix.de, hpa@zytor.com, alex.williamson@redhat.com, jacob.jun.pan@intel.com, ashok.raj@intel.com, jgg@mellanox.com, yi.l.liu@intel.com, baolu.lu@intel.com, kevin.tian@intel.com, sanjay.k.kumar@intel.com, tony.luck@intel.com, jing.lin@intel.com, dan.j.williams@intel.com, kwankhede@nvidia.com, eric.auger@redhat.com, parav@mellanox.com, jgg@mellanox.com, rafael@kernel.org, dave.hansen@intel.com, netanelg@mellanox.com, shahafs@mellanox.com, yan.y.zhao@linux.intel.com, pbonzini@redhat.com, samuel.ortiz@intel.com, mona.hossain@intel.com Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org Date: Tue, 21 Jul 2020 09:03:47 -0700 Message-ID: <159534742756.28840.2462836305382720334.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <159534667974.28840.2045034360240786644.stgit@djiang5-desk3.ch.intel.com> References: <159534667974.28840.2045034360240786644.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add "mdev" wq type and support helpers. The mdev wq type marks the wq to be utilized as a VFIO mediated device. Signed-off-by: Dave Jiang Reviewed-by: Kevin Tian --- drivers/dma/idxd/idxd.h | 2 ++ drivers/dma/idxd/sysfs.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h index 1e4d9ec9b00d..1f03019bb45d 100644 --- a/drivers/dma/idxd/idxd.h +++ b/drivers/dma/idxd/idxd.h @@ -71,6 +71,7 @@ enum idxd_wq_type { IDXD_WQT_NONE = 0, IDXD_WQT_KERNEL, IDXD_WQT_USER, + IDXD_WQT_MDEV, }; struct idxd_cdev { @@ -308,6 +309,7 @@ void idxd_cleanup_sysfs(struct idxd_device *idxd); int idxd_register_driver(void); void idxd_unregister_driver(void); struct bus_type *idxd_get_bus_type(struct idxd_device *idxd); +bool is_idxd_wq_mdev(struct idxd_wq *wq); /* device interrupt control */ irqreturn_t idxd_irq_handler(int vec, void *data); diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c index cdf2b5aac314..d3b0a95b0d1d 100644 --- a/drivers/dma/idxd/sysfs.c +++ b/drivers/dma/idxd/sysfs.c @@ -14,6 +14,7 @@ static char *idxd_wq_type_names[] = { [IDXD_WQT_NONE] = "none", [IDXD_WQT_KERNEL] = "kernel", [IDXD_WQT_USER] = "user", + [IDXD_WQT_MDEV] = "mdev", }; static void idxd_conf_device_release(struct device *dev) @@ -69,6 +70,11 @@ static inline bool is_idxd_wq_cdev(struct idxd_wq *wq) return wq->type == IDXD_WQT_USER; } +inline bool is_idxd_wq_mdev(struct idxd_wq *wq) +{ + return wq->type == IDXD_WQT_MDEV ? true : false; +} + static int idxd_config_bus_match(struct device *dev, struct device_driver *drv) { @@ -1095,8 +1101,9 @@ static ssize_t wq_type_show(struct device *dev, return sprintf(buf, "%s\n", idxd_wq_type_names[IDXD_WQT_KERNEL]); case IDXD_WQT_USER: - return sprintf(buf, "%s\n", - idxd_wq_type_names[IDXD_WQT_USER]); + return sprintf(buf, "%s\n", idxd_wq_type_names[IDXD_WQT_USER]); + case IDXD_WQT_MDEV: + return sprintf(buf, "%s\n", idxd_wq_type_names[IDXD_WQT_MDEV]); case IDXD_WQT_NONE: default: return sprintf(buf, "%s\n", @@ -1123,6 +1130,8 @@ static ssize_t wq_type_store(struct device *dev, wq->type = IDXD_WQT_KERNEL; else if (sysfs_streq(buf, idxd_wq_type_names[IDXD_WQT_USER])) wq->type = IDXD_WQT_USER; + else if (sysfs_streq(buf, idxd_wq_type_names[IDXD_WQT_MDEV])) + wq->type = IDXD_WQT_MDEV; else return -EINVAL;