Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
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:15:48 +0200	[thread overview]
Message-ID: <67c90fcd-df2f-40e4-9507-dcc9340f2319@kernel.org> (raw)
In-Reply-To: <CAA8EJpoyTXWY5uxJs2gt1Rths-HdgskuQFyw5dJSL66mxQOv7g@mail.gmail.com>

On 19/04/2024 20:10, Dmitry Baryshkov wrote:
> On Fri, 19 Apr 2024 at 20:07, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>>
>> On 19/04/2024 16:00, Dmitry Baryshkov wrote:
>>> Existing userspace protection domain mapper implementation has several
>>> issue. It doesn't play well with CONFIG_EXTRA_FIRMWARE, it doesn't
>>> reread JSON files if firmware location is changed (or if firmware was
>>> not available at the time pd-mapper was started but the corresponding
>>> directory is mounted later), etc.
>>>
>>> Provide in-kernel service implementing protection domain mapping
>>> required to work with several services, which are provided by the DSP
>>> firmware.
>>>
>>
>> ...
>>
>>> +
>>> +static const struct of_device_id qcom_pdm_domains[] = {
>>> +     { .compatible = "qcom,apq8096", .data = msm8996_domains, },
>>> +     { .compatible = "qcom,msm8996", .data = msm8996_domains, },
>>> +     { .compatible = "qcom,msm8998", .data = msm8998_domains, },
>>> +     { .compatible = "qcom,qcm2290", .data = qcm2290_domains, },
>>> +     { .compatible = "qcom,qcs404", .data = qcs404_domains, },
>>> +     { .compatible = "qcom,sc7180", .data = sc7180_domains, },
>>> +     { .compatible = "qcom,sc7280", .data = sc7280_domains, },
>>> +     { .compatible = "qcom,sc8180x", .data = sc8180x_domains, },
>>> +     { .compatible = "qcom,sc8280xp", .data = sc8280xp_domains, },
>>> +     { .compatible = "qcom,sda660", .data = sdm660_domains, },
>>> +     { .compatible = "qcom,sdm660", .data = sdm660_domains, },
>>> +     { .compatible = "qcom,sdm670", .data = sdm670_domains, },
>>> +     { .compatible = "qcom,sdm845", .data = sdm845_domains, },
>>> +     { .compatible = "qcom,sm6115", .data = sm6115_domains, },
>>> +     { .compatible = "qcom,sm6350", .data = sm6350_domains, },
>>> +     { .compatible = "qcom,sm8150", .data = sm8150_domains, },
>>> +     { .compatible = "qcom,sm8250", .data = sm8250_domains, },
>>> +     { .compatible = "qcom,sm8350", .data = sm8350_domains, },
>>> +     { .compatible = "qcom,sm8450", .data = sm8350_domains, },
>>> +     { .compatible = "qcom,sm8550", .data = sm8550_domains, },
>>> +     { .compatible = "qcom,sm8650", .data = sm8550_domains, },
>>> +     {},
>>> +};
>>
>> 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?

> 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?


...

>>> +
>>> +     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.

> 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.



Best regards,
Krzysztof


  reply	other threads:[~2024-04-19 18:15 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 [this message]
2024-04-19 18:24         ` Dmitry Baryshkov
2024-04-19 18:45           ` Krzysztof Kozlowski
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=67c90fcd-df2f-40e4-9507-dcc9340f2319@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