Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1530445pxj; Fri, 21 May 2021 17:21:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUqUwOLrL1bHzrYDxiJ+dKU5lxRiQqNnruDsbTZfhE70bwJl+bEqxFNRONxGXE3XunSIh2 X-Received: by 2002:aa7:d543:: with SMTP id u3mr13793782edr.26.1621642866673; Fri, 21 May 2021 17:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621642866; cv=none; d=google.com; s=arc-20160816; b=P39yFwwUufGbW+EzMgWb5Oug/I7+2/Nmq2WOMEe5PBnKbsrfnd9yBKF/nrJUbDmP71 QJdxLKsf/PXt0aKFcNcGzTYZ4kMiSlwAx56u5P3rpEit/xqSbiUVwY/kHognH5MTjtOX +cCI22Env0ZGHFeMYW4e/76QQXdn+IxfRsfZV3jZofBwAFLqpae8YcRv7t/2GqhPZZx0 d8uiCTzI9jbYTWkHyxQTxZMIfxhGwE4l8obA0stjUSpbsXgpSqGBwZmNgfGwbyK6glEb dMHB0FIhZwlwJ9BZxDsndvJ/jdZYf0eLGj8MbXuxMuskv9FBL2DJcTpwdzEhk7yL9Bcm vBlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=4ok5MgtMDKlwYhtEurCnu39Ps/5LPYCNJye/4O44Yws=; b=gNRw91XY3MtpEWCNvhr0M895E1bHZWGr6E3TrDc00ZFWtCffZyDT2q++5F6lkuYdNy aV47Qh5tIcfgwD1nGYSskQ5Gg9es120X7vhZ2/5lDw8+yNP0XpVKBzOMawi609GMrVdU fHW2UScl5nQDEL17EpGF1Xy9N7LMyKzQuV/5yyHwZT3694NEy0psfVR4LipnkQzYJxWy HV1d4NTF7rYcrlzl6MBIjCbF1sakUjRehLBGFHm5hz/7id7oMtbBmlgqJmKY4bxpABkT G53E7t49kSTsLPP4LL00ICOIug31TQQShsDTPDfbhmqMqKq+KR2DNCBLEBw9Dezc1wHP zDxA== 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 l1si2193228edq.336.2021.05.21.17.20.43; Fri, 21 May 2021 17:21:06 -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 S230408AbhEVAUu (ORCPT + 99 others); Fri, 21 May 2021 20:20:50 -0400 Received: from mga12.intel.com ([192.55.52.136]:24108 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230147AbhEVAUo (ORCPT ); Fri, 21 May 2021 20:20:44 -0400 IronPort-SDR: hm9HCTDqIBeDvNqHD+FUXrRIZka0ro3BfpXV1f7quv/jgFNhR80wLeZHw+A22guLY4OL4hNwRC 4Lo/cQ13kDPw== X-IronPort-AV: E=McAfee;i="6200,9189,9991"; a="181210488" X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="181210488" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2021 17:19:19 -0700 IronPort-SDR: DnWxC3uEvh++a+mt4AeZTukx2h2qeH/QP/9ZlhvjTjrCsx7cpYdnIKVux4DyC3oIWDINQuMiCv UOfmjP6GTZ7g== X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="434499957" Received: from djiang5-desk3.ch.intel.com ([143.182.136.137]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2021 17:19:18 -0700 Subject: [PATCH v6 02/20] dmaengine: idxd: add external module driver support for dsa_bus_type From: Dave Jiang To: alex.williamson@redhat.com, kwankhede@nvidia.com, tglx@linutronix.de, vkoul@kernel.org, jgg@mellanox.com Cc: megha.dey@intel.com, jacob.jun.pan@intel.com, ashok.raj@intel.com, yi.l.liu@intel.com, baolu.lu@intel.com, kevin.tian@intel.com, sanjay.k.kumar@intel.com, tony.luck@intel.com, dan.j.williams@intel.com, eric.auger@redhat.com, pbonzini@redhat.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Date: Fri, 21 May 2021 17:19:17 -0700 Message-ID: <162164275795.261970.6600777460965468381.stgit@djiang5-desk3.ch.intel.com> In-Reply-To: <162164243591.261970.3439987543338120797.stgit@djiang5-desk3.ch.intel.com> References: <162164243591.261970.3439987543338120797.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support to allow an external driver to be registered to the dsa_bus_type and also auto-loaded. Signed-off-by: Dave Jiang --- drivers/dma/idxd/idxd.h | 6 ++++++ drivers/dma/idxd/init.c | 2 ++ drivers/dma/idxd/sysfs.c | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h index 0970d0e67976..22afaf7ee637 100644 --- a/drivers/dma/idxd/idxd.h +++ b/drivers/dma/idxd/idxd.h @@ -483,11 +483,17 @@ static inline int idxd_wq_refcount(struct idxd_wq *wq) return wq->client_count; }; +#define MODULE_ALIAS_IDXD_DEVICE(type) MODULE_ALIAS("idxd:t" __stringify(type) "*") +#define IDXD_DEVICES_MODALIAS_FMT "idxd:t%d" + int __must_check __idxd_driver_register(struct idxd_device_driver *idxd_drv, struct module *module, const char *mod_name); #define idxd_driver_register(driver) \ __idxd_driver_register(driver, THIS_MODULE, KBUILD_MODNAME) +#define module_idxd_driver(driver) \ + module_driver(driver, idxd_driver_register, idxd_driver_unregister) + void idxd_driver_unregister(struct idxd_device_driver *idxd_drv); int idxd_register_bus_type(void); diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c index 30d3ab0c4051..bed9169152f9 100644 --- a/drivers/dma/idxd/init.c +++ b/drivers/dma/idxd/init.c @@ -843,8 +843,10 @@ int __idxd_driver_register(struct idxd_device_driver *idxd_drv, struct module *o return driver_register(drv); } +EXPORT_SYMBOL_GPL(__idxd_driver_register); void idxd_driver_unregister(struct idxd_device_driver *idxd_drv) { driver_unregister(&idxd_drv->drv); } +EXPORT_SYMBOL_GPL(idxd_driver_unregister); diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c index ff2f1c97ed74..4fcb8833a4df 100644 --- a/drivers/dma/idxd/sysfs.c +++ b/drivers/dma/idxd/sysfs.c @@ -53,11 +53,17 @@ static int idxd_config_bus_remove(struct device *dev) return 0; } +static int idxd_bus_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + return add_uevent_var(env, "MODALIAS=" IDXD_DEVICES_MODALIAS_FMT, 0); +} + struct bus_type dsa_bus_type = { .name = "dsa", .match = idxd_config_bus_match, .probe = idxd_config_bus_probe, .remove = idxd_config_bus_remove, + .uevent = idxd_bus_uevent, }; #define DRIVER_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \