Commit 29009a036f2feb07d8a9b3c715a6365dddd82a7a

Authored by Stephen M. Cameron
Committed by Jens Axboe
1 parent 7b838bde92

cciss: clean up code in cciss_shutdown

cciss: clean up code in cciss_shutdown.  Send the flush cache
command down with interrupts still enabled, and do not do DMA
from the stack.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

Showing 1 changed file with 18 additions and 20 deletions Side-by-side Diff

drivers/block/cciss.c
... ... @@ -4376,30 +4376,28 @@
4376 4376  
4377 4377 static void cciss_shutdown(struct pci_dev *pdev)
4378 4378 {
4379   - ctlr_info_t *tmp_ptr;
4380   - int i;
4381   - char flush_buf[4];
  4379 + ctlr_info_t *h;
  4380 + char *flush_buf;
4382 4381 int return_code;
4383 4382  
4384   - tmp_ptr = pci_get_drvdata(pdev);
4385   - if (tmp_ptr == NULL)
  4383 + h = pci_get_drvdata(pdev);
  4384 + flush_buf = kzalloc(4, GFP_KERNEL);
  4385 + if (!flush_buf) {
  4386 + printk(KERN_WARNING
  4387 + "cciss:%d cache not flushed, out of memory.\n",
  4388 + h->ctlr);
4386 4389 return;
4387   - i = tmp_ptr->ctlr;
4388   - if (hba[i] == NULL)
4389   - return;
4390   -
4391   - /* Turn board interrupts off and send the flush cache command */
4392   - /* sendcmd will turn off interrupt, and send the flush...
4393   - * To write all data in the battery backed cache to disks */
4394   - memset(flush_buf, 0, 4);
4395   - return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0,
4396   - CTLR_LUNID, TYPE_CMD);
4397   - if (return_code == IO_OK) {
4398   - printk(KERN_INFO "Completed flushing cache on controller %d\n", i);
4399   - } else {
4400   - printk(KERN_WARNING "Error flushing cache on controller %d\n", i);
4401 4390 }
4402   - free_irq(hba[i]->intr[2], hba[i]);
  4391 + /* write all data in the battery backed cache to disk */
  4392 + memset(flush_buf, 0, 4);
  4393 + return_code = sendcmd_withirq(CCISS_CACHE_FLUSH, h->ctlr, flush_buf,
  4394 + 4, 0, CTLR_LUNID, TYPE_CMD);
  4395 + kfree(flush_buf);
  4396 + if (return_code != IO_OK)
  4397 + printk(KERN_WARNING "cciss%d: Error flushing cache\n",
  4398 + h->ctlr);
  4399 + h->access.set_intr_mask(h, CCISS_INTR_OFF);
  4400 + free_irq(h->intr[2], h);
4403 4401 }
4404 4402  
4405 4403 static void __devexit cciss_remove_one(struct pci_dev *pdev)