From patchwork Thu Sep 27 06:54:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramalingam C X-Patchwork-Id: 10617345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D6C0913 for ; Thu, 27 Sep 2018 06:58:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F06D2AE16 for ; Thu, 27 Sep 2018 06:58:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 432A72AE64; Thu, 27 Sep 2018 06:58:23 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A81982AE16 for ; Thu, 27 Sep 2018 06:58:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EE4426E4DF; Thu, 27 Sep 2018 06:58:04 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 670A26E4DF; Thu, 27 Sep 2018 06:58:03 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2018 23:58:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,309,1534834800"; d="scan'208";a="95204686" Received: from mint-dev.iind.intel.com ([10.223.25.164]) by orsmga002.jf.intel.com with ESMTP; 26 Sep 2018 23:57:59 -0700 From: Ramalingam C To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, daniel@ffwll.ch, tomas.winkler@intel.com Date: Thu, 27 Sep 2018 12:24:57 +0530 Message-Id: <1538031330-21040-7-git-send-email-ramalingam.c@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538031330-21040-1-git-send-email-ramalingam.c@intel.com> References: <1538031330-21040-1-git-send-email-ramalingam.c@intel.com> Subject: [Intel-gfx] [PATCH v7 06/39] component: alloc component_match without any comp to match X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kate Stewart , Philippe Ombredanne , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Thomas Gleixner MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP If all the components associated to a component master is not added to the component framework due to the HW capability or Kconfig selection, component_match will be NULL at component_master_add_with_match(). To avoid this, component_match_alloc() is added to the framework, to allcoate the struct component_match with zero associated components. Hence component master can be added with a component_match with zero associated components. This helps the component master bind call to get triggered, even if no component is registered for that particular master. This is meant for big PCI device drivers where small/optional features are external components, and based on usecases different combination of components are build as entire driver. In such PCI device driver Load, if we use the component master for waiting for few components(features) availability, only if they are supported by the underlying HW, then we need to allocate memory for component_match using the API introduced in this change before the call to component_master_add_with_match. v2: No Change. Signed-off-by: Ramalingam C Suggested-by: Daniel Vetter Cc: Greg Kroah-Hartman Cc: Kate Stewart Cc: Thomas Gleixner Cc: Philippe Ombredanne Cc: linux-kernel@vger.kernel.org --- drivers/base/component.c | 30 ++++++++++++++++++++++++++++++ include/linux/component.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/base/component.c b/drivers/base/component.c index 8946dfee4768..007fb738263a 100644 --- a/drivers/base/component.c +++ b/drivers/base/component.c @@ -312,6 +312,36 @@ static int component_match_realloc(struct device *dev, } /* + * Allocate the match without any component_match_array elements. + * + * This function is useful when the component master might end up + * registering itself without any matching components. + */ +void component_match_alloc(struct device *master, + struct component_match **matchptr) +{ + struct component_match *match = *matchptr; + + if (IS_ERR(match)) + return; + + if (match) + return; + + match = devres_alloc(devm_component_match_release, + sizeof(*match), GFP_KERNEL); + if (!match) { + *matchptr = ERR_PTR(-ENOMEM); + return; + } + + devres_add(master, match); + + *matchptr = match; +} +EXPORT_SYMBOL(component_match_alloc); + +/* * Add a component to be matched, with a release function. * * The match array is first created or extended if necessary. diff --git a/include/linux/component.h b/include/linux/component.h index e71fbbbc74e2..3f6b420a58f8 100644 --- a/include/linux/component.h +++ b/include/linux/component.h @@ -37,6 +37,8 @@ void component_match_add_release(struct device *master, struct component_match **matchptr, void (*release)(struct device *, void *), int (*compare)(struct device *, void *), void *compare_data); +void component_match_alloc(struct device *master, + struct component_match **matchptr); static inline void component_match_add(struct device *master, struct component_match **matchptr,