public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@codeaurora.org>
To: Jiancheng Xue <xuejiancheng@hisilicon.com>
Cc: mturquette@baylibre.com, p.zabel@pengutronix.de,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	robh+dt@kernel.org, yanhaifeng@hisilicon.com,
	yanghongwei@hisilicon.com, suwenping@hisilicon.com,
	raojun@hisilicon.com, ml.yang@hisilicon.com,
	gaofei@hisilicon.com, zhangzhenxing@hisilicon.com,
	hermit.wangheming@hisilicon.com, jiangheng@hisilicon.com
Subject: Re: [PATCH 3/3] clk: hisilicon: add CRG driver for hi3519 soc
Date: Fri, 6 May 2016 11:19:53 -0700	[thread overview]
Message-ID: <20160506181953.GA3492@codeaurora.org> (raw)
In-Reply-To: <1461397230-1757-4-git-send-email-xuejiancheng@hisilicon.com>

On 04/23, Jiancheng Xue wrote:
> +
> +static int hi3519_clk_probe(struct platform_device *pdev)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	struct hisi_clock_data *clk_data;
> +	struct hisi_reset_controller *rstc;
> +
> +	rstc = hisi_reset_init(np);
> +	if (!rstc)
> +		return -ENOMEM;
> +
> +	clk_data = hisi_clk_init(np, HI3519_NR_CLKS);

This creates and registers a clk provider...

> +	if (!clk_data) {
> +		hisi_reset_exit(rstc);
> +		return -ENODEV;
> +	}
> +
> +	hisi_clk_register_fixed_rate(hi3519_fixed_rate_clks,
> +				     ARRAY_SIZE(hi3519_fixed_rate_clks),
> +				     clk_data);
> +	hisi_clk_register_mux(hi3519_mux_clks, ARRAY_SIZE(hi3519_mux_clks),
> +					clk_data);
> +	hisi_clk_register_gate(hi3519_gate_clks,
> +			ARRAY_SIZE(hi3519_gate_clks), clk_data);
> +

And then this actually populates those clks into the provider's
array of clks..

That isn't good because now we have an ordering problem where the
provider has published itself before it can provide clks to
consumers. Hopefully no race condition arises!

Also, we don't check errors here upon registering clks. Not good
in the case of probe defer or something.

Finally, we should still have a driver remove path even if it's
builtin because userspace can unbind drivers, unless we configure
the struct driver to prevent that. Please do one or the other
here (I would guess you're leaning toward the driver attribute to
prevent unbinding).

> +	return 0;
> +}
> +
> +static const struct of_device_id hi3519_clk_match_table[] = {
> +	{ .compatible = "hisilicon,hi3519-crg" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, hi3519_clk_match_table);
> +
> +static struct platform_driver hi3519_clk_driver = {
> +	.probe          = hi3519_clk_probe,
> +	.driver         = {
> +		.name   = "hi3519-clk",
> +		.of_match_table = hi3519_clk_match_table,
> +	},
> +};
> +

Anyway, I applied this to a new immutable branch clk-hi3519 in
the clk tree and merged it into clk-next. Please send follow up
patches to fix these theoretical problems.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

      reply	other threads:[~2016-05-06 18:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-23  7:40 [PATCH 0/3] clock: hisilicon: Add CRG driver for hi3519 soc Jiancheng Xue
2016-04-23  7:40 ` [PATCH 1/3] reset: hisilicon: add reset controller driver for hisilicon SOCs Jiancheng Xue
2016-05-06 18:20   ` Stephen Boyd
2016-04-23  7:40 ` [PATCH 2/3] clk: hisilicon: export some hisilicon APIs to modules Jiancheng Xue
2016-05-06 18:20   ` Stephen Boyd
2016-04-23  7:40 ` [PATCH 3/3] clk: hisilicon: add CRG driver for hi3519 soc Jiancheng Xue
2016-05-06 18:19   ` Stephen Boyd [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160506181953.GA3492@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=gaofei@hisilicon.com \
    --cc=hermit.wangheming@hisilicon.com \
    --cc=jiangheng@hisilicon.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ml.yang@hisilicon.com \
    --cc=mturquette@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=raojun@hisilicon.com \
    --cc=robh+dt@kernel.org \
    --cc=suwenping@hisilicon.com \
    --cc=xuejiancheng@hisilicon.com \
    --cc=yanghongwei@hisilicon.com \
    --cc=yanhaifeng@hisilicon.com \
    --cc=zhangzhenxing@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox