From: Tomas Henzl <thenzl@redhat.com>
To: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@pmcs.com>,
"James.Bottomley@HansenPartnership.com"
<James.Bottomley@HansenPartnership.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Cc: Mahesh Rajashekhara <Mahesh.Rajashekhara@pmcs.com>,
Murthy Bhat <Murthy.Bhat@pmcs.com>,
Gana Sridaran <Gana.Sridaran@pmcs.com>,
"aacraid@pmc-sierra.com" <aacraid@pmc-sierra.com>,
Scott Benesh <Scott.Benesh@pmcs.com>,
"jthumshirn@suse.de" <jthumshirn@suse.de>,
"shane.seymour@hpe.com" <shane.seymour@hpe.com>,
zzzDavid Carroll <David.Carroll@pmcs.com>
Subject: Re: [PATCH V3 7/9] aacraid: Fix AIF triggered IOP_RESET
Date: Fri, 22 Jan 2016 14:14:49 +0100 [thread overview]
Message-ID: <56A22B49.1040702@redhat.com> (raw)
In-Reply-To: <198D06D448A18D4E93F08FB849C4E39D7D1F6AA9@BBYEXM01.pmc-sierra.internal>
On 20.1.2016 21:32, Raghava Aditya Renukunta wrote:
>
>> -----Original Message-----
>> From: Tomas Henzl [mailto:thenzl@redhat.com]
>> Sent: Tuesday, January 19, 2016 8:14 AM
>> To: Raghava Aditya Renukunta; James.Bottomley@HansenPartnership.com;
>> martin.petersen@oracle.com; linux-scsi@vger.kernel.org
>> Cc: Mahesh Rajashekhara; Murthy Bhat; Gana Sridaran; aacraid@pmc-
>> sierra.com; Scott Benesh; jthumshirn@suse.de; shane.seymour@hpe.com;
>> David Carroll
>> Subject: Re: [PATCH V3 7/9] aacraid: Fix AIF triggered IOP_RESET
>>
>> On 15.1.2016 08:16, Raghava Aditya Renukunta wrote:
>>> From: Raghava Aditya Renukunta <raghavaaditya.renukunta@pmcs.com>
>>>
>>> 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)
>> Hi,
>> I don't think that an atomic variable can change it, imagine that
>> thread just passed your test in aac_cfg_ioctl and another thread
>> enter a bit later the adapter_shutdown so both - an I/O and your shutdown
>> code
>> will run in parallel.
>> Also you need to fix your compat_ioctl path too.
>>
>> --tm
> Hello Tomas,
> Yes that would not solve this problem.
> I can think of 2 solutions
>
> 1.Place a delay after setting adapter_shutdown and before sending the actual
> shutdown command in aac_send_shutdown. This way any impending commands will be
> processed before the adapter actually receives the shutdown command. Since management
> commands are sync only , shutdown command will be sent last. This solution uses an
> estimation of the delay
>
> 2.Since commands are sync , place a check in aac_fib_send to block
> commands once adapter_shutdown is set(only shutdown command will be sent thru)
This option looks better but I guess you still can find a tiny race window.
What do you think about a mutual exclusive access using a mutex, do you think this could work?
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 54195a117f..b9505c58db 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -858,6 +858,8 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
/*
* HBA gets first crack
*/
+ if (dev->adapter_shutdown)
+ return -EACCES;
status = aac_dev_ioctl(dev, cmd, arg);
if (status != -ENOTTY)
diff --git a/drivers/scsi/aacraid/comminit.c b/drivers/scsi/aacraid/comminit.c
index 0e954e37f0..02535c07a4 100644
--- a/drivers/scsi/aacraid/comminit.c
+++ b/drivers/scsi/aacraid/comminit.c
@@ -212,6 +212,10 @@ int aac_send_shutdown(struct aac_dev * dev)
return -ENOMEM;
aac_fib_init(fibctx);
+ mutex_lock(&aac_mutex);
+ dev->adapter_shutdown = 1;
+ mutex_unlock(&aac_mutex);
+
cmd = (struct aac_close *) fib_data(fibctx);
cmd->command = cpu_to_le32(VM_CloseAll);
@@ -229,7 +233,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) &&
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 6944560e22..a87880ab32 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -706,8 +706,9 @@ 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))
return -EPERM;
+
mutex_lock(&aac_mutex);
ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
mutex_unlock(&aac_mutex);
>
> I am more inclined to go with option 2.
>
> Regards,
> Raghava Aditya
>
>>> Signed-off-by: Raghava Aditya Renukunta
>> <raghavaaditya.renukunta@pmcs.com>
>>> ---
>>> 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)
> --
> 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
next prev parent reply other threads:[~2016-01-22 13:14 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 7:16 [PATCH V3 0/9] aacraid: Patchset for aacraid driver version 41052 Raghava Aditya Renukunta
2016-01-15 7:16 ` [PATCH V3 1/9] aacraid: SCSI blk tag support Raghava Aditya Renukunta
2016-01-15 0:17 ` Seymour, Shane M
2016-01-18 11:13 ` Johannes Thumshirn
2016-01-19 15:33 ` Tomas Henzl
2016-01-15 7:16 ` [PATCH V3 2/9] aacraid: Fix RRQ overload Raghava Aditya Renukunta
2016-01-15 7:16 ` [PATCH V3 3/9] aacraid: Added EEH support Raghava Aditya Renukunta
2016-01-18 11:16 ` Johannes Thumshirn
2016-01-23 22:55 ` kbuild test robot
2016-01-15 7:16 ` [PATCH V3 4/9] aacraid: Fix memory leak in aac_fib_map_free Raghava Aditya Renukunta
2016-01-15 7:16 ` [PATCH V3 5/9] aacraid: Set correct msix count for EEH recovery Raghava Aditya Renukunta
2016-01-18 11:18 ` Johannes Thumshirn
2016-01-15 7:16 ` [PATCH V3 6/9] aacraid: Fundamental reset support for Series 7 Raghava Aditya Renukunta
2016-01-19 15:43 ` Tomas Henzl
2016-01-15 7:16 ` [PATCH V3 7/9] aacraid: Fix AIF triggered IOP_RESET Raghava Aditya Renukunta
2016-01-14 23:35 ` Seymour, Shane M
2016-01-18 11:56 ` Johannes Thumshirn
2016-01-19 16:14 ` Tomas Henzl
2016-01-20 20:32 ` Raghava Aditya Renukunta
2016-01-22 13:14 ` Tomas Henzl [this message]
2016-01-23 5:07 ` Raghava Aditya Renukunta
2016-01-27 2:31 ` Martin K. Petersen
2016-01-27 18:02 ` Raghava Aditya Renukunta
2016-01-15 7:16 ` [PATCH V3 8/9] aacraid: Fix character device re-initialization Raghava Aditya Renukunta
2016-01-18 11:58 ` Johannes Thumshirn
2016-01-20 13:41 ` Tomas Henzl
2016-01-20 20:43 ` Raghava Aditya Renukunta
2016-01-22 13:08 ` Tomas Henzl
2016-01-23 5:07 ` Raghava Aditya Renukunta
2016-01-15 7:16 ` [PATCH V3 9/9] aacraid: Update driver version Raghava Aditya Renukunta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56A22B49.1040702@redhat.com \
--to=thenzl@redhat.com \
--cc=David.Carroll@pmcs.com \
--cc=Gana.Sridaran@pmcs.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=Mahesh.Rajashekhara@pmcs.com \
--cc=Murthy.Bhat@pmcs.com \
--cc=RaghavaAditya.Renukunta@pmcs.com \
--cc=Scott.Benesh@pmcs.com \
--cc=aacraid@pmc-sierra.com \
--cc=jthumshirn@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=shane.seymour@hpe.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.