Re: [PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode

2020-10-09 Thread Peter Ujfalusi



On 09/10/2020 14.59, Nishanth Menon wrote:
> On 10:43-20201009, Peter Ujfalusi wrote:
>> Nishanth,
>>
>> On 09/10/2020 6.02, Nishanth Menon wrote:
>>> On 14:52-20201008, Peter Ujfalusi wrote:
 -  ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
 +  ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
ring->size * (4 << ring->elm_size),
>ring_mem_dma, GFP_KERNEL);
>>>
>>> Any chance of getting a cleanup of the file for 5.11? I know this series
>>> has'nt introduced this warning or set of warnings, but I am starting to
>>> get concerned that we are carrying over too much of a debt now?
>>>
>>> https://pastebin.ubuntu.com/p/tT2kPDsCWD/
>>
>> Right, you know that git blame points the finger at you on ti_sci.c errors?
>>
>> Never the less, I have run the tool locally on my linux-next-wip with
>> these patches:
>> https://pastebin.ubuntu.com/p/myJwjvKYw8/
>>
>> and I don't see the noise you see.
> 
> 
> Hmm.. Looks like gcc9/10 make W=2 does generate those warnings with
> container_of .. I will investigate it later today.. just checking to see
> if it is just me seeing this..

It looks that way. W=2 is a kind of noisy if you throw it at a random
file, like:
make kernel/exec_domain.o W=2

> Yes, I introduced the container_of() usage, which is pretty standard
> usage in other subsystems as well, but lots of checks have gotten
> stricter and catches new issues since I introduced things in 2016..
> Time to get the new issues (if valid) fixed up.
> 
>>
>>> Checkpatch does point this:
>>>
>>> --- /tmp/kernel-patch-verify.25812/ptest_check-start2020-10-08
>>> 19:33:31.025898581 +
>>> +++ /tmp/kernel-patch-verify.25812/ptest_check-end  2020-10-08
>>> 19:33:31.593893830 +
>>> @@ -0,0 +1,6 @@
>>> +CHECK: Alignment should match open parenthesis
>>> +#84: FILE: drivers/soc/ti/k3-ringacc.c:657:
>>> ++  ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
>>> +   ring->size * (4 << ring->elm_size),
>>
>> Yes, that's correct. Readability VS very long lines
> 
> 
> checkpatch limit in linux kernel is now 100 chars (I know, it is
> hard to update .vimrc etc.. to the new norm..)but, anyways.. will
> be good not to see such warnings esp when you are touching the same
> lines.

Right, I can send v3 on Monday after a bit of re-adjustment of my editors ;)

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


Re: [PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode

2020-10-09 Thread Nishanth Menon
On 10:43-20201009, Peter Ujfalusi wrote:
> Nishanth,
> 
> On 09/10/2020 6.02, Nishanth Menon wrote:
> > On 14:52-20201008, Peter Ujfalusi wrote:
> >> -  ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
> >> +  ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
> >>ring->size * (4 << ring->elm_size),
> >>>ring_mem_dma, GFP_KERNEL);
> > 
> > Any chance of getting a cleanup of the file for 5.11? I know this series
> > has'nt introduced this warning or set of warnings, but I am starting to
> > get concerned that we are carrying over too much of a debt now?
> > 
> > https://pastebin.ubuntu.com/p/tT2kPDsCWD/
> 
> Right, you know that git blame points the finger at you on ti_sci.c errors?
> 
> Never the less, I have run the tool locally on my linux-next-wip with
> these patches:
> https://pastebin.ubuntu.com/p/myJwjvKYw8/
> 
> and I don't see the noise you see.


Hmm.. Looks like gcc9/10 make W=2 does generate those warnings with
container_of .. I will investigate it later today.. just checking to see
if it is just me seeing this..

Yes, I introduced the container_of() usage, which is pretty standard
usage in other subsystems as well, but lots of checks have gotten
stricter and catches new issues since I introduced things in 2016..
Time to get the new issues (if valid) fixed up.

