Skip to contentSkip to conversation

goofy mtd m25p80 patches in GIT ...

DISCUSSION David Brownell 3 participants 14 messages Oct 19, 2008 – Oct 20, 2008 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

[resend cc'ing linux-mtd, sorry]

I noticed a couple goofy patches in MTD GIT, while poking around wondering what happened to some patches that I expected would already have gotten upstream. Details below.

- Dave

First:

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=commitdiff;h=faff37508a104e9ec5285d5adecaab7e8dde472a

That patch is goofy because the command in question is *NOT* a block erase command. It's a chip-erase command ... entirely unlike the existing *real* block erase commands used in the driver.

Could we get a fix that provides the correct name for the operations? Having real block commands, and this new thing, is at the very least confusing...

Second:

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=commitdiff;h=75d0ee2202b5740e94e913d8a52f91c6557c4c81

That's just plain wrong ... the original code is correct, but the patch changed it to be incorrect. (DMA from the stack is never legal.)

Just revert this one entirely.

#1 lore raw
Quoted 5 lines

Second:

Quoted 10 lines

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=
commitdiff;h=75d0ee2202b5740e94e913d8a52f91c6557c4c81

That's just plain wrong ... the original code is correct, but the patch changed it to be incorrect. (DMA from the stack is never legal.)

Just revert this one entirely.

I know spi_write_then_read is different from spi_write, but here n_rx & rxbuf are both NULL, which means no real read operation are executed. Would you please give me more explanation for potential hazard ?

#2 lore raw
Quoted 12 lines · On Monday 20 October 2008, Chen Gong-B11801 wrote:
Quoted 12 lines

Second:

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=
commitdiff;h=75d0ee2202b5740e94e913d8a52f91c6557c4c81

That's just plain wrong ... the original code is correct, but the patch changed it to be incorrect. (DMA from the stack is never legal.)

Quoted 5 lines
Quoted 1 line

Just revert this one entirely.

I know spi_write_then_read is different from spi_write, but here n_rx & rxbuf are both NULL, which means no real read operation are executed. Would you please give me more explanation for potential hazard ?

Documentation/DMA-mapping.txt, in the "What memory is DMA'able?" section (the first one after overview) lists several hazards. I won't elaborate on that text, but it also states explicitly that DMA from stacks is not allowed (para 4, sentence one).

Note that the spi_write_then_read() is documented as always copying its (small) data buffers, while spi_write() just passes it down to the spi_master driver ... which requires DMA-safe memory, as described in "What memory is DMA'able?".

Have a look at the implementation of spi_write_then_read(), in drivers/spi/spi.c ... one of the main reasons for that routine is to make some of the common cases easier to work with, by masking those DMA issues.

- Dave

#3 lore raw
In reply to David Brownell
Quoted 5 lines · David Brownell

[resend cc'ing linux-mtd, sorry]

I noticed a couple goofy patches in MTD GIT, while poking around wondering what happened to some patches that I expected would already have gotten upstream. Details below.

Did you find the patches you expected to be going upstream?

Quoted 11 lines

First:

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=commitdiff;h=faff37508a104e9ec5285d5adecaab7e8dde472a

That patch is goofy because the command in question is *NOT* a block erase command. It's a chip-erase command ... entirely unlike the existing *real* block erase commands used in the driver.

Could we get a fix that provides the correct name for the operations? Having real block commands, and this new thing, is at the very least confusing...

Makes sense. Chen Gong?

Quoted 8 lines

Second:

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=commitdiff;h=75d0ee2202b5740e94e913d8a52f91c6557c4c81

That's just plain wrong ... the original code is correct, but the patch changed it to be incorrect. (DMA from the stack is never legal.)

Ah, so spi_write() uses DMA, but spi_write_then_read() does not? Not entirely intuitive :)

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
#4 lore raw
Quoted 28 lines

-----Original Message-----
From: David Woodhouse [mailto:[email protected]]
Sent: 2008?10?20? 15:40
To: David Brownell
Cc: Chen Gong-B11801; [email protected]
Subject: Re: goofy mtd m25p80 patches in GIT ...

Quoted 5 lines · David Brownell

[resend cc'ing linux-mtd, sorry]

I noticed a couple goofy patches in MTD GIT, while poking around wondering what happened to some patches that I expected would already have gotten upstream. Details below.

Did you find the patches you expected to be going upstream?

Quoted 3 lines

First:

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=
commitdiff;h=faff37508a104e9ec5285d5adecaab7e8dde472a

Quoted 5 lines

That patch is goofy because the command in question is *NOT* a block erase command. It's a chip-erase command ... entirely unlike the existing *real* block erase commands used in the driver.

Quoted 6 lines
Quoted 1 line

Could we get a fix that provides the correct name for the

operations?

Quoted 2 lines

Having real block commands, and this new thing, is at the very least confusing...

Makes sense. Chen Gong?

I agree with you.

Quoted 22 lines
Quoted 5 lines

Second:

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=
commitdiff;h=75d0ee2202b5740e94e913d8a52f91c6557c4c81

Quoted 4 lines

That's just plain wrong ... the original code is correct, but the patch changed it to be incorrect. (DMA from the stack is never legal.)

Ah, so spi_write() uses DMA, but spi_write_then_read() does not? Not entirely intuitive :)

Signature · 4 lines
David Woodhouse                            Open Source 
Technology Centre
[email protected]                              Intel 
Corporation
#5 lore raw
Quoted 9 lines · On Mon, 2008-10-20 at 15:42 +0800, Chen Gong-B11801 wrote:
Quoted 7 lines
Quoted 2 lines

Could we get a fix that provides the correct name for the

operations?

Quoted 2 lines

Having real block commands, and this new thing, is at the very least confusing...

Makes sense. Chen Gong?

I agree with you.

I was hoping for a response in 'diff -up' form... :)

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
#6 lore raw
Quoted 14 lines

