linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, axboe@suse.de,
	albertcc@tw.ibm.com, lkosewsk@gmail.com,
	linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 11/13] libata-hp: add hotplug flags and flag handling functions
Date: Tue, 11 Apr 2006 23:06:22 +0900	[thread overview]
Message-ID: <11447643824116-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11447643813451-git-send-email-htejun@gmail.com>

Add ap->hotplug_flags field, define ATA_HOTPLUG_*, ATA_DFLAG_DETACH_*
and flag manipulation functions.

As ap->hotplug_flags will be accessed by EH and SCSI hotplug work
simultaneosly, changes should be atomic.  Define functions to
manipulate ap->hostplug_flags - ata_set_hotplug_flags(),
ata_clr_hotplug_flags() and ata_schedule_probe(), which is a shortcut
for setting ATA_HOTPLUG_PROBE, a common operation for LLDDs.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 include/linux/libata.h |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

a0d2a754a788df7a123013480a3295d0c61c0940
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 94f1e9a..2a93c44 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -130,6 +130,9 @@ enum {
 	ATA_DFLAG_FAILED	= (1 << 9), /* device has failed */
 	ATA_DFLAG_INIT_MASK	= (1 << 16) - 1,
 
+	ATA_DFLAG_DETACH_ATA	= (1 << 16), /* detach ATA device */
+	ATA_DFLAG_DETACH_SCSI	= (1 << 17), /* detach SCSI device */
+
 	ATA_DEV_UNKNOWN		= 0,	/* unknown device */
 	ATA_DEV_ATA		= 1,	/* ATA device */
 	ATA_DEV_ATA_UNSUP	= 2,	/* ATA device (unsupported) */
@@ -161,9 +164,15 @@ enum {
 	ATA_FLAG_DISABLED	= (1 << 19), /* port is disabled, ignore it */
 	ATA_FLAG_FROZEN		= (1 << 20), /* port is frozen */
 	ATA_FLAG_SUSPENDED	= (1 << 21), /* port is suspended (power) */
-
 	/* bits 24:31 of ap->flags are reserved for LLDD specific flags */
 
+	/* struct ata_port hotplug_flags */
+	ATA_HOTPLUG_RUNNING	= (1 << 0), /* hotplugging online */
+	ATA_HOTPLUG_PROBE	= (1 << 1), /* probe requested */
+	ATA_HOTPLUG_DID_PROBE	= (1 << 2), /* already probed in this run */
+	ATA_HOTPLUG_SCSI_PLUG	= (1 << 3), /* SCSI hotplug scheduled */
+	ATA_HOTPLUG_SCSI_UNPLUG	= (1 << 4), /* SCSI hotunplug scheduled */
+
 	/* struct ata_queued_cmd flags */
 	ATA_QCFLAG_ACTIVE	= (1 << 0), /* cmd not yet ack'd to scsi lyer */
 	ATA_QCFLAG_SG		= (1 << 1), /* have s/g table? */
@@ -471,6 +480,8 @@ struct ata_port {
 	u32			msg_enable;
 	struct list_head	eh_done_q;
 
+	unsigned long		hotplug_flags;
+
 	void			*private_data;
 };
 
@@ -800,6 +811,30 @@ static inline unsigned int ata_dev_absen
 	return ata_class_absent(dev->class);
 }
 
+/* hotplug flag manipulation helpers */
+static inline void ata_set_hotplug_flags(struct ata_port *ap,
+					 unsigned int flags)
+{
+	unsigned long old;
+	do {
+		old = ap->hotplug_flags;
+	} while (cmpxchg(&ap->hotplug_flags, old, old | flags) != old);
+}
+
+static inline void ata_clr_hotplug_flags(struct ata_port *ap,
+					 unsigned int flags)
+{
+	unsigned long old;
+	do {
+		old = ap->hotplug_flags;
+	} while (cmpxchg(&ap->hotplug_flags, old, old & ~flags) != old);
+}
+
+static inline void ata_schedule_probe(struct ata_port *ap)
+{
+	ata_set_hotplug_flags(ap, ATA_HOTPLUG_PROBE);
+}
+
 static inline u8 ata_chk_status(struct ata_port *ap)
 {
 	return ap->ops->check_status(ap);
-- 
1.2.4



  parent reply	other threads:[~2006-04-11 14:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-11 14:06 [PATCHSET 8/9] prep for hotplug support Tejun Heo
2006-04-11 14:06 ` [PATCH 06/13] libata-hp: prepare for persistent device flags Tejun Heo
2006-04-11 14:06 ` [PATCH 05/13] libata-hp: call ata_dev_init() from ata_bus_probe() Tejun Heo
2006-04-11 14:06 ` [PATCH 07/13] libata-hp: implement ap->orig_sata_spd_limit Tejun Heo
2006-04-27  9:19   ` Jeff Garzik
2006-04-27 10:18     ` Tejun Heo
2006-04-11 14:06 ` [PATCH 02/13] libata-hp: add more SERR_* constants in preparation for hotplug support Tejun Heo
2006-04-11 14:06 ` [PATCH 03/13] libata-hp: implement ata_dev_init() Tejun Heo
2006-04-11 14:06 ` [PATCH 04/13] libata-hp: make some fields of ata_device persistent Tejun Heo
2006-04-11 14:06 ` [PATCH 08/13] libata-hp: move device enable/disable out of ata_bus_probe() Tejun Heo
2006-04-11 14:06 ` [PATCH 01/13] libata-hp: separate out __ata_scsi_find_dev() Tejun Heo
2006-04-11 14:06 ` [PATCH 13/13] libata-hp: add ata_hotplug_wq Tejun Heo
2006-04-13  6:11   ` zhao, forrest
2006-04-13  6:33     ` Tejun Heo
2006-04-11 14:06 ` [PATCH 09/13] libata-hp: prepare ata_bus_probe() for hotplug Tejun Heo
2006-04-11 14:06 ` [PATCH 10/13] libata-hp: make ata_bus_probe() extern Tejun Heo
2006-04-11 14:06 ` Tejun Heo [this message]
2006-04-11 14:06 ` [PATCH 12/13] libata-hp: store attached SCSI device Tejun Heo
2006-04-27  9:20   ` Jeff Garzik
2006-04-12  1:41 ` [PATCHSET 8/9] prep for hotplug support Tejun Heo
2006-04-27  9:22 ` Jeff Garzik
2006-04-27 10:27   ` Tejun Heo
2006-04-27 10:36     ` Jeff Garzik
2006-04-27 10:47       ` Tejun Heo

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=11447643824116-git-send-email-htejun@gmail.com \
    --to=htejun@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=albertcc@tw.ibm.com \
    --cc=axboe@suse.de \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=lkosewsk@gmail.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 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).