From: Krzysztof Kozlowski <krzk@kernel.org>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Sibi Sankar <quic_sibis@quicinc.com>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org,
Johan Hovold <johan+linaro@kernel.org>,
Xilin Wu <wuxilin123@gmail.com>
Subject: Re: [PATCH v5 5/6] soc: qcom: add pd-mapper implementation
Date: Fri, 19 Apr 2024 20:45:21 +0200 [thread overview]
Message-ID: <c255c9d5-f3fc-438c-abbe-64995823e80c@kernel.org> (raw)
In-Reply-To: <CAA8EJprQzp+bmTa9CFoev_vk8Xf-H+ZAc-dFsqev76WOB6GtJQ@mail.gmail.com>
On 19/04/2024 20:24, Dmitry Baryshkov wrote:
>>>>> +};
>>>>
>>>> If this is supposed to be a module, then why no MODULE_DEVICE_TABLE?
>>>
>>> Ok, I should add this to the commit message.
>>>
>>> For now:
>>>
>>> This module is loaded automatically by the remoteproc drivers when
>>
>> Hm? How remoteproc loads this module?
>
> remoteproc drivers call qcom_pdm_start(). This brings in this module
> via symbol deps.
Ah, right, I understand now. So this should not be loaded on its own on
the machine.
>
>>
>>> necessary. It uses a root node to match a protection domains map for a
>>> particular device.
>>>
>>>>
>>>>> +
>>>>> +static int qcom_pdm_start(void)
>>>>> +{
>>>>> + const struct of_device_id *match;
>>>>> + const struct qcom_pdm_domain_data * const *domains;
>>>>> + struct device_node *root;
>>>>> + int ret, i;
>>>>> +
>>>>> + pr_debug("PDM: starting service\n");
>>>>
>>>> Drop simple entry/exit debug messages.
>>>
>>> ack
>>>
>>>>
>>>>> +
>>>>> + root = of_find_node_by_path("/");
>>>>> + if (!root)
>>>>> + return -ENODEV;
>>>>> +
>>>>> + match = of_match_node(qcom_pdm_domains, root);
>>>>> + of_node_put(root);
>>>>> + if (!match) {
>>>>> + pr_notice("PDM: no support for the platform, userspace daemon might be required.\n");
>>>>> + return 0;
>>>>> + }
>>>>> +
>>>>> + domains = match->data;
>>>>
>>>> All this is odd a bit. Why is this not a driver? You are open coding
>>>> here of_device_get_match_data().
>>>
>>> Except that it matches the root node instead of matching a device.
>>
>> Yep, but if this was proper device then things get simpler, don't they?
>
> I don't think we are supposed to have devices for software things?
> This is purely a software construct. It replaces userspace daemon for
> the reason outlined in the cover letter, but other than that there is
> no hardware entity. Not even a firmware entity to drive this thing.
Firmware interfaces are also not "devices" but we create device drivers
for them. The code lies in drivers, so it is a driver, even if somehow
kernel software construct. fs/pstore/ram also has a driver, even though
this is software device to handle ram dumps (it is not a driver for
RAM). net/qrtr/smd.c is not even in the drivers and as well describes
some sort of software daemon.
If this was not a driver, then it would be a subsystem... but it is not
a subsystem, right?
>
>>>>> +
>>>>> + if (!ret)
>>>>> + ++qcom_pdm_count;
>>>>> +
>>>>> + mutex_unlock(&qcom_pdm_mutex);
>>>>
>>>> Looks like you implement refcnt manually...
>>>
>>> Yes... There is refcount_dec_and_mutex_lock(), but I found no
>>> corresponding refcount_add_and_mutex_lock(). Maybe I'm
>>> misunderstanding that framework.
>>> I need to have a mutex after incrementing the lock from 0, so that the
>>> driver can init QMI handlers.
>>>
>>>> Also, what happens if this module gets unloaded? How do you handle
>>>> module dependencies? I don't see any device links. Bartosz won't be
>>>> happy... We really need to stop adding more of
>>>> old-style-buggy-never-unload-logic. At least for new code.
>>>
>>> Module dependencies are handled by the symbol dependencies.
>>
>> You mean build dependencies, not runtime load.
>
> No, I mean runtime load dependencies.
>
>>
>>> Remoteproc module depends on this symbol. Once q6v5 remoteproc modules
>>> are unloaded this module can be unloaded too.
>>
>> I am pretty sure you can unload this and get crashes.
>
> If for some reason somebody has called qcom_pdm_get() without
> qcom_pdm_release(), then yes. To make it 100% safe, I can cleanup
> actions to module_exit(), but for me it looks like an overkill.
I'll come with some more concrete example if you are not convinced.
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-04-19 18:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 14:00 [PATCH v5 0/6] soc: qcom: add in-kernel pd-mapper implementation Dmitry Baryshkov
2024-04-19 14:00 ` [PATCH v5 1/6] soc: qcom: pdr: protect locator_addr with the main mutex Dmitry Baryshkov
2024-04-19 14:00 ` [PATCH v5 2/6] soc: qcom: pdr: fix parsing of domains lists Dmitry Baryshkov
2024-04-19 14:00 ` [PATCH v5 3/6] soc: qcom: pdr: extract PDR message marshalling data Dmitry Baryshkov
2024-04-20 23:42 ` Bryan O'Donoghue
2024-04-21 13:16 ` Dmitry Baryshkov
2024-04-19 14:00 ` [PATCH v5 4/6] soc: qcom: qmi: add a way to remove running service Dmitry Baryshkov
2024-04-19 14:00 ` [PATCH v5 5/6] soc: qcom: add pd-mapper implementation Dmitry Baryshkov
2024-04-19 17:07 ` Krzysztof Kozlowski
2024-04-19 18:10 ` Dmitry Baryshkov
2024-04-19 18:15 ` Krzysztof Kozlowski
2024-04-19 18:24 ` Dmitry Baryshkov
2024-04-19 18:45 ` Krzysztof Kozlowski [this message]
2024-04-19 19:02 ` Dmitry Baryshkov
2024-04-20 11:40 ` Krzysztof Kozlowski
2024-04-19 14:00 ` [PATCH v5 6/6] remoteproc: qcom: enable in-kernel PD mapper Dmitry Baryshkov
2024-04-20 11:32 ` [PATCH v5 0/6] soc: qcom: add in-kernel pd-mapper implementation Krzysztof Kozlowski
2024-04-22 10:00 ` Dmitry Baryshkov
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=c255c9d5-f3fc-438c-abbe-64995823e80c@kernel.org \
--to=krzk@kernel.org \
--cc=andersson@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=johan+linaro@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=quic_sibis@quicinc.com \
--cc=wuxilin123@gmail.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