Lines Matching refs:host
229 struct carm_host *host; member
435 struct carm_host *host; in carm_from_dev() local
453 host = port->host; in carm_from_dev()
454 if (unlikely(host->magic != CARM_MAGIC_HOST)) { in carm_from_dev()
462 return host; in carm_from_dev()
470 struct carm_host *host; in carm_bdev_ioctl() local
472 host = carm_from_dev(ino->i_rdev, &port); in carm_bdev_ioctl()
473 if (!host) in carm_bdev_ioctl()
496 geom.start = host->gendisk_hd[MINOR(ino->i_rdev)].start_sect; in carm_bdev_ioctl()
518 geom.start = host->gendisk_hd[MINOR(ino->i_rdev)].start_sect; in carm_bdev_ioctl()
572 static inline void *carm_ref_msg(struct carm_host *host, in carm_ref_msg() argument
575 return host->msg_base + (msg_idx * CARM_MSG_SIZE); in carm_ref_msg()
578 static inline dma_addr_t carm_ref_msg_dma(struct carm_host *host, in carm_ref_msg_dma() argument
581 return host->msg_dma + (msg_idx * CARM_MSG_SIZE); in carm_ref_msg_dma()
584 static int carm_send_msg(struct carm_host *host, in carm_send_msg() argument
587 void *mmio = host->mmio; in carm_send_msg()
588 u32 msg = (u32) carm_ref_msg_dma(host, crq->tag); in carm_send_msg()
613 static struct carm_request *carm_get_request(struct carm_host *host) in carm_get_request() argument
618 if (host->hw_sg_used >= (CARM_MAX_HOST_SG - CARM_MAX_REQ_SG)) in carm_get_request()
622 if ((host->msg_alloc & (1ULL << i)) == 0) { in carm_get_request()
623 struct carm_request *crq = &host->req[i]; in carm_get_request()
627 host->msg_alloc |= (1ULL << i); in carm_get_request()
628 host->n_msgs++; in carm_get_request()
630 assert(host->n_msgs <= CARM_MAX_REQ); in carm_get_request()
638 static int carm_put_request(struct carm_host *host, struct carm_request *crq) in carm_put_request() argument
642 if (unlikely((host->msg_alloc & (1ULL << crq->tag)) == 0)) in carm_put_request()
645 assert(host->hw_sg_used >= crq->n_elem); in carm_put_request()
647 host->msg_alloc &= ~(1ULL << crq->tag); in carm_put_request()
648 host->hw_sg_used -= crq->n_elem; in carm_put_request()
649 host->n_msgs--; in carm_put_request()
674 static struct carm_request *carm_get_special(struct carm_host *host) in carm_get_special() argument
682 crq = carm_get_request(host); in carm_get_special()
697 static int carm_array_info (struct carm_host *host, unsigned int array_idx) in carm_array_info() argument
707 crq = carm_get_special(host); in carm_array_info()
715 ioc = carm_ref_msg(host, idx); in carm_array_info()
716 msg_dma = carm_ref_msg_dma(host, idx); in carm_array_info()
733 assert(host->state == HST_DEV_SCAN_START || in carm_array_info()
734 host->state == HST_DEV_SCAN); in carm_array_info()
737 carm_insert_special(&host->oob_q, crq->rq, crq, 1); in carm_array_info()
743 host->state = HST_ERROR; in carm_array_info()
750 static int carm_send_special (struct carm_host *host, carm_sspc_t func) in carm_send_special() argument
758 crq = carm_get_special(host); in carm_send_special()
764 mem = carm_ref_msg(host, idx); in carm_send_special()
766 msg_size = func(host, idx, mem); in carm_send_special()
776 carm_insert_special(&host->oob_q, crq->rq, crq, 1); in carm_send_special()
781 static unsigned int carm_fill_sync_time(struct carm_host *host, in carm_fill_sync_time() argument
798 static unsigned int carm_fill_alloc_buf(struct carm_host *host, in carm_fill_alloc_buf() argument
809 ab->addr = cpu_to_le32(host->shm_dma + (PDC_SHM_SIZE >> 1)); in carm_fill_alloc_buf()
811 ab->evt_pool = cpu_to_le32(host->shm_dma + (16 * 1024)); in carm_fill_alloc_buf()
813 ab->rbuf_pool = cpu_to_le32(host->shm_dma); in carm_fill_alloc_buf()
815 ab->msg_pool = cpu_to_le32(host->shm_dma + RBUF_LEN); in carm_fill_alloc_buf()
817 ab->sg[0].start = cpu_to_le32(host->shm_dma + (PDC_SHM_SIZE >> 1)); in carm_fill_alloc_buf()
823 static unsigned int carm_fill_scan_channels(struct carm_host *host, in carm_fill_scan_channels() argument
827 u32 msg_data = (u32) (carm_ref_msg_dma(host, idx) + in carm_fill_scan_channels()
843 static unsigned int carm_fill_get_fw_ver(struct carm_host *host, in carm_fill_get_fw_ver() argument
847 u32 msg_data = (u32) (carm_ref_msg_dma(host, idx) + sizeof(*ioc)); in carm_fill_get_fw_ver()
859 static void carm_activate_disk(struct carm_host *host, in carm_activate_disk() argument
865 host->gendisk_hd[minor_start].nr_sects = port->capacity; in carm_activate_disk()
866 host->blk_sizes[minor_start] = port->capacity; in carm_activate_disk()
871 invalidate_device(MKDEV(host->major, i), 1); in carm_activate_disk()
872 host->gendisk.part[i].start_sect = 0; in carm_activate_disk()
873 host->gendisk.part[i].nr_sects = 0; in carm_activate_disk()
874 host->blk_block_sizes[i] = 512; in carm_activate_disk()
875 host->blk_sect_sizes[i] = 512; in carm_activate_disk()
878 grok_partitions(&host->gendisk, port->port_no, in carm_activate_disk()
885 struct carm_host *host; in carm_revalidate_disk() local
888 host = carm_from_dev(dev, &port); in carm_revalidate_disk()
889 if (!host) in carm_revalidate_disk()
892 carm_activate_disk(host, port); in carm_revalidate_disk()
910 static inline void carm_end_request_queued(struct carm_host *host, in carm_end_request_queued() argument
920 rc = carm_put_request(host, crq); in carm_end_request_queued()
924 static inline void carm_push_q (struct carm_host *host, request_queue_t *q) in carm_push_q() argument
926 unsigned int idx = host->wait_q_prod % CARM_MAX_WAIT_Q; in carm_push_q()
930 host->wait_q[idx] = q; in carm_push_q()
931 host->wait_q_prod++; in carm_push_q()
932 BUG_ON(host->wait_q_prod == host->wait_q_cons); /* overrun */ in carm_push_q()
935 static inline request_queue_t *carm_pop_q(struct carm_host *host) in carm_pop_q() argument
939 if (host->wait_q_prod == host->wait_q_cons) in carm_pop_q()
942 idx = host->wait_q_cons % CARM_MAX_WAIT_Q; in carm_pop_q()
943 host->wait_q_cons++; in carm_pop_q()
945 return host->wait_q[idx]; in carm_pop_q()
948 static inline void carm_round_robin(struct carm_host *host) in carm_round_robin() argument
950 request_queue_t *q = carm_pop_q(host); in carm_round_robin()
953 if (q == &host->oob_q) in carm_round_robin()
954 tasklet = &host->oob_tasklet; in carm_round_robin()
964 static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq, in carm_end_rq() argument
967 carm_end_request_queued(host, crq, is_ok); in carm_end_rq()
969 carm_round_robin(host); in carm_end_rq()
970 else if ((host->n_msgs <= CARM_MSG_LOW_WATER) && in carm_end_rq()
971 (host->hw_sg_used <= CARM_SG_LOW_WATER)) { in carm_end_rq()
972 carm_round_robin(host); in carm_end_rq()
1018 struct carm_host *host = q->queuedata; in carm_oob_rq_fn() local
1020 tasklet_schedule(&host->oob_tasklet); in carm_oob_rq_fn()
1032 struct carm_host *host = (void *) _data; in carm_oob_tasklet() local
1033 request_queue_t *q = &host->oob_q; in carm_oob_tasklet()
1061 rc = carm_send_msg(host, crq); in carm_oob_tasklet()
1063 carm_push_q(host, q); in carm_oob_tasklet()
1103 struct carm_host *host = port->host; in carm_rw_tasklet() local
1130 crq = carm_get_request(host); in carm_rw_tasklet()
1132 carm_push_q(host, q); in carm_rw_tasklet()
1148 carm_end_rq(host, crq, 0); in carm_rw_tasklet()
1153 n_elem = pci_map_sg(host->pdev, sg, n_elem, pci_dir); in carm_rw_tasklet()
1155 carm_end_rq(host, crq, 0); in carm_rw_tasklet()
1160 host->hw_sg_used += n_elem; in carm_rw_tasklet()
1167 msg = (struct carm_msg_rw *) carm_ref_msg(host, crq->tag); in carm_rw_tasklet()
1178 start_sector += host->gendisk_hd[MINOR(rq->rq_dev)].start_sect; in carm_rw_tasklet()
1206 rc = carm_send_msg(host, crq); in carm_rw_tasklet()
1208 carm_put_request(host, crq); in carm_rw_tasklet()
1209 carm_push_q(host, q); in carm_rw_tasklet()
1220 static void carm_handle_array_info(struct carm_host *host, in carm_handle_array_info() argument
1233 carm_end_rq(host, crq, is_ok); in carm_handle_array_info()
1240 cur_port = host->cur_scan_dev; in carm_handle_array_info()
1249 port = &host->port[cur_port]; in carm_handle_array_info()
1259 host->dev_active |= (1 << cur_port); in carm_handle_array_info()
1270 pci_name(host->pdev), port->port_no, port->capacity); in carm_handle_array_info()
1272 pci_name(host->pdev), port->port_no, port->name); in carm_handle_array_info()
1275 assert(host->state == HST_DEV_SCAN); in carm_handle_array_info()
1276 schedule_task(&host->fsm_task); in carm_handle_array_info()
1279 static void carm_handle_scan_chan(struct carm_host *host, in carm_handle_scan_chan() argument
1289 carm_end_rq(host, crq, is_ok); in carm_handle_scan_chan()
1299 host->dev_present |= (1 << i); in carm_handle_scan_chan()
1304 pci_name(host->pdev), dev_count); in carm_handle_scan_chan()
1307 assert(host->state == HST_PORT_SCAN); in carm_handle_scan_chan()
1308 host->state = new_state; in carm_handle_scan_chan()
1309 schedule_task(&host->fsm_task); in carm_handle_scan_chan()
1312 static void carm_handle_generic(struct carm_host *host, in carm_handle_generic() argument
1318 carm_end_rq(host, crq, is_ok); in carm_handle_generic()
1320 assert(host->state == cur_state); in carm_handle_generic()
1322 host->state = next_state; in carm_handle_generic()
1324 host->state = HST_ERROR; in carm_handle_generic()
1325 schedule_task(&host->fsm_task); in carm_handle_generic()
1328 static inline void carm_handle_rw(struct carm_host *host, in carm_handle_rw() argument
1340 pci_unmap_sg(host->pdev, &crq->sg[0], crq->n_elem, pci_dir); in carm_handle_rw()
1342 carm_end_rq(host, crq, is_ok); in carm_handle_rw()
1345 static inline void carm_handle_resp(struct carm_host *host, in carm_handle_resp() argument
1358 pci_name(host->pdev), handle); in carm_handle_resp()
1365 crq = &host->req[msg_idx]; in carm_handle_resp()
1370 carm_handle_rw(host, crq, is_ok); in carm_handle_resp()
1374 mem = carm_ref_msg(host, msg_idx); in carm_handle_resp()
1380 carm_handle_scan_chan(host, crq, mem, is_ok); in carm_handle_resp()
1392 carm_handle_generic(host, crq, is_ok, in carm_handle_resp()
1396 carm_handle_generic(host, crq, is_ok, in carm_handle_resp()
1403 host->fw_ver = le32_to_cpu(ver->version); in carm_handle_resp()
1404 host->flags |= (ver->features & FL_FW_VER_MASK); in carm_handle_resp()
1406 carm_handle_generic(host, crq, is_ok, in carm_handle_resp()
1420 carm_handle_array_info(host, crq, mem, is_ok); in carm_handle_resp()
1438 pci_name(host->pdev), crq->msg_type, crq->msg_subtype); in carm_handle_resp()
1439 carm_end_rq(host, crq, 0); in carm_handle_resp()
1442 static inline void carm_handle_responses(struct carm_host *host) in carm_handle_responses() argument
1444 void *mmio = host->mmio; in carm_handle_responses()
1445 struct carm_response *resp = (struct carm_response *) host->shm; in carm_handle_responses()
1447 unsigned int idx = host->resp_idx % RMSG_Q_LEN; in carm_handle_responses()
1461 carm_handle_resp(host, resp[idx].ret_handle, status); in carm_handle_responses()
1470 pci_name(host->pdev), (int) evt_type); in carm_handle_responses()
1479 host->resp_idx += work; in carm_handle_responses()
1484 struct carm_host *host = __host; in carm_interrupt() local
1490 if (!host) { in carm_interrupt()
1497 mmio = host->mmio; in carm_interrupt()
1510 if (unlikely(host->state == HST_INVALID)) { in carm_interrupt()
1517 carm_handle_responses(host); in carm_interrupt()
1528 struct carm_host *host = _data; in carm_fsm_task() local
1536 state = host->state; in carm_fsm_task()
1548 rc = carm_send_special(host, carm_fill_alloc_buf); in carm_fsm_task()
1556 rc = carm_send_special(host, carm_fill_sync_time); in carm_fsm_task()
1564 rc = carm_send_special(host, carm_fill_get_fw_ver); in carm_fsm_task()
1572 rc = carm_send_special(host, carm_fill_scan_channels); in carm_fsm_task()
1580 host->cur_scan_dev = -1; in carm_fsm_task()
1587 for (i = host->cur_scan_dev + 1; i < CARM_MAX_PORTS; i++) in carm_fsm_task()
1588 if (host->dev_present & (1 << i)) { in carm_fsm_task()
1594 host->cur_scan_dev = next_dev; in carm_fsm_task()
1595 rc = carm_array_info(host, next_dev); in carm_fsm_task()
1609 if (host->dev_active & (1 << i)) { in carm_fsm_task()
1610 carm_activate_disk(host, &host->port[i]); in carm_fsm_task()
1615 pci_name(host->pdev), activated); in carm_fsm_task()
1623 up(&host->probe_sem); in carm_fsm_task()
1639 host->state = new_state; in carm_fsm_task()
1643 schedule_task(&host->fsm_task); in carm_fsm_task()
1670 static void carm_init_responses(struct carm_host *host) in carm_init_responses() argument
1672 void *mmio = host->mmio; in carm_init_responses()
1674 struct carm_response *resp = (struct carm_response *) host->shm; in carm_init_responses()
1682 static int carm_init_host(struct carm_host *host) in carm_init_host() argument
1684 void *mmio = host->mmio; in carm_init_host()
1734 writel(host->shm_dma & 0xffffffff, mmio + RBUF_ADDR_LO); in carm_init_host()
1735 writel((host->shm_dma >> 16) >> 16, mmio + RBUF_ADDR_HI); in carm_init_host()
1752 carm_init_responses(host); in carm_init_host()
1756 assert(host->state == HST_INVALID); in carm_init_host()
1757 host->state = HST_PROBE_START; in carm_init_host()
1760 schedule_task(&host->fsm_task); in carm_init_host()
1766 static void carm_init_ports (struct carm_host *host) in carm_init_ports() argument
1773 port = &host->port[i]; in carm_init_ports()
1775 port->host = host; in carm_init_ports()
1784 blk_queue_bounce_limit(q, host->pdev->dma_mask); in carm_init_ports()
1795 struct carm_host *host; in carm_find_queue() local
1797 host = blk_dev[MAJOR(device)].data; in carm_find_queue()
1798 if (!host) in carm_find_queue()
1800 if (host->magic != CARM_MAGIC_HOST) in carm_find_queue()
1805 return &host->port[MINOR(device) >> CARM_PART_SHIFT].q; in carm_find_queue()
1808 static int carm_init_disks(struct carm_host *host) in carm_init_disks() argument
1810 host->gendisk.major = host->major; in carm_init_disks()
1811 host->gendisk.major_name = host->name; in carm_init_disks()
1812 host->gendisk.minor_shift = CARM_PART_SHIFT; in carm_init_disks()
1813 host->gendisk.max_p = CARM_MINORS_PER_MAJOR; in carm_init_disks()
1814 host->gendisk.part = host->gendisk_hd; in carm_init_disks()
1815 host->gendisk.sizes = host->blk_sizes; in carm_init_disks()
1816 host->gendisk.nr_real = CARM_MAX_PORTS; in carm_init_disks()
1817 host->gendisk.fops = &carm_bd_ops; in carm_init_disks()
1819 blk_dev[host->major].queue = carm_find_queue; in carm_init_disks()
1820 blk_dev[host->major].data = host; in carm_init_disks()
1821 blk_size[host->major] = host->blk_sizes; in carm_init_disks()
1822 blksize_size[host->major] = host->blk_block_sizes; in carm_init_disks()
1823 hardsect_size[host->major] = host->blk_sect_sizes; in carm_init_disks()
1825 add_gendisk(&host->gendisk); in carm_init_disks()
1830 static void carm_free_disks(struct carm_host *host) in carm_free_disks() argument
1834 del_gendisk(&host->gendisk); in carm_free_disks()
1837 struct carm_port *port = &host->port[i]; in carm_free_disks()
1842 blk_dev[host->major].queue = NULL; in carm_free_disks()
1843 blk_dev[host->major].data = NULL; in carm_free_disks()
1844 blk_size[host->major] = NULL; in carm_free_disks()
1845 blksize_size[host->major] = NULL; in carm_free_disks()
1846 hardsect_size[host->major] = NULL; in carm_free_disks()
1849 static void carm_stop_tasklets(struct carm_host *host) in carm_stop_tasklets() argument
1853 tasklet_kill(&host->oob_tasklet); in carm_stop_tasklets()
1856 struct carm_port *port = &host->port[i]; in carm_stop_tasklets()
1861 static int carm_init_shm(struct carm_host *host) in carm_init_shm() argument
1863 host->shm = pci_alloc_consistent(host->pdev, CARM_SHM_SIZE, in carm_init_shm()
1864 &host->shm_dma); in carm_init_shm()
1865 if (!host->shm) in carm_init_shm()
1868 host->msg_base = host->shm + RBUF_LEN; in carm_init_shm()
1869 host->msg_dma = host->shm_dma + RBUF_LEN; in carm_init_shm()
1871 memset(host->shm, 0xff, RBUF_LEN); in carm_init_shm()
1872 memset(host->msg_base, 0, PDC_SHM_SIZE - RBUF_LEN); in carm_init_shm()
1880 struct carm_host *host; in carm_init_one() local
1919 host = kmalloc(sizeof(*host), GFP_KERNEL); in carm_init_one()
1920 if (!host) { in carm_init_one()
1927 memset(host, 0, sizeof(*host)); in carm_init_one()
1928 host->magic = CARM_MAGIC_HOST; in carm_init_one()
1929 host->pdev = pdev; in carm_init_one()
1930 host->flags = pci_dac ? FL_DAC : 0; in carm_init_one()
1931 INIT_TQUEUE(&host->fsm_task, carm_fsm_task, host); in carm_init_one()
1932 INIT_LIST_HEAD(&host->host_list_node); in carm_init_one()
1933 init_MUTEX_LOCKED(&host->probe_sem); in carm_init_one()
1934 tasklet_init(&host->oob_tasklet, carm_oob_tasklet, in carm_init_one()
1935 (unsigned long) host); in carm_init_one()
1936 carm_init_ports(host); in carm_init_one()
1938 for (i = 0; i < ARRAY_SIZE(host->req); i++) in carm_init_one()
1939 host->req[i].tag = i; in carm_init_one()
1941 host->mmio = ioremap(pci_resource_start(pdev, 0), in carm_init_one()
1943 if (!host->mmio) { in carm_init_one()
1950 rc = carm_init_shm(host); in carm_init_one()
1957 blk_init_queue(&host->oob_q, carm_oob_rq_fn); in carm_init_one()
1958 host->oob_q.queuedata = host; in carm_init_one()
1959 blk_queue_bounce_limit(&host->oob_q, pdev->dma_mask); in carm_init_one()
1960 blk_queue_headactive(&host->oob_q, 0); in carm_init_one()
1966 host->major = 160; in carm_init_one()
1968 host->major = 161; in carm_init_one()
1970 host->flags |= FL_DYN_MAJOR; in carm_init_one()
1972 host->id = carm_host_id; in carm_init_one()
1973 sprintf(host->name, DRV_NAME "%d", carm_host_id); in carm_init_one()
1975 rc = register_blkdev(host->major, host->name, &carm_bd_ops); in carm_init_one()
1978 if (host->flags & FL_DYN_MAJOR) in carm_init_one()
1979 host->major = rc; in carm_init_one()
1981 rc = carm_init_disks(host); in carm_init_one()
1987 rc = request_irq(pdev->irq, carm_interrupt, SA_SHIRQ, DRV_NAME, host); in carm_init_one()
1994 rc = carm_init_host(host); in carm_init_one()
1999 down(&host->probe_sem); in carm_init_one()
2002 host->name, pci_name(pdev), (int) CARM_MAX_PORTS, in carm_init_one()
2003 pci_resource_start(pdev, 0), pdev->irq, host->major); in carm_init_one()
2006 pci_set_drvdata(pdev, host); in carm_init_one()
2010 free_irq(pdev->irq, host); in carm_init_one()
2012 carm_free_disks(host); in carm_init_one()
2013 unregister_blkdev(host->major, host->name); in carm_init_one()
2015 if (host->major == 160) in carm_init_one()
2017 else if (host->major == 161) in carm_init_one()
2019 blk_cleanup_queue(&host->oob_q); in carm_init_one()
2020 pci_free_consistent(pdev, CARM_SHM_SIZE, host->shm, host->shm_dma); in carm_init_one()
2022 iounmap(host->mmio); in carm_init_one()
2024 kfree(host); in carm_init_one()
2034 struct carm_host *host = pci_get_drvdata(pdev); in carm_remove_one() local
2036 if (!host) { in carm_remove_one()
2042 free_irq(pdev->irq, host); in carm_remove_one()
2043 carm_stop_tasklets(host); in carm_remove_one()
2044 carm_free_disks(host); in carm_remove_one()
2045 unregister_blkdev(host->major, host->name); in carm_remove_one()
2046 if (host->major == 160) in carm_remove_one()
2048 else if (host->major == 161) in carm_remove_one()
2050 blk_cleanup_queue(&host->oob_q); in carm_remove_one()
2051 pci_free_consistent(pdev, CARM_SHM_SIZE, host->shm, host->shm_dma); in carm_remove_one()
2052 iounmap(host->mmio); in carm_remove_one()
2053 kfree(host); in carm_remove_one()