Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge patch series "scsi: libsas: Some coding style fixes and cleanups"

Jason Yan <yanaijie@huawei.com> says:

A few coding style fixes and cleanups. There should be no functional
changes in this series besides the debug log prints.

Link: https://lore.kernel.org/r/20221214133808.1649122-1-yanaijie@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

+134 -106
+73 -15
drivers/scsi/libsas/sas_ata.c
··· 239 239 return to_sas_internal(dev->port->ha->core.shost->transportt); 240 240 } 241 241 242 - static int sas_get_ata_command_set(struct domain_device *dev); 242 + static int sas_get_ata_command_set(struct domain_device *dev) 243 + { 244 + struct ata_taskfile tf; 245 + 246 + if (dev->dev_type == SAS_SATA_PENDING) 247 + return ATA_DEV_UNKNOWN; 248 + 249 + ata_tf_from_fis(dev->frame_rcvd, &tf); 250 + 251 + return ata_dev_classify(&tf); 252 + } 243 253 244 254 int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy) 245 255 { ··· 647 637 complete(waiting); 648 638 } 649 639 650 - static int sas_get_ata_command_set(struct domain_device *dev) 651 - { 652 - struct dev_to_host_fis *fis = 653 - (struct dev_to_host_fis *) dev->frame_rcvd; 654 - struct ata_taskfile tf; 655 - 656 - if (dev->dev_type == SAS_SATA_PENDING) 657 - return ATA_DEV_UNKNOWN; 658 - 659 - ata_tf_from_fis((const u8 *)fis, &tf); 660 - 661 - return ata_dev_classify(&tf); 662 - } 663 - 664 640 void sas_probe_sata(struct asd_sas_port *port) 665 641 { 666 642 struct domain_device *dev, *n; ··· 673 677 sas_fail_probe(dev, __func__, -ENODEV); 674 678 } 675 679 680 + } 681 + 682 + int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, 683 + struct domain_device *child, int phy_id) 684 + { 685 + struct sas_rphy *rphy; 686 + int ret; 687 + 688 + if (child->linkrate > parent->min_linkrate) { 689 + struct sas_phy *cphy = child->phy; 690 + enum sas_linkrate min_prate = cphy->minimum_linkrate, 691 + parent_min_lrate = parent->min_linkrate, 692 + min_linkrate = (min_prate > parent_min_lrate) ? 693 + parent_min_lrate : 0; 694 + struct sas_phy_linkrates rates = { 695 + .maximum_linkrate = parent->min_linkrate, 696 + .minimum_linkrate = min_linkrate, 697 + }; 698 + 699 + pr_notice("ex %016llx phy%02d SATA device linkrate > min pathway connection rate, attempting to lower device linkrate\n", 700 + SAS_ADDR(child->sas_addr), phy_id); 701 + ret = sas_smp_phy_control(parent, phy_id, 702 + PHY_FUNC_LINK_RESET, &rates); 703 + if (ret) { 704 + pr_err("ex %016llx phy%02d SATA device could not set linkrate (%d)\n", 705 + SAS_ADDR(child->sas_addr), phy_id, ret); 706 + return ret; 707 + } 708 + pr_notice("ex %016llx phy%02d SATA device set linkrate successfully\n", 709 + SAS_ADDR(child->sas_addr), phy_id); 710 + child->linkrate = child->min_linkrate; 711 + } 712 + ret = sas_get_ata_info(child, phy); 713 + if (ret) 714 + return ret; 715 + 716 + sas_init_dev(child); 717 + ret = sas_ata_init(child); 718 + if (ret) 719 + return ret; 720 + 721 + rphy = sas_end_device_alloc(phy->port); 722 + if (!rphy) 723 + return ret; 724 + 725 + rphy->identify.phy_identifier = phy_id; 726 + child->rphy = rphy; 727 + get_device(&rphy->dev); 728 + 729 + list_add_tail(&child->disco_list_node, &parent->port->disco_list); 730 + 731 + ret = sas_discover_sata(child); 732 + if (ret) { 733 + pr_notice("sas_discover_sata() for device %16llx at %016llx:%02d returned 0x%x\n", 734 + SAS_ADDR(child->sas_addr), 735 + SAS_ADDR(parent->sas_addr), phy_id, ret); 736 + sas_rphy_free(child->rphy); 737 + list_del(&child->disco_list_node); 738 + return ret; 739 + } 740 + 741 + return 0; 676 742 } 677 743 678 744 static void sas_ata_flush_pm_eh(struct asd_sas_port *port, const char *func)
-6
drivers/scsi/libsas/sas_discover.c
··· 455 455 break; 456 456 case SAS_SATA_DEV: 457 457 case SAS_SATA_PM: 458 - #ifdef CONFIG_SCSI_SAS_ATA 459 458 error = sas_discover_sata(dev); 460 459 break; 461 - #else 462 - pr_notice("ATA device seen but CONFIG_SCSI_SAS_ATA=N so cannot attach\n"); 463 - fallthrough; 464 - #endif 465 - /* Fall through - only for the #else condition above. */ 466 460 default: 467 461 error = -ENXIO; 468 462 pr_err("unhandled device %d\n", dev->dev_type);
+41 -84
drivers/scsi/libsas/sas_expander.c
··· 751 751 child->pathways = min(child->pathways, parent->pathways); 752 752 } 753 753 754 + static int sas_ex_add_dev(struct domain_device *parent, struct ex_phy *phy, 755 + struct domain_device *child, int phy_id) 756 + { 757 + struct sas_rphy *rphy; 758 + int res; 759 + 760 + child->dev_type = SAS_END_DEVICE; 761 + rphy = sas_end_device_alloc(phy->port); 762 + if (!rphy) 763 + return -ENOMEM; 764 + 765 + child->tproto = phy->attached_tproto; 766 + sas_init_dev(child); 767 + 768 + child->rphy = rphy; 769 + get_device(&rphy->dev); 770 + rphy->identify.phy_identifier = phy_id; 771 + sas_fill_in_rphy(child, rphy); 772 + 773 + list_add_tail(&child->disco_list_node, &parent->port->disco_list); 774 + 775 + res = sas_notify_lldd_dev_found(child); 776 + if (res) { 777 + pr_notice("notify lldd for device %016llx at %016llx:%02d returned 0x%x\n", 778 + SAS_ADDR(child->sas_addr), 779 + SAS_ADDR(parent->sas_addr), phy_id, res); 780 + sas_rphy_free(child->rphy); 781 + list_del(&child->disco_list_node); 782 + return res; 783 + } 784 + 785 + return 0; 786 + } 787 + 754 788 static struct domain_device *sas_ex_discover_end_dev( 755 789 struct domain_device *parent, int phy_id) 756 790 { 757 791 struct expander_device *parent_ex = &parent->ex_dev; 758 792 struct ex_phy *phy = &parent_ex->ex_phy[phy_id]; 759 793 struct domain_device *child = NULL; 760 - struct sas_rphy *rphy; 761 794 int res; 762 795 763 796 if (phy->attached_sata_host || phy->attached_sata_ps) ··· 818 785 sas_ex_get_linkrate(parent, child, phy); 819 786 sas_device_set_phy(child, phy->port); 820 787 821 - #ifdef CONFIG_SCSI_SAS_ATA 822 788 if ((phy->attached_tproto & SAS_PROTOCOL_STP) || phy->attached_sata_dev) { 823 - if (child->linkrate > parent->min_linkrate) { 824 - struct sas_phy *cphy = child->phy; 825 - enum sas_linkrate min_prate = cphy->minimum_linkrate, 826 - parent_min_lrate = parent->min_linkrate, 827 - min_linkrate = (min_prate > parent_min_lrate) ? 828 - parent_min_lrate : 0; 829 - struct sas_phy_linkrates rates = { 830 - .maximum_linkrate = parent->min_linkrate, 831 - .minimum_linkrate = min_linkrate, 832 - }; 833 - int ret; 834 - 835 - pr_notice("ex %016llx phy%02d SATA device linkrate > min pathway connection rate, attempting to lower device linkrate\n", 836 - SAS_ADDR(child->sas_addr), phy_id); 837 - ret = sas_smp_phy_control(parent, phy_id, 838 - PHY_FUNC_LINK_RESET, &rates); 839 - if (ret) { 840 - pr_err("ex %016llx phy%02d SATA device could not set linkrate (%d)\n", 841 - SAS_ADDR(child->sas_addr), phy_id, ret); 842 - goto out_free; 843 - } 844 - pr_notice("ex %016llx phy%02d SATA device set linkrate successfully\n", 845 - SAS_ADDR(child->sas_addr), phy_id); 846 - child->linkrate = child->min_linkrate; 847 - } 848 - res = sas_get_ata_info(child, phy); 849 - if (res) 850 - goto out_free; 851 - 852 - sas_init_dev(child); 853 - res = sas_ata_init(child); 854 - if (res) 855 - goto out_free; 856 - rphy = sas_end_device_alloc(phy->port); 857 - if (!rphy) 858 - goto out_free; 859 - rphy->identify.phy_identifier = phy_id; 860 - 861 - child->rphy = rphy; 862 - get_device(&rphy->dev); 863 - 864 - list_add_tail(&child->disco_list_node, &parent->port->disco_list); 865 - 866 - res = sas_discover_sata(child); 867 - if (res) { 868 - pr_notice("sas_discover_sata() for device %16llx at %016llx:%02d returned 0x%x\n", 869 - SAS_ADDR(child->sas_addr), 870 - SAS_ADDR(parent->sas_addr), phy_id, res); 871 - goto out_list_del; 872 - } 873 - } else 874 - #endif 875 - if (phy->attached_tproto & SAS_PROTOCOL_SSP) { 876 - child->dev_type = SAS_END_DEVICE; 877 - rphy = sas_end_device_alloc(phy->port); 878 - /* FIXME: error handling */ 879 - if (unlikely(!rphy)) 880 - goto out_free; 881 - child->tproto = phy->attached_tproto; 882 - sas_init_dev(child); 883 - 884 - child->rphy = rphy; 885 - get_device(&rphy->dev); 886 - rphy->identify.phy_identifier = phy_id; 887 - sas_fill_in_rphy(child, rphy); 888 - 889 - list_add_tail(&child->disco_list_node, &parent->port->disco_list); 890 - 891 - res = sas_discover_end_dev(child); 892 - if (res) { 893 - pr_notice("sas_discover_end_dev() for device %016llx at %016llx:%02d returned 0x%x\n", 894 - SAS_ADDR(child->sas_addr), 895 - SAS_ADDR(parent->sas_addr), phy_id, res); 896 - goto out_list_del; 897 - } 789 + res = sas_ata_add_dev(parent, phy, child, phy_id); 790 + } else if (phy->attached_tproto & SAS_PROTOCOL_SSP) { 791 + res = sas_ex_add_dev(parent, phy, child, phy_id); 898 792 } else { 899 793 pr_notice("target proto 0x%x at %016llx:0x%x not handled\n", 900 794 phy->attached_tproto, SAS_ADDR(parent->sas_addr), 901 795 phy_id); 902 - goto out_free; 796 + res = -ENODEV; 903 797 } 798 + 799 + if (res) 800 + goto out_free; 904 801 905 802 list_add_tail(&child->siblings, &parent_ex->children); 906 803 return child; 907 804 908 - out_list_del: 909 - sas_rphy_free(child->rphy); 910 - list_del(&child->disco_list_node); 911 - spin_lock_irq(&parent->port->dev_list_lock); 912 - list_del(&child->dev_list_node); 913 - spin_unlock_irq(&parent->port->dev_list_lock); 914 805 out_free: 915 806 sas_port_delete(phy->port); 916 807 out_err:
-1
include/scsi/libsas.h
··· 735 735 void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *); 736 736 void sas_discover_event(struct asd_sas_port *, enum discover_event ev); 737 737 738 - int sas_discover_sata(struct domain_device *); 739 738 int sas_discover_end_dev(struct domain_device *); 740 739 741 740 void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *);
+20
include/scsi/sas_ata.h
··· 36 36 int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, 37 37 int force_phy_id); 38 38 int smp_ata_check_ready_type(struct ata_link *link); 39 + int sas_discover_sata(struct domain_device *dev); 40 + int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, 41 + struct domain_device *child, int phy_id); 39 42 #else 40 43 44 + static inline void sas_ata_disabled_notice(void) 45 + { 46 + pr_notice_once("ATA device seen but CONFIG_SCSI_SAS_ATA=N\n"); 47 + } 41 48 42 49 static inline int dev_is_sata(struct domain_device *dev) 43 50 { ··· 109 102 static inline int smp_ata_check_ready_type(struct ata_link *link) 110 103 { 111 104 return 0; 105 + } 106 + 107 + static inline int sas_discover_sata(struct domain_device *dev) 108 + { 109 + sas_ata_disabled_notice(); 110 + return -ENXIO; 111 + } 112 + 113 + static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, 114 + struct domain_device *child, int phy_id) 115 + { 116 + sas_ata_disabled_notice(); 117 + return -ENODEV; 112 118 } 113 119 #endif 114 120