svn commit: r367306 - head/sys/cam/mmc
Author: kibab Date: Tue Nov 3 21:38:59 2020 New Revision: 367306 URL: https://svnweb.freebsd.org/changeset/base/367306 Log: Always return MMC errors from mmc_handle_reply() There are two ways to propagate the error in MMCCAM: * Using cmd.error which is set by the peripheral driver; * Using CCB status which is... also set by the driver. The problem is that those two error conditions don't necessarily match. This leads to the confusion when handling the MMC reply. So enforce the consistency by panicking if request is marked as completed successfully but MMC-level error is present (this hints to the programming error). Reviewed by: manu Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D26925 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Tue Nov 3 20:43:01 2020(r367305) +++ head/sys/cam/mmc/mmc_da.c Tue Nov 3 21:38:59 2020(r367306) @@ -239,31 +239,29 @@ get_rca(struct cam_periph *periph) { /* * Figure out if CCB execution resulted in error. * Look at both CAM-level errors and on MMC protocol errors. + * + * Return value is always MMC error. */ static int mmc_handle_reply(union ccb *ccb) { - KASSERT(ccb->ccb_h.func_code == XPT_MMC_IO, ("ccb %p: cannot handle non-XPT_MMC_IO errors, got func_code=%d", ccb, ccb->ccb_h.func_code)); - /* TODO: maybe put MMC-specific handling into cam.c/cam_error_print altogether */ - if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { - if (ccb->mmcio.cmd.error != 0) { - xpt_print_path(ccb->ccb_h.path); - printf("CMD%d failed, err %d (%s)\n", - ccb->mmcio.cmd.opcode, - ccb->mmcio.cmd.error, - mmc_errmsg[ccb->mmcio.cmd.error]); - return (EIO); - } - } else { - cam_error_print(ccb, CAM_ESF_ALL, CAM_EPF_ALL); - return (EIO); - } + /* CAM-level error should always correspond to MMC-level error */ + if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) && + (ccb->mmcio.cmd.error != MMC_ERR_NONE)) + panic("CCB status is OK but MMC error != MMC_ERR_NONE"); - return (0); /* Normal return */ + if (ccb->mmcio.cmd.error != MMC_ERR_NONE) { + xpt_print_path(ccb->ccb_h.path); + printf("CMD%d failed, err %d (%s)\n", + ccb->mmcio.cmd.opcode, + ccb->mmcio.cmd.error, + mmc_errmsg[ccb->mmcio.cmd.error]); + } + return (ccb->mmcio.cmd.error); } static uint32_t ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r367180 - head/sbin/camcontrol
Author: kibab Date: Fri Oct 30 18:55:08 2020 New Revision: 367180 URL: https://svnweb.freebsd.org/changeset/base/367180 Log: Add help messages for camcontrol(8) MMCCAM functionality This adds the help messages for camcontrol(8) in-binary help. Man page will follow in the separate change. Reviewed by: bz Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D25963 Modified: head/sbin/camcontrol/camcontrol.c Modified: head/sbin/camcontrol/camcontrol.c == --- head/sbin/camcontrol/camcontrol.c Fri Oct 30 18:48:09 2020 (r367179) +++ head/sbin/camcontrol/camcontrol.c Fri Oct 30 18:55:08 2020 (r367180) @@ -9988,6 +9988,13 @@ usage(int printlong) "camcontrol timestamp [dev_id][generic_args] <-r [-f format|-m|-U]>|\n" " <-s <-f format -T time | -U >>\n" "camcontrol devtype[dev_id]\n" +"camcontrol mmcsdcmd [dev_id] [[-c mmc_opcode] [-a mmc_arg]\n" +" [-f mmc_flags] [-l data_len]\n" +" [-W [-b data_byte]]] |\n" +" [-F frequency] |\n" +" [-I]\n" +" [-1 | -4]\n" +" [-S high|normal]\n" " \n" "camcontrol help\n"); if (!printlong) @@ -10034,6 +10041,7 @@ usage(int printlong) "epc send ATA Extended Power Conditions commands\n" "timestamp report or set the device's timestamp\n" "devtype report the type of device\n" +"mmcsdcmdsend the given MMC command, needs -c and -a as well\n" "helpthis message\n" "Device Identifiers:\n" "bus:targetspecify the bus and target, lun defaults to 0\n" @@ -10242,6 +10250,18 @@ usage(int printlong) "-f format the format of the time string passed into strptime(3)\n" "-T time the time value passed into strptime(3)\n" "-Uset the timestamp of the device to UTC time\n" +"mmcsdcmd arguments:\n" +"-c mmc_cmdMMC command to send to the card\n" +"-a mmc_argArgument for the MMC command\n" +"-f mmc_flag Flags to set for the MMC command\n" +"-l data_len Expect data_len bytes of data in reply and display them\n" +"-WFill the data buffer before invoking the MMC command\n" +"-b data_byte One byte of data to fill the data buffer with\n" +"-F frequency Operating frequency to set on the controller\n" +"-4Set bus width to 4 bit\n" +"-1Set bus width to 8 bit\n" +"-S high | std Set high-speed or standard timing\n" +"-IDisplay various card and host controller information\n" ); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r363870 - head/sys/cam/mmc
Author: kibab Date: Tue Aug 4 21:58:43 2020 New Revision: 363870 URL: https://svnweb.freebsd.org/changeset/base/363870 Log: Minor cleanups in mmc_xpt.c * Downgrade some CAM debug messages from _INFO to _DEBUG level; * Add KASSERT for the case when we suspect incorrect CAM SIM initialization (using cam_sim_alloc() instead of cam_sim_alloc_dev()); * Use waiting version of xpt_alloc_ccb(), we are not in hurry; * With the waiting version we cannot get NULL return, so remove the NULL check; * In some csses, the name of mmcprobe_done has been written as mmc_probedone(); * Send AC_LOST_DEVICE if we, well, lost the device; * Misc style(9) fixes. Reviewed by: manu Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D25843 Modified: head/sys/cam/mmc/mmc_xpt.c Modified: head/sys/cam/mmc/mmc_xpt.c == --- head/sys/cam/mmc/mmc_xpt.c Tue Aug 4 21:49:13 2020(r363869) +++ head/sys/cam/mmc/mmc_xpt.c Tue Aug 4 21:58:43 2020(r363870) @@ -374,8 +374,7 @@ mmc_announce_periph(struct cam_periph *periph) cam_periph_assert(periph, MA_OWNED); - CAM_DEBUG(periph->path, CAM_DEBUG_INFO, - ("mmc_announce_periph: called\n")); + CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("mmc_announce_periph")); xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL); cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS; @@ -388,15 +387,15 @@ mmc_announce_periph(struct cam_periph *periph) } void -mmccam_start_discovery(struct cam_sim *sim) { +mmccam_start_discovery(struct cam_sim *sim) +{ union ccb *ccb; uint32_t pathid; + KASSERT(sim->sim_dev != NULL, ("mmccam_start_discovery(%s): sim_dev is not initialized," + " has cam_sim_alloc_dev() been used?", cam_sim_name(sim))); pathid = cam_sim_path(sim); - ccb = xpt_alloc_ccb_nowait(); - if (ccb == NULL) { - return; - } + ccb = xpt_alloc_ccb(); /* * We create a rescan request for BUS:0:0, since the card @@ -806,7 +805,7 @@ mmcprobe_done(struct cam_periph *periph, union ccb *do struct ccb_mmcio *mmcio; u_int32_t priority; - CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("mmcprobe_done\n")); + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("mmcprobe_done\n")); softc = (mmcprobe_softc *)periph->softc; path = done_ccb->ccb_h.path; priority = done_ccb->ccb_h.pinfo.priority; @@ -827,6 +826,9 @@ mmcprobe_done(struct cam_periph *periph, union ccb *do /* There was a device there, but now it's gone... */ if ((path->device->flags & CAM_DEV_UNCONFIGURED) == 0) { + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, + ("Device lost!\n")); + xpt_async(AC_LOST_DEVICE, path, NULL); } PROBE_SET_ACTION(softc, PROBE_INVALID); @@ -896,7 +898,7 @@ mmcprobe_done(struct cam_periph *periph, union ccb *do ("SDIO card: %d functions\n", mmcp->sdio_func_count)); if (io_ocr == 0) { CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, - ("SDIO OCR invalid?!\n")); + ("SDIO OCR invalid, retrying\n")); break; /* Retry */ } @@ -1120,22 +1122,21 @@ mmcprobe_done(struct cam_periph *periph, union ccb *do } default: CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, - ("mmc_probedone: invalid action state 0x%x\n", softc->action)); + ("mmcprobe_done: invalid action state 0x%x\n", softc->action)); panic("default: case in mmc_probe_done()"); } -if (softc->action == PROBE_INVALID && -(path->device->flags & CAM_DEV_UNCONFIGURED) == 0) { -CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, - ("mmc_probedone: Should send AC_LOST_DEVICE but won't for now\n")); -//xpt_async(AC_LOST_DEVICE, path, NULL); -} + if (softc->action == PROBE_INVALID && + (path->device->flags & CAM_DEV_UNCONFIGURED) == 0) { + xpt_async(AC_LOST_DEVICE, path, NULL); + } -if (softc->action != PROBE_INVALID) -xpt_schedule(periph, priority); + if (softc->action != PROBE_INVALID) + xpt_schedule(periph, priority); /* Drop freeze taken due to CAM_DEV_QFREEZE flag set. */ int frozen = cam_release_devq(path, 0, 0, 0, FALSE); -CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("mmc_probedone: remaining freezecnt %d\n", frozen)); + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, +
svn commit: r363497 - head/sbin/camcontrol
Author: kibab Date: Fri Jul 24 21:14:59 2020 New Revision: 363497 URL: https://svnweb.freebsd.org/changeset/base/363497 Log: Make it possible to get/set MMC frequency from camcontrol Enhance camcontrol(8) so that it's possible to manually set frequency for SD/MMC cards. While here, display more information about the current controller, such as supported operating modes and VCCQ voltages, as well as current VCCQ voltage. Reviewed by: manu Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D25795 Modified: head/sbin/camcontrol/camcontrol.c Modified: head/sbin/camcontrol/camcontrol.c == --- head/sbin/camcontrol/camcontrol.c Fri Jul 24 20:54:07 2020 (r363496) +++ head/sbin/camcontrol/camcontrol.c Fri Jul 24 21:14:59 2020 (r363497) @@ -190,7 +190,7 @@ static struct camcontrol_opts option_table[] = { {"rescan", CAM_CMD_RESCAN, CAM_ARG_NONE, NULL}, {"reset", CAM_CMD_RESET, CAM_ARG_NONE, NULL}, {"cmd", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, - {"mmcsdcmd", CAM_CMD_MMCSD_CMD, CAM_ARG_NONE, "c:a:f:Wb:l:41S:I"}, + {"mmcsdcmd", CAM_CMD_MMCSD_CMD, CAM_ARG_NONE, "c:a:F:f:Wb:l:41S:I"}, {"command", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, {"smpcmd", CAM_CMD_SMP_CMD, CAM_ARG_NONE, "r:R:"}, {"smprg", CAM_CMD_SMP_RG, CAM_ARG_NONE, smprg_opts}, @@ -7833,10 +7833,12 @@ mmcsdcmd(struct cam_device *device, int argc, char **a int retval; int is_write = 0; int is_bw_4 = 0, is_bw_1 = 0; + int is_frequency = 0; int is_highspeed = 0, is_stdspeed = 0; int is_info_request = 0; int flags = 0; uint8_t mmc_data_byte = 0; + uint32_t mmc_frequency = 0; /* For IO_RW_EXTENDED command */ uint8_t *mmc_data = NULL; @@ -7873,6 +7875,10 @@ mmcsdcmd(struct cam_device *device, int argc, char **a case 'I': is_info_request = 1; break; + case 'F': + is_frequency = 1; + mmc_frequency = strtol(optarg, NULL, 0); + break; case 'c': mmc_opcode = strtol(optarg, NULL, 0); if (mmc_opcode < 0) { @@ -7978,6 +7984,23 @@ mmcsdcmd(struct cam_device *device, int argc, char **a return (retval); } + if (is_frequency) { + struct ccb_trans_settings_mmc *cts; + ccb->ccb_h.func_code = XPT_SET_TRAN_SETTINGS; + ccb->ccb_h.flags = 0; + cts = &ccb->cts.proto_specific.mmc; + cts->ios.clock = mmc_frequency; + cts->ios_valid = MMC_CLK; + if (((retval = cam_send_ccb(device, ccb)) < 0) + || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { + warn("Error sending command"); + } else { + printf("Parameters set OK\n"); + } + cam_freeccb(ccb); + return (retval); + } + // Switch bus speed instead of sending IO command if (is_stdspeed || is_highspeed) { struct ccb_trans_settings_mmc *cts; @@ -8011,13 +8034,48 @@ mmcsdcmd(struct cam_device *device, int argc, char **a printf("Host OCR: 0x%x\n", cts->host_ocr); printf("Min frequency: %u KHz\n", cts->host_f_min / 1000); printf("Max frequency: %u MHz\n", cts->host_f_max / 100); - printf("Supported bus width: "); + printf("Supported bus width:\n"); if (cts->host_caps & MMC_CAP_4_BIT_DATA) printf(" 4 bit\n"); if (cts->host_caps & MMC_CAP_8_BIT_DATA) printf(" 8 bit\n"); - printf("\nCurrent settings:\n"); - printf("Bus width: "); + + printf("Supported operating modes:\n"); + if (cts->host_caps & MMC_CAP_HSPEED) + printf(" Can do High Speed transfers\n"); + if (cts->host_caps & MMC_CAP_UHS_SDR12) + printf(" Can do UHS SDR12\n"); + if (cts->host_caps & MMC_CAP_UHS_SDR25) + printf(" Can do UHS SDR25\n"); + if (cts->host_caps & MMC_CAP_UHS_SDR50) + printf(" Can do UHS SDR50\n"); + if (cts->host_caps & MMC_CAP_UHS_SDR104) + printf(" Can do UHS SDR104\n"); + if (cts->host_caps & MMC_CAP_UHS_DDR50) + printf(" Can do UHS DDR50\n"); + if (cts->host_caps & MMC_CAP_MMC_DDR52_120) + printf(" Can do eMMC DDR52 at 1.2V\n"); + if (cts->host_caps & MMC_CAP_MMC_DDR52_180) + printf
Re: svn commit: r354206 - head/sys/arm/allwinner
The first part (cam_sim_alloc -> cam_sim_alloc_dev) is necessary to properly fill cam_sim structure so that sdiob(4) can attach to the SDIO card. See https://svnweb.freebsd.org/base?view=revision&revision=r348800 for the details. The second part (new DEVMETHOD) is needed because now MMC adapter becomes a bus (like, something that has children) and without this change the kernel panics when trying to attach sdiob(4). On Thu, Oct 31, 2019 at 1:51 PM Emmanuel Vadot wrote: > On Wed, 30 Oct 2019 20:43:27 +0000 (UTC) > Ilya Bakulin wrote: > > > Author: kibab > > Date: Wed Oct 30 20:43:27 2019 > > New Revision: 354206 > > URL: https://svnweb.freebsd.org/changeset/base/354206 > > > > Log: > > Use the new cam_sim_alloc_dev function to properly initialize SIM > > > > Using cam_sim_alloc_dev() allows to properly set sim_dev field so that > > sdiob(4) can attach to the CAM device that represents SDIO card. > > The same change for SDHCI driver happened in r348800. > > > > Approved by:imp (mentor) > > Differential Revision: https://reviews.freebsd.org/D22192 > > > > Modified: > > head/sys/arm/allwinner/aw_mmc.c > > > > Modified: head/sys/arm/allwinner/aw_mmc.c > > > == > > --- head/sys/arm/allwinner/aw_mmc.c Wed Oct 30 20:08:10 2019 > (r354205) > > +++ head/sys/arm/allwinner/aw_mmc.c Wed Oct 30 20:43:27 2019 > (r354206) > > @@ -526,8 +526,8 @@ aw_mmc_attach(device_t dev) > > } > > > > mtx_init(&sc->sim_mtx, "awmmcsim", NULL, MTX_DEF); > > - sc->sim = cam_sim_alloc(aw_mmc_cam_action, aw_mmc_cam_poll, > > - "aw_mmc_sim", sc, device_get_unit(dev), > > + sc->sim = cam_sim_alloc_dev(aw_mmc_cam_action, aw_mmc_cam_poll, > > + "aw_mmc_sim", sc, dev, > > &sc->sim_mtx, 1, 1, sc->devq); > > > > if (sc->sim == NULL) { > > @@ -1514,6 +1514,7 @@ static device_method_t aw_mmc_methods[] = { > > /* Bus interface */ > > DEVMETHOD(bus_read_ivar,aw_mmc_read_ivar), > > DEVMETHOD(bus_write_ivar, aw_mmc_write_ivar), > > + DEVMETHOD(bus_add_child,bus_generic_add_child), > > Why is this change needed ? > > > > > /* MMC bridge interface */ > > DEVMETHOD(mmcbr_update_ios, aw_mmc_update_ios), > > > -- > Emmanuel Vadot > ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r354206 - head/sys/arm/allwinner
Author: kibab Date: Wed Oct 30 20:43:27 2019 New Revision: 354206 URL: https://svnweb.freebsd.org/changeset/base/354206 Log: Use the new cam_sim_alloc_dev function to properly initialize SIM Using cam_sim_alloc_dev() allows to properly set sim_dev field so that sdiob(4) can attach to the CAM device that represents SDIO card. The same change for SDHCI driver happened in r348800. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D22192 Modified: head/sys/arm/allwinner/aw_mmc.c Modified: head/sys/arm/allwinner/aw_mmc.c == --- head/sys/arm/allwinner/aw_mmc.c Wed Oct 30 20:08:10 2019 (r354205) +++ head/sys/arm/allwinner/aw_mmc.c Wed Oct 30 20:43:27 2019 (r354206) @@ -526,8 +526,8 @@ aw_mmc_attach(device_t dev) } mtx_init(&sc->sim_mtx, "awmmcsim", NULL, MTX_DEF); - sc->sim = cam_sim_alloc(aw_mmc_cam_action, aw_mmc_cam_poll, - "aw_mmc_sim", sc, device_get_unit(dev), + sc->sim = cam_sim_alloc_dev(aw_mmc_cam_action, aw_mmc_cam_poll, + "aw_mmc_sim", sc, dev, &sc->sim_mtx, 1, 1, sc->devq); if (sc->sim == NULL) { @@ -1514,6 +1514,7 @@ static device_method_t aw_mmc_methods[] = { /* Bus interface */ DEVMETHOD(bus_read_ivar,aw_mmc_read_ivar), DEVMETHOD(bus_write_ivar, aw_mmc_write_ivar), + DEVMETHOD(bus_add_child,bus_generic_add_child), /* MMC bridge interface */ DEVMETHOD(mmcbr_update_ios, aw_mmc_update_ios), ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r346098 - in head/sys: arm/allwinner dev/sdhci
Author: kibab Date: Wed Apr 10 19:53:36 2019 New Revision: 346098 URL: https://svnweb.freebsd.org/changeset/base/346098 Log: Implement CMD53 block mode support for SDHCI and AllWinner-based boards If a custom block size requested, use it, otherwise revert to the previous logic of using just a data size if it's less than MMC_BLOCK_SIZE, and MMC_BLOCK_SIZE otherwise. Reviewed by: bz Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D19783 Modified: head/sys/arm/allwinner/aw_mmc.c head/sys/dev/sdhci/sdhci.c Modified: head/sys/arm/allwinner/aw_mmc.c == --- head/sys/arm/allwinner/aw_mmc.c Wed Apr 10 19:49:35 2019 (r346097) +++ head/sys/arm/allwinner/aw_mmc.c Wed Apr 10 19:53:36 2019 (r346098) @@ -1104,10 +1104,17 @@ aw_mmc_request(device_t bus, device_t child, struct mm } if (cmd->data->flags & MMC_DATA_WRITE) cmdreg |= AW_MMC_CMDR_DIR_WRITE; - blksz = min(cmd->data->len, MMC_SECTOR_SIZE); - AW_MMC_WRITE_4(sc, AW_MMC_BKSR, blksz); - AW_MMC_WRITE_4(sc, AW_MMC_BYCR, cmd->data->len); +#ifdef MMCCAM + if (cmd->data->flags & MMC_DATA_BLOCK_SIZE) { + AW_MMC_WRITE_4(sc, AW_MMC_BKSR, cmd->data->block_size); + AW_MMC_WRITE_4(sc, AW_MMC_BYCR, cmd->data->len); + } else +#endif + { + AW_MMC_WRITE_4(sc, AW_MMC_BKSR, blksz); + AW_MMC_WRITE_4(sc, AW_MMC_BYCR, cmd->data->len); + } } else { imask |= AW_MMC_INT_CMD_DONE; } Modified: head/sys/dev/sdhci/sdhci.c == --- head/sys/dev/sdhci/sdhci.c Wed Apr 10 19:49:35 2019(r346097) +++ head/sys/dev/sdhci/sdhci.c Wed Apr 10 19:53:36 2019(r346098) @@ -496,7 +496,13 @@ sdhci_read_block_pio(struct sdhci_slot *slot) buffer = slot->curcmd->data->data; buffer += slot->offset; /* Transfer one block at a time. */ - left = min(512, slot->curcmd->data->len - slot->offset); +#ifdef MMCCAM + if (slot->curcmd->data->flags & MMC_DATA_BLOCK_SIZE) + left = min(slot->curcmd->data->block_size, + slot->curcmd->data->len - slot->offset); + else +#endif + left = min(512, slot->curcmd->data->len - slot->offset); slot->offset += left; /* If we are too fast, broken controllers return zeroes. */ @@ -539,7 +545,13 @@ sdhci_write_block_pio(struct sdhci_slot *slot) buffer = slot->curcmd->data->data; buffer += slot->offset; /* Transfer one block at a time. */ - left = min(512, slot->curcmd->data->len - slot->offset); +#ifdef MMCCAM + if (slot->curcmd->data->flags & MMC_DATA_BLOCK_SIZE) { + left = min(slot->curcmd->data->block_size, + slot->curcmd->data->len - slot->offset); + } else +#endif + left = min(512, slot->curcmd->data->len - slot->offset); slot->offset += left; /* Handle unaligned and aligned buffer cases. */ @@ -1623,9 +1635,9 @@ sdhci_set_transfer_mode(struct sdhci_slot *slot, const return; mode = SDHCI_TRNS_BLK_CNT_EN; - if (data->len > 512) { + if (data->len > 512 || data->block_count > 1) { mode |= SDHCI_TRNS_MULTI; - if (__predict_true( + if (data->block_count == 0 && __predict_true( #ifdef MMCCAM slot->ccb->mmcio.stop.opcode == MMC_STOP_TRANSMISSION && #else @@ -1888,11 +1900,23 @@ sdhci_start_data(struct sdhci_slot *slot, const struct } /* Current data offset for both PIO and DMA. */ slot->offset = 0; - /* Set block size and request border interrupts on the SDMA boundary. */ - blksz = SDHCI_MAKE_BLKSZ(slot->sdma_boundary, ulmin(data->len, 512)); +#ifdef MMCCAM + if (data->flags & MMC_DATA_BLOCK_SIZE) { + /* Set block size and request border interrupts on the SDMA boundary. */ + blksz = SDHCI_MAKE_BLKSZ(slot->sdma_boundary, data->block_size); + blkcnt = data->block_count; + if (__predict_false(sdhci_debug > 0)) + slot_printf(slot, "SDIO Custom block params: blksz: " + "%#10x, blk cnt: %#10x\n", blksz, blkcnt); + } else +#endif + { + /* Set block size and request border interrupts on the SDMA boundary. */ + blksz = SDHCI_MAKE_BLKSZ(slot->sdma_boundary, ulmin(data->len, 512)); + blkcnt = howmany(data->len, 512); + } + WR2(slot, SDHCI_BLOCK_SIZE, blksz); - /* Set block count. */ - blkcnt = howmany(data->len, 512); WR2(slot, SDHCI_BLOCK
svn commit: r346097 - in head: sbin/camcontrol sys/cam/mmc sys/dev/mmc
Author: kibab Date: Wed Apr 10 19:49:35 2019 New Revision: 346097 URL: https://svnweb.freebsd.org/changeset/base/346097 Log: Add new fields to mmc_data in preparation to SDIO CMD53 block mode support SDIO command CMD53 (IO_RW_EXTENDED) allows data transfers using blocks of 1-2048 bytes, with a maximum of 511 blocks per request. Extend mmc_data structure to properly describe such requests, and initialize the new fields in kernel and userland consumers. No actual driver changes happen yet, these will follow in the separate changes. Reviewed by: bz Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D19779 Modified: head/sbin/camcontrol/camcontrol.c head/sys/cam/mmc/mmc_da.c head/sys/dev/mmc/mmcreg.h Modified: head/sbin/camcontrol/camcontrol.c == --- head/sbin/camcontrol/camcontrol.c Wed Apr 10 19:27:14 2019 (r346096) +++ head/sbin/camcontrol/camcontrol.c Wed Apr 10 19:49:35 2019 (r346097) @@ -7788,6 +7788,7 @@ mmcsdcmd(struct cam_device *device, int argc, char **a flags |= CAM_DIR_IN; mmc_data = malloc(mmc_data_len); memset(mmc_data, 0, mmc_data_len); + memset(&mmc_d, 0, sizeof(mmc_d)); mmc_d.len = mmc_data_len; mmc_d.data = mmc_data; mmc_d.flags = MMC_DATA_READ; Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Wed Apr 10 19:27:14 2019(r346096) +++ head/sys/cam/mmc/mmc_da.c Wed Apr 10 19:49:35 2019(r346097) @@ -791,6 +791,11 @@ sddaregister(struct cam_periph *periph, void *arg) softc->state = SDDA_STATE_INIT; softc->mmcdata = (struct mmc_data *)malloc(sizeof(struct mmc_data), M_DEVBUF, M_NOWAIT|M_ZERO); + if (softc->mmcdata == NULL) { + printf("sddaregister: Unable to probe new device. " + "Unable to allocate mmcdata\n"); + return (CAM_REQ_CMP_ERR); + } periph->softc = softc; softc->periph = periph; @@ -889,6 +894,7 @@ mmc_send_ext_csd(struct cam_periph *periph, union ccb struct mmc_data d; KASSERT(buf_len == 512, ("Buffer for ext csd must be 512 bytes")); + memset(&d, 0, sizeof(d)); d.data = rawextcsd; d.len = buf_len; d.flags = MMC_DATA_READ; @@ -1013,6 +1019,7 @@ mmc_sd_switch(struct cam_periph *periph, union ccb *cc int err; memset(res, 0, 64); + memset(&mmc_d, 0, sizeof(mmc_d)); mmc_d.len = 64; mmc_d.data = res; mmc_d.flags = MMC_DATA_READ; @@ -1804,6 +1811,7 @@ sddastart(struct cam_periph *periph, union ccb *start_ mmcio->cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; mmcio->cmd.data = softc->mmcdata; + memset(mmcio->cmd.data, 0, sizeof(struct mmc_data)); mmcio->cmd.data->data = bp->bio_data; mmcio->cmd.data->len = 512 * count; mmcio->cmd.data->flags = (bp->bio_cmd == BIO_READ ? MMC_DATA_READ : MMC_DATA_WRITE); Modified: head/sys/dev/mmc/mmcreg.h == --- head/sys/dev/mmc/mmcreg.h Wed Apr 10 19:27:14 2019(r346096) +++ head/sys/dev/mmc/mmcreg.h Wed Apr 10 19:49:35 2019(r346097) @@ -197,7 +197,10 @@ struct mmc_data { #defineMMC_DATA_READ (1UL << 1) #defineMMC_DATA_STREAM (1UL << 2) #defineMMC_DATA_MULTI (1UL << 3) +#define MMC_DATA_BLOCK_SIZE (1UL << 4) struct mmc_request *mrq; + size_t block_size; /* block size for CMD53 */ + size_t block_count; /* block count for CMD53 */ }; struct mmc_request { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r346100 - head/sys/dev/mmc
Author: kibab Date: Wed Apr 10 20:44:54 2019 New Revision: 346100 URL: https://svnweb.freebsd.org/changeset/base/346100 Log: Add some CMD53-related definitions In preparation to adding block mode functions, add necessary definitions. Reviewed by: bz Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D19832 Modified: head/sys/dev/mmc/mmcreg.h Modified: head/sys/dev/mmc/mmcreg.h == --- head/sys/dev/mmc/mmcreg.h Wed Apr 10 20:11:28 2019(r346099) +++ head/sys/dev/mmc/mmcreg.h Wed Apr 10 20:44:54 2019(r346100) @@ -549,30 +549,39 @@ struct mmc_request { #defineSD_IO_RW_LEN(x) (((x) & 0xFF) << 0) #defineSD_IOE_RW_LEN(x)(((x) & 0x1FF) << 0) +#defineSD_IOE_RW_ADR(x)(((x) & 0x1) << 9) +#defineSD_IOE_RW_INCR (1u << 26) #defineSD_IOE_RW_BLK (1u << 27) +#defineSD_IOE_RW_FUNC(x) (((x) & 0x7) << 28) +#defineSD_IOE_RW_WR(1u << 31) /* Card Common Control Registers (CCCR) */ -#defineSD_IO_CCCR_START0x0 -#defineSD_IO_CCCR_SIZE 0x100 -#defineSD_IO_CCCR_FN_ENABLE0x02 -#defineSD_IO_CCCR_FN_READY 0x03 -#defineSD_IO_CCCR_INT_ENABLE 0x04 -#defineSD_IO_CCCR_INT_PENDING 0x05 -#defineSD_IO_CCCR_CTL 0x06 -#define CCCR_CTL_RES (1 << 3) -#defineSD_IO_CCCR_BUS_WIDTH0x07 +#defineSD_IO_CCCR_START0x0 /* Offset in F0 address space */ +#defineSD_IO_CCCR_SIZE 0x100 /* Total size of CCCR */ +#defineSD_IO_CCCR_FN_ENABLE0x02/* Enabled functions */ +#defineSD_IO_CCCR_FN_READY 0x03/* Function ready status */ +#defineSD_IO_CCCR_INT_ENABLE 0x04/* Per-function interrupt enable */ +#defineSD_IO_CCCR_INT_PENDING 0x05/* Per-function interrupt pending */ +#defineSD_IO_CCCR_CTL 0x06/* I/O Abort register */ +#define CCCR_CTL_RES (1 << 3) /* Perform SDIO reset */ +#defineSD_IO_CCCR_BUS_WIDTH0x07/* Bus Width register */ #define CCCR_BUS_WIDTH_4 (1 << 1) #define CCCR_BUS_WIDTH_1 (1 << 0) -#defineSD_IO_CCCR_CARDCAP 0x08 -#defineSD_IO_CCCR_CISPTR 0x09/* XXX 9-10, 10-11, or 9-12 */ - +#defineSD_IO_CCCR_CARDCAP 0x08/* SDIO card capabilities */ +#define CCCR_CC_SMB(1 << 1) /* CMD53 block mode support */ +#defineSD_IO_CCCR_CISPTR 0x09/* 0x09 - 0x0B */ +#define SD_IO_CCCR_FN0_BLKSZ0x10/* 0x10 - 0x11 */ /* Function Basic Registers (FBR) */ -#defineSD_IO_FBR_START 0x00100 -#defineSD_IO_FBR_SIZE 0x00700 +#defineSD_IO_FBR_START 0x00100 /* Offset in F0 address space */ +#defineSD_IO_FBR_SIZE 0x00700 /* Total size of FBR */ +#define SD_IO_FBR_F_SIZE 0x00100 /* Size of each function */ +#define SD_IO_FBR_START_F(n)(SD_IO_FBR_START + (n-1) * SD_IO_FBR_F_SIZE) +#define SD_IO_FBR_CIS_OFFSET0x9 /* Offset of this function's info block within CIS area */ +#define SD_IO_FBR_IOBLKSZ 0x10 /* Block size for CMD53 block mode operations */ /* Card Information Structure (CIS) */ -#defineSD_IO_CIS_START 0x01000 -#defineSD_IO_CIS_SIZE 0x17000 +#defineSD_IO_CIS_START 0x01000 /* Offset in F0 address space */ +#defineSD_IO_CIS_SIZE 0x17000 /* Total size of CIS */ /* CIS tuple codes (based on PC Card 16) */ #defineSD_IO_CISTPL_VERS_1 0x15 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r345776 - head/sys/cam/mmc
Author: kibab Date: Mon Apr 1 18:54:15 2019 New Revision: 345776 URL: https://svnweb.freebsd.org/changeset/base/345776 Log: Refactor error handling There is some code duplication in error handling paths in a few functions. Create a function for printing such errors in human-readable way and get rid of duplicates. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15912 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:49:39 2019(r345775) +++ head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:54:15 2019(r345776) @@ -150,6 +150,17 @@ struct sdda_softc { struct timeval log_time; }; +static const char *mmc_errmsg[] = +{ + "None", + "Timeout", + "Bad CRC", + "Fifo", + "Failed", + "Invalid", + "NO MEMORY" +}; + #define ccb_bp ppriv_ptr1 static disk_strategy_t sddastrategy; @@ -165,6 +176,7 @@ static voidsddadone(struct cam_periph *periph, static intsddaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags); +static int mmc_handle_reply(union ccb *ccb); static uint16_t get_rca(struct cam_periph *periph); static void sdda_start_init(void *context, union ccb *start_ccb); static void sdda_start_init_task(void *context, int pending); @@ -218,6 +230,37 @@ get_rca(struct cam_periph *periph) { return periph->path->device->mmc_ident_data.card_rca; } +/* + * Figure out if CCB execution resulted in error. + * Look at both CAM-level errors and on MMC protocol errors. +*/ +static int +mmc_handle_reply(union ccb *ccb) +{ + + KASSERT(ccb->ccb_h.func_code == XPT_MMC_IO, + ("ccb %p: cannot handle non-XPT_MMC_IO errors, got func_code=%d", + ccb, ccb->ccb_h.func_code)); + + /* TODO: maybe put MMC-specific handling into cam.c/cam_error_print altogether */ + if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { + if (ccb->mmcio.cmd.error != 0) { + xpt_print_path(ccb->ccb_h.path); + printf("CMD%d failed, err %d (%s)\n", + ccb->mmcio.cmd.opcode, + ccb->mmcio.cmd.error, + mmc_errmsg[ccb->mmcio.cmd.error]); + return (EIO); + } + } else { + cam_error_print(ccb, CAM_ESF_ALL, CAM_EPF_ALL); + return (EIO); + } + + return (0); /* Normal return */ +} + + static uint32_t mmc_get_bits(uint32_t *bits, int bit_len, int start, int size) { @@ -777,11 +820,12 @@ mmc_exec_app_cmd(struct cam_periph *periph, union ccb /*mmc_data*/ NULL, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); if (err != 0) - return err; + return (err); if (!(ccb->mmcio.cmd.resp[0] & R1_APP_CMD)) - return MMC_ERR_FAILED; + return (EIO); /* Now exec actual command */ int flags = 0; @@ -803,12 +847,14 @@ mmc_exec_app_cmd(struct cam_periph *periph, union ccb /*mmc_data*/ cmd->data, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); + if (err != 0) + return (err); memcpy(cmd->resp, ccb->mmcio.cmd.resp, sizeof(cmd->resp)); cmd->error = ccb->mmcio.cmd.error; - if (err != 0) - return err; - return 0; + + return (0); } static int @@ -858,10 +904,9 @@ mmc_send_ext_csd(struct cam_periph *periph, union ccb /*mmc_data*/ &d, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - if (err != 0) - return (err); - return (MMC_ERR_NONE); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); + return (err); } static void @@ -904,7 +949,7 @@ mmc_switch_fill_mmcio(union ccb *ccb, static int mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca) { - int flags; + int flags, err; flags = (rca ? MMC_RSP_R1B : MMC_RSP_NONE) | MMC_CMD_AC; cam_fill_mmcio(&ccb->mmcio, @@ -918,42 +963,20 @@ mmc_select_card(struct cam_periph *periph, union ccb * /*timeout*/ 0); cam_periph_runccb(ccb, sddaerr
svn commit: r345775 - in head/sys: arm/allwinner cam cam/mmc dev/sdhci
Author: kibab Date: Mon Apr 1 18:49:39 2019 New Revision: 345775 URL: https://svnweb.freebsd.org/changeset/base/345775 Log: Use information about max data size that the controller is able to operate Using DFLTPHYS/MAXPHYS is not always OK, instead make it possible for the controller driver to provide maximum data size to MMCCAM, and use it there. The old stack already does this. Reviewed by: manu Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15892 Modified: head/sys/arm/allwinner/aw_mmc.c head/sys/cam/cam_ccb.h head/sys/cam/mmc/mmc_da.c head/sys/dev/sdhci/sdhci.c Modified: head/sys/arm/allwinner/aw_mmc.c == --- head/sys/arm/allwinner/aw_mmc.c Mon Apr 1 18:35:27 2019 (r345774) +++ head/sys/arm/allwinner/aw_mmc.c Mon Apr 1 18:49:39 2019 (r345775) @@ -256,6 +256,8 @@ aw_mmc_cam_action(struct cam_sim *sim, union ccb *ccb) cts->proto_specific.mmc.host_f_min = sc->aw_host.f_min; cts->proto_specific.mmc.host_f_max = sc->aw_host.f_max; cts->proto_specific.mmc.host_caps = sc->aw_host.caps; + cts->proto_specific.mmc.host_max_data = (sc->aw_mmc_conf->dma_xferlen * + AW_MMC_DMA_SEGS) / MMC_SECTOR_SIZE; memcpy(&cts->proto_specific.mmc.ios, &sc->aw_host.ios, sizeof(struct mmc_ios)); ccb->ccb_h.status = CAM_REQ_CMP; break; Modified: head/sys/cam/cam_ccb.h == --- head/sys/cam/cam_ccb.h Mon Apr 1 18:35:27 2019(r345774) +++ head/sys/cam/cam_ccb.h Mon Apr 1 18:49:39 2019(r345775) @@ -1051,6 +1051,7 @@ struct ccb_trans_settings_mmc { #define MMC_CAP_8_BIT_DATA (1 << 1) /* Can do 8-bit data transfers */ #define MMC_CAP_HSPEED (1 << 2) /* Can do High Speed transfers */ uint32_t host_caps; + uint32_t host_max_data; }; /* Get/Set transfer rate/width/disconnection/tag queueing settings */ Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:35:27 2019(r345774) +++ head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:49:39 2019(r345775) @@ -1195,6 +1195,27 @@ sdda_get_host_caps(struct cam_periph *periph, union cc return (cts->host_caps); } +static uint32_t +sdda_get_max_data(struct cam_periph *periph, union ccb *ccb) +{ + struct ccb_trans_settings_mmc *cts; + + cts = &ccb->cts.proto_specific.mmc; + memset(cts, 0, sizeof(struct ccb_trans_settings_mmc)); + + ccb->ccb_h.func_code = XPT_GET_TRAN_SETTINGS; + ccb->ccb_h.flags = CAM_DIR_NONE; + ccb->ccb_h.retry_count = 0; + ccb->ccb_h.timeout = 100; + ccb->ccb_h.cbfcnp = NULL; + xpt_action(ccb); + + if (ccb->ccb_h.status != CAM_REQ_CMP) + panic("Cannot get host max data"); + KASSERT(cts->host_max_data != 0, ("host_max_data == 0?!")); + return (cts->host_max_data); +} + static void sdda_start_init(void *context, union ccb *start_ccb) { @@ -1420,7 +1441,6 @@ sdda_add_part(struct cam_periph *periph, u_int type, c struct sdda_softc *sc = (struct sdda_softc *)periph->softc; struct sdda_part *part; struct ccb_pathinq cpi; - u_int maxio; CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Partition type '%s', size %ju %s\n", @@ -1479,12 +1499,9 @@ sdda_add_part(struct cam_periph *periph, u_int type, c part->disk->d_gone = sddadiskgonecb; part->disk->d_name = part->name; part->disk->d_drv1 = part; - maxio = cpi.maxio; /* Honor max I/O size of SIM */ - if (maxio == 0) - maxio = DFLTPHYS; /* traditional default */ - else if (maxio > MAXPHYS) - maxio = MAXPHYS;/* for safety */ - part->disk->d_maxsize = maxio; + part->disk->d_maxsize = + MIN(MAXPHYS, sdda_get_max_data(periph, + (union ccb *)&cpi) * mmc_get_sector_size(periph)); part->disk->d_unit = cnt; part->disk->d_flags = 0; strlcpy(part->disk->d_descr, sc->card_id_string, Modified: head/sys/dev/sdhci/sdhci.c == --- head/sys/dev/sdhci/sdhci.c Mon Apr 1 18:35:27 2019(r345774) +++ head/sys/dev/sdhci/sdhci.c Mon Apr 1 18:49:39 2019(r345775) @@ -2580,6 +2580,7 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; + uint32_t max_data; if (sdhci_debug > 1) slot_printf(slot, "Got XPT_GET_TRAN_SETTINGS\n"); @@ -2593,6 +2594,19 @@ sdhci_cam_action(stru
svn commit: r346100 - head/sys/dev/mmc
Author: kibab Date: Wed Apr 10 20:44:54 2019 New Revision: 346100 URL: https://svnweb.freebsd.org/changeset/base/346100 Log: Add some CMD53-related definitions In preparation to adding block mode functions, add necessary definitions. Reviewed by: bz Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D19832 Modified: head/sys/dev/mmc/mmcreg.h Modified: head/sys/dev/mmc/mmcreg.h == --- head/sys/dev/mmc/mmcreg.h Wed Apr 10 20:11:28 2019(r346099) +++ head/sys/dev/mmc/mmcreg.h Wed Apr 10 20:44:54 2019(r346100) @@ -549,30 +549,39 @@ struct mmc_request { #defineSD_IO_RW_LEN(x) (((x) & 0xFF) << 0) #defineSD_IOE_RW_LEN(x)(((x) & 0x1FF) << 0) +#defineSD_IOE_RW_ADR(x)(((x) & 0x1) << 9) +#defineSD_IOE_RW_INCR (1u << 26) #defineSD_IOE_RW_BLK (1u << 27) +#defineSD_IOE_RW_FUNC(x) (((x) & 0x7) << 28) +#defineSD_IOE_RW_WR(1u << 31) /* Card Common Control Registers (CCCR) */ -#defineSD_IO_CCCR_START0x0 -#defineSD_IO_CCCR_SIZE 0x100 -#defineSD_IO_CCCR_FN_ENABLE0x02 -#defineSD_IO_CCCR_FN_READY 0x03 -#defineSD_IO_CCCR_INT_ENABLE 0x04 -#defineSD_IO_CCCR_INT_PENDING 0x05 -#defineSD_IO_CCCR_CTL 0x06 -#define CCCR_CTL_RES (1 << 3) -#defineSD_IO_CCCR_BUS_WIDTH0x07 +#defineSD_IO_CCCR_START0x0 /* Offset in F0 address space */ +#defineSD_IO_CCCR_SIZE 0x100 /* Total size of CCCR */ +#defineSD_IO_CCCR_FN_ENABLE0x02/* Enabled functions */ +#defineSD_IO_CCCR_FN_READY 0x03/* Function ready status */ +#defineSD_IO_CCCR_INT_ENABLE 0x04/* Per-function interrupt enable */ +#defineSD_IO_CCCR_INT_PENDING 0x05/* Per-function interrupt pending */ +#defineSD_IO_CCCR_CTL 0x06/* I/O Abort register */ +#define CCCR_CTL_RES (1 << 3) /* Perform SDIO reset */ +#defineSD_IO_CCCR_BUS_WIDTH0x07/* Bus Width register */ #define CCCR_BUS_WIDTH_4 (1 << 1) #define CCCR_BUS_WIDTH_1 (1 << 0) -#defineSD_IO_CCCR_CARDCAP 0x08 -#defineSD_IO_CCCR_CISPTR 0x09/* XXX 9-10, 10-11, or 9-12 */ - +#defineSD_IO_CCCR_CARDCAP 0x08/* SDIO card capabilities */ +#define CCCR_CC_SMB(1 << 1) /* CMD53 block mode support */ +#defineSD_IO_CCCR_CISPTR 0x09/* 0x09 - 0x0B */ +#define SD_IO_CCCR_FN0_BLKSZ0x10/* 0x10 - 0x11 */ /* Function Basic Registers (FBR) */ -#defineSD_IO_FBR_START 0x00100 -#defineSD_IO_FBR_SIZE 0x00700 +#defineSD_IO_FBR_START 0x00100 /* Offset in F0 address space */ +#defineSD_IO_FBR_SIZE 0x00700 /* Total size of FBR */ +#define SD_IO_FBR_F_SIZE 0x00100 /* Size of each function */ +#define SD_IO_FBR_START_F(n)(SD_IO_FBR_START + (n-1) * SD_IO_FBR_F_SIZE) +#define SD_IO_FBR_CIS_OFFSET0x9 /* Offset of this function's info block within CIS area */ +#define SD_IO_FBR_IOBLKSZ 0x10 /* Block size for CMD53 block mode operations */ /* Card Information Structure (CIS) */ -#defineSD_IO_CIS_START 0x01000 -#defineSD_IO_CIS_SIZE 0x17000 +#defineSD_IO_CIS_START 0x01000 /* Offset in F0 address space */ +#defineSD_IO_CIS_SIZE 0x17000 /* Total size of CIS */ /* CIS tuple codes (based on PC Card 16) */ #defineSD_IO_CISTPL_VERS_1 0x15 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r346098 - in head/sys: arm/allwinner dev/sdhci
Author: kibab Date: Wed Apr 10 19:53:36 2019 New Revision: 346098 URL: https://svnweb.freebsd.org/changeset/base/346098 Log: Implement CMD53 block mode support for SDHCI and AllWinner-based boards If a custom block size requested, use it, otherwise revert to the previous logic of using just a data size if it's less than MMC_BLOCK_SIZE, and MMC_BLOCK_SIZE otherwise. Reviewed by: bz Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D19783 Modified: head/sys/arm/allwinner/aw_mmc.c head/sys/dev/sdhci/sdhci.c Modified: head/sys/arm/allwinner/aw_mmc.c == --- head/sys/arm/allwinner/aw_mmc.c Wed Apr 10 19:49:35 2019 (r346097) +++ head/sys/arm/allwinner/aw_mmc.c Wed Apr 10 19:53:36 2019 (r346098) @@ -1104,10 +1104,17 @@ aw_mmc_request(device_t bus, device_t child, struct mm } if (cmd->data->flags & MMC_DATA_WRITE) cmdreg |= AW_MMC_CMDR_DIR_WRITE; - blksz = min(cmd->data->len, MMC_SECTOR_SIZE); - AW_MMC_WRITE_4(sc, AW_MMC_BKSR, blksz); - AW_MMC_WRITE_4(sc, AW_MMC_BYCR, cmd->data->len); +#ifdef MMCCAM + if (cmd->data->flags & MMC_DATA_BLOCK_SIZE) { + AW_MMC_WRITE_4(sc, AW_MMC_BKSR, cmd->data->block_size); + AW_MMC_WRITE_4(sc, AW_MMC_BYCR, cmd->data->len); + } else +#endif + { + AW_MMC_WRITE_4(sc, AW_MMC_BKSR, blksz); + AW_MMC_WRITE_4(sc, AW_MMC_BYCR, cmd->data->len); + } } else { imask |= AW_MMC_INT_CMD_DONE; } Modified: head/sys/dev/sdhci/sdhci.c == --- head/sys/dev/sdhci/sdhci.c Wed Apr 10 19:49:35 2019(r346097) +++ head/sys/dev/sdhci/sdhci.c Wed Apr 10 19:53:36 2019(r346098) @@ -496,7 +496,13 @@ sdhci_read_block_pio(struct sdhci_slot *slot) buffer = slot->curcmd->data->data; buffer += slot->offset; /* Transfer one block at a time. */ - left = min(512, slot->curcmd->data->len - slot->offset); +#ifdef MMCCAM + if (slot->curcmd->data->flags & MMC_DATA_BLOCK_SIZE) + left = min(slot->curcmd->data->block_size, + slot->curcmd->data->len - slot->offset); + else +#endif + left = min(512, slot->curcmd->data->len - slot->offset); slot->offset += left; /* If we are too fast, broken controllers return zeroes. */ @@ -539,7 +545,13 @@ sdhci_write_block_pio(struct sdhci_slot *slot) buffer = slot->curcmd->data->data; buffer += slot->offset; /* Transfer one block at a time. */ - left = min(512, slot->curcmd->data->len - slot->offset); +#ifdef MMCCAM + if (slot->curcmd->data->flags & MMC_DATA_BLOCK_SIZE) { + left = min(slot->curcmd->data->block_size, + slot->curcmd->data->len - slot->offset); + } else +#endif + left = min(512, slot->curcmd->data->len - slot->offset); slot->offset += left; /* Handle unaligned and aligned buffer cases. */ @@ -1623,9 +1635,9 @@ sdhci_set_transfer_mode(struct sdhci_slot *slot, const return; mode = SDHCI_TRNS_BLK_CNT_EN; - if (data->len > 512) { + if (data->len > 512 || data->block_count > 1) { mode |= SDHCI_TRNS_MULTI; - if (__predict_true( + if (data->block_count == 0 && __predict_true( #ifdef MMCCAM slot->ccb->mmcio.stop.opcode == MMC_STOP_TRANSMISSION && #else @@ -1888,11 +1900,23 @@ sdhci_start_data(struct sdhci_slot *slot, const struct } /* Current data offset for both PIO and DMA. */ slot->offset = 0; - /* Set block size and request border interrupts on the SDMA boundary. */ - blksz = SDHCI_MAKE_BLKSZ(slot->sdma_boundary, ulmin(data->len, 512)); +#ifdef MMCCAM + if (data->flags & MMC_DATA_BLOCK_SIZE) { + /* Set block size and request border interrupts on the SDMA boundary. */ + blksz = SDHCI_MAKE_BLKSZ(slot->sdma_boundary, data->block_size); + blkcnt = data->block_count; + if (__predict_false(sdhci_debug > 0)) + slot_printf(slot, "SDIO Custom block params: blksz: " + "%#10x, blk cnt: %#10x\n", blksz, blkcnt); + } else +#endif + { + /* Set block size and request border interrupts on the SDMA boundary. */ + blksz = SDHCI_MAKE_BLKSZ(slot->sdma_boundary, ulmin(data->len, 512)); + blkcnt = howmany(data->len, 512); + } + WR2(slot, SDHCI_BLOCK_SIZE, blksz); - /* Set block count. */ - blkcnt = howmany(data->len, 512); WR2(slot, SDHCI_BLOCK
svn commit: r346097 - in head: sbin/camcontrol sys/cam/mmc sys/dev/mmc
Author: kibab Date: Wed Apr 10 19:49:35 2019 New Revision: 346097 URL: https://svnweb.freebsd.org/changeset/base/346097 Log: Add new fields to mmc_data in preparation to SDIO CMD53 block mode support SDIO command CMD53 (IO_RW_EXTENDED) allows data transfers using blocks of 1-2048 bytes, with a maximum of 511 blocks per request. Extend mmc_data structure to properly describe such requests, and initialize the new fields in kernel and userland consumers. No actual driver changes happen yet, these will follow in the separate changes. Reviewed by: bz Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D19779 Modified: head/sbin/camcontrol/camcontrol.c head/sys/cam/mmc/mmc_da.c head/sys/dev/mmc/mmcreg.h Modified: head/sbin/camcontrol/camcontrol.c == --- head/sbin/camcontrol/camcontrol.c Wed Apr 10 19:27:14 2019 (r346096) +++ head/sbin/camcontrol/camcontrol.c Wed Apr 10 19:49:35 2019 (r346097) @@ -7788,6 +7788,7 @@ mmcsdcmd(struct cam_device *device, int argc, char **a flags |= CAM_DIR_IN; mmc_data = malloc(mmc_data_len); memset(mmc_data, 0, mmc_data_len); + memset(&mmc_d, 0, sizeof(mmc_d)); mmc_d.len = mmc_data_len; mmc_d.data = mmc_data; mmc_d.flags = MMC_DATA_READ; Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Wed Apr 10 19:27:14 2019(r346096) +++ head/sys/cam/mmc/mmc_da.c Wed Apr 10 19:49:35 2019(r346097) @@ -791,6 +791,11 @@ sddaregister(struct cam_periph *periph, void *arg) softc->state = SDDA_STATE_INIT; softc->mmcdata = (struct mmc_data *)malloc(sizeof(struct mmc_data), M_DEVBUF, M_NOWAIT|M_ZERO); + if (softc->mmcdata == NULL) { + printf("sddaregister: Unable to probe new device. " + "Unable to allocate mmcdata\n"); + return (CAM_REQ_CMP_ERR); + } periph->softc = softc; softc->periph = periph; @@ -889,6 +894,7 @@ mmc_send_ext_csd(struct cam_periph *periph, union ccb struct mmc_data d; KASSERT(buf_len == 512, ("Buffer for ext csd must be 512 bytes")); + memset(&d, 0, sizeof(d)); d.data = rawextcsd; d.len = buf_len; d.flags = MMC_DATA_READ; @@ -1013,6 +1019,7 @@ mmc_sd_switch(struct cam_periph *periph, union ccb *cc int err; memset(res, 0, 64); + memset(&mmc_d, 0, sizeof(mmc_d)); mmc_d.len = 64; mmc_d.data = res; mmc_d.flags = MMC_DATA_READ; @@ -1804,6 +1811,7 @@ sddastart(struct cam_periph *periph, union ccb *start_ mmcio->cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; mmcio->cmd.data = softc->mmcdata; + memset(mmcio->cmd.data, 0, sizeof(struct mmc_data)); mmcio->cmd.data->data = bp->bio_data; mmcio->cmd.data->len = 512 * count; mmcio->cmd.data->flags = (bp->bio_cmd == BIO_READ ? MMC_DATA_READ : MMC_DATA_WRITE); Modified: head/sys/dev/mmc/mmcreg.h == --- head/sys/dev/mmc/mmcreg.h Wed Apr 10 19:27:14 2019(r346096) +++ head/sys/dev/mmc/mmcreg.h Wed Apr 10 19:49:35 2019(r346097) @@ -197,7 +197,10 @@ struct mmc_data { #defineMMC_DATA_READ (1UL << 1) #defineMMC_DATA_STREAM (1UL << 2) #defineMMC_DATA_MULTI (1UL << 3) +#define MMC_DATA_BLOCK_SIZE (1UL << 4) struct mmc_request *mrq; + size_t block_size; /* block size for CMD53 */ + size_t block_count; /* block count for CMD53 */ }; struct mmc_request { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r345776 - head/sys/cam/mmc
Author: kibab Date: Mon Apr 1 18:54:15 2019 New Revision: 345776 URL: https://svnweb.freebsd.org/changeset/base/345776 Log: Refactor error handling There is some code duplication in error handling paths in a few functions. Create a function for printing such errors in human-readable way and get rid of duplicates. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15912 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:49:39 2019(r345775) +++ head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:54:15 2019(r345776) @@ -150,6 +150,17 @@ struct sdda_softc { struct timeval log_time; }; +static const char *mmc_errmsg[] = +{ + "None", + "Timeout", + "Bad CRC", + "Fifo", + "Failed", + "Invalid", + "NO MEMORY" +}; + #define ccb_bp ppriv_ptr1 static disk_strategy_t sddastrategy; @@ -165,6 +176,7 @@ static voidsddadone(struct cam_periph *periph, static intsddaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags); +static int mmc_handle_reply(union ccb *ccb); static uint16_t get_rca(struct cam_periph *periph); static void sdda_start_init(void *context, union ccb *start_ccb); static void sdda_start_init_task(void *context, int pending); @@ -218,6 +230,37 @@ get_rca(struct cam_periph *periph) { return periph->path->device->mmc_ident_data.card_rca; } +/* + * Figure out if CCB execution resulted in error. + * Look at both CAM-level errors and on MMC protocol errors. +*/ +static int +mmc_handle_reply(union ccb *ccb) +{ + + KASSERT(ccb->ccb_h.func_code == XPT_MMC_IO, + ("ccb %p: cannot handle non-XPT_MMC_IO errors, got func_code=%d", + ccb, ccb->ccb_h.func_code)); + + /* TODO: maybe put MMC-specific handling into cam.c/cam_error_print altogether */ + if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { + if (ccb->mmcio.cmd.error != 0) { + xpt_print_path(ccb->ccb_h.path); + printf("CMD%d failed, err %d (%s)\n", + ccb->mmcio.cmd.opcode, + ccb->mmcio.cmd.error, + mmc_errmsg[ccb->mmcio.cmd.error]); + return (EIO); + } + } else { + cam_error_print(ccb, CAM_ESF_ALL, CAM_EPF_ALL); + return (EIO); + } + + return (0); /* Normal return */ +} + + static uint32_t mmc_get_bits(uint32_t *bits, int bit_len, int start, int size) { @@ -777,11 +820,12 @@ mmc_exec_app_cmd(struct cam_periph *periph, union ccb /*mmc_data*/ NULL, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); if (err != 0) - return err; + return (err); if (!(ccb->mmcio.cmd.resp[0] & R1_APP_CMD)) - return MMC_ERR_FAILED; + return (EIO); /* Now exec actual command */ int flags = 0; @@ -803,12 +847,14 @@ mmc_exec_app_cmd(struct cam_periph *periph, union ccb /*mmc_data*/ cmd->data, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); + if (err != 0) + return (err); memcpy(cmd->resp, ccb->mmcio.cmd.resp, sizeof(cmd->resp)); cmd->error = ccb->mmcio.cmd.error; - if (err != 0) - return err; - return 0; + + return (0); } static int @@ -858,10 +904,9 @@ mmc_send_ext_csd(struct cam_periph *periph, union ccb /*mmc_data*/ &d, /*timeout*/ 0); - err = cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); - if (err != 0) - return (err); - return (MMC_ERR_NONE); + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + err = mmc_handle_reply(ccb); + return (err); } static void @@ -904,7 +949,7 @@ mmc_switch_fill_mmcio(union ccb *ccb, static int mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca) { - int flags; + int flags, err; flags = (rca ? MMC_RSP_R1B : MMC_RSP_NONE) | MMC_CMD_AC; cam_fill_mmcio(&ccb->mmcio, @@ -918,42 +963,20 @@ mmc_select_card(struct cam_periph *periph, union ccb * /*timeout*/ 0); cam_periph_runccb(ccb, sddaerr
svn commit: r345775 - in head/sys: arm/allwinner cam cam/mmc dev/sdhci
Author: kibab Date: Mon Apr 1 18:49:39 2019 New Revision: 345775 URL: https://svnweb.freebsd.org/changeset/base/345775 Log: Use information about max data size that the controller is able to operate Using DFLTPHYS/MAXPHYS is not always OK, instead make it possible for the controller driver to provide maximum data size to MMCCAM, and use it there. The old stack already does this. Reviewed by: manu Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15892 Modified: head/sys/arm/allwinner/aw_mmc.c head/sys/cam/cam_ccb.h head/sys/cam/mmc/mmc_da.c head/sys/dev/sdhci/sdhci.c Modified: head/sys/arm/allwinner/aw_mmc.c == --- head/sys/arm/allwinner/aw_mmc.c Mon Apr 1 18:35:27 2019 (r345774) +++ head/sys/arm/allwinner/aw_mmc.c Mon Apr 1 18:49:39 2019 (r345775) @@ -256,6 +256,8 @@ aw_mmc_cam_action(struct cam_sim *sim, union ccb *ccb) cts->proto_specific.mmc.host_f_min = sc->aw_host.f_min; cts->proto_specific.mmc.host_f_max = sc->aw_host.f_max; cts->proto_specific.mmc.host_caps = sc->aw_host.caps; + cts->proto_specific.mmc.host_max_data = (sc->aw_mmc_conf->dma_xferlen * + AW_MMC_DMA_SEGS) / MMC_SECTOR_SIZE; memcpy(&cts->proto_specific.mmc.ios, &sc->aw_host.ios, sizeof(struct mmc_ios)); ccb->ccb_h.status = CAM_REQ_CMP; break; Modified: head/sys/cam/cam_ccb.h == --- head/sys/cam/cam_ccb.h Mon Apr 1 18:35:27 2019(r345774) +++ head/sys/cam/cam_ccb.h Mon Apr 1 18:49:39 2019(r345775) @@ -1051,6 +1051,7 @@ struct ccb_trans_settings_mmc { #define MMC_CAP_8_BIT_DATA (1 << 1) /* Can do 8-bit data transfers */ #define MMC_CAP_HSPEED (1 << 2) /* Can do High Speed transfers */ uint32_t host_caps; + uint32_t host_max_data; }; /* Get/Set transfer rate/width/disconnection/tag queueing settings */ Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:35:27 2019(r345774) +++ head/sys/cam/mmc/mmc_da.c Mon Apr 1 18:49:39 2019(r345775) @@ -1195,6 +1195,27 @@ sdda_get_host_caps(struct cam_periph *periph, union cc return (cts->host_caps); } +static uint32_t +sdda_get_max_data(struct cam_periph *periph, union ccb *ccb) +{ + struct ccb_trans_settings_mmc *cts; + + cts = &ccb->cts.proto_specific.mmc; + memset(cts, 0, sizeof(struct ccb_trans_settings_mmc)); + + ccb->ccb_h.func_code = XPT_GET_TRAN_SETTINGS; + ccb->ccb_h.flags = CAM_DIR_NONE; + ccb->ccb_h.retry_count = 0; + ccb->ccb_h.timeout = 100; + ccb->ccb_h.cbfcnp = NULL; + xpt_action(ccb); + + if (ccb->ccb_h.status != CAM_REQ_CMP) + panic("Cannot get host max data"); + KASSERT(cts->host_max_data != 0, ("host_max_data == 0?!")); + return (cts->host_max_data); +} + static void sdda_start_init(void *context, union ccb *start_ccb) { @@ -1420,7 +1441,6 @@ sdda_add_part(struct cam_periph *periph, u_int type, c struct sdda_softc *sc = (struct sdda_softc *)periph->softc; struct sdda_part *part; struct ccb_pathinq cpi; - u_int maxio; CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Partition type '%s', size %ju %s\n", @@ -1479,12 +1499,9 @@ sdda_add_part(struct cam_periph *periph, u_int type, c part->disk->d_gone = sddadiskgonecb; part->disk->d_name = part->name; part->disk->d_drv1 = part; - maxio = cpi.maxio; /* Honor max I/O size of SIM */ - if (maxio == 0) - maxio = DFLTPHYS; /* traditional default */ - else if (maxio > MAXPHYS) - maxio = MAXPHYS;/* for safety */ - part->disk->d_maxsize = maxio; + part->disk->d_maxsize = + MIN(MAXPHYS, sdda_get_max_data(periph, + (union ccb *)&cpi) * mmc_get_sector_size(periph)); part->disk->d_unit = cnt; part->disk->d_flags = 0; strlcpy(part->disk->d_descr, sc->card_id_string, Modified: head/sys/dev/sdhci/sdhci.c == --- head/sys/dev/sdhci/sdhci.c Mon Apr 1 18:35:27 2019(r345774) +++ head/sys/dev/sdhci/sdhci.c Mon Apr 1 18:49:39 2019(r345775) @@ -2580,6 +2580,7 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; + uint32_t max_data; if (sdhci_debug > 1) slot_printf(slot, "Got XPT_GET_TRAN_SETTINGS\n"); @@ -2593,6 +2594,19 @@ sdhci_cam_action(stru
svn commit: r335476 - in head/sys: arm/allwinner conf
Author: kibab Date: Thu Jun 21 11:49:21 2018 New Revision: 335476 URL: https://svnweb.freebsd.org/changeset/base/335476 Log: Add MMCCAM support to AllWinner MMC driver Using MMCCAM on AllWinner boards is now possible, reaching highest possible data transfer speed. For now, MMCCAM doesn't scan cards on boot. This means that scanning has to be done manually and that it's not possible to mount root FS from MMC/SD card since there is no block device at the boot time. For manually scanning the cards, run: # camcontrol rescan X:0:0 Where X is the bus number (look at camcontrol devlist to determine bus number assigned to the MMC controller). Reviewed by: manu Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15891 Modified: head/sys/arm/allwinner/aw_mmc.c head/sys/arm/allwinner/files.allwinner head/sys/conf/files.arm64 Modified: head/sys/arm/allwinner/aw_mmc.c == --- head/sys/arm/allwinner/aw_mmc.c Thu Jun 21 11:43:54 2018 (r335475) +++ head/sys/arm/allwinner/aw_mmc.c Thu Jun 21 11:49:21 2018 (r335476) @@ -55,6 +55,16 @@ __FBSDID("$FreeBSD$"); #include #include +#include "opt_mmccam.h" + +#ifdef MMCCAM +#include +#include +#include +#include +#include +#endif + #defineAW_MMC_MEMRES 0 #defineAW_MMC_IRQRES 1 #defineAW_MMC_RESSZ2 @@ -112,7 +122,14 @@ struct aw_mmc_softc { int aw_timeout; struct callout aw_timeoutc; struct mmc_host aw_host; +#ifdef MMCCAM + union ccb * ccb; + struct cam_devq * devq; + struct cam_sim *sim; + struct mtx sim_mtx; +#else struct mmc_request *aw_req; +#endif struct mtx aw_mtx; struct resource * aw_res[AW_MMC_RESSZ]; struct aw_mmc_conf *aw_mmc_conf; @@ -148,11 +165,19 @@ static int aw_mmc_init(struct aw_mmc_softc *); static void aw_mmc_intr(void *); static int aw_mmc_update_clock(struct aw_mmc_softc *, uint32_t); +static void aw_mmc_print_error(uint32_t); static int aw_mmc_update_ios(device_t, device_t); static int aw_mmc_request(device_t, device_t, struct mmc_request *); static int aw_mmc_get_ro(device_t, device_t); static int aw_mmc_acquire_host(device_t, device_t); static int aw_mmc_release_host(device_t, device_t); +#ifdef MMCCAM +static void aw_mmc_cam_action(struct cam_sim *, union ccb *); +static void aw_mmc_cam_poll(struct cam_sim *); +static int aw_mmc_cam_settran_settings(struct aw_mmc_softc *, union ccb *); +static int aw_mmc_cam_request(struct aw_mmc_softc *, union ccb *); +static void aw_mmc_cam_handle_mmcio(struct cam_sim *, union ccb *); +#endif #defineAW_MMC_LOCK(_sc)mtx_lock(&(_sc)->aw_mtx) #defineAW_MMC_UNLOCK(_sc) mtx_unlock(&(_sc)->aw_mtx) @@ -161,7 +186,201 @@ static int aw_mmc_release_host(device_t, device_t); #defineAW_MMC_WRITE_4(_sc, _reg, _value) \ bus_write_4((_sc)->aw_res[AW_MMC_MEMRES], _reg, _value) +#ifdef MMCCAM +static void +aw_mmc_cam_handle_mmcio(struct cam_sim *sim, union ccb *ccb) +{ + struct aw_mmc_softc *sc; + + sc = cam_sim_softc(sim); + + aw_mmc_cam_request(sc, ccb); +} + +static void +aw_mmc_cam_action(struct cam_sim *sim, union ccb *ccb) +{ + struct aw_mmc_softc *sc; + + sc = cam_sim_softc(sim); + if (sc == NULL) { + ccb->ccb_h.status = CAM_SEL_TIMEOUT; + xpt_done(ccb); + return; + } + + mtx_assert(&sc->sim_mtx, MA_OWNED); + + switch (ccb->ccb_h.func_code) { + case XPT_PATH_INQ: + { + struct ccb_pathinq *cpi; + + cpi = &ccb->cpi; + cpi->version_num = 1; + cpi->hba_inquiry = 0; + cpi->target_sprt = 0; + cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN; + cpi->hba_eng_cnt = 0; + cpi->max_target = 0; + cpi->max_lun = 0; + cpi->initiator_id = 1; + cpi->maxio = (sc->aw_mmc_conf->dma_xferlen * + AW_MMC_DMA_SEGS) / MMC_SECTOR_SIZE; + strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); + strncpy(cpi->hba_vid, "Deglitch Networks", HBA_IDLEN); + strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); + cpi->unit_number = cam_sim_unit(sim); + cpi->bus_id = cam_sim_bus(sim); + cpi->protocol = PROTO_MMCSD; + cpi->protocol_version = SCSI_REV_0; + cpi->transport = XPORT_MMCSD; + cpi->transport_version = 1; + + cpi->ccb_h.status = CAM_REQ_CMP; + break; + } + case XPT_GET_TRAN_SETTINGS: + { +
svn commit: r335384 - head/sys/cam/mmc
Author: kibab Date: Tue Jun 19 20:02:03 2018 New Revision: 335384 URL: https://svnweb.freebsd.org/changeset/base/335384 Log: Fix setting RCA for MMC cards Unlike SD cards, that publish RCA in response to CMD3, MMC cards expect the host to set RCA itself. Since we don't support multiple MMC cards on the bus, just assign a static RCA of 2 to the attached MMC card. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D13063 Modified: head/sys/cam/mmc/mmc.h head/sys/cam/mmc/mmc_xpt.c Modified: head/sys/cam/mmc/mmc.h == --- head/sys/cam/mmc/mmc.h Tue Jun 19 19:27:37 2018(r335383) +++ head/sys/cam/mmc/mmc.h Tue Jun 19 20:02:03 2018(r335384) @@ -94,4 +94,12 @@ struct mmc_params { uint8_t sdio_func_count; } __packed; +/* + * Only one MMC card on bus is supported now. + * If we ever want to support multiple MMC cards on the same bus, + * mmc_xpt needs to be extended to issue new RCAs based on number + * of already probed cards. Furthermore, retuning and high-speed + * settings should also take all cards into account. + */ +#define MMC_PROPOSED_RCA2 #endif Modified: head/sys/cam/mmc/mmc_xpt.c == --- head/sys/cam/mmc/mmc_xpt.c Tue Jun 19 19:27:37 2018(r335383) +++ head/sys/cam/mmc/mmc_xpt.c Tue Jun 19 20:02:03 2018(r335384) @@ -98,7 +98,8 @@ typedef enum { PROBE_GET_CID, PROBE_GET_CSD, PROBE_SEND_RELATIVE_ADDR, -PROBE_SELECT_CARD, + PROBE_MMC_SET_RELATIVE_ADDR, + PROBE_SELECT_CARD, PROBE_DONE, PROBE_INVALID } probe_action; @@ -114,6 +115,7 @@ static char *probe_action_text[] = { "PROBE_GET_CID", "PROBE_GET_CSD", "PROBE_SEND_RELATIVE_ADDR", + "PROBE_MMC_SET_RELATIVE_ADDR", "PROBE_SELECT_CARD", "PROBE_DONE", "PROBE_INVALID" @@ -702,7 +704,6 @@ mmcprobe_start(struct cam_periph *periph, union ccb *s mmcio->cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR; mmcio->stop.opcode = 0; break; - case PROBE_SEND_RELATIVE_ADDR: init_standard_ccb(start_ccb, XPT_MMC_IO); mmcio->cmd.opcode = SD_SEND_RELATIVE_ADDR; @@ -710,6 +711,13 @@ mmcprobe_start(struct cam_periph *periph, union ccb *s mmcio->cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR; mmcio->stop.opcode = 0; break; + case PROBE_MMC_SET_RELATIVE_ADDR: + init_standard_ccb(start_ccb, XPT_MMC_IO); + mmcio->cmd.opcode = MMC_SET_RELATIVE_ADDR; + mmcio->cmd.arg = MMC_PROPOSED_RCA << 16; + mmcio->cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; + mmcio->stop.opcode = 0; + break; case PROBE_SELECT_CARD: init_standard_ccb(start_ccb, XPT_MMC_IO); mmcio->cmd.opcode = MMC_SELECT_CARD; @@ -985,7 +993,10 @@ mmcprobe_done(struct cam_periph *periph, union ccb *do mmcp->card_cid[1], mmcp->card_cid[2], mmcp->card_cid[3])); -PROBE_SET_ACTION(softc, PROBE_SEND_RELATIVE_ADDR); + if (mmcp->card_features & CARD_FEATURE_MMC) + PROBE_SET_ACTION(softc, PROBE_MMC_SET_RELATIVE_ADDR); + else + PROBE_SET_ACTION(softc, PROBE_SEND_RELATIVE_ADDR); break; } case PROBE_SEND_RELATIVE_ADDR: { @@ -1010,6 +1021,18 @@ mmcprobe_done(struct cam_periph *periph, union ccb *do PROBE_SET_ACTION(softc, PROBE_SELECT_CARD); break; } + case PROBE_MMC_SET_RELATIVE_ADDR: + mmcio = &done_ccb->mmcio; + err = mmcio->cmd.error; + if (err != MMC_ERR_NONE) { + CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_PROBE, + ("PROBE_MMC_SET_RELATIVE_ADDR: error %d\n", err)); + PROBE_SET_ACTION(softc, PROBE_INVALID); + break; + } + path->device->mmc_ident_data.card_rca = MMC_PROPOSED_RCA; + PROBE_SET_ACTION(softc, PROBE_GET_CSD); + break; case PROBE_GET_CSD: { mmcio = &done_ccb->mmcio; err = mmcio->cmd.error; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r335367 - head/sys/cam/mmc
Author: kibab Date: Tue Jun 19 11:28:50 2018 New Revision: 335367 URL: https://svnweb.freebsd.org/changeset/base/335367 Log: Don't try to turn power down MMC bus if it is already down Regulator framework doens't like turning off already turned off regulators, so we get panic on AllWinner boards. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15890 Modified: head/sys/cam/mmc/mmc_xpt.c Modified: head/sys/cam/mmc/mmc_xpt.c == --- head/sys/cam/mmc/mmc_xpt.c Tue Jun 19 11:25:40 2018(r335366) +++ head/sys/cam/mmc/mmc_xpt.c Tue Jun 19 11:28:50 2018(r335367) @@ -574,14 +574,16 @@ mmcprobe_start(struct cam_periph *periph, union ccb *s /* FALLTHROUGH */ case PROBE_IDENTIFY: xpt_path_inq(&start_ccb->cpi, periph->path); - CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_PROBE, ("Start with PROBE_RESET\n")); - init_standard_ccb(start_ccb, XPT_SET_TRAN_SETTINGS); - cts->ios.power_mode = power_off; - cts->ios_valid = MMC_PM; + init_standard_ccb(start_ccb, XPT_GET_TRAN_SETTINGS); xpt_action(start_ccb); - mtx_sleep(periph, p_mtx, 0, "mmcios", 100); - + if (cts->ios.power_mode != power_off) { + init_standard_ccb(start_ccb, XPT_SET_TRAN_SETTINGS); + cts->ios.power_mode = power_off; + cts->ios_valid = MMC_PM; + xpt_action(start_ccb); + mtx_sleep(periph, p_mtx, 0, "mmcios", 100); + } /* mmc_power_up */ /* Get the host OCR */ init_standard_ccb(start_ccb, XPT_GET_TRAN_SETTINGS); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r335366 - head/sys/cam/mmc
Author: kibab Date: Tue Jun 19 11:25:40 2018 New Revision: 335366 URL: https://svnweb.freebsd.org/changeset/base/335366 Log: Correctly define rawscr so initializing it doesn't result in overwriting memory. We need 8 bytes of storage for rawscr. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15889 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Tue Jun 19 11:23:48 2018(r335365) +++ head/sys/cam/mmc/mmc_da.c Tue Jun 19 11:25:40 2018(r335366) @@ -818,6 +818,7 @@ mmc_app_get_scr(struct cam_periph *periph, union ccb * struct mmc_data d; memset(&cmd, 0, sizeof(cmd)); + memset(&d, 0, sizeof(d)); memset(rawscr, 0, 8); cmd.opcode = ACMD_SEND_SCR; @@ -1296,13 +1297,13 @@ sdda_start_init(void *context, union ccb *start_ccb) /* Find out if the card supports High speed timing */ if (mmcp->card_features & CARD_FEATURE_SD20) { /* Get and decode SCR */ - uint32_t rawscr; + uint32_t rawscr[2]; uint8_t res[64]; - if (mmc_app_get_scr(periph, start_ccb, &rawscr)) { + if (mmc_app_get_scr(periph, start_ccb, rawscr)) { CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Cannot get SCR\n")); goto finish_hs_tests; } - mmc_app_decode_scr(&rawscr, &softc->scr); + mmc_app_decode_scr(rawscr, &softc->scr); if ((softc->scr.sda_vsn >= 1) && (softc->csd.ccc & (1<<10))) { mmc_sd_switch(periph, start_ccb, SD_SWITCH_MODE_CHECK, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r335365 - head/sys/cam/mmc
Author: kibab Date: Tue Jun 19 11:23:48 2018 New Revision: 335365 URL: https://svnweb.freebsd.org/changeset/base/335365 Log: Set MMC_DATA_MULTI flag when doing multi-block transfers Lower layers (MMC / SDHCI controller drivers) may make certain decisions based on the presence of this flag. The fact that sdhci.c doesn't look at this flag is another problem that should be fixed separately. Found when adding MMCCAM support to AllWinner MMC controller driver where the presence of this flag actually matters. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15888 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Tue Jun 19 11:20:28 2018(r335364) +++ head/sys/cam/mmc/mmc_da.c Tue Jun 19 11:23:48 2018(r335365) @@ -1778,6 +1778,7 @@ sddastart(struct cam_periph *periph, union ccb *start_ mmcio->cmd.data->flags = (bp->bio_cmd == BIO_READ ? MMC_DATA_READ : MMC_DATA_WRITE); /* Direct h/w to issue CMD12 upon completion */ if (count > 1) { + mmcio->cmd.data->flags |= MMC_DATA_MULTI; mmcio->stop.opcode = MMC_STOP_TRANSMISSION; mmcio->stop.flags = MMC_RSP_R1B | MMC_CMD_AC; mmcio->stop.arg = 0; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r334651 - head/sys/cam/mmc
Author: kibab Date: Tue Jun 5 11:03:24 2018 New Revision: 334651 URL: https://svnweb.freebsd.org/changeset/base/334651 Log: Enable high-speed on the card before increasing frequency on the controller Increasing operating frequency without telling card to switch to high-speed mode first upsets some cards and generates CRC errors. While here, deselect / reselect cards after CMD6 and SCR fetch, as in original code. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15568 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Tue Jun 5 09:52:38 2018(r334650) +++ head/sys/cam/mmc/mmc_da.c Tue Jun 5 11:03:24 2018(r334651) @@ -171,7 +171,7 @@ static void sdda_start_init_task(void *context, int pe static void sdda_process_mmc_partitions(struct cam_periph *periph, union ccb *start_ccb); static uint32_t sdda_get_host_caps(struct cam_periph *periph, union ccb *ccb); static void sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb, u_int part); - +static int mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca); static inline uint32_t mmc_get_sector_size(struct cam_periph *periph) {return MMC_SECTOR_SIZE;} /* TODO: actually issue GET_TRAN_SETTINGS to get R/O status */ @@ -901,6 +901,38 @@ mmc_switch_fill_mmcio(union ccb *ccb, } static int +mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca) +{ + int flags; + + flags = (rca ? MMC_RSP_R1B : MMC_RSP_NONE) | MMC_CMD_AC; + cam_fill_mmcio(&ccb->mmcio, + /*retries*/ 0, + /*cbfcnp*/ NULL, + /*flags*/ CAM_DIR_IN, + /*mmc_opcode*/ MMC_SELECT_CARD, + /*mmc_arg*/ rca << 16, + /*mmc_flags*/ flags, + /*mmc_data*/ NULL, + /*timeout*/ 0); + + cam_periph_runccb(ccb, sddaerror, CAM_FLAG_NONE, /*sense_flags*/0, NULL); + + if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)) { + if (ccb->mmcio.cmd.error != 0) { + CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, + ("%s: MMC_SELECT command failed", __func__)); + return EIO; + } + return 0; /* Normal return */ + } else { + CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_PERIPH, + ("%s: CAM request failed\n", __func__)); + return EIO; + } +} + +static int mmc_switch(struct cam_periph *periph, union ccb *ccb, uint8_t set, uint8_t index, uint8_t value, u_int timeout) { @@ -953,18 +985,24 @@ mmc_sd_switch(struct cam_periph *periph, union ccb *cc uint8_t *res) { struct mmc_data mmc_d; + uint32_t arg; memset(res, 0, 64); mmc_d.len = 64; mmc_d.data = res; mmc_d.flags = MMC_DATA_READ; + arg = mode << 31; /* 0 - check, 1 - set */ + arg |= 0x00FF; + arg &= ~(0xF << (grp * 4)); + arg |= value << (grp * 4); + cam_fill_mmcio(&ccb->mmcio, /*retries*/ 0, /*cbfcnp*/ NULL, /*flags*/ CAM_DIR_IN, /*mmc_opcode*/ SD_SWITCH_FUNC, - /*mmc_arg*/ mode << 31, + /*mmc_arg*/ arg, /*mmc_flags*/ MMC_RSP_R1 | MMC_CMD_ADTC, /*mmc_data*/ &mmc_d, /*timeout*/ 0); @@ -1273,6 +1311,19 @@ sdda_start_init(void *context, union ccb *start_ccb) CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Card supports HS\n")); softc->card_f_max = SD_HS_MAX; } + + /* +* We deselect then reselect the card here. Some cards +* become unselected and timeout with the above two +* commands, although the state tables / diagrams in the +* standard suggest they go back to the transfer state. +* Other cards don't become deselected, and if we +* attempt to blindly re-select them, we get timeout +* errors from some controllers. So we deselect then +* reselect to handle all situations. +*/ + mmc_select_card(periph, start_ccb, 0); + mmc_select_card(periph, start_ccb, get_rca(periph)); } else { CA
svn commit: r334218 - head/sys/dev/mmc/host
Author: kibab Date: Fri May 25 19:00:28 2018 New Revision: 334218 URL: https://svnweb.freebsd.org/changeset/base/334218 Log: Fix building GENERIC-MMCCAM on arm64 Since GENERIC includes quite a few drivers now, all MMC drivers should have appropriate MMCCAM-related ifdefs and include opt_mmccam.h so that those ifdefs are actually processed correctly. Reviewed by: manu Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15569 Modified: head/sys/dev/mmc/host/dwmmc_rockchip.c Modified: head/sys/dev/mmc/host/dwmmc_rockchip.c == --- head/sys/dev/mmc/host/dwmmc_rockchip.c Fri May 25 18:57:41 2018 (r334217) +++ head/sys/dev/mmc/host/dwmmc_rockchip.c Fri May 25 19:00:28 2018 (r334218) @@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$"); #include +#include "opt_mmccam.h" + enum RKTYPE { RK2928 = 1, RK3328, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r334065 - head/sys/cam/mmc
Author: kibab Date: Tue May 22 22:16:49 2018 New Revision: 334065 URL: https://svnweb.freebsd.org/changeset/base/334065 Log: Implement initial MMC partitions support for MMCCAM. For MMC cards, add partitions found on the card as separate disk(9) devices. Don't do anything with RPMB partition for now. Lots of code is copied almost 1:1 from the mmcsd.c in the old stack, credits Marius Strobl (mar...@freebsd.org) Reviewed by: marius Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D12762 Modified: head/sys/cam/mmc/mmc_da.c Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Tue May 22 20:50:19 2018(r334064) +++ head/sys/cam/mmc/mmc_da.c Tue May 22 22:16:49 2018(r334065) @@ -88,35 +88,66 @@ typedef enum { } sdda_flags; typedef enum { -SDDA_STATE_INIT, -SDDA_STATE_INVALID, -SDDA_STATE_NORMAL + SDDA_STATE_INIT, + SDDA_STATE_INVALID, + SDDA_STATE_NORMAL, + SDDA_STATE_PART_SWITCH, } sdda_state; +#defineSDDA_FMT_BOOT "sdda%dboot" +#defineSDDA_FMT_GP "sdda%dgp" +#defineSDDA_FMT_RPMB "sdda%drpmb" +#defineSDDA_LABEL_ENH "enh" + +#defineSDDA_PART_NAMELEN (16 + 1) + +struct sdda_softc; + +struct sdda_part { + struct disk *disk; + struct bio_queue_head bio_queue; + sdda_flags flags; + struct sdda_softc *sc; + u_int cnt; + u_int type; + bool ro; + char name[SDDA_PART_NAMELEN]; +}; + struct sdda_softc { - struct bio_queue_head bio_queue; int outstanding_cmds; /* Number of active commands */ int refcount; /* Active xpt_action() calls */ sdda_state state; - sdda_flags flags; struct mmc_data *mmcdata; + struct cam_periph *periph; // sdda_quirks quirks; struct task start_init_task; - struct disk *disk; -uint32_t raw_csd[4]; + uint32_t raw_csd[4]; uint8_t raw_ext_csd[512]; /* MMC only? */ -struct mmc_csd csd; -struct mmc_cid cid; + struct mmc_csd csd; + struct mmc_cid cid; struct mmc_scr scr; -/* Calculated from CSD */ -uint64_t sector_count; -uint64_t mediasize; + /* Calculated from CSD */ + uint64_t sector_count; + uint64_t mediasize; -/* Calculated from CID */ + /* Calculated from CID */ char card_id_string[64];/* Formatted CID info (serial, MFG, etc) */ char card_sn_string[16];/* Formatted serial # for disk->d_ident */ /* Determined from CSD + is highspeed card*/ uint32_t card_f_max; + + /* Generic switch timeout */ + uint32_t cmd6_time; + /* MMC partitions support */ + struct sdda_part *part[MMC_PART_MAX]; + uint8_t part_curr; /* Partition currently switched to */ + uint8_t part_requested; /* What partition we're currently switching to */ + uint32_t part_time; /* Partition switch timeout [us] */ + off_t enh_base; /* Enhanced user data area slice base ... */ + off_t enh_size; /* ... and size [bytes] */ + int log_count; + struct timeval log_time; }; #define ccb_bp ppriv_ptr1 @@ -135,10 +166,27 @@ static int sddaerror(union ccb *ccb, u_int32_t cam_f u_int32_t sense_flags); static uint16_t get_rca(struct cam_periph *periph); -static cam_status sdda_hook_into_geom(struct cam_periph *periph); static void sdda_start_init(void *context, union ccb *start_ccb); static void sdda_start_init_task(void *context, int pending); +static void sdda_process_mmc_partitions(struct cam_periph *periph, union ccb *start_ccb); +static uint32_t sdda_get_host_caps(struct cam_periph *periph, union ccb *ccb); +static void sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb, u_int part); +static inline uint32_t mmc_get_sector_size(struct cam_periph *periph) {return MMC_SECTOR_SIZE;} + +/* TODO: actually issue GET_TRAN_SETTINGS to get R/O status */ +static inline bool sdda_get_read_only(struct cam_periph *periph, union ccb *start_ccb) +{ + + return (false); +} + +static uint32_t mmc_get_spec_vers(struct cam_periph *periph); +static uint64_t mmc_get_media_size(struct cam_periph *periph); +static uint32_t mmc_get_cmd6_timeout(struct cam_periph *periph); +static void sdda_add_part(struct cam_periph *periph, u_int type, +const char *name, u_int cnt, off_t media_size, bool ro); + static struct periph_driver sddadriver = { sddainit, "sdda", @@ -364,11 +412,14 @@ mmc_format_card_id_string(struct sdda_softc *sc, struc static int sddaopen(struct disk *dp) { + struct sdda_part *part; struct cam_periph *periph; struct sdda_softc *softc;
svn commit: r334059 - head/sys/cam/mmc
Author: kibab Date: Tue May 22 16:32:34 2018 New Revision: 334059 URL: https://svnweb.freebsd.org/changeset/base/334059 Log: Fix MMCCAM scanning for new cards. r326645 used an incorrect argument for xpt_path_inq(). Reviewed by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D15521 Modified: head/sys/cam/mmc/mmc_xpt.c Modified: head/sys/cam/mmc/mmc_xpt.c == --- head/sys/cam/mmc/mmc_xpt.c Tue May 22 16:23:14 2018(r334058) +++ head/sys/cam/mmc/mmc_xpt.c Tue May 22 16:32:34 2018(r334059) @@ -241,7 +241,7 @@ mmc_scan_lun(struct cam_periph *periph, struct cam_pat CAM_DEBUG(path, CAM_DEBUG_TRACE, ("mmc_scan_lun\n")); - xpt_path_inq(&cpi, periph->path); + xpt_path_inq(&cpi, path); if (cpi.ccb_h.status != CAM_REQ_CMP) { if (request_ccb != NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r333425 - in head/sys: cddl/compat/opensolaris/sys cddl/contrib/opensolaris/uts/common/fs/zfs compat/cloudabi compat/linux compat/linuxkpi/common/include/linux dev/filemon dev/hwpmc fs
Hi Matt, seems this commit has broken at least BeagleBone Black booting process. On all revisions after it the kernel panics with this message: http://dl.bakulin.de/bbb_panic.txt My suspicion is that there are quite a few new SYSINIT objects that are created on startup, and as a result some kind of memory reservation gets exhausted. I don't have immediate idea how to debug this further; just can confirm that patching out this change allows the board to boot again. On Wed, May 9, 2018 at 8:47 PM Matt Macy wrote: > Author: mmacy > Date: Wed May 9 18:47:24 2018 > New Revision: 333425 > URL: https://svnweb.freebsd.org/changeset/base/333425 > > Log: > Eliminate the overhead of gratuitous repeated reinitialization of > cap_rights > > - Add macros to allow preinitialization of cap_rights_t. > > - Convert most commonly used code paths to use preinitialized > cap_rights_t. > A 3.6% speedup in fstat was measured with this change. > > Reported by: mjg > Reviewed by: oshogbo > Approved by: sbruno > MFC after:1 month > > Modified: > head/sys/cddl/compat/opensolaris/sys/file.h > head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c > head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_onexit.c > head/sys/compat/cloudabi/cloudabi_file.c > head/sys/compat/linux/linux_event.c > head/sys/compat/linux/linux_file.c > head/sys/compat/linux/linux_ioctl.c > head/sys/compat/linux/linux_mmap.c > head/sys/compat/linux/linux_socket.c > head/sys/compat/linux/linux_stats.c > head/sys/compat/linuxkpi/common/include/linux/file.h > head/sys/dev/filemon/filemon.c > head/sys/dev/hwpmc/hwpmc_logging.c > head/sys/fs/fdescfs/fdesc_vnops.c > head/sys/fs/fuse/fuse_vfsops.c > head/sys/kern/kern_descrip.c > head/sys/kern/kern_event.c > head/sys/kern/kern_exec.c > head/sys/kern/kern_sendfile.c > head/sys/kern/kern_sig.c > head/sys/kern/subr_capability.c > head/sys/kern/sys_generic.c > head/sys/kern/sys_procdesc.c > head/sys/kern/uipc_mqueue.c > head/sys/kern/uipc_sem.c > head/sys/kern/uipc_syscalls.c > head/sys/kern/vfs_aio.c > head/sys/kern/vfs_syscalls.c > head/sys/netsmb/smb_dev.c > head/sys/sys/capsicum.h > > Modified: head/sys/cddl/compat/opensolaris/sys/file.h > > == > --- head/sys/cddl/compat/opensolaris/sys/file.h Wed May 9 18:41:04 2018 > (r333424) > +++ head/sys/cddl/compat/opensolaris/sys/file.h Wed May 9 18:47:24 2018 > (r333425) > @@ -52,10 +52,9 @@ static __inline void > releasef(int fd) > { > struct file *fp; > - cap_rights_t rights; > > /* No CAP_ rights required, as we're only releasing. */ > - if (fget(curthread, fd, cap_rights_init(&rights), &fp) == 0) { > + if (fget(curthread, fd, &cap_no_rights, &fp) == 0) { > fdrop(fp, curthread); > fdrop(fp, curthread); > } > > Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c > > == > --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c > Wed May 9 18:41:04 2018(r333424) > +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c > Wed May 9 18:47:24 2018(r333425) > @@ -4446,7 +4446,6 @@ zfs_ioc_recv(zfs_cmd_t *zc) > char *origin = NULL; > char *tosnap; > char tofs[ZFS_MAX_DATASET_NAME_LEN]; > - cap_rights_t rights; > boolean_t first_recvd_props = B_FALSE; > > if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || > @@ -4467,7 +4466,7 @@ zfs_ioc_recv(zfs_cmd_t *zc) > #ifdef illumos > fp = getf(fd); > #else > - fget_read(curthread, fd, cap_rights_init(&rights, CAP_PREAD), &fp); > + fget_read(curthread, fd, &cap_pread_rights, &fp); > #endif > if (fp == NULL) { > nvlist_free(props); > @@ -4744,13 +4743,11 @@ zfs_ioc_send(zfs_cmd_t *zc) > dsl_pool_rele(dp, FTAG); > } else { > file_t *fp; > - cap_rights_t rights; > > #ifdef illumos > fp = getf(zc->zc_cookie); > #else > - fget_write(curthread, zc->zc_cookie, > - cap_rights_init(&rights, CAP_WRITE), &fp); > + fget_write(curthread, zc->zc_cookie, &cap_write_rights, > &fp); > #endif > if (fp == NULL) > return (SET_ERROR(EBADF)); > @@ -5387,15 +5384,13 @@ static int > zfs_ioc_diff(zfs_cmd_t *zc) > { > file_t *fp; > - cap_rights_t rights; > offset_t off; > int error; > > #ifdef illumos > fp = getf(zc->zc_cookie); > #else > - fget_write(curthread, zc->zc_cookie, > - cap_rights_init(&rights, CAP_WRITE), &fp); > + fget_write(curthread, zc->zc_cookie, &cap_write_rights, &fp); > #endif > if (fp == NULL) >
Re: svn commit: r330696 - in head/libexec/tftpd: . tests
This broke build for at least ARM. Fix: diff --git a/libexec/tftpd/tests/functional.c b/libexec/tftpd/tests/functional.c index fea6870cac59..c467dfee3ba0 100644 --- a/libexec/tftpd/tests/functional.c +++ b/libexec/tftpd/tests/functional.c @@ -248,10 +248,10 @@ require_bufeq(const char *expected, ssize_t expected_len, const char *actual, ssize_t i; ATF_REQUIRE_EQ_MSG(expected_len, len, - "Expected %ld bytes but got %ld", expected_len, len); + "Expected %zd bytes but got %zd", expected_len, len); for (i = 0; i < len; i++) { ATF_REQUIRE_EQ_MSG(actual[i], expected[i], - "Expected %#hhx at position %ld; got %hhx instead", + "Expected %#hhx at position %zd; got %hhx instead", expected[i], i, actual[i]); } } On Sat, Mar 10, 2018 at 12:30 AM Alan Somers wrote: > Author: asomers > Date: Fri Mar 9 15:30:20 2018 > New Revision: 330696 > URL: https://svnweb.freebsd.org/changeset/base/330696 > > Log: > Add some functional tests for tftpd(8) > > tftpd(8) is difficult to test in isolation due to its relationship with > inetd. Create a test program that mimics the behavior of tftp(1) and > inetd(8) and verifies tftpd's response in several different scenarios. > > These test cases cover all of the basic TFTP protocol, but not the > optional > parts. > > PR: 157700 > PR: 225996 > PR: 226004 > PR: 226005 > MFC after:3 weeks > Differential Revision:https://reviews.freebsd.org/D14310 > > Added: > head/libexec/tftpd/tests/ > head/libexec/tftpd/tests/Makefile (contents, props changed) > head/libexec/tftpd/tests/functional.c (contents, props changed) > Modified: > head/libexec/tftpd/Makefile > > Modified: head/libexec/tftpd/Makefile > > == > --- head/libexec/tftpd/Makefile Fri Mar 9 14:45:47 2018(r330695) > +++ head/libexec/tftpd/Makefile Fri Mar 9 15:30:20 2018(r330696) > @@ -14,4 +14,7 @@ CFLAGS+= -DLIBWRAP > LIBADD=wrap > .endif > > +HAS_TESTS= > +SUBDIR.${MK_TESTS}+= tests > + > .include > > Added: head/libexec/tftpd/tests/Makefile > > == > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/libexec/tftpd/tests/Makefile Fri Mar 9 15:30:20 2018 > (r330696) > @@ -0,0 +1,14 @@ > +# $FreeBSD$ > + > +.include > + > +# Skip on GCC 4.2, because it lacks __COUNTER__ > +.if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40300 > +ATF_TESTS_C= functional > +TEST_METADATA.functional+= timeout=15 > +.endif > + > +LIBADD=util > +WARNS?=6 > + > +.include > > Added: head/libexec/tftpd/tests/functional.c > > == > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/libexec/tftpd/tests/functional.c Fri Mar 9 15:30:20 2018 > (r330696) > @@ -0,0 +1,1006 @@ > +/*- > + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD > + * > + * Copyright (c) 2018 Alan Somers. All rights reserved. > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + *notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + *notice, this list of conditions and the following disclaimer in the > + *documentation and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR > PURPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > CONSEQUENTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, > STRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY > WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > + > +#include > + > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > + > +static const uint16_t BASEPORT = 6969; > +static const char pidfile[] = "tftpd.pid"; > +static int protocol = PF_UNSPEC; > +static int s = -1; /* tftp cl
svn commit: r323966 - in head/sys: arm/broadcom/bcm2835 arm/ti dev/sdhci
Author: kibab Date: Sun Sep 24 09:05:35 2017 New Revision: 323966 URL: https://svnweb.freebsd.org/changeset/base/323966 Log: Rename sdhci_cam_start_slot() into sdhci_start_slot() This change allows to just call sdhci_start_slot() in SDHCI drivers and not to think about which stack handles the operation. As a side effect, this will also fix MMCCAM with sdhci_acpi driver. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D12471 Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c head/sys/arm/ti/ti_sdhci.c head/sys/dev/sdhci/fsl_sdhci.c head/sys/dev/sdhci/sdhci.c head/sys/dev/sdhci/sdhci.h head/sys/dev/sdhci/sdhci_pci.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c == --- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Sun Sep 24 05:04:06 2017(r323965) +++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Sun Sep 24 09:05:35 2017(r323966) @@ -255,11 +255,7 @@ bcm_sdhci_attach(device_t dev) bus_generic_probe(dev); bus_generic_attach(dev); -#ifdef MMCCAM - sdhci_cam_start_slot(&sc->sc_slot); -#else sdhci_start_slot(&sc->sc_slot); -#endif return (0); Modified: head/sys/arm/ti/ti_sdhci.c == --- head/sys/arm/ti/ti_sdhci.c Sun Sep 24 05:04:06 2017(r323965) +++ head/sys/arm/ti/ti_sdhci.c Sun Sep 24 09:05:35 2017(r323966) @@ -683,11 +683,7 @@ ti_sdhci_attach(device_t dev) bus_generic_probe(dev); bus_generic_attach(dev); -#ifdef MMCCAM - sdhci_cam_start_slot(&sc->slot); -#else sdhci_start_slot(&sc->slot); -#endif return (0); fail: Modified: head/sys/dev/sdhci/fsl_sdhci.c == --- head/sys/dev/sdhci/fsl_sdhci.c Sun Sep 24 05:04:06 2017 (r323965) +++ head/sys/dev/sdhci/fsl_sdhci.c Sun Sep 24 09:05:35 2017 (r323966) @@ -913,11 +913,7 @@ fsl_sdhci_attach(device_t dev) bus_generic_probe(dev); bus_generic_attach(dev); -#ifdef MMCCAM - sdhci_cam_start_slot(&sc->slot); -#else sdhci_start_slot(&sc->slot); -#endif return (0); Modified: head/sys/dev/sdhci/sdhci.c == --- head/sys/dev/sdhci/sdhci.c Sun Sep 24 05:04:06 2017(r323965) +++ head/sys/dev/sdhci/sdhci.c Sun Sep 24 09:05:35 2017(r323966) @@ -1051,12 +1051,14 @@ no_tuning: return (0); } +#ifndef MMCCAM void sdhci_start_slot(struct sdhci_slot *slot) { sdhci_card_task(slot, 0); } +#endif int sdhci_cleanup_slot(struct sdhci_slot *slot) @@ -2383,7 +2385,7 @@ sdhci_generic_write_ivar(device_t bus, device_t child, #ifdef MMCCAM void -sdhci_cam_start_slot(struct sdhci_slot *slot) +sdhci_start_slot(struct sdhci_slot *slot) { if ((slot->devq = cam_simq_alloc(1)) == NULL) { goto fail; Modified: head/sys/dev/sdhci/sdhci.h == --- head/sys/dev/sdhci/sdhci.h Sun Sep 24 05:04:06 2017(r323965) +++ head/sys/dev/sdhci/sdhci.h Sun Sep 24 09:05:35 2017(r323966) @@ -430,9 +430,4 @@ bool sdhci_generic_get_card_present(device_t brdev, st void sdhci_generic_set_uhs_timing(device_t brdev, struct sdhci_slot *slot); void sdhci_handle_card_present(struct sdhci_slot *slot, bool is_present); -#ifdef MMCCAM -/* CAM-related */ -void sdhci_cam_start_slot(struct sdhci_slot *slot); -#endif - #endif /* __SDHCI_H__ */ Modified: head/sys/dev/sdhci/sdhci_pci.c == --- head/sys/dev/sdhci/sdhci_pci.c Sun Sep 24 05:04:06 2017 (r323965) +++ head/sys/dev/sdhci/sdhci_pci.c Sun Sep 24 09:05:35 2017 (r323966) @@ -395,11 +395,7 @@ sdhci_pci_attach(device_t dev) pci_enable_busmaster(dev); /* Process cards detection. */ for (i = 0; i < sc->num_slots; i++) { -#ifdef MMCCAM - sdhci_cam_start_slot(&sc->slots[i]); -#else sdhci_start_slot(&sc->slots[i]); -#endif } return (0); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r323721 - head/sys/cam/mmc
Author: kibab Date: Mon Sep 18 20:17:08 2017 New Revision: 323721 URL: https://svnweb.freebsd.org/changeset/base/323721 Log: Add kern.features flag for MMCCAM kern.features.mmcam will be present and equal to 1 if the kernel has been compiled with option MMCCAM. This will help sdio-related userland tools to fail-fast if running on the kernel without MMCCAM enabled. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D12386 Modified: head/sys/cam/mmc/mmc_xpt.c Modified: head/sys/cam/mmc/mmc_xpt.c == --- head/sys/cam/mmc/mmc_xpt.c Mon Sep 18 20:09:17 2017(r323720) +++ head/sys/cam/mmc/mmc_xpt.c Mon Sep 18 20:17:08 2017(r323721) @@ -63,6 +63,8 @@ __FBSDID("$FreeBSD$"); #include /* for PRIu64 */ #include "opt_cam.h" +FEATURE(mmccam, "CAM-based MMC/SD/SDIO stack"); + static struct cam_ed * mmc_alloc_device(struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id); static void mmc_dev_async(u_int32_t async_code, struct cam_eb *bus, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r323717 - head/usr.bin/sdiotool
RDCAP_CMD14_SUPPORT 0x02 +#define SDIO_CCCR_BRCM_CARDCAP_CMD14_EXT 0x04 +#define SDIO_CCCR_BRCM_CARDCAP_CMD_NODEC 0x08 +#define SDIO_CCCR_BRCM_CARDCTRL0xf1 +#define SDIO_CCCR_BRCM_CARDCTRL_WLANRESET 0x02 +#define SDIO_CCCR_BRCM_SEPINT 0xf2 + +#define SDIO_SEPINT_MASK 0x01 +#define SDIO_SEPINT_OE0x02 +#define SDIO_SEPINT_ACT_HI0x04 + +/* function 1 miscellaneous registers */ + +/* sprom command and status */ +#define SBSDIO_SPROM_CS0x1 +/* sprom info register */ +#define SBSDIO_SPROM_INFO 0x10001 +/* sprom indirect access data byte 0 */ +#define SBSDIO_SPROM_DATA_LOW 0x10002 +/* sprom indirect access data byte 1 */ +#define SBSDIO_SPROM_DATA_HIGH 0x10003 +/* sprom indirect access addr byte 0 */ +#define SBSDIO_SPROM_ADDR_LOW 0x10004 +/* gpio select */ +#define SBSDIO_GPIO_SELECT 0x10005 +/* gpio output */ +#define SBSDIO_GPIO_OUT0x10006 +/* gpio enable */ +#define SBSDIO_GPIO_EN 0x10007 +/* rev < 7, watermark for sdio device */ +#define SBSDIO_WATERMARK 0x10008 +/* control busy signal generation */ +#define SBSDIO_DEVICE_CTL 0x10009 + +/* SB Address Window Low (b15) */ +#define SBSDIO_FUNC1_SBADDRLOW 0x1000A +/* SB Address Window Mid (b23:b16) */ +#define SBSDIO_FUNC1_SBADDRMID 0x1000B +/* SB Address Window High (b31:b24)*/ +#define SBSDIO_FUNC1_SBADDRHIGH0x1000C +/* Frame Control (frame term/abort) */ +#define SBSDIO_FUNC1_FRAMECTRL 0x1000D +/* ChipClockCSR (ALP/HT ctl/status) */ +#define SBSDIO_FUNC1_CHIPCLKCSR0x1000E +/* SdioPullUp (on cmd, d0-d2) */ +#define SBSDIO_FUNC1_SDIOPULLUP0x1000F +/* Write Frame Byte Count Low */ +#define SBSDIO_FUNC1_WFRAMEBCLO0x10019 +/* Write Frame Byte Count High */ +#define SBSDIO_FUNC1_WFRAMEBCHI0x1001A +/* Read Frame Byte Count Low */ +#define SBSDIO_FUNC1_RFRAMEBCLO0x1001B +/* Read Frame Byte Count High */ +#define SBSDIO_FUNC1_RFRAMEBCHI0x1001C +/* MesBusyCtl (rev 11) */ +#define SBSDIO_FUNC1_MESBUSYCTRL 0x1001D +/* Sdio Core Rev 12 */ +#define SBSDIO_FUNC1_WAKEUPCTRL0x1001E +#define SBSDIO_FUNC1_WCTRL_ALPWAIT_MASK0x1 +#define SBSDIO_FUNC1_WCTRL_ALPWAIT_SHIFT 0 +#define SBSDIO_FUNC1_WCTRL_HTWAIT_MASK 0x2 +#define SBSDIO_FUNC1_WCTRL_HTWAIT_SHIFT1 +#define SBSDIO_FUNC1_SLEEPCSR 0x1001F +#define SBSDIO_FUNC1_SLEEPCSR_KSO_MASK 0x1 +#define SBSDIO_FUNC1_SLEEPCSR_KSO_SHIFT0 +#define SBSDIO_FUNC1_SLEEPCSR_KSO_EN 1 +#define SBSDIO_FUNC1_SLEEPCSR_DEVON_MASK 0x2 +#define SBSDIO_FUNC1_SLEEPCSR_DEVON_SHIFT 1 + +#define SBSDIO_FUNC1_MISC_REG_START0x1 /* f1 misc register start */ +#define SBSDIO_FUNC1_MISC_REG_LIMIT0x1001F /* f1 misc register end */ + +/* function 1 OCP space */ + +/* sb offset addr is <= 15 bits, 32k */ +#define SBSDIO_SB_OFT_ADDR_MASK0x07FFF +#define SBSDIO_SB_OFT_ADDR_LIMIT 0x08000 +/* with b15, maps to 32-bit SB access */ +#define SBSDIO_SB_ACCESS_2_4B_FLAG 0x08000 + +/* valid bits in SBSDIO_FUNC1_SBADDRxxx regs */ + +#define SBSDIO_SBADDRLOW_MASK 0x80/* Valid bits in SBADDRLOW */ +#define SBSDIO_SBADDRMID_MASK 0xff/* Valid bits in SBADDRMID */ +#define SBSDIO_SBADDRHIGH_MASK 0xffU /* Valid bits in SBADDRHIGH */ +/* Address bits from SBADDR regs */ +#define SBSDIO_SBWINDOW_MASK 0x8000 + +#define SDIOH_READ 0 /* Read request */ +#define SDIOH_WRITE 1 /* Write request */ + +#define SDIOH_DATA_FIX 0 /* Fixed addressing */ +#define SDIOH_DATA_INC 1 /* Incremental addressing */ + +/* internal return code */ +#define SUCCESS0 +#define ERROR 1 + +/* Packet alignment for most efficient SDIO (can change based on platform) */ +#define BRCMF_SDALIGN (1 << 6) + +/** + * enum brcmf_sdiod_state - the state of the bus. + * + * @BRCMF_SDIOD_DOWN: Device can be accessed, no DPC. + * @BRCMF_SDIOD_DATA: Ready for data transfers, DPC enabled. + * @BRCMF_SDIOD_NOMEDIUM: No medium access to dongle possible. + */ +enum brcmf_sdiod_state { + BRCMF_SDIOD_DOWN, + BRCMF_SDIOD_DATA, + BRCMF_SDIOD_NOMEDIUM +}; Added: head/usr.bin/sdiotool/cam_sdio.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/sdiotool/cam_sdio.cMon Sep 18 20:01:01 2017 (r323717) @@ -0,0 +1,440 @@ +/*- + * Copyright (c) 2017 Ilya Bakulin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following condition
svn commit: r323619 - in head/sys: arm/broadcom/bcm2835 cam/mmc conf dev/mmc/host
Author: kibab Date: Fri Sep 15 19:47:44 2017 New Revision: 323619 URL: https://svnweb.freebsd.org/changeset/base/323619 Log: Miscellaneous fixes and improvements to MMCCAM stack * Demote the level of several debug messages to CAM_DEBUG_TRACE * Add detection for SDHC cards that can do 1.8V. No voltage switch sequence is issued yet; * Don't create a separate LUN for each SDIO function. We need just one to make pass(4) attach; * Remove obsolete mmc_sdio* files. SDIO functionality will be moved into the separate device that will manage a new sdio(4) bus; * Terminate probing if got no reply to CMD0; * Make bcm2835 SDHCI host controller driver compile with 'option MMCCAM'. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D12109 Deleted: head/sys/cam/mmc/mmc_sdio.c head/sys/cam/mmc/mmc_sdio.h Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c head/sys/cam/mmc/mmc.h head/sys/cam/mmc/mmc_da.c head/sys/cam/mmc/mmc_xpt.c head/sys/conf/files head/sys/dev/mmc/host/dwmmc.c Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c == --- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Fri Sep 15 19:17:30 2017(r323618) +++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c Fri Sep 15 19:47:44 2017(r323619) @@ -685,4 +685,6 @@ static driver_t bcm_sdhci_driver = { DRIVER_MODULE(sdhci_bcm, simplebus, bcm_sdhci_driver, bcm_sdhci_devclass, NULL, NULL); MODULE_DEPEND(sdhci_bcm, sdhci, 1, 1, 1); +#ifndef MMCCAM MMC_DECLARE_BRIDGE(sdhci_bcm); +#endif Modified: head/sys/cam/mmc/mmc.h == --- head/sys/cam/mmc/mmc.h Fri Sep 15 19:17:30 2017(r323618) +++ head/sys/cam/mmc/mmc.h Fri Sep 15 19:47:44 2017(r323619) @@ -87,6 +87,7 @@ struct mmc_params { #define CARD_FEATURE_SDIO 0x1 << 2 #define CARD_FEATURE_SD20 0x1 << 3 #define CARD_FEATURE_MMC0x1 << 4 +#define CARD_FEATURE_18V0x1 << 5 uint8_t sdio_func_count; } __packed; Modified: head/sys/cam/mmc/mmc_da.c == --- head/sys/cam/mmc/mmc_da.c Fri Sep 15 19:17:30 2017(r323618) +++ head/sys/cam/mmc/mmc_da.c Fri Sep 15 19:47:44 2017(r323619) @@ -378,8 +378,7 @@ sddaopen(struct disk *dp) return (error); } - CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, - ("sddaopen\n")); + CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddaopen\n")); softc = (struct sdda_softc *)periph->softc; softc->flags |= SDDA_FLAG_OPEN; @@ -403,8 +402,7 @@ sddaclose(struct disk *dp) cam_periph_lock(periph); - CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, - ("sddaclose\n")); + CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddaclose\n")); while (softc->refcount != 0) cam_periph_sleep(periph, &softc->refcount, PRIBIO, "sddaclose", 1); Modified: head/sys/cam/mmc/mmc_xpt.c == --- head/sys/cam/mmc/mmc_xpt.c Fri Sep 15 19:17:30 2017(r323618) +++ head/sys/cam/mmc/mmc_xpt.c Fri Sep 15 19:47:44 2017(r323619) @@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include /* for xpt_print below */ #include /* for PRIu64 */ @@ -162,6 +161,7 @@ typedef struct { union ccb saved_ccb; uint32_tflags; #define PROBE_FLAG_ACMD_SENT 0x1 /* CMD55 is sent, card expects ACMD */ + uint8_t acmd41_count; /* how many times ACMD41 has been issued */ struct cam_periph *periph; } mmcprobe_softc; @@ -219,6 +219,8 @@ mmc_dev_async(u_int32_t async_code, struct cam_eb *bus printf("Got AC_PATH_REGISTERED -- whatever...\n"); } else if (async_code == AC_PATH_DEREGISTERED ) { printf("Got AC_PATH_DEREGISTERED -- whatever...\n"); + } else if (async_code == AC_UNIT_ATTENTION) { + printf("Got interrupt generated by the card and ignored it\n"); } else panic("Unknown async code\n"); } @@ -299,9 +301,9 @@ mmc_scan_lun(struct cam_periph *periph, struct cam_pat static void mmc_action(union ccb *start_ccb) { - CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_INFO, + CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("mmc_action! func_code=%x, action %s\n", start_ccb->ccb_h.func_code, - xpt_action_name(start_ccb->ccb_h.func_code))); + xpt_action_name(start_ccb->ccb_h.func_code))); switch (start_ccb->ccb_h.func_code) { case XPT_SCAN_BUS: @@ -486,6 +488,7 @@ mmcprobe_register(struct cam_periph *periph, void *arg } softc->flags
svn commit: r323532 - in head/sys: amd64/conf arm/conf
Author: kibab Date: Wed Sep 13 10:56:02 2017 New Revision: 323532 URL: https://svnweb.freebsd.org/changeset/base/323532 Log: Add MMCCAM-enabled kernel config for IMX6, reduce debug noice in MMCCAM kernels CAM_DEBUG_TRACE results in way too much debug output than needed now. When debugging, it's always possible to turn on trace level using camcontrol. Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D12110 Added: head/sys/amd64/conf/GENERIC-MMCCAM - copied, changed from r323530, head/sys/amd64/conf/MMCCAM head/sys/arm/conf/IMX6-MMCCAM (contents, props changed) Deleted: head/sys/amd64/conf/MMCCAM Modified: head/sys/arm/conf/BEAGLEBONE-MMCCAM Copied and modified: head/sys/amd64/conf/GENERIC-MMCCAM (from r323530, head/sys/amd64/conf/MMCCAM) == --- head/sys/amd64/conf/MMCCAM Wed Sep 13 10:45:49 2017(r323530, copy source) +++ head/sys/amd64/conf/GENERIC-MMCCAM Wed Sep 13 10:56:02 2017 (r323532) @@ -4,7 +4,7 @@ include MINIMAL -ident MMCCAM +ident GENERIC-MMCCAM # Access GPT-formatted and labeled root volume options GEOM_PART_GPT @@ -28,9 +28,9 @@ devicevirtio_balloon # VirtIO Memory Balloon device device pass device scbus device da -device mmccam -optionsMMCCAM +options MMCCAM + # Add CAMDEBUG stuff -options CAMDEBUG -options CAM_DEBUG_FLAGS=(CAM_DEBUG_INFO|CAM_DEBUG_PROBE|CAM_DEBUG_PERIPH|CAM_DEBUG_TRACE) +options CAMDEBUG +options CAM_DEBUG_FLAGS=(CAM_DEBUG_INFO|CAM_DEBUG_PROBE|CAM_DEBUG_PERIPH) Modified: head/sys/arm/conf/BEAGLEBONE-MMCCAM == --- head/sys/arm/conf/BEAGLEBONE-MMCCAM Wed Sep 13 10:54:56 2017 (r323531) +++ head/sys/arm/conf/BEAGLEBONE-MMCCAM Wed Sep 13 10:56:02 2017 (r323532) @@ -6,16 +6,18 @@ # # $FreeBSD$ +#NO_UNIVERSE + includeBEAGLEBONE +optionsMMCCAM + # Add CAMDEBUG stuff optionsCAMDEBUG -options CAM_DEBUG_FLAGS=(CAM_DEBUG_INFO|CAM_DEBUG_PROBE|CAM_DEBUG_PERIPH|CAM_DEBUG_TRACE) +options CAM_DEBUG_FLAGS=(CAM_DEBUG_INFO|CAM_DEBUG_PROBE|CAM_DEBUG_PERIPH) # pass(4) device device pass -device mmccam -optionsMMCCAM nodevice mmc nodevice mmcsd Added: head/sys/arm/conf/IMX6-MMCCAM == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/conf/IMX6-MMCCAM Wed Sep 13 10:56:02 2017 (r323532) @@ -0,0 +1,23 @@ +# +# IMX6-MMCCAM +# +# Custom kernel for IMX6 plus MMCCAM as opposed to the prior MMC stack. It is +# present to keep it building in tree since it wouldn't work in LINT. +# +# $FreeBSD$ + +#NO_UNIVERSE + +includeIMX6 + +optionsMMCCAM + +# Add CAMDEBUG stuff +optionsCAMDEBUG +options CAM_DEBUG_FLAGS=(CAM_DEBUG_INFO|CAM_DEBUG_PROBE|CAM_DEBUG_PERIPH) + +# pass(4) device +device pass + +nodevice mmc +nodevice mmcsd ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r323458 - head/sys/arm64/conf
Author: kibab Date: Mon Sep 11 19:07:42 2017 New Revision: 323458 URL: https://svnweb.freebsd.org/changeset/base/323458 Log: Add MMCCAM-enabled kernel config for arm64 Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D12114 Added: head/sys/arm64/conf/GENERIC-MMCCAM (contents, props changed) Added: head/sys/arm64/conf/GENERIC-MMCCAM == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm64/conf/GENERIC-MMCCAM Mon Sep 11 19:07:42 2017 (r323458) @@ -0,0 +1,22 @@ +# +# GENERIC-MMCCAM +# +# Custom kernel for arm64 plus MMCCAM as opposed to the prior MMC stack. It is +# present to keep it building in tree since it wouldn't work in LINT. +# +# $FreeBSD$ + +#NO_UNIVERSE + +includeGENERIC + +# Add CAMDEBUG stuff +optionsCAMDEBUG +options CAM_DEBUG_FLAGS=(CAM_DEBUG_INFO|CAM_DEBUG_PROBE|CAM_DEBUG_PERIPH) + +# pass(4) device +device pass +optionsMMCCAM + +nodevice mmc +nodevice mmcsd ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r323398 - in head: share/misc usr.bin/calendar/calendars
Author: kibab Date: Sun Sep 10 20:33:23 2017 New Revision: 323398 URL: https://svnweb.freebsd.org/changeset/base/323398 Log: Add information about new src committer (kibab) Approved by: imp (mentor) Differential Revision:https://reviews.freebsd.org/D12304 Modified: head/share/misc/committers-src.dot head/usr.bin/calendar/calendars/calendar.freebsd Modified: head/share/misc/committers-src.dot == --- head/share/misc/committers-src.dot Sun Sep 10 20:17:31 2017 (r323397) +++ head/share/misc/committers-src.dot Sun Sep 10 20:33:23 2017 (r323398) @@ -222,6 +222,7 @@ kensmith [label="Ken Smith\nkensm...@freebsd.org\n2004 kevans [label="Kyle Evans\nkev...@freebsd.org\n2017/06/20"] kevlo [label="Kevin Lo\nke...@freebsd.org\n2006/07/23"] kib [label="Konstantin Belousov\n...@freebsd.org\n2006/06/03"] +kibab [label="Ilya Bakulin\nki...@freebsd.org\n2017/09/02"] kmacy [label="Kip Macy\nkm...@freebsd.org\n2005/06/01"] kp [label="Kristof Provost\n...@freebsd.org\n2015/03/22"] landonf [label="Landon Fuller\nland...@freebsd.org\n2016/05/31"] @@ -525,6 +526,7 @@ imp -> furuta imp -> joe imp -> jon imp -> keichii +imp -> kibab imp -> mb imp -> mr imp -> neel Modified: head/usr.bin/calendar/calendars/calendar.freebsd == --- head/usr.bin/calendar/calendars/calendar.freebsdSun Sep 10 20:17:31 2017(r323397) +++ head/usr.bin/calendar/calendars/calendar.freebsdSun Sep 10 20:33:23 2017(r323398) @@ -307,6 +307,7 @@ 08/19 Pav Lucistnik born in Kutna Hora, Czech Republic, 1980 08/20 Michael Heffner born in Cleona, Pennsylvania, United States, 1981 08/21 Jason A. Harmening born in Fort Wayne, Indiana, United States, 1981 +08/22 Ilya Bakulin born in Tbilisi, USSR, 1986 08/24 Mark Linimon born in Houston, Texas, United States, 1955 08/24 Alexander Botero-Lowry died in San Francisco, California, United States, 2012 08/25 Beech Rintoul born in Oakland, California, United States, 1952 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r259032 - in head: share/man/man4 sys/dev/usb sys/dev/usb/wlan
On 06.12.13, 16:26, Kevin Lo wrote: > Author: kevlo > Date: Fri Dec 6 15:26:39 2013 > New Revision: 259032 > URL: http://svnweb.freebsd.org/changeset/base/259032 > > Log: > Add support for the MediaTek/Ralink RT5572 chipset. > Committed over the TP-LINK TL-WDN3200 (RT5572) on amd64 with WPA. > > While here, add my copyright. > > Modified: > head/share/man/man4/run.4 > head/sys/dev/usb/usbdevs > head/sys/dev/usb/wlan/if_run.c > head/sys/dev/usb/wlan/if_runreg.h > head/sys/dev/usb/wlan/if_runvar.h This seems to break the build due to undeclared structure: ===> usb/run (all) --- if_run.o --- cc -O2 -pipe -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc -DHAVE_KERNEL_OPTION_HEADERS -include /stor0/jails/buildhost.kibab.com/usr/home/kibab/repos/freebsd-git/gs0/obj/i386.i386/stor0/jails/buildhost.kibab.com/usr/home/kibab/repos/freebsd-git/freebsd/sys/GS0/opt_global.h -I. -I@ -I@/contrib/altq -fno-common -g -I/stor0/jails/buildhost.kibab.com/usr/home/kibab/repos/freebsd-git/gs0/obj/i386.i386/stor0/jails/buildhost.kibab.com/usr/home/kibab/repos/freebsd-git/freebsd/sys/GS0 -mno-aes -mno-avx -mno-mmx -mno-sse -msoft-float -ffreestanding -fstack-protector -std=iso9899:1999 -Qunused-arguments -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -Wmissing-include-dirs -fdiagnostics-show-option -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -c /stor0/jails/buildhost.kibab.com/usr/home/kibab/repos/freebsd-git/freebsd/sys/modules/usb/run/../../../dev/usb/wlan/if_run.c /stor0/jails/buildhost.kibab.com/usr/home/kibab/repos/freebsd-git/freebsd/sys/modules/usb/run/../../../dev/usb/wlan/if_run.c:3233:6: error: invalid application of 'sizeof' to an incomplete type 'struct rt2870_txwi' sizeof(struct rt2870_txwi)), rt2860_rates[ridx].rate, qid); ^ @/dev/usb/usb_debug.h:41:21: note: expanded from macro 'DPRINTFN' __FUNCTION__ ,##__VA_ARGS__);\ ^ /stor0/jails/buildhost.kibab.com/usr/home/kibab/repos/freebsd-git/freebsd/sys/modules/usb/run/../../../dev/usb/wlan/if_run.c:3233:20: note: forward declaration of 'struct rt2870_txwi' sizeof(struct rt2870_txwi)), rt2860_rates[ridx].rate, qid); ^ @/dev/usb/usb_debug.h:41:21: note: expanded from macro 'DPRINTFN' __FUNCTION__ ,##__VA_ARGS__); \ ^ 1 error generated. *** [if_run.o] Error code 1 -- Regards, Ilya Bakulin ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"