Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev Pull up the followin revisions (all via patch), r...



details:   https://anonhg.NetBSD.org/src/rev/d976523d9a3b
branches:  netbsd-9
changeset: 1026623:d976523d9a3b
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Dec 03 18:20:40 2021 +0000

description:
Pull up the followin revisions (all via patch), requested by msaitoh
in ticket #1383:

        sys/dev/sdmmc/sdhc.c                            1.110, 1.112
        sys/dev/sdmmc/sdmmc_mem.c                       1.74
        sys/dev/pci/sdhc_pci.c                          1.18

- Support 64bit BAR.
- Use unsigned to avoid undefined behavior in hwrite[12]() and
  sdmmc_mem_sd_switch().
- Fix typo in comment.

diffstat:

 sys/dev/pci/sdhc_pci.c    |  21 ++++++++++++++++-----
 sys/dev/sdmmc/sdhc.c      |  10 +++++-----
 sys/dev/sdmmc/sdmmc_mem.c |   8 ++++----
 3 files changed, 25 insertions(+), 14 deletions(-)

diffs (127 lines):

diff -r 357b3f96828a -r d976523d9a3b sys/dev/pci/sdhc_pci.c
--- a/sys/dev/pci/sdhc_pci.c    Fri Dec 03 18:11:41 2021 +0000
+++ b/sys/dev/pci/sdhc_pci.c    Fri Dec 03 18:20:40 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdhc_pci.c,v 1.14 2017/04/27 10:01:54 msaitoh Exp $    */
+/*     $NetBSD: sdhc_pci.c,v 1.14.16.1 2021/12/03 18:20:40 martin Exp $        */
 /*     $OpenBSD: sdhc_pci.c,v 1.7 2007/10/30 18:13:45 chl Exp $        */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.14 2017/04/27 10:01:54 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.14.16.1 2021/12/03 18:20:40 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -250,6 +250,7 @@
        bus_space_handle_t ioh;
        bus_size_t size;
        uint32_t flags;
+       int width;
        char intrbuf[PCI_INTRSTR_LEN];
 
        sc->sc.sc_dev = self;
@@ -313,13 +314,23 @@
        if ((PCI_INTERFACE(pa->pa_class) == SDHC_PCI_INTERFACE_DMA))
                SET(sc->sc.sc_flags, SDHC_FLAG_USE_DMA);
 
-       /* XXX: handle 64-bit BARs */
        cnt = 0;
        for (reg = SDHC_PCI_BAR_START + SDHC_PCI_FIRST_BAR(slotinfo) *
                 sizeof(uint32_t);
             reg < SDHC_PCI_BAR_END && nslots > 0;
-            reg += sizeof(uint32_t), nslots--) {
-               if (pci_mapreg_map(pa, reg, PCI_MAPREG_TYPE_MEM, 0,
+            reg += width, nslots--) {
+               pcireg_t type;
+
+               type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, reg);
+               if (type == PCI_MAPREG_TYPE_IO)
+                       break;
+               else if (PCI_MAPREG_MEM_TYPE(type)
+                   == PCI_MAPREG_MEM_TYPE_64BIT)
+                       width = 8;
+               else
+                       width = 4;
+
+               if (pci_mapreg_map(pa, reg, type, 0,
                    &iot, &ioh, NULL, &size)) {
                        continue;
                }
diff -r 357b3f96828a -r d976523d9a3b sys/dev/sdmmc/sdhc.c
--- a/sys/dev/sdmmc/sdhc.c      Fri Dec 03 18:11:41 2021 +0000
+++ b/sys/dev/sdmmc/sdhc.c      Fri Dec 03 18:20:40 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdhc.c,v 1.103.2.2 2020/07/20 18:15:43 martin Exp $    */
+/*     $NetBSD: sdhc.c,v 1.103.2.3 2021/12/03 18:20:41 martin Exp $    */
 /*     $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $        */
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.103.2.2 2020/07/20 18:15:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.103.2.3 2021/12/03 18:20:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -138,7 +138,7 @@
                const size_t shift = 8 * (o & 3);
                o &= -4;
                uint32_t tmp = bus_space_read_4(hp->iot, hp->ioh, o);
-               tmp = (val << shift) | (tmp & ~(0xff << shift));
+               tmp = (val << shift) | (tmp & ~(0xffU << shift));
                bus_space_write_4(hp->iot, hp->ioh, o, tmp);
        }
 }
@@ -153,7 +153,7 @@
                const size_t shift = 8 * (o & 2);
                o &= -4;
                uint32_t tmp = bus_space_read_4(hp->iot, hp->ioh, o);
-               tmp = (val << shift) | (tmp & ~(0xffff << shift));
+               tmp = (val << shift) | (tmp & ~(0xffffU << shift));
                bus_space_write_4(hp->iot, hp->ioh, o, tmp);
        }
 }
@@ -403,7 +403,7 @@
 
        /*
         * Use DMA if the host system and the controller support it.
-        * Suports integrated or external DMA egine, with or without
+        * Supports integrated or external DMA egine, with or without
         * SDHC_DMA_ENABLE in the command.
         */
        if (ISSET(sc->sc_flags, SDHC_FLAG_FORCE_DMA) ||
diff -r 357b3f96828a -r d976523d9a3b sys/dev/sdmmc/sdmmc_mem.c
--- a/sys/dev/sdmmc/sdmmc_mem.c Fri Dec 03 18:11:41 2021 +0000
+++ b/sys/dev/sdmmc/sdmmc_mem.c Fri Dec 03 18:20:40 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sdmmc_mem.c,v 1.68.2.2 2020/08/09 14:03:07 martin Exp $        */
+/*     $NetBSD: sdmmc_mem.c,v 1.68.2.3 2021/12/03 18:20:41 martin Exp $        */
 /*     $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $      */
 
 /*
@@ -45,7 +45,7 @@
 /* Routines for SD/MMC memory cards. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.68.2.2 2020/08/09 14:03:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.68.2.3 2021/12/03 18:20:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -1605,8 +1605,8 @@
        cmd.c_datalen = statlen;
        cmd.c_blklen = statlen;
        cmd.c_opcode = SD_SEND_SWITCH_FUNC;
-       cmd.c_arg =
-           (!!mode << 31) | (function << gsft) | (0x00ffffff & ~(0xf << gsft));
+       cmd.c_arg = ((uint32_t)!!mode << 31) |
+           (function << gsft) | (0x00ffffff & ~(0xf << gsft));
        cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1 | SCF_RSP_SPI_R1;
        if (ISSET(sc->sc_caps, SMC_CAPS_DMA))
                cmd.c_dmamap = sc->sc_dmap;



Home | Main Index | Thread Index | Old Index