Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2525707rwl; Thu, 13 Apr 2023 07:35:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YXAoMjM/it7IlVJtGfmNwUBw9ErrXIf1zm8tjpUz0zoASH6C/NoW7tbAebbCDYHQLx+SFQ X-Received: by 2002:a05:6402:10c2:b0:504:8929:71ca with SMTP id p2-20020a05640210c200b00504892971camr2445048edu.6.1681396538016; Thu, 13 Apr 2023 07:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681396537; cv=none; d=google.com; s=arc-20160816; b=Fl+7kjinGjRRK5ZFm1YtvrYkyugdbcFj1uta3wMIUaCOd+ypzbMqnznJZyPr6mEb/D /JMVTbSQzOuIa1aFJyf6dlGjvw6ba7YVSSxINdP1Lq2UY1LQjvyDzNLEvT8aqOUJAAYB yCvxZPJn1a3hOwY1+NX3Ue3JgYt9V2WiXcwImejS04XnIgCpkZTPmej/9T5QrFTDabLn kelR0JM4WuBiPjayC5Nj5CAb9wkYxajq1SlqZnL1SxnK4ZclpoFNOKslLSTMA0bQpRpV RqTtXm+Jxj8ThseUP6phgIdqNcoTwpl/P7xolL/4RFommXU+A20go8LxfMXjsNVoHf6l Cmrg== 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=301cr5wq80Jr9e7cgNxA85OvYlwokPNLxNPpXw8siB4=; b=J8vs9tCk9n+r9Qf9mkARv1HhaMsj7BgEroM1tVphBYNUENo1v//uRNEzok5U59mdED 4IgmaDxcQgsKQWf438Bu5VFw3lDU9uUGEl+Cp2TSzfauQaPILxrvlZThEstrmHfBnCL9 YvBjoaMP/BtHYEhXTVaXq4cmCwM1/9SRGEdIRh5uYRND4nk4X02qm1VKW5EgSszF5Png S8Y+fL3rpTv8GmSLmzVWOMC2faOBhbF/JO+f04igJjl5ZzweSBENdkvFHWW6xMHwEG6q hMDRaY1T2aC+OrqDx1HrQeER8xEhfqFyNKi9DDWbGtPy7bQvqDI/A07RJO57f4pnGbBw g9KQ== 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 v9-20020aa7cd49000000b004aaa505ac5fsi2035053edw.76.2023.04.13.07.35.12; Thu, 13 Apr 2023 07:35:37 -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 S230363AbjDMO0v (ORCPT + 99 others); Thu, 13 Apr 2023 10:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231217AbjDMO0u (ORCPT ); Thu, 13 Apr 2023 10:26:50 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1B6B9EE3; Thu, 13 Apr 2023 07:26:49 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Py21S54Z5z67NYF; Thu, 13 Apr 2023 22:25:48 +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; Thu, 13 Apr 2023 15:26:46 +0100 From: Jonathan Cameron To: Liang Kan , , , , CC: , , , , , , Davidlohr Bueso , Dave Jiang Subject: [PATCH v6 1/5] perf: Allow a PMU to have a parent Date: Thu, 13 Apr 2023 15:26:13 +0100 Message-ID: <20230413142617.15995-2-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230413142617.15995-1-Jonathan.Cameron@huawei.com> References: <20230413142617.15995-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: lhrpeml500001.china.huawei.com (7.191.163.213) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Reviewed-by: Greg Kroah-Hartman --- v6: No change v5: Move to head of series as may merge as part of: https://lore.kernel.org/all/20230404134225.13408-1-Jonathan.Cameron@huawei.com/ --- 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 435815d3be3f..32079a332480 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