linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "hartleys" <hartleys-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>
To: "David Brownell" <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Pierre Ossman
	<drzeus-mmc-p3sGCRWkH8CeZLLa646FqQ@public.gmane.org>
Subject: Re: mmc_spi.c driver
Date: Tue, 15 Apr 2008 21:58:52 -0400	[thread overview]
Message-ID: <1CF6EDDF0820924DA43C9A52FE7325950A89E4C1@MI8NYCMAIL17.Mi8.com> (raw)
In-Reply-To: <200804151244.34171.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>

>> One of the cards actually produces a "Division by zero in kernel."
error.
>> It appears to happen in the mmc_set_data_timeout() function. I added
a 
>> printk to the function and get the following when the card is
inserted.
>> 
>> mmc_set_data_timeout  timeout_ns:0  timeout_clks:0  ios.clock:400000 
>> mmc_set_data_timeout  timeout_ns:-589934592  timeout_clks:0  
>> ios.clock:400000
>> mmc0: new SD card on SPI
>> mmcblk0: mmc0:0000       29888KiB
>>  mmcblk0:mmc_set_data_timeout  timeout_ns:-589934592  timeout_clks:0

>> ios.clock:0 Division by zero in kernel.
>> [<c003e650>] (dump_stack+0x0/0x14) from [<c003e67c>] 
>> (__div0+0x18/0x20) [<c003e664>] (__div0+0x0/0x20) from [<c01766d8>] 
>> (Ldiv0+0x8/0x10) [<c0210cb4>] (mmc_set_data_timeout+0x0/0x128) from 
>> [<c0216e28>] (mmc_blk_issue_rq+0x124/0x73c)  r7:c50b8000 r6:c4949614 
>> r5:c5560e00 r4:c50b8000 [<c0216d04>] (mmc_blk_issue_rq+0x0/0x73c)
from 
>> [<c0217a80>] (mmc_queue_thread+0xd8/0x180) [<c02179a8>] 
>> (mmc_queue_thread+0x0/0x180) from [<c006d6a8>] (kthread+0x54/0x80)  
>> r8:00000000 r7:00000000 r6:00000000 r5:c02179a8 r4:fffffffc 
>> [<c006d654>] (kthread+0x0/0x80) from [<c005a1dc>] (do_exit+0x0/0x828)

>> r5:00000000 r4:00000000
>>  p1
>
>That's wrong.  :(
>
>
>> For some reason the card->host->ios.clock value is getting changed to

>> 0 on the third call to the function. I haven't been able to trace
down 
>> where/why this would happen. Any idea on that one?

>ISTR the MMC stack sometimes sets clockspeed to zero as a way of
disabling
>a controller ... but if that were happening, I'd expect it not to have
>issued a request like taht.

I didn't think of checking dmesg before, here's the actual dump after I
insert
the SD card:

mmc_spi_detect_irq
mmc0: clock 0Hz busmode 2 powermode 1 cs 1 Vdd 21 width 0 timing 0
mmc_spi spi0.1: mmc_spi: power up (21)
mmc0: clock 400000Hz busmode 2 powermode 2 cs 1 Vdd 21 width 0 timing 0
mmc_spi spi0.1: mmc_spi: power on (21)
mmc0: starting CMD0 arg 00000000 flags 000000c0
mmc_spi spi0.1:   mmc_spi: CMD0, resp R1
mmc0: req done (CMD0): 0: 00000001 00000000 00000000 00000000
mmc0: starting CMD8 arg 000001aa flags 000002f5
mmc_spi spi0.1:   mmc_spi: CMD8, resp R3/R4/R7
mmc_spi spi0.1:   ... CMD8 response SPI_R3/R4/R: resp 0005 ffffffff
mmc0: req done (CMD8): -22: 00000005 ffffffff 00000000 00000000
mmc0: starting CMD5 arg 00000000 flags 000002e1
mmc_spi spi0.1:   mmc_spi: CMD5, resp R3/R4/R7
mmc_spi spi0.1:   ... CMD5 response SPI_R3/R4/R: resp 0005 ffffffff
mmc0: req done (CMD5): -22: 00000005 ffffffff 00000000 00000000
mmc0: starting CMD55 arg 00000000 flags 000000f5
mmc_spi spi0.1:   mmc_spi: CMD55, resp R1
mmc0: req done (CMD55): 0: 00000001 00000000 00000000 00000000
mmc0: starting CMD41 arg 00000000 flags 000000e1
mmc_spi spi0.1:   mmc_spi: CMD41, resp R1
mmc0: req done (CMD41): 0: 00000001 00000000 00000000 00000000
mmc0: starting CMD0 arg 00000000 flags 000000c0
mmc_spi spi0.1:   mmc_spi: CMD0, resp R1
mmc0: req done (CMD0): 0: 00000001 00000000 00000000 00000000
mmc0: starting CMD58 arg 00000000 flags 00000280
mmc_spi spi0.1:   mmc_spi: CMD58, resp R3/R4/R7
mmc0: req done (CMD58): 0: 00000001 00ff8000 00000000 00000000
mmc0: clock 400000Hz busmode 2 powermode 2 cs 1 Vdd 21 width 0 timing 0
mmc0: starting CMD0 arg 00000000 flags 000000c0
mmc_spi spi0.1:   mmc_spi: CMD0, resp R1
mmc0: req done (CMD0): 0: 00000001 00000000 00000000 00000000
mmc0: starting CMD8 arg 000001aa flags 000002f5
mmc_spi spi0.1:   mmc_spi: CMD8, resp R3/R4/R7
mmc_spi spi0.1:   ... CMD8 response SPI_R3/R4/R: resp 0005 ffffffff
mmc0: req done (CMD8): -22: 00000005 ffffffff 00000000 00000000
mmc0: starting CMD55 arg 00000000 flags 000000f5
mmc_spi spi0.1:   mmc_spi: CMD55, resp R1
mmc0: req done (CMD55): 0: 00000001 00000000 00000000 00000000
mmc0: starting CMD41 arg 00000000 flags 000000e1
mmc_spi spi0.1:   mmc_spi: CMD41, resp R1
mmc0: req done (CMD41): 0: 00000001 00000000 00000000 00000000
mmc0: starting CMD55 arg 00000000 flags 000000f5
mmc_spi spi0.1:   mmc_spi: CMD55, resp R1
mmc0: req done (CMD55): 0: 00000001 00000000 00000000 00000000
mmc0: starting CMD41 arg 00000000 flags 000000e1
mmc_spi spi0.1:   mmc_spi: CMD41, resp R1
mmc0: req done (CMD41): 0: 00000000 00000000 00000000 00000000
mmc0: starting CMD59 arg 00000001 flags 00000080
mmc_spi spi0.1:   mmc_spi: CMD59, resp R1
mmc0: req done (CMD59): 0: 00000000 00000000 00000000 00000000
mmc0: starting CMD10 arg 00000000 flags 000000b5
mmc0:     blksz 16 blocks 1 flags 00000200 tsac 0 ms nsac 0
mmc_spi spi0.1:   mmc_spi: CMD10, resp R1
mmc_spi spi0.1:     mmc_spi: read block, 16 bytes
mmc0: req done (CMD10): 0: 00000000 00000000 00000000 00000000
mmc0:     16 bytes transferred: 0
mmc0: starting CMD9 arg 00000000 flags 000000b5
mmc0:     blksz 16 blocks 1 flags 00000200 tsac 0 ms nsac 0
mmc_spi spi0.1:   mmc_spi: CMD9, resp R1
mmc_spi spi0.1:     mmc_spi: read block, 16 bytes
mmc0: req done (CMD9): 0: 00000000 00000000 00000000 00000000
mmc0:     16 bytes transferred: 0
mmc0: starting CMD55 arg 00000000 flags 00000095
mmc_spi spi0.1:   mmc_spi: CMD55, resp R1
mmc0: req done (CMD55): 0: 00000000 00000000 00000000 00000000
mmc0: starting CMD51 arg 00000000 flags 000000b5
mmc0:     blksz 8 blocks 1 flags 00000200 tsac 100 ms nsac 0
mmc_spi spi0.1:   mmc_spi: CMD51, resp R1
mmc_spi spi0.1:     mmc_spi: read block, 8 bytes
mmc0: req done (CMD51): 0: 00000000 00000000 00000000 00000000
mmc0:     8 bytes transferred: 0
mmc0: clock 0Hz busmode 2 powermode 2 cs 1 Vdd 21 width 0 timing 0
mmc_spi spi0.1: card is read-write
mmc0: new SD card on SPI
mmc0: starting CMD16 arg 00000200 flags 00000095
mmc_spi spi0.1:   mmc_spi: CMD16, resp R1
mmc0: req done (CMD16): 0: 00000000 00000000 00000000 00000000
mmcblk0: mmc0:0000 D0507 29888KiB
 mmcblk0:Division by zero in kernel.
