All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal
@ 2022-11-02 12:54 Wolfram Sang
  2022-11-02 12:54 ` [RFC PATCH 1/2] mmc: tmio: remove tmio_mmc_k(un)map_atomic helpers Wolfram Sang
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Wolfram Sang @ 2022-11-02 12:54 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Wolfram Sang

Thanks to Adrian's patches mentioned in patch 1 in this series, we can
now simplify the TMIO driver a tad further to ease future refactoring.
This is marked as RFC because testing the corner cases is not so easy so
extra eyes for review are more than welcome.

Thanks and happy hacking!

   Wolfram


Wolfram Sang (2):
  mmc: tmio: remove tmio_mmc_k(un)map_atomic helpers
  mmc: tmio: remove 'alignment_shift' from platform data

 drivers/mmc/host/renesas_sdhi_core.c     |  1 -
 drivers/mmc/host/renesas_sdhi_sys_dmac.c | 10 +++++-----
 drivers/mmc/host/tmio_mmc.h              | 11 -----------
 drivers/mmc/host/tmio_mmc_core.c         | 13 +++++++------
 include/linux/mfd/tmio.h                 |  1 -
 5 files changed, 12 insertions(+), 24 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RFC PATCH 1/2] mmc: tmio: remove tmio_mmc_k(un)map_atomic helpers
  2022-11-02 12:54 [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal Wolfram Sang
@ 2022-11-02 12:54 ` Wolfram Sang
  2022-11-02 12:54 ` [RFC PATCH 2/2] mmc: tmio: remove 'alignment_shift' from platform data Wolfram Sang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2022-11-02 12:54 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Wolfram Sang

After a8402aed8ca5 ("mmc: tmio_mmc_core: Remove
local_irq_{save,restore}() around k[un]map_atomic()") and ac91578a6812
("mmc: tmio_mmc_core: Replace kmap_atomic() with kmap_local_page()"),
the helpers contain just a single call. Putting it directly in the code
makes it actually more readable. More so, because we now avoid the
'offset' calculation when mapping/unmapping and just use it when we need
it in the copy routines.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/host/renesas_sdhi_sys_dmac.c |  6 +++---
 drivers/mmc/host/tmio_mmc.h              | 11 -----------
 drivers/mmc/host/tmio_mmc_core.c         | 13 +++++++------
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c
index e9cc6c15d229..c4545cb143dd 100644
--- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c
@@ -254,11 +254,11 @@ static void renesas_sdhi_sys_dmac_start_dma_tx(struct tmio_mmc_host *host)
 
 	/* The only sg element can be unaligned, use our bounce buffer then */
 	if (!aligned) {
-		void *sg_vaddr = tmio_mmc_kmap_atomic(sg);
+		void *sg_vaddr = kmap_local_page(sg_page(sg));
 
 		sg_init_one(&host->bounce_sg, host->bounce_buf, sg->length);
-		memcpy(host->bounce_buf, sg_vaddr, host->bounce_sg.length);
-		tmio_mmc_kunmap_atomic(sg, sg_vaddr);
+		memcpy(host->bounce_buf, sg_vaddr + sg->offset, host->bounce_sg.length);
+		kunmap_local(sg_vaddr);
 		host->sg_ptr = &host->bounce_sg;
 		sg = host->sg_ptr;
 	}
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index e36ff80108e6..df6b3dccf96a 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -204,17 +204,6 @@ void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
 void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i);
 irqreturn_t tmio_mmc_irq(int irq, void *devid);
 
-static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg)
-{
-	return kmap_local_page(sg_page(sg)) + sg->offset;
-}
-
-static inline void tmio_mmc_kunmap_atomic(struct scatterlist *sg,
-					  void *virt)
-{
-	kunmap_local(virt - sg->offset);
-}
-
 #ifdef CONFIG_PM
 int tmio_mmc_host_runtime_suspend(struct device *dev);
 int tmio_mmc_host_runtime_resume(struct device *dev);
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 6d50c0dd53fe..6d8597f1d22d 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -421,8 +421,8 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
 		return;
 	}
 
-	sg_virt = tmio_mmc_kmap_atomic(host->sg_ptr);
-	buf = (unsigned short *)(sg_virt + host->sg_off);
+	sg_virt = kmap_local_page(sg_page(host->sg_ptr));
+	buf = (unsigned short *)(sg_virt + host->sg_ptr->offset + host->sg_off);
 
 	count = host->sg_ptr->length - host->sg_off;
 	if (count > data->blksz)
@@ -436,7 +436,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
 
 	host->sg_off += count;
 
-	tmio_mmc_kunmap_atomic(host->sg_ptr, sg_virt);
+	kunmap_local(sg_virt);
 
 	if (host->sg_off == host->sg_ptr->length)
 		tmio_mmc_next_sg(host);
@@ -445,10 +445,11 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
 static void tmio_mmc_check_bounce_buffer(struct tmio_mmc_host *host)
 {
 	if (host->sg_ptr == &host->bounce_sg) {
-		void *sg_vaddr = tmio_mmc_kmap_atomic(host->sg_orig);
+		void *sg_virt = kmap_local_page(sg_page(host->sg_orig));
 
-		memcpy(sg_vaddr, host->bounce_buf, host->bounce_sg.length);
-		tmio_mmc_kunmap_atomic(host->sg_orig, sg_vaddr);
+		memcpy(sg_virt + host->sg_orig->offset, host->bounce_buf,
+		       host->bounce_sg.length);
+		kunmap_local(sg_virt);
 	}
 }
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC PATCH 2/2] mmc: tmio: remove 'alignment_shift' from platform data
  2022-11-02 12:54 [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal Wolfram Sang
  2022-11-02 12:54 ` [RFC PATCH 1/2] mmc: tmio: remove tmio_mmc_k(un)map_atomic helpers Wolfram Sang
