From: Himanshu Madhani <himanshu.madhani@oracle.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-scsi@vger.kernel.org,
Finn Thain <fthain@telegraphics.com.au>,
GR-QLogic-Storage-Upstream
<GR-QLogic-Storage-Upstream@marvell.com>,
Hannes Reinecke <hare@kernel.org>,
Jack Wang <jinpu.wang@cloud.ionos.com>,
John Garry <john.garry@huawei.com>,
linux-m68k@vger.kernel.org,
Manish Rangankar <mrangankar@marvell.com>,
Michael Schmitz <schmitzmic@gmail.com>,
MPT-FusionLinux.pdl@broadcom.com,
Nilesh Javali <njavali@marvell.com>,
Sathya Prakash <sathya.prakash@broadcom.com>,
Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>,
Vikram Auradkar <auradkar@google.com>,
Xiang Chen <chenxiang66@hisilicon.com>,
Xiaofei Tan <tanxiaofei@huawei.com>,
"James E . J . Bottomley" <jejb@linux.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
"Ahmed S . Darwish" <a.darwish@linutronix.de>
Subject: Re: [PATCH 04/14] scsi: qla2xxx: qla82xx: Remove in_interrupt().
Date: Mon, 30 Nov 2020 13:11:25 -0600 [thread overview]
Message-ID: <B8EAE100-5178-41D8-97B4-104CEB3500FF@oracle.com> (raw)
In-Reply-To: <20201126132952.2287996-5-bigeasy@linutronix.de>
> On Nov 26, 2020, at 7:29 AM, Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
>
> From: "Ahmed S. Darwish" <a.darwish@linutronix.de>
>
> qla82xx_idc_lock() spins on a certain hardware state until it's updated. At
> the end of each spin, if in_interrupt() is true, it does 20 loops of
> cpu_relax(). Otherwise, it yields the CPU.
>
> While in_interrupt() is ill-defined and does not provide what the name
> suggests, it is not needed here: qla82xx_idc_lock() is always called
> from process context. Below is an analysis of its callers, in order of
> appearance:
>
> - qla_nx.c: qla82xx_device_bootstrap(), only called by
> qla82xx_device_state_handler(), has multiple msleep()s.
>
> - qla_nx.c: qla82xx_need_qsnt_handler(), has one second msleep()
>
> - qla_nx.c: qla82xx_wait_for_state_change(), one second msleep()
>
> - qla_nx.c: qla82xx_need_reset_handler(), can sleep up to 10 seconds
>
> - qla_nx.c: qla82xx_device_state_handler(), has multiple msleep()s
>
> - qla_nx.c: qla82xx_abort_isp(), if it's a qla82xx controller, calls
> qla82xx_device_state_handler(), which sleeps. It's also bound to
> isp_operations ->abort_isp() hook, where all the callers are in
> process context.
>
> - qla_nx.c: qla82xx_beacon_on(), bound to isp_operations ->beacon_on()
> hook. That hook is only called once, in a mutex locked context,
> from qla2x00_beacon_store().
>
> - qla_nx.c: qla82xx_beacon_off(), bound to isp_operations
> ->beacon_off() hook. Like ->beacon_on(), it's only called once, in
> a mutex locked context, from qla2x00_beacon_store().
>
> - qla_nx.c: qla82xx_fw_dump(), calls qla2x00_wait_for_chip_reset(),
> which has msleep() in a loop. It is bound to isp_operations
> ->fw_dump() hook. That hook *is* called from atomic context at
> qla_isr.c by multiple interrupt handlers. Nonetheless, it's other
> controllers interrupt handlers, and not the qla82xx.
>
> - qla_attr.c: qla2x00_sysfs_write_fw_dump(), and
> qla2x00_sysfs_write_reset(), process-context sysfs ->write() hooks.
>
> - qla_os.c: qla2x00_probe_one(). PCI ->probe(), process context.
>
> - qla_os.c: qla2x00_clear_drv_active(), called solely from
> qla2x00_remove_one(), which is PCI ->remove() hook, process context.
>
> - qla_os.c: qla2x00_do_dpc(), kthread function, process context.
>
> Remove the in_interrupt() check. Change qla82xx_idc_lock() specification
> to a purely process-context function. Mark it with "Context: task, might
> sleep".
>
> Change qla82xx_idc_lock() implementation to sleep 100ms, instead of a
> schedule(), for each spin. This is more deterministic, and it matches
> the other qla models idc_lock() functions.
>
> Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: <GR-QLogic-Storage-Upstream@marvell.com>
> ---
> drivers/scsi/qla2xxx/qla_def.h | 5 +++++
> drivers/scsi/qla2xxx/qla_nx.c | 25 +++++++++++--------------
> 2 files changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
> index ed9b10f8537d6..fe3c0e2f1ce88 100644
> --- a/drivers/scsi/qla2xxx/qla_def.h
> +++ b/drivers/scsi/qla2xxx/qla_def.h
> @@ -3296,8 +3296,10 @@ struct isp_operations {
> void (*fw_dump)(struct scsi_qla_host *vha);
> void (*mpi_fw_dump)(struct scsi_qla_host *, int);
>
> + /* Context: task, might sleep */
> int (*beacon_on) (struct scsi_qla_host *);
> int (*beacon_off) (struct scsi_qla_host *);
> +
> void (*beacon_blink) (struct scsi_qla_host *);
>
> void *(*read_optrom)(struct scsi_qla_host *, void *,
> @@ -3308,7 +3310,10 @@ struct isp_operations {
> int (*get_flash_version) (struct scsi_qla_host *, void *);
> int (*start_scsi) (srb_t *);
> int (*start_scsi_mq) (srb_t *);
> +
> + /* Context: task, might sleep */
> int (*abort_isp) (struct scsi_qla_host *);
> +
> int (*iospace_config)(struct qla_hw_data *);
> int (*initialize_adapter)(struct scsi_qla_host *);
> };
> diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c
> index b3ba0de5d4fb8..b2017f1c35044 100644
> --- a/drivers/scsi/qla2xxx/qla_nx.c
> +++ b/drivers/scsi/qla2xxx/qla_nx.c
> @@ -489,29 +489,26 @@ qla82xx_rd_32(struct qla_hw_data *ha, ulong off_in)
> return data;
> }
>
> -#define IDC_LOCK_TIMEOUT 100000000
> +/*
> + * Context: task, might sleep
> + */
> int qla82xx_idc_lock(struct qla_hw_data *ha)
> {
> - int i;
> - int done = 0, timeout = 0;
> + const int delay_ms = 100, timeout_ms = 2000;
> + int done, total = 0;
>
> - while (!done) {
> + might_sleep();
> +
> + while (true) {
> /* acquire semaphore5 from PCI HW block */
> done = qla82xx_rd_32(ha, QLA82XX_PCIE_REG(PCIE_SEM5_LOCK));
> if (done == 1)
> break;
> - if (timeout >= IDC_LOCK_TIMEOUT)
> + if (WARN_ON_ONCE(total >= timeout_ms))
> return -1;
>
> - timeout++;
> -
> - /* Yield CPU */
> - if (!in_interrupt())
> - schedule();
> - else {
> - for (i = 0; i < 20; i++)
> - cpu_relax();
> - }
> + total += delay_ms;
> + msleep(delay_ms);
> }
>
> return 0;
> --
> 2.29.2
>
Looks Good.
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
--
Himanshu Madhani Oracle Linux Engineering
next prev parent reply other threads:[~2020-11-30 19:15 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-26 13:29 [PATCH 00/14] scsi: Remove in_interrupt() usage Sebastian Andrzej Siewior
2020-11-26 13:29 ` [PATCH 01/14] scsi: pm80xx: Do not sleep in atomic context Sebastian Andrzej Siewior
2020-11-26 13:58 ` Jinpu Wang
2020-11-26 13:29 ` [PATCH 02/14] scsi: hisi_sas: Remove preemptible() Sebastian Andrzej Siewior
2020-11-26 14:10 ` John Garry
2020-11-26 13:29 ` [PATCH 03/14] scsi: qla4xxx: qla4_82xx_crb_win_lock(): Remove in_interrupt() Sebastian Andrzej Siewior
2020-11-30 13:54 ` Daniel Wagner
2020-11-26 13:29 ` [PATCH 04/14] scsi: qla2xxx: qla82xx: " Sebastian Andrzej Siewior
2020-11-30 10:59 ` Daniel Wagner
2020-11-30 19:11 ` Himanshu Madhani [this message]
2020-11-26 13:29 ` [PATCH 05/14] scsi: qla2xxx: tcm_qla2xxx: Remove BUG_ON(in_interrupt()) Sebastian Andrzej Siewior
2020-11-30 11:02 ` Daniel Wagner
2020-11-30 19:13 ` Himanshu Madhani
2020-11-26 13:29 ` [PATCH 06/14] scsi: qla2xxx: init/os: Remove in_interrupt() Sebastian Andrzej Siewior
2020-11-30 13:26 ` Daniel Wagner
2020-11-30 19:14 ` Himanshu Madhani
2020-11-26 13:29 ` [PATCH 07/14] scsi: qla4xxx: qla4_82xx_idc_lock(): " Sebastian Andrzej Siewior
2020-11-30 14:20 ` Daniel Wagner
2020-11-26 13:29 ` [PATCH 08/14] scsi: qla4xxx: qla4_82xx_rom_lock(): " Sebastian Andrzej Siewior
2020-11-30 14:33 ` Daniel Wagner
2020-11-26 13:29 ` [PATCH 09/14] scsi: mpt3sas: " Sebastian Andrzej Siewior
2020-11-30 15:16 ` Daniel Wagner
2020-11-26 13:29 ` [PATCH 10/14] scsi: myrb: Remove WARN_ON(in_interrupt()) Sebastian Andrzej Siewior
2020-11-30 15:21 ` Daniel Wagner
2020-11-26 13:29 ` [PATCH 11/14] scsi: myrs: " Sebastian Andrzej Siewior
2020-11-30 15:21 ` Daniel Wagner
2020-11-26 13:29 ` [PATCH 12/14] scsi: NCR5380: Remove in_interrupt() Sebastian Andrzej Siewior
2020-11-27 4:37 ` Finn Thain
2020-11-27 21:15 ` Finn Thain
2020-11-27 21:48 ` Finn Thain
2020-11-28 7:28 ` Ahmed S. Darwish
2020-11-30 0:21 ` Finn Thain
2020-11-29 6:54 ` Michael Schmitz
2020-11-30 0:15 ` Finn Thain
2020-11-30 2:42 ` Michael Schmitz
2020-11-26 13:29 ` [PATCH 13/14] scsi: message: fusion: Remove in_interrupt() usage in mpt_config() Sebastian Andrzej Siewior
2020-11-30 15:30 ` Daniel Wagner
2020-11-26 13:29 ` [PATCH 14/14] scsi: message: fusion: Remove in_interrupt() usage in mptsas_cleanup_fw_event_q() Sebastian Andrzej Siewior
2020-11-30 16:07 ` Daniel Wagner
2020-12-01 5:06 ` [PATCH 00/14] scsi: Remove in_interrupt() usage Martin K. Petersen
2020-12-01 9:08 ` Sebastian Andrzej Siewior
2020-12-08 4:51 ` Martin K. Petersen
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=B8EAE100-5178-41D8-97B4-104CEB3500FF@oracle.com \
--to=himanshu.madhani@oracle.com \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=MPT-FusionLinux.pdl@broadcom.com \
--cc=a.darwish@linutronix.de \
--cc=auradkar@google.com \
--cc=bigeasy@linutronix.de \
--cc=chenxiang66@hisilicon.com \
--cc=fthain@telegraphics.com.au \
--cc=hare@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=jinpu.wang@cloud.ionos.com \
--cc=john.garry@huawei.com \
--cc=linux-m68k@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mrangankar@marvell.com \
--cc=njavali@marvell.com \
--cc=sathya.prakash@broadcom.com \
--cc=schmitzmic@gmail.com \
--cc=sreekanth.reddy@broadcom.com \
--cc=suganath-prabu.subramani@broadcom.com \
--cc=tanxiaofei@huawei.com \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).