Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
firewire: Install firewire-constants.h and firewire-cdev.h for userspace.
firewire: Change struct fw_cdev_iso_packet to not use bitfields.
firewire: Implement suspend/resume PCI driver hooks.
firewire: add to MAINTAINERS
firewire: fw-sbp2: implement sysfs ieee1394_id
ieee1394: sbp2: offer SAM-conforming target port ID in sysfs
ieee1394: fix calculation of sysfs attribute "address"

+247 -79
+8
MAINTAINERS
··· 1498 1498 M: viro@zeniv.linux.org.uk 1499 1499 S: Maintained 1500 1500 1501 + FIREWIRE SUBSYSTEM 1502 + P: Kristian Hoegsberg, Stefan Richter 1503 + M: krh@redhat.com, stefanr@s5r6.in-berlin.de 1504 + L: linux1394-devel@lists.sourceforge.net 1505 + W: http://www.linux1394.org/ 1506 + T: git kernel.org:/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git 1507 + S: Maintained 1508 + 1501 1509 FIRMWARE LOADER (request_firmware) 1502 1510 L: linux-kernel@vger.kernel.org 1503 1511 S: Orphan
-5
drivers/firewire/fw-card.c
··· 407 407 card->link_speed = link_speed; 408 408 card->guid = guid; 409 409 410 - /* Activate link_on bit and contender bit in our self ID packets.*/ 411 - if (card->driver->update_phy_reg(card, 4, 0, 412 - PHY_LINK_ACTIVE | PHY_CONTENDER) < 0) 413 - return -EIO; 414 - 415 410 /* 416 411 * The subsystem grabs a reference when the card is added and 417 412 * drops it when the driver calls fw_core_remove_card.
+16 -1
drivers/firewire/fw-cdev.c
··· 677 677 return 0; 678 678 } 679 679 680 + /* Macros for decoding the iso packet control header. */ 681 + #define GET_PAYLOAD_LENGTH(v) ((v) & 0xffff) 682 + #define GET_INTERRUPT(v) (((v) >> 16) & 0x01) 683 + #define GET_SKIP(v) (((v) >> 17) & 0x01) 684 + #define GET_TAG(v) (((v) >> 18) & 0x02) 685 + #define GET_SY(v) (((v) >> 20) & 0x04) 686 + #define GET_HEADER_LENGTH(v) (((v) >> 24) & 0xff) 687 + 680 688 static int ioctl_queue_iso(struct client *client, void *buffer) 681 689 { 682 690 struct fw_cdev_queue_iso *request = buffer; 683 691 struct fw_cdev_iso_packet __user *p, *end, *next; 684 692 struct fw_iso_context *ctx = client->iso_context; 685 693 unsigned long payload, buffer_end, header_length; 694 + u32 control; 686 695 int count; 687 696 struct { 688 697 struct fw_iso_packet packet; ··· 726 717 end = (void __user *)p + request->size; 727 718 count = 0; 728 719 while (p < end) { 729 - if (__copy_from_user(&u.packet, p, sizeof(*p))) 720 + if (get_user(control, &p->control)) 730 721 return -EFAULT; 722 + u.packet.payload_length = GET_PAYLOAD_LENGTH(control); 723 + u.packet.interrupt = GET_INTERRUPT(control); 724 + u.packet.skip = GET_SKIP(control); 725 + u.packet.tag = GET_TAG(control); 726 + u.packet.sy = GET_SY(control); 727 + u.packet.header_length = GET_HEADER_LENGTH(control); 731 728 732 729 if (ctx->type == FW_ISO_CONTEXT_TRANSMIT) { 733 730 header_length = u.packet.header_length;
+1
drivers/firewire/fw-device.h
··· 99 99 #define CSR_DEPENDENT_INFO 0x14 100 100 #define CSR_MODEL 0x17 101 101 #define CSR_INSTANCE 0x18 102 + #define CSR_DIRECTORY_ID 0x20 102 103 103 104 #define SBP2_COMMAND_SET_SPECIFIER 0x38 104 105 #define SBP2_COMMAND_SET 0x39
+123 -64
drivers/firewire/fw-ohci.c
··· 417 417 ctx->current_buffer = ab.next; 418 418 ctx->pointer = ctx->current_buffer->data; 419 419 420 - reg_write(ctx->ohci, COMMAND_PTR(ctx->regs), 421 - le32_to_cpu(ab.descriptor.branch_address)); 420 + return 0; 421 + } 422 + 423 + static void ar_context_run(struct ar_context *ctx) 424 + { 425 + struct ar_buffer *ab = ctx->current_buffer; 426 + dma_addr_t ab_bus; 427 + size_t offset; 428 + 429 + offset = offsetof(struct ar_buffer, data); 430 + ab_bus = ab->descriptor.data_address - offset; 431 + 432 + reg_write(ctx->ohci, COMMAND_PTR(ctx->regs), ab_bus | 1); 422 433 reg_write(ctx->ohci, CONTROL_SET(ctx->regs), CONTEXT_RUN); 423 434 flush_writes(ctx->ohci); 424 - 425 - return 0; 426 435 } 427 436 428 437 static void context_tasklet(unsigned long data) ··· 1048 1039 return IRQ_HANDLED; 1049 1040 } 1050 1041 1042 + static int software_reset(struct fw_ohci *ohci) 1043 + { 1044 + int i; 1045 + 1046 + reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset); 1047 + 1048 + for (i = 0; i < OHCI_LOOP_COUNT; i++) { 1049 + if ((reg_read(ohci, OHCI1394_HCControlSet) & 1050 + OHCI1394_HCControl_softReset) == 0) 1051 + return 0; 1052 + msleep(1); 1053 + } 1054 + 1055 + return -EBUSY; 1056 + } 1057 + 1051 1058 static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) 1052 1059 { 1053 1060 struct fw_ohci *ohci = fw_ohci(card); 1054 1061 struct pci_dev *dev = to_pci_dev(card->device); 1062 + 1063 + if (software_reset(ohci)) { 1064 + fw_error("Failed to reset ohci card.\n"); 1065 + return -EBUSY; 1066 + } 1067 + 1068 + /* 1069 + * Now enable LPS, which we need in order to start accessing 1070 + * most of the registers. In fact, on some cards (ALI M5251), 1071 + * accessing registers in the SClk domain without LPS enabled 1072 + * will lock up the machine. Wait 50msec to make sure we have 1073 + * full link enabled. 1074 + */ 1075 + reg_write(ohci, OHCI1394_HCControlSet, 1076 + OHCI1394_HCControl_LPS | 1077 + OHCI1394_HCControl_postedWriteEnable); 1078 + flush_writes(ohci); 1079 + msleep(50); 1080 + 1081 + reg_write(ohci, OHCI1394_HCControlClear, 1082 + OHCI1394_HCControl_noByteSwapData); 1083 + 1084 + reg_write(ohci, OHCI1394_LinkControlSet, 1085 + OHCI1394_LinkControl_rcvSelfID | 1086 + OHCI1394_LinkControl_cycleTimerEnable | 1087 + OHCI1394_LinkControl_cycleMaster); 1088 + 1089 + reg_write(ohci, OHCI1394_ATRetries, 1090 + OHCI1394_MAX_AT_REQ_RETRIES | 1091 + (OHCI1394_MAX_AT_RESP_RETRIES << 4) | 1092 + (OHCI1394_MAX_PHYS_RESP_RETRIES << 8)); 1093 + 1094 + ar_context_run(&ohci->ar_request_ctx); 1095 + ar_context_run(&ohci->ar_response_ctx); 1096 + 1097 + reg_write(ohci, OHCI1394_SelfIDBuffer, ohci->self_id_bus); 1098 + reg_write(ohci, OHCI1394_PhyUpperBound, 0x00010000); 1099 + reg_write(ohci, OHCI1394_IntEventClear, ~0); 1100 + reg_write(ohci, OHCI1394_IntMaskClear, ~0); 1101 + reg_write(ohci, OHCI1394_IntMaskSet, 1102 + OHCI1394_selfIDComplete | 1103 + OHCI1394_RQPkt | OHCI1394_RSPkt | 1104 + OHCI1394_reqTxComplete | OHCI1394_respTxComplete | 1105 + OHCI1394_isochRx | OHCI1394_isochTx | 1106 + OHCI1394_masterIntEnable | 1107 + OHCI1394_cycle64Seconds); 1108 + 1109 + /* Activate link_on bit and contender bit in our self ID packets.*/ 1110 + if (ohci_update_phy_reg(card, 4, 0, 1111 + PHY_LINK_ACTIVE | PHY_CONTENDER) < 0) 1112 + return -EIO; 1055 1113 1056 1114 /* 1057 1115 * When the link is not yet enabled, the atomic config rom ··· 1777 1701 .stop_iso = ohci_stop_iso, 1778 1702 }; 1779 1703 1780 - static int software_reset(struct fw_ohci *ohci) 1781 - { 1782 - int i; 1783 - 1784 - reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_softReset); 1785 - 1786 - for (i = 0; i < OHCI_LOOP_COUNT; i++) { 1787 - if ((reg_read(ohci, OHCI1394_HCControlSet) & 1788 - OHCI1394_HCControl_softReset) == 0) 1789 - return 0; 1790 - msleep(1); 1791 - } 1792 - 1793 - return -EBUSY; 1794 - } 1795 - 1796 1704 static int __devinit 1797 1705 pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) 1798 1706 { ··· 1822 1762 goto fail_iomem; 1823 1763 } 1824 1764 1825 - if (software_reset(ohci)) { 1826 - fw_error("Failed to reset ohci card.\n"); 1827 - err = -EBUSY; 1828 - goto fail_registers; 1829 - } 1830 - 1831 - /* 1832 - * Now enable LPS, which we need in order to start accessing 1833 - * most of the registers. In fact, on some cards (ALI M5251), 1834 - * accessing registers in the SClk domain without LPS enabled 1835 - * will lock up the machine. Wait 50msec to make sure we have 1836 - * full link enabled. 1837 - */ 1838 - reg_write(ohci, OHCI1394_HCControlSet, 1839 - OHCI1394_HCControl_LPS | 1840 - OHCI1394_HCControl_postedWriteEnable); 1841 - flush_writes(ohci); 1842 - msleep(50); 1843 - 1844 - reg_write(ohci, OHCI1394_HCControlClear, 1845 - OHCI1394_HCControl_noByteSwapData); 1846 - 1847 - reg_write(ohci, OHCI1394_LinkControlSet, 1848 - OHCI1394_LinkControl_rcvSelfID | 1849 - OHCI1394_LinkControl_cycleTimerEnable | 1850 - OHCI1394_LinkControl_cycleMaster); 1851 - 1852 1765 ar_context_init(&ohci->ar_request_ctx, ohci, 1853 1766 OHCI1394_AsReqRcvContextControlSet); 1854 1767 ··· 1833 1800 1834 1801 context_init(&ohci->at_response_ctx, ohci, AT_BUFFER_SIZE, 1835 1802 OHCI1394_AsRspTrContextControlSet, handle_at_packet); 1836 - 1837 - reg_write(ohci, OHCI1394_ATRetries, 1838 - OHCI1394_MAX_AT_REQ_RETRIES | 1839 - (OHCI1394_MAX_AT_RESP_RETRIES << 4) | 1840 - (OHCI1394_MAX_PHYS_RESP_RETRIES << 8)); 1841 1803 1842 1804 reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0); 1843 1805 ohci->it_context_mask = reg_read(ohci, OHCI1394_IsoRecvIntMaskSet); ··· 1862 1834 err = -ENOMEM; 1863 1835 goto fail_registers; 1864 1836 } 1865 - 1866 - reg_write(ohci, OHCI1394_SelfIDBuffer, ohci->self_id_bus); 1867 - reg_write(ohci, OHCI1394_PhyUpperBound, 0x00010000); 1868 - reg_write(ohci, OHCI1394_IntEventClear, ~0); 1869 - reg_write(ohci, OHCI1394_IntMaskClear, ~0); 1870 - reg_write(ohci, OHCI1394_IntMaskSet, 1871 - OHCI1394_selfIDComplete | 1872 - OHCI1394_RQPkt | OHCI1394_RSPkt | 1873 - OHCI1394_reqTxComplete | OHCI1394_respTxComplete | 1874 - OHCI1394_isochRx | OHCI1394_isochTx | 1875 - OHCI1394_masterIntEnable | 1876 - OHCI1394_cycle64Seconds); 1877 1837 1878 1838 bus_options = reg_read(ohci, OHCI1394_BusOptions); 1879 1839 max_receive = (bus_options >> 12) & 0xf; ··· 1924 1908 fw_notify("Removed fw-ohci device.\n"); 1925 1909 } 1926 1910 1911 + #ifdef CONFIG_PM 1912 + static int pci_suspend(struct pci_dev *pdev, pm_message_t state) 1913 + { 1914 + struct fw_ohci *ohci = pci_get_drvdata(pdev); 1915 + int err; 1916 + 1917 + software_reset(ohci); 1918 + free_irq(pdev->irq, ohci); 1919 + err = pci_save_state(pdev); 1920 + if (err) { 1921 + fw_error("pci_save_state failed with %d", err); 1922 + return err; 1923 + } 1924 + err = pci_set_power_state(pdev, pci_choose_state(pdev, state)); 1925 + if (err) { 1926 + fw_error("pci_set_power_state failed with %d", err); 1927 + return err; 1928 + } 1929 + 1930 + return 0; 1931 + } 1932 + 1933 + static int pci_resume(struct pci_dev *pdev) 1934 + { 1935 + struct fw_ohci *ohci = pci_get_drvdata(pdev); 1936 + int err; 1937 + 1938 + pci_set_power_state(pdev, PCI_D0); 1939 + pci_restore_state(pdev); 1940 + err = pci_enable_device(pdev); 1941 + if (err) { 1942 + fw_error("pci_enable_device failed with %d", err); 1943 + return err; 1944 + } 1945 + 1946 + return ohci_enable(&ohci->card, ohci->config_rom, CONFIG_ROM_SIZE); 1947 + } 1948 + #endif 1949 + 1927 1950 static struct pci_device_id pci_table[] = { 1928 1951 { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_FIREWIRE_OHCI, ~0) }, 1929 1952 { } ··· 1975 1920 .id_table = pci_table, 1976 1921 .probe = pci_probe, 1977 1922 .remove = pci_remove, 1923 + #ifdef CONFIG_PM 1924 + .resume = pci_resume, 1925 + .suspend = pci_suspend, 1926 + #endif 1978 1927 }; 1979 1928 1980 1929 MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
+53
drivers/firewire/fw-sbp2.c
··· 1108 1108 return SUCCESS; 1109 1109 } 1110 1110 1111 + /* 1112 + * Format of /sys/bus/scsi/devices/.../ieee1394_id: 1113 + * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal) 1114 + * 1115 + * This is the concatenation of target port identifier and logical unit 1116 + * identifier as per SAM-2...SAM-4 annex A. 1117 + */ 1118 + static ssize_t 1119 + sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, 1120 + char *buf) 1121 + { 1122 + struct scsi_device *sdev = to_scsi_device(dev); 1123 + struct sbp2_device *sd; 1124 + struct fw_unit *unit; 1125 + struct fw_device *device; 1126 + u32 directory_id; 1127 + struct fw_csr_iterator ci; 1128 + int key, value, lun; 1129 + 1130 + if (!sdev) 1131 + return 0; 1132 + sd = (struct sbp2_device *)sdev->host->hostdata; 1133 + unit = sd->unit; 1134 + device = fw_device(unit->device.parent); 1135 + 1136 + /* implicit directory ID */ 1137 + directory_id = ((unit->directory - device->config_rom) * 4 1138 + + CSR_CONFIG_ROM) & 0xffffff; 1139 + 1140 + /* explicit directory ID, overrides implicit ID if present */ 1141 + fw_csr_iterator_init(&ci, unit->directory); 1142 + while (fw_csr_iterator_next(&ci, &key, &value)) 1143 + if (key == CSR_DIRECTORY_ID) { 1144 + directory_id = value; 1145 + break; 1146 + } 1147 + 1148 + /* FIXME: Make this work for multi-lun devices. */ 1149 + lun = 0; 1150 + 1151 + return sprintf(buf, "%08x%08x:%06x:%04x\n", 1152 + device->config_rom[3], device->config_rom[4], 1153 + directory_id, lun); 1154 + } 1155 + 1156 + static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL); 1157 + 1158 + static struct device_attribute *sbp2_scsi_sysfs_attrs[] = { 1159 + &dev_attr_ieee1394_id, 1160 + NULL 1161 + }; 1162 + 1111 1163 static struct scsi_host_template scsi_driver_template = { 1112 1164 .module = THIS_MODULE, 1113 1165 .name = "SBP-2 IEEE-1394", ··· 1173 1121 .use_clustering = ENABLE_CLUSTERING, 1174 1122 .cmd_per_lun = 1, 1175 1123 .can_queue = 1, 1124 + .sdev_attrs = sbp2_scsi_sysfs_attrs, 1176 1125 }; 1177 1126 1178 1127 MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
+6 -1
drivers/ieee1394/nodemgr.c
··· 976 976 977 977 ud->ne = ne; 978 978 ud->ignore_driver = ignore_drivers; 979 - ud->address = ud_kv->offset + CSR1212_CONFIG_ROM_SPACE_BASE; 979 + ud->address = ud_kv->offset + CSR1212_REGISTER_SPACE_BASE; 980 + ud->directory_id = ud->address & 0xffffff; 980 981 ud->ud_kv = ud_kv; 981 982 ud->id = (*id)++; 982 983 ··· 1084 1083 nodemgr_register_device(ne, ud_child, &ud->device); 1085 1084 } 1086 1085 1086 + break; 1087 + 1088 + case CSR1212_KV_ID_DIRECTORY_ID: 1089 + ud->directory_id = kv->value.immediate; 1087 1090 break; 1088 1091 1089 1092 default:
+1
drivers/ieee1394/nodemgr.h
··· 75 75 struct csr1212_keyval *model_name_kv; 76 76 quadlet_t specifier_id; 77 77 quadlet_t version; 78 + quadlet_t directory_id; 78 79 79 80 unsigned int id; 80 81
+29 -2
drivers/ieee1394/sbp2.c
··· 194 194 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE) 195 195 ", or a combination)"); 196 196 197 + /* 198 + * This influences the format of the sysfs attribute 199 + * /sys/bus/scsi/devices/.../ieee1394_id. 200 + * 201 + * The default format is like in older kernels: %016Lx:%d:%d 202 + * It contains the target's EUI-64, a number given to the logical unit by 203 + * the ieee1394 driver's nodemgr (starting at 0), and the LUN. 204 + * 205 + * The long format is: %016Lx:%06x:%04x 206 + * It contains the target's EUI-64, the unit directory's directory_ID as per 207 + * IEEE 1212 clause 7.7.19, and the LUN. This format comes closest to the 208 + * format of SBP(-3) target port and logical unit identifier as per SAM (SCSI 209 + * Architecture Model) rev.2 to 4 annex A. Therefore and because it is 210 + * independent of the implementation of the ieee1394 nodemgr, the longer format 211 + * is recommended for future use. 212 + */ 213 + static int sbp2_long_sysfs_ieee1394_id; 214 + module_param_named(long_ieee1394_id, sbp2_long_sysfs_ieee1394_id, bool, 0644); 215 + MODULE_PARM_DESC(long_ieee1394_id, "8+3+2 bytes format of ieee1394_id in sysfs " 216 + "(default = backwards-compatible = N, SAM-conforming = Y)"); 217 + 197 218 198 219 #define SBP2_INFO(fmt, args...) HPSB_INFO("sbp2: "fmt, ## args) 199 220 #define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) ··· 2121 2100 if (!(lu = (struct sbp2_lu *)sdev->host->hostdata[0])) 2122 2101 return 0; 2123 2102 2124 - return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)lu->ne->guid, 2125 - lu->ud->id, ORB_SET_LUN(lu->lun)); 2103 + if (sbp2_long_sysfs_ieee1394_id) 2104 + return sprintf(buf, "%016Lx:%06x:%04x\n", 2105 + (unsigned long long)lu->ne->guid, 2106 + lu->ud->directory_id, ORB_SET_LUN(lu->lun)); 2107 + else 2108 + return sprintf(buf, "%016Lx:%d:%d\n", 2109 + (unsigned long long)lu->ne->guid, 2110 + lu->ud->id, ORB_SET_LUN(lu->lun)); 2126 2111 } 2127 2112 2128 2113 MODULE_AUTHOR("Ben Collins <bcollins@debian.org>");
+2
include/linux/Kbuild
··· 62 62 header-y += fd.h 63 63 header-y += fdreg.h 64 64 header-y += fib_rules.h 65 + header-y += firewire-cdev.h 66 + header-y += firewire-constants.h 65 67 header-y += fuse.h 66 68 header-y += genetlink.h 67 69 header-y += gen_stats.h
+8 -6
include/linux/firewire-cdev.h
··· 198 198 __u32 handle; 199 199 }; 200 200 201 + #define FW_CDEV_ISO_PAYLOAD_LENGTH(v) (v) 202 + #define FW_CDEV_ISO_INTERRUPT (1 << 16) 203 + #define FW_CDEV_ISO_SKIP (1 << 17) 204 + #define FW_CDEV_ISO_TAG(v) ((v) << 18) 205 + #define FW_CDEV_ISO_SY(v) ((v) << 20) 206 + #define FW_CDEV_ISO_HEADER_LENGTH(v) ((v) << 24) 207 + 201 208 struct fw_cdev_iso_packet { 202 - __u16 payload_length; /* Length of indirect payload. */ 203 - __u32 interrupt : 1; /* Generate interrupt on this packet */ 204 - __u32 skip : 1; /* Set to not send packet at all. */ 205 - __u32 tag : 2; 206 - __u32 sy : 4; 207 - __u32 header_length : 8; /* Length of immediate header. */ 209 + __u32 control; 208 210 __u32 header[0]; 209 211 }; 210 212