···11+What: /sys/devices/platform/at91_can/net/<iface>/mb0_id22+Date: January 201133+KernelVersion: 2.6.3844+Contact: Marc Kleine-Budde <kernel@pengutronix.de>55+Description:66+ Value representing the can_id of mailbox 0.77+88+ Default: 0x7ff (standard frame)99+1010+ Due to a chip bug (errata 50.2.6.3 & 50.3.5.3 in1111+ "AT91SAM9263 Preliminary 6249H-ATARM-27-Jul-09") the1212+ contents of mailbox 0 may be send under certain1313+ conditions (even if disabled or in rx mode).1414+1515+ The workaround in the errata suggests not to use the1616+ mailbox and load it with an unused identifier.1717+1818+ In order to use an extended can_id add the1919+ CAN_EFF_FLAG (0x80000000U) to the can_id. Example:2020+2121+ - standard id 0x7ff:2222+ echo 0x7ff > /sys/class/net/can0/mb0_id2323+2424+ - extended id 0x1fffffff:2525+ echo 0x9fffffff > /sys/class/net/can0/mb0_id
+2
Documentation/filesystems/ntfs.txt
···4604602.1.30:461461 - Fix writev() (it kept writing the first segment over and over again462462 instead of moving onto subsequent segments).463463+ - Fix crash in ntfs_mft_record_alloc() when mapping the new extent mft464464+ record failed.4634652.1.29:464466 - Fix a deadlock when mounting read-write.4654672.1.28:
+71-12
Documentation/networking/bonding.txt
···49493.3 Configuring Bonding Manually with Ifenslave50503.3.1 Configuring Multiple Bonds Manually51513.4 Configuring Bonding Manually via Sysfs5252-3.5 Overriding Configuration for Special Cases5252+3.5 Configuration with Interfaces Support5353+3.6 Overriding Configuration for Special Cases535454554. Querying Bonding Configuration55564.1 Bonding Configuration···162161default kernel source include directory.163162164163SECOND IMPORTANT NOTE:165165- If you plan to configure bonding using sysfs, you do not need166166-to use ifenslave.164164+ If you plan to configure bonding using sysfs or using the165165+/etc/network/interfaces file, you do not need to use ifenslave.1671661681672. Bonding Driver Options169168=========================···780779781780 You can configure bonding using either your distro's network782781initialization scripts, or manually using either ifenslave or the783783-sysfs interface. Distros generally use one of two packages for the784784-network initialization scripts: initscripts or sysconfig. Recent785785-versions of these packages have support for bonding, while older782782+sysfs interface. Distros generally use one of three packages for the783783+network initialization scripts: initscripts, sysconfig or interfaces.784784+Recent versions of these packages have support for bonding, while older786785versions do not.787786788787 We will first describe the options for configuring bonding for789789-distros using versions of initscripts and sysconfig with full or790790-partial support for bonding, then provide information on enabling788788+distros using versions of initscripts, sysconfig and interfaces with full789789+or partial support for bonding, then provide information on enabling791790bonding without support from the network initialization scripts (i.e.,792791older versions of initscripts or sysconfig).793792794794- If you're unsure whether your distro uses sysconfig or795795-initscripts, or don't know if it's new enough, have no fear.793793+ If you're unsure whether your distro uses sysconfig,794794+initscripts or interfaces, or don't know if it's new enough, have no fear.796795Determining this is fairly straightforward.797796798798- First, issue the command:797797+ First, look for a file called interfaces in /etc/network directory.798798+If this file is present in your system, then your system use interfaces. See799799+Configuration with Interfaces Support.800800+801801+ Else, issue the command:799802800803$ rpm -qf /sbin/ifup801804···13321327echo +eth2 > /sys/class/net/bond1/bonding/slaves13331328echo +eth3 > /sys/class/net/bond1/bonding/slaves1334132913351335-3.5 Overriding Configuration for Special Cases13301330+3.5 Configuration with Interfaces Support13311331+-----------------------------------------13321332+13331333+ This section applies to distros which use /etc/network/interfaces file13341334+to describe network interface configuration, most notably Debian and it's13351335+derivatives.13361336+13371337+ The ifup and ifdown commands on Debian don't support bonding out of13381338+the box. The ifenslave-2.6 package should be installed to provide bonding13391339+support. Once installed, this package will provide bond-* options to be used13401340+into /etc/network/interfaces.13411341+13421342+ Note that ifenslave-2.6 package will load the bonding module and use13431343+the ifenslave command when appropriate.13441344+13451345+Example Configurations13461346+----------------------13471347+13481348+In /etc/network/interfaces, the following stanza will configure bond0, in13491349+active-backup mode, with eth0 and eth1 as slaves.13501350+13511351+auto bond013521352+iface bond0 inet dhcp13531353+ bond-slaves eth0 eth113541354+ bond-mode active-backup13551355+ bond-miimon 10013561356+ bond-primary eth0 eth113571357+13581358+If the above configuration doesn't work, you might have a system using13591359+upstart for system startup. This is most notably true for recent13601360+Ubuntu versions. The following stanza in /etc/network/interfaces will13611361+produce the same result on those systems.13621362+13631363+auto bond013641364+iface bond0 inet dhcp13651365+ bond-slaves none13661366+ bond-mode active-backup13671367+ bond-miimon 10013681368+13691369+auto eth013701370+iface eth0 inet manual13711371+ bond-master bond013721372+ bond-primary eth0 eth113731373+13741374+auto eth113751375+iface eth1 inet manual13761376+ bond-master bond013771377+ bond-primary eth0 eth113781378+13791379+For a full list of bond-* supported options in /etc/network/interfaces and some13801380+more advanced examples tailored to you particular distros, see the files in13811381+/usr/share/doc/ifenslave-2.6.13821382+13831383+3.6 Overriding Configuration for Special Cases13361384----------------------------------------------13851385+13371386When using the bonding driver, the physical port which transmits a frame is13381387typically selected by the bonding driver, and is not relevant to the user or13391388system administrator. The output port is simply selected using the policies of
+16-1
MAINTAINERS
···31393139F: net/ieee802154/31403140F: drivers/ieee802154/3141314131423142+IKANOS/ADI EAGLE ADSL USB DRIVER31433143+M: Matthieu Castet <castet.matthieu@free.fr>31443144+M: Stanislaw Gruszka <stf_xl@wp.pl>31453145+S: Maintained31463146+F: drivers/usb/atm/ueagle-atm.c31473147+31423148INTEGRITY MEASUREMENT ARCHITECTURE (IMA)31433149M: Mimi Zohar <zohar@us.ibm.com>31443150S: Supported···33333327F: include/linux/wimax/i2400m.h3334332833353329INTEL WIRELESS WIFI LINK (iwlwifi)33363336-M: Reinette Chatre <reinette.chatre@intel.com>33373330M: Wey-Yi Guy <wey-yi.w.guy@intel.com>33383331M: Intel Linux Wireless <ilw@linux.intel.com>33393332L: linux-wireless@vger.kernel.org···65996594S: Maintained66006595F: drivers/char/virtio_console.c66016596F: include/linux/virtio_console.h65976597+65986598+VIRTIO CORE, NET AND BLOCK DRIVERS65996599+M: Rusty Russell <rusty@rustcorp.com.au>66006600+M: "Michael S. Tsirkin" <mst@redhat.com>66016601+L: virtualization@lists.linux-foundation.org66026602+S: Maintained66036603+F: drivers/virtio/66046604+F: drivers/net/virtio_net.c66056605+F: drivers/block/virtio_blk.c66066606+F: include/linux/virtio_*.h6602660766036608VIRTIO HOST (VHOST)66046609M: "Michael S. Tsirkin" <mst@redhat.com>
···1414#include <mach/irqs.h>1515#include <asm/hardware/gic.h>16161717-/*1818- * We use __glue to avoid errors with multiple definitions of1919- * .globl omap_irq_flags as it's included from entry-armv.S but not2020- * from entry-common.S.2121- */2222-#ifdef __glue2323- .pushsection .data2424- .globl omap_irq_flags2525-omap_irq_flags:2626- .word 02727- .popsection2828-#endif2929-3017 .macro disable_fiq3118 .endm3219
+1-1
arch/arm/mach-omap1/irq.c
···5757 unsigned long wake_enable;5858};59596060+u32 omap_irq_flags;6061static unsigned int irq_bank_count;6162static struct omap_irq_bank *irq_banks;6263···177176178177void __init omap_init_irq(void)179178{180180- extern unsigned int omap_irq_flags;181179 int i, j;182180183181#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
+1-1
arch/arm/mach-omap2/dma.c
···264264 if (IS_ERR(od)) {265265 pr_err("%s: Cant build omap_device for %s:%s.\n",266266 __func__, name, oh->name);267267- return IS_ERR(od);267267+ return PTR_ERR(od);268268 }269269270270 mem = platform_get_resource(&od->pdev, IORESOURCE_MEM, 0);
-14
arch/arm/mach-omap2/include/mach/entry-macro.S
···3838 */39394040#ifdef MULTI_OMAP24141-4242-/*4343- * We use __glue to avoid errors with multiple definitions of4444- * .globl omap_irq_base as it's included from entry-armv.S but not4545- * from entry-common.S.4646- */4747-#ifdef __glue4848- .pushsection .data4949- .globl omap_irq_base5050-omap_irq_base:5151- .word 05252- .popsection5353-#endif5454-5541 /*5642 * Configure the interrupt base on the first interrupt.5743 * See also omap_irq_base_init for setting omap_irq_base.
+2-4
arch/arm/mach-omap2/io.c
···314314 return omap_hwmod_set_postsetup_state(oh, *(u8 *)data);315315}316316317317+void __iomem *omap_irq_base;318318+317319/*318320 * Initialize asm_irq_base for entry-macro.S319321 */320322static inline void omap_irq_base_init(void)321323{322322- extern void __iomem *omap_irq_base;323323-324324-#ifdef MULTI_OMAP2325324 if (cpu_is_omap24xx())326325 omap_irq_base = OMAP2_L4_IO_ADDRESS(OMAP24XX_IC_BASE);327326 else if (cpu_is_omap34xx())···329330 omap_irq_base = OMAP2_L4_IO_ADDRESS(OMAP44XX_GIC_CPU_BASE);330331 else331332 pr_err("Could not initialize omap_irq_base\n");332332-#endif333333}334334335335void __init omap2_init_common_infrastructure(void)
+1-1
arch/arm/mach-omap2/mux.c
···160160 struct omap_mux *mux = NULL;161161 struct omap_mux_entry *e;162162 const char *mode_name;163163- int found = 0, found_mode, mode0_len = 0;163163+ int found = 0, found_mode = 0, mode0_len = 0;164164 struct list_head *muxmodes = &partition->muxmodes;165165166166 mode_name = strchr(muxname, '.');
···149149 unsigned used = 0;150150 struct thread_info *tinfo;151151 int graph = 0;152152+ unsigned long dummy;152153 unsigned long bp;153154154155 if (!task)155156 task = current;156157157158 if (!stack) {158158- unsigned long dummy;159159 stack = &dummy;160160 if (task && task != current)161161 stack = (unsigned long *)task->thread.sp;
+5-11
arch/x86/xen/p2m.c
···241241 * As long as the mfn_list has enough entries to completely242242 * fill a p2m page, pointing into the array is ok. But if243243 * not the entries beyond the last pfn will be undefined.244244- * And guessing that the 'what-ever-there-is' does not take it245245- * too kindly when changing it to invalid markers, a new page246246- * is allocated, initialized and filled with the valid part.247244 */248245 if (unlikely(pfn + P2M_PER_PAGE > max_pfn)) {249246 unsigned long p2midx;250250- unsigned long *p2m = extend_brk(PAGE_SIZE, PAGE_SIZE);251251- p2m_init(p2m);252247253253- for (p2midx = 0; pfn + p2midx < max_pfn; p2midx++) {254254- p2m[p2midx] = mfn_list[pfn + p2midx];255255- }256256- p2m_top[topidx][mididx] = p2m;257257- } else258258- p2m_top[topidx][mididx] = &mfn_list[pfn];248248+ p2midx = max_pfn % P2M_PER_PAGE;249249+ for ( ; p2midx < P2M_PER_PAGE; p2midx++)250250+ mfn_list[pfn + p2midx] = INVALID_P2M_ENTRY;251251+ }252252+ p2m_top[topidx][mididx] = &mfn_list[pfn];259253 }260254261255 m2p_override_init();
+7-1
arch/x86/xen/setup.c
···179179 e820.nr_map = 0;180180 xen_extra_mem_start = mem_end;181181 for (i = 0; i < memmap.nr_entries; i++) {182182- unsigned long long end = map[i].addr + map[i].size;182182+ unsigned long long end;183183184184+ /* Guard against non-page aligned E820 entries. */185185+ if (map[i].type == E820_RAM)186186+ map[i].size -= (map[i].size + map[i].addr) % PAGE_SIZE;187187+188188+ end = map[i].addr + map[i].size;184189 if (map[i].type == E820_RAM && end > mem_end) {185190 /* RAM off the end - may be partially included */186191 u64 delta = min(map[i].size, end - mem_end);···355350 boot_cpu_data.hlt_works_ok = 1;356351#endif357352 pm_idle = default_idle;353353+ boot_option_idle_override = IDLE_HALT;358354359355 fiddle_vdso();360356}
···41384138 * device and controller are SATA.41394139 */41404140 { "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER },41414141+ { "PIONEER DVD-RW DVR-212D", "1.28", ATA_HORKAGE_NOSETXFER },4141414241424143 /* End Marker */41434144 { }
+18-6
drivers/ata/libata-scsi.c
···10991099 struct request_queue *q = sdev->request_queue;11001100 void *buf;1101110111021102- /* set the min alignment and padding */11031103- blk_queue_update_dma_alignment(sdev->request_queue,11041104- ATA_DMA_PAD_SZ - 1);11021102+ sdev->sector_size = ATA_SECT_SIZE;11031103+11041104+ /* set DMA padding */11051105 blk_queue_update_dma_pad(sdev->request_queue,11061106 ATA_DMA_PAD_SZ - 1);11071107···1115111511161116 blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN);11171117 } else {11181118- /* ATA devices must be sector aligned */11191118 sdev->sector_size = ata_id_logical_sector_size(dev->id);11201120- blk_queue_update_dma_alignment(sdev->request_queue,11211121- sdev->sector_size - 1);11221119 sdev->manage_start_stop = 1;11231120 }11211121+11221122+ /*11231123+ * ata_pio_sectors() expects buffer for each sector to not cross11241124+ * page boundary. Enforce it by requiring buffers to be sector11251125+ * aligned, which works iff sector_size is not larger than11261126+ * PAGE_SIZE. ATAPI devices also need the alignment as11271127+ * IDENTIFY_PACKET is executed as ATA_PROT_PIO.11281128+ */11291129+ if (sdev->sector_size > PAGE_SIZE)11301130+ ata_dev_printk(dev, KERN_WARNING,11311131+ "sector_size=%u > PAGE_SIZE, PIO may malfunction\n",11321132+ sdev->sector_size);11331133+11341134+ blk_queue_update_dma_alignment(sdev->request_queue,11351135+ sdev->sector_size - 1);1124113611251137 if (dev->flags & ATA_DFLAG_AN)11261138 set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events);
+3-3
drivers/ata/pata_hpt366.c
···2525#include <linux/libata.h>26262727#define DRV_NAME "pata_hpt366"2828-#define DRV_VERSION "0.6.9"2828+#define DRV_VERSION "0.6.10"29293030struct hpt_clock {3131 u8 xfer_mode;···160160161161 while (list[i] != NULL) {162162 if (!strcmp(list[i], model_num)) {163163- printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n",164164- modestr, list[i]);163163+ pr_warning(DRV_NAME ": %s is not supported for %s.\n",164164+ modestr, list[i]);165165 return 1;166166 }167167 i++;
+54-58
drivers/ata/pata_hpt37x.c
···2424#include <linux/libata.h>25252626#define DRV_NAME "pata_hpt37x"2727-#define DRV_VERSION "0.6.18"2727+#define DRV_VERSION "0.6.22"28282929struct hpt_clock {3030 u8 xfer_speed;···229229230230 while (list[i] != NULL) {231231 if (!strcmp(list[i], model_num)) {232232- printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n",233233- modestr, list[i]);232232+ pr_warning(DRV_NAME ": %s is not supported for %s.\n",233233+ modestr, list[i]);234234 return 1;235235 }236236 i++;···642642static struct ata_port_operations hpt374_fn1_port_ops = {643643 .inherits = &hpt372_port_ops,644644 .cable_detect = hpt374_fn1_cable_detect,645645- .prereset = hpt37x_pre_reset,646645};647646648647/**···802803 .udma_mask = ATA_UDMA6,803804 .port_ops = &hpt302_port_ops804805 };805805- /* HPT374 - UDMA100, function 1 uses different prereset method */806806+ /* HPT374 - UDMA100, function 1 uses different cable_detect method */806807 static const struct ata_port_info info_hpt374_fn0 = {807808 .flags = ATA_FLAG_SLAVE_POSS,808809 .pio_mask = ATA_PIO4,···837838 if (rc)838839 return rc;839840840840- if (dev->device == PCI_DEVICE_ID_TTI_HPT366) {841841+ switch (dev->device) {842842+ case PCI_DEVICE_ID_TTI_HPT366:841843 /* May be a later chip in disguise. Check */842844 /* Older chips are in the HPT366 driver. Ignore them */843845 if (rev < 3)···863863 chip_table = &hpt372;864864 break;865865 default:866866- printk(KERN_ERR "pata_hpt37x: Unknown HPT366 subtype, "866866+ pr_err(DRV_NAME ": Unknown HPT366 subtype, "867867 "please report (%d).\n", rev);868868 return -ENODEV;869869 }870870- } else {871871- switch (dev->device) {872872- case PCI_DEVICE_ID_TTI_HPT372:873873- /* 372N if rev >= 2 */874874- if (rev >= 2)875875- return -ENODEV;876876- ppi[0] = &info_hpt372;877877- chip_table = &hpt372a;878878- break;879879- case PCI_DEVICE_ID_TTI_HPT302:880880- /* 302N if rev > 1 */881881- if (rev > 1)882882- return -ENODEV;883883- ppi[0] = &info_hpt302;884884- /* Check this */885885- chip_table = &hpt302;886886- break;887887- case PCI_DEVICE_ID_TTI_HPT371:888888- if (rev > 1)889889- return -ENODEV;890890- ppi[0] = &info_hpt302;891891- chip_table = &hpt371;892892- /*893893- * Single channel device, master is not present894894- * but the BIOS (or us for non x86) must mark it895895- * absent896896- */897897- pci_read_config_byte(dev, 0x50, &mcr1);898898- mcr1 &= ~0x04;899899- pci_write_config_byte(dev, 0x50, mcr1);900900- break;901901- case PCI_DEVICE_ID_TTI_HPT374:902902- chip_table = &hpt374;903903- if (!(PCI_FUNC(dev->devfn) & 1))904904- *ppi = &info_hpt374_fn0;905905- else906906- *ppi = &info_hpt374_fn1;907907- break;908908- default:909909- printk(KERN_ERR910910- "pata_hpt37x: PCI table is bogus, please report (%d).\n",911911- dev->device);912912- return -ENODEV;913913- }870870+ break;871871+ case PCI_DEVICE_ID_TTI_HPT372:872872+ /* 372N if rev >= 2 */873873+ if (rev >= 2)874874+ return -ENODEV;875875+ ppi[0] = &info_hpt372;876876+ chip_table = &hpt372a;877877+ break;878878+ case PCI_DEVICE_ID_TTI_HPT302:879879+ /* 302N if rev > 1 */880880+ if (rev > 1)881881+ return -ENODEV;882882+ ppi[0] = &info_hpt302;883883+ /* Check this */884884+ chip_table = &hpt302;885885+ break;886886+ case PCI_DEVICE_ID_TTI_HPT371:887887+ if (rev > 1)888888+ return -ENODEV;889889+ ppi[0] = &info_hpt302;890890+ chip_table = &hpt371;891891+ /*892892+ * Single channel device, master is not present but the BIOS893893+ * (or us for non x86) must mark it absent894894+ */895895+ pci_read_config_byte(dev, 0x50, &mcr1);896896+ mcr1 &= ~0x04;897897+ pci_write_config_byte(dev, 0x50, mcr1);898898+ break;899899+ case PCI_DEVICE_ID_TTI_HPT374:900900+ chip_table = &hpt374;901901+ if (!(PCI_FUNC(dev->devfn) & 1))902902+ *ppi = &info_hpt374_fn0;903903+ else904904+ *ppi = &info_hpt374_fn1;905905+ break;906906+ default:907907+ pr_err(DRV_NAME ": PCI table is bogus, please report (%d).\n",908908+ dev->device);909909+ return -ENODEV;914910 }915911 /* Ok so this is a chip we support */916912···953957 u8 sr;954958 u32 total = 0;955959956956- printk(KERN_WARNING957957- "pata_hpt37x: BIOS has not set timing clocks.\n");960960+ pr_warning(DRV_NAME ": BIOS has not set timing clocks.\n");958961959962 /* This is the process the HPT371 BIOS is reported to use */960963 for (i = 0; i < 128; i++) {···10091014 (f_high << 16) | f_low | 0x100);10101015 }10111016 if (adjust == 8) {10121012- printk(KERN_ERR "pata_hpt37x: DPLL did not stabilize!\n");10171017+ pr_err(DRV_NAME ": DPLL did not stabilize!\n");10131018 return -ENODEV;10141019 }10151020 if (dpll == 3)···10171022 else10181023 private_data = (void *)hpt37x_timings_50;1019102410201020- printk(KERN_INFO "pata_hpt37x: bus clock %dMHz, using %dMHz DPLL.\n",10211021- MHz[clock_slot], MHz[dpll]);10251025+ pr_info(DRV_NAME ": bus clock %dMHz, using %dMHz DPLL.\n",10261026+ MHz[clock_slot], MHz[dpll]);10221027 } else {10231028 private_data = (void *)chip_table->clocks[clock_slot];10241029 /*···10311036 ppi[0] = &info_hpt370_33;10321037 if (clock_slot < 2 && ppi[0] == &info_hpt370a)10331038 ppi[0] = &info_hpt370a_33;10341034- printk(KERN_INFO "pata_hpt37x: %s using %dMHz bus clock.\n",10351035- chip_table->name, MHz[clock_slot]);10391039+10401040+ pr_info(DRV_NAME ": %s using %dMHz bus clock.\n",10411041+ chip_table->name, MHz[clock_slot]);10361042 }1037104310381044 /* Now kick off ATA set up */
+5-7
drivers/ata/pata_hpt3x2n.c
···2525#include <linux/libata.h>26262727#define DRV_NAME "pata_hpt3x2n"2828-#define DRV_VERSION "0.3.13"2828+#define DRV_VERSION "0.3.14"29293030enum {3131 HPT_PCI_FAST = (1 << 31),···418418 u16 sr;419419 u32 total = 0;420420421421- printk(KERN_WARNING "pata_hpt3x2n: BIOS clock data not set.\n");421421+ pr_warning(DRV_NAME ": BIOS clock data not set.\n");422422423423 /* This is the process the HPT371 BIOS is reported to use */424424 for (i = 0; i < 128; i++) {···528528 ppi[0] = &info_hpt372n;529529 break;530530 default:531531- printk(KERN_ERR532532- "pata_hpt3x2n: PCI table is bogus please report (%d).\n",531531+ pr_err(DRV_NAME ": PCI table is bogus, please report (%d).\n",533532 dev->device);534533 return -ENODEV;535534 }···578579 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low);579580 }580581 if (adjust == 8) {581581- printk(KERN_ERR "pata_hpt3x2n: DPLL did not stabilize!\n");582582+ pr_err(DRV_NAME ": DPLL did not stabilize!\n");582583 return -ENODEV;583584 }584585585585- printk(KERN_INFO "pata_hpt37x: bus clock %dMHz, using 66MHz DPLL.\n",586586- pci_mhz);586586+ pr_info(DRV_NAME ": bus clock %dMHz, using 66MHz DPLL.\n", pci_mhz);587587588588 /*589589 * Set our private data up. We only need a few flags
···6969 mb();7070}71717272+#define R300_PTE_WRITEABLE (1 << 2)7373+#define R300_PTE_READABLE (1 << 3)7474+7275int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)7376{7477 void __iomem *ptr = (void *)rdev->gart.table.vram.ptr;···8178 }8279 addr = (lower_32_bits(addr) >> 8) |8380 ((upper_32_bits(addr) & 0xff) << 24) |8484- 0xc;8181+ R300_PTE_WRITEABLE | R300_PTE_READABLE;8582 /* on x86 we want this to be CPU endian, on powerpc8683 * on powerpc without HW swappers, it'll get swapped on way8784 * into VRAM - so no need for cpu_to_le32 on VRAM tables */···138135 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_LO, rdev->mc.vram_start);139136 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_HI, 0);140137 /* Clear error */141141- WREG32_PCIE(0x18, 0);138138+ WREG32_PCIE(RADEON_PCIE_TX_GART_ERROR, 0);142139 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);143140 tmp |= RADEON_PCIE_TX_GART_EN;144141 tmp |= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD;
+1-1
drivers/gpu/drm/radeon/r420.c
···9696 "programming pipes. Bad things might happen.\n");9797 }9898 /* get max number of pipes */9999- gb_pipe_select = RREG32(0x402C);9999+ gb_pipe_select = RREG32(R400_GB_PIPE_SELECT);100100 num_pipes = ((gb_pipe_select >> 12) & 3) + 1;101101102102 /* SE chips have 1 pipe */
···641641 switch (connector->connector_type) {642642 case DRM_MODE_CONNECTOR_DVII:643643 case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */644644- if (drm_detect_monitor_audio(radeon_connector->edid)) {644644+ if (drm_detect_monitor_audio(radeon_connector->edid) && radeon_audio) {645645 /* fix me */646646 if (ASIC_IS_DCE4(rdev))647647 return ATOM_ENCODER_MODE_DVI;···655655 case DRM_MODE_CONNECTOR_DVID:656656 case DRM_MODE_CONNECTOR_HDMIA:657657 default:658658- if (drm_detect_monitor_audio(radeon_connector->edid)) {658658+ if (drm_detect_monitor_audio(radeon_connector->edid) && radeon_audio) {659659 /* fix me */660660 if (ASIC_IS_DCE4(rdev))661661 return ATOM_ENCODER_MODE_DVI;···673673 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||674674 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP))675675 return ATOM_ENCODER_MODE_DP;676676- else if (drm_detect_monitor_audio(radeon_connector->edid)) {676676+ else if (drm_detect_monitor_audio(radeon_connector->edid) && radeon_audio) {677677 /* fix me */678678 if (ASIC_IS_DCE4(rdev))679679 return ATOM_ENCODER_MODE_DVI;
+2
drivers/gpu/drm/radeon/radeon_kms.c
···247247 struct radeon_device *rdev = dev->dev_private;248248 if (rdev->hyperz_filp == file_priv)249249 rdev->hyperz_filp = NULL;250250+ if (rdev->cmask_filp == file_priv)251251+ rdev->cmask_filp = NULL;250252}251253252254/*
···1313#include <linux/list.h>1414#include <linux/module.h>1515#include <linux/slab.h>1616+#include <linux/dmi.h>16171718#include <acpi/acpi.h>1819#include <acpi/acpixf.h>···222123222423#define ATK_HID "ATK0110"2424+2525+static bool new_if;2626+module_param(new_if, bool, 0);2727+MODULE_PARM_DESC(new_if, "Override detection heuristic and force the use of the new ATK0110 interface");2828+2929+static const struct dmi_system_id __initconst atk_force_new_if[] = {3030+ {3131+ /* Old interface has broken MCH temp monitoring */3232+ .ident = "Asus Sabertooth X58",3333+ .matches = {3434+ DMI_MATCH(DMI_BOARD_NAME, "SABERTOOTH X58")3535+ }3636+ },3737+ { }3838+};25392640/* Minimum time between readings, enforced in order to avoid2741 * hogging the CPU.···13181302 * analysis of multiple DSDTs indicates that when both interfaces13191303 * are present the new one (GGRP/GITM) is not functional.13201304 */13211321- if (data->rtmp_handle && data->rvlt_handle && data->rfan_handle)13051305+ if (new_if)13061306+ dev_info(dev, "Overriding interface detection\n");13071307+ if (data->rtmp_handle && data->rvlt_handle && data->rfan_handle && !new_if)13221308 data->old_interface = true;13231309 else if (data->enumerate_handle && data->read_handle &&13241310 data->write_handle)···14371419 pr_err("Resources not safely usable due to acpi_enforce_resources kernel parameter\n");14381420 return -EBUSY;14391421 }14221422+14231423+ if (dmi_check_system(atk_force_new_if))14241424+ new_if = true;1440142514411426 ret = acpi_bus_register_driver(&atk_driver);14421427 if (ret)
+1-1
drivers/hwmon/lis3lv02d.c
···957957958958 /* bail if we did not get an IRQ from the bus layer */959959 if (!dev->irq) {960960- pr_err("No IRQ. Disabling /dev/freefall\n");960960+ pr_debug("No IRQ. Disabling /dev/freefall\n");961961 goto out;962962 }963963
···672672 ubi->nor_flash = 1;673673 }674674675675- /*676676- * Set UBI min. I/O size (@ubi->min_io_size). We use @mtd->writebufsize677677- * for these purposes, not @mtd->writesize. At the moment this does not678678- * matter for NAND, because currently @mtd->writebufsize is equivalent to679679- * @mtd->writesize for all NANDs. However, some CFI NOR flashes may680680- * have @mtd->writebufsize which is multiple of @mtd->writesize.681681- *682682- * The reason we use @mtd->writebufsize for @ubi->min_io_size is that683683- * UBI and UBIFS recovery algorithms rely on the fact that if there was684684- * an unclean power cut, then we can find offset of the last corrupted685685- * node, align the offset to @ubi->min_io_size, read the rest of the686686- * eraseblock starting from this offset, and check whether there are687687- * only 0xFF bytes. If yes, then we are probably dealing with a688688- * corruption caused by a power cut, if not, then this is probably some689689- * severe corruption.690690- *691691- * Thus, we have to use the maximum write unit size of the flash, which692692- * is @mtd->writebufsize, because @mtd->writesize is the minimum write693693- * size, not the maximum.694694- */695695- if (ubi->mtd->type == MTD_NANDFLASH)696696- ubi_assert(ubi->mtd->writebufsize == ubi->mtd->writesize);697697- else if (ubi->mtd->type == MTD_NORFLASH)698698- ubi_assert(ubi->mtd->writebufsize % ubi->mtd->writesize == 0);699699-700700- ubi->min_io_size = ubi->mtd->writebufsize;701701-675675+ ubi->min_io_size = ubi->mtd->writesize;702676 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;703677704678 /*
+13-8
drivers/net/bnx2.c
···75537553 !(data & ETH_FLAG_RXVLAN))75547554 return -EINVAL;7555755575567556+ /* TSO with VLAN tag won't work with current firmware */75577557+ if (!(data & ETH_FLAG_TXVLAN))75587558+ return -EINVAL;75597559+75567560 rc = ethtool_op_set_flags(dev, data, ETH_FLAG_RXHASH | ETH_FLAG_RXVLAN |75577561 ETH_FLAG_TXVLAN);75587562 if (rc)···7966796279677963 /* AER (Advanced Error Reporting) hooks */79687964 err = pci_enable_pcie_error_reporting(pdev);79697969- if (err) {79707970- dev_err(&pdev->dev, "pci_enable_pcie_error_reporting "79717971- "failed 0x%x\n", err);79727972- /* non-fatal, continue */79737973- }79657965+ if (!err)79667966+ bp->flags |= BNX2_FLAG_AER_ENABLED;7974796779757968 } else {79767969 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);···82308229 return 0;8231823082328231err_out_unmap:82338233- if (bp->flags & BNX2_FLAG_PCIE)82328232+ if (bp->flags & BNX2_FLAG_AER_ENABLED) {82348233 pci_disable_pcie_error_reporting(pdev);82348234+ bp->flags &= ~BNX2_FLAG_AER_ENABLED;82358235+ }8235823682368237 if (bp->regview) {82378238 iounmap(bp->regview);···8421841884228419 kfree(bp->temp_stats_blk);8423842084248424- if (bp->flags & BNX2_FLAG_PCIE)84218421+ if (bp->flags & BNX2_FLAG_AER_ENABLED) {84258422 pci_disable_pcie_error_reporting(pdev);84238423+ bp->flags &= ~BNX2_FLAG_AER_ENABLED;84248424+ }8426842584278426 free_netdev(dev);84288427···85408535 }85418536 rtnl_unlock();8542853785438543- if (!(bp->flags & BNX2_FLAG_PCIE))85388538+ if (!(bp->flags & BNX2_FLAG_AER_ENABLED))85448539 return result;8545854085468541 err = pci_cleanup_aer_uncorrect_error_status(pdev);
···22 * at91_can.c - CAN network driver for AT91 SoC CAN controller33 *44 * (C) 2007 by Hans J. Koch <hjk@hansjkoch.de>55- * (C) 2008, 2009, 2010 by Marc Kleine-Budde <kernel@pengutronix.de>55+ * (C) 2008, 2009, 2010, 2011 by Marc Kleine-Budde <kernel@pengutronix.de>66 *77 * This software may be distributed under the terms of the GNU General88 * Public License ("GPL") version 2 as distributed in the 'COPYING'···3030#include <linux/module.h>3131#include <linux/netdevice.h>3232#include <linux/platform_device.h>3333+#include <linux/rtnetlink.h>3334#include <linux/skbuff.h>3435#include <linux/spinlock.h>3536#include <linux/string.h>···41404241#include <mach/board.h>43424444-#define AT91_NAPI_WEIGHT 124343+#define AT91_NAPI_WEIGHT 1145444645/*4746 * RX/TX Mailbox split4847 * don't dare to touch4948 */5050-#define AT91_MB_RX_NUM 124949+#define AT91_MB_RX_NUM 115150#define AT91_MB_TX_SHIFT 252515353-#define AT91_MB_RX_FIRST 05252+#define AT91_MB_RX_FIRST 15453#define AT91_MB_RX_LAST (AT91_MB_RX_FIRST + AT91_MB_RX_NUM - 1)55545655#define AT91_MB_RX_MASK(i) ((1 << (i)) - 1)5756#define AT91_MB_RX_SPLIT 85857#define AT91_MB_RX_LOW_LAST (AT91_MB_RX_SPLIT - 1)5959-#define AT91_MB_RX_LOW_MASK (AT91_MB_RX_MASK(AT91_MB_RX_SPLIT))5858+#define AT91_MB_RX_LOW_MASK (AT91_MB_RX_MASK(AT91_MB_RX_SPLIT) & \5959+ ~AT91_MB_RX_MASK(AT91_MB_RX_FIRST))60606161#define AT91_MB_TX_NUM (1 << AT91_MB_TX_SHIFT)6262#define AT91_MB_TX_FIRST (AT91_MB_RX_LAST + 1)···170168171169 struct clk *clk;172170 struct at91_can_data *pdata;171171+172172+ canid_t mb0_id;173173};174174175175static struct can_bittiming_const at91_bittiming_const = {···224220 set_mb_mode_prio(priv, mb, mode, 0);225221}226222223223+static inline u32 at91_can_id_to_reg_mid(canid_t can_id)224224+{225225+ u32 reg_mid;226226+227227+ if (can_id & CAN_EFF_FLAG)228228+ reg_mid = (can_id & CAN_EFF_MASK) | AT91_MID_MIDE;229229+ else230230+ reg_mid = (can_id & CAN_SFF_MASK) << 18;231231+232232+ return reg_mid;233233+}234234+227235/*228236 * Swtich transceiver on or off229237 */···249233{250234 struct at91_priv *priv = netdev_priv(dev);251235 unsigned int i;236236+ u32 reg_mid;252237253238 /*254254- * The first 12 mailboxes are used as a reception FIFO. The255255- * last mailbox is configured with overwrite option. The256256- * overwrite flag indicates a FIFO overflow.239239+ * Due to a chip bug (errata 50.2.6.3 & 50.3.5.3) the first240240+ * mailbox is disabled. The next 11 mailboxes are used as a241241+ * reception FIFO. The last mailbox is configured with242242+ * overwrite option. The overwrite flag indicates a FIFO243243+ * overflow.257244 */245245+ reg_mid = at91_can_id_to_reg_mid(priv->mb0_id);246246+ for (i = 0; i < AT91_MB_RX_FIRST; i++) {247247+ set_mb_mode(priv, i, AT91_MB_MODE_DISABLED);248248+ at91_write(priv, AT91_MID(i), reg_mid);249249+ at91_write(priv, AT91_MCR(i), 0x0); /* clear dlc */250250+ }251251+258252 for (i = AT91_MB_RX_FIRST; i < AT91_MB_RX_LAST; i++)259253 set_mb_mode(priv, i, AT91_MB_MODE_RX);260254 set_mb_mode(priv, AT91_MB_RX_LAST, AT91_MB_MODE_RX_OVRWR);···280254 set_mb_mode_prio(priv, i, AT91_MB_MODE_TX, 0);281255282256 /* Reset tx and rx helper pointers */283283- priv->tx_next = priv->tx_echo = priv->rx_next = 0;257257+ priv->tx_next = priv->tx_echo = 0;258258+ priv->rx_next = AT91_MB_RX_FIRST;284259}285260286261static int at91_set_bittiming(struct net_device *dev)···399372 netdev_err(dev, "BUG! TX buffer full when queue awake!\n");400373 return NETDEV_TX_BUSY;401374 }402402-403403- if (cf->can_id & CAN_EFF_FLAG)404404- reg_mid = (cf->can_id & CAN_EFF_MASK) | AT91_MID_MIDE;405405- else406406- reg_mid = (cf->can_id & CAN_SFF_MASK) << 18;407407-375375+ reg_mid = at91_can_id_to_reg_mid(cf->can_id);408376 reg_mcr = ((cf->can_id & CAN_RTR_FLAG) ? AT91_MCR_MRTR : 0) |409377 (cf->can_dlc << 16) | AT91_MCR_MTCR;410378···561539 *562540 * Theory of Operation:563541 *564564- * 12 of the 16 mailboxes on the chip are reserved for RX. we split565565- * them into 2 groups. The lower group holds 8 and upper 4 mailboxes.542542+ * 11 of the 16 mailboxes on the chip are reserved for RX. we split543543+ * them into 2 groups. The lower group holds 7 and upper 4 mailboxes.566544 *567545 * Like it or not, but the chip always saves a received CAN message568546 * into the first free mailbox it finds (starting with the569547 * lowest). This makes it very difficult to read the messages in the570548 * right order from the chip. This is how we work around that problem:571549 *572572- * The first message goes into mb nr. 0 and issues an interrupt. All550550+ * The first message goes into mb nr. 1 and issues an interrupt. All573551 * rx ints are disabled in the interrupt handler and a napi poll is574552 * scheduled. We read the mailbox, but do _not_ reenable the mb (to575553 * receive another message).576554 *577555 * lower mbxs upper578578- * ______^______ __^__579579- * / \ / \556556+ * ____^______ __^__557557+ * / \ / \580558 * +-+-+-+-+-+-+-+-++-+-+-+-+581581- * |x|x|x|x|x|x|x|x|| | | | |559559+ * | |x|x|x|x|x|x|x|| | | | |582560 * +-+-+-+-+-+-+-+-++-+-+-+-+583561 * 0 0 0 0 0 0 0 0 0 0 1 1 \ mail584562 * 0 1 2 3 4 5 6 7 8 9 0 1 / box563563+ * ^564564+ * |565565+ * \566566+ * unused, due to chip bug585567 *586568 * The variable priv->rx_next points to the next mailbox to read a587569 * message from. As long we're in the lower mailboxes we just read the···616590 "order of incoming frames cannot be guaranteed\n");617591618592 again:619619- for (mb = find_next_bit(addr, AT91_MB_RX_NUM, priv->rx_next);620620- mb < AT91_MB_RX_NUM && quota > 0;593593+ for (mb = find_next_bit(addr, AT91_MB_RX_LAST + 1, priv->rx_next);594594+ mb < AT91_MB_RX_LAST + 1 && quota > 0;621595 reg_sr = at91_read(priv, AT91_SR),622622- mb = find_next_bit(addr, AT91_MB_RX_NUM, ++priv->rx_next)) {596596+ mb = find_next_bit(addr, AT91_MB_RX_LAST + 1, ++priv->rx_next)) {623597 at91_read_msg(dev, mb);624598625599 /* reactivate mailboxes */···636610637611 /* upper group completed, look again in lower */638612 if (priv->rx_next > AT91_MB_RX_LOW_LAST &&639639- quota > 0 && mb >= AT91_MB_RX_NUM) {640640- priv->rx_next = 0;613613+ quota > 0 && mb > AT91_MB_RX_LAST) {614614+ priv->rx_next = AT91_MB_RX_FIRST;641615 goto again;642616 }643617···10631037 .ndo_start_xmit = at91_start_xmit,10641038};1065103910401040+static ssize_t at91_sysfs_show_mb0_id(struct device *dev,10411041+ struct device_attribute *attr, char *buf)10421042+{10431043+ struct at91_priv *priv = netdev_priv(to_net_dev(dev));10441044+10451045+ if (priv->mb0_id & CAN_EFF_FLAG)10461046+ return snprintf(buf, PAGE_SIZE, "0x%08x\n", priv->mb0_id);10471047+ else10481048+ return snprintf(buf, PAGE_SIZE, "0x%03x\n", priv->mb0_id);10491049+}10501050+10511051+static ssize_t at91_sysfs_set_mb0_id(struct device *dev,10521052+ struct device_attribute *attr, const char *buf, size_t count)10531053+{10541054+ struct net_device *ndev = to_net_dev(dev);10551055+ struct at91_priv *priv = netdev_priv(ndev);10561056+ unsigned long can_id;10571057+ ssize_t ret;10581058+ int err;10591059+10601060+ rtnl_lock();10611061+10621062+ if (ndev->flags & IFF_UP) {10631063+ ret = -EBUSY;10641064+ goto out;10651065+ }10661066+10671067+ err = strict_strtoul(buf, 0, &can_id);10681068+ if (err) {10691069+ ret = err;10701070+ goto out;10711071+ }10721072+10731073+ if (can_id & CAN_EFF_FLAG)10741074+ can_id &= CAN_EFF_MASK | CAN_EFF_FLAG;10751075+ else10761076+ can_id &= CAN_SFF_MASK;10771077+10781078+ priv->mb0_id = can_id;10791079+ ret = count;10801080+10811081+ out:10821082+ rtnl_unlock();10831083+ return ret;10841084+}10851085+10861086+static DEVICE_ATTR(mb0_id, S_IWUGO | S_IRUGO,10871087+ at91_sysfs_show_mb0_id, at91_sysfs_set_mb0_id);10881088+10891089+static struct attribute *at91_sysfs_attrs[] = {10901090+ &dev_attr_mb0_id.attr,10911091+ NULL,10921092+};10931093+10941094+static struct attribute_group at91_sysfs_attr_group = {10951095+ .attrs = at91_sysfs_attrs,10961096+};10971097+10661098static int __devinit at91_can_probe(struct platform_device *pdev)10671099{10681100 struct net_device *dev;···11661082 dev->netdev_ops = &at91_netdev_ops;11671083 dev->irq = irq;11681084 dev->flags |= IFF_ECHO;10851085+ dev->sysfs_groups[0] = &at91_sysfs_attr_group;1169108611701087 priv = netdev_priv(dev);11711088 priv->can.clock.freq = clk_get_rate(clk);···11781093 priv->dev = dev;11791094 priv->clk = clk;11801095 priv->pdata = pdev->dev.platform_data;10961096+ priv->mb0_id = 0x7ff;1181109711821098 netif_napi_add(dev, &priv->napi, at91_poll, AT91_NAPI_WEIGHT);11831099
+30
drivers/net/can/softing/Kconfig
···11+config CAN_SOFTING22+ tristate "Softing Gmbh CAN generic support"33+ depends on CAN_DEV44+ ---help---55+ Support for CAN cards from Softing Gmbh & some cards66+ from Vector Gmbh.77+ Softing Gmbh CAN cards come with 1 or 2 physical busses.88+ Those cards typically use Dual Port RAM to communicate99+ with the host CPU. The interface is then identical for PCI1010+ and PCMCIA cards. This driver operates on a platform device,1111+ which has been created by softing_cs or softing_pci driver.1212+ Warning:1313+ The API of the card does not allow fine control per bus, but1414+ controls the 2 busses on the card together.1515+ As such, some actions (start/stop/busoff recovery) on 1 bus1616+ must bring down the other bus too temporarily.1717+1818+config CAN_SOFTING_CS1919+ tristate "Softing Gmbh CAN pcmcia cards"2020+ depends on PCMCIA2121+ select CAN_SOFTING2222+ ---help---2323+ Support for PCMCIA cards from Softing Gmbh & some cards2424+ from Vector Gmbh.2525+ You need firmware for these, which you can get at2626+ http://developer.berlios.de/projects/socketcan/2727+ This version of the driver is written against2828+ firmware version 4.6 (softing-fw-4.6-binaries.tar.gz)2929+ In order to use the card as CAN device, you need the Softing generic3030+ support too.
···11+/*22+ * Copyright (C) 2008-201033+ *44+ * - Kurt Van Dijck, EIA Electronics55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the version 2 of the GNU General Public License88+ * as published by the Free Software Foundation99+ *1010+ * This program is distributed in the hope that it will be useful,1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313+ * GNU General Public License for more details.1414+ *1515+ * You should have received a copy of the GNU General Public License1616+ * along with this program; if not, write to the Free Software1717+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1818+ */1919+2020+#include <linux/firmware.h>2121+#include <linux/sched.h>2222+#include <asm/div64.h>2323+2424+#include "softing.h"2525+2626+/*2727+ * low level DPRAM command.2828+ * Make sure that card->dpram[DPRAM_FCT_HOST] is preset2929+ */3030+static int _softing_fct_cmd(struct softing *card, int16_t cmd, uint16_t vector,3131+ const char *msg)3232+{3333+ int ret;3434+ unsigned long stamp;3535+3636+ iowrite16(cmd, &card->dpram[DPRAM_FCT_PARAM]);3737+ iowrite8(vector >> 8, &card->dpram[DPRAM_FCT_HOST + 1]);3838+ iowrite8(vector, &card->dpram[DPRAM_FCT_HOST]);3939+ /* be sure to flush this to the card */4040+ wmb();4141+ stamp = jiffies + 1 * HZ;4242+ /* wait for card */4343+ do {4444+ /* DPRAM_FCT_HOST is _not_ aligned */4545+ ret = ioread8(&card->dpram[DPRAM_FCT_HOST]) +4646+ (ioread8(&card->dpram[DPRAM_FCT_HOST + 1]) << 8);4747+ /* don't have any cached variables */4848+ rmb();4949+ if (ret == RES_OK)5050+ /* read return-value now */5151+ return ioread16(&card->dpram[DPRAM_FCT_RESULT]);5252+5353+ if ((ret != vector) || time_after(jiffies, stamp))5454+ break;5555+ /* process context => relax */5656+ usleep_range(500, 10000);5757+ } while (1);5858+5959+ ret = (ret == RES_NONE) ? -ETIMEDOUT : -ECANCELED;6060+ dev_alert(&card->pdev->dev, "firmware %s failed (%i)\n", msg, ret);6161+ return ret;6262+}6363+6464+static int softing_fct_cmd(struct softing *card, int16_t cmd, const char *msg)6565+{6666+ int ret;6767+6868+ ret = _softing_fct_cmd(card, cmd, 0, msg);6969+ if (ret > 0) {7070+ dev_alert(&card->pdev->dev, "%s returned %u\n", msg, ret);7171+ ret = -EIO;7272+ }7373+ return ret;7474+}7575+7676+int softing_bootloader_command(struct softing *card, int16_t cmd,7777+ const char *msg)7878+{7979+ int ret;8080+ unsigned long stamp;8181+8282+ iowrite16(RES_NONE, &card->dpram[DPRAM_RECEIPT]);8383+ iowrite16(cmd, &card->dpram[DPRAM_COMMAND]);8484+ /* be sure to flush this to the card */8585+ wmb();8686+ stamp = jiffies + 3 * HZ;8787+ /* wait for card */8888+ do {8989+ ret = ioread16(&card->dpram[DPRAM_RECEIPT]);9090+ /* don't have any cached variables */9191+ rmb();9292+ if (ret == RES_OK)9393+ return 0;9494+ if (time_after(jiffies, stamp))9595+ break;9696+ /* process context => relax */9797+ usleep_range(500, 10000);9898+ } while (!signal_pending(current));9999+100100+ ret = (ret == RES_NONE) ? -ETIMEDOUT : -ECANCELED;101101+ dev_alert(&card->pdev->dev, "bootloader %s failed (%i)\n", msg, ret);102102+ return ret;103103+}104104+105105+static int fw_parse(const uint8_t **pmem, uint16_t *ptype, uint32_t *paddr,106106+ uint16_t *plen, const uint8_t **pdat)107107+{108108+ uint16_t checksum[2];109109+ const uint8_t *mem;110110+ const uint8_t *end;111111+112112+ /*113113+ * firmware records are a binary, unaligned stream composed of:114114+ * uint16_t type;115115+ * uint32_t addr;116116+ * uint16_t len;117117+ * uint8_t dat[len];118118+ * uint16_t checksum;119119+ * all values in little endian.120120+ * We could define a struct for this, with __attribute__((packed)),121121+ * but would that solve the alignment in _all_ cases (cfr. the122122+ * struct itself may be an odd address)?123123+ *124124+ * I chose to use leXX_to_cpup() since this solves both125125+ * endianness & alignment.126126+ */127127+ mem = *pmem;128128+ *ptype = le16_to_cpup((void *)&mem[0]);129129+ *paddr = le32_to_cpup((void *)&mem[2]);130130+ *plen = le16_to_cpup((void *)&mem[6]);131131+ *pdat = &mem[8];132132+ /* verify checksum */133133+ end = &mem[8 + *plen];134134+ checksum[0] = le16_to_cpup((void *)end);135135+ for (checksum[1] = 0; mem < end; ++mem)136136+ checksum[1] += *mem;137137+ if (checksum[0] != checksum[1])138138+ return -EINVAL;139139+ /* increment */140140+ *pmem += 10 + *plen;141141+ return 0;142142+}143143+144144+int softing_load_fw(const char *file, struct softing *card,145145+ __iomem uint8_t *dpram, unsigned int size, int offset)146146+{147147+ const struct firmware *fw;148148+ int ret;149149+ const uint8_t *mem, *end, *dat;150150+ uint16_t type, len;151151+ uint32_t addr;152152+ uint8_t *buf = NULL;153153+ int buflen = 0;154154+ int8_t type_end = 0;155155+156156+ ret = request_firmware(&fw, file, &card->pdev->dev);157157+ if (ret < 0)158158+ return ret;159159+ dev_dbg(&card->pdev->dev, "%s, firmware(%s) got %u bytes"160160+ ", offset %c0x%04x\n",161161+ card->pdat->name, file, (unsigned int)fw->size,162162+ (offset >= 0) ? '+' : '-', (unsigned int)abs(offset));163163+ /* parse the firmware */164164+ mem = fw->data;165165+ end = &mem[fw->size];166166+ /* look for header record */167167+ ret = fw_parse(&mem, &type, &addr, &len, &dat);168168+ if (ret < 0)169169+ goto failed;170170+ if (type != 0xffff)171171+ goto failed;172172+ if (strncmp("Structured Binary Format, Softing GmbH" , dat, len)) {173173+ ret = -EINVAL;174174+ goto failed;175175+ }176176+ /* ok, we had a header */177177+ while (mem < end) {178178+ ret = fw_parse(&mem, &type, &addr, &len, &dat);179179+ if (ret < 0)180180+ goto failed;181181+ if (type == 3) {182182+ /* start address, not used here */183183+ continue;184184+ } else if (type == 1) {185185+ /* eof */186186+ type_end = 1;187187+ break;188188+ } else if (type != 0) {189189+ ret = -EINVAL;190190+ goto failed;191191+ }192192+193193+ if ((addr + len + offset) > size)194194+ goto failed;195195+ memcpy_toio(&dpram[addr + offset], dat, len);196196+ /* be sure to flush caches from IO space */197197+ mb();198198+ if (len > buflen) {199199+ /* align buflen */200200+ buflen = (len + (1024-1)) & ~(1024-1);201201+ buf = krealloc(buf, buflen, GFP_KERNEL);202202+ if (!buf) {203203+ ret = -ENOMEM;204204+ goto failed;205205+ }206206+ }207207+ /* verify record data */208208+ memcpy_fromio(buf, &dpram[addr + offset], len);209209+ if (memcmp(buf, dat, len)) {210210+ /* is not ok */211211+ dev_alert(&card->pdev->dev, "DPRAM readback failed\n");212212+ ret = -EIO;213213+ goto failed;214214+ }215215+ }216216+ if (!type_end)217217+ /* no end record seen */218218+ goto failed;219219+ ret = 0;220220+failed:221221+ kfree(buf);222222+ release_firmware(fw);223223+ if (ret < 0)224224+ dev_info(&card->pdev->dev, "firmware %s failed\n", file);225225+ return ret;226226+}227227+228228+int softing_load_app_fw(const char *file, struct softing *card)229229+{230230+ const struct firmware *fw;231231+ const uint8_t *mem, *end, *dat;232232+ int ret, j;233233+ uint16_t type, len;234234+ uint32_t addr, start_addr = 0;235235+ unsigned int sum, rx_sum;236236+ int8_t type_end = 0, type_entrypoint = 0;237237+238238+ ret = request_firmware(&fw, file, &card->pdev->dev);239239+ if (ret) {240240+ dev_alert(&card->pdev->dev, "request_firmware(%s) got %i\n",241241+ file, ret);242242+ return ret;243243+ }244244+ dev_dbg(&card->pdev->dev, "firmware(%s) got %lu bytes\n",245245+ file, (unsigned long)fw->size);246246+ /* parse the firmware */247247+ mem = fw->data;248248+ end = &mem[fw->size];249249+ /* look for header record */250250+ ret = fw_parse(&mem, &type, &addr, &len, &dat);251251+ if (ret)252252+ goto failed;253253+ ret = -EINVAL;254254+ if (type != 0xffff) {255255+ dev_alert(&card->pdev->dev, "firmware starts with type 0x%x\n",256256+ type);257257+ goto failed;258258+ }259259+ if (strncmp("Structured Binary Format, Softing GmbH", dat, len)) {260260+ dev_alert(&card->pdev->dev, "firmware string '%.*s' fault\n",261261+ len, dat);262262+ goto failed;263263+ }264264+ /* ok, we had a header */265265+ while (mem < end) {266266+ ret = fw_parse(&mem, &type, &addr, &len, &dat);267267+ if (ret)268268+ goto failed;269269+270270+ if (type == 3) {271271+ /* start address */272272+ start_addr = addr;273273+ type_entrypoint = 1;274274+ continue;275275+ } else if (type == 1) {276276+ /* eof */277277+ type_end = 1;278278+ break;279279+ } else if (type != 0) {280280+ dev_alert(&card->pdev->dev,281281+ "unknown record type 0x%04x\n", type);282282+ ret = -EINVAL;283283+ goto failed;284284+ }285285+286286+ /* regualar data */287287+ for (sum = 0, j = 0; j < len; ++j)288288+ sum += dat[j];289289+ /* work in 16bit (target) */290290+ sum &= 0xffff;291291+292292+ memcpy_toio(&card->dpram[card->pdat->app.offs], dat, len);293293+ iowrite32(card->pdat->app.offs + card->pdat->app.addr,294294+ &card->dpram[DPRAM_COMMAND + 2]);295295+ iowrite32(addr, &card->dpram[DPRAM_COMMAND + 6]);296296+ iowrite16(len, &card->dpram[DPRAM_COMMAND + 10]);297297+ iowrite8(1, &card->dpram[DPRAM_COMMAND + 12]);298298+ ret = softing_bootloader_command(card, 1, "loading app.");299299+ if (ret < 0)300300+ goto failed;301301+ /* verify checksum */302302+ rx_sum = ioread16(&card->dpram[DPRAM_RECEIPT + 2]);303303+ if (rx_sum != sum) {304304+ dev_alert(&card->pdev->dev, "SRAM seems to be damaged"305305+ ", wanted 0x%04x, got 0x%04x\n", sum, rx_sum);306306+ ret = -EIO;307307+ goto failed;308308+ }309309+ }310310+ if (!type_end || !type_entrypoint)311311+ goto failed;312312+ /* start application in card */313313+ iowrite32(start_addr, &card->dpram[DPRAM_COMMAND + 2]);314314+ iowrite8(1, &card->dpram[DPRAM_COMMAND + 6]);315315+ ret = softing_bootloader_command(card, 3, "start app.");316316+ if (ret < 0)317317+ goto failed;318318+ ret = 0;319319+failed:320320+ release_firmware(fw);321321+ if (ret < 0)322322+ dev_info(&card->pdev->dev, "firmware %s failed\n", file);323323+ return ret;324324+}325325+326326+static int softing_reset_chip(struct softing *card)327327+{328328+ int ret;329329+330330+ do {331331+ /* reset chip */332332+ iowrite8(0, &card->dpram[DPRAM_RESET_RX_FIFO]);333333+ iowrite8(0, &card->dpram[DPRAM_RESET_RX_FIFO+1]);334334+ iowrite8(1, &card->dpram[DPRAM_RESET]);335335+ iowrite8(0, &card->dpram[DPRAM_RESET+1]);336336+337337+ ret = softing_fct_cmd(card, 0, "reset_can");338338+ if (!ret)339339+ break;340340+ if (signal_pending(current))341341+ /* don't wait any longer */342342+ break;343343+ } while (1);344344+ card->tx.pending = 0;345345+ return ret;346346+}347347+348348+int softing_chip_poweron(struct softing *card)349349+{350350+ int ret;351351+ /* sync */352352+ ret = _softing_fct_cmd(card, 99, 0x55, "sync-a");353353+ if (ret < 0)354354+ goto failed;355355+356356+ ret = _softing_fct_cmd(card, 99, 0xaa, "sync-b");357357+ if (ret < 0)358358+ goto failed;359359+360360+ ret = softing_reset_chip(card);361361+ if (ret < 0)362362+ goto failed;363363+ /* get_serial */364364+ ret = softing_fct_cmd(card, 43, "get_serial_number");365365+ if (ret < 0)366366+ goto failed;367367+ card->id.serial = ioread32(&card->dpram[DPRAM_FCT_PARAM]);368368+ /* get_version */369369+ ret = softing_fct_cmd(card, 12, "get_version");370370+ if (ret < 0)371371+ goto failed;372372+ card->id.fw_version = ioread16(&card->dpram[DPRAM_FCT_PARAM + 2]);373373+ card->id.hw_version = ioread16(&card->dpram[DPRAM_FCT_PARAM + 4]);374374+ card->id.license = ioread16(&card->dpram[DPRAM_FCT_PARAM + 6]);375375+ card->id.chip[0] = ioread16(&card->dpram[DPRAM_FCT_PARAM + 8]);376376+ card->id.chip[1] = ioread16(&card->dpram[DPRAM_FCT_PARAM + 10]);377377+ return 0;378378+failed:379379+ return ret;380380+}381381+382382+static void softing_initialize_timestamp(struct softing *card)383383+{384384+ uint64_t ovf;385385+386386+ card->ts_ref = ktime_get();387387+388388+ /* 16MHz is the reference */389389+ ovf = 0x100000000ULL * 16;390390+ do_div(ovf, card->pdat->freq ?: 16);391391+392392+ card->ts_overflow = ktime_add_us(ktime_set(0, 0), ovf);393393+}394394+395395+ktime_t softing_raw2ktime(struct softing *card, u32 raw)396396+{397397+ uint64_t rawl;398398+ ktime_t now, real_offset;399399+ ktime_t target;400400+ ktime_t tmp;401401+402402+ now = ktime_get();403403+ real_offset = ktime_sub(ktime_get_real(), now);404404+405405+ /* find nsec from card */406406+ rawl = raw * 16;407407+ do_div(rawl, card->pdat->freq ?: 16);408408+ target = ktime_add_us(card->ts_ref, rawl);409409+ /* test for overflows */410410+ tmp = ktime_add(target, card->ts_overflow);411411+ while (unlikely(ktime_to_ns(tmp) > ktime_to_ns(now))) {412412+ card->ts_ref = ktime_add(card->ts_ref, card->ts_overflow);413413+ target = tmp;414414+ tmp = ktime_add(target, card->ts_overflow);415415+ }416416+ return ktime_add(target, real_offset);417417+}418418+419419+static inline int softing_error_reporting(struct net_device *netdev)420420+{421421+ struct softing_priv *priv = netdev_priv(netdev);422422+423423+ return (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)424424+ ? 1 : 0;425425+}426426+427427+int softing_startstop(struct net_device *dev, int up)428428+{429429+ int ret;430430+ struct softing *card;431431+ struct softing_priv *priv;432432+ struct net_device *netdev;433433+ int bus_bitmask_start;434434+ int j, error_reporting;435435+ struct can_frame msg;436436+ const struct can_bittiming *bt;437437+438438+ priv = netdev_priv(dev);439439+ card = priv->card;440440+441441+ if (!card->fw.up)442442+ return -EIO;443443+444444+ ret = mutex_lock_interruptible(&card->fw.lock);445445+ if (ret)446446+ return ret;447447+448448+ bus_bitmask_start = 0;449449+ if (dev && up)450450+ /* prepare to start this bus as well */451451+ bus_bitmask_start |= (1 << priv->index);452452+ /* bring netdevs down */453453+ for (j = 0; j < ARRAY_SIZE(card->net); ++j) {454454+ netdev = card->net[j];455455+ if (!netdev)456456+ continue;457457+ priv = netdev_priv(netdev);458458+459459+ if (dev != netdev)460460+ netif_stop_queue(netdev);461461+462462+ if (netif_running(netdev)) {463463+ if (dev != netdev)464464+ bus_bitmask_start |= (1 << j);465465+ priv->tx.pending = 0;466466+ priv->tx.echo_put = 0;467467+ priv->tx.echo_get = 0;468468+ /*469469+ * this bus' may just have called open_candev()470470+ * which is rather stupid to call close_candev()471471+ * already472472+ * but we may come here from busoff recovery too473473+ * in which case the echo_skb _needs_ flushing too.474474+ * just be sure to call open_candev() again475475+ */476476+ close_candev(netdev);477477+ }478478+ priv->can.state = CAN_STATE_STOPPED;479479+ }480480+ card->tx.pending = 0;481481+482482+ softing_enable_irq(card, 0);483483+ ret = softing_reset_chip(card);484484+ if (ret)485485+ goto failed;486486+ if (!bus_bitmask_start)487487+ /* no busses to be brought up */488488+ goto card_done;489489+490490+ if ((bus_bitmask_start & 1) && (bus_bitmask_start & 2)491491+ && (softing_error_reporting(card->net[0])492492+ != softing_error_reporting(card->net[1]))) {493493+ dev_alert(&card->pdev->dev,494494+ "err_reporting flag differs for busses\n");495495+ goto invalid;496496+ }497497+ error_reporting = 0;498498+ if (bus_bitmask_start & 1) {499499+ netdev = card->net[0];500500+ priv = netdev_priv(netdev);501501+ error_reporting += softing_error_reporting(netdev);502502+ /* init chip 1 */503503+ bt = &priv->can.bittiming;504504+ iowrite16(bt->brp, &card->dpram[DPRAM_FCT_PARAM + 2]);505505+ iowrite16(bt->sjw, &card->dpram[DPRAM_FCT_PARAM + 4]);506506+ iowrite16(bt->phase_seg1 + bt->prop_seg,507507+ &card->dpram[DPRAM_FCT_PARAM + 6]);508508+ iowrite16(bt->phase_seg2, &card->dpram[DPRAM_FCT_PARAM + 8]);509509+ iowrite16((priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) ? 1 : 0,510510+ &card->dpram[DPRAM_FCT_PARAM + 10]);511511+ ret = softing_fct_cmd(card, 1, "initialize_chip[0]");512512+ if (ret < 0)513513+ goto failed;514514+ /* set mode */515515+ iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 2]);516516+ iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 4]);517517+ ret = softing_fct_cmd(card, 3, "set_mode[0]");518518+ if (ret < 0)519519+ goto failed;520520+ /* set filter */521521+ /* 11bit id & mask */522522+ iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 2]);523523+ iowrite16(0x07ff, &card->dpram[DPRAM_FCT_PARAM + 4]);524524+ /* 29bit id.lo & mask.lo & id.hi & mask.hi */525525+ iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 6]);526526+ iowrite16(0xffff, &card->dpram[DPRAM_FCT_PARAM + 8]);527527+ iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 10]);528528+ iowrite16(0x1fff, &card->dpram[DPRAM_FCT_PARAM + 12]);529529+ ret = softing_fct_cmd(card, 7, "set_filter[0]");530530+ if (ret < 0)531531+ goto failed;532532+ /* set output control */533533+ iowrite16(priv->output, &card->dpram[DPRAM_FCT_PARAM + 2]);534534+ ret = softing_fct_cmd(card, 5, "set_output[0]");535535+ if (ret < 0)536536+ goto failed;537537+ }538538+ if (bus_bitmask_start & 2) {539539+ netdev = card->net[1];540540+ priv = netdev_priv(netdev);541541+ error_reporting += softing_error_reporting(netdev);542542+ /* init chip2 */543543+ bt = &priv->can.bittiming;544544+ iowrite16(bt->brp, &card->dpram[DPRAM_FCT_PARAM + 2]);545545+ iowrite16(bt->sjw, &card->dpram[DPRAM_FCT_PARAM + 4]);546546+ iowrite16(bt->phase_seg1 + bt->prop_seg,547547+ &card->dpram[DPRAM_FCT_PARAM + 6]);548548+ iowrite16(bt->phase_seg2, &card->dpram[DPRAM_FCT_PARAM + 8]);549549+ iowrite16((priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) ? 1 : 0,550550+ &card->dpram[DPRAM_FCT_PARAM + 10]);551551+ ret = softing_fct_cmd(card, 2, "initialize_chip[1]");552552+ if (ret < 0)553553+ goto failed;554554+ /* set mode2 */555555+ iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 2]);556556+ iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 4]);557557+ ret = softing_fct_cmd(card, 4, "set_mode[1]");558558+ if (ret < 0)559559+ goto failed;560560+ /* set filter2 */561561+ /* 11bit id & mask */562562+ iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 2]);563563+ iowrite16(0x07ff, &card->dpram[DPRAM_FCT_PARAM + 4]);564564+ /* 29bit id.lo & mask.lo & id.hi & mask.hi */565565+ iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 6]);566566+ iowrite16(0xffff, &card->dpram[DPRAM_FCT_PARAM + 8]);567567+ iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 10]);568568+ iowrite16(0x1fff, &card->dpram[DPRAM_FCT_PARAM + 12]);569569+ ret = softing_fct_cmd(card, 8, "set_filter[1]");570570+ if (ret < 0)571571+ goto failed;572572+ /* set output control2 */573573+ iowrite16(priv->output, &card->dpram[DPRAM_FCT_PARAM + 2]);574574+ ret = softing_fct_cmd(card, 6, "set_output[1]");575575+ if (ret < 0)576576+ goto failed;577577+ }578578+ /* enable_error_frame */579579+ /*580580+ * Error reporting is switched off at the moment since581581+ * the receiving of them is not yet 100% verified582582+ * This should be enabled sooner or later583583+ *584584+ if (error_reporting) {585585+ ret = softing_fct_cmd(card, 51, "enable_error_frame");586586+ if (ret < 0)587587+ goto failed;588588+ }589589+ */590590+ /* initialize interface */591591+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 2]);592592+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 4]);593593+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 6]);594594+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 8]);595595+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 10]);596596+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 12]);597597+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 14]);598598+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 16]);599599+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 18]);600600+ iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 20]);601601+ ret = softing_fct_cmd(card, 17, "initialize_interface");602602+ if (ret < 0)603603+ goto failed;604604+ /* enable_fifo */605605+ ret = softing_fct_cmd(card, 36, "enable_fifo");606606+ if (ret < 0)607607+ goto failed;608608+ /* enable fifo tx ack */609609+ ret = softing_fct_cmd(card, 13, "fifo_tx_ack[0]");610610+ if (ret < 0)611611+ goto failed;612612+ /* enable fifo tx ack2 */613613+ ret = softing_fct_cmd(card, 14, "fifo_tx_ack[1]");614614+ if (ret < 0)615615+ goto failed;616616+ /* start_chip */617617+ ret = softing_fct_cmd(card, 11, "start_chip");618618+ if (ret < 0)619619+ goto failed;620620+ iowrite8(0, &card->dpram[DPRAM_INFO_BUSSTATE]);621621+ iowrite8(0, &card->dpram[DPRAM_INFO_BUSSTATE2]);622622+ if (card->pdat->generation < 2) {623623+ iowrite8(0, &card->dpram[DPRAM_V2_IRQ_TOHOST]);624624+ /* flush the DPRAM caches */625625+ wmb();626626+ }627627+628628+ softing_initialize_timestamp(card);629629+630630+ /*631631+ * do socketcan notifications/status changes632632+ * from here, no errors should occur, or the failed: part633633+ * must be reviewed634634+ */635635+ memset(&msg, 0, sizeof(msg));636636+ msg.can_id = CAN_ERR_FLAG | CAN_ERR_RESTARTED;637637+ msg.can_dlc = CAN_ERR_DLC;638638+ for (j = 0; j < ARRAY_SIZE(card->net); ++j) {639639+ if (!(bus_bitmask_start & (1 << j)))640640+ continue;641641+ netdev = card->net[j];642642+ if (!netdev)643643+ continue;644644+ priv = netdev_priv(netdev);645645+ priv->can.state = CAN_STATE_ERROR_ACTIVE;646646+ open_candev(netdev);647647+ if (dev != netdev) {648648+ /* notify other busses on the restart */649649+ softing_netdev_rx(netdev, &msg, ktime_set(0, 0));650650+ ++priv->can.can_stats.restarts;651651+ }652652+ netif_wake_queue(netdev);653653+ }654654+655655+ /* enable interrupts */656656+ ret = softing_enable_irq(card, 1);657657+ if (ret)658658+ goto failed;659659+card_done:660660+ mutex_unlock(&card->fw.lock);661661+ return 0;662662+invalid:663663+ ret = -EINVAL;664664+failed:665665+ softing_enable_irq(card, 0);666666+ softing_reset_chip(card);667667+ mutex_unlock(&card->fw.lock);668668+ /* bring all other interfaces down */669669+ for (j = 0; j < ARRAY_SIZE(card->net); ++j) {670670+ netdev = card->net[j];671671+ if (!netdev)672672+ continue;673673+ dev_close(netdev);674674+ }675675+ return ret;676676+}677677+678678+int softing_default_output(struct net_device *netdev)679679+{680680+ struct softing_priv *priv = netdev_priv(netdev);681681+ struct softing *card = priv->card;682682+683683+ switch (priv->chip) {684684+ case 1000:685685+ return (card->pdat->generation < 2) ? 0xfb : 0xfa;686686+ case 5:687687+ return 0x60;688688+ default:689689+ return 0x40;690690+ }691691+}
+893
drivers/net/can/softing/softing_main.c
···11+/*22+ * Copyright (C) 2008-201033+ *44+ * - Kurt Van Dijck, EIA Electronics55+ *66+ * This program is free software; you can redistribute it and/or modify77+ * it under the terms of the version 2 of the GNU General Public License88+ * as published by the Free Software Foundation99+ *1010+ * This program is distributed in the hope that it will be useful,1111+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1212+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313+ * GNU General Public License for more details.1414+ *1515+ * You should have received a copy of the GNU General Public License1616+ * along with this program; if not, write to the Free Software1717+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA1818+ */1919+2020+#include <linux/version.h>2121+#include <linux/module.h>2222+#include <linux/init.h>2323+#include <linux/interrupt.h>2424+2525+#include "softing.h"2626+2727+#define TX_ECHO_SKB_MAX (((TXMAX+1)/2)-1)2828+2929+/*3030+ * test is a specific CAN netdev3131+ * is online (ie. up 'n running, not sleeping, not busoff3232+ */3333+static inline int canif_is_active(struct net_device *netdev)3434+{3535+ struct can_priv *can = netdev_priv(netdev);3636+3737+ if (!netif_running(netdev))3838+ return 0;3939+ return (can->state <= CAN_STATE_ERROR_PASSIVE);4040+}4141+4242+/* reset DPRAM */4343+static inline void softing_set_reset_dpram(struct softing *card)4444+{4545+ if (card->pdat->generation >= 2) {4646+ spin_lock_bh(&card->spin);4747+ iowrite8(ioread8(&card->dpram[DPRAM_V2_RESET]) & ~1,4848+ &card->dpram[DPRAM_V2_RESET]);4949+ spin_unlock_bh(&card->spin);5050+ }5151+}5252+5353+static inline void softing_clr_reset_dpram(struct softing *card)5454+{5555+ if (card->pdat->generation >= 2) {5656+ spin_lock_bh(&card->spin);5757+ iowrite8(ioread8(&card->dpram[DPRAM_V2_RESET]) | 1,5858+ &card->dpram[DPRAM_V2_RESET]);5959+ spin_unlock_bh(&card->spin);6060+ }6161+}6262+6363+/* trigger the tx queue-ing */6464+static netdev_tx_t softing_netdev_start_xmit(struct sk_buff *skb,6565+ struct net_device *dev)6666+{6767+ struct softing_priv *priv = netdev_priv(dev);6868+ struct softing *card = priv->card;6969+ int ret;7070+ uint8_t *ptr;7171+ uint8_t fifo_wr, fifo_rd;7272+ struct can_frame *cf = (struct can_frame *)skb->data;7373+ uint8_t buf[DPRAM_TX_SIZE];7474+7575+ if (can_dropped_invalid_skb(dev, skb))7676+ return NETDEV_TX_OK;7777+7878+ spin_lock(&card->spin);7979+8080+ ret = NETDEV_TX_BUSY;8181+ if (!card->fw.up ||8282+ (card->tx.pending >= TXMAX) ||8383+ (priv->tx.pending >= TX_ECHO_SKB_MAX))8484+ goto xmit_done;8585+ fifo_wr = ioread8(&card->dpram[DPRAM_TX_WR]);8686+ fifo_rd = ioread8(&card->dpram[DPRAM_TX_RD]);8787+ if (fifo_wr == fifo_rd)8888+ /* fifo full */8989+ goto xmit_done;9090+ memset(buf, 0, sizeof(buf));9191+ ptr = buf;9292+ *ptr = CMD_TX;9393+ if (cf->can_id & CAN_RTR_FLAG)9494+ *ptr |= CMD_RTR;9595+ if (cf->can_id & CAN_EFF_FLAG)9696+ *ptr |= CMD_XTD;9797+ if (priv->index)9898+ *ptr |= CMD_BUS2;9999+ ++ptr;100100+ *ptr++ = cf->can_dlc;101101+ *ptr++ = (cf->can_id >> 0);102102+ *ptr++ = (cf->can_id >> 8);103103+ if (cf->can_id & CAN_EFF_FLAG) {104104+ *ptr++ = (cf->can_id >> 16);105105+ *ptr++ = (cf->can_id >> 24);106106+ } else {107107+ /* increment 1, not 2 as you might think */108108+ ptr += 1;109109+ }110110+ if (!(cf->can_id & CAN_RTR_FLAG))111111+ memcpy(ptr, &cf->data[0], cf->can_dlc);112112+ memcpy_toio(&card->dpram[DPRAM_TX + DPRAM_TX_SIZE * fifo_wr],113113+ buf, DPRAM_TX_SIZE);114114+ if (++fifo_wr >= DPRAM_TX_CNT)115115+ fifo_wr = 0;116116+ iowrite8(fifo_wr, &card->dpram[DPRAM_TX_WR]);117117+ card->tx.last_bus = priv->index;118118+ ++card->tx.pending;119119+ ++priv->tx.pending;120120+ can_put_echo_skb(skb, dev, priv->tx.echo_put);121121+ ++priv->tx.echo_put;122122+ if (priv->tx.echo_put >= TX_ECHO_SKB_MAX)123123+ priv->tx.echo_put = 0;124124+ /* can_put_echo_skb() saves the skb, safe to return TX_OK */125125+ ret = NETDEV_TX_OK;126126+xmit_done:127127+ spin_unlock(&card->spin);128128+ if (card->tx.pending >= TXMAX) {129129+ int j;130130+ for (j = 0; j < ARRAY_SIZE(card->net); ++j) {131131+ if (card->net[j])132132+ netif_stop_queue(card->net[j]);133133+ }134134+ }135135+ if (ret != NETDEV_TX_OK)136136+ netif_stop_queue(dev);137137+138138+ return ret;139139+}140140+141141+/*142142+ * shortcut for skb delivery143143+ */144144+int softing_netdev_rx(struct net_device *netdev, const struct can_frame *msg,145145+ ktime_t ktime)146146+{147147+ struct sk_buff *skb;148148+ struct can_frame *cf;149149+150150+ skb = alloc_can_skb(netdev, &cf);151151+ if (!skb)152152+ return -ENOMEM;153153+ memcpy(cf, msg, sizeof(*msg));154154+ skb->tstamp = ktime;155155+ return netif_rx(skb);156156+}157157+158158+/*159159+ * softing_handle_1160160+ * pop 1 entry from the DPRAM queue, and process161161+ */162162+static int softing_handle_1(struct softing *card)163163+{164164+ struct net_device *netdev;165165+ struct softing_priv *priv;166166+ ktime_t ktime;167167+ struct can_frame msg;168168+ int cnt = 0, lost_msg;169169+ uint8_t fifo_rd, fifo_wr, cmd;170170+ uint8_t *ptr;171171+ uint32_t tmp_u32;172172+ uint8_t buf[DPRAM_RX_SIZE];173173+174174+ memset(&msg, 0, sizeof(msg));175175+ /* test for lost msgs */176176+ lost_msg = ioread8(&card->dpram[DPRAM_RX_LOST]);177177+ if (lost_msg) {178178+ int j;179179+ /* reset condition */180180+ iowrite8(0, &card->dpram[DPRAM_RX_LOST]);181181+ /* prepare msg */182182+ msg.can_id = CAN_ERR_FLAG | CAN_ERR_CRTL;183183+ msg.can_dlc = CAN_ERR_DLC;184184+ msg.data[1] = CAN_ERR_CRTL_RX_OVERFLOW;185185+ /*186186+ * service to all busses, we don't know which it was applicable187187+ * but only service busses that are online188188+ */189189+ for (j = 0; j < ARRAY_SIZE(card->net); ++j) {190190+ netdev = card->net[j];191191+ if (!netdev)192192+ continue;193193+ if (!canif_is_active(netdev))194194+ /* a dead bus has no overflows */195195+ continue;196196+ ++netdev->stats.rx_over_errors;197197+ softing_netdev_rx(netdev, &msg, ktime_set(0, 0));198198+ }199199+ /* prepare for other use */200200+ memset(&msg, 0, sizeof(msg));201201+ ++cnt;202202+ }203203+204204+ fifo_rd = ioread8(&card->dpram[DPRAM_RX_RD]);205205+ fifo_wr = ioread8(&card->dpram[DPRAM_RX_WR]);206206+207207+ if (++fifo_rd >= DPRAM_RX_CNT)208208+ fifo_rd = 0;209209+ if (fifo_wr == fifo_rd)210210+ return cnt;211211+212212+ memcpy_fromio(buf, &card->dpram[DPRAM_RX + DPRAM_RX_SIZE*fifo_rd],213213+ DPRAM_RX_SIZE);214214+ mb();215215+ /* trigger dual port RAM */216216+ iowrite8(fifo_rd, &card->dpram[DPRAM_RX_RD]);217217+218218+ ptr = buf;219219+ cmd = *ptr++;220220+ if (cmd == 0xff)221221+ /* not quite usefull, probably the card has got out */222222+ return 0;223223+ netdev = card->net[0];224224+ if (cmd & CMD_BUS2)225225+ netdev = card->net[1];226226+ priv = netdev_priv(netdev);227227+228228+ if (cmd & CMD_ERR) {229229+ uint8_t can_state, state;230230+231231+ state = *ptr++;232232+233233+ msg.can_id = CAN_ERR_FLAG;234234+ msg.can_dlc = CAN_ERR_DLC;235235+236236+ if (state & SF_MASK_BUSOFF) {237237+ can_state = CAN_STATE_BUS_OFF;238238+ msg.can_id |= CAN_ERR_BUSOFF;239239+ state = STATE_BUSOFF;240240+ } else if (state & SF_MASK_EPASSIVE) {241241+ can_state = CAN_STATE_ERROR_PASSIVE;242242+ msg.can_id |= CAN_ERR_CRTL;243243+ msg.data[1] = CAN_ERR_CRTL_TX_PASSIVE;244244+ state = STATE_EPASSIVE;245245+ } else {246246+ can_state = CAN_STATE_ERROR_ACTIVE;247247+ msg.can_id |= CAN_ERR_CRTL;248248+ state = STATE_EACTIVE;249249+ }250250+ /* update DPRAM */251251+ iowrite8(state, &card->dpram[priv->index ?252252+ DPRAM_INFO_BUSSTATE2 : DPRAM_INFO_BUSSTATE]);253253+ /* timestamp */254254+ tmp_u32 = le32_to_cpup((void *)ptr);255255+ ptr += 4;256256+ ktime = softing_raw2ktime(card, tmp_u32);257257+258258+ ++netdev->stats.rx_errors;259259+ /* update internal status */260260+ if (can_state != priv->can.state) {261261+ priv->can.state = can_state;262262+ if (can_state == CAN_STATE_ERROR_PASSIVE)263263+ ++priv->can.can_stats.error_passive;264264+ else if (can_state == CAN_STATE_BUS_OFF) {265265+ /* this calls can_close_cleanup() */266266+ can_bus_off(netdev);267267+ netif_stop_queue(netdev);268268+ }269269+ /* trigger socketcan */270270+ softing_netdev_rx(netdev, &msg, ktime);271271+ }272272+273273+ } else {274274+ if (cmd & CMD_RTR)275275+ msg.can_id |= CAN_RTR_FLAG;276276+ msg.can_dlc = get_can_dlc(*ptr++);277277+ if (cmd & CMD_XTD) {278278+ msg.can_id |= CAN_EFF_FLAG;279279+ msg.can_id |= le32_to_cpup((void *)ptr);280280+ ptr += 4;281281+ } else {282282+ msg.can_id |= le16_to_cpup((void *)ptr);283283+ ptr += 2;284284+ }285285+ /* timestamp */286286+ tmp_u32 = le32_to_cpup((void *)ptr);287287+ ptr += 4;288288+ ktime = softing_raw2ktime(card, tmp_u32);289289+ if (!(msg.can_id & CAN_RTR_FLAG))290290+ memcpy(&msg.data[0], ptr, 8);291291+ ptr += 8;292292+ /* update socket */293293+ if (cmd & CMD_ACK) {294294+ /* acknowledge, was tx msg */295295+ struct sk_buff *skb;296296+ skb = priv->can.echo_skb[priv->tx.echo_get];297297+ if (skb)298298+ skb->tstamp = ktime;299299+ can_get_echo_skb(netdev, priv->tx.echo_get);300300+ ++priv->tx.echo_get;301301+ if (priv->tx.echo_get >= TX_ECHO_SKB_MAX)302302+ priv->tx.echo_get = 0;303303+ if (priv->tx.pending)304304+ --priv->tx.pending;305305+ if (card->tx.pending)306306+ --card->tx.pending;307307+ ++netdev->stats.tx_packets;308308+ if (!(msg.can_id & CAN_RTR_FLAG))309309+ netdev->stats.tx_bytes += msg.can_dlc;310310+ } else {311311+ int ret;312312+313313+ ret = softing_netdev_rx(netdev, &msg, ktime);314314+ if (ret == NET_RX_SUCCESS) {315315+ ++netdev->stats.rx_packets;316316+ if (!(msg.can_id & CAN_RTR_FLAG))317317+ netdev->stats.rx_bytes += msg.can_dlc;318318+ } else {319319+ ++netdev->stats.rx_dropped;320320+ }321321+ }322322+ }323323+ ++cnt;324324+ return cnt;325325+}326326+327327+/*328328+ * real interrupt handler329329+ */330330+static irqreturn_t softing_irq_thread(int irq, void *dev_id)331331+{332332+ struct softing *card = (struct softing *)dev_id;333333+ struct net_device *netdev;334334+ struct softing_priv *priv;335335+ int j, offset, work_done;336336+337337+ work_done = 0;338338+ spin_lock_bh(&card->spin);339339+ while (softing_handle_1(card) > 0) {340340+ ++card->irq.svc_count;341341+ ++work_done;342342+ }343343+ spin_unlock_bh(&card->spin);344344+ /* resume tx queue's */345345+ offset = card->tx.last_bus;346346+ for (j = 0; j < ARRAY_SIZE(card->net); ++j) {347347+ if (card->tx.pending >= TXMAX)348348+ break;349349+ netdev = card->net[(j + offset + 1) % card->pdat->nbus];350350+ if (!netdev)351351+ continue;352352+ priv = netdev_priv(netdev);353353+ if (!canif_is_active(netdev))354354+ /* it makes no sense to wake dead busses */355355+ continue;356356+ if (priv->tx.pending >= TX_ECHO_SKB_MAX)357357+ continue;358358+ ++work_done;359359+ netif_wake_queue(netdev);360360+ }361361+ return work_done ? IRQ_HANDLED : IRQ_NONE;362362+}363363+364364+/*365365+ * interrupt routines:366366+ * schedule the 'real interrupt handler'367367+ */368368+static irqreturn_t softing_irq_v2(int irq, void *dev_id)369369+{370370+ struct softing *card = (struct softing *)dev_id;371371+ uint8_t ir;372372+373373+ ir = ioread8(&card->dpram[DPRAM_V2_IRQ_TOHOST]);374374+ iowrite8(0, &card->dpram[DPRAM_V2_IRQ_TOHOST]);375375+ return (1 == ir) ? IRQ_WAKE_THREAD : IRQ_NONE;376376+}377377+378378+static irqreturn_t softing_irq_v1(int irq, void *dev_id)379379+{380380+ struct softing *card = (struct softing *)dev_id;381381+ uint8_t ir;382382+383383+ ir = ioread8(&card->dpram[DPRAM_IRQ_TOHOST]);384384+ iowrite8(0, &card->dpram[DPRAM_IRQ_TOHOST]);385385+ return ir ? IRQ_WAKE_THREAD : IRQ_NONE;386386+}387387+388388+/*389389+ * netdev/candev inter-operability390390+ */391391+static int softing_netdev_open(struct net_device *ndev)392392+{393393+ int ret;394394+395395+ /* check or determine and set bittime */396396+ ret = open_candev(ndev);397397+ if (!ret)398398+ ret = softing_startstop(ndev, 1);399399+ return ret;400400+}401401+402402+static int softing_netdev_stop(struct net_device *ndev)403403+{404404+ int ret;405405+406406+ netif_stop_queue(ndev);407407+408408+ /* softing cycle does close_candev() */409409+ ret = softing_startstop(ndev, 0);410410+ return ret;411411+}412412+413413+static int softing_candev_set_mode(struct net_device *ndev, enum can_mode mode)414414+{415415+ int ret;416416+417417+ switch (mode) {418418+ case CAN_MODE_START:419419+ /* softing_startstop does close_candev() */420420+ ret = softing_startstop(ndev, 1);421421+ return ret;422422+ case CAN_MODE_STOP:423423+ case CAN_MODE_SLEEP:424424+ return -EOPNOTSUPP;425425+ }426426+ return 0;427427+}428428+429429+/*430430+ * Softing device management helpers431431+ */432432+int softing_enable_irq(struct softing *card, int enable)433433+{434434+ int ret;435435+436436+ if (!card->irq.nr) {437437+ return 0;438438+ } else if (card->irq.requested && !enable) {439439+ free_irq(card->irq.nr, card);440440+ card->irq.requested = 0;441441+ } else if (!card->irq.requested && enable) {442442+ ret = request_threaded_irq(card->irq.nr,443443+ (card->pdat->generation >= 2) ?444444+ softing_irq_v2 : softing_irq_v1,445445+ softing_irq_thread, IRQF_SHARED,446446+ dev_name(&card->pdev->dev), card);447447+ if (ret) {448448+ dev_alert(&card->pdev->dev,449449+ "request_threaded_irq(%u) failed\n",450450+ card->irq.nr);451451+ return ret;452452+ }453453+ card->irq.requested = 1;454454+ }455455+ return 0;456456+}457457+458458+static void softing_card_shutdown(struct softing *card)459459+{460460+ int fw_up = 0;461461+462462+ if (mutex_lock_interruptible(&card->fw.lock))463463+ /* return -ERESTARTSYS */;464464+ fw_up = card->fw.up;465465+ card->fw.up = 0;466466+467467+ if (card->irq.requested && card->irq.nr) {468468+ free_irq(card->irq.nr, card);469469+ card->irq.requested = 0;470470+ }471471+ if (fw_up) {472472+ if (card->pdat->enable_irq)473473+ card->pdat->enable_irq(card->pdev, 0);474474+ softing_set_reset_dpram(card);475475+ if (card->pdat->reset)476476+ card->pdat->reset(card->pdev, 1);477477+ }478478+ mutex_unlock(&card->fw.lock);479479+}480480+481481+static __devinit int softing_card_boot(struct softing *card)482482+{483483+ int ret, j;484484+ static const uint8_t stream[] = {485485+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, };486486+ unsigned char back[sizeof(stream)];487487+488488+ if (mutex_lock_interruptible(&card->fw.lock))489489+ return -ERESTARTSYS;490490+ if (card->fw.up) {491491+ mutex_unlock(&card->fw.lock);492492+ return 0;493493+ }494494+ /* reset board */495495+ if (card->pdat->enable_irq)496496+ card->pdat->enable_irq(card->pdev, 1);497497+ /* boot card */498498+ softing_set_reset_dpram(card);499499+ if (card->pdat->reset)500500+ card->pdat->reset(card->pdev, 1);501501+ for (j = 0; (j + sizeof(stream)) < card->dpram_size;502502+ j += sizeof(stream)) {503503+504504+ memcpy_toio(&card->dpram[j], stream, sizeof(stream));505505+ /* flush IO cache */506506+ mb();507507+ memcpy_fromio(back, &card->dpram[j], sizeof(stream));508508+509509+ if (!memcmp(back, stream, sizeof(stream)))510510+ continue;511511+ /* memory is not equal */512512+ dev_alert(&card->pdev->dev, "dpram failed at 0x%04x\n", j);513513+ ret = -EIO;514514+ goto failed;515515+ }516516+ wmb();517517+ /* load boot firmware */518518+ ret = softing_load_fw(card->pdat->boot.fw, card, card->dpram,519519+ card->dpram_size,520520+ card->pdat->boot.offs - card->pdat->boot.addr);521521+ if (ret < 0)522522+ goto failed;523523+ /* load loader firmware */524524+ ret = softing_load_fw(card->pdat->load.fw, card, card->dpram,525525+ card->dpram_size,526526+ card->pdat->load.offs - card->pdat->load.addr);527527+ if (ret < 0)528528+ goto failed;529529+530530+ if (card->pdat->reset)531531+ card->pdat->reset(card->pdev, 0);532532+ softing_clr_reset_dpram(card);533533+ ret = softing_bootloader_command(card, 0, "card boot");534534+ if (ret < 0)535535+ goto failed;536536+ ret = softing_load_app_fw(card->pdat->app.fw, card);537537+ if (ret < 0)538538+ goto failed;539539+540540+ ret = softing_chip_poweron(card);541541+ if (ret < 0)542542+ goto failed;543543+544544+ card->fw.up = 1;545545+ mutex_unlock(&card->fw.lock);546546+ return 0;547547+failed:548548+ card->fw.up = 0;549549+ if (card->pdat->enable_irq)550550+ card->pdat->enable_irq(card->pdev, 0);551551+ softing_set_reset_dpram(card);552552+ if (card->pdat->reset)553553+ card->pdat->reset(card->pdev, 1);554554+ mutex_unlock(&card->fw.lock);555555+ return ret;556556+}557557+558558+/*559559+ * netdev sysfs560560+ */561561+static ssize_t show_channel(struct device *dev, struct device_attribute *attr,562562+ char *buf)563563+{564564+ struct net_device *ndev = to_net_dev(dev);565565+ struct softing_priv *priv = netdev2softing(ndev);566566+567567+ return sprintf(buf, "%i\n", priv->index);568568+}569569+570570+static ssize_t show_chip(struct device *dev, struct device_attribute *attr,571571+ char *buf)572572+{573573+ struct net_device *ndev = to_net_dev(dev);574574+ struct softing_priv *priv = netdev2softing(ndev);575575+576576+ return sprintf(buf, "%i\n", priv->chip);577577+}578578+579579+static ssize_t show_output(struct device *dev, struct device_attribute *attr,580580+ char *buf)581581+{582582+ struct net_device *ndev = to_net_dev(dev);583583+ struct softing_priv *priv = netdev2softing(ndev);584584+585585+ return sprintf(buf, "0x%02x\n", priv->output);586586+}587587+588588+static ssize_t store_output(struct device *dev, struct device_attribute *attr,589589+ const char *buf, size_t count)590590+{591591+ struct net_device *ndev = to_net_dev(dev);592592+ struct softing_priv *priv = netdev2softing(ndev);593593+ struct softing *card = priv->card;594594+ unsigned long val;595595+ int ret;596596+597597+ ret = strict_strtoul(buf, 0, &val);598598+ if (ret < 0)599599+ return ret;600600+ val &= 0xFF;601601+602602+ ret = mutex_lock_interruptible(&card->fw.lock);603603+ if (ret)604604+ return -ERESTARTSYS;605605+ if (netif_running(ndev)) {606606+ mutex_unlock(&card->fw.lock);607607+ return -EBUSY;608608+ }609609+ priv->output = val;610610+ mutex_unlock(&card->fw.lock);611611+ return count;612612+}613613+614614+static const DEVICE_ATTR(channel, S_IRUGO, show_channel, NULL);615615+static const DEVICE_ATTR(chip, S_IRUGO, show_chip, NULL);616616+static const DEVICE_ATTR(output, S_IRUGO | S_IWUSR, show_output, store_output);617617+618618+static const struct attribute *const netdev_sysfs_attrs[] = {619619+ &dev_attr_channel.attr,620620+ &dev_attr_chip.attr,621621+ &dev_attr_output.attr,622622+ NULL,623623+};624624+static const struct attribute_group netdev_sysfs_group = {625625+ .name = NULL,626626+ .attrs = (struct attribute **)netdev_sysfs_attrs,627627+};628628+629629+static const struct net_device_ops softing_netdev_ops = {630630+ .ndo_open = softing_netdev_open,631631+ .ndo_stop = softing_netdev_stop,632632+ .ndo_start_xmit = softing_netdev_start_xmit,633633+};634634+635635+static const struct can_bittiming_const softing_btr_const = {636636+ .tseg1_min = 1,637637+ .tseg1_max = 16,638638+ .tseg2_min = 1,639639+ .tseg2_max = 8,640640+ .sjw_max = 4, /* overruled */641641+ .brp_min = 1,642642+ .brp_max = 32, /* overruled */643643+ .brp_inc = 1,644644+};645645+646646+647647+static __devinit struct net_device *softing_netdev_create(struct softing *card,648648+ uint16_t chip_id)649649+{650650+ struct net_device *netdev;651651+ struct softing_priv *priv;652652+653653+ netdev = alloc_candev(sizeof(*priv), TX_ECHO_SKB_MAX);654654+ if (!netdev) {655655+ dev_alert(&card->pdev->dev, "alloc_candev failed\n");656656+ return NULL;657657+ }658658+ priv = netdev_priv(netdev);659659+ priv->netdev = netdev;660660+ priv->card = card;661661+ memcpy(&priv->btr_const, &softing_btr_const, sizeof(priv->btr_const));662662+ priv->btr_const.brp_max = card->pdat->max_brp;663663+ priv->btr_const.sjw_max = card->pdat->max_sjw;664664+ priv->can.bittiming_const = &priv->btr_const;665665+ priv->can.clock.freq = 8000000;666666+ priv->chip = chip_id;667667+ priv->output = softing_default_output(netdev);668668+ SET_NETDEV_DEV(netdev, &card->pdev->dev);669669+670670+ netdev->flags |= IFF_ECHO;671671+ netdev->netdev_ops = &softing_netdev_ops;672672+ priv->can.do_set_mode = softing_candev_set_mode;673673+ priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;674674+675675+ return netdev;676676+}677677+678678+static __devinit int softing_netdev_register(struct net_device *netdev)679679+{680680+ int ret;681681+682682+ netdev->sysfs_groups[0] = &netdev_sysfs_group;683683+ ret = register_candev(netdev);684684+ if (ret) {685685+ dev_alert(&netdev->dev, "register failed\n");686686+ return ret;687687+ }688688+ return 0;689689+}690690+691691+static void softing_netdev_cleanup(struct net_device *netdev)692692+{693693+ unregister_candev(netdev);694694+ free_candev(netdev);695695+}696696+697697+/*698698+ * sysfs for Platform device699699+ */700700+#define DEV_ATTR_RO(name, member) \701701+static ssize_t show_##name(struct device *dev, \702702+ struct device_attribute *attr, char *buf) \703703+{ \704704+ struct softing *card = platform_get_drvdata(to_platform_device(dev)); \705705+ return sprintf(buf, "%u\n", card->member); \706706+} \707707+static DEVICE_ATTR(name, 0444, show_##name, NULL)708708+709709+#define DEV_ATTR_RO_STR(name, member) \710710+static ssize_t show_##name(struct device *dev, \711711+ struct device_attribute *attr, char *buf) \712712+{ \713713+ struct softing *card = platform_get_drvdata(to_platform_device(dev)); \714714+ return sprintf(buf, "%s\n", card->member); \715715+} \716716+static DEVICE_ATTR(name, 0444, show_##name, NULL)717717+718718+DEV_ATTR_RO(serial, id.serial);719719+DEV_ATTR_RO_STR(firmware, pdat->app.fw);720720+DEV_ATTR_RO(firmware_version, id.fw_version);721721+DEV_ATTR_RO_STR(hardware, pdat->name);722722+DEV_ATTR_RO(hardware_version, id.hw_version);723723+DEV_ATTR_RO(license, id.license);724724+DEV_ATTR_RO(frequency, id.freq);725725+DEV_ATTR_RO(txpending, tx.pending);726726+727727+static struct attribute *softing_pdev_attrs[] = {728728+ &dev_attr_serial.attr,729729+ &dev_attr_firmware.attr,730730+ &dev_attr_firmware_version.attr,731731+ &dev_attr_hardware.attr,732732+ &dev_attr_hardware_version.attr,733733+ &dev_attr_license.attr,734734+ &dev_attr_frequency.attr,735735+ &dev_attr_txpending.attr,736736+ NULL,737737+};738738+739739+static const struct attribute_group softing_pdev_group = {740740+ .name = NULL,741741+ .attrs = softing_pdev_attrs,742742+};743743+744744+/*745745+ * platform driver746746+ */747747+static __devexit int softing_pdev_remove(struct platform_device *pdev)748748+{749749+ struct softing *card = platform_get_drvdata(pdev);750750+ int j;751751+752752+ /* first, disable card*/753753+ softing_card_shutdown(card);754754+755755+ for (j = 0; j < ARRAY_SIZE(card->net); ++j) {756756+ if (!card->net[j])757757+ continue;758758+ softing_netdev_cleanup(card->net[j]);759759+ card->net[j] = NULL;760760+ }761761+ sysfs_remove_group(&pdev->dev.kobj, &softing_pdev_group);762762+763763+ iounmap(card->dpram);764764+ kfree(card);765765+ return 0;766766+}767767+768768+static __devinit int softing_pdev_probe(struct platform_device *pdev)769769+{770770+ const struct softing_platform_data *pdat = pdev->dev.platform_data;771771+ struct softing *card;772772+ struct net_device *netdev;773773+ struct softing_priv *priv;774774+ struct resource *pres;775775+ int ret;776776+ int j;777777+778778+ if (!pdat) {779779+ dev_warn(&pdev->dev, "no platform data\n");780780+ return -EINVAL;781781+ }782782+ if (pdat->nbus > ARRAY_SIZE(card->net)) {783783+ dev_warn(&pdev->dev, "%u nets??\n", pdat->nbus);784784+ return -EINVAL;785785+ }786786+787787+ card = kzalloc(sizeof(*card), GFP_KERNEL);788788+ if (!card)789789+ return -ENOMEM;790790+ card->pdat = pdat;791791+ card->pdev = pdev;792792+ platform_set_drvdata(pdev, card);793793+ mutex_init(&card->fw.lock);794794+ spin_lock_init(&card->spin);795795+796796+ ret = -EINVAL;797797+ pres = platform_get_resource(pdev, IORESOURCE_MEM, 0);798798+ if (!pres)799799+ goto platform_resource_failed;;800800+ card->dpram_phys = pres->start;801801+ card->dpram_size = pres->end - pres->start + 1;802802+ card->dpram = ioremap_nocache(card->dpram_phys, card->dpram_size);803803+ if (!card->dpram) {804804+ dev_alert(&card->pdev->dev, "dpram ioremap failed\n");805805+ goto ioremap_failed;806806+ }807807+808808+ pres = platform_get_resource(pdev, IORESOURCE_IRQ, 0);809809+ if (pres)810810+ card->irq.nr = pres->start;811811+812812+ /* reset card */813813+ ret = softing_card_boot(card);814814+ if (ret < 0) {815815+ dev_alert(&pdev->dev, "failed to boot\n");816816+ goto boot_failed;817817+ }818818+819819+ /* only now, the chip's are known */820820+ card->id.freq = card->pdat->freq;821821+822822+ ret = sysfs_create_group(&pdev->dev.kobj, &softing_pdev_group);823823+ if (ret < 0) {824824+ dev_alert(&card->pdev->dev, "sysfs failed\n");825825+ goto sysfs_failed;826826+ }827827+828828+ ret = -ENOMEM;829829+ for (j = 0; j < ARRAY_SIZE(card->net); ++j) {830830+ card->net[j] = netdev =831831+ softing_netdev_create(card, card->id.chip[j]);832832+ if (!netdev) {833833+ dev_alert(&pdev->dev, "failed to make can[%i]", j);834834+ goto netdev_failed;835835+ }836836+ priv = netdev_priv(card->net[j]);837837+ priv->index = j;838838+ ret = softing_netdev_register(netdev);839839+ if (ret) {840840+ free_candev(netdev);841841+ card->net[j] = NULL;842842+ dev_alert(&card->pdev->dev,843843+ "failed to register can[%i]\n", j);844844+ goto netdev_failed;845845+ }846846+ }847847+ dev_info(&card->pdev->dev, "%s ready.\n", card->pdat->name);848848+ return 0;849849+850850+netdev_failed:851851+ for (j = 0; j < ARRAY_SIZE(card->net); ++j) {852852+ if (!card->net[j])853853+ continue;854854+ softing_netdev_cleanup(card->net[j]);855855+ }856856+ sysfs_remove_group(&pdev->dev.kobj, &softing_pdev_group);857857+sysfs_failed:858858+ softing_card_shutdown(card);859859+boot_failed:860860+ iounmap(card->dpram);861861+ioremap_failed:862862+platform_resource_failed:863863+ kfree(card);864864+ return ret;865865+}866866+867867+static struct platform_driver softing_driver = {868868+ .driver = {869869+ .name = "softing",870870+ .owner = THIS_MODULE,871871+ },872872+ .probe = softing_pdev_probe,873873+ .remove = __devexit_p(softing_pdev_remove),874874+};875875+876876+MODULE_ALIAS("platform:softing");877877+878878+static int __init softing_start(void)879879+{880880+ return platform_driver_register(&softing_driver);881881+}882882+883883+static void __exit softing_stop(void)884884+{885885+ platform_driver_unregister(&softing_driver);886886+}887887+888888+module_init(softing_start);889889+module_exit(softing_stop);890890+891891+MODULE_DESCRIPTION("Softing DPRAM CAN driver");892892+MODULE_AUTHOR("Kurt Van Dijck <kurt.van.dijck@eia.be>");893893+MODULE_LICENSE("GPL v2");
+40
drivers/net/can/softing/softing_platform.h
···11+22+#include <linux/platform_device.h>33+44+#ifndef _SOFTING_DEVICE_H_55+#define _SOFTING_DEVICE_H_66+77+/* softing firmware directory prefix */88+#define fw_dir "softing-4.6/"99+1010+struct softing_platform_data {1111+ unsigned int manf;1212+ unsigned int prod;1313+ /*1414+ * generation1515+ * 1st with NEC or SJA10001616+ * 8bit, exclusive interrupt, ...1717+ * 2nd only SJA10001818+ * 16bit, shared interrupt1919+ */2020+ int generation;2121+ int nbus; /* # busses on device */2222+ unsigned int freq; /* operating frequency in Hz */2323+ unsigned int max_brp;2424+ unsigned int max_sjw;2525+ unsigned long dpram_size;2626+ const char *name;2727+ struct {2828+ unsigned long offs;2929+ unsigned long addr;3030+ const char *fw;3131+ } boot, load, app;3232+ /*3333+ * reset() function3434+ * bring pdev in or out of reset, depending on value3535+ */3636+ int (*reset)(struct platform_device *pdev, int value);3737+ int (*enable_irq)(struct platform_device *pdev, int value);3838+};3939+4040+#endif
+6-6
drivers/net/cnic.c
···699699static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma)700700{701701 int i;702702- u32 *page_table = dma->pgtbl;702702+ __le32 *page_table = (__le32 *) dma->pgtbl;703703704704 for (i = 0; i < dma->num_pages; i++) {705705 /* Each entry needs to be in big endian format. */706706- *page_table = (u32) ((u64) dma->pg_map_arr[i] >> 32);706706+ *page_table = cpu_to_le32((u64) dma->pg_map_arr[i] >> 32);707707 page_table++;708708- *page_table = (u32) dma->pg_map_arr[i];708708+ *page_table = cpu_to_le32(dma->pg_map_arr[i] & 0xffffffff);709709 page_table++;710710 }711711}···713713static void cnic_setup_page_tbl_le(struct cnic_dev *dev, struct cnic_dma *dma)714714{715715 int i;716716- u32 *page_table = dma->pgtbl;716716+ __le32 *page_table = (__le32 *) dma->pgtbl;717717718718 for (i = 0; i < dma->num_pages; i++) {719719 /* Each entry needs to be in little endian format. */720720- *page_table = dma->pg_map_arr[i] & 0xffffffff;720720+ *page_table = cpu_to_le32(dma->pg_map_arr[i] & 0xffffffff);721721 page_table++;722722- *page_table = (u32) ((u64) dma->pg_map_arr[i] >> 32);722722+ *page_table = cpu_to_le32((u64) dma->pg_map_arr[i] >> 32);723723 page_table++;724724 }725725}
···332332 unsigned long flags;333333334334 len = strlen(buf);335335- if (len > 0 || len < 3) {335335+ if (len > 0 && len < 3) {336336 ch = buf[0];337337 if (ch == '\n')338338 ch = '0';
···7272/*7373 * ======== io_mbox_msg ========7474 * Purpose:7575- * Main interrupt handler for the shared memory Bridge channel manager.7676- * Calls the Bridge's chnlsm_isr to determine if this interrupt is ours,7777- * then schedules a DPC to dispatch I/O.7575+ * Main message handler for the shared memory Bridge channel manager.7676+ * Determine if this message is ours, then schedules a DPC to7777+ * dispatch I/O.7878 * Parameters:7979- * ref_data: Pointer to the channel manager object for this board.8080- * Set in an initial call to ISR_Install().7979+ * self: Pointer to its own notifier_block struct.8080+ * len: Length of message.8181+ * msg: Message code received.8182 * Returns:8282- * TRUE if interrupt handled; FALSE otherwise.8383- * Requires:8484- * Must be in locked memory if executing in kernel mode.8585- * Must only call functions which are in locked memory if Kernel mode.8686- * Must only call asynchronous services.8787- * Interrupts are disabled and EOI for this interrupt has been sent.8888- * Ensures:8383+ * NOTIFY_OK if handled; NOTIFY_BAD otherwise.8984 */9090-void io_mbox_msg(u32 msg);8585+int io_mbox_msg(struct notifier_block *self, unsigned long len, void *msg);91869287/*9388 * ======== io_request_chnl ========
···100100 * But, the index of this array begins from 0.101101 */102102 struct vhci_device vdev[VHCI_NPORTS];103103-104104- /* vhci_device which has not been assiged its address yet */105105- int pending_port;106103};107104108105···115118void rh_port_disconnect(int rhport);116119void vhci_rx_loop(struct usbip_task *ut);117120void vhci_tx_loop(struct usbip_task *ut);121121+122122+struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,123123+ __u32 seqnum);118124119125#define hardware (&the_controller->pdev.dev)120126
+46-8
drivers/staging/usbip/vhci_hcd.c
···138138 * the_controller->vdev[rhport].ud.status = VDEV_CONNECT;139139 * spin_unlock(&the_controller->vdev[rhport].ud.lock); */140140141141- the_controller->pending_port = rhport;142142-143141 spin_unlock_irqrestore(&the_controller->lock, flags);144142145143 usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));···557559 struct device *dev = &urb->dev->dev;558560 int ret = 0;559561 unsigned long flags;562562+ struct vhci_device *vdev;560563561564 usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n",562565 hcd, urb, mem_flags);···572573 spin_unlock_irqrestore(&the_controller->lock, flags);573574 return urb->status;574575 }576576+577577+ vdev = port_to_vdev(urb->dev->portnum-1);578578+579579+ /* refuse enqueue for dead connection */580580+ spin_lock(&vdev->ud.lock);581581+ if (vdev->ud.status == VDEV_ST_NULL || vdev->ud.status == VDEV_ST_ERROR) {582582+ usbip_uerr("enqueue for inactive port %d\n", vdev->rhport);583583+ spin_unlock(&vdev->ud.lock);584584+ spin_unlock_irqrestore(&the_controller->lock, flags);585585+ return -ENODEV;586586+ }587587+ spin_unlock(&vdev->ud.lock);575588576589 ret = usb_hcd_link_urb_to_ep(hcd, urb);577590 if (ret)···603592 __u8 type = usb_pipetype(urb->pipe);604593 struct usb_ctrlrequest *ctrlreq =605594 (struct usb_ctrlrequest *) urb->setup_packet;606606- struct vhci_device *vdev =607607- port_to_vdev(the_controller->pending_port);608595609596 if (type != PIPE_CONTROL || !ctrlreq) {610597 dev_err(dev, "invalid request to devnum 0\n");···616607 dev_info(dev, "SetAddress Request (%d) to port %d\n",617608 ctrlreq->wValue, vdev->rhport);618609619619- vdev->udev = urb->dev;610610+ if (vdev->udev)611611+ usb_put_dev(vdev->udev);612612+ vdev->udev = usb_get_dev(urb->dev);620613621614 spin_lock(&vdev->ud.lock);622615 vdev->ud.status = VDEV_ST_USED;···638627 "Get_Descriptor to device 0 "639628 "(get max pipe size)\n");640629641641- /* FIXME: reference count? (usb_get_dev()) */642642- vdev->udev = urb->dev;630630+ if (vdev->udev)631631+ usb_put_dev(vdev->udev);632632+ vdev->udev = usb_get_dev(urb->dev);643633 goto out;644634645635 default:···817805 return 0;818806}819807820820-821808static void vhci_device_unlink_cleanup(struct vhci_device *vdev)822809{823810 struct vhci_unlink *unlink, *tmp;···824813 spin_lock(&vdev->priv_lock);825814826815 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {816816+ usbip_uinfo("unlink cleanup tx %lu\n", unlink->unlink_seqnum);827817 list_del(&unlink->list);828818 kfree(unlink);829819 }830820831821 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) {822822+ struct urb *urb;823823+824824+ /* give back URB of unanswered unlink request */825825+ usbip_uinfo("unlink cleanup rx %lu\n", unlink->unlink_seqnum);826826+827827+ urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);828828+ if (!urb) {829829+ usbip_uinfo("the urb (seqnum %lu) was already given back\n",830830+ unlink->unlink_seqnum);831831+ list_del(&unlink->list);832832+ kfree(unlink);833833+ continue;834834+ }835835+836836+ urb->status = -ENODEV;837837+838838+ spin_lock(&the_controller->lock);839839+ usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);840840+ spin_unlock(&the_controller->lock);841841+842842+ usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);843843+832844 list_del(&unlink->list);833845 kfree(unlink);834846 }···920886921887 vdev->speed = 0;922888 vdev->devid = 0;889889+890890+ if (vdev->udev)891891+ usb_put_dev(vdev->udev);892892+ vdev->udev = NULL;923893924894 ud->tcp_socket = NULL;925895
+42-8
drivers/staging/usbip/vhci_rx.c
···2323#include "vhci.h"242425252626-/* get URB from transmitted urb queue */2727-static struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,2626+/* get URB from transmitted urb queue. caller must hold vdev->priv_lock */2727+struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,2828 __u32 seqnum)2929{3030 struct vhci_priv *priv, *tmp;3131 struct urb *urb = NULL;3232 int status;3333-3434- spin_lock(&vdev->priv_lock);35333634 list_for_each_entry_safe(priv, tmp, &vdev->priv_rx, list) {3735 if (priv->seqnum == seqnum) {···6163 }6264 }63656464- spin_unlock(&vdev->priv_lock);6565-6666 return urb;6767}6868···7074 struct usbip_device *ud = &vdev->ud;7175 struct urb *urb;72767777+ spin_lock(&vdev->priv_lock);73787479 urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum);75808181+ spin_unlock(&vdev->priv_lock);76827783 if (!urb) {7884 usbip_uerr("cannot find a urb of seqnum %u\n",···159161 return;160162 }161163164164+ spin_lock(&vdev->priv_lock);165165+162166 urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);167167+168168+ spin_unlock(&vdev->priv_lock);169169+163170 if (!urb) {164171 /*165172 * I get the result of a unlink request. But, it seems that I···193190 return;194191}195192193193+static int vhci_priv_tx_empty(struct vhci_device *vdev)194194+{195195+ int empty = 0;196196+197197+ spin_lock(&vdev->priv_lock);198198+199199+ empty = list_empty(&vdev->priv_rx);200200+201201+ spin_unlock(&vdev->priv_lock);202202+203203+ return empty;204204+}205205+196206/* recv a pdu */197207static void vhci_rx_pdu(struct usbip_device *ud)198208{···218202219203 memset(&pdu, 0, sizeof(pdu));220204221221-222205 /* 1. receive a pdu header */223206 ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0);207207+ if (ret < 0) {208208+ if (ret == -ECONNRESET)209209+ usbip_uinfo("connection reset by peer\n");210210+ else if (ret == -EAGAIN) {211211+ /* ignore if connection was idle */212212+ if (vhci_priv_tx_empty(vdev))213213+ return;214214+ usbip_uinfo("connection timed out with pending urbs\n");215215+ } else if (ret != -ERESTARTSYS)216216+ usbip_uinfo("xmit failed %d\n", ret);217217+218218+ usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);219219+ return;220220+ }221221+ if (ret == 0) {222222+ usbip_uinfo("connection closed");223223+ usbip_event_add(ud, VDEV_EVENT_DOWN);224224+ return;225225+ }224226 if (ret != sizeof(pdu)) {225225- usbip_uerr("receiving pdu failed! size is %d, should be %d\n",227227+ usbip_uerr("received pdu size is %d, should be %d\n",226228 ret, (unsigned int)sizeof(pdu));227229 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);228230 return;
···581581 __u8 __user *buf, size_t nr)582582{583583 struct n_hdlc *n_hdlc = tty2n_hdlc(tty);584584- int ret;584584+ int ret = 0;585585 struct n_hdlc_buf *rbuf;586586+ DECLARE_WAITQUEUE(wait, current);586587587588 if (debuglevel >= DEBUG_LEVEL_INFO) 588589 printk("%s(%d)n_hdlc_tty_read() called\n",__FILE__,__LINE__);···599598 return -EFAULT;600599 }601600602602- tty_lock();601601+ add_wait_queue(&tty->read_wait, &wait);603602604603 for (;;) {605604 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {606606- tty_unlock();607607- return -EIO;605605+ ret = -EIO;606606+ break;608607 }608608+ if (tty_hung_up_p(file))609609+ break;609610610610- n_hdlc = tty2n_hdlc (tty);611611- if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC ||612612- tty != n_hdlc->tty) {613613- tty_unlock();614614- return 0;615615- }611611+ set_current_state(TASK_INTERRUPTIBLE);616612617613 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list);618618- if (rbuf)614614+ if (rbuf) {615615+ if (rbuf->count > nr) {616616+ /* too large for caller's buffer */617617+ ret = -EOVERFLOW;618618+ } else {619619+ if (copy_to_user(buf, rbuf->buf, rbuf->count))620620+ ret = -EFAULT;621621+ else622622+ ret = rbuf->count;623623+ }624624+625625+ if (n_hdlc->rx_free_buf_list.count >626626+ DEFAULT_RX_BUF_COUNT)627627+ kfree(rbuf);628628+ else629629+ n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, rbuf);619630 break;631631+ }620632621633 /* no data */622634 if (file->f_flags & O_NONBLOCK) {623623- tty_unlock();624624- return -EAGAIN;635635+ ret = -EAGAIN;636636+ break;625637 }626626-627627- interruptible_sleep_on (&tty->read_wait);638638+639639+ schedule();640640+628641 if (signal_pending(current)) {629629- tty_unlock();630630- return -EINTR;642642+ ret = -EINTR;643643+ break;631644 }632645 }633633-634634- if (rbuf->count > nr)635635- /* frame too large for caller's buffer (discard frame) */636636- ret = -EOVERFLOW;637637- else {638638- /* Copy the data to the caller's buffer */639639- if (copy_to_user(buf, rbuf->buf, rbuf->count))640640- ret = -EFAULT;641641- else642642- ret = rbuf->count;643643- }644644-645645- /* return HDLC buffer to free list unless the free list */646646- /* count has exceeded the default value, in which case the */647647- /* buffer is freed back to the OS to conserve memory */648648- if (n_hdlc->rx_free_buf_list.count > DEFAULT_RX_BUF_COUNT)649649- kfree(rbuf);650650- else 651651- n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf);652652- tty_unlock();646646+647647+ remove_wait_queue(&tty->read_wait, &wait);648648+ __set_current_state(TASK_RUNNING);649649+653650 return ret;654651655652} /* end of n_hdlc_tty_read() */···690691 count = maxframe;691692 }692693693693- tty_lock();694694-695694 add_wait_queue(&tty->write_wait, &wait);696696- set_current_state(TASK_INTERRUPTIBLE);695695+696696+ for (;;) {697697+ set_current_state(TASK_INTERRUPTIBLE);697698698698- /* Allocate transmit buffer */699699- /* sleep until transmit buffer available */ 700700- while (!(tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list))) {699699+ tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list);700700+ if (tbuf)701701+ break;702702+701703 if (file->f_flags & O_NONBLOCK) {702704 error = -EAGAIN;703705 break;···719719 }720720 }721721722722- set_current_state(TASK_RUNNING);722722+ __set_current_state(TASK_RUNNING);723723 remove_wait_queue(&tty->write_wait, &wait);724724725725 if (!error) { ···731731 n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);732732 n_hdlc_send_frames(n_hdlc,tty);733733 }734734- tty_unlock();734734+735735 return error;736736737737} /* end of n_hdlc_tty_write() */
···15181518config SERIAL_GRLIB_GAISLER_APBUART15191519 tristate "GRLIB APBUART serial support"15201520 depends on OF15211521+ select SERIAL_CORE15211522 ---help---15221523 Add support for the GRLIB APBUART serial port.15231524
+2-2
drivers/tty/tty_io.c
···32573257 ssize_t count = 0;3258325832593259 console_lock();32603260- for (c = console_drivers; c; c = c->next) {32603260+ for_each_console(c) {32613261 if (!c->device)32623262 continue;32633263 if (!c->write)···33063306 if (IS_ERR(consdev))33073307 consdev = NULL;33083308 else33093309- device_create_file(consdev, &dev_attr_active);33093309+ WARN_ON(device_create_file(consdev, &dev_attr_active) < 0);3310331033113311#ifdef CONFIG_VT33123312 vty_init(&console_fops);
+8-3
drivers/tty/vt/vt.c
···29942994 if (IS_ERR(tty0dev))29952995 tty0dev = NULL;29962996 else29972997- device_create_file(tty0dev, &dev_attr_active);29972997+ WARN_ON(device_create_file(tty0dev, &dev_attr_active) < 0);2998299829992999 vcs_init();30003000···3545354535463546 /* already registered */35473547 if (con_driver->con == csw)35483548- retval = -EINVAL;35483548+ retval = -EBUSY;35493549 }3550355035513551 if (retval)···36563656 int err;3657365736583658 err = register_con_driver(csw, first, last);36593659-36593659+ /* if we get an busy error we still want to bind the console driver36603660+ * and return success, as we may have unbound the console driver36613661+ * but not unregistered it.36623662+ */36633663+ if (err == -EBUSY)36643664+ err = 0;36603665 if (!err)36613666 bind_con_driver(csw, first, last, deflt);36623667
+1-1
drivers/usb/class/cdc-wdm.c
···342342 goto outnp;343343 }344344345345- if (!file->f_flags && O_NONBLOCK)345345+ if (!(file->f_flags & O_NONBLOCK))346346 r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE,347347 &desc->flags));348348 else
···405405 return retval;406406 }407407408408- synchronize_irq(pci_dev->irq);408408+ /* If MSI-X is enabled, the driver will have synchronized all vectors409409+ * in pci_suspend(). If MSI or legacy PCI is enabled, that will be410410+ * synchronized here.411411+ */412412+ if (!hcd->msix_enabled)413413+ synchronize_irq(pci_dev->irq);409414410415 /* Downstream ports from this root hub should already be quiesced, so411416 * there will be no DMA activity. Now we can shut down the upstream
+21
drivers/usb/core/hub.c
···676676static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)677677{678678 struct usb_device *hdev = hub->hdev;679679+ struct usb_hcd *hcd;680680+ int ret;679681 int port1;680682 int status;681683 bool need_debounce_delay = false;···716714 usb_autopm_get_interface_no_resume(717715 to_usb_interface(hub->intfdev));718716 return; /* Continues at init2: below */717717+ } else if (type == HUB_RESET_RESUME) {718718+ /* The internal host controller state for the hub device719719+ * may be gone after a host power loss on system resume.720720+ * Update the device's info so the HW knows it's a hub.721721+ */722722+ hcd = bus_to_hcd(hdev->bus);723723+ if (hcd->driver->update_hub_device) {724724+ ret = hcd->driver->update_hub_device(hcd, hdev,725725+ &hub->tt, GFP_NOIO);726726+ if (ret < 0) {727727+ dev_err(hub->intfdev, "Host not "728728+ "accepting hub info "729729+ "update.\n");730730+ dev_err(hub->intfdev, "LS/FS devices "731731+ "and hubs may not work "732732+ "under this hub\n.");733733+ }734734+ }735735+ hub_power_on(hub, true);719736 } else {720737 hub_power_on(hub, true);721738 }
+6-1
drivers/usb/gadget/Kconfig
···509509 select USB_GADGET_SELECTED510510511511config USB_GADGET_EG20T512512- boolean "Intel EG20T(Topcliff) USB Device controller"512512+ boolean "Intel EG20T PCH/OKI SEMICONDUCTOR ML7213 IOH UDC"513513 depends on PCI514514 select USB_GADGET_DUALSPEED515515 help···524524 This driver supports both control transfer and bulk transfer modes.525525 This driver dose not support interrupt transfer or isochronous526526 transfer modes.527527+528528+ This driver also can be used for OKI SEMICONDUCTOR's ML7213 which is529529+ for IVI(In-Vehicle Infotainment) use.530530+ ML7213 is companion chip for Intel Atom E6xx series.531531+ ML7213 is completely compatible for Intel EG20T PCH.527532528533config USB_EG20T529534 tristate
+137-131
drivers/usb/gadget/ci13xxx_udc.c
···76767777/* control endpoint description */7878static const struct usb_endpoint_descriptor7979-ctrl_endpt_desc = {7979+ctrl_endpt_out_desc = {8080 .bLength = USB_DT_ENDPOINT_SIZE,8181 .bDescriptorType = USB_DT_ENDPOINT,82828383+ .bEndpointAddress = USB_DIR_OUT,8484+ .bmAttributes = USB_ENDPOINT_XFER_CONTROL,8585+ .wMaxPacketSize = cpu_to_le16(CTRL_PAYLOAD_MAX),8686+};8787+8888+static const struct usb_endpoint_descriptor8989+ctrl_endpt_in_desc = {9090+ .bLength = USB_DT_ENDPOINT_SIZE,9191+ .bDescriptorType = USB_DT_ENDPOINT,9292+9393+ .bEndpointAddress = USB_DIR_IN,8394 .bmAttributes = USB_ENDPOINT_XFER_CONTROL,8495 .wMaxPacketSize = cpu_to_le16(CTRL_PAYLOAD_MAX),8596};···276265 hw_bank.size /= sizeof(u32);277266278267 reg = hw_aread(ABS_DCCPARAMS, DCCPARAMS_DEN) >> ffs_nr(DCCPARAMS_DEN);279279- if (reg == 0 || reg > ENDPT_MAX)280280- return -ENODEV;268268+ hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */281269282282- hw_ep_max = reg; /* cache hw ENDPT_MAX */270270+ if (hw_ep_max == 0 || hw_ep_max > ENDPT_MAX)271271+ return -ENODEV;283272284273 /* setup lock mode ? */285274···12081197 }1209119812101199 spin_lock_irqsave(udc->lock, flags);12111211- for (i = 0; i < hw_ep_max; i++) {12121212- struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];12001200+ for (i = 0; i < hw_ep_max/2; i++) {12011201+ struct ci13xxx_ep *mEpRx = &udc->ci13xxx_ep[i];12021202+ struct ci13xxx_ep *mEpTx = &udc->ci13xxx_ep[i + hw_ep_max/2];12131203 n += scnprintf(buf + n, PAGE_SIZE - n,12141204 "EP=%02i: RX=%08X TX=%08X\n",12151215- i, (u32)mEp->qh[RX].dma, (u32)mEp->qh[TX].dma);12051205+ i, (u32)mEpRx->qh.dma, (u32)mEpTx->qh.dma);12161206 for (j = 0; j < (sizeof(struct ci13xxx_qh)/sizeof(u32)); j++) {12171207 n += scnprintf(buf + n, PAGE_SIZE - n,12181208 " %04X: %08X %08X\n", j,12191219- *((u32 *)mEp->qh[RX].ptr + j),12201220- *((u32 *)mEp->qh[TX].ptr + j));12091209+ *((u32 *)mEpRx->qh.ptr + j),12101210+ *((u32 *)mEpTx->qh.ptr + j));12211211 }12221212 }12231213 spin_unlock_irqrestore(udc->lock, flags);···13051293 unsigned long flags;13061294 struct list_head *ptr = NULL;13071295 struct ci13xxx_req *req = NULL;13081308- unsigned i, j, k, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32);12961296+ unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32);1309129713101298 dbg_trace("[%s] %p\n", __func__, buf);13111299 if (attr == NULL || buf == NULL) {···1315130313161304 spin_lock_irqsave(udc->lock, flags);13171305 for (i = 0; i < hw_ep_max; i++)13181318- for (k = RX; k <= TX; k++)13191319- list_for_each(ptr, &udc->ci13xxx_ep[i].qh[k].queue)13201320- {13211321- req = list_entry(ptr,13221322- struct ci13xxx_req, queue);13061306+ list_for_each(ptr, &udc->ci13xxx_ep[i].qh.queue)13071307+ {13081308+ req = list_entry(ptr, struct ci13xxx_req, queue);1323130913101310+ n += scnprintf(buf + n, PAGE_SIZE - n,13111311+ "EP=%02i: TD=%08X %s\n",13121312+ i % hw_ep_max/2, (u32)req->dma,13131313+ ((i < hw_ep_max/2) ? "RX" : "TX"));13141314+13151315+ for (j = 0; j < qSize; j++)13241316 n += scnprintf(buf + n, PAGE_SIZE - n,13251325- "EP=%02i: TD=%08X %s\n",13261326- i, (u32)req->dma,13271327- ((k == RX) ? "RX" : "TX"));13281328-13291329- for (j = 0; j < qSize; j++)13301330- n += scnprintf(buf + n, PAGE_SIZE - n,13311331- " %04X: %08X\n", j,13321332- *((u32 *)req->ptr + j));13331333- }13171317+ " %04X: %08X\n", j,13181318+ *((u32 *)req->ptr + j));13191319+ }13341320 spin_unlock_irqrestore(udc->lock, flags);1335132113361322 return n;···14771467 * At this point it's guaranteed exclusive access to qhead14781468 * (endpt is not primed) so it's no need to use tripwire14791469 */14801480- mEp->qh[mEp->dir].ptr->td.next = mReq->dma; /* TERMINATE = 0 */14811481- mEp->qh[mEp->dir].ptr->td.token &= ~TD_STATUS; /* clear status */14701470+ mEp->qh.ptr->td.next = mReq->dma; /* TERMINATE = 0 */14711471+ mEp->qh.ptr->td.token &= ~TD_STATUS; /* clear status */14821472 if (mReq->req.zero == 0)14831483- mEp->qh[mEp->dir].ptr->cap |= QH_ZLT;14731473+ mEp->qh.ptr->cap |= QH_ZLT;14841474 else14851485- mEp->qh[mEp->dir].ptr->cap &= ~QH_ZLT;14751475+ mEp->qh.ptr->cap &= ~QH_ZLT;1486147614871477 wmb(); /* synchronize before ep prime */14881478···1552154215531543 hw_ep_flush(mEp->num, mEp->dir);1554154415551555- while (!list_empty(&mEp->qh[mEp->dir].queue)) {15451545+ while (!list_empty(&mEp->qh.queue)) {1556154615571547 /* pop oldest request */15581548 struct ci13xxx_req *mReq = \15591559- list_entry(mEp->qh[mEp->dir].queue.next,15491549+ list_entry(mEp->qh.queue.next,15601550 struct ci13xxx_req, queue);15611551 list_del_init(&mReq->queue);15621552 mReq->req.status = -ESHUTDOWN;···15811571{15821572 struct usb_ep *ep;15831573 struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget);15841584- struct ci13xxx_ep *mEp = container_of(gadget->ep0,15851585- struct ci13xxx_ep, ep);1586157415871575 trace("%p", gadget);15881576···15911583 gadget_for_each_ep(ep, gadget) {15921584 usb_ep_fifo_flush(ep);15931585 }15941594- usb_ep_fifo_flush(gadget->ep0);15861586+ usb_ep_fifo_flush(&udc->ep0out.ep);15871587+ usb_ep_fifo_flush(&udc->ep0in.ep);1595158815961589 udc->driver->disconnect(gadget);15971590···16001591 gadget_for_each_ep(ep, gadget) {16011592 usb_ep_disable(ep);16021593 }16031603- usb_ep_disable(gadget->ep0);15941594+ usb_ep_disable(&udc->ep0out.ep);15951595+ usb_ep_disable(&udc->ep0in.ep);1604159616051605- if (mEp->status != NULL) {16061606- usb_ep_free_request(gadget->ep0, mEp->status);16071607- mEp->status = NULL;15971597+ if (udc->status != NULL) {15981598+ usb_ep_free_request(&udc->ep0in.ep, udc->status);15991599+ udc->status = NULL;16081600 }1609160116101602 return 0;···16241614__releases(udc->lock)16251615__acquires(udc->lock)16261616{16271627- struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[0];16281617 int retval;1629161816301619 trace("%p", udc);···16441635 if (retval)16451636 goto done;1646163716471647- retval = usb_ep_enable(&mEp->ep, &ctrl_endpt_desc);16381638+ retval = usb_ep_enable(&udc->ep0out.ep, &ctrl_endpt_out_desc);16391639+ if (retval)16401640+ goto done;16411641+16421642+ retval = usb_ep_enable(&udc->ep0in.ep, &ctrl_endpt_in_desc);16481643 if (!retval) {16491649- mEp->status = usb_ep_alloc_request(&mEp->ep, GFP_ATOMIC);16501650- if (mEp->status == NULL) {16511651- usb_ep_disable(&mEp->ep);16441644+ udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC);16451645+ if (udc->status == NULL) {16461646+ usb_ep_disable(&udc->ep0out.ep);16521647 retval = -ENOMEM;16531648 }16541649 }···1685167216861673/**16871674 * isr_get_status_response: get_status request response16881688- * @ep: endpoint16751675+ * @udc: udc struct16891676 * @setup: setup request packet16901677 *16911678 * This function returns an error code16921679 */16931693-static int isr_get_status_response(struct ci13xxx_ep *mEp,16801680+static int isr_get_status_response(struct ci13xxx *udc,16941681 struct usb_ctrlrequest *setup)16951682__releases(mEp->lock)16961683__acquires(mEp->lock)16971684{16851685+ struct ci13xxx_ep *mEp = &udc->ep0in;16981686 struct usb_request *req = NULL;16991687 gfp_t gfp_flags = GFP_ATOMIC;17001688 int dir, num, retval;···1750173617511737/**17521738 * isr_setup_status_phase: queues the status phase of a setup transation17531753- * @mEp: endpoint17391739+ * @udc: udc struct17541740 *17551741 * This function returns an error code17561742 */17571757-static int isr_setup_status_phase(struct ci13xxx_ep *mEp)17431743+static int isr_setup_status_phase(struct ci13xxx *udc)17581744__releases(mEp->lock)17591745__acquires(mEp->lock)17601746{17611747 int retval;17481748+ struct ci13xxx_ep *mEp;1762174917631763- trace("%p", mEp);17501750+ trace("%p", udc);1764175117651765- /* mEp is always valid & configured */17661766-17671767- if (mEp->type == USB_ENDPOINT_XFER_CONTROL)17681768- mEp->dir = (mEp->dir == TX) ? RX : TX;17691769-17701770- mEp->status->no_interrupt = 1;17521752+ mEp = (udc->ep0_dir == TX) ? &udc->ep0out : &udc->ep0in;1771175317721754 spin_unlock(mEp->lock);17731773- retval = usb_ep_queue(&mEp->ep, mEp->status, GFP_ATOMIC);17551755+ retval = usb_ep_queue(&mEp->ep, udc->status, GFP_ATOMIC);17741756 spin_lock(mEp->lock);1775175717761758 return retval;···1788177817891779 trace("%p", mEp);1790178017911791- if (list_empty(&mEp->qh[mEp->dir].queue))17811781+ if (list_empty(&mEp->qh.queue))17921782 return -EINVAL;1793178317941784 /* pop oldest request */17951795- mReq = list_entry(mEp->qh[mEp->dir].queue.next,17851785+ mReq = list_entry(mEp->qh.queue.next,17961786 struct ci13xxx_req, queue);17971787 list_del_init(&mReq->queue);17981788···1804179418051795 dbg_done(_usb_addr(mEp), mReq->ptr->token, retval);1806179618071807- if (!list_empty(&mEp->qh[mEp->dir].queue)) {17971797+ if (!list_empty(&mEp->qh.queue)) {18081798 struct ci13xxx_req* mReqEnq;1809179918101810- mReqEnq = list_entry(mEp->qh[mEp->dir].queue.next,18001800+ mReqEnq = list_entry(mEp->qh.queue.next,18111801 struct ci13xxx_req, queue);18121802 _hardware_enqueue(mEp, mReqEnq);18131803 }···18461836 int type, num, err = -EINVAL;18471837 struct usb_ctrlrequest req;1848183818491849-18501839 if (mEp->desc == NULL)18511840 continue; /* not configured */1852184118531853- if ((mEp->dir == RX && hw_test_and_clear_complete(i)) ||18541854- (mEp->dir == TX && hw_test_and_clear_complete(i + 16))) {18421842+ if (hw_test_and_clear_complete(i)) {18551843 err = isr_tr_complete_low(mEp);18561844 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {18571845 if (err > 0) /* needs status phase */18581858- err = isr_setup_status_phase(mEp);18461846+ err = isr_setup_status_phase(udc);18591847 if (err < 0) {18601848 dbg_event(_usb_addr(mEp),18611849 "ERROR", err);···18741866 continue;18751867 }1876186818691869+ /*18701870+ * Flush data and handshake transactions of previous18711871+ * setup packet.18721872+ */18731873+ _ep_nuke(&udc->ep0out);18741874+ _ep_nuke(&udc->ep0in);18751875+18771876 /* read_setup_packet */18781877 do {18791878 hw_test_and_set_setup_guard();18801880- memcpy(&req, &mEp->qh[RX].ptr->setup, sizeof(req));18791879+ memcpy(&req, &mEp->qh.ptr->setup, sizeof(req));18811880 } while (!hw_test_and_clear_setup_guard());1882188118831882 type = req.bRequestType;1884188318851885- mEp->dir = (type & USB_DIR_IN) ? TX : RX;18841884+ udc->ep0_dir = (type & USB_DIR_IN) ? TX : RX;1886188518871886 dbg_setup(_usb_addr(mEp), &req);18881887···19101895 if (err)19111896 break;19121897 }19131913- err = isr_setup_status_phase(mEp);18981898+ err = isr_setup_status_phase(udc);19141899 break;19151900 case USB_REQ_GET_STATUS:19161901 if (type != (USB_DIR_IN|USB_RECIP_DEVICE) &&···19201905 if (le16_to_cpu(req.wLength) != 2 ||19211906 le16_to_cpu(req.wValue) != 0)19221907 break;19231923- err = isr_get_status_response(mEp, &req);19081908+ err = isr_get_status_response(udc, &req);19241909 break;19251910 case USB_REQ_SET_ADDRESS:19261911 if (type != (USB_DIR_OUT|USB_RECIP_DEVICE))···19311916 err = hw_usb_set_address((u8)le16_to_cpu(req.wValue));19321917 if (err)19331918 break;19341934- err = isr_setup_status_phase(mEp);19191919+ err = isr_setup_status_phase(udc);19351920 break;19361921 case USB_REQ_SET_FEATURE:19371922 if (type != (USB_DIR_OUT|USB_RECIP_ENDPOINT) &&···19471932 spin_lock(udc->lock);19481933 if (err)19491934 break;19501950- err = isr_setup_status_phase(mEp);19351935+ err = isr_setup_status_phase(udc);19511936 break;19521937 default:19531938delegate:19541939 if (req.wLength == 0) /* no data phase */19551955- mEp->dir = TX;19401940+ udc->ep0_dir = TX;1956194119571942 spin_unlock(udc->lock);19581943 err = udc->driver->setup(&udc->gadget, &req);···19831968 const struct usb_endpoint_descriptor *desc)19841969{19851970 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);19861986- int direction, retval = 0;19711971+ int retval = 0;19871972 unsigned long flags;1988197319891974 trace("%p, %p", ep, desc);···1997198219981983 mEp->desc = desc;1999198420002000- if (!list_empty(&mEp->qh[mEp->dir].queue))19851985+ if (!list_empty(&mEp->qh.queue))20011986 warn("enabling a non-empty endpoint!");2002198720031988 mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX;···2006199120071992 mEp->ep.maxpacket = __constant_le16_to_cpu(desc->wMaxPacketSize);2008199320092009- direction = mEp->dir;20102010- do {20112011- dbg_event(_usb_addr(mEp), "ENABLE", 0);19941994+ dbg_event(_usb_addr(mEp), "ENABLE", 0);2012199520132013- mEp->qh[mEp->dir].ptr->cap = 0;19961996+ mEp->qh.ptr->cap = 0;2014199720152015- if (mEp->type == USB_ENDPOINT_XFER_CONTROL)20162016- mEp->qh[mEp->dir].ptr->cap |= QH_IOS;20172017- else if (mEp->type == USB_ENDPOINT_XFER_ISOC)20182018- mEp->qh[mEp->dir].ptr->cap &= ~QH_MULT;20192019- else20202020- mEp->qh[mEp->dir].ptr->cap &= ~QH_ZLT;19981998+ if (mEp->type == USB_ENDPOINT_XFER_CONTROL)19991999+ mEp->qh.ptr->cap |= QH_IOS;20002000+ else if (mEp->type == USB_ENDPOINT_XFER_ISOC)20012001+ mEp->qh.ptr->cap &= ~QH_MULT;20022002+ else20032003+ mEp->qh.ptr->cap &= ~QH_ZLT;2021200420222022- mEp->qh[mEp->dir].ptr->cap |=20232023- (mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;20242024- mEp->qh[mEp->dir].ptr->td.next |= TD_TERMINATE; /* needed? */20052005+ mEp->qh.ptr->cap |=20062006+ (mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;20072007+ mEp->qh.ptr->td.next |= TD_TERMINATE; /* needed? */2025200820262026- retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);20272027-20282028- if (mEp->type == USB_ENDPOINT_XFER_CONTROL)20292029- mEp->dir = (mEp->dir == TX) ? RX : TX;20302030-20312031- } while (mEp->dir != direction);20092009+ retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);2032201020332011 spin_unlock_irqrestore(mEp->lock, flags);20342012 return retval;···21542146 spin_lock_irqsave(mEp->lock, flags);2155214721562148 if (mEp->type == USB_ENDPOINT_XFER_CONTROL &&21572157- !list_empty(&mEp->qh[mEp->dir].queue)) {21492149+ !list_empty(&mEp->qh.queue)) {21582150 _ep_nuke(mEp);21592151 retval = -EOVERFLOW;21602152 warn("endpoint ctrl %X nuked", _usb_addr(mEp));···21782170 /* push request */21792171 mReq->req.status = -EINPROGRESS;21802172 mReq->req.actual = 0;21812181- list_add_tail(&mReq->queue, &mEp->qh[mEp->dir].queue);21732173+ list_add_tail(&mReq->queue, &mEp->qh.queue);2182217421832183- if (list_is_singular(&mEp->qh[mEp->dir].queue))21752175+ if (list_is_singular(&mEp->qh.queue))21842176 retval = _hardware_enqueue(mEp, mReq);2185217721862178 if (retval == -EALREADY) {···22072199 trace("%p, %p", ep, req);2208220022092201 if (ep == NULL || req == NULL || mEp->desc == NULL ||22102210- list_empty(&mReq->queue) || list_empty(&mEp->qh[mEp->dir].queue))22022202+ list_empty(&mReq->queue) || list_empty(&mEp->qh.queue))22112203 return -EINVAL;2212220422132205 spin_lock_irqsave(mEp->lock, flags);···22522244#ifndef STALL_IN22532245 /* g_file_storage MS compliant but g_zero fails chapter 9 compliance */22542246 if (value && mEp->type == USB_ENDPOINT_XFER_BULK && mEp->dir == TX &&22552255- !list_empty(&mEp->qh[mEp->dir].queue)) {22472247+ !list_empty(&mEp->qh.queue)) {22562248 spin_unlock_irqrestore(mEp->lock, flags);22572249 return -EAGAIN;22582250 }···23632355 if (is_active) {23642356 pm_runtime_get_sync(&_gadget->dev);23652357 hw_device_reset(udc);23662366- hw_device_state(udc->ci13xxx_ep[0].qh[RX].dma);23582358+ hw_device_state(udc->ep0out.qh.dma);23672359 } else {23682360 hw_device_state(0);23692361 if (udc->udc_driver->notify_event)···23982390 int (*bind)(struct usb_gadget *))23992391{24002392 struct ci13xxx *udc = _udc;24012401- unsigned long i, k, flags;23932393+ unsigned long flags;23942394+ int i, j;24022395 int retval = -ENOMEM;2403239624042397 trace("%p", driver);···2436242724372428 info("hw_ep_max = %d", hw_ep_max);2438242924392439- udc->driver = driver;24402430 udc->gadget.dev.driver = NULL;2441243124422432 retval = 0;24432443- for (i = 0; i < hw_ep_max; i++) {24442444- struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];24332433+ for (i = 0; i < hw_ep_max/2; i++) {24342434+ for (j = RX; j <= TX; j++) {24352435+ int k = i + j * hw_ep_max/2;24362436+ struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[k];2445243724462446- scnprintf(mEp->name, sizeof(mEp->name), "ep%i", (int)i);24382438+ scnprintf(mEp->name, sizeof(mEp->name), "ep%i%s", i,24392439+ (j == TX) ? "in" : "out");2447244024482448- mEp->lock = udc->lock;24492449- mEp->device = &udc->gadget.dev;24502450- mEp->td_pool = udc->td_pool;24412441+ mEp->lock = udc->lock;24422442+ mEp->device = &udc->gadget.dev;24432443+ mEp->td_pool = udc->td_pool;2451244424522452- mEp->ep.name = mEp->name;24532453- mEp->ep.ops = &usb_ep_ops;24542454- mEp->ep.maxpacket = CTRL_PAYLOAD_MAX;24452445+ mEp->ep.name = mEp->name;24462446+ mEp->ep.ops = &usb_ep_ops;24472447+ mEp->ep.maxpacket = CTRL_PAYLOAD_MAX;2455244824562456- /* this allocation cannot be random */24572457- for (k = RX; k <= TX; k++) {24582458- INIT_LIST_HEAD(&mEp->qh[k].queue);24492449+ INIT_LIST_HEAD(&mEp->qh.queue);24592450 spin_unlock_irqrestore(udc->lock, flags);24602460- mEp->qh[k].ptr = dma_pool_alloc(udc->qh_pool,24612461- GFP_KERNEL,24622462- &mEp->qh[k].dma);24512451+ mEp->qh.ptr = dma_pool_alloc(udc->qh_pool, GFP_KERNEL,24522452+ &mEp->qh.dma);24632453 spin_lock_irqsave(udc->lock, flags);24642464- if (mEp->qh[k].ptr == NULL)24542454+ if (mEp->qh.ptr == NULL)24652455 retval = -ENOMEM;24662456 else24672467- memset(mEp->qh[k].ptr, 0,24682468- sizeof(*mEp->qh[k].ptr));24692469- }24702470- if (i == 0)24712471- udc->gadget.ep0 = &mEp->ep;24722472- else24572457+ memset(mEp->qh.ptr, 0, sizeof(*mEp->qh.ptr));24582458+24592459+ /* skip ep0 out and in endpoints */24602460+ if (i == 0)24612461+ continue;24622462+24732463 list_add_tail(&mEp->ep.ep_list, &udc->gadget.ep_list);24642464+ }24742465 }24752466 if (retval)24762467 goto done;2477246824692469+ udc->gadget.ep0 = &udc->ep0in.ep;24782470 /* bind gadget */24792471 driver->driver.bus = NULL;24802472 udc->gadget.dev.driver = &driver->driver;···24892479 goto done;24902480 }2491248124822482+ udc->driver = driver;24922483 pm_runtime_get_sync(&udc->gadget.dev);24932484 if (udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) {24942485 if (udc->vbus_active) {···25012490 }25022491 }2503249225042504- retval = hw_device_state(udc->ci13xxx_ep[0].qh[RX].dma);24932493+ retval = hw_device_state(udc->ep0out.qh.dma);25052494 if (retval)25062495 pm_runtime_put_sync(&udc->gadget.dev);2507249625082497 done:25092498 spin_unlock_irqrestore(udc->lock, flags);25102510- if (retval)25112511- usb_gadget_unregister_driver(driver);25122499 return retval;25132500}25142501EXPORT_SYMBOL(usb_gadget_probe_driver);···25192510int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)25202511{25212512 struct ci13xxx *udc = _udc;25222522- unsigned long i, k, flags;25132513+ unsigned long i, flags;2523251425242515 trace("%p", driver);25252516···25552546 for (i = 0; i < hw_ep_max; i++) {25562547 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];2557254825582558- if (i == 0)25592559- udc->gadget.ep0 = NULL;25602560- else if (!list_empty(&mEp->ep.ep_list))25492549+ if (!list_empty(&mEp->ep.ep_list))25612550 list_del_init(&mEp->ep.ep_list);2562255125632563- for (k = RX; k <= TX; k++)25642564- if (mEp->qh[k].ptr != NULL)25652565- dma_pool_free(udc->qh_pool,25662566- mEp->qh[k].ptr, mEp->qh[k].dma);25522552+ if (mEp->qh.ptr != NULL)25532553+ dma_pool_free(udc->qh_pool, mEp->qh.ptr, mEp->qh.dma);25672554 }2568255525562556+ udc->gadget.ep0 = NULL;25692557 udc->driver = NULL;2570255825712559 spin_unlock_irqrestore(udc->lock, flags);
+6-3
drivers/usb/gadget/ci13xxx_udc.h
···2020 * DEFINE2121 *****************************************************************************/2222#define CI13XXX_PAGE_SIZE 4096ul /* page size for TD's */2323-#define ENDPT_MAX (16)2323+#define ENDPT_MAX (32)2424#define CTRL_PAYLOAD_MAX (64)2525#define RX (0) /* similar to USB_DIR_OUT but can be used as an index */2626#define TX (1) /* similar to USB_DIR_IN but can be used as an index */···8888 struct list_head queue;8989 struct ci13xxx_qh *ptr;9090 dma_addr_t dma;9191- } qh[2];9292- struct usb_request *status;9191+ } qh;9392 int wedge;94939594 /* global resources */···118119119120 struct dma_pool *qh_pool; /* DMA pool for queue heads */120121 struct dma_pool *td_pool; /* DMA pool for transfer descs */122122+ struct usb_request *status; /* ep0 status request */121123122124 struct usb_gadget gadget; /* USB slave device */123125 struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */126126+ u32 ep0_dir; /* ep0 direction */127127+#define ep0out ci13xxx_ep[0]128128+#define ep0in ci13xxx_ep[16]124129125130 struct usb_gadget_driver *driver; /* 3rd party gadget driver */126131 struct ci13xxx_udc_driver *udc_driver; /* device controller driver */
+3-2
drivers/usb/gadget/composite.c
···928928 */929929 switch (ctrl->bRequestType & USB_RECIP_MASK) {930930 case USB_RECIP_INTERFACE:931931- if (cdev->config)932932- f = cdev->config->interface[intf];931931+ if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)932932+ break;933933+ f = cdev->config->interface[intf];933934 break;934935935936 case USB_RECIP_ENDPOINT:
+76-51
drivers/usb/gadget/pch_udc.c
···198198#define PCH_UDC_BRLEN 0x0F /* Burst length */199199#define PCH_UDC_THLEN 0x1F /* Threshold length */200200/* Value of EP Buffer Size */201201-#define UDC_EP0IN_BUFF_SIZE 64202202-#define UDC_EPIN_BUFF_SIZE 512203203-#define UDC_EP0OUT_BUFF_SIZE 64204204-#define UDC_EPOUT_BUFF_SIZE 512201201+#define UDC_EP0IN_BUFF_SIZE 16202202+#define UDC_EPIN_BUFF_SIZE 256203203+#define UDC_EP0OUT_BUFF_SIZE 16204204+#define UDC_EPOUT_BUFF_SIZE 256205205/* Value of EP maximum packet size */206206#define UDC_EP0IN_MAX_PKT_SIZE 64207207#define UDC_EP0OUT_MAX_PKT_SIZE 64···351351 struct pci_pool *data_requests;352352 struct pci_pool *stp_requests;353353 dma_addr_t dma_addr;354354- unsigned long ep0out_buf[64];354354+ void *ep0out_buf;355355 struct usb_ctrlrequest setup_data;356356 unsigned long phys_addr;357357 void __iomem *base_addr;···361361362362#define PCH_UDC_PCI_BAR 1363363#define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808364364+#define PCI_VENDOR_ID_ROHM 0x10DB365365+#define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D364366365367static const char ep0_string[] = "ep0in";366368static DEFINE_SPINLOCK(udc_stall_spinlock); /* stall spin lock */···12211219 dev = ep->dev;12221220 if (req->dma_mapped) {12231221 if (ep->in)12241224- pci_unmap_single(dev->pdev, req->req.dma,12251225- req->req.length, PCI_DMA_TODEVICE);12221222+ dma_unmap_single(&dev->pdev->dev, req->req.dma,12231223+ req->req.length, DMA_TO_DEVICE);12261224 else12271227- pci_unmap_single(dev->pdev, req->req.dma,12281228- req->req.length, PCI_DMA_FROMDEVICE);12251225+ dma_unmap_single(&dev->pdev->dev, req->req.dma,12261226+ req->req.length, DMA_FROM_DEVICE);12291227 req->dma_mapped = 0;12301228 req->req.dma = DMA_ADDR_INVALID;12311229 }···1416141414171415 pch_udc_clear_dma(ep->dev, DMA_DIR_RX);14181416 td_data = req->td_data;14191419- ep->td_data = req->td_data;14201417 /* Set the status bits for all descriptors */14211418 while (1) {14221419 td_data->status = (td_data->status & ~PCH_UDC_BUFF_STS) |···16141613 if (usbreq->length &&16151614 ((usbreq->dma == DMA_ADDR_INVALID) || !usbreq->dma)) {16161615 if (ep->in)16171617- usbreq->dma = pci_map_single(dev->pdev, usbreq->buf,16181618- usbreq->length, PCI_DMA_TODEVICE);16161616+ usbreq->dma = dma_map_single(&dev->pdev->dev,16171617+ usbreq->buf,16181618+ usbreq->length,16191619+ DMA_TO_DEVICE);16191620 else16201620- usbreq->dma = pci_map_single(dev->pdev, usbreq->buf,16211621- usbreq->length, PCI_DMA_FROMDEVICE);16211621+ usbreq->dma = dma_map_single(&dev->pdev->dev,16221622+ usbreq->buf,16231623+ usbreq->length,16241624+ DMA_FROM_DEVICE);16221625 req->dma_mapped = 1;16231626 }16241627 if (usbreq->length > 0) {16251625- retval = prepare_dma(ep, req, gfp);16281628+ retval = prepare_dma(ep, req, GFP_ATOMIC);16261629 if (retval)16271630 goto probe_end;16281631 }···16511646 pch_udc_wait_ep_stall(ep);16521647 pch_udc_ep_clear_nak(ep);16531648 pch_udc_enable_ep_interrupts(ep->dev, (1 << ep->num));16541654- pch_udc_set_dma(dev, DMA_DIR_TX);16551649 }16561650 }16571651 /* Now add this request to the ep's pending requests */···19301926 PCH_UDC_BS_DMA_DONE)19311927 return;19321928 pch_udc_clear_dma(ep->dev, DMA_DIR_RX);19291929+ pch_udc_ep_set_ddptr(ep, 0);19331930 if ((req->td_data_last->status & PCH_UDC_RXTX_STS) !=19341931 PCH_UDC_RTS_SUCC) {19351932 dev_err(&dev->pdev->dev, "Invalid RXTX status (0x%08x) "···19681963 u32 epsts;19691964 struct pch_udc_ep *ep;1970196519711971- ep = &dev->ep[2*ep_num];19661966+ ep = &dev->ep[UDC_EPIN_IDX(ep_num)];19721967 epsts = ep->epsts;19731968 ep->epsts = 0;19741969···20132008 struct pch_udc_ep *ep;20142009 struct pch_udc_request *req = NULL;2015201020162016- ep = &dev->ep[2*ep_num + 1];20112011+ ep = &dev->ep[UDC_EPOUT_IDX(ep_num)];20172012 epsts = ep->epsts;20182013 ep->epsts = 0;20192014···20302025 }20312026 if (epsts & UDC_EPSTS_HE)20322027 return;20332033- if (epsts & UDC_EPSTS_RSS)20282028+ if (epsts & UDC_EPSTS_RSS) {20342029 pch_udc_ep_set_stall(ep);20352030 pch_udc_enable_ep_interrupts(ep->dev,20362031 PCH_UDC_EPINT(ep->in, ep->num));20322032+ }20372033 if (epsts & UDC_EPSTS_RCS) {20382034 if (!dev->prot_stall) {20392035 pch_udc_ep_clear_stall(ep);···20662060{20672061 u32 epsts;20682062 struct pch_udc_ep *ep;20632063+ struct pch_udc_ep *ep_out;2069206420702065 ep = &dev->ep[UDC_EP0IN_IDX];20662066+ ep_out = &dev->ep[UDC_EP0OUT_IDX];20712067 epsts = ep->epsts;20722068 ep->epsts = 0;20732069···20812073 return;20822074 if (epsts & UDC_EPSTS_HE)20832075 return;20842084- if ((epsts & UDC_EPSTS_TDC) && (!dev->stall))20762076+ if ((epsts & UDC_EPSTS_TDC) && (!dev->stall)) {20852077 pch_udc_complete_transfer(ep);20782078+ pch_udc_clear_dma(dev, DMA_DIR_RX);20792079+ ep_out->td_data->status = (ep_out->td_data->status &20802080+ ~PCH_UDC_BUFF_STS) |20812081+ PCH_UDC_BS_HST_RDY;20822082+ pch_udc_ep_clear_nak(ep_out);20832083+ pch_udc_set_dma(dev, DMA_DIR_RX);20842084+ pch_udc_ep_set_rrdy(ep_out);20852085+ }20862086 /* On IN interrupt, provide data if we have any */20872087 if ((epsts & UDC_EPSTS_IN) && !(epsts & UDC_EPSTS_TDC) &&20882088 !(epsts & UDC_EPSTS_TXEMPTY))···21182102 dev->stall = 0;21192103 dev->ep[UDC_EP0IN_IDX].halted = 0;21202104 dev->ep[UDC_EP0OUT_IDX].halted = 0;21212121- /* In data not ready */21222122- pch_udc_ep_set_nak(&(dev->ep[UDC_EP0IN_IDX]));21232105 dev->setup_data = ep->td_stp->request;21242106 pch_udc_init_setup_buff(ep->td_stp);21252125- pch_udc_clear_dma(dev, DMA_DIR_TX);21072107+ pch_udc_clear_dma(dev, DMA_DIR_RX);21262108 pch_udc_ep_fifo_flush(&(dev->ep[UDC_EP0IN_IDX]),21272109 dev->ep[UDC_EP0IN_IDX].in);21282110 if ((dev->setup_data.bRequestType & USB_DIR_IN))···21362122 setup_supported = dev->driver->setup(&dev->gadget,21372123 &dev->setup_data);21382124 spin_lock(&dev->lock);21252125+21262126+ if (dev->setup_data.bRequestType & USB_DIR_IN) {21272127+ ep->td_data->status = (ep->td_data->status &21282128+ ~PCH_UDC_BUFF_STS) |21292129+ PCH_UDC_BS_HST_RDY;21302130+ pch_udc_ep_set_ddptr(ep, ep->td_data_phys);21312131+ }21392132 /* ep0 in returns data on IN phase */21402133 if (setup_supported >= 0 && setup_supported <21412134 UDC_EP0IN_MAX_PKT_SIZE) {21422135 pch_udc_ep_clear_nak(&(dev->ep[UDC_EP0IN_IDX]));21432136 /* Gadget would have queued a request when21442137 * we called the setup */21452145- pch_udc_set_dma(dev, DMA_DIR_RX);21462146- pch_udc_ep_clear_nak(ep);21382138+ if (!(dev->setup_data.bRequestType & USB_DIR_IN)) {21392139+ pch_udc_set_dma(dev, DMA_DIR_RX);21402140+ pch_udc_ep_clear_nak(ep);21412141+ }21472142 } else if (setup_supported < 0) {21482143 /* if unsupported request, then stall */21492144 pch_udc_ep_set_stall(&(dev->ep[UDC_EP0IN_IDX]));···21652142 }21662143 } else if ((((stat & UDC_EPSTS_OUT_MASK) >> UDC_EPSTS_OUT_SHIFT) ==21672144 UDC_EPSTS_OUT_DATA) && !dev->stall) {21682168- if (list_empty(&ep->queue)) {21692169- dev_err(&dev->pdev->dev, "%s: No request\n", __func__);21702170- ep->td_data->status = (ep->td_data->status &21712171- ~PCH_UDC_BUFF_STS) |21722172- PCH_UDC_BS_HST_RDY;21732173- pch_udc_set_dma(dev, DMA_DIR_RX);21742174- } else {21752175- /* control write */21762176- /* next function will pickuo an clear the status */21452145+ pch_udc_clear_dma(dev, DMA_DIR_RX);21462146+ pch_udc_ep_set_ddptr(ep, 0);21472147+ if (!list_empty(&ep->queue)) {21772148 ep->epsts = stat;21782178-21792179- pch_udc_svc_data_out(dev, 0);21802180- /* re-program desc. pointer for possible ZLPs */21812181- pch_udc_ep_set_ddptr(ep, ep->td_data_phys);21822182- pch_udc_set_dma(dev, DMA_DIR_RX);21492149+ pch_udc_svc_data_out(dev, PCH_UDC_EP0);21832150 }21512151+ pch_udc_set_dma(dev, DMA_DIR_RX);21842152 }21852153 pch_udc_ep_set_rrdy(ep);21862154}···21882174 struct pch_udc_ep *ep;21892175 struct pch_udc_request *req;2190217621912191- ep = &dev->ep[2*ep_num];21772177+ ep = &dev->ep[UDC_EPIN_IDX(ep_num)];21922178 if (!list_empty(&ep->queue)) {21932179 req = list_entry(ep->queue.next, struct pch_udc_request, queue);21942180 pch_udc_enable_ep_interrupts(ep->dev,···22102196 for (i = 0; i < PCH_UDC_USED_EP_NUM; i++) {22112197 /* IN */22122198 if (ep_intr & (0x1 << i)) {22132213- ep = &dev->ep[2*i];21992199+ ep = &dev->ep[UDC_EPIN_IDX(i)];22142200 ep->epsts = pch_udc_read_ep_status(ep);22152201 pch_udc_clear_ep_status(ep, ep->epsts);22162202 }22172203 /* OUT */22182204 if (ep_intr & (0x10000 << i)) {22192219- ep = &dev->ep[2*i+1];22052205+ ep = &dev->ep[UDC_EPOUT_IDX(i)];22202206 ep->epsts = pch_udc_read_ep_status(ep);22212207 pch_udc_clear_ep_status(ep, ep->epsts);22222208 }···25772563 dev->ep[UDC_EP0IN_IDX].ep.maxpacket = UDC_EP0IN_MAX_PKT_SIZE;25782564 dev->ep[UDC_EP0OUT_IDX].ep.maxpacket = UDC_EP0OUT_MAX_PKT_SIZE;2579256525802580- dev->dma_addr = pci_map_single(dev->pdev, dev->ep0out_buf, 256,25812581- PCI_DMA_FROMDEVICE);25822582-25832566 /* remove ep0 in and out from the list. They have own pointer */25842567 list_del_init(&dev->ep[UDC_EP0IN_IDX].ep.ep_list);25852568 list_del_init(&dev->ep[UDC_EP0OUT_IDX].ep.ep_list);···26482637 dev->ep[UDC_EP0IN_IDX].td_stp_phys = 0;26492638 dev->ep[UDC_EP0IN_IDX].td_data = NULL;26502639 dev->ep[UDC_EP0IN_IDX].td_data_phys = 0;26402640+26412641+ dev->ep0out_buf = kzalloc(UDC_EP0OUT_BUFF_SIZE * 4, GFP_KERNEL);26422642+ if (!dev->ep0out_buf)26432643+ return -ENOMEM;26442644+ dev->dma_addr = dma_map_single(&dev->pdev->dev, dev->ep0out_buf,26452645+ UDC_EP0OUT_BUFF_SIZE * 4,26462646+ DMA_FROM_DEVICE);26512647 return 0;26522648}26532649···2718270027192701 pch_udc_disable_interrupts(dev, UDC_DEVINT_MSK);2720270227212721- /* Assues that there are no pending requets with this driver */27032703+ /* Assures that there are no pending requests with this driver */27042704+ driver->disconnect(&dev->gadget);27222705 driver->unbind(&dev->gadget);27232706 dev->gadget.dev.driver = NULL;27242707 dev->driver = NULL;···27692750 pci_pool_destroy(dev->stp_requests);27702751 }2771275227532753+ if (dev->dma_addr)27542754+ dma_unmap_single(&dev->pdev->dev, dev->dma_addr,27552755+ UDC_EP0OUT_BUFF_SIZE * 4, DMA_FROM_DEVICE);27562756+ kfree(dev->ep0out_buf);27572757+27722758 pch_udc_exit(dev);2773275927742760 if (dev->irq_registered)···28162792 int ret;2817279328182794 pci_set_power_state(pdev, PCI_D0);28192819- ret = pci_restore_state(pdev);28202820- if (ret) {28212821- dev_err(&pdev->dev, "%s: pci_restore_state failed\n", __func__);28222822- return ret;28232823- }27952795+ pci_restore_state(pdev);28242796 ret = pci_enable_device(pdev);28252797 if (ret) {28262798 dev_err(&pdev->dev, "%s: pci_enable_device failed\n", __func__);···29312911static DEFINE_PCI_DEVICE_TABLE(pch_udc_pcidev_id) = {29322912 {29332913 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EG20T_UDC),29142914+ .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,29152915+ .class_mask = 0xffffffff,29162916+ },29172917+ {29182918+ PCI_DEVICE(PCI_VENDOR_ID_ROHM, PCI_DEVICE_ID_ML7213_IOH_UDC),29342919 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,29352920 .class_mask = 0xffffffff,29362921 },
···5252 struct resource *res;5353 int irq;5454 int retval;5555- unsigned int temp;56555756 pr_debug("initializing FSL-SOC USB Controller\n");5857···124125 retval = -ENODEV;125126 goto err3;126127 }127127-128128- /*129129- * Check if it is MPC5121 SoC, otherwise set pdata->have_sysif_regs130130- * flag for 83xx or 8536 system interface registers.131131- */132132- if (pdata->big_endian_mmio)133133- temp = in_be32(hcd->regs + FSL_SOC_USB_ID);134134- else135135- temp = in_le32(hcd->regs + FSL_SOC_USB_ID);136136-137137- if ((temp & ID_MSK) != (~((temp & NID_MSK) >> 8) & ID_MSK))138138- pdata->have_sysif_regs = 1;139128140129 /* Enable USB controller, 83xx or 8536 */141130 if (pdata->have_sysif_regs)
-3
drivers/usb/host/ehci-fsl.h
···1919#define _EHCI_FSL_H20202121/* offsets for the non-ehci registers in the FSL SOC USB controller */2222-#define FSL_SOC_USB_ID 0x02323-#define ID_MSK 0x3f2424-#define NID_MSK 0x3f002522#define FSL_SOC_USB_ULPIVP 0x1702623#define FSL_SOC_USB_PORTSC1 0x1842724#define PORT_PTS_MSK (3<<30)
+12-7
drivers/usb/host/ehci-hcd.c
···572572 ehci->iaa_watchdog.function = ehci_iaa_watchdog;573573 ehci->iaa_watchdog.data = (unsigned long) ehci;574574575575+ hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);576576+575577 /*576578 * hw default: 1K periodic list heads, one per frame.577579 * periodic_size can shrink by USBCMD update if hcc_params allows.···581579 ehci->periodic_size = DEFAULT_I_TDPS;582580 INIT_LIST_HEAD(&ehci->cached_itd_list);583581 INIT_LIST_HEAD(&ehci->cached_sitd_list);582582+583583+ if (HCC_PGM_FRAMELISTLEN(hcc_params)) {584584+ /* periodic schedule size can be smaller than default */585585+ switch (EHCI_TUNE_FLS) {586586+ case 0: ehci->periodic_size = 1024; break;587587+ case 1: ehci->periodic_size = 512; break;588588+ case 2: ehci->periodic_size = 256; break;589589+ default: BUG();590590+ }591591+ }584592 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0)585593 return retval;586594587595 /* controllers may cache some of the periodic schedule ... */588588- hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);589596 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache590597 ehci->i_thresh = 2 + 8;591598 else // N microframes cached···648637 /* periodic schedule size can be smaller than default */649638 temp &= ~(3 << 2);650639 temp |= (EHCI_TUNE_FLS << 2);651651- switch (EHCI_TUNE_FLS) {652652- case 0: ehci->periodic_size = 1024; break;653653- case 1: ehci->periodic_size = 512; break;654654- case 2: ehci->periodic_size = 256; break;655655- default: BUG();656656- }657640 }658641 if (HCC_LPM(hcc_params)) {659642 /* support link power management EHCI 1.1 addendum */
+23-2
drivers/usb/host/ehci-mxc.c
···2121#include <linux/clk.h>2222#include <linux/delay.h>2323#include <linux/usb/otg.h>2424+#include <linux/usb/ulpi.h>2425#include <linux/slab.h>25262627#include <mach/mxc_ehci.h>2828+2929+#include <asm/mach-types.h>27302831#define ULPI_VIEWPORT_OFFSET 0x1702932···117114 struct usb_hcd *hcd;118115 struct resource *res;119116 int irq, ret;117117+ unsigned int flags;120118 struct ehci_mxc_priv *priv;121119 struct device *dev = &pdev->dev;122120 struct ehci_hcd *ehci;···181177 clk_enable(priv->ahbclk);182178 }183179184184- /* "dr" device has its own clock */185185- if (pdev->id == 0) {180180+ /* "dr" device has its own clock on i.MX51 */181181+ if (cpu_is_mx51() && (pdev->id == 0)) {186182 priv->phy1clk = clk_get(dev, "usb_phy1");187183 if (IS_ERR(priv->phy1clk)) {188184 ret = PTR_ERR(priv->phy1clk);···243239 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);244240 if (ret)245241 goto err_add;242242+243243+ if (pdata->otg) {244244+ /*245245+ * efikamx and efikasb have some hardware bug which is246246+ * preventing usb to work unless CHRGVBUS is set.247247+ * It's in violation of USB specs248248+ */249249+ if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {250250+ flags = otg_io_read(pdata->otg, ULPI_OTG_CTRL);251251+ flags |= ULPI_OTG_CTRL_CHRGVBUS;252252+ ret = otg_io_write(pdata->otg, flags, ULPI_OTG_CTRL);253253+ if (ret) {254254+ dev_err(dev, "unable to set CHRVBUS\n");255255+ goto err_add;256256+ }257257+ }258258+ }246259247260 return 0;248261
+20-13
drivers/usb/host/ehci-pci.c
···4444 return 0;4545}46464747-static int ehci_quirk_amd_SB800(struct ehci_hcd *ehci)4747+static int ehci_quirk_amd_hudson(struct ehci_hcd *ehci)4848{4949 struct pci_dev *amd_smbus_dev;5050 u8 rev = 0;51515252 amd_smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, 0x4385, NULL);5353- if (!amd_smbus_dev)5454- return 0;5555-5656- pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev);5757- if (rev < 0x40) {5858- pci_dev_put(amd_smbus_dev);5959- amd_smbus_dev = NULL;6060- return 0;5353+ if (amd_smbus_dev) {5454+ pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev);5555+ if (rev < 0x40) {5656+ pci_dev_put(amd_smbus_dev);5757+ amd_smbus_dev = NULL;5858+ return 0;5959+ }6060+ } else {6161+ amd_smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x780b, NULL);6262+ if (!amd_smbus_dev)6363+ return 0;6464+ pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev);6565+ if (rev < 0x11 || rev > 0x18) {6666+ pci_dev_put(amd_smbus_dev);6767+ amd_smbus_dev = NULL;6868+ return 0;6969+ }6170 }62716372 if (!amd_nb_dev)6473 amd_nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1510, NULL);6565- if (!amd_nb_dev)6666- ehci_err(ehci, "QUIRK: unable to get AMD NB device\n");67746868- ehci_info(ehci, "QUIRK: Enable AMD SB800 L1 fix\n");7575+ ehci_info(ehci, "QUIRK: Enable exception for AMD Hudson ASPM\n");69767077 pci_dev_put(amd_smbus_dev);7178 amd_smbus_dev = NULL;···138131 /* cache this readonly data; minimize chip reads */139132 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);140133141141- if (ehci_quirk_amd_SB800(ehci))134134+ if (ehci_quirk_amd_hudson(ehci))142135 ehci->amd_l1_fix = 1;143136144137 retval = ehci_halt(ehci);
···308308/* Ring the host controller doorbell after placing a command on the ring */309309void xhci_ring_cmd_db(struct xhci_hcd *xhci)310310{311311- u32 temp;312312-313311 xhci_dbg(xhci, "// Ding dong!\n");314314- temp = xhci_readl(xhci, &xhci->dba->doorbell[0]) & DB_MASK;315315- xhci_writel(xhci, temp | DB_TARGET_HOST, &xhci->dba->doorbell[0]);312312+ xhci_writel(xhci, DB_VALUE_HOST, &xhci->dba->doorbell[0]);316313 /* Flush PCI posted writes */317314 xhci_readl(xhci, &xhci->dba->doorbell[0]);318315}···319322 unsigned int ep_index,320323 unsigned int stream_id)321324{322322- struct xhci_virt_ep *ep;323323- unsigned int ep_state;324324- u32 field;325325 __u32 __iomem *db_addr = &xhci->dba->doorbell[slot_id];326326+ struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index];327327+ unsigned int ep_state = ep->ep_state;326328327327- ep = &xhci->devs[slot_id]->eps[ep_index];328328- ep_state = ep->ep_state;329329 /* Don't ring the doorbell for this endpoint if there are pending330330- * cancellations because the we don't want to interrupt processing.330330+ * cancellations because we don't want to interrupt processing.331331 * We don't want to restart any stream rings if there's a set dequeue332332 * pointer command pending because the device can choose to start any333333 * stream once the endpoint is on the HW schedule.334334 * FIXME - check all the stream rings for pending cancellations.335335 */336336- if (!(ep_state & EP_HALT_PENDING) && !(ep_state & SET_DEQ_PENDING)337337- && !(ep_state & EP_HALTED)) {338338- field = xhci_readl(xhci, db_addr) & DB_MASK;339339- field |= EPI_TO_DB(ep_index) | STREAM_ID_TO_DB(stream_id);340340- xhci_writel(xhci, field, db_addr);341341- }336336+ if ((ep_state & EP_HALT_PENDING) || (ep_state & SET_DEQ_PENDING) ||337337+ (ep_state & EP_HALTED))338338+ return;339339+ xhci_writel(xhci, DB_VALUE(ep_index, stream_id), db_addr);340340+ /* The CPU has better things to do at this point than wait for a341341+ * write-posting flush. It'll get there soon enough.342342+ */342343}343344344345/* Ring the doorbell for any rings with pending URBs */···1183118811841189 addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS * (port_id - 1);11851190 temp = xhci_readl(xhci, addr);11861186- if ((temp & PORT_CONNECT) && (hcd->state == HC_STATE_SUSPENDED)) {11911191+ if (hcd->state == HC_STATE_SUSPENDED) {11871192 xhci_dbg(xhci, "resume root hub\n");11881193 usb_hcd_resume_root_hub(hcd);11891194 }···17051710 /* Others already handled above */17061711 break;17071712 }17081708- dev_dbg(&td->urb->dev->dev,17091709- "ep %#x - asked for %d bytes, "17131713+ xhci_dbg(xhci, "ep %#x - asked for %d bytes, "17101714 "%d bytes untransferred\n",17111715 td->urb->ep->desc.bEndpointAddress,17121716 td->urb->transfer_buffer_length,···23832389 }23842390 xhci_dbg(xhci, "\n");23852391 if (!in_interrupt())23862386- dev_dbg(&urb->dev->dev, "ep %#x - urb len = %d, sglist used, num_trbs = %d\n",23922392+ xhci_dbg(xhci, "ep %#x - urb len = %d, sglist used, "23932393+ "num_trbs = %d\n",23872394 urb->ep->desc.bEndpointAddress,23882395 urb->transfer_buffer_length,23892396 num_trbs);···2409241424102415static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id,24112416 unsigned int ep_index, unsigned int stream_id, int start_cycle,24122412- struct xhci_generic_trb *start_trb, struct xhci_td *td)24172417+ struct xhci_generic_trb *start_trb)24132418{24142419 /*24152420 * Pass all the TRBs to the hardware at once and make sure this write24162421 * isn't reordered.24172422 */24182423 wmb();24192419- start_trb->field[3] |= start_cycle;24242424+ if (start_cycle)24252425+ start_trb->field[3] |= start_cycle;24262426+ else24272427+ start_trb->field[3] &= ~0x1;24202428 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id);24212429}24222430···24472449 * to set the polling interval (once the API is added).24482450 */24492451 if (xhci_interval != ep_interval) {24502450- if (!printk_ratelimit())24522452+ if (printk_ratelimit())24512453 dev_dbg(&urb->dev->dev, "Driver uses different interval"24522454 " (%d microframe%s) than xHCI "24532455 "(%d microframe%s)\n",···25492551 u32 remainder = 0;2550255225512553 /* Don't change the cycle bit of the first TRB until later */25522552- if (first_trb)25542554+ if (first_trb) {25532555 first_trb = false;25542554- else25562556+ if (start_cycle == 0)25572557+ field |= 0x1;25582558+ } else25552559 field |= ep_ring->cycle_state;2556256025572561 /* Chain all the TRBs together; clear the chain bit in the last···2625262526262626 check_trb_math(urb, num_trbs, running_total);26272627 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,26282628- start_cycle, start_trb, td);26282628+ start_cycle, start_trb);26292629 return 0;26302630}26312631···26712671 /* FIXME: this doesn't deal with URB_ZERO_PACKET - need one more */2672267226732673 if (!in_interrupt())26742674- dev_dbg(&urb->dev->dev, "ep %#x - urb len = %#x (%d), addr = %#llx, num_trbs = %d\n",26742674+ xhci_dbg(xhci, "ep %#x - urb len = %#x (%d), "26752675+ "addr = %#llx, num_trbs = %d\n",26752676 urb->ep->desc.bEndpointAddress,26762677 urb->transfer_buffer_length,26772678 urb->transfer_buffer_length,···27122711 field = 0;2713271227142713 /* Don't change the cycle bit of the first TRB until later */27152715- if (first_trb)27142714+ if (first_trb) {27162715 first_trb = false;27172717- else27162716+ if (start_cycle == 0)27172717+ field |= 0x1;27182718+ } else27182719 field |= ep_ring->cycle_state;2719272027202721 /* Chain all the TRBs together; clear the chain bit in the last···2760275727612758 check_trb_math(urb, num_trbs, running_total);27622759 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,27632763- start_cycle, start_trb, td);27602760+ start_cycle, start_trb);27642761 return 0;27652762}27662763···28212818 /* Queue setup TRB - see section 6.4.1.2.1 */28222819 /* FIXME better way to translate setup_packet into two u32 fields? */28232820 setup = (struct usb_ctrlrequest *) urb->setup_packet;28212821+ field = 0;28222822+ field |= TRB_IDT | TRB_TYPE(TRB_SETUP);28232823+ if (start_cycle == 0)28242824+ field |= 0x1;28242825 queue_trb(xhci, ep_ring, false, true,28252826 /* FIXME endianness is probably going to bite my ass here. */28262827 setup->bRequestType | setup->bRequest << 8 | setup->wValue << 16,28272828 setup->wIndex | setup->wLength << 16,28282829 TRB_LEN(8) | TRB_INTR_TARGET(0),28292830 /* Immediate data in pointer */28302830- TRB_IDT | TRB_TYPE(TRB_SETUP));28312831+ field);2831283228322833 /* If there's data, queue data TRBs */28332834 field = 0;···28662859 field | TRB_IOC | TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state);2867286028682861 giveback_first_trb(xhci, slot_id, ep_index, 0,28692869- start_cycle, start_trb, td);28622862+ start_cycle, start_trb);28702863 return 0;28712864}28722865···29072900 int running_total, trb_buff_len, td_len, td_remain_len, ret;29082901 u64 start_addr, addr;29092902 int i, j;29032903+ bool more_trbs_coming;2910290429112905 ep_ring = xhci->devs[slot_id]->eps[ep_index].ring;29122906···29182910 }2919291129202912 if (!in_interrupt())29212921- dev_dbg(&urb->dev->dev, "ep %#x - urb len = %#x (%d),"29132913+ xhci_dbg(xhci, "ep %#x - urb len = %#x (%d),"29222914 " addr = %#llx, num_tds = %d\n",29232915 urb->ep->desc.bEndpointAddress,29242916 urb->transfer_buffer_length,···29582950 field |= TRB_TYPE(TRB_ISOC);29592951 /* Assume URB_ISO_ASAP is set */29602952 field |= TRB_SIA;29612961- if (i > 0)29532953+ if (i == 0) {29542954+ if (start_cycle == 0)29552955+ field |= 0x1;29562956+ } else29622957 field |= ep_ring->cycle_state;29632958 first_trb = false;29642959 } else {···29762965 */29772966 if (j < trbs_per_td - 1) {29782967 field |= TRB_CHAIN;29682968+ more_trbs_coming = true;29792969 } else {29802970 td->last_trb = ep_ring->enqueue;29812971 field |= TRB_IOC;29722972+ more_trbs_coming = false;29822973 }2983297429842975 /* Calculate TRB length */···29932980 length_field = TRB_LEN(trb_buff_len) |29942981 remainder |29952982 TRB_INTR_TARGET(0);29962996- queue_trb(xhci, ep_ring, false, false,29832983+ queue_trb(xhci, ep_ring, false, more_trbs_coming,29972984 lower_32_bits(addr),29982985 upper_32_bits(addr),29992986 length_field,···30163003 }30173004 }3018300530193019- wmb();30203020- start_trb->field[3] |= start_cycle;30213021-30223022- xhci_ring_ep_doorbell(xhci, slot_id, ep_index, urb->stream_id);30063006+ giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,30073007+ start_cycle, start_trb);30233008 return 0;30243009}30253010···30753064 * to set the polling interval (once the API is added).30763065 */30773066 if (xhci_interval != ep_interval) {30783078- if (!printk_ratelimit())30673067+ if (printk_ratelimit())30793068 dev_dbg(&urb->dev->dev, "Driver uses different interval"30803069 " (%d microframe%s) than xHCI "30813070 "(%d microframe%s)\n",
+25-35
drivers/usb/host/xhci.c
···226226static int xhci_setup_msix(struct xhci_hcd *xhci)227227{228228 int i, ret = 0;229229- struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);229229+ struct usb_hcd *hcd = xhci_to_hcd(xhci);230230+ struct pci_dev *pdev = to_pci_dev(hcd->self.controller);230231231232 /*232233 * calculate number of msi-x vectors supported.···266265 goto disable_msix;267266 }268267268268+ hcd->msix_enabled = 1;269269 return ret;270270271271disable_msix:···282280/* Free any IRQs and disable MSI-X */283281static void xhci_cleanup_msix(struct xhci_hcd *xhci)284282{285285- struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);283283+ struct usb_hcd *hcd = xhci_to_hcd(xhci);284284+ struct pci_dev *pdev = to_pci_dev(hcd->self.controller);286285287286 xhci_free_irq(xhci);288287···295292 pci_disable_msi(pdev);296293 }297294295295+ hcd->msix_enabled = 0;298296 return;299297}300298···512508 spin_lock_irq(&xhci->lock);513509 xhci_halt(xhci);514510 xhci_reset(xhci);515515- xhci_cleanup_msix(xhci);516511 spin_unlock_irq(&xhci->lock);512512+513513+ xhci_cleanup_msix(xhci);517514518515#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING519516 /* Tell the event ring poll function not to reschedule */···549544550545 spin_lock_irq(&xhci->lock);551546 xhci_halt(xhci);552552- xhci_cleanup_msix(xhci);553547 spin_unlock_irq(&xhci->lock);548548+549549+ xhci_cleanup_msix(xhci);554550555551 xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n",556552 xhci_readl(xhci, &xhci->op_regs->status));···653647 int rc = 0;654648 struct usb_hcd *hcd = xhci_to_hcd(xhci);655649 u32 command;650650+ int i;656651657652 spin_lock_irq(&xhci->lock);658653 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);···684677 spin_unlock_irq(&xhci->lock);685678 return -ETIMEDOUT;686679 }687687- /* step 5: remove core well power */688688- xhci_cleanup_msix(xhci);689680 spin_unlock_irq(&xhci->lock);681681+682682+ /* step 5: remove core well power */683683+ /* synchronize irq when using MSI-X */684684+ if (xhci->msix_entries) {685685+ for (i = 0; i < xhci->msix_count; i++)686686+ synchronize_irq(xhci->msix_entries[i].vector);687687+ }690688691689 return rc;692690}···706694{707695 u32 command, temp = 0;708696 struct usb_hcd *hcd = xhci_to_hcd(xhci);709709- struct pci_dev *pdev = to_pci_dev(hcd->self.controller);710697 int old_state, retval;711698712699 old_state = hcd->state;···740729 xhci_dbg(xhci, "Stop HCD\n");741730 xhci_halt(xhci);742731 xhci_reset(xhci);743743- if (hibernated)744744- xhci_cleanup_msix(xhci);745732 spin_unlock_irq(&xhci->lock);733733+ xhci_cleanup_msix(xhci);746734747735#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING748736 /* Tell the event ring poll function not to reschedule */···775765 return retval;776766 }777767778778- spin_unlock_irq(&xhci->lock);779779- /* Re-setup MSI-X */780780- if (hcd->irq)781781- free_irq(hcd->irq, hcd);782782- hcd->irq = -1;783783-784784- retval = xhci_setup_msix(xhci);785785- if (retval)786786- /* fall back to msi*/787787- retval = xhci_setup_msi(xhci);788788-789789- if (retval) {790790- /* fall back to legacy interrupt*/791791- retval = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED,792792- hcd->irq_descr, hcd);793793- if (retval) {794794- xhci_err(xhci, "request interrupt %d failed\n",795795- pdev->irq);796796- return retval;797797- }798798- hcd->irq = pdev->irq;799799- }800800-801801- spin_lock_irq(&xhci->lock);802768 /* step 4: set Run/Stop bit */803769 command = xhci_readl(xhci, &xhci->op_regs->command);804770 command |= CMD_RUN;···24312445 xhci_err(xhci, "Error while assigning device slot ID\n");24322446 return 0;24332447 }24342434- /* xhci_alloc_virt_device() does not touch rings; no need to lock */24352435- if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_KERNEL)) {24482448+ /* xhci_alloc_virt_device() does not touch rings; no need to lock.24492449+ * Use GFP_NOIO, since this function can be called from24502450+ * xhci_discover_or_reset_device(), which may be called as part of24512451+ * mass storage driver error handling.24522452+ */24532453+ if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_NOIO)) {24362454 /* Disable slot, if we can do it without mem alloc */24372455 xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n");24382456 spin_lock_irqsave(&xhci->lock, flags);
···133133134134/* how come ??? */135135#define UART_STATE 0x08136136-#define UART_STATE_TRANSIENT_MASK 0x74136136+#define UART_STATE_TRANSIENT_MASK 0x75137137#define UART_DCD 0x01138138#define UART_DSR 0x02139139#define UART_BREAK_ERROR 0x04···525525 /* overrun is special, not associated with a char */526526 if (status & UART_OVERRUN_ERROR)527527 tty_insert_flip_char(tty, 0, TTY_OVERRUN);528528+529529+ if (status & UART_DCD)530530+ usb_serial_handle_dcd_change(port, tty,531531+ priv->line_status & MSR_STATUS_LINE_DCD);528532 }529533530534 tty_insert_flip_string_fixed_flag(tty, data, tty_flag,···649645 .name = "SPCP8x5",650646 },651647 .id_table = id_table,648648+ .usb_driver = &spcp8x5_driver,652649 .num_ports = 1,653650 .open = spcp8x5_open,654651 .dtr_rts = spcp8x5_dtr_rts,
+6-2
drivers/usb/serial/usb-serial.c
···13441344 return -ENODEV;1345134513461346 fixup_generic(driver);13471347- if (driver->usb_driver)13481348- driver->usb_driver->supports_autosuspend = 1;1349134713501348 if (!driver->description)13511349 driver->description = driver->driver.name;13501350+ if (!driver->usb_driver) {13511351+ WARN(1, "Serial driver %s has no usb_driver\n",13521352+ driver->description);13531353+ return -EINVAL;13541354+ }13551355+ driver->usb_driver->supports_autosuspend = 1;1352135613531357 /* Add this device to our list of devices */13541358 mutex_lock(&table_lock);
···452452 if oplock (caching token) is granted and held. Note that453453 direct allows write operations larger than page size454454 to be sent to the server.455455+ strictcache Use for switching on strict cache mode. In this mode the456456+ client read from the cache all the time it has Oplock Level II,457457+ otherwise - read from the server. All written data are stored458458+ in the cache, but if the client doesn't have Exclusive Oplock,459459+ it writes the data to the server.455460 acl Allow setfacl and getfacl to manage posix ACLs if server456461 supports them. (default)457462 noacl Do not allow setfacl and getfacl calls on this mount
+20-13
fs/cifs/cifsencrypt.c
···2424#include "cifspdu.h"2525#include "cifsglob.h"2626#include "cifs_debug.h"2727-#include "md5.h"2827#include "cifs_unicode.h"2928#include "cifsproto.h"3029#include "ntlmssp.h"···3536/* Note we only use the 1st eight bytes */3637/* Note that the smb header signature field on input contains the3738 sequence number before this function is called */3838-3939-extern void mdfour(unsigned char *out, unsigned char *in, int n);4040-extern void E_md4hash(const unsigned char *passwd, unsigned char *p16);4141-extern void SMBencrypt(unsigned char *passwd, const unsigned char *c8,4242- unsigned char *p24);43394440static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu,4541 struct TCP_Server_Info *server, char *signature)···228234/* first calculate 24 bytes ntlm response and then 16 byte session key */229235int setup_ntlm_response(struct cifsSesInfo *ses)230236{237237+ int rc = 0;231238 unsigned int temp_len = CIFS_SESS_KEY_SIZE + CIFS_AUTH_RESP_SIZE;232239 char temp_key[CIFS_SESS_KEY_SIZE];233240···242247 }243248 ses->auth_key.len = temp_len;244249245245- SMBNTencrypt(ses->password, ses->server->cryptkey,250250+ rc = SMBNTencrypt(ses->password, ses->server->cryptkey,246251 ses->auth_key.response + CIFS_SESS_KEY_SIZE);252252+ if (rc) {253253+ cFYI(1, "%s Can't generate NTLM response, error: %d",254254+ __func__, rc);255255+ return rc;256256+ }247257248248- E_md4hash(ses->password, temp_key);249249- mdfour(ses->auth_key.response, temp_key, CIFS_SESS_KEY_SIZE);258258+ rc = E_md4hash(ses->password, temp_key);259259+ if (rc) {260260+ cFYI(1, "%s Can't generate NT hash, error: %d", __func__, rc);261261+ return rc;262262+ }250263251251- return 0;264264+ rc = mdfour(ses->auth_key.response, temp_key, CIFS_SESS_KEY_SIZE);265265+ if (rc)266266+ cFYI(1, "%s Can't generate NTLM session key, error: %d",267267+ __func__, rc);268268+269269+ return rc;252270}253271254272#ifdef CONFIG_CIFS_WEAK_PW_HASH···708700 unsigned int size;709701710702 server->secmech.hmacmd5 = crypto_alloc_shash("hmac(md5)", 0, 0);711711- if (!server->secmech.hmacmd5 ||712712- IS_ERR(server->secmech.hmacmd5)) {703703+ if (IS_ERR(server->secmech.hmacmd5)) {713704 cERROR(1, "could not allocate crypto hmacmd5\n");714705 return PTR_ERR(server->secmech.hmacmd5);715706 }716707717708 server->secmech.md5 = crypto_alloc_shash("md5", 0, 0);718718- if (!server->secmech.md5 || IS_ERR(server->secmech.md5)) {709709+ if (IS_ERR(server->secmech.md5)) {719710 cERROR(1, "could not allocate crypto md5\n");720711 rc = PTR_ERR(server->secmech.md5);721712 goto crypto_allocate_md5_fail;
-33
fs/cifs/cifsencrypt.h
···11-/*22- * fs/cifs/cifsencrypt.h33- *44- * Copyright (c) International Business Machines Corp., 200555- * Author(s): Steve French (sfrench@us.ibm.com)66- *77- * Externs for misc. small encryption routines88- * so we do not have to put them in cifsproto.h99- *1010- * This library is free software; you can redistribute it and/or modify1111- * it under the terms of the GNU Lesser General Public License as published1212- * by the Free Software Foundation; either version 2.1 of the License, or1313- * (at your option) any later version.1414- *1515- * This library is distributed in the hope that it will be useful,1616- * but WITHOUT ANY WARRANTY; without even the implied warranty of1717- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See1818- * the GNU Lesser General Public License for more details.1919- *2020- * You should have received a copy of the GNU Lesser General Public License2121- * along with this library; if not, write to the Free Software2222- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2323- */2424-2525-/* md4.c */2626-extern void mdfour(unsigned char *out, unsigned char *in, int n);2727-/* smbdes.c */2828-extern void E_P16(unsigned char *p14, unsigned char *p16);2929-extern void E_P24(unsigned char *p21, const unsigned char *c8,3030- unsigned char *p24);3131-3232-3333-
···4545 up with a different answer to the one above)4646*/4747#include <linux/slab.h>4848-#include "cifsencrypt.h"4948#define uchar unsigned char50495150static uchar perm1[56] = { 57, 49, 41, 33, 25, 17, 9,
+64-27
fs/cifs/smbencrypt.c
···3232#include "cifs_unicode.h"3333#include "cifspdu.h"3434#include "cifsglob.h"3535-#include "md5.h"3635#include "cifs_debug.h"3737-#include "cifsencrypt.h"3636+#include "cifsproto.h"38373938#ifndef false4039#define false 0···4748#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)4849#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((__u16)(val)))49505050-/*The following definitions come from libsmb/smbencrypt.c */5151+/* produce a md4 message digest from data of length n bytes */5252+int5353+mdfour(unsigned char *md4_hash, unsigned char *link_str, int link_len)5454+{5555+ int rc;5656+ unsigned int size;5757+ struct crypto_shash *md4;5858+ struct sdesc *sdescmd4;51595252-void SMBencrypt(unsigned char *passwd, const unsigned char *c8,5353- unsigned char *p24);5454-void E_md4hash(const unsigned char *passwd, unsigned char *p16);5555-static void SMBOWFencrypt(unsigned char passwd[16], const unsigned char *c8,5656- unsigned char p24[24]);5757-void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);6060+ md4 = crypto_alloc_shash("md4", 0, 0);6161+ if (IS_ERR(md4)) {6262+ cERROR(1, "%s: Crypto md4 allocation error %d\n", __func__, rc);6363+ return PTR_ERR(md4);6464+ }6565+ size = sizeof(struct shash_desc) + crypto_shash_descsize(md4);6666+ sdescmd4 = kmalloc(size, GFP_KERNEL);6767+ if (!sdescmd4) {6868+ rc = -ENOMEM;6969+ cERROR(1, "%s: Memory allocation failure\n", __func__);7070+ goto mdfour_err;7171+ }7272+ sdescmd4->shash.tfm = md4;7373+ sdescmd4->shash.flags = 0x0;7474+7575+ rc = crypto_shash_init(&sdescmd4->shash);7676+ if (rc) {7777+ cERROR(1, "%s: Could not init md4 shash\n", __func__);7878+ goto mdfour_err;7979+ }8080+ crypto_shash_update(&sdescmd4->shash, link_str, link_len);8181+ rc = crypto_shash_final(&sdescmd4->shash, md4_hash);8282+8383+mdfour_err:8484+ crypto_free_shash(md4);8585+ kfree(sdescmd4);8686+8787+ return rc;8888+}8989+9090+/* Does the des encryption from the NT or LM MD4 hash. */9191+static void9292+SMBOWFencrypt(unsigned char passwd[16], const unsigned char *c8,9393+ unsigned char p24[24])9494+{9595+ unsigned char p21[21];9696+9797+ memset(p21, '\0', 21);9898+9999+ memcpy(p21, passwd, 16);100100+ E_P24(p21, c8, p24);101101+}5810259103/*60104 This implements the X/Open SMB password encryption···160118 * Creates the MD4 Hash of the users password in NT UNICODE.161119 */162120163163-void121121+int164122E_md4hash(const unsigned char *passwd, unsigned char *p16)165123{124124+ int rc;166125 int len;167126 __u16 wpwd[129];168127···182139 /* Calculate length in bytes */183140 len = _my_wcslen(wpwd) * sizeof(__u16);184141185185- mdfour(p16, (unsigned char *) wpwd, len);142142+ rc = mdfour(p16, (unsigned char *) wpwd, len);186143 memset(wpwd, 0, 129 * 2);144144+145145+ return rc;187146}188147189148#if 0 /* currently unused */···257212}258213#endif259214260260-/* Does the des encryption from the NT or LM MD4 hash. */261261-static void262262-SMBOWFencrypt(unsigned char passwd[16], const unsigned char *c8,263263- unsigned char p24[24])264264-{265265- unsigned char p21[21];266266-267267- memset(p21, '\0', 21);268268-269269- memcpy(p21, passwd, 16);270270- E_P24(p21, c8, p24);271271-}272272-273215/* Does the des encryption from the FIRST 8 BYTES of the NT or LM MD4 hash. */274216#if 0 /* currently unused */275217static void···274242#endif275243276244/* Does the NT MD4 hash then des encryption. */277277-278278-void245245+int279246SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24)280247{248248+ int rc;281249 unsigned char p21[21];282250283251 memset(p21, '\0', 21);284252285285- E_md4hash(passwd, p21);253253+ rc = E_md4hash(passwd, p21);254254+ if (rc) {255255+ cFYI(1, "%s Can't generate NT hash, error: %d", __func__, rc);256256+ return rc;257257+ }286258 SMBOWFencrypt(p21, c8, p24);259259+ return rc;287260}288261289262
···135135136136#if defined(CONFIG_NFS_V4_1)137137/*138138- * * CB_SEQUENCE operations will fail until the callback sessionid is set.139139- * */140140-int nfs4_set_callback_sessionid(struct nfs_client *clp)141141-{142142- struct svc_serv *serv = clp->cl_rpcclient->cl_xprt->bc_serv;143143- struct nfs4_sessionid *bc_sid;144144-145145- if (!serv->sv_bc_xprt)146146- return -EINVAL;147147-148148- /* on success freed in xprt_free */149149- bc_sid = kmalloc(sizeof(struct nfs4_sessionid), GFP_KERNEL);150150- if (!bc_sid)151151- return -ENOMEM;152152- memcpy(bc_sid->data, &clp->cl_session->sess_id.data,153153- NFS4_MAX_SESSIONID_LEN);154154- spin_lock_bh(&serv->sv_cb_lock);155155- serv->sv_bc_xprt->xpt_bc_sid = bc_sid;156156- spin_unlock_bh(&serv->sv_cb_lock);157157- dprintk("%s set xpt_bc_sid=%u:%u:%u:%u for sv_bc_xprt %p\n", __func__,158158- ((u32 *)bc_sid->data)[0], ((u32 *)bc_sid->data)[1],159159- ((u32 *)bc_sid->data)[2], ((u32 *)bc_sid->data)[3],160160- serv->sv_bc_xprt);161161- return 0;162162-}163163-164164-/*165138 * The callback service for NFSv4.1 callbacks166139 */167140static int···239266 struct nfs_callback_data *cb_info)240267{241268}242242-int nfs4_set_callback_sessionid(struct nfs_client *clp)243243-{244244- return 0;245245-}246269#endif /* CONFIG_NFS_V4_1 */247270248271/*···328359 mutex_unlock(&nfs_callback_mutex);329360}330361331331-static int check_gss_callback_principal(struct nfs_client *clp,332332- struct svc_rqst *rqstp)362362+/* Boolean check of RPC_AUTH_GSS principal */363363+int364364+check_gss_callback_principal(struct nfs_client *clp, struct svc_rqst *rqstp)333365{334366 struct rpc_clnt *r = clp->cl_rpcclient;335367 char *p = svc_gss_principal(rqstp);336368369369+ if (rqstp->rq_authop->flavour != RPC_AUTH_GSS)370370+ return 1;371371+337372 /* No RPC_AUTH_GSS on NFSv4.1 back channel yet */338373 if (clp->cl_minorversion != 0)339339- return SVC_DROP;374374+ return 0;340375 /*341376 * It might just be a normal user principal, in which case342377 * userspace won't bother to tell us the name at all.343378 */344379 if (p == NULL)345345- return SVC_DENIED;380380+ return 0;346381347382 /* Expect a GSS_C_NT_HOSTBASED_NAME like "nfs@serverhostname" */348383349384 if (memcmp(p, "nfs@", 4) != 0)350350- return SVC_DENIED;385385+ return 0;351386 p += 4;352387 if (strcmp(p, r->cl_server) != 0)353353- return SVC_DENIED;354354- return SVC_OK;388388+ return 0;389389+ return 1;355390}356391357357-/* pg_authenticate method helper */358358-static struct nfs_client *nfs_cb_find_client(struct svc_rqst *rqstp)359359-{360360- struct nfs4_sessionid *sessionid = bc_xprt_sid(rqstp);361361- int is_cb_compound = rqstp->rq_proc == CB_COMPOUND ? 1 : 0;362362-363363- dprintk("--> %s rq_proc %d\n", __func__, rqstp->rq_proc);364364- if (svc_is_backchannel(rqstp))365365- /* Sessionid (usually) set after CB_NULL ping */366366- return nfs4_find_client_sessionid(svc_addr(rqstp), sessionid,367367- is_cb_compound);368368- else369369- /* No callback identifier in pg_authenticate */370370- return nfs4_find_client_no_ident(svc_addr(rqstp));371371-}372372-373373-/* pg_authenticate method for nfsv4 callback threads. */392392+/*393393+ * pg_authenticate method for nfsv4 callback threads.394394+ *395395+ * The authflavor has been negotiated, so an incorrect flavor is a server396396+ * bug. Drop packets with incorrect authflavor.397397+ *398398+ * All other checking done after NFS decoding where the nfs_client can be399399+ * found in nfs4_callback_compound400400+ */374401static int nfs_callback_authenticate(struct svc_rqst *rqstp)375402{376376- struct nfs_client *clp;377377- RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);378378- int ret = SVC_OK;379379-380380- /* Don't talk to strangers */381381- clp = nfs_cb_find_client(rqstp);382382- if (clp == NULL)383383- return SVC_DROP;384384-385385- dprintk("%s: %s NFSv4 callback!\n", __func__,386386- svc_print_addr(rqstp, buf, sizeof(buf)));387387-388403 switch (rqstp->rq_authop->flavour) {389389- case RPC_AUTH_NULL:390390- if (rqstp->rq_proc != CB_NULL)391391- ret = SVC_DENIED;392392- break;393393- case RPC_AUTH_UNIX:394394- break;395395- case RPC_AUTH_GSS:396396- ret = check_gss_callback_principal(clp, rqstp);397397- break;398398- default:399399- ret = SVC_DENIED;404404+ case RPC_AUTH_NULL:405405+ if (rqstp->rq_proc != CB_NULL)406406+ return SVC_DROP;407407+ break;408408+ case RPC_AUTH_GSS:409409+ /* No RPC_AUTH_GSS support yet in NFSv4.1 */410410+ if (svc_is_backchannel(rqstp))411411+ return SVC_DROP;400412 }401401- nfs_put_client(clp);402402- return ret;413413+ return SVC_OK;403414}404415405416/*
···373373{374374 struct nfs_client *clp;375375 int i;376376- __be32 status;376376+ __be32 status = htonl(NFS4ERR_BADSESSION);377377378378 cps->clp = NULL;379379380380- status = htonl(NFS4ERR_BADSESSION);381381- /* Incoming session must match the callback session */382382- if (memcmp(&args->csa_sessionid, cps->svc_sid, NFS4_MAX_SESSIONID_LEN))383383- goto out;384384-385385- clp = nfs4_find_client_sessionid(args->csa_addr,386386- &args->csa_sessionid, 1);380380+ clp = nfs4_find_client_sessionid(args->csa_addr, &args->csa_sessionid);387381 if (clp == NULL)388382 goto out;389383···408414 res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;409415 res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;410416 nfs4_cb_take_slot(clp);411411- cps->clp = clp; /* put in nfs4_callback_compound */412417413418out:419419+ cps->clp = clp; /* put in nfs4_callback_compound */414420 for (i = 0; i < args->csa_nrclists; i++)415421 kfree(args->csa_rclists[i].rcl_refcalls);416422 kfree(args->csa_rclists);
+2-3
fs/nfs/callback_xdr.c
···794794795795 if (hdr_arg.minorversion == 0) {796796 cps.clp = nfs4_find_client_ident(hdr_arg.cb_ident);797797- if (!cps.clp)797797+ if (!cps.clp || !check_gss_callback_principal(cps.clp, rqstp))798798 return rpc_drop_reply;799799- } else800800- cps.svc_sid = bc_xprt_sid(rqstp);799799+ }801800802801 hdr_res.taglen = hdr_arg.taglen;803802 hdr_res.tag = hdr_arg.tag;
+5-10
fs/nfs/client.c
···12061206 * For CB_COMPOUND calls, find a client by IP address, protocol version,12071207 * minorversion, and sessionID12081208 *12091209- * CREATE_SESSION triggers a CB_NULL ping from servers. The callback service12101210- * sessionid can only be set after the CREATE_SESSION return, so a CB_NULL12111211- * can arrive before the callback sessionid is set. For CB_NULL calls,12121212- * find a client by IP address protocol version, and minorversion.12131213- *12141209 * Returns NULL if no such client12151210 */12161211struct nfs_client *12171212nfs4_find_client_sessionid(const struct sockaddr *addr,12181218- struct nfs4_sessionid *sid, int is_cb_compound)12131213+ struct nfs4_sessionid *sid)12191214{12201215 struct nfs_client *clp;12211216···12221227 if (!nfs4_has_session(clp))12231228 continue;1224122912251225- /* Match sessionid unless cb_null call*/12261226- if (is_cb_compound && (memcmp(clp->cl_session->sess_id.data,12271227- sid->data, NFS4_MAX_SESSIONID_LEN) != 0))12301230+ /* Match sessionid*/12311231+ if (memcmp(clp->cl_session->sess_id.data,12321232+ sid->data, NFS4_MAX_SESSIONID_LEN) != 0)12281233 continue;1229123412301235 atomic_inc(&clp->cl_count);···1239124412401245struct nfs_client *12411246nfs4_find_client_sessionid(const struct sockaddr *addr,12421242- struct nfs4_sessionid *sid, int is_cb_compound)12471247+ struct nfs4_sessionid *sid)12431248{12441249 return NULL;12451250}
···311311 if (!nfs_server_capable(inode, NFS_CAP_ACLS))312312 goto out;313313314314- /* We are doing this here, because XDR marshalling can only315315- return -ENOMEM. */314314+ /* We are doing this here because XDR marshalling does not315315+ * return any results, it BUGs. */316316 status = -ENOSPC;317317 if (acl != NULL && acl->a_count > NFS_ACL_MAX_ENTRIES)318318 goto out;
···214214215215 /* ipv6 length plus port is legal */216216 if (rlen > INET6_ADDRSTRLEN + 8) {217217- dprintk("%s Invalid address, length %d\n", __func__,217217+ dprintk("%s: Invalid address, length %d\n", __func__,218218 rlen);219219 goto out_err;220220 }···225225 /* replace the port dots with dashes for the in4_pton() delimiter*/226226 for (i = 0; i < 2; i++) {227227 char *res = strrchr(buf, '.');228228+ if (!res) {229229+ dprintk("%s: Failed finding expected dots in port\n",230230+ __func__);231231+ goto out_free;232232+ }228233 *res = '-';229234 }230235···245240 port = htons((tmp[0] << 8) | (tmp[1]));246241247242 ds = nfs4_pnfs_ds_add(inode, ip_addr, port);248248- dprintk("%s Decoded address and port %s\n", __func__, buf);243243+ dprintk("%s: Decoded address and port %s\n", __func__, buf);249244out_free:250245 kfree(buf);251246out_err:
+10-20
fs/nfs/nfs4proc.c
···5050#include <linux/module.h>5151#include <linux/sunrpc/bc_xprt.h>5252#include <linux/xattr.h>5353+#include <linux/utsname.h>53545455#include "nfs4_fs.h"5556#include "delegation.h"···45734572 *p = htonl((u32)clp->cl_boot_time.tv_nsec);45744573 args.verifier = &verifier;4575457445764576- while (1) {45774577- args.id_len = scnprintf(args.id, sizeof(args.id),45784578- "%s/%s %u",45794579- clp->cl_ipaddr,45804580- rpc_peeraddr2str(clp->cl_rpcclient,45814581- RPC_DISPLAY_ADDR),45824582- clp->cl_id_uniquifier);45754575+ args.id_len = scnprintf(args.id, sizeof(args.id),45764576+ "%s/%s.%s/%u",45774577+ clp->cl_ipaddr,45784578+ init_utsname()->nodename,45794579+ init_utsname()->domainname,45804580+ clp->cl_rpcclient->cl_auth->au_flavor);4583458145844584- status = rpc_call_sync(clp->cl_rpcclient, &msg, 0);45854585-45864586- if (status != -NFS4ERR_CLID_INUSE)45874587- break;45884588-45894589- if (signalled())45904590- break;45914591-45924592- if (++clp->cl_id_uniquifier == 0)45934593- break;45944594- }45954595-45964596- status = nfs4_check_cl_exchange_flags(clp->cl_exchange_flags);45824582+ status = rpc_call_sync(clp->cl_rpcclient, &msg, 0);45834583+ if (!status)45844584+ status = nfs4_check_cl_exchange_flags(clp->cl_exchange_flags);45974585 dprintk("<-- %s status= %d\n", __func__, status);45984586 return status;45994587}
-6
fs/nfs/nfs4state.c
···232232 status = nfs4_proc_create_session(clp);233233 if (status != 0)234234 goto out;235235- status = nfs4_set_callback_sessionid(clp);236236- if (status != 0) {237237- printk(KERN_WARNING "Sessionid not set. No callback service\n");238238- nfs_callback_down(1);239239- status = 0;240240- }241235 nfs41_setup_state_renewal(clp);242236 nfs_mark_client_ready(clp, NFS_CS_READY);243237out:
+3-6
fs/nfs/nfs4xdr.c
···60866086 __be32 *p = xdr_inline_decode(xdr, 4);60876087 if (unlikely(!p))60886088 goto out_overflow;60896089- if (!ntohl(*p++)) {60896089+ if (*p == xdr_zero) {60906090 p = xdr_inline_decode(xdr, 4);60916091 if (unlikely(!p))60926092 goto out_overflow;60936093- if (!ntohl(*p++))60936093+ if (*p == xdr_zero)60946094 return -EAGAIN;60956095 entry->eof = 1;60966096 return -EBADCOOKIE;···61016101 goto out_overflow;61026102 entry->prev_cookie = entry->cookie;61036103 p = xdr_decode_hyper(p, &entry->cookie);61046104- entry->len = ntohl(*p++);61046104+ entry->len = be32_to_cpup(p);6105610561066106 p = xdr_inline_decode(xdr, entry->len);61076107 if (unlikely(!p))···61316131 entry->d_type = DT_UNKNOWN;61326132 if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE)61336133 entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);61346134-61356135- if (verify_attr_len(xdr, p, len) < 0)61366136- goto out_overflow;6137613461386135 return 0;61396136
+1-1
fs/nfs/pnfs.c
···951951{952952 struct pnfs_deviceid_cache *local = clp->cl_devid_cache;953953954954- dprintk("--> %s cl_devid_cache %p\n", __func__, clp->cl_devid_cache);954954+ dprintk("--> %s ({%d})\n", __func__, atomic_read(&local->dc_ref));955955 if (atomic_dec_and_lock(&local->dc_ref, &clp->cl_lock)) {956956 int i;957957 /* Verify cache is empty */
+1-1
fs/nfs/write.c
···932932 while (!list_empty(&list)) {933933 data = list_entry(list.next, struct nfs_write_data, pages);934934 list_del(&data->pages);935935- nfs_writedata_release(data);935935+ nfs_writedata_free(data);936936 }937937 nfs_redirty_request(req);938938 return -ENOMEM;
+41-13
fs/nfs_common/nfsacl.c
···4242 gid_t gid;4343};44444545+struct nfsacl_simple_acl {4646+ struct posix_acl acl;4747+ struct posix_acl_entry ace[4];4848+};4949+4550static int4651xdr_nfsace_encode(struct xdr_array2_desc *desc, void *elem)4752{···7772 return 0;7873}79748080-unsigned int8181-nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,8282- struct posix_acl *acl, int encode_entries, int typeflag)7575+/**7676+ * nfsacl_encode - Encode an NFSv3 ACL7777+ *7878+ * @buf: destination xdr_buf to contain XDR encoded ACL7979+ * @base: byte offset in xdr_buf where XDR'd ACL begins8080+ * @inode: inode of file whose ACL this is8181+ * @acl: posix_acl to encode8282+ * @encode_entries: whether to encode ACEs as well8383+ * @typeflag: ACL type: NFS_ACL_DEFAULT or zero8484+ *8585+ * Returns size of encoded ACL in bytes or a negative errno value.8686+ */8787+int nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,8888+ struct posix_acl *acl, int encode_entries, int typeflag)8389{8490 int entries = (acl && acl->a_count) ? max_t(int, acl->a_count, 4) : 0;8591 struct nfsacl_encode_desc nfsacl_desc = {···10488 .uid = inode->i_uid,10589 .gid = inode->i_gid,10690 };9191+ struct nfsacl_simple_acl aclbuf;10792 int err;108108- struct posix_acl *acl2 = NULL;1099311094 if (entries > NFS_ACL_MAX_ENTRIES ||11195 xdr_encode_word(buf, base, entries))11296 return -EINVAL;11397 if (encode_entries && acl && acl->a_count == 3) {114114- /* Fake up an ACL_MASK entry. */115115- acl2 = posix_acl_alloc(4, GFP_KERNEL);116116- if (!acl2)117117- return -ENOMEM;9898+ struct posix_acl *acl2 = &aclbuf.acl;9999+100100+ /* Avoid the use of posix_acl_alloc(). nfsacl_encode() is101101+ * invoked in contexts where a memory allocation failure is102102+ * fatal. Fortunately this fake ACL is small enough to103103+ * construct on the stack. */104104+ memset(acl2, 0, sizeof(acl2));105105+ posix_acl_init(acl2, 4);106106+118107 /* Insert entries in canonical order: other orders seem119108 to confuse Solaris VxFS. */120109 acl2->a_entries[0] = acl->a_entries[0]; /* ACL_USER_OBJ */···130109 nfsacl_desc.acl = acl2;131110 }132111 err = xdr_encode_array2(buf, base + 4, &nfsacl_desc.desc);133133- if (acl2)134134- posix_acl_release(acl2);135112 if (!err)136113 err = 8 + nfsacl_desc.desc.elem_size *137114 nfsacl_desc.desc.array_len;···243224 return 0;244225}245226246246-unsigned int247247-nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,248248- struct posix_acl **pacl)227227+/**228228+ * nfsacl_decode - Decode an NFSv3 ACL229229+ *230230+ * @buf: xdr_buf containing XDR'd ACL data to decode231231+ * @base: byte offset in xdr_buf where XDR'd ACL begins232232+ * @aclcnt: count of ACEs in decoded posix_acl233233+ * @pacl: buffer in which to place decoded posix_acl234234+ *235235+ * Returns the length of the decoded ACL in bytes, or a negative errno value.236236+ */237237+int nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,238238+ struct posix_acl **pacl)249239{250240 struct nfsacl_decode_desc nfsacl_desc = {251241 .desc = {
+7-4
fs/ntfs/mft.c
···11/**22 * mft.c - NTFS kernel mft record operations. Part of the Linux-NTFS project.33 *44- * Copyright (c) 2001-2006 Anton Altaparmakov44+ * Copyright (c) 2001-2011 Anton Altaparmakov and Tuxera Inc.55 * Copyright (c) 2002 Richard Russon66 *77 * This program/include file is free software; you can redistribute it and/or···25762576 flush_dcache_page(page);25772577 SetPageUptodate(page);25782578 if (base_ni) {25792579+ MFT_RECORD *m_tmp;25802580+25792581 /*25802582 * Setup the base mft record in the extent mft record. This25812583 * completes initialization of the allocated extent mft record···25902588 * attach it to the base inode @base_ni and map, pin, and lock25912589 * its, i.e. the allocated, mft record.25922590 */25932593- m = map_extent_mft_record(base_ni, bit, &ni);25942594- if (IS_ERR(m)) {25912591+ m_tmp = map_extent_mft_record(base_ni, bit, &ni);25922592+ if (IS_ERR(m_tmp)) {25952593 ntfs_error(vol->sb, "Failed to map allocated extent "25962594 "mft record 0x%llx.", (long long)bit);25972597- err = PTR_ERR(m);25952595+ err = PTR_ERR(m_tmp);25982596 /* Set the mft record itself not in use. */25992597 m->flags &= cpu_to_le16(26002598 ~le16_to_cpu(MFT_RECORD_IN_USE));···26052603 ntfs_unmap_page(page);26062604 goto undo_mftbmp_alloc;26072605 }26062606+ BUG_ON(m != m_tmp);26082607 /*26092608 * Make sure the allocated mft record is written out to disk.26102609 * No need to set the inode dirty because the caller is going
+13-4
fs/posix_acl.c
···22222323#include <linux/errno.h>24242525+EXPORT_SYMBOL(posix_acl_init);2526EXPORT_SYMBOL(posix_acl_alloc);2627EXPORT_SYMBOL(posix_acl_clone);2728EXPORT_SYMBOL(posix_acl_valid);···3332EXPORT_SYMBOL(posix_acl_permission);34333534/*3535+ * Init a fresh posix_acl3636+ */3737+void3838+posix_acl_init(struct posix_acl *acl, int count)3939+{4040+ atomic_set(&acl->a_refcount, 1);4141+ acl->a_count = count;4242+}4343+4444+/*3645 * Allocate a new ACL with the specified number of entries.3746 */3847struct posix_acl *···5140 const size_t size = sizeof(struct posix_acl) +5241 count * sizeof(struct posix_acl_entry);5342 struct posix_acl *acl = kmalloc(size, flags);5454- if (acl) {5555- atomic_set(&acl->a_refcount, 1);5656- acl->a_count = count;5757- }4343+ if (acl)4444+ posix_acl_init(acl, count);5845 return acl;5946}6047
+18-2
fs/xfs/linux-2.6/xfs_ioctl.c
···985985986986 /*987987 * Extent size must be a multiple of the appropriate block988988- * size, if set at all.988988+ * size, if set at all. It must also be smaller than the989989+ * maximum extent size supported by the filesystem.990990+ *991991+ * Also, for non-realtime files, limit the extent size hint to992992+ * half the size of the AGs in the filesystem so alignment993993+ * doesn't result in extents larger than an AG.989994 */990995 if (fa->fsx_extsize != 0) {991991- xfs_extlen_t size;996996+ xfs_extlen_t size;997997+ xfs_fsblock_t extsize_fsb;998998+999999+ extsize_fsb = XFS_B_TO_FSB(mp, fa->fsx_extsize);10001000+ if (extsize_fsb > MAXEXTLEN) {10011001+ code = XFS_ERROR(EINVAL);10021002+ goto error_return;10031003+ }99210049931005 if (XFS_IS_REALTIME_INODE(ip) ||9941006 ((mask & FSX_XFLAGS) &&···1009997 mp->m_sb.sb_blocklog;1010998 } else {1011999 size = mp->m_sb.sb_blocksize;10001000+ if (extsize_fsb > mp->m_sb.sb_agblocks / 2) {10011001+ code = XFS_ERROR(EINVAL);10021002+ goto error_return;10031003+ }10121004 }1013100510141006 if (fa->fsx_extsize % size) {
+21-25
fs/xfs/quota/xfs_qm.c
···18631863 xfs_dquot_t *dqpout;18641864 xfs_dquot_t *dqp;18651865 int restarts;18661866+ int startagain;1866186718671868 restarts = 0;18681869 dqpout = NULL;1869187018701871 /* lockorder: hashchainlock, freelistlock, mplistlock, dqlock, dqflock */18711871-startagain:18721872+again:18731873+ startagain = 0;18721874 mutex_lock(&xfs_Gqm->qm_dqfrlist_lock);1873187518741876 list_for_each_entry(dqp, &xfs_Gqm->qm_dqfrlist, q_freelist) {···18871885 ASSERT(! (dqp->dq_flags & XFS_DQ_INACTIVE));1888188618891887 trace_xfs_dqreclaim_want(dqp);18901890-18911891- xfs_dqunlock(dqp);18921892- mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);18931893- if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)18941894- return NULL;18951888 XQM_STATS_INC(xqmstats.xs_qm_dqwants);18961896- goto startagain;18891889+ restarts++;18901890+ startagain = 1;18911891+ goto dqunlock;18971892 }1898189318991894 /*···19051906 ASSERT(list_empty(&dqp->q_mplist));19061907 list_del_init(&dqp->q_freelist);19071908 xfs_Gqm->qm_dqfrlist_cnt--;19081908- xfs_dqunlock(dqp);19091909 dqpout = dqp;19101910 XQM_STATS_INC(xqmstats.xs_qm_dqinact_reclaims);19111911- break;19111911+ goto dqunlock;19121912 }1913191319141914 ASSERT(dqp->q_hash);19151915 ASSERT(!list_empty(&dqp->q_mplist));1916191619171917 /*19181918- * Try to grab the flush lock. If this dquot is in the process of19191919- * getting flushed to disk, we don't want to reclaim it.19181918+ * Try to grab the flush lock. If this dquot is in the process19191919+ * of getting flushed to disk, we don't want to reclaim it.19201920 */19211921- if (!xfs_dqflock_nowait(dqp)) {19221922- xfs_dqunlock(dqp);19231923- continue;19241924- }19211921+ if (!xfs_dqflock_nowait(dqp))19221922+ goto dqunlock;1925192319261924 /*19271925 * We have the flush lock so we know that this is not in the···19401944 xfs_fs_cmn_err(CE_WARN, mp,19411945 "xfs_qm_dqreclaim: dquot %p flush failed", dqp);19421946 }19431943- xfs_dqunlock(dqp); /* dqflush unlocks dqflock */19441944- continue;19471947+ goto dqunlock;19451948 }1946194919471950 /*···19621967 */19631968 if (!mutex_trylock(&mp->m_quotainfo->qi_dqlist_lock)) {19641969 restarts++;19651965- mutex_unlock(&dqp->q_hash->qh_lock);19661966- xfs_dqfunlock(dqp);19671967- xfs_dqunlock(dqp);19681968- mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);19691969- if (restarts++ >= XFS_QM_RECLAIM_MAX_RESTARTS)19701970- return NULL;19711971- goto startagain;19701970+ startagain = 1;19711971+ goto qhunlock;19721972 }1973197319741974 ASSERT(dqp->q_nrefs == 0);···19761986 xfs_Gqm->qm_dqfrlist_cnt--;19771987 dqpout = dqp;19781988 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock);19891989+qhunlock:19791990 mutex_unlock(&dqp->q_hash->qh_lock);19801991dqfunlock:19811992 xfs_dqfunlock(dqp);19931993+dqunlock:19821994 xfs_dqunlock(dqp);19831995 if (dqpout)19841996 break;19851997 if (restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)19861986- return NULL;19981998+ break;19991999+ if (startagain) {20002000+ mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);20012001+ goto again;20022002+ }19872003 }19882004 mutex_unlock(&xfs_Gqm->qm_dqfrlist_lock);19892005 return dqpout;
+16
fs/xfs/xfs_alloc.h
···7575#define XFS_ALLOC_SET_ASIDE(mp) (4 + ((mp)->m_sb.sb_agcount * 4))76767777/*7878+ * When deciding how much space to allocate out of an AG, we limit the7979+ * allocation maximum size to the size the AG. However, we cannot use all the8080+ * blocks in the AG - some are permanently used by metadata. These8181+ * blocks are generally:8282+ * - the AG superblock, AGF, AGI and AGFL8383+ * - the AGF (bno and cnt) and AGI btree root blocks8484+ * - 4 blocks on the AGFL according to XFS_ALLOC_SET_ASIDE() limits8585+ *8686+ * The AG headers are sector sized, so the amount of space they take up is8787+ * dependent on filesystem geometry. The others are all single blocks.8888+ */8989+#define XFS_ALLOC_AG_MAX_USABLE(mp) \9090+ ((mp)->m_sb.sb_agblocks - XFS_BB_TO_FSB(mp, XFS_FSS_TO_BB(mp, 4)) - 7)9191+9292+9393+/*7894 * Argument structure for xfs_alloc routines.7995 * This is turned into a structure to avoid having 20 arguments passed8096 * down several levels of the stack.
+45-16
fs/xfs/xfs_bmap.c
···10381038 * Filling in the middle part of a previous delayed allocation.10391039 * Contiguity is impossible here.10401040 * This case is avoided almost all the time.10411041+ *10421042+ * We start with a delayed allocation:10431043+ *10441044+ * +ddddddddddddddddddddddddddddddddddddddddddddddddddddddd+10451045+ * PREV @ idx10461046+ *10471047+ * and we are allocating:10481048+ * +rrrrrrrrrrrrrrrrr+10491049+ * new10501050+ *10511051+ * and we set it up for insertion as:10521052+ * +ddddddddddddddddddd+rrrrrrrrrrrrrrrrr+ddddddddddddddddd+10531053+ * new10541054+ * PREV @ idx LEFT RIGHT10551055+ * inserted at idx + 110411056 */10421057 temp = new->br_startoff - PREV.br_startoff;10431043- trace_xfs_bmap_pre_update(ip, idx, 0, _THIS_IP_);10441044- xfs_bmbt_set_blockcount(ep, temp);10451045- r[0] = *new;10461046- r[1].br_state = PREV.br_state;10471047- r[1].br_startblock = 0;10481048- r[1].br_startoff = new_endoff;10491058 temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff;10501050- r[1].br_blockcount = temp2;10511051- xfs_iext_insert(ip, idx + 1, 2, &r[0], state);10591059+ trace_xfs_bmap_pre_update(ip, idx, 0, _THIS_IP_);10601060+ xfs_bmbt_set_blockcount(ep, temp); /* truncate PREV */10611061+ LEFT = *new;10621062+ RIGHT.br_state = PREV.br_state;10631063+ RIGHT.br_startblock = nullstartblock(10641064+ (int)xfs_bmap_worst_indlen(ip, temp2));10651065+ RIGHT.br_startoff = new_endoff;10661066+ RIGHT.br_blockcount = temp2;10671067+ /* insert LEFT (r[0]) and RIGHT (r[1]) at the same time */10681068+ xfs_iext_insert(ip, idx + 1, 2, &LEFT, state);10521069 ip->i_df.if_lastex = idx + 1;10531070 ip->i_d.di_nextents++;10541071 if (cur == NULL)···24472430 startag = ag = 0;2448243124492432 pag = xfs_perag_get(mp, ag);24502450- while (*blen < ap->alen) {24332433+ while (*blen < args->maxlen) {24512434 if (!pag->pagf_init) {24522435 error = xfs_alloc_pagf_init(mp, args->tp, ag,24532436 XFS_ALLOC_FLAG_TRYLOCK);···24692452 notinit = 1;2470245324712454 if (xfs_inode_is_filestream(ap->ip)) {24722472- if (*blen >= ap->alen)24552455+ if (*blen >= args->maxlen)24732456 break;2474245724752458 if (ap->userdata) {···25152498 * If the best seen length is less than the request25162499 * length, use the best as the minimum.25172500 */25182518- else if (*blen < ap->alen)25012501+ else if (*blen < args->maxlen)25192502 args->minlen = *blen;25202503 /*25212521- * Otherwise we've seen an extent as big as alen,25042504+ * Otherwise we've seen an extent as big as maxlen,25222505 * use that as the minimum.25232506 */25242507 else25252525- args->minlen = ap->alen;25082508+ args->minlen = args->maxlen;2526250925272510 /*25282511 * set the failure fallback case to look in the selected···25902573 args.tp = ap->tp;25912574 args.mp = mp;25922575 args.fsbno = ap->rval;25932593- args.maxlen = MIN(ap->alen, mp->m_sb.sb_agblocks);25762576+25772577+ /* Trim the allocation back to the maximum an AG can fit. */25782578+ args.maxlen = MIN(ap->alen, XFS_ALLOC_AG_MAX_USABLE(mp));25942579 args.firstblock = ap->firstblock;25952580 blen = 0;25962581 if (nullfb) {···26402621 /*26412622 * Adjust for alignment26422623 */26432643- if (blen > args.alignment && blen <= ap->alen)26242624+ if (blen > args.alignment && blen <= args.maxlen)26442625 args.minlen = blen - args.alignment;26452626 args.minalignslop = 0;26462627 } else {···26592640 * of minlen+alignment+slop doesn't go up26602641 * between the calls.26612642 */26622662- if (blen > mp->m_dalign && blen <= ap->alen)26432643+ if (blen > mp->m_dalign && blen <= args.maxlen)26632644 nextminlen = blen - mp->m_dalign;26642645 else26652646 nextminlen = args.minlen;···45044485 /* Figure out the extent size, adjust alen */45054486 extsz = xfs_get_extsz_hint(ip);45064487 if (extsz) {44884488+ /*44894489+ * make sure we don't exceed a single44904490+ * extent length when we align the44914491+ * extent by reducing length we are44924492+ * going to allocate by the maximum44934493+ * amount extent size aligment may44944494+ * require.44954495+ */44964496+ alen = XFS_FILBLKS_MIN(len,44974497+ MAXEXTLEN - (2 * extsz - 1));45074498 error = xfs_bmap_extsize_align(mp,45084499 &got, &prev, extsz,45094500 rt, eof,
+7-5
fs/xfs/xfs_buf_item.c
···427427428428 if (remove) {429429 /*430430- * We have to remove the log item from the transaction431431- * as we are about to release our reference to the432432- * buffer. If we don't, the unlock that occurs later433433- * in xfs_trans_uncommit() will ry to reference the430430+ * If we are in a transaction context, we have to431431+ * remove the log item from the transaction as we are432432+ * about to release our reference to the buffer. If we433433+ * don't, the unlock that occurs later in434434+ * xfs_trans_uncommit() will try to reference the434435 * buffer which we no longer have a hold on.435436 */436436- xfs_trans_del_item(lip);437437+ if (lip->li_desc)438438+ xfs_trans_del_item(lip);437439438440 /*439441 * Since the transaction no longer refers to the buffer,
+2-1
fs/xfs/xfs_extfree_item.c
···138138139139 if (remove) {140140 ASSERT(!(lip->li_flags & XFS_LI_IN_AIL));141141- xfs_trans_del_item(lip);141141+ if (lip->li_desc)142142+ xfs_trans_del_item(lip);142143 xfs_efi_item_free(efip);143144 return;144145 }
+6-1
fs/xfs/xfs_iomap.c
···337337 int shift = 0;338338 int64_t freesp;339339340340- alloc_blocks = XFS_B_TO_FSB(mp, ip->i_size);340340+ /*341341+ * rounddown_pow_of_two() returns an undefined result342342+ * if we pass in alloc_blocks = 0. Hence the "+ 1" to343343+ * ensure we always pass in a non-zero value.344344+ */345345+ alloc_blocks = XFS_B_TO_FSB(mp, ip->i_size) + 1;341346 alloc_blocks = XFS_FILEOFF_MIN(MAXEXTLEN,342347 rounddown_pow_of_two(alloc_blocks));343348
···543543544544 error = xlog_write(log, &lvhdr, tic, &ctx->start_lsn, NULL, 0);545545 if (error)546546- goto out_abort;546546+ goto out_abort_free_ticket;547547548548 /*549549 * now that we've written the checkpoint into the log, strictly···569569 }570570 spin_unlock(&cil->xc_cil_lock);571571572572+ /* xfs_log_done always frees the ticket on error. */572573 commit_lsn = xfs_log_done(log->l_mp, tic, &commit_iclog, 0);573573- if (error || commit_lsn == -1)574574+ if (commit_lsn == -1)574575 goto out_abort;575576576577 /* attach all the transactions w/ busy extents to iclog */···601600 kmem_free(new_ctx);602601 return 0;603602603603+out_abort_free_ticket:604604+ xfs_log_ticket_put(tic);604605out_abort:605606 xlog_cil_committed(ctx, XFS_LI_ABORTED);606607 return XFS_ERROR(EIO);···625622 * background commit, returns without it held once background commits are626623 * allowed again.627624 */628628-int625625+void629626xfs_log_commit_cil(630627 struct xfs_mount *mp,631628 struct xfs_trans *tp,···639636640637 if (flags & XFS_TRANS_RELEASE_LOG_RES)641638 log_flags = XFS_LOG_REL_PERM_RESERV;642642-643643- if (XLOG_FORCED_SHUTDOWN(log)) {644644- xlog_cil_free_logvec(log_vector);645645- return XFS_ERROR(EIO);646646- }647639648640 /*649641 * do all the hard work of formatting items (including memory···699701 */700702 if (push)701703 xlog_cil_push(log, 0);702702- return 0;703704}704705705706/*
+30-11
fs/xfs/xfs_trans.c
···14461446 * Bulk operation version of xfs_trans_committed that takes a log vector of14471447 * items to insert into the AIL. This uses bulk AIL insertion techniques to14481448 * minimise lock traffic.14491449+ *14501450+ * If we are called with the aborted flag set, it is because a log write during14511451+ * a CIL checkpoint commit has failed. In this case, all the items in the14521452+ * checkpoint have already gone through IOP_COMMITED and IOP_UNLOCK, which14531453+ * means that checkpoint commit abort handling is treated exactly the same14541454+ * as an iclog write error even though we haven't started any IO yet. Hence in14551455+ * this case all we need to do is IOP_COMMITTED processing, followed by an14561456+ * IOP_UNPIN(aborted) call.14491457 */14501458void14511459xfs_trans_committed_bulk(···14791471 /* item_lsn of -1 means the item was freed */14801472 if (XFS_LSN_CMP(item_lsn, (xfs_lsn_t)-1) == 0)14811473 continue;14741474+14751475+ /*14761476+ * if we are aborting the operation, no point in inserting the14771477+ * object into the AIL as we are in a shutdown situation.14781478+ */14791479+ if (aborted) {14801480+ ASSERT(XFS_FORCED_SHUTDOWN(ailp->xa_mount));14811481+ IOP_UNPIN(lip, 1);14821482+ continue;14831483+ }1482148414831485 if (item_lsn != commit_lsn) {14841486···15211503}1522150415231505/*15241524- * Called from the trans_commit code when we notice that15251525- * the filesystem is in the middle of a forced shutdown.15061506+ * Called from the trans_commit code when we notice that the filesystem is in15071507+ * the middle of a forced shutdown.15081508+ *15091509+ * When we are called here, we have already pinned all the items in the15101510+ * transaction. However, neither IOP_COMMITTING or IOP_UNLOCK has been called15111511+ * so we can simply walk the items in the transaction, unpin them with an abort15121512+ * flag and then free the items. Note that unpinning the items can result in15131513+ * them being freed immediately, so we need to use a safe list traversal method15141514+ * here.15261515 */15271516STATIC void15281517xfs_trans_uncommit(15291518 struct xfs_trans *tp,15301519 uint flags)15311520{15321532- struct xfs_log_item_desc *lidp;15211521+ struct xfs_log_item_desc *lidp, *n;1533152215341534- list_for_each_entry(lidp, &tp->t_items, lid_trans) {15351535- /*15361536- * Unpin all but those that aren't dirty.15371537- */15231523+ list_for_each_entry_safe(lidp, n, &tp->t_items, lid_trans) {15381524 if (lidp->lid_flags & XFS_LID_DIRTY)15391525 IOP_UNPIN(lidp->lid_item, 1);15401526 }···17551733 int flags)17561734{17571735 struct xfs_log_vec *log_vector;17581758- int error;1759173617601737 /*17611738 * Get each log item to allocate a vector structure for···17651744 if (!log_vector)17661745 return ENOMEM;1767174617681768- error = xfs_log_commit_cil(mp, tp, log_vector, commit_lsn, flags);17691769- if (error)17701770- return error;17471747+ xfs_log_commit_cil(mp, tp, log_vector, commit_lsn, flags);1771174817721749 current_restore_flags_nested(&tp->t_pflags, PF_FSTRANS);17731750 xfs_trans_free(tp);
+1-1
include/linux/kernel.h
···588588589589/**590590 * BUILD_BUG_ON - break compile if a condition is true.591591- * @cond: the condition which the compiler should know is false.591591+ * @condition: the condition which the compiler should know is false.592592 *593593 * If you have some code which relies on certain constants being equal, or594594 * other compile-time-evaluated condition, you should use BUILD_BUG_ON to
+2-2
include/linux/nfsacl.h
···5151 return w;5252}53535454-extern unsigned int5454+extern int5555nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,5656 struct posix_acl *acl, int encode_entries, int typeflag);5757-extern unsigned int5757+extern int5858nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,5959 struct posix_acl **pacl);6060
···7777 size_t xpt_remotelen; /* length of address */7878 struct rpc_wait_queue xpt_bc_pending; /* backchannel wait queue */7979 struct list_head xpt_users; /* callbacks on free */8080- void *xpt_bc_sid; /* back channel session ID */81808281 struct net *xpt_net;8382 struct rpc_xprt *xpt_bc_xprt; /* NFSv4.1 backchannel */
+1
include/linux/usb/hcd.h
···112112 /* Flags that get set only during HCD registration or removal. */113113 unsigned rh_registered:1;/* is root hub registered? */114114 unsigned rh_pollable:1; /* may we poll the root hub? */115115+ unsigned msix_enabled:1; /* driver has MSI-X enabled? */115116116117 /* The next flag is a stopgap, to be removed when all the HCDs117118 * support the new root-hub polling mechanism. */
+3
include/linux/usb/serial.h
···347347extern int usb_serial_handle_sysrq_char(struct usb_serial_port *port,348348 unsigned int ch);349349extern int usb_serial_handle_break(struct usb_serial_port *port);350350+extern void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port,351351+ struct tty_struct *tty,352352+ unsigned int status);350353351354352355extern int usb_serial_bus_register(struct usb_serial_driver *device);
···722722 u64 now, delta;723723 unsigned long load = cfs_rq->load.weight;724724725725- if (!cfs_rq)725725+ if (cfs_rq->tg == &root_task_group)726726 return;727727728728- now = rq_of(cfs_rq)->clock;728728+ now = rq_of(cfs_rq)->clock_task;729729 delta = now - cfs_rq->load_stamp;730730731731 /* truncate load history at 4 idle periods */···829829 struct task_group *tg;830830 struct sched_entity *se;831831 long shares;832832-833833- if (!cfs_rq)834834- return;835832836833 tg = cfs_rq->tg;837834 se = tg->se[cpu_of(rq_of(cfs_rq))];···1429143214301433static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)14311434{14321432- unsigned long this_load, load;14351435+ s64 this_load, load;14331436 int idx, this_cpu, prev_cpu;14341437 unsigned long tl_per_task;14351438 struct task_group *tg;···14681471 * Otherwise check if either cpus are near enough in load to allow this14691472 * task to be woken on this_cpu.14701473 */14711471- if (this_load) {14721472- unsigned long this_eff_load, prev_eff_load;14741474+ if (this_load > 0) {14751475+ s64 this_eff_load, prev_eff_load;1473147614741477 this_eff_load = 100;14751478 this_eff_load *= power_of(prev_cpu);
···315315316316 rb_augment_path(node, func, data);317317}318318+EXPORT_SYMBOL(rb_augment_insert);318319319320/*320321 * before removing the node, find the deepest node on the rebalance path···341340342341 return deepest;343342}343343+EXPORT_SYMBOL(rb_augment_erase_begin);344344345345/*346346 * after removal, update the tree to account for the removed entry···352350 if (node)353351 rb_augment_path(node, func, data);354352}353353+EXPORT_SYMBOL(rb_augment_erase_end);355354356355/*357356 * This function returns the first node (in sort order) of the tree.
+5-5
lib/textsearch.c
···1313 *1414 * INTRODUCTION1515 *1616- * The textsearch infrastructure provides text searching facitilies for1616+ * The textsearch infrastructure provides text searching facilities for1717 * both linear and non-linear data. Individual search algorithms are1818 * implemented in modules and chosen by the user.1919 *···4343 * to the algorithm to store persistent variables.4444 * (4) Core eventually resets the search offset and forwards the find()4545 * request to the algorithm.4646- * (5) Algorithm calls get_next_block() provided by the user continously4646+ * (5) Algorithm calls get_next_block() provided by the user continuously4747 * to fetch the data to be searched in block by block.4848 * (6) Algorithm invokes finish() after the last call to get_next_block4949 * to clean up any leftovers from get_next_block. (Optional)···5858 * the pattern to look for and flags. As a flag, you can set TS_IGNORECASE5959 * to perform case insensitive matching. But it might slow down6060 * performance of algorithm, so you should use it at own your risk.6161- * The returned configuration may then be used for an arbitary6161+ * The returned configuration may then be used for an arbitrary6262 * amount of times and even in parallel as long as a separate struct6363 * ts_state variable is provided to every instance.6464 *6565 * The actual search is performed by either calling textsearch_find_-6666 * continuous() for linear data or by providing an own get_next_block()6767 * implementation and calling textsearch_find(). Both functions return6868- * the position of the first occurrence of the patern or UINT_MAX if6969- * no match was found. Subsequent occurences can be found by calling6868+ * the position of the first occurrence of the pattern or UINT_MAX if6969+ * no match was found. Subsequent occurrences can be found by calling7070 * textsearch_next() regardless of the linearity of the data.7171 *7272 * Once you're done using a configuration it must be given back via
+2-4
mm/kmemleak-test.c
···7575 * after the module is removed.7676 */7777 for (i = 0; i < 10; i++) {7878- elem = kmalloc(sizeof(*elem), GFP_KERNEL);7979- pr_info("kmemleak: kmalloc(sizeof(*elem)) = %p\n", elem);7878+ elem = kzalloc(sizeof(*elem), GFP_KERNEL);7979+ pr_info("kmemleak: kzalloc(sizeof(*elem)) = %p\n", elem);8080 if (!elem)8181 return -ENOMEM;8282- memset(elem, 0, sizeof(*elem));8382 INIT_LIST_HEAD(&elem->list);8484-8583 list_add_tail(&elem->list, &test_list);8684 }8785
+8-5
mm/kmemleak.c
···113113#define BYTES_PER_POINTER sizeof(void *)114114115115/* GFP bitmask for kmemleak internal allocations */116116-#define GFP_KMEMLEAK_MASK (GFP_KERNEL | GFP_ATOMIC)116116+#define gfp_kmemleak_mask(gfp) (((gfp) & (GFP_KERNEL | GFP_ATOMIC)) | \117117+ __GFP_NORETRY | __GFP_NOMEMALLOC | \118118+ __GFP_NOWARN)117119118120/* scanning area inside a memory block */119121struct kmemleak_scan_area {···513511 struct kmemleak_object *object;514512 struct prio_tree_node *node;515513516516- object = kmem_cache_alloc(object_cache, gfp & GFP_KMEMLEAK_MASK);514514+ object = kmem_cache_alloc(object_cache, gfp_kmemleak_mask(gfp));517515 if (!object) {518518- kmemleak_stop("Cannot allocate a kmemleak_object structure\n");516516+ pr_warning("Cannot allocate a kmemleak_object structure\n");517517+ kmemleak_disable();519518 return NULL;520519 }521520···737734 return;738735 }739736740740- area = kmem_cache_alloc(scan_area_cache, gfp & GFP_KMEMLEAK_MASK);737737+ area = kmem_cache_alloc(scan_area_cache, gfp_kmemleak_mask(gfp));741738 if (!area) {742742- kmemleak_warn("Cannot allocate a scan area\n");739739+ pr_warning("Cannot allocate a scan area\n");743740 goto out;744741 }745742
+9-7
net/bluetooth/hci_conn.c
···379379 hci_conn_hold(acl);380380381381 if (acl->state == BT_OPEN || acl->state == BT_CLOSED) {382382- acl->sec_level = sec_level;382382+ acl->sec_level = BT_SECURITY_LOW;383383+ acl->pending_sec_level = sec_level;383384 acl->auth_type = auth_type;384385 hci_acl_connect(acl);385385- } else {386386- if (acl->sec_level < sec_level)387387- acl->sec_level = sec_level;388388- if (acl->auth_type < auth_type)389389- acl->auth_type = auth_type;390386 }391387392388 if (type == ACL_LINK)···438442{439443 BT_DBG("conn %p", conn);440444445445+ if (conn->pending_sec_level > sec_level)446446+ sec_level = conn->pending_sec_level;447447+441448 if (sec_level > conn->sec_level)442442- conn->sec_level = sec_level;449449+ conn->pending_sec_level = sec_level;443450 else if (conn->link_mode & HCI_LM_AUTH)444451 return 1;452452+453453+ /* Make sure we preserve an existing MITM requirement*/454454+ auth_type |= (conn->auth_type & 0x01);445455446456 conn->auth_type = auth_type;447457
···11641164 * initiator rfcomm_process_rx already calls11651165 * rfcomm_session_put() */11661166 if (s->sock->sk->sk_state != BT_CLOSED)11671167- rfcomm_session_put(s);11671167+ if (list_empty(&s->dlcs))11681168+ rfcomm_session_put(s);11681169 break;11691170 }11701171 }
+2-1
net/core/dev.c
···749749 * @ha: hardware address750750 *751751 * Search for an interface by MAC address. Returns NULL if the device752752- * is not found or a pointer to the device. The caller must hold RCU752752+ * is not found or a pointer to the device.753753+ * The caller must hold RCU or RTNL.753754 * The returned device has not had its ref count increased754755 * and the caller must therefore be careful about locking755756 *
+1-1
net/core/ethtool.c
···817817 if (regs.len > reglen)818818 regs.len = reglen;819819820820- regbuf = vmalloc(reglen);820820+ regbuf = vzalloc(reglen);821821 if (!regbuf)822822 return -ENOMEM;823823
···26612661 struct net *net = dev_net(dev);26622662 struct inet6_dev *idev;26632663 struct inet6_ifaddr *ifa;26642664- LIST_HEAD(keep_list);26652665- int state;26642664+ int state, i;2666266526672666 ASSERT_RTNL();2668266726692669- /* Flush routes if device is being removed or it is not loopback */26702670- if (how || !(dev->flags & IFF_LOOPBACK))26712671- rt6_ifdown(net, dev);26682668+ rt6_ifdown(net, dev);26692669+ neigh_ifdown(&nd_tbl, dev);2672267026732671 idev = __in6_dev_get(dev);26742672 if (idev == NULL)···26852687 /* Step 1.5: remove snmp6 entry */26862688 snmp6_unregister_dev(idev);2687268926902690+ }26912691+26922692+ /* Step 2: clear hash table */26932693+ for (i = 0; i < IN6_ADDR_HSIZE; i++) {26942694+ struct hlist_head *h = &inet6_addr_lst[i];26952695+ struct hlist_node *n;26962696+26972697+ spin_lock_bh(&addrconf_hash_lock);26982698+ restart:26992699+ hlist_for_each_entry_rcu(ifa, n, h, addr_lst) {27002700+ if (ifa->idev == idev) {27012701+ hlist_del_init_rcu(&ifa->addr_lst);27022702+ addrconf_del_timer(ifa);27032703+ goto restart;27042704+ }27052705+ }27062706+ spin_unlock_bh(&addrconf_hash_lock);26882707 }2689270826902709 write_lock_bh(&idev->lock);···27372722 struct inet6_ifaddr, if_list);27382723 addrconf_del_timer(ifa);2739272427402740- /* If just doing link down, and address is permanent27412741- and not link-local, then retain it. */27422742- if (!how &&27432743- (ifa->flags&IFA_F_PERMANENT) &&27442744- !(ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) {27452745- list_move_tail(&ifa->if_list, &keep_list);27252725+ list_del(&ifa->if_list);2746272627472747- /* If not doing DAD on this address, just keep it. */27482748- if ((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) ||27492749- idev->cnf.accept_dad <= 0 ||27502750- (ifa->flags & IFA_F_NODAD))27512751- continue;27272727+ write_unlock_bh(&idev->lock);2752272827532753- /* If it was tentative already, no need to notify */27542754- if (ifa->flags & IFA_F_TENTATIVE)27552755- continue;27292729+ spin_lock_bh(&ifa->state_lock);27302730+ state = ifa->state;27312731+ ifa->state = INET6_IFADDR_STATE_DEAD;27322732+ spin_unlock_bh(&ifa->state_lock);2756273327572757- /* Flag it for later restoration when link comes up */27582758- ifa->flags |= IFA_F_TENTATIVE;27592759- ifa->state = INET6_IFADDR_STATE_DAD;27602760- } else {27612761- list_del(&ifa->if_list);27622762-27632763- /* clear hash table */27642764- spin_lock_bh(&addrconf_hash_lock);27652765- hlist_del_init_rcu(&ifa->addr_lst);27662766- spin_unlock_bh(&addrconf_hash_lock);27672767-27682768- write_unlock_bh(&idev->lock);27692769- spin_lock_bh(&ifa->state_lock);27702770- state = ifa->state;27712771- ifa->state = INET6_IFADDR_STATE_DEAD;27722772- spin_unlock_bh(&ifa->state_lock);27732773-27742774- if (state != INET6_IFADDR_STATE_DEAD) {27752775- __ipv6_ifa_notify(RTM_DELADDR, ifa);27762776- atomic_notifier_call_chain(&inet6addr_chain,27772777- NETDEV_DOWN, ifa);27782778- }27792779-27802780- in6_ifa_put(ifa);27812781- write_lock_bh(&idev->lock);27342734+ if (state != INET6_IFADDR_STATE_DEAD) {27352735+ __ipv6_ifa_notify(RTM_DELADDR, ifa);27362736+ atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);27822737 }27832783- }27382738+ in6_ifa_put(ifa);2784273927852785- list_splice(&keep_list, &idev->addr_list);27402740+ write_lock_bh(&idev->lock);27412741+ }2786274227872743 write_unlock_bh(&idev->lock);27882744···41424156 addrconf_leave_solict(ifp->idev, &ifp->addr);41434157 dst_hold(&ifp->rt->dst);4144415841454145- if (ifp->state == INET6_IFADDR_STATE_DEAD &&41464146- ip6_del_rt(ifp->rt))41594159+ if (ip6_del_rt(ifp->rt))41474160 dst_free(&ifp->rt->dst);41484161 break;41494162 }
···9898 if (!xdst->u.rt6.rt6i_idev)9999 return -ENODEV;100100101101+ xdst->u.rt6.rt6i_peer = rt->rt6i_peer;102102+ if (rt->rt6i_peer)103103+ atomic_inc(&rt->rt6i_peer->refcnt);104104+101105 /* Sheit... I remember I did this right. Apparently,102106 * it was magically lost, so this code needs audit */103107 xdst->u.rt6.rt6i_flags = rt->rt6i_flags & (RTF_ANYCAST |···220216221217 if (likely(xdst->u.rt6.rt6i_idev))222218 in6_dev_put(xdst->u.rt6.rt6i_idev);219219+ if (likely(xdst->u.rt6.rt6i_peer))220220+ inet_putpeer(xdst->u.rt6.rt6i_peer);223221 xfrm_dst_destroy(xdst);224222}225223
···392392 unsigned int i;393393394394 snd_iprintf(buffer, "\nCS4398: 7?");395395- for (i = 2; i <= 8; ++i)395395+ for (i = 2; i < 8; ++i)396396 snd_iprintf(buffer, " %02x", data->cs4398_regs[i]);397397 snd_iprintf(buffer, "\n");398398 dump_cs4362a_registers(data, buffer);
···12231223 else12241224 val = 0;1225122512261226- return snd_soc_update_bits(codec, reg, mask, reg);12261226+ return snd_soc_update_bits(codec, reg, mask, val);12271227}1228122812291229/* The size in bits of the FLL divide multiplied by 10
+7-8
sound/soc/codecs/wm_hubs.c
···9191static void calibrate_dc_servo(struct snd_soc_codec *codec)9292{9393 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);9494+ s8 offset;9495 u16 reg, reg_l, reg_r, dcs_cfg;95969697 /* If we're using a digital only path and have a previously···150149 hubs->dcs_codes);151150152151 /* HPOUT1L */153153- if (reg_l + hubs->dcs_codes > 0 &&154154- reg_l + hubs->dcs_codes < 0xff)155155- reg_l += hubs->dcs_codes;156156- dcs_cfg = reg_l << WM8993_DCS_DAC_WR_VAL_1_SHIFT;152152+ offset = reg_l;153153+ offset += hubs->dcs_codes;154154+ dcs_cfg = (u8)offset << WM8993_DCS_DAC_WR_VAL_1_SHIFT;157155158156 /* HPOUT1R */159159- if (reg_r + hubs->dcs_codes > 0 &&160160- reg_r + hubs->dcs_codes < 0xff)161161- reg_r += hubs->dcs_codes;162162- dcs_cfg |= reg_r;157157+ offset = reg_r;158158+ offset += hubs->dcs_codes;159159+ dcs_cfg |= (u8)offset;163160164161 dev_dbg(codec->dev, "DCS result: %x\n", dcs_cfg);165162