[Trac #251] Timeout calculation causes divide by zero on stopped SD card.

Zarro Boogs per Child bugtracker at laptop.org
Tue Oct 31 10:31:01 EST 2006


#251: Timeout calculation causes divide by zero on stopped SD card.
--------------------+-------------------------------------------------------
 Reporter:  dwmw2   |        Owner:  dwmw2  
     Type:  defect  |       Status:  new    
 Priority:  normal  |    Milestone:  BTest-1
Component:  kernel  |   Resolution:         
 Keywords:          |  
--------------------+-------------------------------------------------------
Comment (by dwmw2):

 Very little is modified in drivers/mmc/. Looks like this...

 {{{
 commit 74e21efd27175886b41afdbe26404b0393feb3d6
 Author: David Woodhouse <dwmw2 at infradead.org>
 Date:   Tue Oct 31 22:04:24 2006 +0800

     [MMC] Fail I/O to stopped SD card; avoid dividing by zero

     When we reset an SD host, we set the clock to zero. Dividing the
     required timeout for I/O by zero is not a good thing, and we might
     as well just abort the I/O early since it's not going to work anyway.

     Signed-off-by: David Woodhouse <dwmw2 at infradead.org>

 commit 48e92963dadd0f35903a4999e87224f3667d43d5
 Author: Andres Salomon <dilinger at debian.org>
 Date:   Thu Oct 26 22:55:19 2006 -0400

     Remove the iomem size check.  The sdhci spec is ambiguous on this.

 commit ace529a24f828f7728a6509008cf94966e5d8f1e
 Author: Andres Salomon <dilinger at debian.org>
 Date:   Fri Oct 20 18:02:14 2006 -0400

     Poke at some magic registers to enable SD on the cafe chip.


 diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
 index f9027c8..0ea0e92 100644
 --- a/drivers/mmc/mmc_block.c
 +++ b/drivers/mmc/mmc_block.c
 @@ -246,6 +246,11 @@ static int mmc_blk_issue_rq(struct mmc_q
                 brq.stop.arg = 0;
                 brq.stop.flags = MMC_RSP_R1B | MMC_CMD_AC;

 +               if (mmc_card_sd(card) && !card->host->ios.clock) {
 +                       printk(KERN_ERR "%s: I/O to stopped card\n",
 +                              req->rq_disk->disk_name);
 +                       goto cmd_err;
 +               }
                 mmc_set_data_timeout(&brq.data, card, rq_data_dir(req) !=
 READ);

                 /*
 diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
 index 9a7d39b..daafb82 100644
 --- a/drivers/mmc/sdhci.c
 +++ b/drivers/mmc/sdhci.c
 @@ -162,6 +162,12 @@ static void sdhci_init(struct sdhci_host

         sdhci_reset(host, SDHCI_RESET_ALL);

 +       /* write bits to some magic register to turn on the device;
 +        * FIXME: this should only be done for CAFE chip!  -dilinger */
 +       writeb(0x06, host->ioaddr + 0x3038);
 +       writel(0x60006, host->ioaddr + 0x315C);
 +       /* XXX: any delays necessary? */
 +
         intmask = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
                 SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT |
 SDHCI_INT_INDEX |
                 SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT |
 @@ -1161,11 +1167,6 @@ static int __devinit sdhci_probe_slot(st
                 return -ENODEV;
         }

 -       if (pci_resource_len(pdev, first_bar + slot) != 0x100) {
 -               printk(KERN_ERR DRIVER_NAME ": Invalid iomem size.
 Aborting.\n");
 -               return -ENODEV;
 -       }
 -
         if ((pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) {
                 printk(KERN_ERR DRIVER_NAME ": Vendor specific interface.
 Aborting.\n");
                 return -ENODEV;
 }}}

-- 
Ticket URL: <http://dev.laptop.org/ticket/251#comment:3>
One Laptop Per Child <http://laptop.org/>



More information about the Bugs mailing list