From patchwork Thu Feb 4 11:21:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Chiou X-Patchwork-Id: 8219641 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 9EA3CBEEE5 for ; Thu, 4 Feb 2016 11:22:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A04CE20357 for ; Thu, 4 Feb 2016 11:22:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8419D20266 for ; Thu, 4 Feb 2016 11:22:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964929AbcBDLVz (ORCPT ); Thu, 4 Feb 2016 06:21:55 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34186 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757781AbcBDLVw (ORCPT ); Thu, 4 Feb 2016 06:21:52 -0500 Received: by mail-pf0-f196.google.com with SMTP id 65so3234316pfd.1; Thu, 04 Feb 2016 03:21:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=hpsPYlBdbk27mfIsn7f3TojN5i3u2CwmRPuiGmnNsSY=; b=YJHdSczq55ptMUA4QkBv5YrLtv57FI1+9AEFkjcY+zOtNZHUBxijTe31A4kiG8xGWn cSW1T1t/f4of2ZXSd6dMSenrV0JZ/0kMG3BRLVXyq1l8wv6kwBtf1/fVJKlDH2Vo4p4v yDkTIFZFCH+jGLU1ZmRmEu0LfMQBB4qYUza9ukdJmOufyxYpsVMMObav6rj9kEB5f0gP 57lXN0+b+dakcrGGS8NJM2DEGiMiUW+Z1GnOvAzfeudn/Q4OMBDV7PvAoiToDZ6K8KDx rFMEvYNV6rNX2UFAIPOcQ68cZyWieiPHpLmk2RSgqirDdxKp3rhv1eLJXQw/ksyt0Zf4 71+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=hpsPYlBdbk27mfIsn7f3TojN5i3u2CwmRPuiGmnNsSY=; b=MttaVdihSHPsiAIXUkEp7Tb971tQ/3fRn0/4Nyh5gqPDHVjRikYX+RwElFkGasb+c8 onfyC3DSiLcMeY/3hsq+koTWWffUiNmpXX6HEXvoHEMeZHARXQ2lHx6wQahgT0bBYcC4 M+zsVe4+UOgVDdVX2MYOYi1x4j1WiJzZ0iUKpEyzFh3jY9VrcUjAeym2Zyv5XQb823aL eeylNhvl2chNLpT0/oYsQsNy/WWMJVBj6tkOkvX+LLea/DmLIORiJObYsSB7wTppv5G7 FKeNqvmy+U1VqoTSQaGU2xlQFatCMyoS+yPbednkA5Ft0bDZoFIiZTTrv5IuXg2qjOhj YfQg== X-Gm-Message-State: AG10YOT9jd30eQc1QXv/Q4ZWQBK73UW35nd2gPCk8rLO9Wxc7/MsmGmUAUfVePi+mm1qyA== X-Received: by 10.67.7.200 with SMTP id de8mr10164948pad.28.1454584911931; Thu, 04 Feb 2016 03:21:51 -0800 (PST) Received: from [192.168.204.32] (vpn.promise.com.tw. [61.222.81.253]) by smtp.googlemail.com with ESMTPSA id o73sm16466033pfa.37.2016.02.04.03.21.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Feb 2016 03:21:51 -0800 (PST) Message-ID: <56B33440.50409@gmail.com> Date: Thu, 04 Feb 2016 19:21:36 +0800 From: Charles Chiou User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Johannes Thumshirn CC: Christoph Hellwig , JBottomley@parallels.com, Oliver Neukum , grace.chang@tw.promise.com, linus.chen@tw.promise.com, victor.p@promise.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, eva.cheng@tw.promise.com Subject: [Resend PATCH 2/3] scsi:stex.c Add hotplug support References: <55E83DB3.5050209@gmail.com> <56AB4B89.6070309@gmail.com> In-Reply-To: <56AB4B89.6070309@gmail.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=-7.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From 60e14c245c18cbe0300cfa244334e2850a52a381 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 2 Sep 2015 20:48:55 +0800 Subject: [PATCH 2/3] scsi:stex.c Add hotplug support 1. Add hotplug support. Pegasus support surprise removal. To this end, I use return_abnormal_state function to return DID_NO_CONNECT for all commands which sent to driver. 2. Remove stex_hba_stop in stex_remove because we cannot send command to device after hotplug. 3. Add new device status: MU_STATE_STOP, MU_STATE_NOCONNECT, MU_STATE_STOP. MU_STATE_STOP is currently not referenced. MU_STATE_NOCONNECT represent that device is plugged out from the host. 4. Use return_abnormal_function() to substitute part of code in stex_do_reset. V2: N/A Signed-off-by: Charles Chiou Reviewed-by: Johannes Thumshirn --- drivers/scsi/stex.c | 53 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) stex_slave_config(struct scsi_device *sdev) { @@ -567,8 +590,12 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) id = cmd->device->id; lun = cmd->device->lun; hba = (struct st_hba *) &host->hostdata[0]; - - if (unlikely(hba->mu_status == MU_STATE_RESETTING)) + if (hba->mu_status == MU_STATE_NOCONNECT) { + cmd->result = DID_NO_CONNECT; + done(cmd); + return 0; + } + if (unlikely(hba->mu_status != MU_STATE_STARTED)) return SCSI_MLQUEUE_HOST_BUSY; switch (cmd->cmnd[0]) { @@ -1267,10 +1294,8 @@ static void stex_ss_reset(struct st_hba *hba) static int stex_do_reset(struct st_hba *hba) { - struct st_ccb *ccb; unsigned long flags; unsigned int mu_status = MU_STATE_RESETTING; - u16 tag; spin_lock_irqsave(hba->host->host_lock, flags); if (hba->mu_status == MU_STATE_STARTING) { @@ -1304,20 +1329,8 @@ static int stex_do_reset(struct st_hba *hba) else if (hba->cardtype == st_yel) stex_ss_reset(hba); - spin_lock_irqsave(hba->host->host_lock, flags); - for (tag = 0; tag < hba->host->can_queue; tag++) { - ccb = &hba->ccb[tag]; - if (ccb->req == NULL) - continue; - ccb->req = NULL; - if (ccb->cmd) { - scsi_dma_unmap(ccb->cmd); - ccb->cmd->result = DID_RESET << 16; - ccb->cmd->scsi_done(ccb->cmd); - ccb->cmd = NULL; - } - } - spin_unlock_irqrestore(hba->host->host_lock, flags); + + return_abnormal_state(hba, DID_RESET); if (stex_handshake(hba) == 0) return 0; @@ -1786,9 +1799,11 @@ static void stex_remove(struct pci_dev *pdev) { struct st_hba *hba = pci_get_drvdata(pdev); + hba->mu_status = MU_STATE_NOCONNECT; + return_abnormal_state(hba, DID_NO_CONNECT); scsi_remove_host(hba->host); - stex_hba_stop(hba); + scsi_block_requests(hba->host); stex_hba_free(hba); -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 0c93f1f..4ef0c80 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -83,6 +83,8 @@ enum { MU_STATE_STARTED = 2, MU_STATE_RESETTING = 3, MU_STATE_FAILED = 4, + MU_STATE_STOP = 5, + MU_STATE_NOCONNECT = 6, MU_MAX_DELAY = 120, MU_HANDSHAKE_SIGNATURE = 0x55aaaa55, @@ -544,6 +546,27 @@ stex_ss_send_cmd(struct st_hba *hba, struct req_msg *req, u16 tag) readl(hba->mmio_base + YH2I_REQ); /* flush */ } +static void return_abnormal_state(struct st_hba *hba, int status) +{ + struct st_ccb *ccb; + unsigned long flags; + u16 tag; + + spin_lock_irqsave(hba->host->host_lock, flags); + for (tag = 0; tag < hba->host->can_queue; tag++) { + ccb = &hba->ccb[tag]; + if (ccb->req == NULL) + continue; + ccb->req = NULL; + if (ccb->cmd) { + scsi_dma_unmap(ccb->cmd); + ccb->cmd->result = status << 16; + ccb->cmd->scsi_done(ccb->cmd); + ccb->cmd = NULL; + } + } + spin_unlock_irqrestore(hba->host->host_lock, flags); +} static int