From patchwork Mon Sep 14 03:08:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 7172551 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C7199BEEC1 for ; Mon, 14 Sep 2015 03:06:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 07DAF205FF for ; Mon, 14 Sep 2015 03:06:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E80520573 for ; Mon, 14 Sep 2015 03:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754565AbbINDG1 (ORCPT ); Sun, 13 Sep 2015 23:06:27 -0400 Received: from mga11.intel.com ([192.55.52.93]:33946 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754396AbbINDGG (ORCPT ); Sun, 13 Sep 2015 23:06:06 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 13 Sep 2015 20:06:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,525,1437462000"; d="scan'208";a="803788178" Received: from gerry-dev.bj.intel.com ([10.238.158.61]) by orsmga002.jf.intel.com with ESMTP; 13 Sep 2015 20:06:03 -0700 From: Jiang Liu To: Thomas Gleixner , Bjorn Helgaas , Arthur Marsh , Dario Ballabio , "James E.J. Bottomley" Cc: Jiang Liu , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org, x86@kernel.org Subject: [Bugfix 3/3] eata: Enhance eata driver to support PCI device hot-removal Date: Mon, 14 Sep 2015 11:08:59 +0800 Message-Id: <1442200140-30808-4-git-send-email-jiang.liu@linux.intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1442200140-30808-1-git-send-email-jiang.liu@linux.intel.com> References: <1442200140-30808-1-git-send-email-jiang.liu@linux.intel.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Due to having no hardware for testing, this is just a sample code to support PCI device hot-removal. It just passing compilation, no any tests. Signed-off-by: Jiang Liu --- drivers/scsi/eata.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c index b92e6856f909..f3bd7cbf260e 100644 --- a/drivers/scsi/eata.c +++ b/drivers/scsi/eata.c @@ -1474,6 +1474,21 @@ static unsigned int port_probe(unsigned long port_base, #ifdef CONFIG_PCI static int eata2x_pci_device_count; +/* TODO: need help here to shutdown the scsi host and release resources */ +static void port_remove(unsigned int id, resource_size_t port_base, + struct pci_dev *pdev) +{ + struct Scsi_Host *shost = sh[id]; + + /* TODO: stop scsi device */ + scsi_unregister(shost); + /* TODO: clean up resources allocated by port_detect() */ + clear_bit(id, eata_board_bitmap); + free_irq(shost->irq, &sha[id]); + release_region(port_base, REGION_SIZE); + ida_simple_remove(&eata_ida, id); +} + static int eata2x_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) { int i, ret = -ENXIO; @@ -1521,6 +1536,16 @@ out_error: return ret; } +static void eata2x_pci_remove(struct pci_dev *pdev) +{ + int id = (int)(long)dev_get_drvdata(&pdev->dev); + resource_size_t port_base; + + port_base = pci_resource_start(pdev, 0) + PCI_BASE_ADDRESS_0; + port_remove(id, port_base, pdev); + pci_disable_device(pdev); +} + static struct pci_device_id eata2x_tbl[] = { { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_SCSI << 8, PCI_ANY_ID) }, { }, @@ -1531,6 +1556,7 @@ static struct pci_driver eata2x_pci_driver = { .name = "eata", .id_table = eata2x_tbl, .probe = eata2x_pci_probe, + .remove = eata2x_pci_remove, }; static int eata2x_probe_pci_devices(struct scsi_host_template *tpnt)