···596596 static int pil_to_sbus[] = {597597 0, 0, 1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 0,598598 };599599- struct device_node *busp = dp->parent;599599+ struct device_node *io_unit, *sbi = dp->parent;600600 struct linux_prom_registers *regs;601601- int board = of_getintprop_default(busp, "board#", 0);602602- int slot;601601+ int board, slot;602602+603603+ while (sbi) {604604+ if (!strcmp(sbi->name, "sbi"))605605+ break;606606+607607+ sbi = sbi->parent;608608+ }609609+ if (!sbi)610610+ goto build_resources;603611604612 regs = of_get_property(dp, "reg", NULL);613613+ if (!regs)614614+ goto build_resources;615615+605616 slot = regs->which_io;617617+618618+ /* If SBI's parent is not io-unit or the io-unit lacks619619+ * a "board#" property, something is very wrong.620620+ */621621+ if (!sbi->parent || strcmp(sbi->parent->name, "io-unit")) {622622+ printk("%s: Error, parent is not io-unit.\n",623623+ sbi->full_name);624624+ goto build_resources;625625+ }626626+ io_unit = sbi->parent;627627+ board = of_getintprop_default(io_unit, "board#", -1);628628+ if (board == -1) {629629+ printk("%s: Error, lacks board# property.\n",630630+ io_unit->full_name);631631+ goto build_resources;632632+ }606633607634 for (i = 0; i < op->num_irqs; i++) {608635 int this_irq = op->irqs[i];···644617 }645618 }646619620620+build_resources:647621 build_device_resources(op, parent);648622649623 op->dev.parent = parent;
+6-3
arch/sparc/kernel/prom.c
···444444 static struct property *tmp = NULL;445445 struct property *p;446446 int len;447447+ const char *name;447448448449 if (tmp) {449450 p = tmp;···457456458457 p->name = (char *) (p + 1);459458 if (special_name) {459459+ strcpy(p->name, special_name);460460 p->length = special_len;461461 p->value = prom_early_alloc(special_len);462462 memcpy(p->value, special_val, special_len);463463 } else {464464 if (prev == NULL) {465465- prom_firstprop(node, p->name);465465+ name = prom_firstprop(node, NULL);466466 } else {467467- prom_nextprop(node, prev, p->name);467467+ name = prom_nextprop(node, prev, NULL);468468 }469469- if (strlen(p->name) == 0) {469469+ if (strlen(name) == 0) {470470 tmp = p;471471 return NULL;472472 }473473+ strcpy(p->name, name);473474 p->length = prom_getproplen(node, p->name);474475 if (p->length <= 0) {475476 p->length = 0;
+88-6
arch/sparc/kernel/smp.c
···8787void __init smp_cpus_done(unsigned int max_cpus)8888{8989 extern void smp4m_smp_done(void);9090+ extern void smp4d_smp_done(void);9091 unsigned long bogosum = 0;9192 int cpu, num;9293···101100 num, bogosum/(500000/HZ),102101 (bogosum/(5000/HZ))%100);103102104104- BUG_ON(sparc_cpu_model != sun4m);105105- smp4m_smp_done();103103+ switch(sparc_cpu_model) {104104+ case sun4:105105+ printk("SUN4\n");106106+ BUG();107107+ break;108108+ case sun4c:109109+ printk("SUN4C\n");110110+ BUG();111111+ break;112112+ case sun4m:113113+ smp4m_smp_done();114114+ break;115115+ case sun4d:116116+ smp4d_smp_done();117117+ break;118118+ case sun4e:119119+ printk("SUN4E\n");120120+ BUG();121121+ break;122122+ case sun4u:123123+ printk("SUN4U\n");124124+ BUG();125125+ break;126126+ default:127127+ printk("UNKNOWN!\n");128128+ BUG();129129+ break;130130+ };106131}107132108133void cpu_panic(void)···294267void __init smp_prepare_cpus(unsigned int max_cpus)295268{296269 extern void smp4m_boot_cpus(void);270270+ extern void smp4d_boot_cpus(void);297271 int i, cpuid, extra;298272299299- BUG_ON(sparc_cpu_model != sun4m);300273 printk("Entering SMP Mode...\n");301274302275 extra = 0;···310283311284 smp_store_cpu_info(boot_cpu_id);312285313313- smp4m_boot_cpus();286286+ switch(sparc_cpu_model) {287287+ case sun4:288288+ printk("SUN4\n");289289+ BUG();290290+ break;291291+ case sun4c:292292+ printk("SUN4C\n");293293+ BUG();294294+ break;295295+ case sun4m:296296+ smp4m_boot_cpus();297297+ break;298298+ case sun4d:299299+ smp4d_boot_cpus();300300+ break;301301+ case sun4e:302302+ printk("SUN4E\n");303303+ BUG();304304+ break;305305+ case sun4u:306306+ printk("SUN4U\n");307307+ BUG();308308+ break;309309+ default:310310+ printk("UNKNOWN!\n");311311+ BUG();312312+ break;313313+ };314314}315315316316/* Set this up early so that things like the scheduler can init···377323int __cpuinit __cpu_up(unsigned int cpu)378324{379325 extern int smp4m_boot_one_cpu(int);380380- int ret;326326+ extern int smp4d_boot_one_cpu(int);327327+ int ret=0;381328382382- ret = smp4m_boot_one_cpu(cpu);329329+ switch(sparc_cpu_model) {330330+ case sun4:331331+ printk("SUN4\n");332332+ BUG();333333+ break;334334+ case sun4c:335335+ printk("SUN4C\n");336336+ BUG();337337+ break;338338+ case sun4m:339339+ ret = smp4m_boot_one_cpu(cpu);340340+ break;341341+ case sun4d:342342+ ret = smp4d_boot_one_cpu(cpu);343343+ break;344344+ case sun4e:345345+ printk("SUN4E\n");346346+ BUG();347347+ break;348348+ case sun4u:349349+ printk("SUN4U\n");350350+ BUG();351351+ break;352352+ default:353353+ printk("UNKNOWN!\n");354354+ BUG();355355+ break;356356+ };383357384358 if (!ret) {385359 cpu_set(cpu, smp_commenced_mask);
···205205 return 0;206206}207207208208-/* Gets name in the form prom v2+ uses it (name@x,yyyyy or name (if no reg)) */209209-int prom_getname (int node, char *buffer, int len)210210-{211211- int i;212212- struct linux_prom_registers reg[PROMREG_MAX];213213-214214- i = prom_getproperty (node, "name", buffer, len);215215- if (i <= 0) return -1;216216- buffer [i] = 0;217217- len -= i;218218- i = prom_getproperty (node, "reg", (char *)reg, sizeof (reg));219219- if (i <= 0) return 0;220220- if (len < 11) return -1;221221- buffer = strchr (buffer, 0);222222- sprintf (buffer, "@%x,%x", reg[0].which_io, (uint)reg[0].phys_addr);223223- return 0;224224-}225225-226208/* Interal version of nextprop that does not alter return values. */227209char * __prom_nextprop(int node, char * oprop)228210{
+4-4
arch/sparc64/defconfig
···11#22# Automatically generated make config: don't edit33-# Linux kernel version: 2.6.18-rc144-# Wed Jul 12 14:00:58 200633+# Linux kernel version: 2.6.18-rc244+# Fri Jul 21 14:19:24 200655#66CONFIG_SPARC=y77CONFIG_SPARC64=y···3636CONFIG_SYSVIPC=y3737CONFIG_POSIX_MQUEUE=y3838# CONFIG_BSD_PROCESS_ACCT is not set3939+# CONFIG_TASKSTATS is not set3940CONFIG_SYSCTL=y4041# CONFIG_AUDIT is not set4142# CONFIG_IKCONFIG is not set···11211120# CONFIG_USB_LEGOTOWER is not set11221121# CONFIG_USB_LCD is not set11231122# CONFIG_USB_LED is not set11241124-# CONFIG_USB_CY7C63 is not set11231123+# CONFIG_USB_CYPRESS_CY7C63 is not set11251124# CONFIG_USB_CYTHERM is not set11261125# CONFIG_USB_PHIDGETKIT is not set11271126# CONFIG_USB_PHIDGETSERVO is not set···12801279# CONFIG_NFSD is not set12811280# CONFIG_SMB_FS is not set12821281# CONFIG_CIFS is not set12831283-# CONFIG_CIFS_DEBUG2 is not set12841282# CONFIG_NCP_FS is not set12851283# CONFIG_CODA_FS is not set12861284# CONFIG_AFS_FS is not set
-3
arch/sparc64/kernel/devices.c
···6666 void *compare_arg,6767 struct device_node **dev_node, int *mid)6868{6969- if (strcmp(dp->type, "cpu"))7070- return -ENODEV;7171-7269 if (!compare(dp, *cur_inst, compare_arg)) {7370 if (dev_node)7471 *dev_node = dp;
+32-2
arch/sparc64/kernel/of_device.c
···542542 /* Convert to num-cells. */543543 num_reg /= 4;544544545545- /* Conver to num-entries. */545545+ /* Convert to num-entries. */546546 num_reg /= na + ns;547547+548548+ /* Prevent overruning the op->resources[] array. */549549+ if (num_reg > PROMREG_MAX) {550550+ printk(KERN_WARNING "%s: Too many regs (%d), "551551+ "limiting to %d.\n",552552+ op->node->full_name, num_reg, PROMREG_MAX);553553+ num_reg = PROMREG_MAX;554554+ }547555548556 for (index = 0; index < num_reg; index++) {549557 struct resource *r = &op->resource[index];···658650 next:659651 imap += (na + 3);660652 }661661- if (i == imlen)653653+ if (i == imlen) {654654+ /* Psycho and Sabre PCI controllers can have 'interrupt-map'655655+ * properties that do not include the on-board device656656+ * interrupts. Instead, the device's 'interrupts' property657657+ * is already a fully specified INO value.658658+ *659659+ * Handle this by deciding that, if we didn't get a660660+ * match in the parent's 'interrupt-map', and the661661+ * parent is an IRQ translater, then use the parent as662662+ * our IRQ controller.663663+ */664664+ if (pp->irq_trans)665665+ return pp;666666+662667 return NULL;668668+ }663669664670 *irq_p = irq;665671 cp = of_find_node_by_phandle(handle);···823801 op->num_irqs = len / 4;824802 } else {825803 op->num_irqs = 0;804804+ }805805+806806+ /* Prevent overruning the op->irqs[] array. */807807+ if (op->num_irqs > PROMINTR_MAX) {808808+ printk(KERN_WARNING "%s: Too many irqs (%d), "809809+ "limiting to %d.\n",810810+ dp->full_name, op->num_irqs, PROMINTR_MAX);811811+ op->num_irqs = PROMINTR_MAX;826812 }827813828814 build_device_resources(op, parent);
···17521752 spin_lock_irqsave(&info->lock, flags);17531753 get_signals(info);17541754 spin_unlock_irqrestore(&info->lock, flags);17551755- hdlc_set_carrier(info->serial_signals & SerialSignal_DCD, dev);17561756-17551755+ if (info->serial_signals & SerialSignal_DCD)17561756+ netif_carrier_on(dev);17571757+ else17581758+ netif_carrier_off(dev);17571759 return 0;17581760}17591761···25242522 } else25252523 info->input_signal_events.dcd_down++;25262524#ifdef CONFIG_HDLC25272527- if (info->netcount)25282528- hdlc_set_carrier(status & SerialSignal_DCD, info->netdev);25252525+ if (info->netcount) {25262526+ if (status & SerialSignal_DCD)25272527+ netif_carrier_on(info->netdev);25282528+ else25292529+ netif_carrier_off(info->netdev);25302530+ }25292531#endif25302532 }25312533 if (status & MISCSTATUS_CTS_LATCHED)
+10-6
drivers/cpufreq/cpufreq_ondemand.c
···239239 total_ticks = (unsigned int) cputime64_sub(cur_jiffies,240240 this_dbs_info->prev_cpu_wall);241241 this_dbs_info->prev_cpu_wall = cur_jiffies;242242+ if (!total_ticks)243243+ return;242244 /*243245 * Every sampling_rate, we check, if current idle time is less244246 * than 20% (default), then we try to increase frequency···306304 unsigned int cpu = smp_processor_id();307305 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu);308306307307+ if (!dbs_info->enable)308308+ return;309309+309310 dbs_check_cpu(dbs_info);310311 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work,311312 usecs_to_jiffies(dbs_tuners_ins.sampling_rate));···324319 return;325320}326321327327-static inline void dbs_timer_exit(unsigned int cpu)322322+static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)328323{329329- struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu);330330-331331- cancel_rearming_delayed_workqueue(kondemand_wq, &dbs_info->work);324324+ dbs_info->enable = 0;325325+ cancel_delayed_work(&dbs_info->work);326326+ flush_workqueue(kondemand_wq);332327}333328334329static int cpufreq_governor_dbs(struct cpufreq_policy *policy,···401396402397 case CPUFREQ_GOV_STOP:403398 mutex_lock(&dbs_mutex);404404- dbs_timer_exit(policy->cpu);405405- this_dbs_info->enable = 0;399399+ dbs_timer_exit(this_dbs_info);406400 sysfs_remove_group(&policy->kobj, &dbs_attr_group);407401 dbs_enable--;408402 if (dbs_enable == 0)
+1-1
drivers/dma/ioatdma.c
···828828 /* if forced, worst case is that rmmod hangs */829829 __unsafe(THIS_MODULE);830830831831- return pci_module_init(&ioat_pci_drv);831831+ return pci_register_driver(&ioat_pci_drv);832832}833833834834module_init(ioat_init_module);
···23322332}2333233323342334/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/23352335-/* Prototype Routine for the HP HOST INFO command.23352335+/* Prototype Routine for the HOST INFO command.23362336 *23372337 * Outputs: None.23382338 * Return: 0 if successful···25682568}2569256925702570/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/25712571-/* Prototype Routine for the HP TARGET INFO command.25712571+/* Prototype Routine for the TARGET INFO command.25722572 *25732573 * Outputs: None.25742574 * Return: 0 if successful
-5
drivers/message/fusion/mptctl.h
···354354355355356356/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/357357-/*358358- * HP Specific IOCTL Defines and Structures359359- */360357361358#define CPQFCTS_IOC_MAGIC 'Z'362359#define HP_IOC_MAGIC 'Z'···361364#define HP_GETHOSTINFO1 _IOR(HP_IOC_MAGIC, 20, hp_host_info_rev0_t)362365#define HP_GETTARGETINFO _IOR(HP_IOC_MAGIC, 21, hp_target_info_t)363366364364-/* All HP IOCTLs must include this header365365- */366367typedef struct _hp_header {367368 unsigned int iocnum;368369 unsigned int host;
···132132 for (i = 0; i < numdummies && !err; i++)133133 err = dummy_init_one(i); 134134 if (err) { 135135+ i--;135136 while (--i >= 0)136137 dummy_free_one(i);137138 }
+3
drivers/net/e1000/e1000.h
···110110#define E1000_MIN_RXD 80111111#define E1000_MAX_82544_RXD 4096112112113113+/* this is the size past which hardware will drop packets when setting LPE=0 */114114+#define MAXIMUM_ETHERNET_VLAN_SIZE 1522115115+113116/* Supported Rx Buffer Sizes */114117#define E1000_RXBUFFER_128 128 /* Used for packet split */115118#define E1000_RXBUFFER_256 256 /* Used for packet split */
+26-26
drivers/net/e1000/e1000_main.c
···3636#else3737#define DRIVERNAPI "-NAPI"3838#endif3939-#define DRV_VERSION "7.1.9-k2"DRIVERNAPI3939+#define DRV_VERSION "7.1.9-k4"DRIVERNAPI4040char e1000_driver_version[] = DRV_VERSION;4141static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";4242···1068106810691069 pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);1070107010711071- adapter->rx_buffer_len = MAXIMUM_ETHERNET_FRAME_SIZE;10711071+ adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;10721072 adapter->rx_ps_bsize0 = E1000_RXBUFFER_128;10731073 hw->max_frame_size = netdev->mtu +10741074 ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;···31483148 adapter->rx_buffer_len = E1000_RXBUFFER_16384;3149314931503150 /* adjust allocation if LPE protects us, and we aren't using SBP */31513151-#define MAXIMUM_ETHERNET_VLAN_SIZE 152231523151 if (!adapter->hw.tbi_compatibility_on &&31533152 ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) ||31543153 (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE)))···33863387 E1000_WRITE_REG(hw, IMC, ~0);33873388 E1000_WRITE_FLUSH(hw);33883389 }33893389- if (likely(netif_rx_schedule_prep(&adapter->polling_netdev[0])))33903390- __netif_rx_schedule(&adapter->polling_netdev[0]);33903390+ if (likely(netif_rx_schedule_prep(netdev)))33913391+ __netif_rx_schedule(netdev);33913392 else33923393 e1000_irq_enable(adapter);33933394#else···34303431{34313432 struct e1000_adapter *adapter;34323433 int work_to_do = min(*budget, poll_dev->quota);34333433- int tx_cleaned = 0, i = 0, work_done = 0;34343434+ int tx_cleaned = 0, work_done = 0;3434343534353436 /* Must NOT use netdev_priv macro here. */34363437 adapter = poll_dev->priv;3437343834383439 /* Keep link state information with original netdev */34393439- if (!netif_carrier_ok(adapter->netdev))34403440+ if (!netif_carrier_ok(poll_dev))34403441 goto quit_polling;3441344234423442- while (poll_dev != &adapter->polling_netdev[i]) {34433443- i++;34443444- BUG_ON(i == adapter->num_rx_queues);34433443+ /* e1000_clean is called per-cpu. This lock protects34443444+ * tx_ring[0] from being cleaned by multiple cpus34453445+ * simultaneously. A failure obtaining the lock means34463446+ * tx_ring[0] is currently being cleaned anyway. */34473447+ if (spin_trylock(&adapter->tx_queue_lock)) {34483448+ tx_cleaned = e1000_clean_tx_irq(adapter,34493449+ &adapter->tx_ring[0]);34503450+ spin_unlock(&adapter->tx_queue_lock);34453451 }3446345234473447- if (likely(adapter->num_tx_queues == 1)) {34483448- /* e1000_clean is called per-cpu. This lock protects34493449- * tx_ring[0] from being cleaned by multiple cpus34503450- * simultaneously. A failure obtaining the lock means34513451- * tx_ring[0] is currently being cleaned anyway. */34523452- if (spin_trylock(&adapter->tx_queue_lock)) {34533453- tx_cleaned = e1000_clean_tx_irq(adapter,34543454- &adapter->tx_ring[0]);34553455- spin_unlock(&adapter->tx_queue_lock);34563456- }34573457- } else34583458- tx_cleaned = e1000_clean_tx_irq(adapter, &adapter->tx_ring[i]);34593459-34603460- adapter->clean_rx(adapter, &adapter->rx_ring[i],34533453+ adapter->clean_rx(adapter, &adapter->rx_ring[0],34613454 &work_done, work_to_do);3462345534633456 *budget -= work_done;···3457346634583467 /* If no Tx and not enough Rx work done, exit the polling mode */34593468 if ((!tx_cleaned && (work_done == 0)) ||34603460- !netif_running(adapter->netdev)) {34693469+ !netif_running(poll_dev)) {34613470quit_polling:34623471 netif_rx_complete(poll_dev);34633472 e1000_irq_enable(adapter);···3672368136733682 length = le16_to_cpu(rx_desc->length);3674368336843684+ /* adjust length to remove Ethernet CRC */36853685+ length -= 4;36863686+36753687 if (unlikely(!(status & E1000_RXD_STAT_EOP))) {36763688 /* All receives must fit into a single buffer */36773689 E1000_DBG("%s: Receive packet consumed multiple"···38793885 pci_dma_sync_single_for_device(pdev,38803886 ps_page_dma->ps_page_dma[0],38813887 PAGE_SIZE, PCI_DMA_FROMDEVICE);38883888+ /* remove the CRC */38893889+ l1 -= 4;38823890 skb_put(skb, l1);38833883- length += l1;38843891 goto copydone;38853892 } /* if */38863893 }···38993904 skb->data_len += length;39003905 skb->truesize += length;39013906 }39073907+39083908+ /* strip the ethernet crc, problem is we're using pages now so39093909+ * this whole operation can get a little cpu intensive */39103910+ pskb_trim(skb, skb->len - 4);3902391139033912copydone:39043913 e1000_rx_checksum(adapter, staterr,···47514752e1000_netpoll(struct net_device *netdev)47524753{47534754 struct e1000_adapter *adapter = netdev_priv(netdev);47554755+47544756 disable_irq(adapter->pdev->irq);47554757 e1000_intr(adapter->pdev->irq, netdev, NULL);47564758 e1000_clean_tx_irq(adapter, adapter->tx_ring);
+1
drivers/net/ifb.c
···271271 for (i = 0; i < numifbs && !err; i++)272272 err = ifb_init_one(i); 273273 if (err) { 274274+ i--;274275 while (--i >= 0)275276 ifb_free_one(i);276277 }
···8484 *8585 * returns the content of the specified SMMIO register.8686 */8787-static u328787+static inline u328888spider_net_read_reg(struct spider_net_card *card, u32 reg)8989{9090 u32 value;···101101 * @reg: register to write to102102 * @value: value to write into the specified SMMIO register103103 */104104-static void104104+static inline void105105spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value)106106{107107 value = cpu_to_le32(value);···259259 *260260 * returns the status as in the dmac_cmd_status field of the descriptor261261 */262262-static enum spider_net_descr_status262262+static inline int263263spider_net_get_descr_status(struct spider_net_descr *descr)264264{265265- u32 cmd_status;266266-267267- cmd_status = descr->dmac_cmd_status;268268- cmd_status >>= SPIDER_NET_DESCR_IND_PROC_SHIFT;269269- /* no need to mask out any bits, as cmd_status is 32 bits wide only270270- * (and unsigned) */271271- return cmd_status;272272-}273273-274274-/**275275- * spider_net_set_descr_status -- sets the status of a descriptor276276- * @descr: descriptor to change277277- * @status: status to set in the descriptor278278- *279279- * changes the status to the specified value. Doesn't change other bits280280- * in the status281281- */282282-static void283283-spider_net_set_descr_status(struct spider_net_descr *descr,284284- enum spider_net_descr_status status)285285-{286286- u32 cmd_status;287287- /* read the status */288288- cmd_status = descr->dmac_cmd_status;289289- /* clean the upper 4 bits */290290- cmd_status &= SPIDER_NET_DESCR_IND_PROC_MASKO;291291- /* add the status to it */292292- cmd_status |= ((u32)status)<<SPIDER_NET_DESCR_IND_PROC_SHIFT;293293- /* and write it back */294294- descr->dmac_cmd_status = cmd_status;265265+ return descr->dmac_cmd_status & SPIDER_NET_DESCR_IND_PROC_MASK;295266}296267297268/**···299328static int300329spider_net_init_chain(struct spider_net_card *card,301330 struct spider_net_descr_chain *chain,302302- struct spider_net_descr *start_descr, int no)331331+ struct spider_net_descr *start_descr,332332+ int direction, int no)303333{304334 int i;305335 struct spider_net_descr *descr;306336 dma_addr_t buf;307307-308308- atomic_set(&card->rx_chain_refill,0);309337310338 descr = start_descr;311339 memset(descr, 0, sizeof(*descr) * no);312340313341 /* set up the hardware pointers in each descriptor */314342 for (i=0; i<no; i++, descr++) {315315- spider_net_set_descr_status(descr, SPIDER_NET_DESCR_NOT_IN_USE);343343+ descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;316344317345 buf = pci_map_single(card->pdev, descr,318346 SPIDER_NET_DESCR_SIZE,319319- PCI_DMA_BIDIRECTIONAL);347347+ direction);320348321349 if (buf == DMA_ERROR_CODE)322350 goto iommu_error;···330360 start_descr->prev = descr-1;331361332362 descr = start_descr;333333- for (i=0; i < no; i++, descr++) {334334- descr->next_descr_addr = descr->next->bus_addr;335335- }363363+ if (direction == PCI_DMA_FROMDEVICE)364364+ for (i=0; i < no; i++, descr++)365365+ descr->next_descr_addr = descr->next->bus_addr;336366367367+ spin_lock_init(&chain->lock);337368 chain->head = start_descr;338369 chain->tail = start_descr;339370···346375 if (descr->bus_addr)347376 pci_unmap_single(card->pdev, descr->bus_addr,348377 SPIDER_NET_DESCR_SIZE,349349- PCI_DMA_BIDIRECTIONAL);378378+ direction);350379 return -ENOMEM;351380}352381···367396 dev_kfree_skb(descr->skb);368397 pci_unmap_single(card->pdev, descr->buf_addr,369398 SPIDER_NET_MAX_FRAME,370370- PCI_DMA_BIDIRECTIONAL);399399+ PCI_DMA_FROMDEVICE);371400 }372401 descr = descr->next;373402 }···417446 skb_reserve(descr->skb, SPIDER_NET_RXBUF_ALIGN - offset);418447 /* io-mmu-map the skb */419448 buf = pci_map_single(card->pdev, descr->skb->data,420420- SPIDER_NET_MAX_FRAME, PCI_DMA_BIDIRECTIONAL);449449+ SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);421450 descr->buf_addr = buf;422451 if (buf == DMA_ERROR_CODE) {423452 dev_kfree_skb_any(descr->skb);424453 if (netif_msg_rx_err(card) && net_ratelimit())425454 pr_err("Could not iommu-map rx buffer\n");426426- spider_net_set_descr_status(descr, SPIDER_NET_DESCR_NOT_IN_USE);455455+ descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;427456 } else {428428- descr->dmac_cmd_status = SPIDER_NET_DMAC_RX_CARDOWNED;457457+ descr->dmac_cmd_status = SPIDER_NET_DESCR_CARDOWNED |458458+ SPIDER_NET_DMAC_NOINTR_COMPLETE;429459 }430460431461 return error;···440468 * chip by writing to the appropriate register. DMA is enabled in441469 * spider_net_enable_rxdmac.442470 */443443-static void471471+static inline void444472spider_net_enable_rxchtails(struct spider_net_card *card)445473{446474 /* assume chain is aligned correctly */···455483 * spider_net_enable_rxdmac enables the DMA controller by setting RX_DMA_EN456484 * in the GDADMACCNTR register457485 */458458-static void486486+static inline void459487spider_net_enable_rxdmac(struct spider_net_card *card)460488{461489 wmb();···472500static void473501spider_net_refill_rx_chain(struct spider_net_card *card)474502{475475- struct spider_net_descr_chain *chain;476476-477477- chain = &card->rx_chain;503503+ struct spider_net_descr_chain *chain = &card->rx_chain;504504+ unsigned long flags;478505479506 /* one context doing the refill (and a second context seeing that480507 * and omitting it) is ok. If called by NAPI, we'll be called again481508 * as spider_net_decode_one_descr is called several times. If some482509 * interrupt calls us, the NAPI is about to clean up anyway. */483483- if (atomic_inc_return(&card->rx_chain_refill) == 1)484484- while (spider_net_get_descr_status(chain->head) ==485485- SPIDER_NET_DESCR_NOT_IN_USE) {486486- if (spider_net_prepare_rx_descr(card, chain->head))487487- break;488488- chain->head = chain->head->next;489489- }510510+ if (!spin_trylock_irqsave(&chain->lock, flags))511511+ return;490512491491- atomic_dec(&card->rx_chain_refill);513513+ while (spider_net_get_descr_status(chain->head) ==514514+ SPIDER_NET_DESCR_NOT_IN_USE) {515515+ if (spider_net_prepare_rx_descr(card, chain->head))516516+ break;517517+ chain->head = chain->head->next;518518+ }519519+520520+ spin_unlock_irqrestore(&chain->lock, flags);492521}493522494523/**···524551error:525552 spider_net_free_rx_chain_contents(card);526553 return result;527527-}528528-529529-/**530530- * spider_net_release_tx_descr - processes a used tx descriptor531531- * @card: card structure532532- * @descr: descriptor to release533533- *534534- * releases a used tx descriptor (unmapping, freeing of skb)535535- */536536-static void537537-spider_net_release_tx_descr(struct spider_net_card *card,538538- struct spider_net_descr *descr)539539-{540540- struct sk_buff *skb;541541-542542- /* unmap the skb */543543- skb = descr->skb;544544- pci_unmap_single(card->pdev, descr->buf_addr, skb->len,545545- PCI_DMA_BIDIRECTIONAL);546546-547547- dev_kfree_skb_any(skb);548548-549549- /* set status to not used */550550- spider_net_set_descr_status(descr, SPIDER_NET_DESCR_NOT_IN_USE);551551-}552552-553553-/**554554- * spider_net_release_tx_chain - processes sent tx descriptors555555- * @card: adapter structure556556- * @brutal: if set, don't care about whether descriptor seems to be in use557557- *558558- * returns 0 if the tx ring is empty, otherwise 1.559559- *560560- * spider_net_release_tx_chain releases the tx descriptors that spider has561561- * finished with (if non-brutal) or simply release tx descriptors (if brutal).562562- * If some other context is calling this function, we return 1 so that we're563563- * scheduled again (if we were scheduled) and will not loose initiative.564564- */565565-static int566566-spider_net_release_tx_chain(struct spider_net_card *card, int brutal)567567-{568568- struct spider_net_descr_chain *tx_chain = &card->tx_chain;569569- enum spider_net_descr_status status;570570-571571- if (atomic_inc_return(&card->tx_chain_release) != 1) {572572- atomic_dec(&card->tx_chain_release);573573- return 1;574574- }575575-576576- for (;;) {577577- status = spider_net_get_descr_status(tx_chain->tail);578578- switch (status) {579579- case SPIDER_NET_DESCR_CARDOWNED:580580- if (!brutal)581581- goto out;582582- /* fallthrough, if we release the descriptors583583- * brutally (then we don't care about584584- * SPIDER_NET_DESCR_CARDOWNED) */585585- case SPIDER_NET_DESCR_RESPONSE_ERROR:586586- case SPIDER_NET_DESCR_PROTECTION_ERROR:587587- case SPIDER_NET_DESCR_FORCE_END:588588- if (netif_msg_tx_err(card))589589- pr_err("%s: forcing end of tx descriptor "590590- "with status x%02x\n",591591- card->netdev->name, status);592592- card->netdev_stats.tx_dropped++;593593- break;594594-595595- case SPIDER_NET_DESCR_COMPLETE:596596- card->netdev_stats.tx_packets++;597597- card->netdev_stats.tx_bytes +=598598- tx_chain->tail->skb->len;599599- break;600600-601601- default: /* any other value (== SPIDER_NET_DESCR_NOT_IN_USE) */602602- goto out;603603- }604604- spider_net_release_tx_descr(card, tx_chain->tail);605605- tx_chain->tail = tx_chain->tail->next;606606- }607607-out:608608- atomic_dec(&card->tx_chain_release);609609-610610- netif_wake_queue(card->netdev);611611-612612- if (status == SPIDER_NET_DESCR_CARDOWNED)613613- return 1;614614- return 0;615615-}616616-617617-/**618618- * spider_net_cleanup_tx_ring - cleans up the TX ring619619- * @card: card structure620620- *621621- * spider_net_cleanup_tx_ring is called by the tx_timer (as we don't use622622- * interrupts to cleanup our TX ring) and returns sent packets to the stack623623- * by freeing them624624- */625625-static void626626-spider_net_cleanup_tx_ring(struct spider_net_card *card)627627-{628628- if ( (spider_net_release_tx_chain(card, 0)) &&629629- (card->netdev->flags & IFF_UP) ) {630630- mod_timer(&card->tx_timer, jiffies + SPIDER_NET_TX_TIMER);631631- }632554}633555634556/**···629761}630762631763/**632632- * spider_net_stop - called upon ifconfig down633633- * @netdev: interface device structure634634- *635635- * always returns 0636636- */637637-int638638-spider_net_stop(struct net_device *netdev)639639-{640640- struct spider_net_card *card = netdev_priv(netdev);641641-642642- tasklet_kill(&card->rxram_full_tl);643643- netif_poll_disable(netdev);644644- netif_carrier_off(netdev);645645- netif_stop_queue(netdev);646646- del_timer_sync(&card->tx_timer);647647-648648- /* disable/mask all interrupts */649649- spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0);650650- spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0);651651- spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0);652652-653653- /* free_irq(netdev->irq, netdev);*/654654- free_irq(to_pci_dev(netdev->class_dev.dev)->irq, netdev);655655-656656- spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,657657- SPIDER_NET_DMA_TX_FEND_VALUE);658658-659659- /* turn off DMA, force end */660660- spider_net_disable_rxdmac(card);661661-662662- /* release chains */663663- spider_net_release_tx_chain(card, 1);664664-665665- spider_net_free_chain(card, &card->tx_chain);666666- spider_net_free_chain(card, &card->rx_chain);667667-668668- return 0;669669-}670670-671671-/**672672- * spider_net_get_next_tx_descr - returns the next available tx descriptor673673- * @card: device structure to get descriptor from674674- *675675- * returns the address of the next descriptor, or NULL if not available.676676- */677677-static struct spider_net_descr *678678-spider_net_get_next_tx_descr(struct spider_net_card *card)679679-{680680- /* check, if head points to not-in-use descr */681681- if ( spider_net_get_descr_status(card->tx_chain.head) ==682682- SPIDER_NET_DESCR_NOT_IN_USE ) {683683- return card->tx_chain.head;684684- } else {685685- return NULL;686686- }687687-}688688-689689-/**690690- * spider_net_set_txdescr_cmdstat - sets the tx descriptor command field691691- * @descr: descriptor structure to fill out692692- * @skb: packet to consider693693- *694694- * fills out the command and status field of the descriptor structure,695695- * depending on hardware checksum settings.696696- */697697-static void698698-spider_net_set_txdescr_cmdstat(struct spider_net_descr *descr,699699- struct sk_buff *skb)700700-{701701- /* make sure the other fields in the descriptor are written */702702- wmb();703703-704704- if (skb->ip_summed != CHECKSUM_HW) {705705- descr->dmac_cmd_status = SPIDER_NET_DMAC_CMDSTAT_NOCS;706706- return;707707- }708708-709709- /* is packet ip?710710- * if yes: tcp? udp? */711711- if (skb->protocol == htons(ETH_P_IP)) {712712- if (skb->nh.iph->protocol == IPPROTO_TCP)713713- descr->dmac_cmd_status = SPIDER_NET_DMAC_CMDSTAT_TCPCS;714714- else if (skb->nh.iph->protocol == IPPROTO_UDP)715715- descr->dmac_cmd_status = SPIDER_NET_DMAC_CMDSTAT_UDPCS;716716- else /* the stack should checksum non-tcp and non-udp717717- packets on his own: NETIF_F_IP_CSUM */718718- descr->dmac_cmd_status = SPIDER_NET_DMAC_CMDSTAT_NOCS;719719- }720720-}721721-722722-/**723764 * spider_net_prepare_tx_descr - fill tx descriptor with skb data724765 * @card: card structure725766 * @descr: descriptor structure to fill out···641864 */642865static int643866spider_net_prepare_tx_descr(struct spider_net_card *card,644644- struct spider_net_descr *descr,645867 struct sk_buff *skb)646868{869869+ struct spider_net_descr *descr = card->tx_chain.head;647870 dma_addr_t buf;648871649649- buf = pci_map_single(card->pdev, skb->data,650650- skb->len, PCI_DMA_BIDIRECTIONAL);872872+ buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE);651873 if (buf == DMA_ERROR_CODE) {652874 if (netif_msg_tx_err(card) && net_ratelimit())653875 pr_err("could not iommu-map packet (%p, %i). "···656880657881 descr->buf_addr = buf;658882 descr->buf_size = skb->len;883883+ descr->next_descr_addr = 0;659884 descr->skb = skb;660885 descr->data_status = 0;661886662662- spider_net_set_txdescr_cmdstat(descr,skb);887887+ descr->dmac_cmd_status =888888+ SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS;889889+ if (skb->protocol == htons(ETH_P_IP))890890+ switch (skb->nh.iph->protocol) {891891+ case IPPROTO_TCP:892892+ descr->dmac_cmd_status |= SPIDER_NET_DMAC_TCP;893893+ break;894894+ case IPPROTO_UDP:895895+ descr->dmac_cmd_status |= SPIDER_NET_DMAC_UDP;896896+ break;897897+ }898898+899899+ descr->prev->next_descr_addr = descr->bus_addr;900900+901901+ return 0;902902+}903903+904904+/**905905+ * spider_net_release_tx_descr - processes a used tx descriptor906906+ * @card: card structure907907+ * @descr: descriptor to release908908+ *909909+ * releases a used tx descriptor (unmapping, freeing of skb)910910+ */911911+static inline void912912+spider_net_release_tx_descr(struct spider_net_card *card)913913+{914914+ struct spider_net_descr *descr = card->tx_chain.tail;915915+ struct sk_buff *skb;916916+917917+ card->tx_chain.tail = card->tx_chain.tail->next;918918+ descr->dmac_cmd_status |= SPIDER_NET_DESCR_NOT_IN_USE;919919+920920+ /* unmap the skb */921921+ skb = descr->skb;922922+ pci_unmap_single(card->pdev, descr->buf_addr, skb->len,923923+ PCI_DMA_TODEVICE);924924+ dev_kfree_skb_any(skb);925925+}926926+927927+/**928928+ * spider_net_release_tx_chain - processes sent tx descriptors929929+ * @card: adapter structure930930+ * @brutal: if set, don't care about whether descriptor seems to be in use931931+ *932932+ * returns 0 if the tx ring is empty, otherwise 1.933933+ *934934+ * spider_net_release_tx_chain releases the tx descriptors that spider has935935+ * finished with (if non-brutal) or simply release tx descriptors (if brutal).936936+ * If some other context is calling this function, we return 1 so that we're937937+ * scheduled again (if we were scheduled) and will not loose initiative.938938+ */939939+static int940940+spider_net_release_tx_chain(struct spider_net_card *card, int brutal)941941+{942942+ struct spider_net_descr_chain *chain = &card->tx_chain;943943+ int status;944944+945945+ spider_net_read_reg(card, SPIDER_NET_GDTDMACCNTR);946946+947947+ while (chain->tail != chain->head) {948948+ status = spider_net_get_descr_status(chain->tail);949949+ switch (status) {950950+ case SPIDER_NET_DESCR_COMPLETE:951951+ card->netdev_stats.tx_packets++;952952+ card->netdev_stats.tx_bytes += chain->tail->skb->len;953953+ break;954954+955955+ case SPIDER_NET_DESCR_CARDOWNED:956956+ if (!brutal)957957+ return 1;958958+ /* fallthrough, if we release the descriptors959959+ * brutally (then we don't care about960960+ * SPIDER_NET_DESCR_CARDOWNED) */961961+962962+ case SPIDER_NET_DESCR_RESPONSE_ERROR:963963+ case SPIDER_NET_DESCR_PROTECTION_ERROR:964964+ case SPIDER_NET_DESCR_FORCE_END:965965+ if (netif_msg_tx_err(card))966966+ pr_err("%s: forcing end of tx descriptor "967967+ "with status x%02x\n",968968+ card->netdev->name, status);969969+ card->netdev_stats.tx_errors++;970970+ break;971971+972972+ default:973973+ card->netdev_stats.tx_dropped++;974974+ return 1;975975+ }976976+ spider_net_release_tx_descr(card);977977+ }663978664979 return 0;665980}···763896 * spider_net_kick_tx_dma writes the current tx chain head as start address764897 * of the tx descriptor chain and enables the transmission DMA engine765898 */766766-static void767767-spider_net_kick_tx_dma(struct spider_net_card *card,768768- struct spider_net_descr *descr)899899+static inline void900900+spider_net_kick_tx_dma(struct spider_net_card *card)769901{770770- /* this is the only descriptor in the output chain.771771- * Enable TX DMA */902902+ struct spider_net_descr *descr;772903773773- spider_net_write_reg(card, SPIDER_NET_GDTDCHA,774774- descr->bus_addr);904904+ if (spider_net_read_reg(card, SPIDER_NET_GDTDMACCNTR) &905905+ SPIDER_NET_TX_DMA_EN)906906+ goto out;775907776776- spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,777777- SPIDER_NET_DMA_TX_VALUE);908908+ descr = card->tx_chain.tail;909909+ for (;;) {910910+ if (spider_net_get_descr_status(descr) ==911911+ SPIDER_NET_DESCR_CARDOWNED) {912912+ spider_net_write_reg(card, SPIDER_NET_GDTDCHA,913913+ descr->bus_addr);914914+ spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,915915+ SPIDER_NET_DMA_TX_VALUE);916916+ break;917917+ }918918+ if (descr == card->tx_chain.head)919919+ break;920920+ descr = descr->next;921921+ }922922+923923+out:924924+ mod_timer(&card->tx_timer, jiffies + SPIDER_NET_TX_TIMER);778925}779926780927/**···796915 * @skb: packet to send out797916 * @netdev: interface device structure798917 *799799- * returns 0 on success, <0 on failure918918+ * returns 0 on success, !0 on failure800919 */801920static int802921spider_net_xmit(struct sk_buff *skb, struct net_device *netdev)803922{804923 struct spider_net_card *card = netdev_priv(netdev);805805- struct spider_net_descr *descr;924924+ struct spider_net_descr_chain *chain = &card->tx_chain;925925+ struct spider_net_descr *descr = chain->head;926926+ unsigned long flags;806927 int result;928928+929929+ spin_lock_irqsave(&chain->lock, flags);807930808931 spider_net_release_tx_chain(card, 0);809932810810- descr = spider_net_get_next_tx_descr(card);811811-812812- if (!descr)813813- goto error;814814-815815- result = spider_net_prepare_tx_descr(card, descr, skb);816816- if (result)817817- goto error;818818-819819- card->tx_chain.head = card->tx_chain.head->next;820820-821821- if (spider_net_get_descr_status(descr->prev) !=822822- SPIDER_NET_DESCR_CARDOWNED) {823823- /* make sure the current descriptor is in memory. Then824824- * kicking it on again makes sense, if the previous is not825825- * card-owned anymore. Check the previous descriptor twice826826- * to omit an mb() in heavy traffic cases */827827- mb();828828- if (spider_net_get_descr_status(descr->prev) !=829829- SPIDER_NET_DESCR_CARDOWNED)830830- spider_net_kick_tx_dma(card, descr);933933+ if (chain->head->next == chain->tail->prev) {934934+ card->netdev_stats.tx_dropped++;935935+ result = NETDEV_TX_LOCKED;936936+ goto out;831937 }832938833833- mod_timer(&card->tx_timer, jiffies + SPIDER_NET_TX_TIMER);939939+ if (spider_net_get_descr_status(descr) != SPIDER_NET_DESCR_NOT_IN_USE) {940940+ result = NETDEV_TX_LOCKED;941941+ goto out;942942+ }834943835835- return NETDEV_TX_OK;944944+ if (spider_net_prepare_tx_descr(card, skb) != 0) {945945+ card->netdev_stats.tx_dropped++;946946+ result = NETDEV_TX_BUSY;947947+ goto out;948948+ }836949837837-error:838838- card->netdev_stats.tx_dropped++;839839- return NETDEV_TX_BUSY;950950+ result = NETDEV_TX_OK;951951+952952+ spider_net_kick_tx_dma(card);953953+ card->tx_chain.head = card->tx_chain.head->next;954954+955955+out:956956+ spin_unlock_irqrestore(&chain->lock, flags);957957+ netif_wake_queue(netdev);958958+ return result;959959+}960960+961961+/**962962+ * spider_net_cleanup_tx_ring - cleans up the TX ring963963+ * @card: card structure964964+ *965965+ * spider_net_cleanup_tx_ring is called by the tx_timer (as we don't use966966+ * interrupts to cleanup our TX ring) and returns sent packets to the stack967967+ * by freeing them968968+ */969969+static void970970+spider_net_cleanup_tx_ring(struct spider_net_card *card)971971+{972972+ unsigned long flags;973973+974974+ spin_lock_irqsave(&card->tx_chain.lock, flags);975975+976976+ if ((spider_net_release_tx_chain(card, 0) != 0) &&977977+ (card->netdev->flags & IFF_UP))978978+ spider_net_kick_tx_dma(card);979979+980980+ spin_unlock_irqrestore(&card->tx_chain.lock, flags);840981}841982842983/**···90510029061003 /* unmap descriptor */9071004 pci_unmap_single(card->pdev, descr->buf_addr, SPIDER_NET_MAX_FRAME,908908- PCI_DMA_BIDIRECTIONAL);10051005+ PCI_DMA_FROMDEVICE);90910069101007 /* the cases we'll throw away the packet immediately */9111008 if (data_error & SPIDER_NET_DESTROY_RX_FLAGS) {···9701067static int9711068spider_net_decode_one_descr(struct spider_net_card *card, int napi)9721069{973973- enum spider_net_descr_status status;974974- struct spider_net_descr *descr;975975- struct spider_net_descr_chain *chain;10701070+ struct spider_net_descr_chain *chain = &card->rx_chain;10711071+ struct spider_net_descr *descr = chain->tail;10721072+ int status;9761073 int result;977977-978978- chain = &card->rx_chain;979979- descr = chain->tail;98010749811075 status = spider_net_get_descr_status(descr);9821076···10031103 card->netdev->name, status);10041104 card->netdev_stats.rx_dropped++;10051105 pci_unmap_single(card->pdev, descr->buf_addr,10061006- SPIDER_NET_MAX_FRAME, PCI_DMA_BIDIRECTIONAL);11061106+ SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);10071107 dev_kfree_skb_irq(descr->skb);10081108 goto refill;10091109 }···10191119 /* ok, we've got a packet in descr */10201120 result = spider_net_pass_skb_up(descr, card, napi);10211121refill:10221022- spider_net_set_descr_status(descr, SPIDER_NET_DESCR_NOT_IN_USE);11221122+ descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;10231123 /* change the descriptor state: */10241124 if (!napi)10251125 spider_net_refill_rx_chain(card);···11881288 return -EADDRNOTAVAIL;1189128911901290 return 0;11911191-}11921192-11931193-/**11941194- * spider_net_enable_txdmac - enables a TX DMA controller11951195- * @card: card structure11961196- *11971197- * spider_net_enable_txdmac enables the TX DMA controller by setting the11981198- * descriptor chain tail address11991199- */12001200-static void12011201-spider_net_enable_txdmac(struct spider_net_card *card)12021202-{12031203- /* assume chain is aligned correctly */12041204- spider_net_write_reg(card, SPIDER_NET_GDTDCHA,12051205- card->tx_chain.tail->bus_addr);12061291}1207129212081293/**···15381653 { SPIDER_NET_GMRWOLCTRL, 0 },15391654 { SPIDER_NET_GTESTMD, 0x10000000 },15401655 { SPIDER_NET_GTTQMSK, 0x00400040 },15411541- { SPIDER_NET_GTESTMD, 0 },1542165615431657 { SPIDER_NET_GMACINTEN, 0 },15441658···1576169215771693 spider_net_write_reg(card, SPIDER_NET_GRXDMAEN, SPIDER_NET_WOL_VALUE);1578169415791579- /* set chain tail adress for TX chain */15801580- spider_net_enable_txdmac(card);15811581-15821695 spider_net_write_reg(card, SPIDER_NET_GMACLENLMT,15831696 SPIDER_NET_LENLMT_VALUE);15841697 spider_net_write_reg(card, SPIDER_NET_GMACMODE,···15901709 SPIDER_NET_INT1_MASK_VALUE);15911710 spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK,15921711 SPIDER_NET_INT2_MASK_VALUE);17121712+17131713+ spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,17141714+ SPIDER_NET_GDTDCEIDIS);15931715}1594171615951717/**···1612172816131729 result = -ENOMEM;16141730 if (spider_net_init_chain(card, &card->tx_chain,16151615- card->descr, tx_descriptors))17311731+ card->descr,17321732+ PCI_DMA_TODEVICE, tx_descriptors))16161733 goto alloc_tx_failed;16171734 if (spider_net_init_chain(card, &card->rx_chain,16181618- card->descr + tx_descriptors, rx_descriptors))17351735+ card->descr + tx_descriptors,17361736+ PCI_DMA_FROMDEVICE, rx_descriptors))16191737 goto alloc_rx_failed;1620173816211739 /* allocate rx skbs */···18241938 /* empty sequencer data */18251939 for (sequencer = 0; sequencer < SPIDER_NET_FIRMWARE_SEQS;18261940 sequencer++) {18271827- spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT +19411941+ spider_net_write_reg(card, SPIDER_NET_GSnPRGADR +18281942 sequencer * 8, 0x0);18291943 for (i = 0; i < SPIDER_NET_FIRMWARE_SEQWORDS; i++) {18301944 spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT +···18381952 /* reset */18391953 spider_net_write_reg(card, SPIDER_NET_CKRCTRL,18401954 SPIDER_NET_CKRCTRL_STOP_VALUE);19551955+}19561956+19571957+/**19581958+ * spider_net_stop - called upon ifconfig down19591959+ * @netdev: interface device structure19601960+ *19611961+ * always returns 019621962+ */19631963+int19641964+spider_net_stop(struct net_device *netdev)19651965+{19661966+ struct spider_net_card *card = netdev_priv(netdev);19671967+19681968+ tasklet_kill(&card->rxram_full_tl);19691969+ netif_poll_disable(netdev);19701970+ netif_carrier_off(netdev);19711971+ netif_stop_queue(netdev);19721972+ del_timer_sync(&card->tx_timer);19731973+19741974+ /* disable/mask all interrupts */19751975+ spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0);19761976+ spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0);19771977+ spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0);19781978+19791979+ /* free_irq(netdev->irq, netdev);*/19801980+ free_irq(to_pci_dev(netdev->class_dev.dev)->irq, netdev);19811981+19821982+ spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,19831983+ SPIDER_NET_DMA_TX_FEND_VALUE);19841984+19851985+ /* turn off DMA, force end */19861986+ spider_net_disable_rxdmac(card);19871987+19881988+ /* release chains */19891989+ if (spin_trylock(&card->tx_chain.lock)) {19901990+ spider_net_release_tx_chain(card, 1);19911991+ spin_unlock(&card->tx_chain.lock);19921992+ }19931993+19941994+ spider_net_free_chain(card, &card->tx_chain);19951995+ spider_net_free_chain(card, &card->rx_chain);19961996+19971997+ return 0;18411998}1842199918432000/**···19111982 goto out;1912198319131984 spider_net_open(netdev);19141914- spider_net_kick_tx_dma(card, card->tx_chain.head);19851985+ spider_net_kick_tx_dma(card);19151986 netif_device_attach(netdev);1916198719171988out:···1994206519952066 pci_set_drvdata(card->pdev, netdev);1996206719971997- atomic_set(&card->tx_chain_release,0);19982068 card->rxram_full_tl.data = (unsigned long) card;19992069 card->rxram_full_tl.func =20002070 (void (*)(unsigned long)) spider_net_handle_rxram_full;···2007207920082080 spider_net_setup_netdev_ops(netdev);2009208120102010- netdev->features = NETIF_F_HW_CSUM;20822082+ netdev->features = NETIF_F_HW_CSUM | NETIF_F_LLTX;20112083 /* some time: NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX |20122084 * NETIF_F_HW_VLAN_FILTER */20132085
+20-51
drivers/net/spider_net.h
···208208#define SPIDER_NET_DMA_RX_VALUE 0x80000000209209#define SPIDER_NET_DMA_RX_FEND_VALUE 0x00030003210210/* to set TX_DMA_EN */211211-#define SPIDER_NET_DMA_TX_VALUE 0x80000000211211+#define SPIDER_NET_TX_DMA_EN 0x80000000212212+#define SPIDER_NET_GDTDCEIDIS 0x00000002213213+#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \214214+ SPIDER_NET_GDTDCEIDIS212215#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003213216214217/* SPIDER_NET_UA_DESCR_VALUE is OR'ed with the unicast address */···332329 (~SPIDER_NET_TXINT) & \333330 (~SPIDER_NET_RXINT) )334331335335-#define SPIDER_NET_GPREXEC 0x80000000336336-#define SPIDER_NET_GPRDAT_MASK 0x0000ffff332332+#define SPIDER_NET_GPREXEC 0x80000000333333+#define SPIDER_NET_GPRDAT_MASK 0x0000ffff337334338338-/* descriptor bits339339- *340340- * 1010 descriptor ready341341- * 0 descr in middle of chain342342- * 000 fixed to 0343343- *344344- * 0 no interrupt on completion345345- * 000 fixed to 0346346- * 1 no ipsec processing347347- * 1 last descriptor for this frame348348- * 00 no checksum349349- * 10 tcp checksum350350- * 11 udp checksum351351- *352352- * 00 fixed to 0353353- * 0 fixed to 0354354- * 0 no interrupt on response errors355355- * 0 no interrupt on invalid descr356356- * 0 no interrupt on dma process termination357357- * 0 no interrupt on descr chain end358358- * 0 no interrupt on descr complete359359- *360360- * 000 fixed to 0361361- * 0 response error interrupt status362362- * 0 invalid descr status363363- * 0 dma termination status364364- * 0 descr chain end status365365- * 0 descr complete status */366366-#define SPIDER_NET_DMAC_CMDSTAT_NOCS 0xa00c0000367367-#define SPIDER_NET_DMAC_CMDSTAT_TCPCS 0xa00e0000368368-#define SPIDER_NET_DMAC_CMDSTAT_UDPCS 0xa00f0000369369-#define SPIDER_NET_DESCR_IND_PROC_SHIFT 28370370-#define SPIDER_NET_DESCR_IND_PROC_MASKO 0x0fffffff335335+#define SPIDER_NET_DMAC_NOINTR_COMPLETE 0x00800000336336+#define SPIDER_NET_DMAC_NOCS 0x00040000337337+#define SPIDER_NET_DMAC_TCP 0x00020000338338+#define SPIDER_NET_DMAC_UDP 0x00030000339339+#define SPIDER_NET_TXDCEST 0x08000000371340372372-/* descr ready, descr is in middle of chain, get interrupt on completion */373373-#define SPIDER_NET_DMAC_RX_CARDOWNED 0xa0800000374374-375375-enum spider_net_descr_status {376376- SPIDER_NET_DESCR_COMPLETE = 0x00, /* used in rx and tx */377377- SPIDER_NET_DESCR_RESPONSE_ERROR = 0x01, /* used in rx and tx */378378- SPIDER_NET_DESCR_PROTECTION_ERROR = 0x02, /* used in rx and tx */379379- SPIDER_NET_DESCR_FRAME_END = 0x04, /* used in rx */380380- SPIDER_NET_DESCR_FORCE_END = 0x05, /* used in rx and tx */381381- SPIDER_NET_DESCR_CARDOWNED = 0x0a, /* used in rx and tx */382382- SPIDER_NET_DESCR_NOT_IN_USE /* any other value */383383-};341341+#define SPIDER_NET_DESCR_IND_PROC_MASK 0xF0000000342342+#define SPIDER_NET_DESCR_COMPLETE 0x00000000 /* used in rx and tx */343343+#define SPIDER_NET_DESCR_RESPONSE_ERROR 0x10000000 /* used in rx and tx */344344+#define SPIDER_NET_DESCR_PROTECTION_ERROR 0x20000000 /* used in rx and tx */345345+#define SPIDER_NET_DESCR_FRAME_END 0x40000000 /* used in rx */346346+#define SPIDER_NET_DESCR_FORCE_END 0x50000000 /* used in rx and tx */347347+#define SPIDER_NET_DESCR_CARDOWNED 0xA0000000 /* used in rx and tx */348348+#define SPIDER_NET_DESCR_NOT_IN_USE 0xF0000000384349385350struct spider_net_descr {386351 /* as defined by the hardware */···369398} __attribute__((aligned(32)));370399371400struct spider_net_descr_chain {372372- /* we walk from tail to head */401401+ spinlock_t lock;373402 struct spider_net_descr *head;374403 struct spider_net_descr *tail;375404};···424453425454 struct spider_net_descr_chain tx_chain;426455 struct spider_net_descr_chain rx_chain;427427- atomic_t rx_chain_refill;428428- atomic_t tx_chain_release;429456430457 struct net_device_stats netdev_stats;431458
···114114MODULE_LICENSE("GPL");115115module_param(NCR_D700, charp, 0);116116117117-static __u8 __initdata id_array[2*(MCA_MAX_SLOT_NR + 1)] =117117+static __u8 __devinitdata id_array[2*(MCA_MAX_SLOT_NR + 1)] =118118 { [0 ... 2*(MCA_MAX_SLOT_NR + 1)-1] = 7 };119119120120#ifdef MODULE···173173 char pad;174174};175175176176-static int 176176+static int __devinit177177NCR_D700_probe_one(struct NCR_D700_private *p, int siop, int irq,178178 int slot, u32 region, int differential)179179{···243243 * essentially connectecd to the MCA bus independently, it is easier244244 * to set them up as two separate host adapters, rather than one245245 * adapter with two channels */246246-static int246246+static int __devinit247247NCR_D700_probe(struct device *dev)248248{249249 struct NCR_D700_private *p;···329329 for (i = 0; i < 2; i++) {330330 int err;331331332332- if ((err = NCR_D700_probe_one(p, i, slot, irq,332332+ if ((err = NCR_D700_probe_one(p, i, irq, slot,333333 offset_addr + (0x80 * i),334334 differential)) != 0)335335 printk("D700: SIOP%d: probe failed, error = %d\n",···349349 return 0;350350}351351352352-static void352352+static void __devexit353353NCR_D700_remove_one(struct Scsi_Host *host)354354{355355 scsi_remove_host(host);···359359 release_region(host->base, 64);360360}361361362362-static int362362+static int __devexit363363NCR_D700_remove(struct device *dev)364364{365365 struct NCR_D700_private *p = dev_get_drvdata(dev);···380380 .name = "NCR_D700",381381 .bus = &mca_bus_type,382382 .probe = NCR_D700_probe,383383- .remove = NCR_D700_remove,383383+ .remove = __devexit_p(NCR_D700_remove),384384 },385385};386386
···243243static uint32_t aic79xx_no_reset;244244245245/*246246- * Certain PCI motherboards will scan PCI devices from highest to lowest,247247- * others scan from lowest to highest, and they tend to do all kinds of248248- * strange things when they come into contact with PCI bridge chips. The249249- * net result of all this is that the PCI card that is actually used to boot250250- * the machine is very hard to detect. Most motherboards go from lowest251251- * PCI slot number to highest, and the first SCSI controller found is the252252- * one you boot from. The only exceptions to this are when a controller253253- * has its BIOS disabled. So, we by default sort all of our SCSI controllers254254- * from lowest PCI slot number to highest PCI slot number. We also force255255- * all controllers with their BIOS disabled to the end of the list. This256256- * works on *almost* all computers. Where it doesn't work, we have this257257- * option. Setting this option to non-0 will reverse the order of the sort258258- * to highest first, then lowest, but will still leave cards with their BIOS259259- * disabled at the very end. That should fix everyone up unless there are260260- * really strange cirumstances.261261- */262262-static uint32_t aic79xx_reverse_scan;263263-264264-/*265246 * Should we force EXTENDED translation on a controller.266247 * 0 == Use whatever is in the SEEPROM or default to off267248 * 1 == Use whatever is in the SEEPROM or default to on···331350" periodically to prevent tag starvation.\n"332351" This may be required by some older disk\n"333352" or drives/RAID arrays.\n"334334-" reverse_scan Sort PCI devices highest Bus/Slot to lowest\n"335353" tag_info:<tag_str> Set per-target tag depth\n"336354" global_tag_depth:<int> Global tag depth for all targets on all buses\n"337355" slewrate:<slewrate_list>Set the signal slew rate (0-15).\n"···10111031#ifdef AHD_DEBUG10121032 { "debug", &ahd_debug },10131033#endif10141014- { "reverse_scan", &aic79xx_reverse_scan },10151034 { "periodic_otag", &aic79xx_periodic_otag },10161035 { "pci_parity", &aic79xx_pci_parity },10171036 { "seltime", &aic79xx_seltime },
-1
drivers/scsi/aic7xxx/aic7xxx_osm.c
···353353" periodically to prevent tag starvation.\n"354354" This may be required by some older disk\n"355355" drives or RAID arrays.\n"356356-" reverse_scan Sort PCI devices highest Bus/Slot to lowest\n"357356" tag_info:<tag_str> Set per-target tag depth\n"358357" global_tag_depth:<int> Global tag depth for every target\n"359358" on every bus\n"
···8181 int rc;82828383 single_host_data = hostdata;8484- rc = viopath_open(viopath_hostLp, viomajorsubtype_scsi, 0);8484+ rc = viopath_open(viopath_hostLp, viomajorsubtype_scsi, max_requests);8585 if (rc < 0) {8686 printk("viopath_open failed with rc %d in open_event_path\n",8787 rc);
+1
drivers/scsi/ibmvscsi/rpa_vscsi.c
···238238 if (rc == 2) {239239 /* Adapter is good, but other end is not ready */240240 printk(KERN_WARNING "ibmvscsi: Partner adapter not ready\n");241241+ retrc = 0;241242 } else if (rc != 0) {242243 printk(KERN_WARNING "ibmvscsi: Error %d opening adapter\n", rc);243244 goto reg_crq_failed;
···21212222struct lpfc_sli2_slim;23232424-#define LPFC_MAX_TARGET 256 /* max targets supported */2525-#define LPFC_MAX_DISC_THREADS 64 /* max outstanding discovery els req */2626-#define LPFC_MAX_NS_RETRY 3 /* max NameServer retries */27242525+#define LPFC_MAX_TARGET 256 /* max number of targets supported */2626+#define LPFC_MAX_DISC_THREADS 64 /* max outstanding discovery els2727+ requests */2828+#define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact2929+ the NameServer before giving up. */2830#define LPFC_DFT_HBA_Q_DEPTH 2048 /* max cmds per hba */2931#define LPFC_LC_HBA_Q_DEPTH 1024 /* max cmds per low cost hba */3032#define LPFC_LP101_HBA_Q_DEPTH 128 /* max cmds per low cost hba */···4341 (( (u64)(high)<<16 ) << 16)|( (u64)(low))))4442/* Provide maximum configuration definitions. */4543#define LPFC_DRVR_TIMEOUT 16 /* driver iocb timeout value in sec */4646-#define MAX_FCP_TARGET 256 /* max num of FCP targets supported */4744#define FC_MAX_ADPTMSG 6448454946#define MAX_HBAEVT 32
+59-48
drivers/scsi/lpfc/lpfc_attr.c
···219219 return -ENOMEM;220220221221 memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));222222- lpfc_init_link(phba, pmboxq, phba->cfg_topology, phba->cfg_link_speed);222222+ pmboxq->mb.mbxCommand = MBX_DOWN_LINK;223223+ pmboxq->mb.mbxOwner = OWN_HOST;224224+223225 mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);226226+227227+ if ((mbxstatus == MBX_SUCCESS) && (pmboxq->mb.mbxStatus == 0)) {228228+ memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));229229+ lpfc_init_link(phba, pmboxq, phba->cfg_topology,230230+ phba->cfg_link_speed);231231+ mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq,232232+ phba->fc_ratov * 2);233233+ }224234225235 if (mbxstatus == MBX_TIMEOUT)226236 pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl;···243233 return 0;244234}245235236236+static int237237+lpfc_selective_reset(struct lpfc_hba *phba)238238+{239239+ struct completion online_compl;240240+ int status = 0;241241+242242+ init_completion(&online_compl);243243+ lpfc_workq_post_event(phba, &status, &online_compl,244244+ LPFC_EVT_OFFLINE);245245+ wait_for_completion(&online_compl);246246+247247+ if (status != 0)248248+ return -EIO;249249+250250+ init_completion(&online_compl);251251+ lpfc_workq_post_event(phba, &status, &online_compl,252252+ LPFC_EVT_ONLINE);253253+ wait_for_completion(&online_compl);254254+255255+ if (status != 0)256256+ return -EIO;257257+258258+ return 0;259259+}260260+261261+static ssize_t262262+lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count)263263+{264264+ struct Scsi_Host *host = class_to_shost(cdev);265265+ struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;266266+ int status = -EINVAL;267267+268268+ if (strncmp(buf, "selective", sizeof("selective") - 1) == 0)269269+ status = lpfc_selective_reset(phba);270270+271271+ if (status == 0)272272+ return strlen(buf);273273+ else274274+ return status;275275+}276276+246277static ssize_t247278lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf)248279{249280 struct Scsi_Host *host = class_to_shost(cdev);250281 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;251282 return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);252252-}253253-254254-static ssize_t255255-lpfc_board_online_show(struct class_device *cdev, char *buf)256256-{257257- struct Scsi_Host *host = class_to_shost(cdev);258258- struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;259259-260260- if (phba->fc_flag & FC_OFFLINE_MODE)261261- return snprintf(buf, PAGE_SIZE, "0\n");262262- else263263- return snprintf(buf, PAGE_SIZE, "1\n");264264-}265265-266266-static ssize_t267267-lpfc_board_online_store(struct class_device *cdev, const char *buf,268268- size_t count)269269-{270270- struct Scsi_Host *host = class_to_shost(cdev);271271- struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;272272- struct completion online_compl;273273- int val=0, status=0;274274-275275- if (sscanf(buf, "%d", &val) != 1)276276- return -EINVAL;277277-278278- init_completion(&online_compl);279279-280280- if (val)281281- lpfc_workq_post_event(phba, &status, &online_compl,282282- LPFC_EVT_ONLINE);283283- else284284- lpfc_workq_post_event(phba, &status, &online_compl,285285- LPFC_EVT_OFFLINE);286286- wait_for_completion(&online_compl);287287- if (!status)288288- return strlen(buf);289289- else290290- return -EIO;291283}292284293285static ssize_t···544532 NULL);545533static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show,546534 NULL);547547-static CLASS_DEVICE_ATTR(board_online, S_IRUGO | S_IWUSR,548548- lpfc_board_online_show, lpfc_board_online_store);549535static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,550536 lpfc_board_mode_show, lpfc_board_mode_store);537537+static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);551538552539static int lpfc_poll = 0;553540module_param(lpfc_poll, int, 0);···706695 "during discovery");707696708697/*709709-# lpfc_max_luns: maximum number of LUNs per target driver will support710710-# Value range is [1,32768]. Default value is 256.711711-# NOTE: The SCSI layer will scan each target for this many luns698698+# lpfc_max_luns: maximum allowed LUN.699699+# Value range is [0,65535]. Default value is 255.700700+# NOTE: The SCSI layer might probe all allowed LUN on some old targets.712701*/713713-LPFC_ATTR_R(max_luns, 256, 1, 32768,714714- "Maximum number of LUNs per target driver will support");702702+LPFC_ATTR_R(max_luns, 255, 0, 65535,703703+ "Maximum allowed LUN");715704716705/*717706# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.···750739 &class_device_attr_lpfc_max_luns,751740 &class_device_attr_nport_evt_cnt,752741 &class_device_attr_management_version,753753- &class_device_attr_board_online,754742 &class_device_attr_board_mode,743743+ &class_device_attr_issue_reset,755744 &class_device_attr_lpfc_poll,756745 &class_device_attr_lpfc_poll_tmo,757746 NULL,
···7171 uint16_t offset = 0;7272 static char licensed[56] =7373 "key unlock for use with gnu public licensed code only\0";7474+ static int init_key = 1;74757576 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);7677 if (!pmb) {···8382 phba->hba_state = LPFC_INIT_MBX_CMDS;84838584 if (lpfc_is_LC_HBA(phba->pcidev->device)) {8686- uint32_t *ptext = (uint32_t *) licensed;8585+ if (init_key) {8686+ uint32_t *ptext = (uint32_t *) licensed;87878888- for (i = 0; i < 56; i += sizeof (uint32_t), ptext++)8989- *ptext = cpu_to_be32(*ptext);8888+ for (i = 0; i < 56; i += sizeof (uint32_t), ptext++)8989+ *ptext = cpu_to_be32(*ptext);9090+ init_key = 0;9191+ }90929193 lpfc_read_nv(phba, pmb);9294 memset((char*)mb->un.varRDnvp.rsvd3, 0,···409405 }410406 /* MBOX buffer will be freed in mbox compl */411407412412- i = 0;408408+ return (0);409409+}410410+411411+static int412412+lpfc_discovery_wait(struct lpfc_hba *phba)413413+{414414+ int i = 0;415415+413416 while ((phba->hba_state != LPFC_HBA_READY) ||414417 (phba->num_disc_nodes) || (phba->fc_prli_sent) ||415418 ((phba->fc_map_cnt == 0) && (i<2)) ||416416- (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) {419419+ (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE)) {417420 /* Check every second for 30 retries. */418421 i++;419422 if (i > 30) {420420- break;423423+ return -ETIMEDOUT;421424 }422425 if ((i >= 15) && (phba->hba_state <= LPFC_LINK_DOWN)) {423426 /* The link is down. Set linkdown timeout */424424- break;427427+ return -ETIMEDOUT;425428 }426429427430 /* Delay for 1 second to give discovery time to complete. */···436425437426 }438427439439- /* Since num_disc_nodes keys off of PLOGI, delay a bit to let440440- * any potential PRLIs to flush thru the SLI sub-system.441441- */442442- msleep(50);443443-444444- return (0);428428+ return 0;445429}446430447431/************************************************************************/···13451339 struct lpfc_sli_ring *pring;13461340 struct lpfc_sli *psli;13471341 unsigned long iflag;13481348- int i = 0;13421342+ int i;13431343+ int cnt = 0;1349134413501345 if (!phba)13511346 return 0;···13551348 return 0;1356134913571350 psli = &phba->sli;13581358- pring = &psli->ring[psli->fcp_ring];1359135113601352 lpfc_linkdown(phba);13531353+ lpfc_sli_flush_mbox_queue(phba);1361135413621362- /* The linkdown event takes 30 seconds to timeout. */13631363- while (pring->txcmplq_cnt) {13641364- mdelay(10);13651365- if (i++ > 3000)13661366- break;13551355+ for (i = 0; i < psli->num_rings; i++) {13561356+ pring = &psli->ring[i];13571357+ /* The linkdown event takes 30 seconds to timeout. */13581358+ while (pring->txcmplq_cnt) {13591359+ mdelay(10);13601360+ if (cnt++ > 3000) {13611361+ lpfc_printf_log(phba,13621362+ KERN_WARNING, LOG_INIT,13631363+ "%d:0466 Outstanding IO when "13641364+ "bringing Adapter offline\n",13651365+ phba->brd_no);13661366+ break;13671367+ }13681368+ }13671369 }13701370+1368137113691372 /* stop all timers associated with this hba */13701373 lpfc_stop_timer(phba);···16551638 error = -ENODEV;16561639 goto out_free_irq;16571640 }16411641+16421642+ lpfc_discovery_wait(phba);1658164316591644 if (phba->cfg_poll & DISABLE_FCP_RING_INT) {16601645 spin_lock_irq(phba->host->host_lock);
···11101110 phba->brd_no,11111111 did, mb->mbxStatus, phba->hba_state);1112111211131113+ /*11141114+ * If RegLogin failed due to lack of HBA resources do not11151115+ * retry discovery.11161116+ */11171117+ if (mb->mbxStatus == MBXERR_RPI_FULL) {11181118+ ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;11191119+ ndlp->nlp_state = NLP_STE_UNUSED_NODE;11201120+ lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);11211121+ return ndlp->nlp_state;11221122+ }11231123+11131124 /* Put ndlp in npr list set plogi timer for 1 sec */11141125 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);11151126 spin_lock_irq(phba->host->host_lock);
+37-27
drivers/scsi/lpfc/lpfc_scsi.c
···153153lpfc_release_scsi_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb)154154{155155 unsigned long iflag = 0;156156- /*157157- * There are only two special cases to consider. (1) the scsi command158158- * requested scatter-gather usage or (2) the scsi command allocated159159- * a request buffer, but did not request use_sg. There is a third160160- * case, but it does not require resource deallocation.161161- */162162- if ((psb->seg_cnt > 0) && (psb->pCmd->use_sg)) {163163- dma_unmap_sg(&phba->pcidev->dev, psb->pCmd->request_buffer,164164- psb->seg_cnt, psb->pCmd->sc_data_direction);165165- } else {166166- if ((psb->nonsg_phys) && (psb->pCmd->request_bufflen)) {167167- dma_unmap_single(&phba->pcidev->dev, psb->nonsg_phys,168168- psb->pCmd->request_bufflen,169169- psb->pCmd->sc_data_direction);170170- }171171- }172156173157 spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag);174158 psb->pCmd = NULL;···263279 iocb_cmd->ulpLe = 1;264280 fcp_cmnd->fcpDl = be32_to_cpu(scsi_cmnd->request_bufflen);265281 return 0;282282+}283283+284284+static void285285+lpfc_scsi_unprep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb)286286+{287287+ /*288288+ * There are only two special cases to consider. (1) the scsi command289289+ * requested scatter-gather usage or (2) the scsi command allocated290290+ * a request buffer, but did not request use_sg. There is a third291291+ * case, but it does not require resource deallocation.292292+ */293293+ if ((psb->seg_cnt > 0) && (psb->pCmd->use_sg)) {294294+ dma_unmap_sg(&phba->pcidev->dev, psb->pCmd->request_buffer,295295+ psb->seg_cnt, psb->pCmd->sc_data_direction);296296+ } else {297297+ if ((psb->nonsg_phys) && (psb->pCmd->request_bufflen)) {298298+ dma_unmap_single(&phba->pcidev->dev, psb->nonsg_phys,299299+ psb->pCmd->request_bufflen,300300+ psb->pCmd->sc_data_direction);301301+ }302302+ }266303}267304268305static void···459454 cmd->scsi_done(cmd);460455461456 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {457457+ lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);462458 lpfc_release_scsi_buf(phba, lpfc_cmd);463459 return;464460 }···517511 }518512 }519513514514+ lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);520515 lpfc_release_scsi_buf(phba, lpfc_cmd);521516}522517···616609static int617610lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_hba *phba,618611 struct lpfc_scsi_buf *lpfc_cmd,612612+ unsigned int lun,619613 uint8_t task_mgmt_cmd)620614{621615 struct lpfc_sli *psli;···635627 piocb = &piocbq->iocb;636628637629 fcp_cmnd = lpfc_cmd->fcp_cmnd;638638- int_to_scsilun(lpfc_cmd->pCmd->device->lun,639639- &lpfc_cmd->fcp_cmnd->fcp_lun);630630+ int_to_scsilun(lun, &lpfc_cmd->fcp_cmnd->fcp_lun);640631 fcp_cmnd->fcpCntl2 = task_mgmt_cmd;641632642633 piocb->ulpCommand = CMD_FCP_ICMND64_CR;···662655663656static int664657lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba,665665- unsigned tgt_id, struct lpfc_rport_data *rdata)658658+ unsigned tgt_id, unsigned int lun,659659+ struct lpfc_rport_data *rdata)666660{667661 struct lpfc_iocbq *iocbq;668662 struct lpfc_iocbq *iocbqrsp;669663 int ret;670664671665 lpfc_cmd->rdata = rdata;672672- ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, FCP_TARGET_RESET);666666+ ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, lun,667667+ FCP_TARGET_RESET);673668 if (!ret)674669 return FAILED;675670···831822 return 0;832823833824 out_host_busy_free_buf:825825+ lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);834826 lpfc_release_scsi_buf(phba, lpfc_cmd);835827 out_host_busy:836828 return SCSI_MLQUEUE_HOST_BUSY;···979969 if (lpfc_cmd == NULL)980970 goto out;981971982982- lpfc_cmd->pCmd = cmnd;983972 lpfc_cmd->timeout = 60;984973 lpfc_cmd->scsi_hba = phba;985974 lpfc_cmd->rdata = rdata;986975987987- ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, FCP_LUN_RESET);976976+ ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, cmnd->device->lun,977977+ FCP_LUN_RESET);988978 if (!ret)989979 goto out_free_scsi_buf;990980···10111001 cmd_status = iocbqrsp->iocb.ulpStatus;1012100210131003 lpfc_sli_release_iocbq(phba, iocbqrsp);10141014- lpfc_release_scsi_buf(phba, lpfc_cmd);1015100410161005 /*10171006 * All outstanding txcmplq I/Os should have been aborted by the device.···10491040 }1050104110511042out_free_scsi_buf:10431043+ lpfc_release_scsi_buf(phba, lpfc_cmd);10441044+10521045 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,10531046 "%d:0713 SCSI layer issued LUN reset (%d, %d) "10541047 "Data: x%x x%x x%x\n",···1081107010821071 /* The lpfc_cmd storage is reused. Set all loop invariants. */10831072 lpfc_cmd->timeout = 60;10841084- lpfc_cmd->pCmd = cmnd;10851073 lpfc_cmd->scsi_hba = phba;1086107410871075 /*···10881078 * targets known to the driver. Should any target reset10891079 * fail, this routine returns failure to the midlayer.10901080 */10911091- for (i = 0; i < MAX_FCP_TARGET; i++) {10811081+ for (i = 0; i < LPFC_MAX_TARGET; i++) {10921082 /* Search the mapped list for this target ID */10931083 match = 0;10941084 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {···11001090 if (!match)11011091 continue;1102109211031103- ret = lpfc_scsi_tgt_reset(lpfc_cmd, phba,11041104- i, ndlp->rport->dd_data);10931093+ ret = lpfc_scsi_tgt_reset(lpfc_cmd, phba, i, cmnd->device->lun,10941094+ ndlp->rport->dd_data);11051095 if (ret != SUCCESS) {11061096 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,11071097 "%d:0713 Bus Reset on target %d failed\n",
+24-31
drivers/scsi/lpfc/lpfc_sli.c
···191191lpfc_sli_ringtxcmpl_put(struct lpfc_hba * phba,192192 struct lpfc_sli_ring * pring, struct lpfc_iocbq * piocb)193193{194194- uint16_t iotag;195195-196194 list_add_tail(&piocb->list, &pring->txcmplq);197195 pring->txcmplq_cnt++;198196 if (unlikely(pring->ringno == LPFC_ELS_RING))199197 mod_timer(&phba->els_tmofunc,200198 jiffies + HZ * (phba->fc_ratov << 1));201199202202- if (pring->fast_lookup) {203203- /* Setup fast lookup based on iotag for completion */204204- iotag = piocb->iocb.ulpIoTag;205205- if (iotag && (iotag < pring->fast_iotag))206206- *(pring->fast_lookup + iotag) = piocb;207207- else {208208-209209- /* Cmd ring <ringno> put: iotag <iotag> greater then210210- configured max <fast_iotag> wd0 <icmd> */211211- lpfc_printf_log(phba,212212- KERN_ERR,213213- LOG_SLI,214214- "%d:0316 Cmd ring %d put: iotag x%x "215215- "greater then configured max x%x "216216- "wd0 x%x\n",217217- phba->brd_no,218218- pring->ringno, iotag,219219- pring->fast_iotag,220220- *(((uint32_t *)(&piocb->iocb)) + 7));221221- }222222- }223200 return (0);224201}225202···578601 /* Stray Mailbox Interrupt, mbxCommand <cmd> mbxStatus579602 <status> */580603 lpfc_printf_log(phba,581581- KERN_ERR,604604+ KERN_WARNING,582605 LOG_MBOX | LOG_SLI,583606 "%d:0304 Stray Mailbox Interrupt "584607 "mbxCommand x%x mbxStatus x%x\n",···1547157015481571void lpfc_reset_barrier(struct lpfc_hba * phba)15491572{15501550- uint32_t * resp_buf;15511551- uint32_t * mbox_buf;15731573+ uint32_t __iomem *resp_buf;15741574+ uint32_t __iomem *mbox_buf;15521575 volatile uint32_t mbox;15531576 uint32_t hc_copy;15541577 int i;···15641587 * Tell the other part of the chip to suspend temporarily all15651588 * its DMA activity.15661589 */15671567- resp_buf = (uint32_t *)phba->MBslimaddr;15901590+ resp_buf = phba->MBslimaddr;1568159115691592 /* Disable the error attention */15701593 hc_copy = readl(phba->HCregaddr);···15821605 ((MAILBOX_t *)&mbox)->mbxOwner = OWN_CHIP;1583160615841607 writel(BARRIER_TEST_PATTERN, (resp_buf + 1));15851585- mbox_buf = (uint32_t *)phba->MBslimaddr;16081608+ mbox_buf = phba->MBslimaddr;15861609 writel(mbox, mbox_buf);1587161015881611 for (i = 0;···17821805 skip_post = 0;17831806 word0 = 0; /* This is really setting up word1 */17841807 }17851785- to_slim = (uint8_t *) phba->MBslimaddr + sizeof (uint32_t);18081808+ to_slim = phba->MBslimaddr + sizeof (uint32_t);17861809 writel(*(uint32_t *) mb, to_slim);17871810 readl(to_slim); /* flush */17881811···2636265926372660 INIT_LIST_HEAD(&(pring->txq));2638266126392639- kfree(pring->fast_lookup);26402640- pring->fast_lookup = NULL;26412662 }2642266326432664 spin_unlock_irqrestore(phba->host->host_lock, flags);···30833108 set_current_state(TASK_RUNNING);30843109 remove_wait_queue(&done_q, &wq_entry);30853110 return retval;31113111+}31123112+31133113+int31143114+lpfc_sli_flush_mbox_queue(struct lpfc_hba * phba)31153115+{31163116+ int i = 0;31173117+31183118+ while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE && !phba->stopped) {31193119+ if (i++ > LPFC_MBOX_TMO * 1000)31203120+ return 1;31213121+31223122+ if (lpfc_sli_handle_mb_event(phba) == 0)31233123+ i = 0;31243124+31253125+ msleep(1);31263126+ }31273127+31283128+ return (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) ? 1 : 0;30863129}3087313030883131irqreturn_t
-2
drivers/scsi/lpfc/lpfc_sli.h
···135135 uint32_t fast_iotag; /* max fastlookup based iotag */136136 uint32_t iotag_ctr; /* keeps track of the next iotag to use */137137 uint32_t iotag_max; /* max iotag value to use */138138- struct lpfc_iocbq ** fast_lookup; /* array of IOCB ptrs indexed by139139- iotag */140138 struct list_head txq;141139 uint16_t txq_cnt; /* current length of queue */142140 uint16_t txq_max; /* max length */
+1-1
drivers/scsi/lpfc/lpfc_version.h
···1818 * included with this package. *1919 *******************************************************************/20202121-#define LPFC_DRIVER_VERSION "8.1.6"2121+#define LPFC_DRIVER_VERSION "8.1.7"22222323#define LPFC_DRIVER_NAME "lpfc"2424
+1-1
drivers/scsi/mac53c94.c
···378378 int nseg;379379380380 total = 0;381381- scl = (struct scatterlist *) cmd->buffer;381381+ scl = (struct scatterlist *) cmd->request_buffer;382382 nseg = pci_map_sg(state->pdev, scl, cmd->use_sg,383383 cmd->sc_data_direction);384384 for (i = 0; i < nseg; ++i) {
+1-1
drivers/scsi/mesh.c
···12681268 if (cmd->use_sg > 0) {12691269 int nseg;12701270 total = 0;12711271- scl = (struct scatterlist *) cmd->buffer;12711271+ scl = (struct scatterlist *) cmd->request_buffer;12721272 off = ms->data_ptr;12731273 nseg = pci_map_sg(ms->pdev, scl, cmd->use_sg,12741274 cmd->sc_data_direction);
···346346 if (level > 3) {347347 printk(KERN_INFO "buffer = 0x%p, bufflen = %d,"348348 " done = 0x%p, queuecommand 0x%p\n",349349- cmd->buffer, cmd->bufflen,349349+ cmd->request_buffer, cmd->request_bufflen,350350 cmd->done,351351 sdev->host->hostt->queuecommand);352352···661661 */662662int scsi_retry_command(struct scsi_cmnd *cmd)663663{664664- /*665665- * Restore the SCSI command state.666666- */667667- scsi_setup_cmd_retry(cmd);668668-669664 /*670665 * Zero the sense information from the last time we tried671666 * this command.···706711 "Notifying upper driver of completion "707712 "(result %x)\n", cmd->result));708713709709- /*710710- * We can get here with use_sg=0, causing a panic in the upper level711711- */712712- cmd->use_sg = cmd->old_use_sg;713714 cmd->done(cmd);714715}715716EXPORT_SYMBOL(scsi_finish_command);
+54-18
drivers/scsi/scsi_debug.c
···286286 int dev_id_num, const char * dev_id_str,287287 int dev_id_str_len);288288static int inquiry_evpd_88(unsigned char * arr, int target_dev_id);289289-static void do_create_driverfs_files(void);289289+static int do_create_driverfs_files(void);290290static void do_remove_driverfs_files(void);291291292292static int sdebug_add_adapter(void);···24872487DRIVER_ATTR(add_host, S_IRUGO | S_IWUSR, sdebug_add_host_show, 24882488 sdebug_add_host_store);2489248924902490-static void do_create_driverfs_files(void)24902490+static int do_create_driverfs_files(void)24912491{24922492- driver_create_file(&sdebug_driverfs_driver, &driver_attr_add_host);24932493- driver_create_file(&sdebug_driverfs_driver, &driver_attr_delay);24942494- driver_create_file(&sdebug_driverfs_driver, &driver_attr_dev_size_mb);24952495- driver_create_file(&sdebug_driverfs_driver, &driver_attr_dsense);24962496- driver_create_file(&sdebug_driverfs_driver, &driver_attr_every_nth);24972497- driver_create_file(&sdebug_driverfs_driver, &driver_attr_max_luns);24982498- driver_create_file(&sdebug_driverfs_driver, &driver_attr_num_tgts);24992499- driver_create_file(&sdebug_driverfs_driver, &driver_attr_num_parts);25002500- driver_create_file(&sdebug_driverfs_driver, &driver_attr_ptype);25012501- driver_create_file(&sdebug_driverfs_driver, &driver_attr_opts);25022502- driver_create_file(&sdebug_driverfs_driver, &driver_attr_scsi_level);24922492+ int ret;24932493+24942494+ ret = driver_create_file(&sdebug_driverfs_driver, &driver_attr_add_host);24952495+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_delay);24962496+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_dev_size_mb);24972497+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_dsense);24982498+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_every_nth);24992499+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_max_luns);25002500+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_num_tgts);25012501+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_num_parts);25022502+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_ptype);25032503+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_opts);25042504+ ret |= driver_create_file(&sdebug_driverfs_driver, &driver_attr_scsi_level);25052505+ return ret;25032506}2504250725052508static void do_remove_driverfs_files(void)···25252522 unsigned int sz;25262523 int host_to_add;25272524 int k;25252525+ int ret;2528252625292527 if (scsi_debug_dev_size_mb < 1)25302528 scsi_debug_dev_size_mb = 1; /* force minimum 1 MB ramdisk */···25642560 if (scsi_debug_num_parts > 0)25652561 sdebug_build_parts(fake_storep);2566256225672567- init_all_queued();25632563+ ret = device_register(&pseudo_primary);25642564+ if (ret < 0) {25652565+ printk(KERN_WARNING "scsi_debug: device_register error: %d\n",25662566+ ret);25672567+ goto free_vm;25682568+ }25692569+ ret = bus_register(&pseudo_lld_bus);25702570+ if (ret < 0) {25712571+ printk(KERN_WARNING "scsi_debug: bus_register error: %d\n",25722572+ ret);25732573+ goto dev_unreg;25742574+ }25752575+ ret = driver_register(&sdebug_driverfs_driver);25762576+ if (ret < 0) {25772577+ printk(KERN_WARNING "scsi_debug: driver_register error: %d\n",25782578+ ret);25792579+ goto bus_unreg;25802580+ }25812581+ ret = do_create_driverfs_files();25822582+ if (ret < 0) {25832583+ printk(KERN_WARNING "scsi_debug: driver_create_file error: %d\n",25842584+ ret);25852585+ goto del_files;25862586+ }2568258725692569- device_register(&pseudo_primary);25702570- bus_register(&pseudo_lld_bus);25712571- driver_register(&sdebug_driverfs_driver);25722572- do_create_driverfs_files();25882588+ init_all_queued();2573258925742590 sdebug_driver_template.proc_name = (char *)sdebug_proc_name;25752591···26092585 scsi_debug_add_host);26102586 }26112587 return 0;25882588+25892589+del_files:25902590+ do_remove_driverfs_files();25912591+ driver_unregister(&sdebug_driverfs_driver);25922592+bus_unreg:25932593+ bus_unregister(&pseudo_lld_bus);25942594+dev_unreg:25952595+ device_unregister(&pseudo_primary);25962596+free_vm:25972597+ vfree(fake_storep);25982598+25992599+ return ret;26122600}2613260126142602static void __exit scsi_debug_exit(void)
+89-121
drivers/scsi/scsi_error.c
···460460 * Return value:461461 * SUCCESS or FAILED or NEEDS_RETRY462462 **/463463-static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout)463463+static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout, int copy_sense)464464{465465 struct scsi_device *sdev = scmd->device;466466 struct Scsi_Host *shost = sdev->host;467467+ int old_result = scmd->result;467468 DECLARE_COMPLETION(done);468469 unsigned long timeleft;469470 unsigned long flags;471471+ unsigned char old_cmnd[MAX_COMMAND_SIZE];472472+ enum dma_data_direction old_data_direction;473473+ unsigned short old_use_sg;474474+ unsigned char old_cmd_len;475475+ unsigned old_bufflen;476476+ void *old_buffer;470477 int rtn;478478+479479+ /*480480+ * We need saved copies of a number of fields - this is because481481+ * error handling may need to overwrite these with different values482482+ * to run different commands, and once error handling is complete,483483+ * we will need to restore these values prior to running the actual484484+ * command.485485+ */486486+ old_buffer = scmd->request_buffer;487487+ old_bufflen = scmd->request_bufflen;488488+ memcpy(old_cmnd, scmd->cmnd, sizeof(scmd->cmnd));489489+ old_data_direction = scmd->sc_data_direction;490490+ old_cmd_len = scmd->cmd_len;491491+ old_use_sg = scmd->use_sg;492492+493493+ if (copy_sense) {494494+ int gfp_mask = GFP_ATOMIC;495495+496496+ if (shost->hostt->unchecked_isa_dma)497497+ gfp_mask |= __GFP_DMA;498498+499499+ scmd->sc_data_direction = DMA_FROM_DEVICE;500500+ scmd->request_bufflen = 252;501501+ scmd->request_buffer = kzalloc(scmd->request_bufflen, gfp_mask);502502+ if (!scmd->request_buffer)503503+ return FAILED;504504+ } else {505505+ scmd->request_buffer = NULL;506506+ scmd->request_bufflen = 0;507507+ scmd->sc_data_direction = DMA_NONE;508508+ }509509+510510+ scmd->underflow = 0;511511+ scmd->use_sg = 0;512512+ scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);471513472514 if (sdev->scsi_level <= SCSI_2)473515 scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) |474516 (sdev->lun << 5 & 0xe0);517517+518518+ /*519519+ * Zero the sense buffer. The scsi spec mandates that any520520+ * untransferred sense data should be interpreted as being zero.521521+ */522522+ memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));475523476524 shost->eh_action = &done;477525···570522 rtn = FAILED;571523 }572524525525+526526+ /*527527+ * Last chance to have valid sense data.528528+ */529529+ if (copy_sense) {530530+ if (!SCSI_SENSE_VALID(scmd)) {531531+ memcpy(scmd->sense_buffer, scmd->request_buffer,532532+ sizeof(scmd->sense_buffer));533533+ }534534+ kfree(scmd->request_buffer);535535+ }536536+537537+538538+ /*539539+ * Restore original data540540+ */541541+ scmd->request_buffer = old_buffer;542542+ scmd->request_bufflen = old_bufflen;543543+ memcpy(scmd->cmnd, old_cmnd, sizeof(scmd->cmnd));544544+ scmd->sc_data_direction = old_data_direction;545545+ scmd->cmd_len = old_cmd_len;546546+ scmd->use_sg = old_use_sg;547547+ scmd->result = old_result;573548 return rtn;574549}575550···608537static int scsi_request_sense(struct scsi_cmnd *scmd)609538{610539 static unsigned char generic_sense[6] =611611- {REQUEST_SENSE, 0, 0, 0, 252, 0};612612- unsigned char *scsi_result;613613- int saved_result;614614- int rtn;540540+ {REQUEST_SENSE, 0, 0, 0, 252, 0};615541616542 memcpy(scmd->cmnd, generic_sense, sizeof(generic_sense));617617-618618- scsi_result = kmalloc(252, GFP_ATOMIC | ((scmd->device->host->hostt->unchecked_isa_dma) ? __GFP_DMA : 0));619619-620620-621621- if (unlikely(!scsi_result)) {622622- printk(KERN_ERR "%s: cannot allocate scsi_result.\n",623623- __FUNCTION__);624624- return FAILED;625625- }626626-627627- /*628628- * zero the sense buffer. some host adapters automatically always629629- * request sense, so it is not a good idea that630630- * scmd->request_buffer and scmd->sense_buffer point to the same631631- * address (db). 0 is not a valid sense code. 632632- */633633- memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));634634- memset(scsi_result, 0, 252);635635-636636- saved_result = scmd->result;637637- scmd->request_buffer = scsi_result;638638- scmd->request_bufflen = 252;639639- scmd->use_sg = 0;640640- scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);641641- scmd->sc_data_direction = DMA_FROM_DEVICE;642642- scmd->underflow = 0;643643-644644- rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT);645645-646646- /* last chance to have valid sense data */647647- if(!SCSI_SENSE_VALID(scmd)) {648648- memcpy(scmd->sense_buffer, scmd->request_buffer,649649- sizeof(scmd->sense_buffer));650650- }651651-652652- kfree(scsi_result);653653-654654- /*655655- * when we eventually call scsi_finish, we really wish to complete656656- * the original request, so let's restore the original data. (db)657657- */658658- scsi_setup_cmd_retry(scmd);659659- scmd->result = saved_result;660660- return rtn;543543+ return scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT, 1);661544}662545663546/**···630605{631606 scmd->device->host->host_failed--;632607 scmd->eh_eflags = 0;633633-634634- /*635635- * set this back so that the upper level can correctly free up636636- * things.637637- */638638- scsi_setup_cmd_retry(scmd);639608 list_move_tail(&scmd->eh_entry, done_q);640609}641610EXPORT_SYMBOL(scsi_eh_finish_cmd);···734715{735716 static unsigned char tur_command[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};736717 int retry_cnt = 1, rtn;737737- int saved_result;738718739719retry_tur:740720 memcpy(scmd->cmnd, tur_command, sizeof(tur_command));741721742742- /*743743- * zero the sense buffer. the scsi spec mandates that any744744- * untransferred sense data should be interpreted as being zero.745745- */746746- memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));747722748748- saved_result = scmd->result;749749- scmd->request_buffer = NULL;750750- scmd->request_bufflen = 0;751751- scmd->use_sg = 0;752752- scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);753753- scmd->underflow = 0;754754- scmd->sc_data_direction = DMA_NONE;723723+ rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT, 0);755724756756- rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT);757757-758758- /*759759- * when we eventually call scsi_finish, we really wish to complete760760- * the original request, so let's restore the original data. (db)761761- */762762- scsi_setup_cmd_retry(scmd);763763- scmd->result = saved_result;764764-765765- /*766766- * hey, we are done. let's look to see what happened.767767- */768725 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",769726 __FUNCTION__, scmd, rtn));770770- if (rtn == SUCCESS)771771- return 0;772772- else if (rtn == NEEDS_RETRY) {727727+728728+ switch (rtn) {729729+ case NEEDS_RETRY:773730 if (retry_cnt--)774731 goto retry_tur;732732+ /*FALLTHRU*/733733+ case SUCCESS:775734 return 0;735735+ default:736736+ return 1;776737 }777777- return 1;778738}779739780740/**···835837static int scsi_eh_try_stu(struct scsi_cmnd *scmd)836838{837839 static unsigned char stu_command[6] = {START_STOP, 0, 0, 0, 1, 0};838838- int rtn;839839- int saved_result;840840841841- if (!scmd->device->allow_restart)842842- return 1;841841+ if (scmd->device->allow_restart) {842842+ int rtn;843843844844- memcpy(scmd->cmnd, stu_command, sizeof(stu_command));844844+ memcpy(scmd->cmnd, stu_command, sizeof(stu_command));845845+ rtn = scsi_send_eh_cmnd(scmd, START_UNIT_TIMEOUT, 0);846846+ if (rtn == SUCCESS)847847+ return 0;848848+ }845849846846- /*847847- * zero the sense buffer. the scsi spec mandates that any848848- * untransferred sense data should be interpreted as being zero.849849- */850850- memset(scmd->sense_buffer, 0, sizeof(scmd->sense_buffer));851851-852852- saved_result = scmd->result;853853- scmd->request_buffer = NULL;854854- scmd->request_bufflen = 0;855855- scmd->use_sg = 0;856856- scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);857857- scmd->underflow = 0;858858- scmd->sc_data_direction = DMA_NONE;859859-860860- rtn = scsi_send_eh_cmnd(scmd, START_UNIT_TIMEOUT);861861-862862- /*863863- * when we eventually call scsi_finish, we really wish to complete864864- * the original request, so let's restore the original data. (db)865865- */866866- scsi_setup_cmd_retry(scmd);867867- scmd->result = saved_result;868868-869869- /*870870- * hey, we are done. let's look to see what happened.871871- */872872- SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",873873- __FUNCTION__, scmd, rtn));874874- if (rtn == SUCCESS)875875- return 0;876850 return 1;877851}878852···1654168416551685 scmd->scsi_done = scsi_reset_provider_done_command;16561686 scmd->done = NULL;16571657- scmd->buffer = NULL;16581658- scmd->bufflen = 0;16591687 scmd->request_buffer = NULL;16601688 scmd->request_bufflen = 0;16611689
+6-82
drivers/scsi/scsi_lib.c
···436436 *437437 * Arguments: cmd - command that is ready to be queued.438438 *439439- * Returns: Nothing440440- *441439 * Notes: This function has the job of initializing a number of442440 * fields related to error handling. Typically this will443441 * be called once for each command, as required.444442 */445445-static int scsi_init_cmd_errh(struct scsi_cmnd *cmd)443443+static void scsi_init_cmd_errh(struct scsi_cmnd *cmd)446444{447445 cmd->serial_number = 0;448448-449446 memset(cmd->sense_buffer, 0, sizeof cmd->sense_buffer);450450-451447 if (cmd->cmd_len == 0)452448 cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]);453453-454454- /*455455- * We need saved copies of a number of fields - this is because456456- * error handling may need to overwrite these with different values457457- * to run different commands, and once error handling is complete,458458- * we will need to restore these values prior to running the actual459459- * command.460460- */461461- cmd->old_use_sg = cmd->use_sg;462462- cmd->old_cmd_len = cmd->cmd_len;463463- cmd->sc_old_data_direction = cmd->sc_data_direction;464464- cmd->old_underflow = cmd->underflow;465465- memcpy(cmd->data_cmnd, cmd->cmnd, sizeof(cmd->cmnd));466466- cmd->buffer = cmd->request_buffer;467467- cmd->bufflen = cmd->request_bufflen;468468-469469- return 1;470470-}471471-472472-/*473473- * Function: scsi_setup_cmd_retry()474474- *475475- * Purpose: Restore the command state for a retry476476- *477477- * Arguments: cmd - command to be restored478478- *479479- * Returns: Nothing480480- *481481- * Notes: Immediately prior to retrying a command, we need482482- * to restore certain fields that we saved above.483483- */484484-void scsi_setup_cmd_retry(struct scsi_cmnd *cmd)485485-{486486- memcpy(cmd->cmnd, cmd->data_cmnd, sizeof(cmd->data_cmnd));487487- cmd->request_buffer = cmd->buffer;488488- cmd->request_bufflen = cmd->bufflen;489489- cmd->use_sg = cmd->old_use_sg;490490- cmd->cmd_len = cmd->old_cmd_len;491491- cmd->sc_data_direction = cmd->sc_old_data_direction;492492- cmd->underflow = cmd->old_underflow;493449}494450495451void scsi_device_unbusy(struct scsi_device *sdev)···763807 */764808static void scsi_release_buffers(struct scsi_cmnd *cmd)765809{766766- struct request *req = cmd->request;767767-768768- /*769769- * Free up any indirection buffers we allocated for DMA purposes. 770770- */771810 if (cmd->use_sg)772811 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);773773- else if (cmd->request_buffer != req->buffer)774774- kfree(cmd->request_buffer);775812776813 /*777814 * Zero these out. They now point to freed memory, and it is778815 * dangerous to hang onto the pointers.779816 */780780- cmd->buffer = NULL;781781- cmd->bufflen = 0;782817 cmd->request_buffer = NULL;783818 cmd->request_bufflen = 0;784819}···805858void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)806859{807860 int result = cmd->result;808808- int this_count = cmd->bufflen;861861+ int this_count = cmd->request_bufflen;809862 request_queue_t *q = cmd->device->request_queue;810863 struct request *req = cmd->request;811864 int clear_errors = 1;···813866 int sense_valid = 0;814867 int sense_deferred = 0;815868816816- /*817817- * Free up any indirection buffers we allocated for DMA purposes. 818818- * For the case of a READ, we need to copy the data out of the819819- * bounce buffer and into the real buffer.820820- */821821- if (cmd->use_sg)822822- scsi_free_sgtable(cmd->buffer, cmd->sglist_len);823823- else if (cmd->buffer != req->buffer) {824824- if (rq_data_dir(req) == READ) {825825- unsigned long flags;826826- char *to = bio_kmap_irq(req->bio, &flags);827827- memcpy(to, cmd->buffer, cmd->bufflen);828828- bio_kunmap_irq(to, &flags);829829- }830830- kfree(cmd->buffer);831831- }869869+ scsi_release_buffers(cmd);832870833871 if (result) {834872 sense_valid = scsi_command_normalize_sense(cmd, &sshdr);835873 if (sense_valid)836874 sense_deferred = scsi_sense_is_deferred(&sshdr);837875 }876876+838877 if (blk_pc_request(req)) { /* SG_IO ioctl from block level */839878 req->errors = result;840879 if (result) {···839906 } else840907 req->data_len = cmd->resid;841908 }842842-843843- /*844844- * Zero these out. They now point to freed memory, and it is845845- * dangerous to hang onto the pointers.846846- */847847- cmd->buffer = NULL;848848- cmd->bufflen = 0;849849- cmd->request_buffer = NULL;850850- cmd->request_bufflen = 0;851909852910 /*853911 * Next deal with any sectors which we were able to correctly···9361012 if (!(req->flags & REQ_QUIET)) {9371013 scmd_printk(KERN_INFO, cmd,9381014 "Volume overflow, CDB: ");939939- __scsi_print_command(cmd->data_cmnd);10151015+ __scsi_print_command(cmd->cmnd);9401016 scsi_print_sense("", cmd);9411017 }9421018 /* See SSC3rXX or current. */···10671143 * successfully. Since this is a REQ_BLOCK_PC command the10681144 * caller should check the request's errors value10691145 */10701070- scsi_io_completion(cmd, cmd->bufflen);11461146+ scsi_io_completion(cmd, cmd->request_bufflen);10711147}1072114810731149static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)
-1
drivers/scsi/scsi_priv.h
···57575858/* scsi_lib.c */5959extern int scsi_maybe_unblock_host(struct scsi_device *sdev);6060-extern void scsi_setup_cmd_retry(struct scsi_cmnd *cmd);6160extern void scsi_device_unbusy(struct scsi_device *sdev);6261extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason);6362extern void scsi_next_command(struct scsi_cmnd *cmd);
+58-6
drivers/scsi/scsi_transport_sas.c
···4141 struct mutex lock;4242 u32 next_target_id;4343 u32 next_expander_id;4444+ int next_port_id;4445};4546#define to_sas_host_attrs(host) ((struct sas_host_attrs *)(host)->shost_data)4647···147146 mutex_init(&sas_host->lock);148147 sas_host->next_target_id = 0;149148 sas_host->next_expander_id = 0;149149+ sas_host->next_port_id = 0;150150 return 0;151151}152152···329327sas_phy_simple_attr(identify.sas_address, sas_address, "0x%016llx\n",330328 unsigned long long);331329sas_phy_simple_attr(identify.phy_identifier, phy_identifier, "%d\n", u8);332332-//sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", u8);330330+//sas_phy_simple_attr(port_identifier, port_identifier, "%d\n", int);333331sas_phy_linkspeed_attr(negotiated_linkrate);334332sas_phy_linkspeed_attr(minimum_linkrate_hw);335333sas_phy_linkspeed_attr(minimum_linkrate);···592590}593591EXPORT_SYMBOL(sas_port_alloc);594592593593+/** sas_port_alloc_num - allocate and initialize a SAS port structure594594+ *595595+ * @parent: parent device596596+ *597597+ * Allocates a SAS port structure and a number to go with it. This598598+ * interface is really for adapters where the port number has no599599+ * meansing, so the sas class should manage them. It will be added to600600+ * the device tree below the device specified by @parent which must be601601+ * either a Scsi_Host or a sas_expander_device.602602+ *603603+ * Returns %NULL on error604604+ */605605+struct sas_port *sas_port_alloc_num(struct device *parent)606606+{607607+ int index;608608+ struct Scsi_Host *shost = dev_to_shost(parent);609609+ struct sas_host_attrs *sas_host = to_sas_host_attrs(shost);610610+611611+ /* FIXME: use idr for this eventually */612612+ mutex_lock(&sas_host->lock);613613+ if (scsi_is_sas_expander_device(parent)) {614614+ struct sas_rphy *rphy = dev_to_rphy(parent);615615+ struct sas_expander_device *exp = rphy_to_expander_device(rphy);616616+617617+ index = exp->next_port_id++;618618+ } else619619+ index = sas_host->next_port_id++;620620+ mutex_unlock(&sas_host->lock);621621+ return sas_port_alloc(parent, index);622622+}623623+EXPORT_SYMBOL(sas_port_alloc_num);624624+595625/**596626 * sas_port_add - add a SAS port to the device hierarchy597627 *···691657 list_del_init(&phy->port_siblings);692658 }693659 mutex_unlock(&port->phy_list_mutex);660660+661661+ if (port->is_backlink) {662662+ struct device *parent = port->dev.parent;663663+664664+ sysfs_remove_link(&port->dev.kobj, parent->bus_id);665665+ port->is_backlink = 0;666666+ }694667695668 transport_remove_device(dev);696669 device_del(dev);···773732 mutex_unlock(&port->phy_list_mutex);774733}775734EXPORT_SYMBOL(sas_port_delete_phy);735735+736736+void sas_port_mark_backlink(struct sas_port *port)737737+{738738+ struct device *parent = port->dev.parent->parent->parent;739739+740740+ if (port->is_backlink)741741+ return;742742+ port->is_backlink = 1;743743+ sysfs_create_link(&port->dev.kobj, &parent->kobj,744744+ parent->bus_id);745745+746746+}747747+EXPORT_SYMBOL(sas_port_mark_backlink);776748777749/*778750 * SAS remote PHY attributes.···1194114011951141 if (identify->device_type == SAS_END_DEVICE &&11961142 rphy->scsi_target_id != -1) {11971197- scsi_scan_target(&rphy->dev, parent->port_identifier,11431143+ scsi_scan_target(&rphy->dev, 0,11981144 rphy->scsi_target_id, ~0, 0);11991145 }12001146···1296124212971243 mutex_lock(&sas_host->lock);12981244 list_for_each_entry(rphy, &sas_host->rphy_list, list) {12991299- struct sas_port *parent = dev_to_sas_port(rphy->dev.parent);13001300-13011245 if (rphy->identify.device_type != SAS_END_DEVICE ||13021246 rphy->scsi_target_id == -1)13031247 continue;1304124813051305- if ((channel == SCAN_WILD_CARD || channel == parent->port_identifier) &&12491249+ if ((channel == SCAN_WILD_CARD || channel == 0) &&13061250 (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) {13071307- scsi_scan_target(&rphy->dev, parent->port_identifier,12511251+ scsi_scan_target(&rphy->dev, 0,13081252 rphy->scsi_target_id, lun, 1);13091253 }13101254 }
+1-2
drivers/scsi/sd.c
···502502 SCpnt->cmnd[4] = (unsigned char) this_count;503503 SCpnt->cmnd[5] = 0;504504 }505505- SCpnt->request_bufflen = SCpnt->bufflen =506506- this_count * sdp->sector_size;505505+ SCpnt->request_bufflen = this_count * sdp->sector_size;507506508507 /*509508 * We shouldn't disconnect in the middle of a sector, so with a dumb
···244244/* Does the passed node have the given "name"? YES=1 NO=0 */245245extern int prom_nodematch(int thisnode, char *name);246246247247-/* Puts in buffer a prom name in the form name@x,y or name (x for which_io248248- * and y for first regs phys address249249- */250250-extern int prom_getname(int node, char *buf, int buflen);251251-252247/* Search all siblings starting at the passed node for "name" matching253248 * the given string. Returns the node on success, zero on failure.254249 */
···1919{2020 cycles_t cycles;21212222- __asm__("stck 0(%1)" : "=m" (cycles) : "a" (&cycles) : "cc");2222+ __asm__ __volatile__ ("stck 0(%1)" : "=m" (cycles) : "a" (&cycles) : "cc");2323 return cycles >> 2;2424}2525···2727{2828 unsigned long long clk;29293030- __asm__("stck 0(%1)" : "=m" (clk) : "a" (&clk) : "cc");3030+ __asm__ __volatile__ ("stck 0(%1)" : "=m" (clk) : "a" (&clk) : "cc");3131 return clk;3232}3333
-5
include/asm-sparc/oplib.h
···267267/* Does the passed node have the given "name"? YES=1 NO=0 */268268extern int prom_nodematch(int thisnode, char *name);269269270270-/* Puts in buffer a prom name in the form name@x,y or name (x for which_io 271271- * and y for first regs phys address272272- */273273-extern int prom_getname(int node, char *buf, int buflen);274274-275270/* Search all siblings starting at the passed node for "name" matching276271 * the given string. Returns the node on success, zero on failure.277272 */
+1-1
include/asm-sparc64/openprom.h
···175175};176176177177/* More fun PROM structures for device probing. */178178-#define PROMREG_MAX 16178178+#define PROMREG_MAX 24179179#define PROMVADDR_MAX 16180180#define PROMINTR_MAX 15181181
-5
include/asm-sparc64/oplib.h
···287287/* Does the passed node have the given "name"? YES=1 NO=0 */288288extern int prom_nodematch(int thisnode, const char *name);289289290290-/* Puts in buffer a prom name in the form name@x,y or name (x for which_io 291291- * and y for first regs phys address292292- */293293-extern int prom_getname(int node, char *buf, int buflen);294294-295290/* Search all siblings starting at the passed node for "name" matching296291 * the given string. Returns the node on success, zero on failure.297292 */
-6
include/linux/cpu.h
···4848{4949}5050#endif5151-extern int current_in_cpu_hotplug(void);52515352int cpu_up(unsigned int cpu);5453···6061static inline void unregister_cpu_notifier(struct notifier_block *nb)6162{6263}6363-static inline int current_in_cpu_hotplug(void)6464-{6565- return 0;6666-}67646865#endif /* CONFIG_SMP */6966extern struct sysdev_class cpu_sysdev_class;···6873/* Stop CPUs going up and down. */6974extern void lock_cpu_hotplug(void);7075extern void unlock_cpu_hotplug(void);7171-extern int lock_cpu_hotplug_interruptible(void);7276#define hotcpu_notifier(fn, pri) { \7377 static struct notifier_block fn##_nb = \7478 { .notifier_call = fn, .priority = pri }; \
+3-3
include/linux/netdevice.h
···924924925925static inline int netif_tx_trylock(struct net_device *dev)926926{927927- int err = spin_trylock(&dev->_xmit_lock);928928- if (!err)927927+ int ok = spin_trylock(&dev->_xmit_lock);928928+ if (likely(ok))929929 dev->xmit_lock_owner = smp_processor_id();930930- return err;930930+ return ok;931931}932932933933static inline void netif_tx_unlock(struct net_device *dev)
···445445 struct sctp_paramhdr param_hdr;446446 union sctp_addr daddr;447447 unsigned long sent_at;448448+ __u64 hb_nonce;448449} __attribute__((packed)) sctp_sender_hb_info_t;449450450451/*···731730const union sctp_addr *sctp_source(const struct sctp_chunk *chunk);732731733732/* This is a structure for holding either an IPv6 or an IPv4 address. */734734-/* sin_family -- AF_INET or AF_INET6735735- * sin_port -- ordinary port number736736- * sin_addr -- cast to either (struct in_addr) or (struct in6_addr)737737- */738733struct sctp_sockaddr_entry {739734 struct list_head list;740735 union sctp_addr a;736736+ __u8 use_as_src;741737};742738743739typedef struct sctp_chunk *(sctp_packet_phandler_t)(struct sctp_association *);···982984 */983985 char cacc_saw_newack;984986 } cacc;987987+988988+ /* 64-bit random number sent with heartbeat. */989989+ __u64 hb_nonce;985990};986991987992struct sctp_transport *sctp_transport_new(const union sctp_addr *,···11391138 sctp_scope_t scope, gfp_t gfp,11401139 int flags);11411140int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *,11421142- gfp_t gfp);11411141+ __u8 use_as_src, gfp_t gfp);11431142int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);11441143int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,11451144 struct sctp_sock *);
+9
include/net/sctp/user.h
···560560} __attribute__((packed, aligned(4)));561561562562/* Peer addresses's state. */563563+/* UNKNOWN: Peer address passed by the upper layer in sendmsg or connect[x]564564+ * calls.565565+ * UNCONFIRMED: Peer address received in INIT/INIT-ACK address parameters.566566+ * Not yet confirmed by a heartbeat and not available for data567567+ * transfers.568568+ * ACTIVE : Peer address confirmed, active and available for data transfers.569569+ * INACTIVE: Peer address inactive and not available for data transfers.570570+ */563571enum sctp_spinfo_state {564572 SCTP_INACTIVE,565573 SCTP_ACTIVE,574574+ SCTP_UNCONFIRMED,566575 SCTP_UNKNOWN = 0xffff /* Value used for transport state unknown */567576};568577
-9
include/scsi/scsi_cmnd.h
···5858 int timeout_per_command;59596060 unsigned char cmd_len;6161- unsigned char old_cmd_len;6261 enum dma_data_direction sc_data_direction;6363- enum dma_data_direction sc_old_data_direction;64626563 /* These elements define the operation we are about to perform */6664#define MAX_COMMAND_SIZE 16···6971 void *request_buffer; /* Actual requested buffer */70727173 /* These elements define the operation we ultimately want to perform */7272- unsigned char data_cmnd[MAX_COMMAND_SIZE];7373- unsigned short old_use_sg; /* We save use_sg here when requesting7474- * sense info */7574 unsigned short use_sg; /* Number of pieces of scatter-gather */7675 unsigned short sglist_len; /* size of malloc'd scatter-gather list */7777- unsigned bufflen; /* Size of data buffer */7878- void *buffer; /* Data buffer */79768077 unsigned underflow; /* Return error if less than8178 this amount is transferred */8282- unsigned old_underflow; /* save underflow here when reusing the8383- * command for error handling */84798580 unsigned transfersize; /* How much we are guaranteed to8681 transfer with each SCSI transfer
+6-1
include/scsi/scsi_transport_sas.h
···106106107107struct sas_expander_device {108108 int level;109109+ int next_port_id;109110110111 #define SAS_EXPANDER_VENDOR_ID_LEN 8111112 char vendor_id[SAS_EXPANDER_VENDOR_ID_LEN+1];···128127struct sas_port {129128 struct device dev;130129131131- u8 port_identifier;130130+ int port_identifier;132131 int num_phys;132132+ /* port flags */133133+ unsigned int is_backlink:1;133134134135 /* the other end of the link */135136 struct sas_rphy *rphy;···171168extern int scsi_is_sas_rphy(const struct device *);172169173170struct sas_port *sas_port_alloc(struct device *, int);171171+struct sas_port *sas_port_alloc_num(struct device *);174172int sas_port_add(struct sas_port *);175173void sas_port_free(struct sas_port *);176174void sas_port_delete(struct sas_port *);177175void sas_port_add_phy(struct sas_port *, struct sas_phy *);178176void sas_port_delete_phy(struct sas_port *, struct sas_phy *);177177+void sas_port_mark_backlink(struct sas_port *);179178int scsi_is_sas_port(const struct device *);180179181180extern struct scsi_transport_template *
+34-41
kernel/cpu.c
···1616#include <linux/mutex.h>17171818/* This protects CPUs going up and down... */1919-static DEFINE_MUTEX(cpucontrol);1919+static DEFINE_MUTEX(cpu_add_remove_lock);2020+static DEFINE_MUTEX(cpu_bitmask_lock);20212122static __cpuinitdata BLOCKING_NOTIFIER_HEAD(cpu_chain);22232324#ifdef CONFIG_HOTPLUG_CPU2424-static struct task_struct *lock_cpu_hotplug_owner;2525-static int lock_cpu_hotplug_depth;26252727-static int __lock_cpu_hotplug(int interruptible)2828-{2929- int ret = 0;3030-3131- if (lock_cpu_hotplug_owner != current) {3232- if (interruptible)3333- ret = mutex_lock_interruptible(&cpucontrol);3434- else3535- mutex_lock(&cpucontrol);3636- }3737-3838- /*3939- * Set only if we succeed in locking4040- */4141- if (!ret) {4242- lock_cpu_hotplug_depth++;4343- lock_cpu_hotplug_owner = current;4444- }4545-4646- return ret;4747-}2626+/* Crappy recursive lock-takers in cpufreq! Complain loudly about idiots */2727+static struct task_struct *recursive;2828+static int recursive_depth;48294930void lock_cpu_hotplug(void)5031{5151- __lock_cpu_hotplug(0);3232+ struct task_struct *tsk = current;3333+3434+ if (tsk == recursive) {3535+ static int warnings = 10;3636+ if (warnings) {3737+ printk(KERN_ERR "Lukewarm IQ detected in hotplug locking\n");3838+ WARN_ON(1);3939+ warnings--;4040+ }4141+ recursive_depth++;4242+ return;4343+ }4444+ mutex_lock(&cpu_bitmask_lock);4545+ recursive = tsk;5246}5347EXPORT_SYMBOL_GPL(lock_cpu_hotplug);54485549void unlock_cpu_hotplug(void)5650{5757- if (--lock_cpu_hotplug_depth == 0) {5858- lock_cpu_hotplug_owner = NULL;5959- mutex_unlock(&cpucontrol);5151+ WARN_ON(recursive != current);5252+ if (recursive_depth) {5353+ recursive_depth--;5454+ return;6055 }5656+ mutex_unlock(&cpu_bitmask_lock);5757+ recursive = NULL;6158}6259EXPORT_SYMBOL_GPL(unlock_cpu_hotplug);63606464-int lock_cpu_hotplug_interruptible(void)6565-{6666- return __lock_cpu_hotplug(1);6767-}6868-EXPORT_SYMBOL_GPL(lock_cpu_hotplug_interruptible);6961#endif /* CONFIG_HOTPLUG_CPU */70627163/* Need to know about CPUs going up/down? */···114122 struct task_struct *p;115123 cpumask_t old_allowed, tmp;116124117117- if ((err = lock_cpu_hotplug_interruptible()) != 0)118118- return err;119119-125125+ mutex_lock(&cpu_add_remove_lock);120126 if (num_online_cpus() == 1) {121127 err = -EBUSY;122128 goto out;···140150 cpu_clear(cpu, tmp);141151 set_cpus_allowed(current, tmp);142152153153+ mutex_lock(&cpu_bitmask_lock);143154 p = __stop_machine_run(take_cpu_down, NULL, cpu);155155+ mutex_unlock(&cpu_bitmask_lock);156156+144157 if (IS_ERR(p)) {145158 /* CPU didn't die: tell everyone. Can't complain. */146159 if (blocking_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED,···180187out_allowed:181188 set_cpus_allowed(current, old_allowed);182189out:183183- unlock_cpu_hotplug();190190+ mutex_unlock(&cpu_add_remove_lock);184191 return err;185192}186193#endif /*CONFIG_HOTPLUG_CPU*/···190197 int ret;191198 void *hcpu = (void *)(long)cpu;192199193193- if ((ret = lock_cpu_hotplug_interruptible()) != 0)194194- return ret;195195-200200+ mutex_lock(&cpu_add_remove_lock);196201 if (cpu_online(cpu) || !cpu_present(cpu)) {197202 ret = -EINVAL;198203 goto out;···205214 }206215207216 /* Arch-specific enabling code. */217217+ mutex_lock(&cpu_bitmask_lock);208218 ret = __cpu_up(cpu);219219+ mutex_unlock(&cpu_bitmask_lock);209220 if (ret != 0)210221 goto out_notify;211222 BUG_ON(!cpu_online(cpu));···220227 blocking_notifier_call_chain(&cpu_chain,221228 CPU_UP_CANCELED, hcpu);222229out:223223- unlock_cpu_hotplug();230230+ mutex_unlock(&cpu_add_remove_lock);224231 return ret;225232}
+21-3
kernel/cpuset.c
···762762 *763763 * Call with manage_mutex held. May nest a call to the764764 * lock_cpu_hotplug()/unlock_cpu_hotplug() pair.765765+ * Must not be called holding callback_mutex, because we must766766+ * not call lock_cpu_hotplug() while holding callback_mutex.765767 */766768767769static void update_cpu_domains(struct cpuset *cur)···783781 if (is_cpu_exclusive(c))784782 cpus_andnot(pspan, pspan, c->cpus_allowed);785783 }786786- if (is_removed(cur) || !is_cpu_exclusive(cur)) {784784+ if (!is_cpu_exclusive(cur)) {787785 cpus_or(pspan, pspan, cur->cpus_allowed);788786 if (cpus_equal(pspan, cur->cpus_allowed))789787 return;···19191917 return cpuset_create(c_parent, dentry->d_name.name, mode | S_IFDIR);19201918}1921191919201920+/*19211921+ * Locking note on the strange update_flag() call below:19221922+ *19231923+ * If the cpuset being removed is marked cpu_exclusive, then simulate19241924+ * turning cpu_exclusive off, which will call update_cpu_domains().19251925+ * The lock_cpu_hotplug() call in update_cpu_domains() must not be19261926+ * made while holding callback_mutex. Elsewhere the kernel nests19271927+ * callback_mutex inside lock_cpu_hotplug() calls. So the reverse19281928+ * nesting would risk an ABBA deadlock.19291929+ */19301930+19221931static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry)19231932{19241933 struct cpuset *cs = dentry->d_fsdata;···19491936 mutex_unlock(&manage_mutex);19501937 return -EBUSY;19511938 }19391939+ if (is_cpu_exclusive(cs)) {19401940+ int retval = update_flag(CS_CPU_EXCLUSIVE, cs, "0");19411941+ if (retval < 0) {19421942+ mutex_unlock(&manage_mutex);19431943+ return retval;19441944+ }19451945+ }19521946 parent = cs->parent;19531947 mutex_lock(&callback_mutex);19541948 set_bit(CS_REMOVED, &cs->flags);19551955- if (is_cpu_exclusive(cs))19561956- update_cpu_domains(cs);19571949 list_del(&cs->sibling); /* delete my sibling from parent->children */19581950 spin_lock(&cs->dentry->d_lock);19591951 d = dget(cs->dentry);
+1-2
net/8021q/vlan.c
···542542 * so it cannot "appear" on us.543543 */544544 if (!grp) { /* need to add a new group */545545- grp = kmalloc(sizeof(struct vlan_group), GFP_KERNEL);545545+ grp = kzalloc(sizeof(struct vlan_group), GFP_KERNEL);546546 if (!grp)547547 goto out_free_unregister;548548549549 /* printk(KERN_ALERT "VLAN REGISTER: Allocated new group.\n"); */550550- memset(grp, 0, sizeof(struct vlan_group));551550 grp->real_dev_ifindex = real_dev->ifindex;552551553552 hlist_add_head_rcu(&grp->hlist,
···162162 if (num > BR_MAX_PORTS)163163 num = BR_MAX_PORTS;164164165165- indices = kmalloc(num*sizeof(int), GFP_KERNEL);165165+ indices = kcalloc(num, sizeof(int), GFP_KERNEL);166166 if (indices == NULL)167167 return -ENOMEM;168168-169169- memset(indices, 0, num*sizeof(int));170168171169 get_port_ifindices(br, indices, num);172170 if (copy_to_user((void __user *)args[1], indices, num*sizeof(int)))···325327326328 if (args[2] >= 2048)327329 return -ENOMEM;328328- indices = kmalloc(args[2]*sizeof(int), GFP_KERNEL);330330+ indices = kcalloc(args[2], sizeof(int), GFP_KERNEL);329331 if (indices == NULL)330332 return -ENOMEM;331333332332- memset(indices, 0, args[2]*sizeof(int));333334 args[2] = get_bridge_ifindices(indices, args[2]);334335335336 ret = copy_to_user((void __user *)args[1], indices, args[2]*sizeof(int))
+1-1
net/core/ethtool.c
···437437{438438 struct ethtool_pauseparam pauseparam;439439440440- if (!dev->ethtool_ops->get_pauseparam)440440+ if (!dev->ethtool_ops->set_pauseparam)441441 return -EOPNOTSUPP;442442443443 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
···379379 self = hashbin_lock_find(ircomm_tty, line, NULL);380380 if (!self) {381381 /* No, so make new instance */382382- self = kmalloc(sizeof(struct ircomm_tty_cb), GFP_KERNEL);382382+ self = kzalloc(sizeof(struct ircomm_tty_cb), GFP_KERNEL);383383 if (self == NULL) {384384 IRDA_ERROR("%s(), kmalloc failed!\n", __FUNCTION__);385385 return -ENOMEM;386386 }387387- memset(self, 0, sizeof(struct ircomm_tty_cb));388387389388 self->magic = IRCOMM_TTY_MAGIC;390389 self->flow = FLOW_STOP;···758759 }759760 } else {760761 /* Prepare a full sized frame */761761- skb = dev_alloc_skb(self->max_data_size+762762- self->max_header_size);762762+ skb = alloc_skb(self->max_data_size+763763+ self->max_header_size,764764+ GFP_ATOMIC);763765 if (!skb) {764766 spin_unlock_irqrestore(&self->spinlock, flags);765767 return -ENOBUFS;
+1-3
net/irda/irda_device.c
···401401 }402402403403 /* Allocate dongle info for this instance */404404- dongle = kmalloc(sizeof(dongle_t), GFP_KERNEL);404404+ dongle = kzalloc(sizeof(dongle_t), GFP_KERNEL);405405 if (!dongle)406406 goto out;407407-408408- memset(dongle, 0, sizeof(dongle_t));409407410408 /* Bind the registration info to this particular instance */411409 dongle->issue = reg;
+5-4
net/irda/iriap.c
···345345 IRDA_ASSERT(self != NULL, return;);346346 IRDA_ASSERT(self->magic == IAS_MAGIC, return;);347347348348- tx_skb = dev_alloc_skb(64);348348+ tx_skb = alloc_skb(64, GFP_ATOMIC);349349 if (tx_skb == NULL) {350350 IRDA_DEBUG(0, "%s(), Could not allocate an sk_buff of length %d\n", 351351 __FUNCTION__, 64);···396396 attr_len = strlen(attr); /* Up to IAS_MAX_ATTRIBNAME = 60 */397397398398 skb_len = self->max_header_size+2+name_len+1+attr_len+4;399399- tx_skb = dev_alloc_skb(skb_len);399399+ tx_skb = alloc_skb(skb_len, GFP_ATOMIC);400400 if (!tx_skb)401401 return -ENOMEM;402402···562562 * value. We add 32 bytes because of the 6 bytes for the frame and563563 * max 5 bytes for the value coding.564564 */565565- tx_skb = dev_alloc_skb(value->len + self->max_header_size + 32);565565+ tx_skb = alloc_skb(value->len + self->max_header_size + 32,566566+ GFP_ATOMIC);566567 if (!tx_skb)567568 return;568569···701700 IRDA_ASSERT(self != NULL, return;);702701 IRDA_ASSERT(self->magic == IAS_MAGIC, return;);703702704704- tx_skb = dev_alloc_skb(64);703703+ tx_skb = alloc_skb(64, GFP_ATOMIC);705704 if (!tx_skb)706705 return;707706
+1-1
net/irda/iriap_event.c
···365365366366 switch (event) {367367 case IAP_LM_CONNECT_INDICATION:368368- tx_skb = dev_alloc_skb(64);368368+ tx_skb = alloc_skb(64, GFP_ATOMIC);369369 if (tx_skb == NULL) {370370 IRDA_WARNING("%s: unable to malloc!\n", __FUNCTION__);371371 return;
···773773 TCF_META_ID(hdr->right.kind) > TCF_META_ID_MAX)774774 goto errout;775775776776- meta = kmalloc(sizeof(*meta), GFP_KERNEL);776776+ meta = kzalloc(sizeof(*meta), GFP_KERNEL);777777 if (meta == NULL)778778 goto errout;779779- memset(meta, 0, sizeof(*meta));780779781780 memcpy(&meta->lvalue.hdr, &hdr->left, sizeof(hdr->left));782781 memcpy(&meta->rvalue.hdr, &hdr->right, sizeof(hdr->right));
+1-2
net/sched/ematch.c
···321321 list_len = RTA_PAYLOAD(rt_list);322322 matches_len = tree_hdr->nmatches * sizeof(*em);323323324324- tree->matches = kmalloc(matches_len, GFP_KERNEL);324324+ tree->matches = kzalloc(matches_len, GFP_KERNEL);325325 if (tree->matches == NULL)326326 goto errout;327327- memset(tree->matches, 0, matches_len);328327329328 /* We do not use rtattr_parse_nested here because the maximum330329 * number of attributes is unknown. This saves us the allocation
+1-2
net/sched/estimator.c
···139139 if (parm->interval < -2 || parm->interval > 3)140140 return -EINVAL;141141142142- est = kmalloc(sizeof(*est), GFP_KERNEL);142142+ est = kzalloc(sizeof(*est), GFP_KERNEL);143143 if (est == NULL)144144 return -ENOBUFS;145145146146- memset(est, 0, sizeof(*est));147146 est->interval = parm->interval + 2;148147 est->stats = stats;149148 est->stats_lock = stats_lock;
···148148static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)149149{150150 struct netem_sched_data *q = qdisc_priv(sch);151151- struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;151151+ /* We don't fill cb now as skb_unshare() may invalidate it */152152+ struct netem_skb_cb *cb;152153 struct sk_buff *skb2;153154 int ret;154155 int count = 1;···201200 skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);202201 }203202203203+ cb = (struct netem_skb_cb *)skb->cb;204204 if (q->gap == 0 /* not doing reordering */205205 || q->counter < q->gap /* inside last reordering gap */206206 || q->reorder < get_crandom(&q->reorder_cor)) {
+17-10
net/sctp/associola.c
···441441 /* If the primary path is changing, assume that the442442 * user wants to use this new path.443443 */444444- if (transport->state != SCTP_INACTIVE)444444+ if ((transport->state == SCTP_ACTIVE) ||445445+ (transport->state == SCTP_UNKNOWN))445446 asoc->peer.active_path = transport;446447447448 /*···533532 port = addr->v4.sin_port;534533535534 SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ",536536- " port: %d state:%s\n",535535+ " port: %d state:%d\n",537536 asoc,538537 addr,539538 addr->v4.sin_port,540540- peer_state == SCTP_UNKNOWN?"UNKNOWN":"ACTIVE");539539+ peer_state);541540542541 /* Set the port if it has not been set yet. */543542 if (0 == asoc->peer.port)···546545 /* Check to see if this is a duplicate. */547546 peer = sctp_assoc_lookup_paddr(asoc, addr);548547 if (peer) {549549- if (peer_state == SCTP_ACTIVE &&550550- peer->state == SCTP_UNKNOWN)551551- peer->state = SCTP_ACTIVE;548548+ if (peer->state == SCTP_UNKNOWN) {549549+ if (peer_state == SCTP_ACTIVE)550550+ peer->state = SCTP_ACTIVE;551551+ if (peer_state == SCTP_UNCONFIRMED)552552+ peer->state = SCTP_UNCONFIRMED;553553+ }552554 return peer;553555 }554556···743739 list_for_each(pos, &asoc->peer.transport_addr_list) {744740 t = list_entry(pos, struct sctp_transport, transports);745741746746- if (t->state == SCTP_INACTIVE)742742+ if ((t->state == SCTP_INACTIVE) ||743743+ (t->state == SCTP_UNCONFIRMED))747744 continue;748745 if (!first || t->last_time_heard > first->last_time_heard) {749746 second = first;···764759 * [If the primary is active but not most recent, bump the most765760 * recently used transport.]766761 */767767- if (asoc->peer.primary_path->state != SCTP_INACTIVE &&762762+ if (((asoc->peer.primary_path->state == SCTP_ACTIVE) ||763763+ (asoc->peer.primary_path->state == SCTP_UNKNOWN)) &&768764 first != asoc->peer.primary_path) {769765 second = first;770766 first = asoc->peer.primary_path;···10601054 transports);10611055 if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr))10621056 sctp_assoc_add_peer(asoc, &trans->ipaddr,10631063- GFP_ATOMIC, SCTP_ACTIVE);10571057+ GFP_ATOMIC, trans->state);10641058 }1065105910661060 asoc->ctsn_ack_point = asoc->next_tsn - 1;···1100109411011095 /* Try to find an active transport. */1102109611031103- if (t->state != SCTP_INACTIVE) {10971097+ if ((t->state == SCTP_ACTIVE) ||10981098+ (t->state == SCTP_UNKNOWN)) {11041099 break;11051100 } else {11061101 /* Keep track of the next transport in case
+5-3
net/sctp/bind_addr.c
···146146147147/* Add an address to the bind address list in the SCTP_bind_addr structure. */148148int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,149149- gfp_t gfp)149149+ __u8 use_as_src, gfp_t gfp)150150{151151 struct sctp_sockaddr_entry *addr;152152···162162 */163163 if (!addr->a.v4.sin_port)164164 addr->a.v4.sin_port = bp->port;165165+166166+ addr->use_as_src = use_as_src;165167166168 INIT_LIST_HEAD(&addr->list);167169 list_add_tail(&addr->list, &bp->address_list);···276274 }277275278276 af->from_addr_param(&addr, rawaddr, port, 0);279279- retval = sctp_add_bind_addr(bp, &addr, gfp);277277+ retval = sctp_add_bind_addr(bp, &addr, 1, gfp);280278 if (retval) {281279 /* Can't finish building the list, clean up. */282280 sctp_bind_addr_clean(bp);···369367 (((AF_INET6 == addr->sa.sa_family) &&370368 (flags & SCTP_ADDR6_ALLOWED) &&371369 (flags & SCTP_ADDR6_PEERSUPP))))372372- error = sctp_add_bind_addr(dest, addr, gfp);370370+ error = sctp_add_bind_addr(dest, addr, 1, gfp);373371 }374372375373 return error;
+6-5
net/sctp/endpointola.c
···158158void sctp_endpoint_free(struct sctp_endpoint *ep)159159{160160 ep->base.dead = 1;161161+162162+ ep->base.sk->sk_state = SCTP_SS_CLOSED;163163+164164+ /* Unlink this endpoint, so we can't find it again! */165165+ sctp_unhash_endpoint(ep);166166+161167 sctp_endpoint_put(ep);162168}163169···171165static void sctp_endpoint_destroy(struct sctp_endpoint *ep)172166{173167 SCTP_ASSERT(ep->base.dead, "Endpoint is not dead", return);174174-175175- ep->base.sk->sk_state = SCTP_SS_CLOSED;176176-177177- /* Unlink this endpoint, so we can't find it again! */178178- sctp_unhash_endpoint(ep);179168180169 /* Free up the HMAC transform. */181170 sctp_crypto_free_tfm(sctp_sk(ep->base.sk)->hmac);
···691691692692 if (!new_transport) {693693 new_transport = asoc->peer.active_path;694694- } else if (new_transport->state == SCTP_INACTIVE) {694694+ } else if ((new_transport->state == SCTP_INACTIVE) ||695695+ (new_transport->state == SCTP_UNCONFIRMED)) {695696 /* If the chunk is Heartbeat or Heartbeat Ack,696697 * send it to chunk->transport, even if it's697698 * inactive.···849848 */850849 new_transport = chunk->transport;851850 if (!new_transport ||852852- new_transport->state == SCTP_INACTIVE)851851+ ((new_transport->state == SCTP_INACTIVE) ||852852+ (new_transport->state == SCTP_UNCONFIRMED)))853853 new_transport = asoc->peer.active_path;854854855855 /* Change packets if necessary. */···14661464 /* Mark the destination transport address as14671465 * active if it is not so marked.14681466 */14691469- if (transport->state == SCTP_INACTIVE) {14671467+ if ((transport->state == SCTP_INACTIVE) ||14681468+ (transport->state == SCTP_UNCONFIRMED)) {14701469 sctp_assoc_control_transport(14711470 transport->asoc,14721471 transport,
···1493149314941494 /* Also, add the destination address. */14951495 if (list_empty(&retval->base.bind_addr.address_list)) {14961496- sctp_add_bind_addr(&retval->base.bind_addr, &chunk->dest,14961496+ sctp_add_bind_addr(&retval->base.bind_addr, &chunk->dest, 1,14971497 GFP_ATOMIC);14981498 }14991499···20172017 af->from_addr_param(&addr, param.addr, asoc->peer.port, 0);20182018 scope = sctp_scope(peer_addr);20192019 if (sctp_in_scope(&addr, scope))20202020- if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_ACTIVE))20202020+ if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED))20212021 return 0;20222022 break;20232023···24182418 * Due to Resource Shortage'.24192419 */2420242024212421- peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC, SCTP_ACTIVE);24212421+ peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC, SCTP_UNCONFIRMED);24222422 if (!peer)24232423 return SCTP_ERROR_RSRC_LOW;24242424···25652565 union sctp_addr_param *addr_param;25662566 struct list_head *pos;25672567 struct sctp_transport *transport;25682568+ struct sctp_sockaddr_entry *saddr;25682569 int retval = 0;2569257025702571 addr_param = (union sctp_addr_param *)···25792578 case SCTP_PARAM_ADD_IP:25802579 sctp_local_bh_disable();25812580 sctp_write_lock(&asoc->base.addr_lock);25822582- retval = sctp_add_bind_addr(bp, &addr, GFP_ATOMIC);25812581+ list_for_each(pos, &bp->address_list) {25822582+ saddr = list_entry(pos, struct sctp_sockaddr_entry, list);25832583+ if (sctp_cmp_addr_exact(&saddr->a, &addr))25842584+ saddr->use_as_src = 1;25852585+ }25832586 sctp_write_unlock(&asoc->base.addr_lock);25842587 sctp_local_bh_enable();25852588 break;···25962591 list_for_each(pos, &asoc->peer.transport_addr_list) {25972592 transport = list_entry(pos, struct sctp_transport,25982593 transports);25942594+ dst_release(transport->dst);25992595 sctp_transport_route(transport, NULL,26002596 sctp_sk(asoc->base.sk));26012597 }
+10-2
net/sctp/sm_sideeffect.c
···430430 /* The check for association's overall error counter exceeding the431431 * threshold is done in the state function.432432 */433433- asoc->overall_error_count++;433433+ /* When probing UNCONFIRMED addresses, the association overall434434+ * error count is NOT incremented435435+ */436436+ if (transport->state != SCTP_UNCONFIRMED)437437+ asoc->overall_error_count++;434438435439 if (transport->state != SCTP_INACTIVE &&436440 (transport->error_count++ >= transport->pathmaxrxt)) {···614610 /* Mark the destination transport address as active if it is not so615611 * marked.616612 */617617- if (t->state == SCTP_INACTIVE)613613+ if ((t->state == SCTP_INACTIVE) || (t->state == SCTP_UNCONFIRMED))618614 sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP,619615 SCTP_HEARTBEAT_SUCCESS);620616···624620 */625621 hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data;626622 sctp_transport_update_rto(t, (jiffies - hbinfo->sent_at));623623+624624+ /* Update the heartbeat timer. */625625+ if (!mod_timer(&t->hb_timer, sctp_transport_timeout(t)))626626+ sctp_transport_hold(t);627627}628628629629/* Helper function to do a transport reset at the expiry of the hearbeat
+7-1
net/sctp/sm_statefuns.c
···846846 hbinfo.param_hdr.length = htons(sizeof(sctp_sender_hb_info_t));847847 hbinfo.daddr = transport->ipaddr;848848 hbinfo.sent_at = jiffies;849849+ hbinfo.hb_nonce = transport->hb_nonce;849850850851 /* Send a heartbeat to our peer. */851852 paylen = sizeof(sctp_sender_hb_info_t);···10481047 }10491048 return SCTP_DISPOSITION_DISCARD;10501049 }10501050+10511051+ /* Validate the 64-bit random nonce. */10521052+ if (hbinfo->hb_nonce != link->hb_nonce)10531053+ return SCTP_DISPOSITION_DISCARD;1051105410521055 max_interval = link->hbinterval + link->rto;10531056···52835278 datalen -= sizeof(sctp_data_chunk_t);5284527952855280 deliver = SCTP_CMD_CHUNK_ULP;52865286- chunk->data_accepted = 1;5287528152885282 /* Think about partial delivery. */52895283 if ((datalen >= asoc->rwnd) && (!asoc->ulpq.pd_mode)) {···53605356 */53615357 if (SCTP_CMD_CHUNK_ULP == deliver)53625358 sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_TSN, SCTP_U32(tsn));53595359+53605360+ chunk->data_accepted = 1;5363536153645362 /* Note: Some chunks may get overcounted (if we drop) or overcounted53655363 * if we renege and the chunk arrives again.
+60-16
net/sctp/socket.c
···369369370370 /* Use GFP_ATOMIC since BHs are disabled. */371371 addr->v4.sin_port = ntohs(addr->v4.sin_port);372372- ret = sctp_add_bind_addr(bp, addr, GFP_ATOMIC);372372+ ret = sctp_add_bind_addr(bp, addr, 1, GFP_ATOMIC);373373 addr->v4.sin_port = htons(addr->v4.sin_port);374374 sctp_write_unlock(&ep->base.addr_lock);375375 sctp_local_bh_enable();···491491 struct sctp_chunk *chunk;492492 struct sctp_sockaddr_entry *laddr;493493 union sctp_addr *addr;494494+ union sctp_addr saveaddr;494495 void *addr_buf;495496 struct sctp_af *af;496497 struct list_head *pos;···559558 }560559561560 retval = sctp_send_asconf(asoc, chunk);561561+ if (retval)562562+ goto out;562563563563- /* FIXME: After sending the add address ASCONF chunk, we564564- * cannot append the address to the association's binding565565- * address list, because the new address may be used as the566566- * source of a message sent to the peer before the ASCONF567567- * chunk is received by the peer. So we should wait until568568- * ASCONF_ACK is received.564564+ /* Add the new addresses to the bind address list with565565+ * use_as_src set to 0.569566 */567567+ sctp_local_bh_disable();568568+ sctp_write_lock(&asoc->base.addr_lock);569569+ addr_buf = addrs;570570+ for (i = 0; i < addrcnt; i++) {571571+ addr = (union sctp_addr *)addr_buf;572572+ af = sctp_get_af_specific(addr->v4.sin_family);573573+ memcpy(&saveaddr, addr, af->sockaddr_len);574574+ saveaddr.v4.sin_port = ntohs(saveaddr.v4.sin_port);575575+ retval = sctp_add_bind_addr(bp, &saveaddr, 0,576576+ GFP_ATOMIC);577577+ addr_buf += af->sockaddr_len;578578+ }579579+ sctp_write_unlock(&asoc->base.addr_lock);580580+ sctp_local_bh_enable();570581 }571582572583out:···689676 struct sctp_sock *sp;690677 struct sctp_endpoint *ep;691678 struct sctp_association *asoc;679679+ struct sctp_transport *transport;692680 struct sctp_bind_addr *bp;693681 struct sctp_chunk *chunk;694682 union sctp_addr *laddr;683683+ union sctp_addr saveaddr;695684 void *addr_buf;696685 struct sctp_af *af;697697- struct list_head *pos;686686+ struct list_head *pos, *pos1;687687+ struct sctp_sockaddr_entry *saddr;698688 int i;699689 int retval = 0;700690···764748 goto out;765749 }766750767767- retval = sctp_send_asconf(asoc, chunk);768768-769769- /* FIXME: After sending the delete address ASCONF chunk, we770770- * cannot remove the addresses from the association's bind771771- * address list, because there maybe some packet send to772772- * the delete addresses, so we should wait until ASCONF_ACK773773- * packet is received.751751+ /* Reset use_as_src flag for the addresses in the bind address752752+ * list that are to be deleted.774753 */754754+ sctp_local_bh_disable();755755+ sctp_write_lock(&asoc->base.addr_lock);756756+ addr_buf = addrs;757757+ for (i = 0; i < addrcnt; i++) {758758+ laddr = (union sctp_addr *)addr_buf;759759+ af = sctp_get_af_specific(laddr->v4.sin_family);760760+ memcpy(&saveaddr, laddr, af->sockaddr_len);761761+ saveaddr.v4.sin_port = ntohs(saveaddr.v4.sin_port);762762+ list_for_each(pos1, &bp->address_list) {763763+ saddr = list_entry(pos1,764764+ struct sctp_sockaddr_entry,765765+ list);766766+ if (sctp_cmp_addr_exact(&saddr->a, &saveaddr))767767+ saddr->use_as_src = 0;768768+ }769769+ addr_buf += af->sockaddr_len;770770+ }771771+ sctp_write_unlock(&asoc->base.addr_lock);772772+ sctp_local_bh_enable();773773+774774+ /* Update the route and saddr entries for all the transports775775+ * as some of the addresses in the bind address list are776776+ * about to be deleted and cannot be used as source addresses.777777+ */778778+ list_for_each(pos1, &asoc->peer.transport_addr_list) {779779+ transport = list_entry(pos1, struct sctp_transport,780780+ transports);781781+ dst_release(transport->dst);782782+ sctp_transport_route(transport, NULL,783783+ sctp_sk(asoc->base.sk));784784+ }785785+786786+ retval = sctp_send_asconf(asoc, chunk);775787 }776788out:777789 return retval;···50214977/* Caller must hold hashbucket lock for this tb with local BH disabled */50224978static void sctp_bucket_destroy(struct sctp_bind_bucket *pp)50234979{50245024- if (hlist_empty(&pp->owner)) {49804980+ if (pp && hlist_empty(&pp->owner)) {50254981 if (pp->next)50264982 pp->next->pprev = pp->pprev;50274983 *(pp->pprev) = pp->next;