-----Original Message-----
From: David Woodhouse [mailto:[email protected]]
Sent: 2008?10?20? 15:44
To: Chen Gong-B11801
Cc: David Brownell; [email protected]
Subject: RE: goofy mtd m25p80 patches in GIT ...

Quoted 4 lines · On Mon, 2008-10-20 at 15:42 +0800, Chen Gong-B11801 wrote:
Quoted 4 lines
Quoted 2 lines

Could we get a fix that provides the correct name for the

operations?

Quoted 1 line

Having real block commands, and this new thing, is at

Quoted 8 lines

the very least

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

confusing...

Makes sense. Chen Gong?

I agree with you.

I was hoping for a response in 'diff -up' form... :)

I'm not sure whether I catch your word. Frankly I agree that we need a chip-erase
command but in fact current MTD doesn't support this kind of interface (only one erase interface),
so I can't give you a new patch :-(

#7 lore raw
Quoted 3 lines · On Mon, 2008-10-20 at 15:56 +0800, Chen Gong-B11801 wrote:

I'm not sure whether I catch your word. Frankly I agree that we need a chip-erase command but in fact current MTD doesn't support this kind of interface (only one erase interface), so I can't give you a new patch :-(

I think the interface is fine -- if you ask it to erase the whole chip (start == 0, len == size), then it'll use a chip erase command if it has one, or fall back to erasing individual blocks.

I think David just wanted a cleanup to the nomenclature -- renaming 'erase_block' to 'erase_chip', perhaps, and changing the #define for the command?

Or did I misunderstand?

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
#8 lore raw
Quoted 21 lines

-----Original Message-----
From: David Woodhouse [mailto:[email protected]]
Sent: 2008?10?20? 16:03
To: Chen Gong-B11801
Cc: David Brownell; [email protected]
Subject: RE: goofy mtd m25p80 patches in GIT ...

Quoted 1 line · On Mon, 2008-10-20 at 15:56 +0800, Chen Gong-B11801 wrote:

I'm not sure whether I catch your word. Frankly I agree

that we need a

Quoted 1 line

chip-erase command but in fact current MTD doesn't support

this kind of interface

Quoted 1 line

(only one erase interface), so I can't give you a new patch :-(

I think the interface is fine -- if you ask it to erase the whole chip (start == 0, len == size), then it'll use a chip erase command if it has
one, or fall back to erasing individual blocks.

Quoted 4 lines

I think David just wanted a cleanup to the nomenclature -- renaming 'erase_block' to 'erase_chip', perhaps, and changing the #define for the
command?

I prefer to the first opinion -- renaming 'erase_block' to 'erase_chip', it looks
more straightforward

#9 lore raw
Quoted 2 lines · On Monday 20 October 2008, Chen Gong-B11801 wrote:

I prefer to the first opinion -- renaming 'erase_block' to 'erase_chip', it looks more straightforward

*AND* fixing the name of the operation.

