mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Marc Pignat <marc.pignat@hevs.ch>
Cc: Nicolas Ferre <nicolas.ferre@rfo.atmel.com>,
	ARM Linux Mailing List  <linux-arm-kernel@lists.arm.linux.org.uk>,
	Linux Kernel list <linux-kernel@vger.kernel.org>,
	Andrew Victor <andrew@sanpeople.com>,
	Pierre Ossman <drzeus@drzeus.cx>
Subject: Re: [PATCH] mmc-atmel : fix kunmap wrong usage
Date: Fri, 22 Jun 2007 13:00:23 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0706221237330.26363@blonde.wat.veritas.com> (raw)
In-Reply-To: <200706220828.18750.marc.pignat@hevs.ch>

On Fri, 22 Jun 2007, Marc Pignat wrote:
> from: Marc Pignat <marc.pignat@hevs.ch>
> 
> kunmap must be called on the pointer returned by kmap.

Not necessarily: an offset within the same page is acceptable.

> 
> Signed-off-by: Marc Pignat <marc.pignat@hevs.ch>
> 
> ---
> 
> N.B: This is the same patch as yesterday, with proper Signed-off-by and more 
> comments.
> 
> The buffer variable is used this way:
> 		buffer = kmap_atomic(sg->page, KM_BIO_SRC_IRQ) + sg->offset;
> So we can't do
> 		kunmap_atomic(buffer, KM_BIO_SRC_IRQ);
> we must do
> 		kunmap_atomic(buffer - sg->offset, KM_BIO_SRC_IRQ);
> 		
> Strangely this misuse showed no problem using CONFIG_SLAB, but oops using
> CONFIG_SLUB, (lkml ''Oops in a driver while using SLUB as a SLAB allocator").

Aren't you just guessing there?  Those kunmap_atomics in at91_mci.c
may look wrong to you, but they're not incorrect (so long as sg->offset
falls within the page, as it must do here to make sense of the page).
Especially not on ARM, where kunmap_atomic actually has no interest
in the argument passed.  And the oops was in the flush_dcache_page.

If you actually reproduced Nicolas' problem on ARM, and verified
that your patch then fixes it, please let us know: that will be
remarkably interesting.

I believe I posted the correct fix last night (or at least a safe fix
for now: Christoph Lameter may prefer to undo it and change ARM's
dma_mapping at leisure later), checking PageSlab in page_mapping;
and Linus has already put that one into his git tree.

But it would be good to hear from Nicolas whether that indeed fixes
his oops: I couldn't actually try my patch on ARM either.

Hugh

> 
> Regards
> 
> Marc
> 
> --- drivers/mmc/host/at91_mci.c-2.6.22-rc5.orig	2007-06-21 16:27:31.000000000 +0200
> +++ drivers/mmc/host/at91_mci.c-2.6.22-rc5	2007-06-21 16:42:48.000000000 +0200
> @@ -164,7 +164,7 @@ static inline void at91mci_sg_to_dma(str
>  		else
>  			memcpy(dmabuf, sgbuffer, amount);
> 
> -		kunmap_atomic(sgbuffer, KM_BIO_SRC_IRQ);
> +		kunmap_atomic(sgbuffer - sg->offset, KM_BIO_SRC_IRQ);
> 
>  		if (size == 0)
>  			break;
> @@ -293,7 +293,7 @@ static void at91mci_post_dma_read(struct
>  				buffer[index] = swab32(buffer[index]);
>  		}
> 
> -		kunmap_atomic(buffer, KM_BIO_SRC_IRQ);
> +		kunmap_atomic(buffer - sg->offset, KM_BIO_SRC_IRQ);
>  		flush_dcache_page(sg->page);

  reply	other threads:[~2007-06-22 12:28 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-21  9:30 Oops in a driver while using SLUB as a SLAB allocator Nicolas Ferre
2007-06-21 14:54 ` Marc Pignat
2007-06-21 14:57 ` Marc Pignat
2007-06-21 15:54   ` Nicolas Ferre
2007-06-22  6:28     ` [PATCH] mmc-atmel : fix kunmap wrong usage Marc Pignat
2007-06-22 12:00       ` Hugh Dickins [this message]
2007-06-22 13:34         ` Nicolas Ferre
2007-06-22 13:46           ` Hugh Dickins
2007-06-22 14:21           ` Marc Pignat
2007-06-22 14:58           ` Marc Pignat
2007-06-22 19:00       ` Jens Axboe
2007-06-22  9:09     ` Oops in a driver while using SLUB as a SLAB allocator Nicolas Ferre
2007-06-21 22:27 ` Hugh Dickins
2007-06-22  1:01   ` Christoph Lameter
2007-06-22  4:26     ` Hugh Dickins
2007-06-22  5:13       ` Christoph Lameter
2007-06-22  7:00       ` Russell King
2007-06-22  1:36   ` Christoph Lameter
2007-06-22  4:40     ` Hugh Dickins
2007-06-22  5:10       ` Christoph Lameter
2007-06-22  5:37         ` Hugh Dickins
2007-06-22 16:40       ` Linus Torvalds
2007-06-22 17:26         ` Christoph Lameter
2007-06-22 17:41         ` Christoph Lameter
2007-06-22 18:39           ` Hugh Dickins
2007-06-22 18:51             ` Christoph Lameter
2007-06-22 19:01               ` Hugh Dickins
2007-06-22 19:11                 ` Christoph Lameter
2007-06-22 20:21                   ` Hugh Dickins
2007-06-22 22:54                     ` Christoph Lameter
2007-06-22 20:15                 ` Christoph Lameter
2007-06-23 10:40                   ` Oleg Verych
2007-06-24  8:38             ` Russell King
2007-06-24 10:24               ` Hugh Dickins
2007-06-24 10:51                 ` Russell King
2007-06-25  0:25                   ` Hugh Dickins
2007-06-25 13:55                     ` Nicolas Ferre
2007-06-25 14:07                     ` Christoph Lameter
2007-06-25 16:42                       ` Hugh Dickins
2007-06-25 17:00                         ` Christoph Lameter
2007-06-25 17:23                           ` Hugh Dickins
2007-06-25 18:23                             ` Christoph Lameter
2007-06-25 18:43                               ` Hugh Dickins
2007-06-25 18:50                                 ` Christoph Lameter
2007-06-25 19:04                                   ` Hugh Dickins
2007-06-26 18:09                                     ` Christoph Lameter
2007-06-22 20:18         ` Russell King
2007-06-22  1:41   ` Christoph Lameter
2007-06-22  4:46     ` Hugh Dickins
2007-06-22  5:31       ` Christoph Lameter

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=Pine.LNX.4.64.0706221237330.26363@blonde.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=andrew@sanpeople.com \
    --cc=drzeus@drzeus.cx \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.pignat@hevs.ch \
    --cc=nicolas.ferre@rfo.atmel.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®