Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6011673rwl; Tue, 4 Apr 2023 06:48:23 -0700 (PDT) X-Google-Smtp-Source: AKy350aY/bHmxoBb5LB9z5igamsqdTrtilVfuySswbHevWz9wbbO/3Q5SysJMle0OmEbiYb9p1jj X-Received: by 2002:a17:90b:1d10:b0:23c:feb9:2cea with SMTP id on16-20020a17090b1d1000b0023cfeb92ceamr2916129pjb.42.1680616103440; Tue, 04 Apr 2023 06:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680616103; cv=none; d=google.com; s=arc-20160816; b=P8yavxr6PfmQj8O6FN23nHB7BJAXLsXvpo0qKEh3Ga+/kf3SXTuE5tX2as2hh9ii5Q OV4VbsJ5kDkLCmSbVvADrB+r7RDuxi9EBNZvP9pmq6GXGDiqCAgt06AjND9aUZzRJ+Tp u2N5lAfRFe9c/qrdT7b229B4lBZYr8cldnvLN2ogDQ5EBbbLpeWYKzn1vPT/F2V4AOMl T9HIdYLKHuSf/HqC/0AokxzQ7BMNOQkkV8cGC18ua2TX4t+rfEqdqlyngQ1Efys18Vec wUkWoQqVTC6WEnIg3ygB6u5di5/NbCUHo/kJHLT+oL2jiEZKx2pLRv6PsNO3768ypM5X q5TQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vR7Tj4itEEj3R0vhbfH04WfsZVqbNRf/z0F4kcZjGAA=; b=vVCiecuv69cJM9Rnivdwo+Wx0EulN4dndNdU9f8nRPrSjHMBHp7Kw1g4o0Mc4aquWl ic/Q7ekH8wEBi7YRVqPgCB6H118c+kaRwByV6oLFzG5RaTs+XwxVdneysVt6Wzf6l9fP OUiLMbjIrZFo4j1ayUgRKRLkm5mOw5/P/zZ1VeUYmMd5+46Lg4Mds28fKuzbj59O1H6C 0Z6prqd+5nbSzW6gSe9xBX0rV8stGqqZR3ylkpm3szg7VVxQtiJKHl3OfbYE/h5VjPIW zBlCBL+9CjDhe55O4u7vXS4xYaB1rhNBCb2Ja3aXpG+f2PERqN+Az/pEMdTKT67YQ4gY hEzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y190-20020a638ac7000000b00503a029385asi11029181pgd.849.2023.04.04.06.48.11; Tue, 04 Apr 2023 06:48:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235143AbjDDNmx (ORCPT + 99 others); Tue, 4 Apr 2023 09:42:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234493AbjDDNmv (ORCPT ); Tue, 4 Apr 2023 09:42:51 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C11C186; Tue, 4 Apr 2023 06:42:49 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4PrTT50JLsz67ZTx; Tue, 4 Apr 2023 21:42:01 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 4 Apr 2023 14:42:46 +0100 From: Jonathan Cameron To: Mark Rutland , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Will Deacon , , , CC: , Dan Williams , Shaokun Zhang , Yicong Yang , Jiucheng Xu , Khuong Dinh , Robert Richter , Atish Patra , Anup Patel , Andy Gross , Bjorn Andersson , Frank Li , Shuai Xue , Vineet Gupta , Shawn Guo , Fenghua Yu , Dave Jiang , Wu Hao , Tom Rix , , Suzuki K Poulose , Liang Kan Subject: [PATCH 01/32] perf: Allow a PMU to have a parent Date: Tue, 4 Apr 2023 14:41:54 +0100 Message-ID: <20230404134225.13408-2-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230404134225.13408-1-Jonathan.Cameron@huawei.com> References: <20230404134225.13408-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml500004.china.huawei.com (7.191.163.9) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some PMUs have well defined parents such as PCI devices. As the device_initialize() and device_add() are all within pmu_dev_alloc() which is called from perf_pmu_register() there is no opportunity to set the parent from within a driver. Add a struct device *parent field to struct pmu and use that to set the parent. Signed-off-by: Jonathan Cameron Reviewed-by: Dan Williams --- Previously posted in CPMU series hence the change log. v3: No change --- include/linux/perf_event.h | 1 + kernel/events/core.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index d5628a7b5eaa..b99db1eda72c 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -303,6 +303,7 @@ struct pmu { struct module *module; struct device *dev; + struct device *parent; const struct attribute_group **attr_groups; const struct attribute_group **attr_update; const char *name; diff --git a/kernel/events/core.c b/kernel/events/core.c index fb3e436bcd4a..a84c282221f2 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -11367,6 +11367,7 @@ static int pmu_dev_alloc(struct pmu *pmu) dev_set_drvdata(pmu->dev, pmu); pmu->dev->bus = &pmu_bus; + pmu->dev->parent = pmu->parent; pmu->dev->release = pmu_dev_release; ret = dev_set_name(pmu->dev, "%s", pmu->name); -- 2.37.2