From patchwork Mon Mar 27 17:02:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 75589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1674731vqo; Mon, 27 Mar 2023 10:29:06 -0700 (PDT) X-Google-Smtp-Source: AKy350aSKQT1wF9NiiOK6Ywg4SUG6uGWI9oy5gO+oi+e88Wz/EtzHps4jWxMdTGE2aq/kzVori9R X-Received: by 2002:a17:902:e54c:b0:1a0:42c0:b2a5 with SMTP id n12-20020a170902e54c00b001a042c0b2a5mr17598296plf.24.1679938146564; Mon, 27 Mar 2023 10:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679938146; cv=none; d=google.com; s=arc-20160816; b=EdDfG63MUbkCrYwjBZblCsPEg9giQWsBDczBWkpunHAHC4lpadJW1Pea+S70GjoPHt 4zt1Z+tGCOmm8ECTBudobXSOgfzp0whI6WkNignZhxIYWyAcPNnJO+MTx67tJJ8Vs15s tcm9VvFVWX91hG+NRq0MgoNimnO3bHt/t2x2kN/M8nbryCPWS3kmuKHieDikS56NikNl sJyvgluiUIRb2g9DeOYkgZVLj3cIa8fignb9UFAz4lbgNabOwfT7+clQeplmA0lhjUNl XEwPdZOb7f8EdeVEVYEGo7XPjjgksywSBGez7aGcLWCjTZFXRWSEB4Bj747lIB8frTi5 KyXg== 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=ZibIGgC01l9wOwxmHxquWhw+Q6ksEiE8yy7lWTasx5Q=; b=v53K/qS2eLZK22bcvCmavpLrwtRJOarc3F4ecXhQflNiMfZAg57fLk+x/E44wsnDuZ lfwiFPDqBmYKsbOkJksyJoJIL3U6l6Z9TWcMu2b4p7B9/g882m2eA9Xsy5Oe+hxTngqF KVzPhvBm00s7HwE7flaiuNEiXebGqJ0+2rtL1QL7N2hIcAtTV73ObJPeapQpn0LQ0N2M deFMMoIeX8Mj0p6RA642axTfEl7YFoRudSHYc3MZibARFJwHTEJEHy+wJvEBCpXhTKPR /n8QNE+rRzITVUuhG+Sx4NYAjDneOQZigcfji0JoEHM1juGBX9t5T5l1z7/h989rjRBz 749Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a190-20020a6390c7000000b0050bf634ebf2si28145715pge.304.2023.03.27.10.28.34; Mon, 27 Mar 2023 10:29:06 -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 S229767AbjC0RF7 (ORCPT + 99 others); Mon, 27 Mar 2023 13:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232520AbjC0RFn (ORCPT ); Mon, 27 Mar 2023 13:05:43 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1067876AC; Mon, 27 Mar 2023 10:04:13 -0700 (PDT) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4PlfJp4cnfz6J82x; Tue, 28 Mar 2023 01:03:06 +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; Mon, 27 Mar 2023 18:03:40 +0100 From: Jonathan Cameron To: Liang Kan , , CC: , , , , , , , , Davidlohr Bueso , Dave Jiang Subject: [PATCH v3 2/5] perf: Allow a PMU to have a parent Date: Mon, 27 Mar 2023 18:02:44 +0100 Message-ID: <20230327170247.6968-3-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230327170247.6968-1-Jonathan.Cameron@huawei.com> References: <20230327170247.6968-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761542822190164970?= X-GMAIL-MSGID: =?utf-8?q?1761542822190164970?= 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 --- 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);