From: Finn Thain <fthain@telegraphics.com.au>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-scsi@vger.kernel.org,
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@lists.linux-m68k.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 12/14] scsi: NCR5380: Remove in_interrupt().
Date: Sat, 28 Nov 2020 08:15:03 +1100 (AEDT) [thread overview]
Message-ID: <alpine.LNX.2.23.453.2011280802170.6@nippy.intranet> (raw)
In-Reply-To: <alpine.LNX.2.23.453.2011271524140.15@nippy.intranet>
On Fri, 27 Nov 2020, Finn Thain wrote:
>
> On Thu, 26 Nov 2020, Sebastian Andrzej Siewior wrote:
>
> > From: "Ahmed S. Darwish" <a.darwish@linutronix.de>
> >
> > NCR5380_poll_politely2() uses in_interrupt() to check if it is safe to
> > sleep.
> >
> > The usage of in_interrupt() in drivers is phased out and Linus clearly
> > requested that code which changes behaviour depending on context should
> > either be separated, or the context be explicitly conveyed in an
> > argument passed by the caller.
> >
> > Below is a context analysis of NCR5380_poll_politely2() uppermost
> > callers:
> >
> > - NCR5380_maybe_reset_bus(), task, invoked during device probe.
> > -> NCR5380_poll_politely()
> > -> do_abort()
> >
> > - NCR5380_select(), task, but can only sleep in the "release, then
> > re-acquire" regions of the spinlock held by its caller.
> > Sleeping invocations (lock released):
> > -> NCR5380_poll_politely2()
> >
> > Atomic invocations (lock acquired):
> > -> NCR5380_reselect()
> > -> NCR5380_poll_politely()
> > -> do_abort()
> > -> NCR5380_transfer_pio()
> >
> > - NCR5380_intr(), interrupt handler
> > -> NCR5380_dma_complete()
> > -> NCR5380_transfer_pio()
> > -> NCR5380_poll_politely()
> > -> NCR5380_reselect() (see above)
> >
> > - NCR5380_information_transfer(), task, but can only sleep in the
> > "release, then re-acquire" regions of the caller-held spinlock.
> > Sleeping invocations (lock released):
> > - NCR5380_transfer_pio() -> NCR5380_poll_politely()
> > - NCR5380_poll_politely()
> >
> > Atomic invocations (lock acquired):
> > - NCR5380_transfer_dma()
> > -> NCR5380_dma_recv_setup()
> > => generic_NCR5380_precv() -> NCR5380_poll_politely()
> > => macscsi_pread() -> NCR5380_poll_politely()
> >
> > -> NCR5380_dma_send_setup()
> > => generic_NCR5380_psend -> NCR5380_poll_politely2()
> > => macscsi_pwrite() -> NCR5380_poll_politely()
> >
> > -> NCR5380_poll_politely2()
> > -> NCR5380_dma_complete()
> > -> NCR5380_transfer_pio()
> > -> NCR5380_poll_politely()
> > - NCR5380_transfer_pio() -> NCR5380_poll_politely
> >
> > - NCR5380_reselect(), atomic, always called with hostdata spinlock
> > held.
> >
> > If direct callers are purely atomic, or purely task context, change
> > their specifications accordingly and mark them with "Context: " tags.
> >
> > For the mixed ones, trickle-down context from upper layers.
> >
> > Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
> > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>
> Acked-by: Finn Thain <fthain@telegraphics.com.au>
>
On second thoughts, have you considered this patch instead?
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index d654a6cc4162..739def70cffb 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -223,7 +223,10 @@ static int NCR5380_poll_politely2(struct NCR5380_hostdata *hostdata,
cpu_relax();
} while (n--);
- if (irqs_disabled() || in_interrupt())
+ /* We can't sleep when local irqs are disabled and callers ensure
+ * that local irqs are disabled whenever we can't sleep.
+ */
+ if (irqs_disabled())
return -ETIMEDOUT;
/* Repeatedly sleep for 1 ms until deadline */
> > @@ -513,9 +513,11 @@ static void wait_for_53c80_access(struct NCR5380_hostdata *hostdata)
> > * @dst: buffer to write into
> > * @len: transfer size
> > *
> > + * Context: atomic. This implements NCR5380.c NCR5380_dma_recv_setup(),
> > + * which is always called with @hostdata spinlock held.
> > + *
> > * Perform a pseudo DMA mode receive from a 53C400 or equivalent device.
> > */
> > -
> > static inline int generic_NCR5380_precv(struct NCR5380_hostdata *hostdata,
> > unsigned char *dst, int len)
> > {
>
> BTW, if I was doing this, I'd omit all of the many gratuitous whitespace
> changes and I'd avoid copying so much program logic into the comments
> where it is redundant -- here I'd have written only "Context: atomic,
> spinlock held". However, no need to revise. Looks fine otherwise.
>
Also BTW, the phrase "may sleep" expresses that the caller permits the
callee to sleep. Whereas, "can sleep" expresses that the callee is put on
notice by the caller that sleeping is a possibility. And since the caller
determines the actual true or false value, and the callee determines
whether sleeping actually takes place, only the former phrase makes sense.
next prev parent reply other threads:[~2020-11-27 21:19 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
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 [this message]
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=alpine.LNX.2.23.453.2011280802170.6@nippy.intranet \
--to=fthain@telegraphics.com.au \
--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=hare@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=jinpu.wang@cloud.ionos.com \
--cc=john.garry@huawei.com \
--cc=linux-m68k@lists.linux-m68k.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