Lines Matching +full:on +full:- +full:die

1 // SPDX-License-Identifier: GPL-2.0+
3 * The Huawei Cache Coherence System (HCCS) is a multi-chip interconnection
10 * - Retrieve the following information about each port:
11 * - port type
12 * - lane mode
13 * - enable
14 * - current lane mode
15 * - link finite state machine
16 * - lane mask
17 * - CRC error count
19 * - Retrieve the following information about all the ports on the chip or
20 * the die:
21 * - if all enabled ports are in linked
22 * - if all linked ports are in full lane
23 * - CRC error count sum
68 if (ares->type != ACPI_RESOURCE_TYPE_GENERIC_REGISTER) in hccs_get_register_cb()
71 reg = &ares->data.generic_reg; in hccs_get_register_cb()
72 if (reg->space_id != ACPI_ADR_SPACE_PLATFORM_COMM) { in hccs_get_register_cb()
73 dev_err(ctx->dev, "Bad register resource.\n"); in hccs_get_register_cb()
74 ctx->err = -EINVAL; in hccs_get_register_cb()
77 ctx->chan_id = reg->access_size; in hccs_get_register_cb()
84 acpi_handle handle = ACPI_HANDLE(hdev->dev); in hccs_get_pcc_chan_id()
89 dev_err(hdev->dev, "No _CRS method.\n"); in hccs_get_pcc_chan_id()
90 return -ENODEV; in hccs_get_pcc_chan_id()
93 ctx.dev = hdev->dev; in hccs_get_pcc_chan_id()
98 hdev->chan_id = ctx.chan_id; in hccs_get_pcc_chan_id()
118 complete(&cl_info->done); in hccs_pcc_rx_callback()
123 struct hccs_mbox_client_info *cl_info = &hdev->cl_info; in hccs_unregister_pcc_channel()
125 if (cl_info->pcc_comm_addr) in hccs_unregister_pcc_channel()
126 iounmap(cl_info->pcc_comm_addr); in hccs_unregister_pcc_channel()
127 pcc_mbox_free_channel(hdev->cl_info.pcc_chan); in hccs_unregister_pcc_channel()
132 struct hccs_mbox_client_info *cl_info = &hdev->cl_info; in hccs_register_pcc_channel()
133 struct mbox_client *cl = &cl_info->client; in hccs_register_pcc_channel()
135 struct device *dev = hdev->dev; in hccs_register_pcc_channel()
138 cl->dev = dev; in hccs_register_pcc_channel()
139 cl->tx_block = false; in hccs_register_pcc_channel()
140 cl->knows_txdone = true; in hccs_register_pcc_channel()
141 cl->tx_done = hccs_chan_tx_done; in hccs_register_pcc_channel()
142 cl->rx_callback = hdev->verspec_data->rx_callback; in hccs_register_pcc_channel()
143 init_completion(&cl_info->done); in hccs_register_pcc_channel()
145 pcc_chan = pcc_mbox_request_channel(cl, hdev->chan_id); in hccs_register_pcc_channel()
148 rc = -ENODEV; in hccs_register_pcc_channel()
151 cl_info->pcc_chan = pcc_chan; in hccs_register_pcc_channel()
152 cl_info->mbox_chan = pcc_chan->mchan; in hccs_register_pcc_channel()
155 * pcc_chan->latency is just a nominal value. In reality the remote in hccs_register_pcc_channel()
157 * of wait on top of nominal. in hccs_register_pcc_channel()
159 cl_info->deadline_us = in hccs_register_pcc_channel()
160 HCCS_PCC_CMD_WAIT_RETRIES_NUM * pcc_chan->latency; in hccs_register_pcc_channel()
161 if (!hdev->verspec_data->has_txdone_irq && in hccs_register_pcc_channel()
162 cl_info->mbox_chan->mbox->txdone_irq) { in hccs_register_pcc_channel()
164 rc = -EINVAL; in hccs_register_pcc_channel()
166 } else if (hdev->verspec_data->has_txdone_irq && in hccs_register_pcc_channel()
167 !cl_info->mbox_chan->mbox->txdone_irq) { in hccs_register_pcc_channel()
169 rc = -EINVAL; in hccs_register_pcc_channel()
173 if (pcc_chan->shmem_base_addr) { in hccs_register_pcc_channel()
174 cl_info->pcc_comm_addr = ioremap(pcc_chan->shmem_base_addr, in hccs_register_pcc_channel()
175 pcc_chan->shmem_size); in hccs_register_pcc_channel()
176 if (!cl_info->pcc_comm_addr) { in hccs_register_pcc_channel()
177 dev_err(dev, "Failed to ioremap PCC communication region for channel-%u.\n", in hccs_register_pcc_channel()
178 hdev->chan_id); in hccs_register_pcc_channel()
179 rc = -ENOMEM; in hccs_register_pcc_channel()
187 pcc_mbox_free_channel(cl_info->pcc_chan); in hccs_register_pcc_channel()
194 struct hccs_mbox_client_info *cl_info = &hdev->cl_info; in hccs_wait_cmd_complete_by_poll()
196 cl_info->pcc_comm_addr; in hccs_wait_cmd_complete_by_poll()
204 ret = readw_poll_timeout(&comm_base->status, status, in hccs_wait_cmd_complete_by_poll()
207 cl_info->deadline_us); in hccs_wait_cmd_complete_by_poll()
209 dev_err(hdev->dev, "poll PCC status failed, ret = %d.\n", ret); in hccs_wait_cmd_complete_by_poll()
216 struct hccs_mbox_client_info *cl_info = &hdev->cl_info; in hccs_wait_cmd_complete_by_irq()
218 if (!wait_for_completion_timeout(&cl_info->done, in hccs_wait_cmd_complete_by_irq()
219 usecs_to_jiffies(cl_info->deadline_us))) { in hccs_wait_cmd_complete_by_irq()
220 dev_err(hdev->dev, "PCC command executed timeout!\n"); in hccs_wait_cmd_complete_by_irq()
221 return -ETIMEDOUT; in hccs_wait_cmd_complete_by_irq()
234 .signature = PCC_SIGNATURE | hdev->chan_id, in hccs_fill_pcc_shared_mem_region()
239 memcpy_toio(hdev->cl_info.pcc_comm_addr, (void *)&tmp, in hccs_fill_pcc_shared_mem_region()
253 .signature = PCC_SIGNATURE | hdev->chan_id, in hccs_fill_ext_pcc_shared_mem_region()
259 memcpy_toio(hdev->cl_info.pcc_comm_addr, (void *)&tmp, in hccs_fill_ext_pcc_shared_mem_region()
269 const struct hccs_verspecific_data *verspec_data = hdev->verspec_data; in hccs_pcc_cmd_send()
270 struct hccs_mbox_client_info *cl_info = &hdev->cl_info; in hccs_pcc_cmd_send()
276 comm_space = cl_info->pcc_comm_addr + verspec_data->shared_mem_size; in hccs_pcc_cmd_send()
277 space_size = HCCS_PCC_SHARE_MEM_BYTES - verspec_data->shared_mem_size; in hccs_pcc_cmd_send()
278 verspec_data->fill_pcc_shared_mem(hdev, cmd, desc, in hccs_pcc_cmd_send()
280 if (verspec_data->has_txdone_irq) in hccs_pcc_cmd_send()
281 reinit_completion(&cl_info->done); in hccs_pcc_cmd_send()
284 ret = mbox_send_message(cl_info->mbox_chan, &cmd); in hccs_pcc_cmd_send()
286 dev_err(hdev->dev, "Send PCC mbox message failed, ret = %d.\n", in hccs_pcc_cmd_send()
291 ret = verspec_data->wait_cmd_complete(hdev); in hccs_pcc_cmd_send()
297 fw_inner_head = &desc->rsp.fw_inner_head; in hccs_pcc_cmd_send()
298 if (fw_inner_head->retStatus) { in hccs_pcc_cmd_send()
299 dev_err(hdev->dev, "Execute PCC command failed, error code = %u.\n", in hccs_pcc_cmd_send()
300 fw_inner_head->retStatus); in hccs_pcc_cmd_send()
301 ret = -EIO; in hccs_pcc_cmd_send()
305 if (verspec_data->has_txdone_irq) in hccs_pcc_cmd_send()
306 mbox_chan_txdone(cl_info->mbox_chan, ret); in hccs_pcc_cmd_send()
308 mbox_client_txdone(cl_info->mbox_chan, ret); in hccs_pcc_cmd_send()
314 struct hccs_req_desc *req = &desc->req; in hccs_init_req_desc()
317 req->req_head.module_code = HCCS_SERDES_MODULE_CODE; in hccs_init_req_desc()
328 dev_err(hdev->dev, "Get device capabilities failed, ret = %d.\n", in hccs_get_dev_caps()
332 memcpy(&hdev->caps, desc.rsp.data, sizeof(hdev->caps)); in hccs_get_dev_caps()
345 dev_err(hdev->dev, "query system chip number failed, ret = %d.\n", in hccs_query_chip_num_on_platform()
350 hdev->chip_num = *((u8 *)&desc.rsp.data); in hccs_query_chip_num_on_platform()
351 if (!hdev->chip_num) { in hccs_query_chip_num_on_platform()
352 dev_err(hdev->dev, "chip num obtained from firmware is zero.\n"); in hccs_query_chip_num_on_platform()
353 return -EINVAL; in hccs_query_chip_num_on_platform()
368 req_param->chip_id = chip->chip_id; in hccs_get_chip_info()
373 chip->die_num = *((u8 *)&desc.rsp.data); in hccs_get_chip_info()
386 dev_err(hdev->dev, "query chip number on platform failed, ret = %d.\n", in hccs_query_chip_info_on_platform()
391 hdev->chips = devm_kzalloc(hdev->dev, in hccs_query_chip_info_on_platform()
392 hdev->chip_num * sizeof(struct hccs_chip_info), in hccs_query_chip_info_on_platform()
394 if (!hdev->chips) { in hccs_query_chip_info_on_platform()
395 dev_err(hdev->dev, "allocate all chips memory failed.\n"); in hccs_query_chip_info_on_platform()
396 return -ENOMEM; in hccs_query_chip_info_on_platform()
399 for (idx = 0; idx < hdev->chip_num; idx++) { in hccs_query_chip_info_on_platform()
400 chip = &hdev->chips[idx]; in hccs_query_chip_info_on_platform()
401 chip->chip_id = idx; in hccs_query_chip_info_on_platform()
404 dev_err(hdev->dev, "get chip%u info failed, ret = %d.\n", in hccs_query_chip_info_on_platform()
408 chip->hdev = hdev; in hccs_query_chip_info_on_platform()
415 u8 die_idx, struct hccs_die_info *die) in hccs_query_die_info_on_chip() argument
424 req_param->chip_id = chip_id; in hccs_query_die_info_on_chip()
425 req_param->die_idx = die_idx; in hccs_query_die_info_on_chip()
431 die->die_id = rsp_data->die_id; in hccs_query_die_info_on_chip()
432 die->port_num = rsp_data->port_num; in hccs_query_die_info_on_chip()
433 die->min_port_id = rsp_data->min_port_id; in hccs_query_die_info_on_chip()
434 die->max_port_id = rsp_data->max_port_id; in hccs_query_die_info_on_chip()
435 if (die->min_port_id > die->max_port_id) { in hccs_query_die_info_on_chip()
436 dev_err(hdev->dev, "min port id(%u) > max port id(%u) on die_idx(%u).\n", in hccs_query_die_info_on_chip()
437 die->min_port_id, die->max_port_id, die_idx); in hccs_query_die_info_on_chip()
438 return -EINVAL; in hccs_query_die_info_on_chip()
440 if (die->max_port_id > HCCS_DIE_MAX_PORT_ID) { in hccs_query_die_info_on_chip()
441 dev_err(hdev->dev, "max port id(%u) on die_idx(%u) is too big.\n", in hccs_query_die_info_on_chip()
442 die->max_port_id, die_idx); in hccs_query_die_info_on_chip()
443 return -EINVAL; in hccs_query_die_info_on_chip()
451 struct device *dev = hdev->dev; in hccs_query_all_die_info_on_platform()
453 struct hccs_die_info *die; in hccs_query_all_die_info_on_platform() local
457 for (i = 0; i < hdev->chip_num; i++) { in hccs_query_all_die_info_on_platform()
458 chip = &hdev->chips[i]; in hccs_query_all_die_info_on_platform()
459 if (!chip->die_num) in hccs_query_all_die_info_on_platform()
462 chip->dies = devm_kzalloc(hdev->dev, in hccs_query_all_die_info_on_platform()
463 chip->die_num * sizeof(struct hccs_die_info), in hccs_query_all_die_info_on_platform()
465 if (!chip->dies) { in hccs_query_all_die_info_on_platform()
466 dev_err(dev, "allocate all dies memory on chip%u failed.\n", in hccs_query_all_die_info_on_platform()
468 return -ENOMEM; in hccs_query_all_die_info_on_platform()
471 for (j = 0; j < chip->die_num; j++) { in hccs_query_all_die_info_on_platform()
472 die = &chip->dies[j]; in hccs_query_all_die_info_on_platform()
473 ret = hccs_query_die_info_on_chip(hdev, i, j, die); in hccs_query_all_die_info_on_platform()
475 dev_err(dev, "get die idx (%u) info on chip%u failed, ret = %d.\n", in hccs_query_all_die_info_on_platform()
479 die->chip = chip; in hccs_query_all_die_info_on_platform()
499 rsp = &desc->rsp; in hccs_get_bd_info()
500 head = &rsp->rsp_head; in hccs_get_bd_info()
501 if (head->data_len > buf_len) { in hccs_get_bd_info()
502 dev_err(hdev->dev, in hccs_get_bd_info()
504 buf_len, head->data_len); in hccs_get_bd_info()
505 return -ENOMEM; in hccs_get_bd_info()
508 memcpy(buf, rsp->data, head->data_len); in hccs_get_bd_info()
515 struct hccs_die_info *die, in hccs_get_all_port_attr() argument
530 start_id = die->min_port_id; in hccs_get_all_port_attr()
531 while (start_id <= die->max_port_id) { in hccs_get_all_port_attr()
534 req_head->start_id = start_id; in hccs_get_all_port_attr()
536 req_param->chip_id = die->chip->chip_id; in hccs_get_all_port_attr()
537 req_param->die_id = die->die_id; in hccs_get_all_port_attr()
542 dev_err(hdev->dev, in hccs_get_all_port_attr()
543 "get the information of port%u on die%u failed, ret = %d.\n", in hccs_get_all_port_attr()
544 start_id, die->die_id, ret); in hccs_get_all_port_attr()
549 left_buf_len -= rsp_head.data_len; in hccs_get_all_port_attr()
551 dev_err(hdev->dev, in hccs_get_all_port_attr()
552 "next port id (%u) is not greater than last start id (%u) on die%u.\n", in hccs_get_all_port_attr()
553 rsp_head.next_id, start_id, die->die_id); in hccs_get_all_port_attr()
554 return -EINVAL; in hccs_get_all_port_attr()
560 dev_err(hdev->dev, "failed to get the expected port number(%u) attribute.\n", in hccs_get_all_port_attr()
562 return -EINVAL; in hccs_get_all_port_attr()
569 struct hccs_die_info *die) in hccs_get_all_port_info_on_die() argument
576 attrs = kcalloc(die->port_num, sizeof(struct hccs_port_attr), in hccs_get_all_port_info_on_die()
579 return -ENOMEM; in hccs_get_all_port_info_on_die()
581 ret = hccs_get_all_port_attr(hdev, die, attrs, die->port_num); in hccs_get_all_port_info_on_die()
585 for (i = 0; i < die->port_num; i++) { in hccs_get_all_port_info_on_die()
586 port = &die->ports[i]; in hccs_get_all_port_info_on_die()
587 port->port_id = attrs[i].port_id; in hccs_get_all_port_info_on_die()
588 port->port_type = attrs[i].port_type; in hccs_get_all_port_info_on_die()
589 port->lane_mode = attrs[i].lane_mode; in hccs_get_all_port_info_on_die()
590 port->enable = attrs[i].enable; in hccs_get_all_port_info_on_die()
591 port->die = die; in hccs_get_all_port_info_on_die()
601 struct device *dev = hdev->dev; in hccs_query_all_port_info_on_platform()
603 struct hccs_die_info *die; in hccs_query_all_port_info_on_platform() local
607 for (i = 0; i < hdev->chip_num; i++) { in hccs_query_all_port_info_on_platform()
608 chip = &hdev->chips[i]; in hccs_query_all_port_info_on_platform()
609 for (j = 0; j < chip->die_num; j++) { in hccs_query_all_port_info_on_platform()
610 die = &chip->dies[j]; in hccs_query_all_port_info_on_platform()
611 if (!die->port_num) in hccs_query_all_port_info_on_platform()
614 die->ports = devm_kzalloc(dev, in hccs_query_all_port_info_on_platform()
615 die->port_num * sizeof(struct hccs_port_info), in hccs_query_all_port_info_on_platform()
617 if (!die->ports) { in hccs_query_all_port_info_on_platform()
618 dev_err(dev, "allocate ports memory on chip%u/die%u failed.\n", in hccs_query_all_port_info_on_platform()
619 i, die->die_id); in hccs_query_all_port_info_on_platform()
620 return -ENOMEM; in hccs_query_all_port_info_on_platform()
623 ret = hccs_get_all_port_info_on_die(hdev, die); in hccs_query_all_port_info_on_platform()
625 dev_err(dev, "get all port info on chip%u/die%u failed, ret = %d.\n", in hccs_query_all_port_info_on_platform()
626 i, die->die_id, ret); in hccs_query_all_port_info_on_platform()
641 dev_err(hdev->dev, "query chip info on platform failed, ret = %d.\n", in hccs_get_hw_info()
648 dev_err(hdev->dev, "query all die info on platform failed, ret = %d.\n", in hccs_get_hw_info()
655 dev_err(hdev->dev, "query all port info on platform failed, ret = %d.\n", in hccs_get_hw_info()
667 const struct hccs_die_info *die = port->die; in hccs_query_port_link_status() local
668 const struct hccs_chip_info *chip = die->chip; in hccs_query_port_link_status()
675 req_param->chip_id = chip->chip_id; in hccs_query_port_link_status()
676 req_param->die_id = die->die_id; in hccs_query_port_link_status()
677 req_param->port_id = port->port_id; in hccs_query_port_link_status()
680 dev_err(hdev->dev, in hccs_query_port_link_status()
694 const struct hccs_die_info *die = port->die; in hccs_query_port_crc_err_cnt() local
695 const struct hccs_chip_info *chip = die->chip; in hccs_query_port_crc_err_cnt()
702 req_param->chip_id = chip->chip_id; in hccs_query_port_crc_err_cnt()
703 req_param->die_id = die->die_id; in hccs_query_port_crc_err_cnt()
704 req_param->port_id = port->port_id; in hccs_query_port_crc_err_cnt()
707 dev_err(hdev->dev, in hccs_query_port_crc_err_cnt()
718 const struct hccs_die_info *die, in hccs_get_die_all_link_status() argument
725 if (die->port_num == 0) { in hccs_get_die_all_link_status()
732 req_param->chip_id = die->chip->chip_id; in hccs_get_die_all_link_status()
733 req_param->die_id = die->die_id; in hccs_get_die_all_link_status()
736 dev_err(hdev->dev, in hccs_get_die_all_link_status()
737 "get link status of all ports failed on die%u, ret = %d.\n", in hccs_get_die_all_link_status()
738 die->die_id, ret); in hccs_get_die_all_link_status()
748 const struct hccs_die_info *die, in hccs_get_die_all_port_lane_status() argument
755 if (die->port_num == 0) { in hccs_get_die_all_port_lane_status()
762 req_param->chip_id = die->chip->chip_id; in hccs_get_die_all_port_lane_status()
763 req_param->die_id = die->die_id; in hccs_get_die_all_port_lane_status()
766 dev_err(hdev->dev, "get lane status of all ports failed on die%u, ret = %d.\n", in hccs_get_die_all_port_lane_status()
767 die->die_id, ret); in hccs_get_die_all_port_lane_status()
777 const struct hccs_die_info *die, in hccs_get_die_total_crc_err_cnt() argument
784 if (die->port_num == 0) { in hccs_get_die_total_crc_err_cnt()
791 req_param->chip_id = die->chip->chip_id; in hccs_get_die_total_crc_err_cnt()
792 req_param->die_id = die->die_id; in hccs_get_die_total_crc_err_cnt()
795 dev_err(hdev->dev, "get crc error count sum failed on die%u, ret = %d.\n", in hccs_get_die_total_crc_err_cnt()
796 die->die_id, ret); in hccs_get_die_total_crc_err_cnt()
811 return kobj_attr->show(k, kobj_attr, buf); in hccs_show()
823 return sysfs_emit(buf, "HCCS-v%u\n", port->port_type); in type_show()
832 return sysfs_emit(buf, "x%u\n", port->lane_mode); in lane_mode_show()
841 return sysfs_emit(buf, "%u\n", port->enable); in enable_show()
849 struct hccs_dev *hdev = port->die->chip->hdev; in cur_lane_num_show()
853 mutex_lock(&hdev->lock); in cur_lane_num_show()
855 mutex_unlock(&hdev->lock); in cur_lane_num_show()
867 struct hccs_dev *hdev = port->die->chip->hdev; in link_fsm_show()
876 {HCCS_PORT_READY, "link-up"}, in link_fsm_show()
882 mutex_lock(&hdev->lock); in link_fsm_show()
884 mutex_unlock(&hdev->lock); in link_fsm_show()
903 struct hccs_dev *hdev = port->die->chip->hdev; in lane_mask_show()
907 mutex_lock(&hdev->lock); in lane_mask_show()
909 mutex_unlock(&hdev->lock); in lane_mask_show()
921 struct hccs_dev *hdev = port->die->chip->hdev; in crc_err_cnt_show()
925 mutex_lock(&hdev->lock); in crc_err_cnt_show()
927 mutex_unlock(&hdev->lock); in crc_err_cnt_show()
955 const struct hccs_die_info *die = kobj_to_die_info(kobj); in all_linked_on_die_show() local
956 struct hccs_dev *hdev = die->chip->hdev; in all_linked_on_die_show()
960 mutex_lock(&hdev->lock); in all_linked_on_die_show()
961 ret = hccs_get_die_all_link_status(hdev, die, &all_linked); in all_linked_on_die_show()
962 mutex_unlock(&hdev->lock); in all_linked_on_die_show()
975 const struct hccs_die_info *die = kobj_to_die_info(kobj); in linked_full_lane_on_die_show() local
976 struct hccs_dev *hdev = die->chip->hdev; in linked_full_lane_on_die_show()
980 mutex_lock(&hdev->lock); in linked_full_lane_on_die_show()
981 ret = hccs_get_die_all_port_lane_status(hdev, die, &full_lane); in linked_full_lane_on_die_show()
982 mutex_unlock(&hdev->lock); in linked_full_lane_on_die_show()
995 const struct hccs_die_info *die = kobj_to_die_info(kobj); in crc_err_cnt_sum_on_die_show() local
996 struct hccs_dev *hdev = die->chip->hdev; in crc_err_cnt_sum_on_die_show()
1000 mutex_lock(&hdev->lock); in crc_err_cnt_sum_on_die_show()
1001 ret = hccs_get_die_total_crc_err_cnt(hdev, die, &total_crc_err_cnt); in crc_err_cnt_sum_on_die_show()
1002 mutex_unlock(&hdev->lock); in crc_err_cnt_sum_on_die_show()
1028 struct hccs_dev *hdev = chip->hdev; in all_linked_on_chip_show()
1029 const struct hccs_die_info *die; in all_linked_on_chip_show() local
1034 mutex_lock(&hdev->lock); in all_linked_on_chip_show()
1035 for (i = 0; i < chip->die_num; i++) { in all_linked_on_chip_show()
1036 die = &chip->dies[i]; in all_linked_on_chip_show()
1037 ret = hccs_get_die_all_link_status(hdev, die, &tmp); in all_linked_on_chip_show()
1039 mutex_unlock(&hdev->lock); in all_linked_on_chip_show()
1047 mutex_unlock(&hdev->lock); in all_linked_on_chip_show()
1059 struct hccs_dev *hdev = chip->hdev; in linked_full_lane_on_chip_show()
1060 const struct hccs_die_info *die; in linked_full_lane_on_chip_show() local
1065 mutex_lock(&hdev->lock); in linked_full_lane_on_chip_show()
1066 for (i = 0; i < chip->die_num; i++) { in linked_full_lane_on_chip_show()
1067 die = &chip->dies[i]; in linked_full_lane_on_chip_show()
1068 ret = hccs_get_die_all_port_lane_status(hdev, die, &tmp); in linked_full_lane_on_chip_show()
1070 mutex_unlock(&hdev->lock); in linked_full_lane_on_chip_show()
1078 mutex_unlock(&hdev->lock); in linked_full_lane_on_chip_show()
1091 struct hccs_dev *hdev = chip->hdev; in crc_err_cnt_sum_on_chip_show()
1092 const struct hccs_die_info *die; in crc_err_cnt_sum_on_chip_show() local
1096 mutex_lock(&hdev->lock); in crc_err_cnt_sum_on_chip_show()
1097 for (i = 0; i < chip->die_num; i++) { in crc_err_cnt_sum_on_chip_show()
1098 die = &chip->dies[i]; in crc_err_cnt_sum_on_chip_show()
1099 ret = hccs_get_die_total_crc_err_cnt(hdev, die, &crc_err_cnt); in crc_err_cnt_sum_on_chip_show()
1101 mutex_unlock(&hdev->lock); in crc_err_cnt_sum_on_chip_show()
1107 mutex_unlock(&hdev->lock); in crc_err_cnt_sum_on_chip_show()
1127 static void hccs_remove_die_dir(struct hccs_die_info *die) in hccs_remove_die_dir() argument
1132 for (i = 0; i < die->port_num; i++) { in hccs_remove_die_dir()
1133 port = &die->ports[i]; in hccs_remove_die_dir()
1134 if (port->dir_created) in hccs_remove_die_dir()
1135 kobject_put(&port->kobj); in hccs_remove_die_dir()
1138 kobject_put(&die->kobj); in hccs_remove_die_dir()
1143 struct hccs_die_info *die; in hccs_remove_chip_dir() local
1146 for (i = 0; i < chip->die_num; i++) { in hccs_remove_chip_dir()
1147 die = &chip->dies[i]; in hccs_remove_chip_dir()
1148 if (die->dir_created) in hccs_remove_chip_dir()
1149 hccs_remove_die_dir(die); in hccs_remove_chip_dir()
1152 kobject_put(&chip->kobj); in hccs_remove_chip_dir()
1159 for (i = 0; i < hdev->chip_num; i++) in hccs_remove_topo_dirs()
1160 hccs_remove_chip_dir(&hdev->chips[i]); in hccs_remove_topo_dirs()
1164 struct hccs_die_info *die, in hccs_create_hccs_dir() argument
1169 ret = kobject_init_and_add(&port->kobj, &hccs_port_type, in hccs_create_hccs_dir()
1170 &die->kobj, "hccs%u", port->port_id); in hccs_create_hccs_dir()
1172 kobject_put(&port->kobj); in hccs_create_hccs_dir()
1181 struct hccs_die_info *die) in hccs_create_die_dir() argument
1187 ret = kobject_init_and_add(&die->kobj, &hccs_die_type, in hccs_create_die_dir()
1188 &chip->kobj, "die%u", die->die_id); in hccs_create_die_dir()
1190 kobject_put(&die->kobj); in hccs_create_die_dir()
1194 for (i = 0; i < die->port_num; i++) { in hccs_create_die_dir()
1195 port = &die->ports[i]; in hccs_create_die_dir()
1196 ret = hccs_create_hccs_dir(hdev, die, port); in hccs_create_die_dir()
1198 dev_err(hdev->dev, "create hccs%u dir failed.\n", in hccs_create_die_dir()
1199 port->port_id); in hccs_create_die_dir()
1202 port->dir_created = true; in hccs_create_die_dir()
1207 hccs_remove_die_dir(die); in hccs_create_die_dir()
1215 struct hccs_die_info *die; in hccs_create_chip_dir() local
1219 ret = kobject_init_and_add(&chip->kobj, &hccs_chip_type, in hccs_create_chip_dir()
1220 &hdev->dev->kobj, "chip%u", chip->chip_id); in hccs_create_chip_dir()
1222 kobject_put(&chip->kobj); in hccs_create_chip_dir()
1226 for (id = 0; id < chip->die_num; id++) { in hccs_create_chip_dir()
1227 die = &chip->dies[id]; in hccs_create_chip_dir()
1228 ret = hccs_create_die_dir(hdev, chip, die); in hccs_create_chip_dir()
1231 die->dir_created = true; in hccs_create_chip_dir()
1247 for (id = 0; id < hdev->chip_num; id++) { in hccs_create_topo_dirs()
1248 chip = &hdev->chips[id]; in hccs_create_topo_dirs()
1251 dev_err(hdev->dev, "init chip%u dir failed!\n", id); in hccs_create_topo_dirs()
1259 hccs_remove_chip_dir(&hdev->chips[k]); in hccs_create_topo_dirs()
1271 dev_err(&pdev->dev, "acpi is disabled.\n"); in hccs_probe()
1272 return -ENODEV; in hccs_probe()
1274 acpi_dev = ACPI_COMPANION(&pdev->dev); in hccs_probe()
1276 return -ENODEV; in hccs_probe()
1278 hdev = devm_kzalloc(&pdev->dev, sizeof(*hdev), GFP_KERNEL); in hccs_probe()
1280 return -ENOMEM; in hccs_probe()
1281 hdev->acpi_dev = acpi_dev; in hccs_probe()
1282 hdev->dev = &pdev->dev; in hccs_probe()
1288 hdev->verspec_data = acpi_device_get_match_data(hdev->dev); in hccs_probe()
1290 mutex_init(&hdev->lock); in hccs_probe()