Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ata Add simplistic atabus(4) rescan support.



details:   https://anonhg.NetBSD.org/src/rev/419fb8d669ed
branches:  trunk
changeset: 764666:419fb8d669ed
user:      jakllsch <jakllsch%NetBSD.org@localhost>
date:      Sat Apr 30 00:34:03 2011 +0000

description:
Add simplistic atabus(4) rescan support.

diffstat:

 sys/dev/ata/ata.c    |  47 ++++++++++++++++++++++++++++++++++++++++++++---
 sys/dev/ata/atavar.h |   3 ++-
 2 files changed, 46 insertions(+), 4 deletions(-)

diffs (103 lines):

diff -r 8261f2a903f3 -r 419fb8d669ed sys/dev/ata/ata.c
--- a/sys/dev/ata/ata.c Fri Apr 29 22:58:46 2011 +0000
+++ b/sys/dev/ata/ata.c Sat Apr 30 00:34:03 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ata.c,v 1.114 2011/04/18 01:47:28 rmind Exp $  */
+/*     $NetBSD: ata.c,v 1.115 2011/04/30 00:34:03 jakllsch Exp $       */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.114 2011/04/18 01:47:28 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.115 2011/04/30 00:34:03 jakllsch Exp $");
 
 #include "opt_ata.h"
 
@@ -105,6 +105,7 @@
 extern struct cfdriver atabus_cd;
 
 static void atabus_childdetached(device_t, device_t);
+static int atabus_rescan(device_t, const char *, const int *);
 static bool atabus_resume(device_t, const pmf_qual_t *);
 static bool atabus_suspend(device_t, const pmf_qual_t *);
 static void atabusconfig_thread(void *);
@@ -396,6 +397,10 @@
                if (chp->ch_flags & ATACH_SHUTDOWN) {
                        break;
                }
+               if (chp->ch_flags & ATACH_TH_RESCAN) {
+                       atabusconfig(sc);
+                       chp->ch_flags &= ~ATACH_TH_RESCAN;
+               }
                if (chp->ch_flags & ATACH_TH_RESET) {
                        /*
                         * ata_reset_channel() will freeze 2 times, so
@@ -585,7 +590,7 @@
 }
 
 CFATTACH_DECL3_NEW(atabus, sizeof(struct atabus_softc),
-    atabus_match, atabus_attach, atabus_detach, NULL, NULL,
+    atabus_match, atabus_attach, atabus_detach, NULL, atabus_rescan,
     atabus_childdetached, DVF_DETACH_SHUTDOWN);
 
 /*****************************************************************************
@@ -1560,3 +1565,39 @@
 
        return true;
 }
+
+static int
+atabus_rescan(device_t self, const char *ifattr, const int *locators)
+{
+       struct atabus_softc *sc = device_private(self);
+       struct ata_channel *chp = sc->sc_chan;
+       struct atabus_initq *initq;
+       int i;
+       int s;
+
+       if (chp->atapibus != NULL) {
+               return EBUSY;
+       }
+
+       for (i = 0; i < ATA_MAXDRIVES; i++) {
+               if (chp->ata_drives[i] != NULL) {
+                       return EBUSY;
+               }
+       }
+
+       s = splbio();
+       for (i = 0; i < ATA_MAXDRIVES; i++) {
+               chp->ch_drive[i].drive_flags = 0;
+       }
+       splx(s);
+
+       initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK);
+       initq->atabus_sc = sc;
+       TAILQ_INSERT_TAIL(&atabus_initq_head, initq, atabus_initq);
+       config_pending_incr();
+
+       chp->ch_flags |= ATACH_TH_RESCAN;
+       wakeup(&chp->ch_thread);
+
+       return 0;
+}
diff -r 8261f2a903f3 -r 419fb8d669ed sys/dev/ata/atavar.h
--- a/sys/dev/ata/atavar.h      Fri Apr 29 22:58:46 2011 +0000
+++ b/sys/dev/ata/atavar.h      Sat Apr 30 00:34:03 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atavar.h,v 1.81 2011/04/18 01:47:28 rmind Exp $        */
+/*     $NetBSD: atavar.h,v 1.82 2011/04/30 00:34:03 jakllsch Exp $     */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -331,6 +331,7 @@
 #define        ATACH_DISABLED 0x80     /* channel is disabled */
 #define ATACH_TH_RUN   0x100   /* the kernel thread is working */
 #define ATACH_TH_RESET 0x200   /* someone ask the thread to reset */
+#define ATACH_TH_RESCAN 0x400  /* rescan requested */
        u_int8_t ch_status;     /* copy of status register */
        u_int8_t ch_error;      /* copy of error register */
 



Home | Main Index | Thread Index | Old Index