@ 2022-11-02 12:54 ` Wolfram Sang
  2022-11-02 17:59 ` [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal Arnd Bergmann
  2022-11-18  9:45 ` Ulf Hansson
  3 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2022-11-02 12:54 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-renesas-soc, Wolfram Sang

There is only one alignment shift for one type of Renesas SDHI. Encode
it directly in its DMA driver to reduce complexity and ease further
simplifications.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/mmc/host/renesas_sdhi_core.c     | 1 -
 drivers/mmc/host/renesas_sdhi_sys_dmac.c | 4 ++--
 include/linux/mfd/tmio.h                 | 1 -
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index b970699743e0..1bc2c2997ead 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -1018,7 +1018,6 @@ int renesas_sdhi_probe(struct platform_device *pdev,
 	dma_priv->filter = shdma_chan_filter;
 	dma_priv->enable = renesas_sdhi_enable_dma;
 
-	mmc_data->alignment_shift = 1; /* 2-byte alignment */
 	mmc_data->capabilities |= MMC_CAP_MMC_HIGHSPEED;
 
 	/*
diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c
index c4545cb143dd..b559ad38b667 100644
--- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c
@@ -160,7 +160,7 @@ static void renesas_sdhi_sys_dmac_start_dma_rx(struct tmio_mmc_host *host)
 	dma_cookie_t cookie;
 	int ret, i;
 	bool aligned = true, multiple = true;
-	unsigned int align = (1 << host->pdata->alignment_shift) - 1;
+	unsigned int align = 1;	/* 2-byte alignment */
 
 	for_each_sg(sg, sg_tmp, host->sg_len, i) {
 		if (sg_tmp->offset & align)
@@ -232,7 +232,7 @@ static void renesas_sdhi_sys_dmac_start_dma_tx(struct tmio_mmc_host *host)
 	dma_cookie_t cookie;
 	int ret, i;
 	bool aligned = true, multiple = true;
-	unsigned int align = (1 << host->pdata->alignment_shift) - 1;
+	unsigned int align = 1;	/* 2-byte alignment */
 
 	for_each_sg(sg, sg_tmp, host->sg_len, i) {
 		if (sg_tmp->offset & align)
diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index 27264fe4b3b9..e8bf90281ba0 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -102,7 +102,6 @@ struct tmio_mmc_data {
 	unsigned long			capabilities2;
 	unsigned long			flags;
 	u32				ocr_mask;	/* available voltages */
-	int				alignment_shift;
 	dma_addr_t			dma_rx_offset;
 	unsigned int			max_blk_count;
 	unsigned short			max_segs;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal
  2022-11-02 12:54 [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal Wolfram Sang
  2022-11-02 12:54 ` [RFC PATCH 1/2] mmc: tmio: remove tmio_mmc_k(un)map_atomic helpers Wolfram Sang
  2022-11-02 12:54 ` [RFC PATCH 2/2] mmc: tmio: remove 'alignment_shift' from platform data Wolfram Sang
@ 2022-11-02 17:59 ` Arnd Bergmann
  2022-11-02 18:58   ` Wolfram Sang
  2022-11-18  9:45 ` Ulf Hansson
  3 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2022-11-02 17:59 UTC (permalink / raw)
  To: Wolfram Sang, linux-mmc @ vger . kernel . org; +Cc: Linux-Renesas

On Wed, Nov 2, 2022, at 13:54, Wolfram Sang wrote:
> Thanks to Adrian's patches mentioned in patch 1 in this series, we can
> now simplify the TMIO driver a tad further to ease future refactoring.
> This is marked as RFC because testing the corner cases is not so easy so
> extra eyes for review are more than welcome.
>
> Thanks and happy hacking!
>

Hi Wolfram,

I haven't posted my PXA boardfile patches yet, but after that
series, the separate tmio MFD devices (MFD_TMIO, MFD_ASIC3)
will all be gone, and tmio-mmc will only be used by SuperH,
Arm MACH_RENESAS and MACH_UNIPHIER. I hope this doesn't conflict
too much with your work and instead opens up further cleanups.

       Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal
  2022-11-02 17:59 ` [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal Arnd Bergmann
@ 2022-11-02 18:58   ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2022-11-02 18:58 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-mmc @ vger . kernel . org, Linux-Renesas

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

Hi Arnd,

> I haven't posted my PXA boardfile patches yet, but after that
> series, the separate tmio MFD devices (MFD_TMIO, MFD_ASIC3)
> will all be gone, and tmio-mmc will only be used by SuperH,
> Arm MACH_RENESAS and MACH_UNIPHIER. I hope this doesn't conflict
> too much with your work and instead opens up further cleanups.

Definately the latter. You didn't send the patches but you did send the
coverletter for the PXA work. Just skimming from that, I see potential
for more cleanups regarding the TMIO MMC/Renesas SDHI driver. Looking
really forward to it :)

Happy hacking,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal
  2022-11-02 12:54 [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal Wolfram Sang
                   ` (2 preceding siblings ...)
  2022-11-02 17:59 ` [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal Arnd Bergmann
@ 2022-11-18  9:45 ` Ulf Hansson
  3 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2022-11-18  9:45 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-mmc, linux-renesas-soc

On Wed, 2 Nov 2022 at 13:54, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> Thanks to Adrian's patches mentioned in patch 1 in this series, we can
> now simplify the TMIO driver a tad further to ease future refactoring.
> This is marked as RFC because testing the corner cases is not so easy so
> extra eyes for review are more than welcome.
>
> Thanks and happy hacking!
>
>    Wolfram
>
>
> Wolfram Sang (2):
>   mmc: tmio: remove tmio_mmc_k(un)map_atomic helpers
>   mmc: tmio: remove 'alignment_shift' from platform data
>
>  drivers/mmc/host/renesas_sdhi_core.c     |  1 -
>  drivers/mmc/host/renesas_sdhi_sys_dmac.c | 10 +++++-----
>  drivers/mmc/host/tmio_mmc.h              | 11 -----------
>  drivers/mmc/host/tmio_mmc_core.c         | 13 +++++++------
>  include/linux/mfd/tmio.h                 |  1 -
>  5 files changed, 12 insertions(+), 24 deletions(-)
>

Applied for next, thanks!

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-18  9:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 12:54 [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal Wolfram Sang
2022-11-02 12:54 ` [RFC PATCH 1/2] mmc: tmio: remove tmio_mmc_k(un)map_atomic helpers Wolfram Sang
2022-11-02 12:54 ` [RFC PATCH 2/2] mmc: tmio: remove 'alignment_shift' from platform data Wolfram Sang
2022-11-02 17:59 ` [RFC PATCH 0/2] mmc: tmio: further cleanups after kmap_atomic removal Arnd Bergmann
2022-11-02 18:58   ` Wolfram Sang
2022-11-18  9:45 ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.