The pre-existing erase operations were:

 #define OPCODE_BE_4K            0x20    /* Erase 4KiB block */
 #define OPCODE_BE_32K           0x52    /* Erase 32KiB block */
 #define OPCODE_SE               0xd8    /* Sector erase (usually 64KiB) */

So I'm quite puzzled why you would call the chip erase opcode a "block erase" opcode ... it's not a 4K block, not a 32K block, not a sector (of, usually, 64K).

It's more typically something like multiple MBytes.

Having read or skimmed several dozen SPI flash specs, none of them called chip erase a "block erase" operation.

#10 lore raw
Quoted 18 lines

-----Original Message-----
From: David Brownell [mailto:[email protected]]
Sent: 2008?10?20? 16:31
To: Chen Gong-B11801
Cc: David Woodhouse; [email protected]
Subject: Re: goofy mtd m25p80 patches in GIT ...

Quoted 1 line · On Monday 20 October 2008, Chen Gong-B11801 wrote:

I prefer to the first opinion -- renaming 'erase_block' to

'erase_chip',

Quoted 1 line

it looks more straightforward

*AND* fixing the name of the operation.

The pre-existing erase operations were:

Quoted 8 lines
 #define OPCODE_BE_4K            0x20    /* Erase 4KiB block */
 #define OPCODE_BE_32K           0x52    /* Erase 32KiB block */
 #define OPCODE_SE               0xd8    /* Sector erase 

(usually 64KiB) */

So I'm quite puzzled why you would call the chip erase opcode a "block erase" opcode ... it's not a 4K block, not a 32K block, not a sector (of, usually, 64K).

ah, simple, because I'v gotten it from its datasheet (BE means Bulk Erase, not block erase here) :-)

Quoted 7 lines

It's more typically something like multiple MBytes.

Having read or skimmed several dozen SPI flash specs, none of them called chip erase a "block erase" operation.

#11 lore raw
In reply to David Woodhouse
Quoted 7 lines · David Woodhouse

I think the interface is fine -- if you ask it to erase the whole chip (start == 0, len == size), then it'll use a chip erase command if it has one, or fall back to erasing individual blocks.

I think David just wanted a cleanup to the nomenclature -- renaming 'erase_block' to 'erase_chip', perhaps, and changing the #define for the command?

Exactly. Since the existing erase block calls are not doing whole-chip erasure ... and since chip-erase is a *VERY* different operation.

The MTD interface just says "erase this stuff", and that patch just added a special case "if <stuff> is the whole chip, use this operation instead of the existing iterate-over-blocks logic".

- Dave

#12 lore raw
In reply to David Woodhouse
Quoted 8 lines · David Woodhouse
Quoted 5 lines · David Brownell

[resend cc'ing linux-mtd, sorry]

I noticed a couple goofy patches in MTD GIT, while poking around wondering what happened to some patches that I expected would already have gotten upstream. Details below.

Did you find the patches you expected to be going upstream?

Yes, sorry to have not made that explicit. The were the mtd_dataflash.c patches.

(And I'm hoping we'll see an MTD "pull" request for 2.6.28-rc0 ... )

Quoted 18 lines
Quoted 5 lines

First:

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=commitdiff;h=faff37508a104e9ec5285d5adecaab7e8dde472a

Quoted 7 lines

That patch is goofy because the command in question is *NOT* a block erase command. It's a chip-erase command ... entirely unlike the existing *real* block erase commands used in the driver.

Could we get a fix that provides the correct name for the operations? Having real block commands, and this new thing, is at the very least confusing...

Makes sense. Chen Gong?

Quoted 3 lines

Second:

Quoted 8 lines
Quoted 5 lines

http://git.kernel.org/?p=linux/kernel/git/dwmw2/mtd-2.6.git;a=commitdiff;h=75d0ee2202b5740e94e913d8a52f91c6557c4c81

That's just plain wrong ... the original code is correct, but the patch changed it to be incorrect. (DMA from the stack is never legal.)

Ah, so spi_write() uses DMA, but spi_write_then_read() does not? Not entirely intuitive :)

Maybe not ... but documented.
(More info in response to Chen Gong.)

Quoted 6 lines
Signature · 3 lines
-- 
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
#13 lore raw
Quoted 6 lines · David Brownell

Yes, sorry to have not made that explicit.
The were the mtd_dataflash.c patches.

(And I'm hoping we'll see an MTD "pull" request
for 2.6.28-rc0 ... )

It went out a couple of days ago.

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation