Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5001352ybi; Mon, 3 Jun 2019 22:51:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFLH2cOEbnrgjBSEqjWdJDe6+c6ajv02FSeUzluoYo7jzkdb2f7e8Z9v1SZCGrH8vtwzyu X-Received: by 2002:a17:90a:1196:: with SMTP id e22mr36123680pja.142.1559627508588; Mon, 03 Jun 2019 22:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559627508; cv=none; d=google.com; s=arc-20160816; b=h1cQ0BF7XEVkCMRAkha/Z5oHO8vxuvtJPfZn9JSNYGhYmMkQVvtx+mx5hEgOC21fEz zA7faMozIzMb6pUrLiSGyCBKhs9vdHVrCmGPbJYqsrEV1txqg9g9xfAa5fhNGkz0CtmR 6frlEOaoP8Y0exRCtuN+hQ44YCoazuvo/YgPk3YKtZhvi5+chqs0q9SNlcqzxRYeuvV/ KiYl5z4ewIC+UNK2VTUQt2j/l1srjUuixh/ihcxMJETNE4hiNkzAwlFC+50KriDvKDuo CyXGDYKKcul+g7HZIpBYOeYf6EvzelXXJ1fvtO6YodcNls4R7HSeyY0YF6ofYUYJNSk0 f5og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yWozHJF4ax3cbzvHE3WNroSBfuc9tA8upuETzuaYcXM=; b=yqzxNSNZNeUMxklmNE0tgt8t5o9unYQe61X5Iuk7+3fX4EaW0qld8Rs5jsmf4nJY4E 2kF28HExE36dj4uV0Oy0ol2Rw8U0gWjiy25mTzSoepWVmOeRnEb7N3Gv52HDi+upKraS b2Mxp3hdlOaaq/vR04rNu4FUHUIVlzh8qmK7aUtRGB5azmFrTcP9WCZb1ZwMWn/0B4g4 ObQN3RjlIAkj0iaeNjfnTH/1fBuFQez788+vrA9hBc7xlvvIwSR9LMaejDkEKRm1mdpW 6zM0HJ/h0pNW1XYwVnmdUDG7grQR2Uj6AxU9B7dQ+Az7NSJGbO2PMZdZAFyR/1RQbuV1 s3ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iqAhl4YB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22si6322691pgb.180.2019.06.03.22.51.32; Mon, 03 Jun 2019 22:51:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iqAhl4YB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726555AbfFDFuR (ORCPT + 99 others); Tue, 4 Jun 2019 01:50:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:39274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726136AbfFDFuR (ORCPT ); Tue, 4 Jun 2019 01:50:17 -0400 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 97E732064A; Tue, 4 Jun 2019 05:50:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559627415; bh=6pJxXDhunaU05disWJij71yT3C7+q3muGfwv90tuWo4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iqAhl4YBQP0Nn6w3xOTrY0YuLNVq3JgdWzAMZlqZSB+1oL9YXG7AOTZyANpzXZODk yzZo0zvmUI/lNOJ6Uj7Btnxw5Y5mjUv38qo3KIG+C3kEXGv5z7bKNKkIQThp1oB45S NUpxUsIKRAzx/ushYV42GJSXmQvs2iAf/xDouoL0= Received: by mail-wm1-f47.google.com with SMTP id f10so13435426wmb.1; Mon, 03 Jun 2019 22:50:15 -0700 (PDT) X-Gm-Message-State: APjAAAUfQsBTQCIqXSg4ttUIHYD2aul1u1fu0SBNSey3pds+ACpFIID9 XWGf30oHwgHnDuUwVmNxOkacoZlgY8Cz7CVLyf4= X-Received: by 2002:a1c:3c8a:: with SMTP id j132mr4542669wma.172.1559627414252; Mon, 03 Jun 2019 22:50:14 -0700 (PDT) MIME-Version: 1.0 References: <40e0b27c342458360f9f30ef16026cb63e792850.1559614824.git.han_mao@c-sky.com> In-Reply-To: <40e0b27c342458360f9f30ef16026cb63e792850.1559614824.git.han_mao@c-sky.com> From: Guo Ren Date: Tue, 4 Jun 2019 13:50:03 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V4 1/6] csky: Init pmu as a device To: Mao Han Cc: linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Mao, On Tue, Jun 4, 2019 at 10:25 AM Mao Han wrote: > > This patch change the csky pmu initialization from arch init to > device init. The pmu can be configued with information from > device tree(pmu device name, irq number and etc.). > > Signed-off-by: Mao Han > Cc: Guo Ren > --- > arch/csky/kernel/perf_event.c | 58 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 57 insertions(+), 1 deletion(-) > > diff --git a/arch/csky/kernel/perf_event.c b/arch/csky/kernel/perf_event.c > index 376c972..c022acc 100644 > --- a/arch/csky/kernel/perf_event.c > +++ b/arch/csky/kernel/perf_event.c > @@ -21,6 +21,8 @@ struct csky_pmu_t { > uint32_t hpcr; > } csky_pmu; > > +typedef int (*csky_pmu_init)(struct csky_pmu_t *); Is the type of csky_pmu_init() the same with init_hw_perf_events ? And I also think you should remove the hook style, because there is only one init for the driver. > + > #define cprgr(reg) \ > ({ \ > unsigned int tmp; \ > @@ -1028,4 +1030,58 @@ int __init init_hw_perf_events(void) > > return perf_pmu_register(&csky_pmu.pmu, "cpu", PERF_TYPE_RAW); > } > -arch_initcall(init_hw_perf_events); > + > +int csky_pmu_device_probe(struct platform_device *pdev, > + const struct of_device_id *of_table) > +{ > + const struct of_device_id *of_id; > + csky_pmu_init init_fn; > + struct device_node *node = pdev->dev.of_node; > + int ret = -ENODEV; > + > + of_id = of_match_node(of_table, pdev->dev.of_node); > + if (node && of_id) { > + init_fn = of_id->data; > + ret = init_fn(&csky_pmu); > + } Ditto, all 7 lines above should be removed and use directly like: ret = init_hw_perf_events(); > + if (ret) { > + pr_notice("[perf] failed to probe PMU!\n"); > + return ret; > + } > + > + return ret; > +} > + > +const static struct of_device_id csky_pmu_of_device_ids[] = { > + {.compatible = "csky,csky-pmu", .data = init_hw_perf_events}, Ditto, Nothing for .data. Best Regards Guo Ren