[<c003e650>] (dump_stack+0x0/0x14) from [<c003e67c>] (__div0+0x18/0x20)
[<c003e664>] (__div0+0x0/0x20) from [<c0176718>] (Ldiv0+0x8/0x10)
[<c0210bf4>] (mmc_set_data_timeout+0x0/0xf8) from [<c0217418>]
(mmc_blk_issue_rq
+0x124/0x73c)
 r8:c494f304 r7:c50b8000 r6:c493f614 r5:c5e22000 r4:c50b8000
[<c02172f4>] (mmc_blk_issue_rq+0x0/0x73c) from [<c0218070>]
(mmc_queue_thread+0x
d8/0x180)
[<c0217f98>] (mmc_queue_thread+0x0/0x180) from [<c006d6e0>]
(kthread+0x54/0x80)
 r8:00000000 r7:00000000 r6:00000000 r5:c0217f98 r4:fffffffc
[<c006d68c>] (kthread+0x0/0x80) from [<c005a214>] (do_exit+0x0/0x828)
 r5:00000000 r4:00000000
mmc0: starting CMD18 arg 00000000 flags 000000b5
mmc0:     blksz 512 blocks 8 flags 00000200 tsac 100 ms nsac 0
mmc0:     CMD12 arg 00000000 flags 0000049d
mmc_spi spi0.1:   mmc_spi: CMD18, resp R1
mmc_spi spi0.1:     mmc_spi: read block, 512 bytes
mmc_spi spi0.1:     mmc_spi: read block, 512 bytes
mmc_spi spi0.1:     mmc_spi: read block, 512 bytes
mmc_spi spi0.1:     mmc_spi: read block, 512 bytes
mmc_spi spi0.1:     mmc_spi: read block, 512 bytes
mmc_spi spi0.1:     mmc_spi: read block, 512 bytes
mmc_spi spi0.1:     mmc_spi: read block, 512 bytes
mmc_spi spi0.1:     mmc_spi: read block, 512 bytes
mmc_spi spi0.1:   mmc_spi: CMD12, resp R1B
mmc0: req done (CMD18): 0: 00000000 00000000 00000000 00000000
mmc0:     4096 bytes transferred: 0
mmc0:     (CMD12): 0: 00000000 00000000 00000000 00000000
 p1

It appears the mmc core is setting the clock to 0Hz for some reason.

If I hack the mmc_set_data_timeout() function to prevent the divide by
zero
the problem goes away and I am able to mount the SD card.

	timeout_us = data->timeout_ns / 1000;
	if (card->nost->ios.clock) {
		timeout_us += data->timeout_clks * 1000 /
			(card->host->ios.clock / 1000);
	}

But this "is" a hack. The question is why does the core set the clock to
0Hz?

Hartley

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

  parent reply	other threads:[~2008-04-16  1:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-03 22:35 mmc_spi.c driver hartleys
     [not found] ` <1CF6EDDF0820924DA43C9A52FE7325950A27D544-3jZfQB9DylyX6QUl2nWcdlaTQe2KTcn/@public.gmane.org>
2008-04-15 18:37   ` David Brownell
     [not found]     ` <1CF6EDDF0820924DA43C9A52FE7325950A89D882@MI8NYCMAIL17.Mi8.com>
     [not found]       ` <1CF6EDDF0820924DA43C9A52FE7325950A89D882-3jZfQB9DylyX6QUl2nWcdlaTQe2KTcn/@public.gmane.org>
2008-04-15 19:04         ` David Brownell
     [not found]           ` <1CF6EDDF0820924DA43C9A52FE7325950A89DA47@MI8NYCMAIL17.Mi8.com>
     [not found]             ` <1CF6EDDF0820924DA43C9A52FE7325950A89DA47-3jZfQB9DylyX6QUl2nWcdlaTQe2KTcn/@public.gmane.org>
2008-04-15 19:44               ` David Brownell
     [not found]                 ` <200804151244.34171.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-04-16  1:58                   ` hartleys [this message]
2008-04-24 12:05               ` Pierre Ossman
     [not found]                 ` <20080424140541.773f6e6b-OhHrUh4vRMSnewYJFaQfwJ5kstrrjoWp@public.gmane.org>
2008-04-30  0:08                   ` David Brownell
     [not found]                     ` <200804291708.09424.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-04-30  0:38                       ` David Brownell
     [not found]                         ` <200804291738.34965.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-04-30 21:35                           ` [PATCH] Add card detect switch sensing during mmc_rescan hartleys
     [not found]                 ` <1CF6EDDF0820924DA43C9A52FE7325950ADABC65@MI8NYCMAIL17.Mi8.com>
     [not found]                   ` <1CF6EDDF0820924DA43C9A52FE7325950ADABC65-3jZfQB9DylyX6QUl2nWcdlaTQe2KTcn/@public.gmane.org>
2008-05-07 18:37                     ` mmc_spi.c driver Pierre Ossman
     [not found]                       ` <1CF6EDDF0820924DA43C9A52FE7325950B4DAA8C@MI8NYCMAIL17.Mi8.com>
     [not found]                         ` <1CF6EDDF0820924DA43C9A52FE7325950B4DAA8C-3jZfQB9DylyX6QUl2nWcdlaTQe2KTcn/@public.gmane.org>
2008-05-09 19:28                           ` Pierre Ossman
     [not found]                             ` <20080509212858.7220f665-OhHrUh4vRMSnewYJFaQfwJ5kstrrjoWp@public.gmane.org>
2008-10-30 22:46                               ` hartleys
     [not found]                                 ` <BD79186B4FD85F4B8E60E381CAEE1909C28EE4-KURmP/Qoe8Pmp66j18f85VaTQe2KTcn/@public.gmane.org>
2008-10-31  7:02                                   ` Pierre Ossman
     [not found]                                     ` <20081031080254.54b22b82-OhHrUh4vRMSnewYJFaQfwJ5kstrrjoWp@public.gmane.org>
2008-10-31 18:12                                       ` hartleys
     [not found]                                         ` <BD79186B4FD85F4B8E60E381CAEE1909C2914D-KURmP/Qoe8Pmp66j18f85VaTQe2KTcn/@public.gmane.org>
2008-10-31 18:32                                           ` David Brownell
     [not found]                                             ` <200810311132.26213.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-10-31 18:46                                               ` hartleys
     [not found]                                                 ` <BD79186B4FD85F4B8E60E381CAEE1909C29174-KURmP/Qoe8Pmp66j18f85VaTQe2KTcn/@public.gmane.org>
2008-10-31 18:47                                                   ` David Brownell
     [not found]                                                     ` <200810311147.45945.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-10-31 18:51                                                       ` hartleys
     [not found]                                                         ` <BD79186B4FD85F4B8E60E381CAEE1909C2917A-KURmP/Qoe8Pmp66j18f85VaTQe2KTcn/@public.gmane.org>
2008-10-31 19:23                                                           ` David Brownell
     [not found]                                                             ` <200810311223.16647.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-10-31 20:23                                                               ` hartleys
2008-10-31  7:59                                   ` David Brownell

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=1CF6EDDF0820924DA43C9A52FE7325950A89E4C1@MI8NYCMAIL17.Mi8.com \
    --to=hartleys-3ff4nkcrg1de2c76skzgb0eocmrvltnr@public.gmane.org \
    --cc=david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org \
    --cc=drzeus-mmc-p3sGCRWkH8CeZLLa646FqQ@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).