Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp1208671qtg; Thu, 30 Mar 2023 09:52:45 -0700 (PDT) X-Google-Smtp-Source: AKy350acGVk6jMfDqf/E1ko9TSxItVi2VI0I0pLXidtnpCnas5+bKeoh2fx3+QHy2JCTTyAmD12B X-Received: by 2002:a17:902:ecc2:b0:19a:7060:948 with SMTP id a2-20020a170902ecc200b0019a70600948mr3089933plh.1.1680195164899; Thu, 30 Mar 2023 09:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680195164; cv=none; d=google.com; s=arc-20160816; b=VzEWTbVRWRkq1tSNZKX/7ZGOY8qQbLDwvXPisAnQ3LZ9sKLqDuF2em69H6tP3V6dvw RfAOruoKYIA76cQqellbav0TfIE2fPOLoxWeuCZV8qWydWyixOBM0pO/l6ZnDEiVRT/M NAbL17FUe5QQE6v34QEZB2m0opIWHRoGib4ydk/p4T/AvXdd2SXVC2/sofxZ6EqtYD4p a4lfAj1CrjcAbTW7GylkdBX3JXc5sQ1Xwel/lmdYEJp0FMR2tGsbMgm17N93dbKZuqQV hoU7sbNd/aLH32clLYsUi9DMJlW/H4NPTkVvItPlmATch3oeLVFcoOG7Vj67iM2qm2iG 6e5Q== 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=9T2i4qotjT4SKDy6R4tSKGzkCNQxqJwWrwYVMS7Q9iA=; b=Tu8Px3aB0iVRiXlWcADkgKQM9cmcAelD7toDKBhjgEAqyz9CdgV4V97BHKUNlqVuHE +gcwkVM6D6invTJZOA3YEKeh95o3/FQDO+NeYcZV1TJ1SqLHlF+I1nOduuSlEvQBqpw3 P+XpittL9AyHlGusBWm/w7DPAg5nQ5sRkjPJK9WVhMUpr2SYmVWwb8j1tuoy1zDNUseQ 8Izu2hQ2DMSxCoehrNzAo6sqcTYgajSYX3tTMZlxojobcSRXXLxdvYpAKnd6gOWPEpfe gGdNzZR+OUefMvcIUpJIrgc46XNt4n9SDpNG2DyfAJset22i804EIEAVq5UOmiKOeetE SCzg== 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 s4-20020a170902b18400b001a0ae87878dsi33801738plr.388.2023.03.30.09.52.28; Thu, 30 Mar 2023 09:52:44 -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 S232509AbjC3Qr2 (ORCPT + 99 others); Thu, 30 Mar 2023 12:47:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbjC3Qqx (ORCPT ); Thu, 30 Mar 2023 12:46:53 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F5A3CC3E; Thu, 30 Mar 2023 09:46:52 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4PnTnv3bXnz6J7n2; Fri, 31 Mar 2023 00:46:11 +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.21; Thu, 30 Mar 2023 17:46:49 +0100 From: Jonathan Cameron To: Liang Kan , , CC: , , , , , , , , Davidlohr Bueso , Dave Jiang Subject: [PATCH v4 2/5] perf: Allow a PMU to have a parent Date: Thu, 30 Mar 2023 17:45:53 +0100 Message-ID: <20230330164556.31533-3-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230330164556.31533-1-Jonathan.Cameron@huawei.com> References: <20230330164556.31533-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: lhrpeml100001.china.huawei.com (7.191.160.183) 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 --- v4: No change Note that this may first merge as part of a larger series I plan to post next week that adds parents for many of the of the other struct pmu instances. If so please drop this patch whilst applying. --- 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