mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tudor Ambarus <tudor.ambarus@linaro.org>
To: Krzysztof Kozlowski <krzk@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Jassi Brar <jassisinghbrar@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	andre.draszik@linaro.org, kernel-team@android.com,
	willmcvicker@google.com, peter.griffin@linaro.org,
	daniel.lezcano@linaro.org, vincent.guittot@linaro.org,
	ulf.hansson@linaro.org, arnd@arndb.de
Subject: Re: [PATCH v5 2/3] firmware: add Exynos ACPM protocol driver
Date: Mon, 6 Jan 2025 09:33:34 +0000	[thread overview]
Message-ID: <24963d4d-9d53-4d07-a756-3eb1fc50c3dc@linaro.org> (raw)
In-Reply-To: <060c7a96-c1ed-4c97-8a3f-f510102466f9@linaro.org>

Hi, Krzysztof,

On 12/31/24 2:32 PM, Tudor Ambarus wrote:
>>> diff --git a/drivers/firmware/samsung/Kconfig b/drivers/firmware/samsung/Kconfig
>>> new file mode 100644
>>> index 000000000000..750b41342174
>>> --- /dev/null
>>> +++ b/drivers/firmware/samsung/Kconfig
>>> @@ -0,0 +1,14 @@
>>> +# SPDX-License-Identifier: GPL-2.0-only
>>> +
>>> +config EXYNOS_ACPM_PROTOCOL
>>> +	tristate "Exynos Alive Clock and Power Manager (ACPM) Message Protocol"
>>> +	depends on ARCH_EXYNOS || COMPILE_TEST
>>> +	depends on EXYNOS_MBOX
>>
>> Is it build time dependency? No || COMPILE_TEST?
> 
> There's no build time dependency, I'll drop this line.
>>
>> Is it fine when EXYNOS_MBOX is a module?
> 
> Yes. When the EXYNOS_MBOX module is not loaded, and one tries to load
> EXYNOS_ACPM_PROTOCOL module, the later will defer probe when requesting
> the mailbox channels, but that's fine.
> 

I'll need to select EXYNOS_MBOX, I explain why below.

cut

>>> + */
>>> +static const struct acpm_handle *acpm_get_by_phandle(struct device_node *np,
>>> +						     const char *property)
>>> +{
>>> +	struct acpm_handle *handle = NULL;
>>> +	struct device_node *acpm_np;
>>> +	struct acpm_info *info;
>>> +
>>> +	if (!np) {
>>> +		pr_err("I need a device pointer\n");
>>> +		return ERR_PTR(-EINVAL);
>>> +	}
>>> +
>>> +	acpm_np = of_parse_phandle(np, property, 0);
>>> +	if (!acpm_np)
>>> +		return ERR_PTR(-ENODEV);
>>> +
>>> +	mutex_lock(&acpm_list_mutex);
>>> +	list_for_each_entry(info, &acpm_list, node) {
>>> +		if (acpm_np == info->dev->of_node) {
>>> +			handle = &info->handle;
>>> +			info->users++;
>>> +			break;
>>> +		}
>>> +	}
>>> +	mutex_unlock(&acpm_list_mutex);
>>> +	of_node_put(acpm_np);
>>> +
>>
>> You also need device links and probably try_module_get. See clk.c

I find these necessary too, will add them. try_module_get() must be
called when the module exists and is alive, otherwise I get a NULL ptr
dereference. I need a module dependency between acpm-protocol.ko and
exynos-mailbox.ko.
	select EXYNOS_MBOX and
	MODULE_SOFTDEP("pre: exynos-mailbox");
shall do the trick I think.

>> clk_hw_create_clk() or of_qcom_ice_get(). Interestingly, none of them
>> perform both operations, which I think is necessary.
>>
>> I think you could also avoid entire list and mutex by using
>> platform_get_drvdata(), see of_qcom_ice_get().

Using platform_get_drvdata() will simplify the code, thanks. It still
assumes the platform driver exists and is alive, otherwise we get a NULL
ptr dereference when getting the drvdata. But we'll be safe if I add the
module dependency.

Thanks,
ta


  reply	other threads:[~2025-01-06  9:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 14:32 [PATCH v5 0/3] " Tudor Ambarus
2024-12-20 14:32 ` [PATCH v5 1/3] dt-bindings: firmware: add google,gs101-acpm-ipc Tudor Ambarus
2024-12-22  8:48   ` Krzysztof Kozlowski
2024-12-20 14:32 ` [PATCH v5 2/3] firmware: add Exynos ACPM protocol driver Tudor Ambarus
2024-12-24 14:14   ` Krzysztof Kozlowski
2024-12-31 14:32     ` Tudor Ambarus
2025-01-06  9:33       ` Tudor Ambarus [this message]
2025-01-06 10:20         ` Tudor Ambarus
2025-01-07 10:50           ` Tudor Ambarus
2025-01-16 11:41       ` Tudor Ambarus
2024-12-20 14:32 ` [PATCH v5 3/3] MAINTAINERS: add entry for the Samsung Exynos ACPM mailbox protocol Tudor Ambarus
2024-12-22  8:47 ` [PATCH v5 0/3] firmware: add Exynos ACPM protocol driver Krzysztof Kozlowski

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=24963d4d-9d53-4d07-a756-3eb1fc50c3dc@linaro.org \
    --to=tudor.ambarus@linaro.org \
    --cc=alim.akhtar@samsung.com \
    --cc=andre.draszik@linaro.org \
    --cc=arnd@arndb.de \
    --cc=conor+dt@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=kernel-team@android.com \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=robh@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vincent.guittot@linaro.org \
    --cc=willmcvicker@google.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

all inboxes | Powered by JetHome®