mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Ungerer <gerg@kernel.org>
To: Angelo Dureghello <adureghello@baylibre.com>
Cc: Arnd Bergmann <arnd@kernel.org>,
	linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org,
	dmaengine@vger.kernel.org, linux-can@vger.kernel.org,
	linux-spi@vger.kernel.org, Vladimir Oltean <olteanv@gmail.com>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [RFC 4/4] m68k: coldfire: fix non-standard readX()/writeX() functions
Date: Sun, 31 May 2026 23:42:26 +1000	[thread overview]
Message-ID: <2b532d56-dce4-4f6d-84e0-2fd87d5494f8@kernel.org> (raw)
In-Reply-To: <CALSJ-wDY_8SMAvKT0L6wMbH1=w5pZNmV=xyeX1REb=BMRZWj-g@mail.gmail.com>

Hi Angelo,

(Adding Christoph to CC list)

On 25/5/26 07:34, Angelo Dureghello wrote:
> On Sun, May 24, 2026 at 02:17:07PM -0700, Angelo Dureghello wrote:
>> Hi All,
>>
>> On Sun, May 17, 2026 at 03:41:31PM -0700, Angelo Dureghello wrote:
>>> Hi,
>>>
>>> On Sun, May 17, 2026 at 03:04:23PM -0700, Angelo Dureghello wrote:
>>>> Hi Arnd,
>>>>
>>>> On Sun, May 17, 2026 at 10:08:22PM +0200, Arnd Bergmann wrote:
>>>>> On Sun, May 17, 2026, at 21:43, Angelo Dureghello wrote:
>>>>>> On Thu, May 07, 2026 at 10:43:01PM +1000, Greg Ungerer wrote:
>>>>>>> On 7/5/26 05:12, Arnd Bergmann wrote:
>>>>>>>> On Wed, May 6, 2026, at 16:26, Greg Ungerer wrote:
>>>>>>
>>>>>> [    2.270000] fsl-dspi fsl-dspi.0: Not able to get desc for DMA xfer
>>>>>> [    2.280000] fsl-dspi fsl-dspi.0: DMA transfer failed
>>>>>> [    2.280000] spi_master spi0: failed to transfer one message from queue
>>>>>> [    2.290000] spi_master spi0: noqueue transfer failed
>>>>>> [    2.290000] spi-nor spi0.1: probe with driver spi-nor failed with error -5
>>>>>>
>>>
>>> About this issue, it fails on dma_pool_alloc(), so tomorrow will check,
>>> i probably lost some dma config option.
>>>
>>
>> so i worked on this open issue above:
>>
>> - moved to master and rebased,
>> - crated a wip/edma branch,
>> - bisected and found the offending commit, before this, mcf-edma driver
>>    and connected spi-fsl-dspi (using edma) was both working correctly.
>>
>> 7a360df941a4bd60847208de59f1ac8b166265a2 is the first bad commit
>> commit 7a360df941a4bd60847208de59f1ac8b166265a2 (HEAD)
>> Author: Christoph Hellwig <hch@lst.de>
>> Date:   Thu Oct 12 09:52:27 2023 +0200
>>
>>      m68k: don't provide arch_dma_alloc for nommu/coldfire
>>
>>      Coldfire cores configured with a data cache can't provide coherent
>>      DMA allocations at all.
>>
>>      Instead of returning non-coherent kernel memory in this case,
>>      return NULL and fail the allocation.
>>
>>      The only driver that used to rely on the previous behavior (fec) has
>>      been switched to use non-coherent allocations for this case recently.
>>
>>      Signed-off-by: Christoph Hellwig <hch@lst.de>
>>      Reviewed-by: Greg Ungerer <gerg@linux-m68k.org>
>>      Tested-by: Greg Ungerer <gerg@linux-m68k.org>
>>
>>   arch/m68k/Kconfig      |  1 -
>>   arch/m68k/kernel/dma.c | 23 -----------------------
>>   2 files changed, 24 deletions(-)
>>
>> So i can try next week a patch for edma looking what has been done
>> in fec, and since i am probably the only with mcf54415, will test it
>> here.
>>
> 
> Looking into this better, looks like the above commit was meant for the
> majority on non-mmu ColdFire. I think mcf5441x and some other with mmu
> enabled can flag pages as "page cache disabled".

I don't think that is right. The way the underlying data cache is setup for
MMU ColdFire (via the ACR/CACR registers) means that individual pages cannot
be marked as non-cached. So coherent memory allocations are not possible -
at least the way things are today.

It would be possible to set aside a chunk of RAM at kernel startup time
to use as a pool for coherent allocations (since it could be marked as
non-cached via the ACR/CACR registers), but there is no code to support doing
that today.

Regards
Greg


> So i would re-enabled that code only for such mmu families.
> 
> Please let me know if i am correct.
> Thanks.
> 
>>>>>> DSPI is using edma, i will try to understand where the issue is asap.
>>>>>>
>>>>>> About how it works:
>>>>>> - for accesses to edma module (IP) mmio registers, must be native
>>>>>> big_endian, so using the "be" suffix in "mcf"_edma looks ok for me.
>>>>>
>>>>> The twist here is that with the way that readl() is defined on
>>>>> coldfire as a non-swapping operation, and the generic
>>>>> definition assuming the opposite in
>>>>>
>>>>> static inline u32 ioread32be(const void __iomem *addr)
>>>>> {
>>>>>          return swab32(readl(addr));
>>>>> }
>>>>>
>>>>> the function called ioread32be() actually tries to access
>>>>> the registers as little-endian. I can see two possible ways
>>>>> we got here, but don't know which one is currect:
>>>>>
>>>>> a) the device actually has little-endian registers (like it
>>>>>     does on i.MX, but unlike all other coldfire devices), and
>>>>>     you just never noticed because using ioread32be() worked
>>>>>     as you expected.
>>>>>
>>>>> b) you tested the driver using an ioread32be() definition that
>>>>>     did not have a byteswap and it correctly accessed big-endian
>>>>>     registers at the time, but the version in mainline today does
>>>>>     not.
>>>>
>>>> Ok. The ioread32be now works properly since i had applied Greg patches.
>>>> I generated an error in _probe on edma channel 2, reading status reg.
>>>> looks consistent:
>>>>
>>>> 	iowrite16(2121, regs->erqh);
>>>> 	iowrite8(0x77, regs->serq);
>>>> 	iowrite8(0x12, regs->ssrt);
>>>> 	
>>>> 	u32 status = ioread32be(regs->es);
>>>> 	printk("%s() status: %04x\n", __func__, status);
>>>>
>>>> [    0.140000] mcf_edma_probe() entering
>>>> [    0.140000] mcf_edma_probe(): allocating data
>>>> [    0.140000] mcf_edma_probe() status: 800012f8
>>>>
>>>> If i am not loosing myself in this r/w labyrinth, the path should be:
>>>>
>>>> 1) Greg removed coldfire readl/writel, leaving now the standard LE r/w,
>>>> 2) So the ioread32be swaps the standard LE read giving BE.
>>>>
>>>> Am i correct ?
>>>>
>>>>
>>>>>
>>>>>> - for accessing the "tcd" memory structure, that must be, from what i
>>>>>> remember, anyway in little endian, independently from the cpu core
>>>>>> endiannes, this is the reason that big_endian flag is needed, it is
>>>>>> used for tcd area accesses, so the IP module was built.
>>>>>> The tcd area may be similar to pci accesses (see mcf54415 RM 19.4.16).
>>>>>
>>>>> edma_read_tcdreg() calls into edma_readl(), which is the same function
>>>>> that is used for normal register access, so from what I can tell,
>>>>> they always use the same endianess here.
>>>>>
>>>>
>>>> If edma_readl was using
>>>>
>>>>          if (edma->big_endian)
>>>>                  val = ioread32be(addr);
>>>>
>>>> and never changed, without Greg patch, it was likely returning little
>>>> endian for coldfire and correct LE for other arch ? :)
>>>>
>>>> I remember something about tcd area was coded LE, but will investigate
>>>> better, now i am over midnight.
>>>>
>>>> Regards,
>>>> angelo
>>>>
>>>>>        Arnd
>>>
>>> Regards,
>>> angelo
>>
>> Regards,
>> angelo
> 
> Regards,
> angelo


  parent reply	other threads:[~2026-05-31 13:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 14:26 [RFC 1/4] net: fec: do not use readl()/writel() for ColdFire Greg Ungerer
2026-05-06 14:26 ` [RFC 2/4] net: smc91x: do not use readw()/writew() on ColdFire platforms Greg Ungerer
2026-05-06 14:26 ` [RFC 3/4] mmc: sdhci-esdhc-mcf: do not use readl()/writel() on ColdFire Greg Ungerer
2026-05-11 15:11   ` Ulf Hansson
2026-06-09 14:31     ` Greg Ungerer
2026-05-17 19:00   ` Angelo Dureghello
2026-05-18  7:17     ` Greg Ungerer
2026-05-06 14:26 ` [RFC 4/4] m68k: coldfire: fix non-standard readX()/writeX() functions Greg Ungerer
2026-05-06 16:14   ` Frank Li
2026-05-06 19:12   ` Arnd Bergmann
2026-05-07 12:43     ` Greg Ungerer
2026-05-07 12:59       ` Arnd Bergmann
2026-05-17 19:43       ` Angelo Dureghello
2026-05-17 20:08         ` Arnd Bergmann
2026-05-17 22:04           ` Angelo Dureghello
2026-05-17 22:41             ` Angelo Dureghello
2026-05-24 21:17               ` Angelo Dureghello
2026-05-24 21:34                 ` Angelo Dureghello
2026-05-25 13:39                   ` Angelo Dureghello
2026-05-31 13:42                   ` Greg Ungerer [this message]
2026-06-01 14:43                     ` Christoph Hellwig
2026-06-09 21:30                       ` Angelo Dureghello
2026-06-10  0:39                         ` Greg Ungerer
2026-05-07 13:30   ` Marc Kleine-Budde
2026-05-07 14:33     ` Greg Ungerer
2026-05-08  2:46 ` [RFC 1/4] net: fec: do not use readl()/writel() for ColdFire Wei Fang
2026-05-08  8:40   ` David Laight
2026-05-08 13:14     ` Greg Ungerer
2026-05-08 13:11   ` Greg Ungerer

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=2b532d56-dce4-4f6d-84e0-2fd87d5494f8@kernel.org \
    --to=gerg@kernel.org \
    --cc=adureghello@baylibre.com \
    --cc=arnd@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=olteanv@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

Powered by JetHome