diff mbox series

[03/14] mmc: sdhci: Replace kmap_atomic() with kmap_local_page()

Message ID 20221005101951.3165-4-adrian.hunter@intel.com (mailing list archive)
State New, archived
Headers show
Series mmc: Replace kmap_atomic() with kmap_local_page() | expand

Commit Message

Adrian Hunter Oct. 5, 2022, 10:19 a.m. UTC
kmap_local_page() is equivalent to kmap_atomic() except that it does not
disable page faults or preemption. Where possible kmap_local_page() is
preferred to kmap_atomic() - refer kernel highmem documentation.

In this case, there is no need to disable page faults or preemption, so
replace kmap_atomic() with kmap_local_page(), and, correspondingly,
kunmap_atomic() with kunmap_local().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Avri Altman Oct. 6, 2022, 7:03 a.m. UTC | #1
> kmap_local_page() is equivalent to kmap_atomic() except that it does not
> disable page faults or preemption. Where possible kmap_local_page() is
> preferred to kmap_atomic() - refer kernel highmem documentation.
> 
> In this case, there is no need to disable page faults or preemption, so replace
> kmap_atomic() with kmap_local_page(), and, correspondingly,
> kunmap_atomic() with kunmap_local().
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  drivers/mmc/host/sdhci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index
> 31d87ec7d055..fb6e9a81f198 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -697,12 +697,12 @@ static int sdhci_pre_dma_transfer(struct sdhci_host
> *host,
> 
>  static char *sdhci_kmap_atomic(struct scatterlist *sg)  {
> -       return kmap_atomic(sg_page(sg)) + sg->offset;
> +       return kmap_local_page(sg_page(sg)) + sg->offset;
>  }
> 
>  static void sdhci_kunmap_atomic(void *buffer)  {
> -       kunmap_atomic(buffer);
> +       kunmap_local(buffer);
kmap_local_page documentation, indicates that the unmapping should be done in reverse order.
Isn't it something that the callers of sdhci_kunmap_atomic now needs to attend?

Thanks,
Avri

>  }
> 
>  void sdhci_adma_write_desc(struct sdhci_host *host, void **desc,
> --
> 2.25.1
Adrian Hunter Oct. 6, 2022, 7:23 a.m. UTC | #2
On 6/10/22 10:03, Avri Altman wrote:
>> kmap_local_page() is equivalent to kmap_atomic() except that it does not
>> disable page faults or preemption. Where possible kmap_local_page() is
>> preferred to kmap_atomic() - refer kernel highmem documentation.
>>
>> In this case, there is no need to disable page faults or preemption, so replace
>> kmap_atomic() with kmap_local_page(), and, correspondingly,
>> kunmap_atomic() with kunmap_local().
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>> ---
>>  drivers/mmc/host/sdhci.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index
>> 31d87ec7d055..fb6e9a81f198 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -697,12 +697,12 @@ static int sdhci_pre_dma_transfer(struct sdhci_host
>> *host,
>>
>>  static char *sdhci_kmap_atomic(struct scatterlist *sg)  {
>> -       return kmap_atomic(sg_page(sg)) + sg->offset;
>> +       return kmap_local_page(sg_page(sg)) + sg->offset;
>>  }
>>
>>  static void sdhci_kunmap_atomic(void *buffer)  {
>> -       kunmap_atomic(buffer);
>> +       kunmap_local(buffer);
> kmap_local_page documentation, indicates that the unmapping should be done in reverse order.
> Isn't it something that the callers of sdhci_kunmap_atomic now needs to attend?

Nesting is strictly ordered in either case, so there is no change there.
i.e. the map management is stack based
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 31d87ec7d055..fb6e9a81f198 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -697,12 +697,12 @@  static int sdhci_pre_dma_transfer(struct sdhci_host *host,
 
 static char *sdhci_kmap_atomic(struct scatterlist *sg)
 {
-	return kmap_atomic(sg_page(sg)) + sg->offset;
+	return kmap_local_page(sg_page(sg)) + sg->offset;
 }
 
 static void sdhci_kunmap_atomic(void *buffer)
 {
-	kunmap_atomic(buffer);
+	kunmap_local(buffer);
 }
 
 void sdhci_adma_write_desc(struct sdhci_host *host, void **desc,