From patchwork Fri Jan 15 07:16:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghava Aditya Renukunta X-Patchwork-Id: 8036501 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 80236BEEE5 for ; Thu, 14 Jan 2016 23:06:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7806720390 for ; Thu, 14 Jan 2016 23:06:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 635F2204FC for ; Thu, 14 Jan 2016 23:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757118AbcANXGg (ORCPT ); Thu, 14 Jan 2016 18:06:36 -0500 Received: from bby1mta02.pmc-sierra.com ([216.241.235.117]:33543 "EHLO bby1mta02.pmc-sierra.bc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756909AbcANXG3 (ORCPT ); Thu, 14 Jan 2016 18:06:29 -0500 Received: from bby1mta02.pmc-sierra.bc.ca (localhost.pmc-sierra.bc.ca [127.0.0.1]) by localhost (Postfix) with SMTP id 155658E03F1; Thu, 14 Jan 2016 15:06:29 -0800 (PST) Received: from smtp.pmcs.com (bby1cas04.pmc-sierra.internal [216.241.227.182]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by bby1mta02.pmc-sierra.bc.ca (Postfix) with ESMTP id E9DB08E0380; Thu, 14 Jan 2016 15:06:28 -0800 (PST) Received: from localhost (216.241.227.4) by bby1cas04.pmc-sierra.internal (216.241.227.182) with Microsoft SMTP Server (TLS) id 14.3.123.3; Thu, 14 Jan 2016 15:06:28 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , , , , , , , Subject: [PATCH V3 7/9] aacraid: Fix AIF triggered IOP_RESET Date: Thu, 14 Jan 2016 23:16:20 -0800 Message-ID: <1452842182-684-8-git-send-email-RaghavaAditya.Renukunta@pmcs.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1452842182-684-1-git-send-email-RaghavaAditya.Renukunta@pmcs.com> References: <1452842182-684-1-git-send-email-RaghavaAditya.Renukunta@pmcs.com> MIME-Version: 1.0 X-Originating-IP: [216.241.227.4] DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pmcs.com; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-type; s=default; bh=OkxHV7nx87FcmTJrlERcGtG2bzHtDM+4j4eW+UuPfRI=; b=JLM4SKQMKrkJ8OKMSt9evRe2fSxhZkWbrAUk6AsouEpDI6oABXkB+19MzV1RiEg1PYrWbWhc7SZg/ydZl/8df6G/IEokDj4p4kyOqVhx5JTJFR/p7RllO4tbYw4FWccXQQeDW2xRngQORteuznaydTSLVz3EDV4kUD/9QTMHX0Y= Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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: Raghava Aditya Renukunta while driver removal is in progress or PCI shutdown is invoked, driver kills AIF aacraid thread, but IOCTL requests from the management tools re-start AIF thread leading to IOP_RESET. Fixed by setting adapter_shutdown flag when PCI shutdown is invoked. Changes in V2: Set adapter_shutdown flag before shutdown command is sent to \ controller Changes in V3: Call aac_send_shut_shutdown first thing in __aac_shutdown Convert adapter_shutdown to atomic_t variable to prevent \ SMP coherency issues(race conditions) Signed-off-by: Raghava Aditya Renukunta Reviewed-by: Shane Seymour Reviewed-by: Johannes Thumshirn --- drivers/scsi/aacraid/aacraid.h | 2 +- drivers/scsi/aacraid/comminit.c | 6 +++--- drivers/scsi/aacraid/linit.c | 15 ++++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 2916288..3473668 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -1234,7 +1234,7 @@ struct aac_dev int msi_enabled; /* MSI/MSI-X enabled */ struct msix_entry msixentry[AAC_MAX_MSIX]; struct aac_msix_ctx aac_msix[AAC_MAX_MSIX]; /* context */ - u8 adapter_shutdown; + atomic_t adapter_shutdown; u32 handle_pci_error; }; diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c index 0e954e3..d361673 100644 --- a/drivers/scsi/aacraid/comminit.c +++ b/drivers/scsi/aacraid/comminit.c @@ -212,8 +212,9 @@ int aac_send_shutdown(struct aac_dev * dev) return -ENOMEM; aac_fib_init(fibctx); - cmd = (struct aac_close *) fib_data(fibctx); + atomic_set(&dev->adapter_shutdown, 1); + cmd = (struct aac_close *) fib_data(fibctx); cmd->command = cpu_to_le32(VM_CloseAll); cmd->cid = cpu_to_le32(0xfffffffe); @@ -229,7 +230,6 @@ int aac_send_shutdown(struct aac_dev * dev) /* FIB should be freed only after getting the response from the F/W */ if (status != -ERESTARTSYS) aac_fib_free(fibctx); - dev->adapter_shutdown = 1; if ((dev->pdev->device == PMC_DEVICE_S7 || dev->pdev->device == PMC_DEVICE_S8 || dev->pdev->device == PMC_DEVICE_S9) && @@ -468,7 +468,7 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) } dev->max_msix = 0; dev->msi_enabled = 0; - dev->adapter_shutdown = 0; + atomic_set(&dev->adapter_shutdown, 0); if ((!aac_adapter_sync_cmd(dev, GET_COMM_PREFERRED_SETTINGS, 0, 0, 0, 0, 0, 0, status+0, status+1, status+2, status+3, status+4)) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 6944560..27b3fcd 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -706,7 +706,7 @@ static long aac_cfg_ioctl(struct file *file, int ret; struct aac_dev *aac; aac = (struct aac_dev *)file->private_data; - if (!capable(CAP_SYS_RAWIO) || aac->adapter_shutdown) + if (!capable(CAP_SYS_RAWIO) || atomic_read(&aac->adapter_shutdown)) return -EPERM; mutex_lock(&aac_mutex); ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg); @@ -1078,6 +1078,8 @@ static void __aac_shutdown(struct aac_dev * aac) int i; int cpu; + aac_send_shutdown(aac); + if (aac->aif_thread) { int i; /* Clear out events first */ @@ -1089,7 +1091,7 @@ static void __aac_shutdown(struct aac_dev * aac) } kthread_stop(aac->thread); } - aac_send_shutdown(aac); + aac_adapter_disable_int(aac); cpu = cpumask_first(cpu_online_mask); if (aac->pdev->device == PMC_DEVICE_S6 || @@ -1474,7 +1476,7 @@ static int aac_resume(struct pci_dev *pdev) * reset this flag to unblock ioctl() as it was set at * aac_send_shutdown() to block ioctls from upperlayer */ - aac->adapter_shutdown = 0; + atomic_set(&aac->adapter_shutdown, 0); scsi_unblock_requests(shost); return 0; @@ -1553,9 +1555,8 @@ static pci_ers_result_t aac_pci_error_detected(struct pci_dev *pdev, case pci_channel_io_normal: return PCI_ERS_RESULT_CAN_RECOVER; case pci_channel_io_frozen: - aac->handle_pci_error = 1; - aac->adapter_shutdown = 1; + atomic_set(&aac->adapter_shutdown, 1); scsi_block_requests(aac->scsi_host_ptr); aac_flush_ios(aac); @@ -1567,7 +1568,7 @@ static pci_ers_result_t aac_pci_error_detected(struct pci_dev *pdev, return PCI_ERS_RESULT_NEED_RESET; case pci_channel_io_perm_failure: aac->handle_pci_error = 1; - aac->adapter_shutdown = 1; + atomic_set(&aac->adapter_shutdown, 1); aac_flush_ios(aac); return PCI_ERS_RESULT_DISCONNECT; @@ -1636,7 +1637,7 @@ static void aac_pci_resume(struct pci_dev *pdev) * reset this flag to unblock ioctl() as it was set * at aac_send_shutdown() to block ioctls from upperlayer */ - aac->adapter_shutdown = 0; + atomic_set(&aac->adapter_shutdown, 0); aac->handle_pci_error = 0; shost_for_each_device(sdev, shost)