linux-remoteproc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Clément Leger" <cleger@kalray.eu>
To: s-anna <s-anna@ti.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Loic PALLARDY <loic.pallardy@st.com>,
	Arnaud Pouliquen <arnaud.pouliquen@st.com>,
	Lokesh Vutla <lokeshvutla@ti.com>,
	linux-remoteproc <linux-remoteproc@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/4] remoteproc: add support for a new 64-bit trace version
Date: Fri, 22 May 2020 21:28:47 +0200 (CEST)	[thread overview]
Message-ID: <811755772.4219337.1590175727911.JavaMail.zimbra@kalray.eu> (raw)
In-Reply-To: <4fab212b-a9d2-927e-d3d7-e591912fd6cf@ti.com>

Hi Suman,

----- On 22 May, 2020, at 20:59, s-anna s-anna@ti.com wrote:

> Hi Clement,
> 
>>  > ----- On 22 May, 2020, at 20:03, Clément Leger cleger@kalray.eu wrote:>
>>> Hi Suman,
>>>
>>> ----- On 22 May, 2020, at 19:33, Bjorn Andersson bjorn.andersson@linaro.org
>>> wrote:
>>>
>>>> On Fri 22 May 09:54 PDT 2020, Suman Anna wrote:
>>>>
>>>>> On 5/21/20 2:42 PM, Suman Anna wrote:
>>>>>> Hi Bjorn,
>>>>>>
>>>>>> On 5/21/20 1:04 PM, Bjorn Andersson wrote:
>>>>>>> On Wed 25 Mar 13:47 PDT 2020, Suman Anna wrote:
>>>> [..]
>>>>>>>> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
>>>> [..]
>>>>>>>> +struct fw_rsc_trace2 {
>>>>>>>
>>>>>>> Sounds more like fw_rsc_trace64 to me - in particular since the version
>>>>>>> of trace2 is 1...
>>>>>>
>>>>>> Yeah, will rename this.
>>>>>>
>>>>>>>
>>>>>>>> +    u32 padding;
>>>>>>>> +    u64 da;
>>>>>>>> +    u32 len;
>>>>>>>> +    u32 reserved;
>>>>>>>
>>>>>>> What's the purpose of this reserved field?
>>>>>>
>>>>>> Partly to make sure the entire resource is aligned on an 8-byte, and
>>>>>> partly copied over from fw_rsc_trace entry. I guess 32-bits is already
>>>>>> large enough of a size for trace entries irrespective of 32-bit or
>>>>>> 64-bit traces, so I doubt if we want to make the len field also a u64.
>>>>>
>>>>> Looking at this again, I can drop both padding and reserved fields, if I
>>>>> move the len field before da. Any preferences/comments?
>>>
>> Sorry, my message went a bit too fast... So as I was saying:
>> 
>> Not only the in-structure alignment matters but also in the resource table.
>> Since the resource table is often packed (see [1] for instance), if a trace
>> resource is embedded in the resource table after another resource aligned
>> on 32 bits only, your 64 bits trace field will potentially end up
>> misaligned.
> 
> Right. Since one can mix and match the resources of different sizes and
> include them in any order, the onus is going to be on the resource table
> constructors to ensure the inter-resource alignments, if any are
> required. The resource table format allows you to add padding fields in
> between if needed, and the remoteproc core relies on the offsets.

Agreed

> 
> I can only ensure the alignment within this resource structure with
> ready-available access and conversion to/from a 64-bit type, as long as
> the resource is starting on a 64-bit boundary.
> 
>> 
>> To overcome this, there is multiple solutions:
>> 
>> - Split the 64 bits fields into 32bits low and high parts:
>> Since all resources are aligned on 32bits, it will be ok
> 
> Yes, this is one solution. At the same time, this means you need
> additional conversion logic for converting to and from 64-bit field. In
> this particular case, da is the address of the trace buffer pointer on a
> 64-bit processor, so we can directly use the address of the trace
> buffer. Guess it is a question of easier translation vs packing the
> resource table as tight as possible.

You simply have to add two wrapper such as the following:

static inline void rproc_rsc_set_addr(u32 *low, u32 *hi, u64 val)
{
	*low = lower_32_bits(val);
	*hi = upper_32_bits(val);
}

static inline u64 rproc_rsc_get_addr(u32 low, u32 hi)
{
	return ((u64) hi << 32) | low;
}

This is not really difficult to use and will ensure your new trace
resource can be used easily without breaking 32 bits alignment.
Breaking compatibility is an option also and it is probably needed
to document it clearly if it is chosen to do so.

> 
>> 
>> - Use memcpy_from/to_io when reading/writing such fields
>> As I said in a previous message this should probably be used since
>> the memories that are accessed by rproc are io mem (ioremap in almost
>> all drivers).
> 
> Anything running out of DDR actually doesn't need the io mem semantics,
> so we actually need to be fixing the drivers. Blindly changing the
> current memcpy to memcpy_to_io in the core loader is also not right. Any
> internal memories properties will actually depend on the processor and
> SoC. Eg: The R5 TCM interfaces in general can be treated as normal memories.

Agreed, this is most of the case indeed where the memories are actually
accessible directly. But using ioremap potentially creates a mapping that
does not support misaligned accesses and so accesses should be always aligned.
memcpy_from/to_io ensures that.
IMHO, there is probably something to be rework since the drivers are mapping
the memories but the core is accessing this memory, knowing nothing about
how it was mapped.

Regards,

Clément

> 
> regards
> Suman
> 
>> 
>> Regards,
>> 
>> Clément
>> 
>> [1]
>> https://github.com/OpenAMP/open-amp/blob/master/apps/machine/zynqmp_r5/rsc_table.h
>>>
>>>
>>>
>>>
>>>>>
>>>>
>>>> Sounds good to me.
>>>>
>>>> Thanks,
> >>> Bjorn

  reply	other threads:[~2020-05-22 19:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 20:46 [PATCH 0/4] Update K3 DSP remoteproc driver for C71x DSPs Suman Anna
2020-03-25 20:46 ` [PATCH 1/4] dt-bindings: remoteproc: k3-dsp: Update bindings " Suman Anna
2020-03-31 21:56   ` Rob Herring
2020-03-25 20:46 ` [PATCH 2/4] remoteproc: introduce version element into resource type field Suman Anna
2020-05-21 17:54   ` Bjorn Andersson
2020-05-21 19:06     ` Suman Anna
2020-05-21 19:21       ` Bjorn Andersson
2020-05-21 19:29         ` Suman Anna
2020-05-21 19:41           ` Bjorn Andersson
2020-05-21 19:52             ` Suman Anna
2020-03-25 20:47 ` [PATCH 3/4] remoteproc: add support for a new 64-bit trace version Suman Anna
2020-05-21 18:04   ` Bjorn Andersson
2020-05-21 19:42     ` Suman Anna
2020-05-22 16:54       ` Suman Anna
2020-05-22 17:33         ` Bjorn Andersson
2020-05-22 18:03           ` Clément Leger
2020-05-22 18:10             ` Clément Leger
2020-05-22 18:59               ` Suman Anna
2020-05-22 19:28                 ` Clément Leger [this message]
2020-03-25 20:47 ` [PATCH 4/4] remoteproc/k3-dsp: Add support for C71x DSPs Suman Anna
2020-04-27 19:54   ` Suman Anna
2020-05-21 15:57 ` [PATCH 0/4] Update K3 DSP remoteproc driver " Suman Anna

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=811755772.4219337.1590175727911.JavaMail.zimbra@kalray.eu \
    --to=cleger@kalray.eu \
    --cc=arnaud.pouliquen@st.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=loic.pallardy@st.com \
    --cc=lokeshvutla@ti.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=robh+dt@kernel.org \
    --cc=s-anna@ti.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;
as well as URLs for NNTP newsgroup(s).