Lines Matching refs:part

118 	struct mmcsd_part *part[MMC_PART_MAX];  member
182 static daddr_t mmcsd_delete(struct mmcsd_part *part, struct bio *bp);
185 static int mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data,
187 static int mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_ioc_cmd *mic,
190 static daddr_t mmcsd_rw(struct mmcsd_part *part, struct bio *bp);
195 u_int part);
485 struct mmcsd_part *part; in mmcsd_add_part() local
496 part = sc->part[type] = malloc(sizeof(*part), M_DEVBUF, in mmcsd_add_part()
498 part->sc = sc; in mmcsd_add_part()
499 part->cnt = cnt; in mmcsd_add_part()
500 part->type = type; in mmcsd_add_part()
501 part->ro = ro; in mmcsd_add_part()
502 snprintf(part->name, sizeof(part->name), name, device_get_unit(dev)); in mmcsd_add_part()
504 MMCSD_IOCTL_LOCK_INIT(part); in mmcsd_add_part()
521 args.mda_si_drv1 = part; in mmcsd_add_part()
522 if (make_dev_s(&args, &sc->rpmb_dev, "%s", part->name) != 0) { in mmcsd_add_part()
524 free(part, M_DEVBUF); in mmcsd_add_part()
528 MMCSD_DISK_LOCK_INIT(part); in mmcsd_add_part()
530 d = part->disk = disk_alloc(); in mmcsd_add_part()
536 d->d_name = part->name; in mmcsd_add_part()
537 d->d_drv1 = part; in mmcsd_add_part()
554 bioq_init(&part->bio_queue); in mmcsd_add_part()
556 part->running = 1; in mmcsd_add_part()
557 kproc_create(&mmcsd_task, part, &part->p, 0, 0, in mmcsd_add_part()
558 "%s%d: mmc/sd card", part->name, cnt); in mmcsd_add_part()
565 part->name, cnt, bytes, unit, mmc_get_card_id_string(dev), in mmcsd_add_part()
570 printf("%s: %ju%sB partition %d%s at %s\n", part->name, bytes, in mmcsd_add_part()
607 part->name, cnt, bytes, unit, type, enh ? in mmcsd_add_part()
612 "(%s)%s at %s\n", part->name, cnt, bytes, unit, in mmcsd_add_part()
624 struct mmcsd_part *part; in mmcsd_slicer() local
634 part = sc->part[EXT_CSD_PART_CONFIG_ACC_DEFAULT]; in mmcsd_slicer()
635 snprintf(name, sizeof(name), "%s%d", part->disk->d_name, in mmcsd_slicer()
636 part->disk->d_unit); in mmcsd_slicer()
651 struct mmcsd_part *part; in mmcsd_detach() local
655 part = sc->part[i]; in mmcsd_detach()
656 if (part != NULL) { in mmcsd_detach()
657 if (part->disk != NULL) { in mmcsd_detach()
658 MMCSD_DISK_LOCK(part); in mmcsd_detach()
659 part->suspend = 0; in mmcsd_detach()
660 if (part->running > 0) { in mmcsd_detach()
662 part->running = 0; in mmcsd_detach()
663 wakeup(part); in mmcsd_detach()
665 while (part->running != -1) in mmcsd_detach()
666 msleep(part, &part->disk_mtx, 0, in mmcsd_detach()
669 MMCSD_DISK_UNLOCK(part); in mmcsd_detach()
671 MMCSD_IOCTL_LOCK(part); in mmcsd_detach()
672 while (part->ioctl > 0) in mmcsd_detach()
673 msleep(part, &part->ioctl_mtx, 0, in mmcsd_detach()
675 part->ioctl = -1; in mmcsd_detach()
676 MMCSD_IOCTL_UNLOCK(part); in mmcsd_detach()
684 part = sc->part[i]; in mmcsd_detach()
685 if (part != NULL) { in mmcsd_detach()
686 if (part->disk != NULL) { in mmcsd_detach()
688 bioq_flush(&part->bio_queue, NULL, ENXIO); in mmcsd_detach()
690 disk_destroy(part->disk); in mmcsd_detach()
692 MMCSD_DISK_LOCK_DESTROY(part); in mmcsd_detach()
694 MMCSD_IOCTL_LOCK_DESTROY(part); in mmcsd_detach()
695 free(part, M_DEVBUF); in mmcsd_detach()
717 struct mmcsd_part *part; in mmcsd_suspend() local
721 part = sc->part[i]; in mmcsd_suspend()
722 if (part != NULL) { in mmcsd_suspend()
723 if (part->disk != NULL) { in mmcsd_suspend()
724 MMCSD_DISK_LOCK(part); in mmcsd_suspend()
725 part->suspend = 1; in mmcsd_suspend()
726 if (part->running > 0) { in mmcsd_suspend()
728 part->running = 0; in mmcsd_suspend()
729 wakeup(part); in mmcsd_suspend()
731 while (part->running != -1) in mmcsd_suspend()
732 msleep(part, &part->disk_mtx, 0, in mmcsd_suspend()
735 MMCSD_DISK_UNLOCK(part); in mmcsd_suspend()
737 MMCSD_IOCTL_LOCK(part); in mmcsd_suspend()
738 while (part->ioctl > 0) in mmcsd_suspend()
739 msleep(part, &part->ioctl_mtx, 0, in mmcsd_suspend()
741 part->ioctl = -1; in mmcsd_suspend()
742 MMCSD_IOCTL_UNLOCK(part); in mmcsd_suspend()
754 struct mmcsd_part *part; in mmcsd_resume() local
758 part = sc->part[i]; in mmcsd_resume()
759 if (part != NULL) { in mmcsd_resume()
760 if (part->disk != NULL) { in mmcsd_resume()
761 MMCSD_DISK_LOCK(part); in mmcsd_resume()
762 part->suspend = 0; in mmcsd_resume()
763 if (part->running <= 0) { in mmcsd_resume()
764 part->running = 1; in mmcsd_resume()
765 MMCSD_DISK_UNLOCK(part); in mmcsd_resume()
766 kproc_create(&mmcsd_task, part, in mmcsd_resume()
767 &part->p, 0, 0, "%s%d: mmc/sd card", in mmcsd_resume()
768 part->name, part->cnt); in mmcsd_resume()
770 MMCSD_DISK_UNLOCK(part); in mmcsd_resume()
772 MMCSD_IOCTL_LOCK(part); in mmcsd_resume()
773 part->ioctl = 0; in mmcsd_resume()
774 MMCSD_IOCTL_UNLOCK(part); in mmcsd_resume()
796 struct mmcsd_part *part; in mmcsd_strategy() local
798 part = bp->bio_disk->d_drv1; in mmcsd_strategy()
799 MMCSD_DISK_LOCK(part); in mmcsd_strategy()
800 if (part->running > 0 || part->suspend > 0) { in mmcsd_strategy()
801 bioq_disksort(&part->bio_queue, bp); in mmcsd_strategy()
802 MMCSD_DISK_UNLOCK(part); in mmcsd_strategy()
803 wakeup(part); in mmcsd_strategy()
805 MMCSD_DISK_UNLOCK(part); in mmcsd_strategy()
827 mmcsd_ioctl(struct mmcsd_part *part, u_long cmd, void *data, int fflag, in mmcsd_ioctl() argument
846 err = mmcsd_ioctl_cmd(part, mic, fflag); in mmcsd_ioctl()
860 err = mmcsd_ioctl_cmd(part, &mic[i], fflag); in mmcsd_ioctl()
874 mmcsd_ioctl_cmd(struct mmcsd_part *part, struct mmc_ioc_cmd *mic, int fflag) in mmcsd_ioctl_cmd() argument
889 if (part->ro == TRUE && mic->write_flag != 0) in mmcsd_ioctl_cmd()
899 MMCSD_IOCTL_LOCK(part); in mmcsd_ioctl_cmd()
900 while (part->ioctl != 0) { in mmcsd_ioctl_cmd()
901 if (part->ioctl < 0) { in mmcsd_ioctl_cmd()
902 MMCSD_IOCTL_UNLOCK(part); in mmcsd_ioctl_cmd()
905 msleep(part, &part->ioctl_mtx, 0, "mmcsd IOCTL", 0); in mmcsd_ioctl_cmd()
907 part->ioctl = 1; in mmcsd_ioctl_cmd()
908 MMCSD_IOCTL_UNLOCK(part); in mmcsd_ioctl_cmd()
935 sc = part->sc; in mmcsd_ioctl_cmd()
966 EXT_CSD_PART_CONFIG_ACC_MASK) != part->type) { in mmcsd_ioctl_cmd()
974 err = mmcsd_switch_part(mmcbus, dev, rca, part->type); in mmcsd_ioctl_cmd()
977 if (part->type == EXT_CSD_PART_CONFIG_ACC_RPMB) { in mmcsd_ioctl_cmd()
989 if (part->type == EXT_CSD_PART_CONFIG_ACC_RPMB) { in mmcsd_ioctl_cmd()
1016 if (part->type == EXT_CSD_PART_CONFIG_ACC_RPMB) { in mmcsd_ioctl_cmd()
1060 MMCSD_IOCTL_LOCK(part); in mmcsd_ioctl_cmd()
1061 part->ioctl = 0; in mmcsd_ioctl_cmd()
1062 MMCSD_IOCTL_UNLOCK(part); in mmcsd_ioctl_cmd()
1063 wakeup(part); in mmcsd_ioctl_cmd()
1072 struct mmcsd_part *part; in mmcsd_getattr() local
1078 part = bp->bio_disk->d_drv1; in mmcsd_getattr()
1079 dev = part->sc->dev; in mmcsd_getattr()
1107 mmcsd_switch_part(device_t bus, device_t dev, uint16_t rca, u_int part) in mmcsd_switch_part() argument
1128 if (part == EXT_CSD_PART_CONFIG_ACC_RPMB) in mmcsd_switch_part()
1131 if (sc->part_curr == part) in mmcsd_switch_part()
1135 ~EXT_CSD_PART_CONFIG_ACC_MASK) | part; in mmcsd_switch_part()
1140 if (part == EXT_CSD_PART_CONFIG_ACC_RPMB) in mmcsd_switch_part()
1148 sc->part_curr = part; in mmcsd_switch_part()
1162 mmcsd_rw(struct mmcsd_part *part, struct bio *bp) in mmcsd_rw() argument
1174 sc = part->sc; in mmcsd_rw()
1179 sz = part->disk->d_sectorsize; in mmcsd_rw()
1237 mmcsd_delete(struct mmcsd_part *part, struct bio *bp) in mmcsd_delete() argument
1248 sc = part->sc; in mmcsd_delete()
1253 sz = part->disk->d_sectorsize; in mmcsd_delete()
1261 if (block > part->eblock && block <= part->eend) in mmcsd_delete()
1262 block = part->eblock; in mmcsd_delete()
1263 if (end >= part->eblock && end < part->eend) in mmcsd_delete()
1264 end = part->eend; in mmcsd_delete()
1276 part->eblock = block; in mmcsd_delete()
1277 part->eend = end; in mmcsd_delete()
1357 if (bp->bio_pblkno >= part->eblock || block == start) { in mmcsd_delete()
1358 part->eblock = stop; /* Predict next forward. */ in mmcsd_delete()
1359 part->eend = end; in mmcsd_delete()
1361 part->eblock = block; /* Predict next backward. */ in mmcsd_delete()
1362 part->eend = start; in mmcsd_delete()
1378 struct mmcsd_part *part; in mmcsd_dump() local
1383 part = disk->d_drv1; in mmcsd_dump()
1384 sc = part->sc; in mmcsd_dump()
1405 err = mmcsd_switch_part(mmcbus, dev, sc->rca, part->type); in mmcsd_dump()
1412 block = mmcsd_rw(part, &bp); in mmcsd_dump()
1421 struct mmcsd_part *part; in mmcsd_task() local
1427 part = arg; in mmcsd_task()
1428 sc = part->sc; in mmcsd_task()
1434 MMCSD_DISK_LOCK(part); in mmcsd_task()
1436 if (part->running == 0) in mmcsd_task()
1438 bp = bioq_takefirst(&part->bio_queue); in mmcsd_task()
1440 msleep(part, &part->disk_mtx, PRIBIO, in mmcsd_task()
1443 MMCSD_DISK_UNLOCK(part); in mmcsd_task()
1452 if (bp->bio_cmd != BIO_READ && part->ro) { in mmcsd_task()
1460 sz = part->disk->d_sectorsize; in mmcsd_task()
1463 err = mmcsd_switch_part(mmcbus, dev, sc->rca, part->type); in mmcsd_task()
1472 if (block < part->eend && end > part->eblock) in mmcsd_task()
1473 part->eblock = part->eend = 0; in mmcsd_task()
1474 block = mmcsd_rw(part, bp); in mmcsd_task()
1476 block = mmcsd_delete(part, bp); in mmcsd_task()
1491 part->running = -1; in mmcsd_task()
1492 MMCSD_DISK_UNLOCK(part); in mmcsd_task()
1493 wakeup(part); in mmcsd_task()