mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: "Shenhar, Talel" <talel@amazon.com>, bp@alien8.de
Cc: talelshenhar@gmail.com, shellykz@amazon.com,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: RFC on drivers/memory vs drivers/edac memory mapping for DDR Controller
Date: Mon, 2 Jan 2023 14:59:07 +0100	[thread overview]
Message-ID: <21c6dd41-3e6f-26c6-d6ca-25102e992c18@linaro.org> (raw)
In-Reply-To: <4bd90224-d09a-1f21-92e6-51c967d68a39@amazon.com>

On 02/01/2023 14:44, Shenhar, Talel wrote:
> 
> On 1/2/2023 2:47 PM, Krzysztof Kozlowski wrote:
>> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
>>
>>
>>
>> On 02/01/2023 13:17, Shenhar, Talel wrote:
>>> Hi,
>>>
>>> Want to consult on a topic that involve both drivers/memory and
>>> drivers/edac.
>>>
>>> * We want to introduce driver that reads DDR controller RAS register and
>>> notify for ECC errors by using EDAC MC API found in drivers/edac.
>>> * We also want to have a capability to dynamically change DDR refresh
>>> rate based on thermal values (best to be done in drivers/memory ?).
>>>
>>> The pain point here is that both capabilities are controlled from the
>>> DDR controller.
>>> This create issue while using
>>> devm_platform_ioremap_resource*->devm_request_mem_region which prevent
>>> two mapping of same area.
>> This could be avoided but the true problem is that you have two devices
>> for same memory mapping. Devicetree does not allow it and it points to
>> some wrong hardware representation in DTS.
>>
>>> It seems to be expected problem as we have 2 "framework" (edac and
>>> memory) split while both aim for same HW unit.
>>> What is the recommended way to face such conflicts?
>> You now mix Devicetree and Linux drivers. You can have same IO address
>> space used by multiple drivers, even though it is not always good
>> approach (concurrent and conflicting change of same settings).
>>
>> HW description is irrelevant to this.
>>
>>> We had several concept in mind but would love to get your point of view
>>> first.
>> Describe hardware accurately and completely. This solves all the
>> problems, doesn't it? Linux drivers do not depend on it and you can make
>> it differently.
> 
> Describing the hardware accurately and completely means to have multiple 
> reg property in the device-tree, right?

Not necessarily. It means to describe the devices, the hardware, not
drivers.

> 
> That way we will split the HW description to smaller bits rather then 
> just big "ddrc", and that shall allow us to have two drivers and each 
> one will get its own share of the split, right?

Not necessarily. If you have one hardware, why would you split it? It's
only one memory controller, not two.

> That was the intent of solution 1 below.
> 
>>
>>> Things we had in mind:
>>> 1) map more specific region to avoid conflict (we don't need the same
>>> registers on both entity so if we do very specific multiple mapping this
>>> shall be resolved)
>>> 2) use other kernel API for mapping that doesn't do request_mem_region
>>> (or use the reserve only for one of them)
>>> 3) have single driver (edac mc) handle also the refresh rate
>>> 4) export edac_mc.h and have the drivers/memory have all the needed code
>>> to do both edac and refresh rate under drivers/memory
>> None of these address the core problem - possibly inaccurate hardware
>> description...
> 
> Can you elaborate on this inaccurate hardware description?

I explained - using same IO address suggests you used Linux driver
structure in your hardware description. I assume we talk here about
Devicetree. If not, that's quite different case... then I guess ACPI,
which I do not care - I am not it's maintainer.

> Also, I'd like to write down my understanding of your response from above:
> 
> it seems you see as possible solution both using different API that 
> allow overlapping (solution 2) and also for splitting the IO address 
> space to finer pieces to achieve full HW description (solution 1)

No. Sorry, we probably talk about two different things.

You started writing that you have a hardware described as one IO address
space and now have a problem developing drivers for it.

The driver model for this is entirely different problem than problem of
accurate hardware description. Whether you described HW correct or not,
I don't know. You did not provide any details here, like DTS or bindings
(if we talk about Devicetree).

Having multiple drivers using similar resources is already solved many
times (MFD, syscon).

Whether the solution is correct or not is one more (third) topic: poking
to same IO address space from two different drivers is error-prone. This
one is solvable with splitting IO address space.

Best regards,
Krzysztof


  reply	other threads:[~2023-01-02 13:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-02 12:17 Shenhar, Talel
2023-01-02 12:47 ` Krzysztof Kozlowski
2023-01-02 13:44   ` Shenhar, Talel
2023-01-02 13:59     ` Krzysztof Kozlowski [this message]
2023-01-02 16:21       ` Shenhar, Talel
2023-01-02 16:25         ` Krzysztof Kozlowski
2023-01-03 13:12           ` Shenhar, Talel
2023-01-03 13:23             ` Krzysztof Kozlowski
2023-01-03 13:47               ` Shenhar, Talel
2023-01-03 14:02                 ` Krzysztof Kozlowski
2023-01-03 14:24                 ` Krzysztof Kozlowski
2023-01-03 14:34                   ` Shenhar, Talel
2023-01-02 13:43 ` Borislav Petkov
2023-01-02 16:14   ` Shenhar, Talel
2023-01-02 16:23     ` Borislav Petkov

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=21c6dd41-3e6f-26c6-d6ca-25102e992c18@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shellykz@amazon.com \
    --cc=talel@amazon.com \
    --cc=talelshenhar@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

all inboxes | Powered by JetHome®