> 
> > Checkpatch does point this:
> > 
> > --- /tmp/kernel-patch-verify.25812/ptest_check-start2020-10-08
> > 19:33:31.025898581 +
> > +++ /tmp/kernel-patch-verify.25812/ptest_check-end  2020-10-08
> > 19:33:31.593893830 +
> > @@ -0,0 +1,6 @@
> > +CHECK: Alignment should match open parenthesis
> > +#84: FILE: drivers/soc/ti/k3-ringacc.c:657:
> > ++  ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
> > +   ring->size * (4 << ring->elm_size),
> 
> Yes, that's correct. Readability VS very long lines


checkpatch limit in linux kernel is now 100 chars (I know, it is
hard to update .vimrc etc.. to the new norm..)but, anyways.. will
be good not to see such warnings esp when you are touching the same
lines.

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


Re: [PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode

2020-10-09 Thread Peter Ujfalusi
Nishanth,

On 09/10/2020 6.02, Nishanth Menon wrote:
> On 14:52-20201008, Peter Ujfalusi wrote:
>> -ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
>> +ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
>>  ring->size * (4 << ring->elm_size),
>>  >ring_mem_dma, GFP_KERNEL);
> 
> Any chance of getting a cleanup of the file for 5.11? I know this series
> has'nt introduced this warning or set of warnings, but I am starting to
> get concerned that we are carrying over too much of a debt now?
> 
> https://pastebin.ubuntu.com/p/tT2kPDsCWD/

Right, you know that git blame points the finger at you on ti_sci.c errors?

Never the less, I have run the tool locally on my linux-next-wip with
these patches:
https://pastebin.ubuntu.com/p/myJwjvKYw8/

and I don't see the noise you see.

> Checkpatch does point this:
> 
> --- /tmp/kernel-patch-verify.25812/ptest_check-start  2020-10-08
> 19:33:31.025898581 +
> +++ /tmp/kernel-patch-verify.25812/ptest_check-end2020-10-08
> 19:33:31.593893830 +
> @@ -0,0 +1,6 @@
> +CHECK: Alignment should match open parenthesis
> +#84: FILE: drivers/soc/ti/k3-ringacc.c:657:
> ++ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
> + ring->size * (4 << ring->elm_size),

Yes, that's correct. Readability VS very long lines

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


Re: [PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode

2020-10-08 Thread Nishanth Menon
On 14:52-20201008, Peter Ujfalusi wrote:
> - ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
> + ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
>   ring->size * (4 << ring->elm_size),
>   >ring_mem_dma, GFP_KERNEL);

Any chance of getting a cleanup of the file for 5.11? I know this series
has'nt introduced this warning or set of warnings, but I am starting to
get concerned that we are carrying over too much of a debt now?

https://pastebin.ubuntu.com/p/tT2kPDsCWD/

Checkpatch does point this:

--- /tmp/kernel-patch-verify.25812/ptest_check-start2020-10-08
19:33:31.025898581 +
+++ /tmp/kernel-patch-verify.25812/ptest_check-end  2020-10-08
19:33:31.593893830 +
@@ -0,0 +1,6 @@
+CHECK: Alignment should match open parenthesis
+#84: FILE: drivers/soc/ti/k3-ringacc.c:657:
++  ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
+   ring->size * (4 << ring->elm_size),

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


[PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode

2020-10-08 Thread Peter Ujfalusi
In RING mode the ringacc does not access the ring memory. In this access
mode the ringacc coherency does not have meaning.

If the ring is configured in RING mode, then the ringacc itself will not
access to the ring memory. Only the requester (user) of the ring is going
to read/write to the memory.
Extend the ring configuration parameters with a device pointer to be used
for DMA API when the ring is configured in RING mode.

Extending the ring configuration struct will allow per ring selection of
device to be used for allocation, thus allowing per ring coherency.

To avoid regression, fall back to use the ringacc dev in case the alloc_dev
is not provided.

Signed-off-by: Peter Ujfalusi 
Reviewed-by: Grygorii Strashko 
---
 drivers/soc/ti/k3-ringacc.c   | 14 +++---
 include/linux/soc/ti/k3-ringacc.h |  5 +
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
index 9ddd77113c5a..7d0b4092fce8 100644
--- a/drivers/soc/ti/k3-ringacc.c
+++ b/drivers/soc/ti/k3-ringacc.c
@@ -141,6 +141,7 @@ struct k3_ring_state {
  * @parent: Pointer on struct @k3_ringacc
  * @use_count: Use count for shared rings
  * @proxy_id: RA Ring Proxy Id (only if @K3_RINGACC_RING_USE_PROXY)
+ * @dma_dev: device to be used for DMA API (allocation, mapping)
  */
 struct k3_ring {
struct k3_ring_rt_regs __iomem *rt;
@@ -160,6 +161,7 @@ struct k3_ring {
struct k3_ringacc   *parent;
u32 use_count;
int proxy_id;
+   struct device   *dma_dev;
 };
 
 struct k3_ringacc_ops {
@@ -508,11 +510,12 @@ int k3_ringacc_ring_free(struct k3_ring *ring)
 
k3_ringacc_ring_free_sci(ring);
 
-   dma_free_coherent(ringacc->dev,
+   dma_free_coherent(ring->dma_dev,
  ring->size * (4 << ring->elm_size),
  ring->ring_mem_virt, ring->ring_mem_dma);
ring->flags = 0;
ring->ops = NULL;
+   ring->dma_dev = NULL;
if (ring->proxy_id != K3_RINGACC_PROXY_NOT_USED) {
clear_bit(ring->proxy_id, ringacc->proxy_inuse);
ring->proxy = NULL;
@@ -633,8 +636,12 @@ int k3_ringacc_ring_cfg(struct k3_ring *ring, struct 
k3_ring_cfg *cfg)
switch (ring->mode) {
case K3_RINGACC_RING_MODE_RING:
ring->ops = _ring_mode_ring_ops;
+   ring->dma_dev = cfg->dma_dev;
+   if (!ring->dma_dev)
+   ring->dma_dev = ringacc->dev;
break;
case K3_RINGACC_RING_MODE_MESSAGE:
+   ring->dma_dev = ringacc->dev;
if (ring->proxy)
ring->ops = _ring_mode_proxy_ops;
else
@@ -646,7 +653,7 @@ int k3_ringacc_ring_cfg(struct k3_ring *ring, struct 
k3_ring_cfg *cfg)
goto err_free_proxy;
}
 
-   ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
+   ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
ring->size * (4 << ring->elm_size),
>ring_mem_dma, GFP_KERNEL);
if (!ring->ring_mem_virt) {
@@ -669,12 +676,13 @@ int k3_ringacc_ring_cfg(struct k3_ring *ring, struct 
k3_ring_cfg *cfg)
return 0;
 
 err_free_mem:
-   dma_free_coherent(ringacc->dev,
+   dma_free_coherent(ring->dma_dev,
  ring->size * (4 << ring->elm_size),
  ring->ring_mem_virt,
  ring->ring_mem_dma);
 err_free_ops:
ring->ops = NULL;
+   ring->dma_dev = NULL;
 err_free_proxy:
ring->proxy = NULL;
return ret;
diff --git a/include/linux/soc/ti/k3-ringacc.h 
b/include/linux/soc/ti/k3-ringacc.h
index 5a472eca5ee4..658dc71d2901 100644
--- a/include/linux/soc/ti/k3-ringacc.h
+++ b/include/linux/soc/ti/k3-ringacc.h
@@ -67,6 +67,9 @@ struct k3_ring;
  *  few times. It's usable when the same ring is used as Free Host PD ring
  *  for different flows, for example.
  *  Note: Locking should be done by consumer if required
+ * @dma_dev: Master device which is using and accessing to the ring
+ * memory when the mode is K3_RINGACC_RING_MODE_RING. Memory allocations
+ * should be done using this device.
  */
 struct k3_ring_cfg {
u32 size;
@@ -74,6 +77,8 @@ struct k3_ring_cfg {
enum k3_ring_mode mode;
 #define K3_RINGACC_RING_SHARED BIT(1)
u32 flags;
+
+   struct device *dma_dev;
 };
 
 #define K3_RINGACC_RING_ID_ANY (-1)
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki