tech-kern archive

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

Re: DIOCGDISCARDINFO and DIOCDISCARD



On Fri, 11 Oct 2013 10:31:39 -0400
Michael <macallan%netbsd.org@localhost> wrote:
> Something related - how difficult would it be to support something
> TRIM-ish on CompactFlash? Not that I have the faintest clue about ATA
> in general, let alone the CF-specific extensions...

The CF part should be easy to do. To be useful in practice, it would
also be necessary to add calls to it from msdosfs. This code is
a mess. Also, common USB card readers don't support the commands
needed AFAIK.
While we are here... I've found some problems with CF cards
when I plugged them into a PCMCIA slot. First was that it was not
correctly identified by "atactl". The other that the machine crashed
on shutdown if the card's filesystem was not mounted, so that
the slot was powered down.
If you have your CF cards connected in a similar way (i.e. not
translated into an "sd" SCSI device), could you try the appended
patch and see that it does no damage?

best regards
Matthias


------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------

# HG changeset patch
# Parent 24bbe2c07df0865de34a29b0279a2cbb52bbddc4

diff -r 24bbe2c07df0 distrib/utils/sysinst/disks.c
--- a/distrib/utils/sysinst/disks.c     Tue Aug 13 12:24:16 2013 +0200
+++ b/distrib/utils/sysinst/disks.c     Tue Aug 13 15:05:05 2013 +0200
@@ -259,7 +259,8 @@
         * Mitsumi ATAPI devices
         */
 
-       if (!((inqbuf->atap_config & WDC_CFG_ATAPI_MASK) == WDC_CFG_ATAPI &&
+       if (!(inqbuf->atap_config != WDC_CFG_CFA_MAGIC &&
+             (inqbuf->atap_config & WDC_CFG_ATAPI) &&
              ((inqbuf->atap_model[0] == 'N' &&
                  inqbuf->atap_model[1] == 'E') ||
               (inqbuf->atap_model[0] == 'F' &&
diff -r 24bbe2c07df0 sbin/atactl/atactl.c
--- a/sbin/atactl/atactl.c      Tue Aug 13 12:24:16 2013 +0200
+++ b/sbin/atactl/atactl.c      Tue Aug 13 15:05:05 2013 +0200
@@ -947,7 +947,8 @@
         * Mitsumi ATAPI devices
         */
 
-       if (!((inqbuf->atap_config & WDC_CFG_ATAPI_MASK) == WDC_CFG_ATAPI &&
+       if (!(inqbuf->atap_config != WDC_CFG_CFA_MAGIC &&
+             (inqbuf->atap_config & WDC_CFG_ATAPI) &&
              ((inqbuf->atap_model[0] == 'N' &&
                  inqbuf->atap_model[1] == 'E') ||
               (inqbuf->atap_model[0] == 'F' &&
@@ -980,9 +981,13 @@
                    ((uint64_t)inqbuf->atap_wwn[2] << 16) |
                    ((uint64_t)inqbuf->atap_wwn[3] <<  0));
 
-       printf("Device type: %s, %s\n", inqbuf->atap_config & WDC_CFG_ATAPI ?
-              "ATAPI" : "ATA", inqbuf->atap_config & ATA_CFG_FIXED ? "fixed" :
-              "removable");
+       printf("Device type: %s",
+               inqbuf->atap_config == WDC_CFG_CFA_MAGIC ? "CF-ATA" :
+                (inqbuf->atap_config & WDC_CFG_ATAPI ? "ATAPI" : "ATA"));
+       if (inqbuf->atap_config != WDC_CFG_CFA_MAGIC)
+               printf(", %s",
+                inqbuf->atap_config & ATA_CFG_FIXED ? "fixed" : "removable");
+       printf("\n");
 
        compute_capacity(inqbuf, &capacity, &sectors, &secsize);
 
diff -r 24bbe2c07df0 sys/dev/ata/atareg.h
--- a/sys/dev/ata/atareg.h      Tue Aug 13 12:24:16 2013 +0200
+++ b/sys/dev/ata/atareg.h      Tue Aug 13 15:05:05 2013 +0200
@@ -284,7 +284,7 @@
 struct ataparams {
     /* drive info */
     uint16_t   atap_config;            /* 0: general configuration */
-#define WDC_CFG_ATAPI_MASK     0xc000
+#define WDC_CFG_CFA_MAGIC      0x848a
 #define WDC_CFG_ATAPI          0x8000
 #define        ATA_CFG_REMOVABLE       0x0080
 #define        ATA_CFG_FIXED           0x0040
diff -r 24bbe2c07df0 sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c  Tue Aug 13 12:24:16 2013 +0200
+++ b/sys/dev/ata/wd.c  Tue Aug 13 15:05:05 2013 +0200
@@ -408,8 +408,14 @@
 {
        struct wd_softc *sc = device_private(dv);
 
+       /* the adapter needs to be enabled */
+       if (sc->atabus->ata_addref(sc->drvp))
+               return true; /* no need to complain */
+
        wd_flushcache(sc, AT_WAIT);
        wd_standby(sc, AT_WAIT);
+
+       sc->atabus->ata_delref(sc->drvp);
        return true;
 }
 
diff -r 24bbe2c07df0 sys/dev/usb/umass_isdata.c
--- a/sys/dev/usb/umass_isdata.c        Tue Aug 13 12:24:16 2013 +0200
+++ b/sys/dev/usb/umass_isdata.c        Tue Aug 13 15:05:05 2013 +0200
@@ -546,8 +546,8 @@
                 * Shuffle string byte order.
                 * ATAPI Mitsumi and NEC drives don't need this.
                 */
-               if ((prms->atap_config & WDC_CFG_ATAPI_MASK) ==
-                   WDC_CFG_ATAPI &&
+               if (prms->atap_config != WDC_CFG_CFA_MAGIC &&
+                   (prms->atap_config & WDC_CFG_ATAPI) &&
                    ((prms->atap_model[0] == 'N' &&
                        prms->atap_model[1] == 'E') ||
                     (prms->atap_model[0] == 'F' &&


Home | Main Index | Thread Index | Old Index