]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelv...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Aug 2010 21:57:58 +0000 (14:57 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 14 Aug 2010 21:57:58 +0000 (14:57 -0700)
* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging: (22 commits)
  hwmon: (via-cputemp) Remove bogus "SHOW" global variable
  hwmon: jc42 depends on I2C
  hwmon: (pc87427) Add a maintainer
  hwmon: (pc87427) Move sysfs file removal to a separate function
  hwmon: (pc87427) Add temperature monitoring support
  hwmon: (pc87427) Add support for the second logical device
  hwmon: (pc87427) Add support for manual fan speed control
  hwmon: (pc87427) Minor style cleanups
  hwmon: (pc87427) Handle disabled fan inputs properly
  hwmon: (w83627ehf) Add support for W83667HG-B
  hwmon: (w83627ehf) Driver cleanup
  hwmon: Add driver for SMSC EMC2103 temperature monitor and fan controller
  hwmon: Remove in[0-*]_fault from sysfs-interface
  hwmon: Add 4 current alarm/beep attributes to sysfs-interface
  hwmon: Add 3 critical limit attributes to sysfs-interface
  hwmon: (asc7621) Clean up and improve detect function
  hwmon: (it87) Export labels for internal sensors
  hwmon: (lm75) Add suspend/resume feature
  hwmon: (emc1403) Add power support
  hwmon: (ltc4245) Expose all GPIO pins as analog voltages
  ...

74 files changed:
Documentation/DMA-API-HOWTO.txt
arch/arm/include/asm/hardware/pl080.h
arch/arm/mach-s3c64xx/Kconfig
arch/arm/mach-s3c64xx/Makefile
arch/arm/mach-s3c64xx/dma.c
arch/arm/mach-s3c64xx/include/mach/memory.h
arch/arm/mach-s3c64xx/mach-real6410.c [new file with mode: 0644]
arch/arm/mach-s3c64xx/mach-smartq.c
arch/arm/mach-s3c64xx/mach-smartq5.c
arch/arm/mach-s3c64xx/mach-smartq7.c
arch/arm/mach-s3c64xx/mach-smdk6410.c
arch/arm/mach-w90x900/include/mach/i2c.h [new file with mode: 0644]
arch/arm/plat-samsung/Kconfig
drivers/firmware/Kconfig
drivers/firmware/Makefile
drivers/i2c/busses/Kconfig
drivers/i2c/busses/Makefile
drivers/i2c/busses/i2c-davinci.c
drivers/i2c/busses/i2c-nuc900.c [new file with mode: 0644]
drivers/i2c/busses/i2c-pxa.c
drivers/message/fusion/mptbase.c
drivers/mmc/host/mmc_spi.c
drivers/scsi/Kconfig
drivers/scsi/Makefile
drivers/scsi/be2iscsi/Kconfig
drivers/scsi/be2iscsi/be_cmds.h
drivers/scsi/be2iscsi/be_iscsi.c
drivers/scsi/be2iscsi/be_iscsi.h
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/be2iscsi/be_main.h
drivers/scsi/be2iscsi/be_mgmt.c
drivers/scsi/ibmvscsi/ibmvfc.c
drivers/scsi/ibmvscsi/ibmvfc.h
drivers/scsi/iscsi_boot_sysfs.c [moved from drivers/firmware/iscsi_boot_sysfs.c with 100% similarity]
drivers/scsi/libfc/fc_fcp.c
drivers/scsi/lpfc/lpfc.h
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_bsg.c
drivers/scsi/lpfc/lpfc_compat.h
drivers/scsi/lpfc/lpfc_els.c
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/lpfc/lpfc_hw.h
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_mbox.c
drivers/scsi/lpfc/lpfc_scsi.c
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/lpfc/lpfc_version.h
drivers/scsi/pm8001/pm8001_hwi.c
drivers/scsi/qla4xxx/ql4_def.h
drivers/scsi/qla4xxx/ql4_fw.h
drivers/scsi/qla4xxx/ql4_glbl.h
drivers/scsi/qla4xxx/ql4_init.c
drivers/scsi/qla4xxx/ql4_iocb.c
drivers/scsi/qla4xxx/ql4_isr.c
drivers/scsi/qla4xxx/ql4_mbx.c
drivers/scsi/qla4xxx/ql4_nx.c
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/qla4xxx/ql4_version.h
drivers/scsi/scsi_error.c
drivers/scsi/scsi_tgt_lib.c
drivers/spi/amba-pl022.c
drivers/spi/mpc512x_psc_spi.c
drivers/spi/omap_spi_100k.c
drivers/spi/spi.c
drivers/spi/spi_bitbang.c
drivers/spi/spi_bitbang_txrx.h
drivers/spi/spi_butterfly.c
drivers/spi/spi_gpio.c
drivers/spi/spi_lm70llp.c
drivers/spi/spi_s3c24xx_gpio.c
drivers/spi/spi_sh_sci.c
include/linux/spi/spi.h
include/linux/spi/spi_gpio.h
mm/memory.c

index 3c4e07123e59a6d441319a4f96cbf2730e4fde1c..d568bc235bc008a215b981bcf303352c54bbda3a 100644 (file)
@@ -738,17 +738,17 @@ to "Closing".
    CONFIG_NEED_SG_DMA_LENGTH if the architecture supports IOMMUs
    (including software IOMMU).
 
-2) ARCH_KMALLOC_MINALIGN
+2) ARCH_DMA_MINALIGN
 
    Architectures must ensure that kmalloc'ed buffer is
    DMA-safe. Drivers and subsystems depend on it. If an architecture
    isn't fully DMA-coherent (i.e. hardware doesn't ensure that data in
    the CPU cache is identical to data in main memory),
-   ARCH_KMALLOC_MINALIGN must be set so that the memory allocator
+   ARCH_DMA_MINALIGN must be set so that the memory allocator
    makes sure that kmalloc'ed buffer doesn't share a cache line with
    the others. See arch/arm/include/asm/cache.h as an example.
 
-   Note that ARCH_KMALLOC_MINALIGN is about DMA memory alignment
+   Note that ARCH_DMA_MINALIGN is about DMA memory alignment
    constraints. You don't need to worry about the architecture data
    alignment constraints (e.g. the alignment constraints about 64-bit
    objects).
index 6a6c66be7f656b89b8bda2e3dd1fc820eb87b603..f35b86e68dd59d92bcc9d5375b0a1a1b11d58080 100644 (file)
@@ -43,7 +43,7 @@
 
 /* Per channel configuration registers */
 
-#define PL008_Cx_STRIDE                                (0x20)
+#define PL080_Cx_STRIDE                                (0x20)
 #define PL080_Cx_BASE(x)                       ((0x100 + (x * 0x20)))
 #define PL080_Cx_SRC_ADDR(x)                   ((0x100 + (x * 0x20)))
 #define PL080_Cx_DST_ADDR(x)                   ((0x104 + (x * 0x20)))
@@ -68,6 +68,8 @@
 #define PL080_CONTROL_TC_IRQ_EN                        (1 << 31)
 #define PL080_CONTROL_PROT_MASK                        (0x7 << 28)
 #define PL080_CONTROL_PROT_SHIFT               (28)
+#define PL080_CONTROL_PROT_CACHE               (1 << 30)
+#define PL080_CONTROL_PROT_BUFF                        (1 << 29)
 #define PL080_CONTROL_PROT_SYS                 (1 << 28)
 #define PL080_CONTROL_DST_INCR                 (1 << 27)
 #define PL080_CONTROL_SRC_INCR                 (1 << 26)
index 071e8a1e07655c722f3c2671c693065329c6f6e8..1e4d78af7d845c614f285e3615938525c588ff0f 100644 (file)
@@ -98,6 +98,15 @@ config MACH_ANW6410
        help
          Machine support for the A&W6410
 
+config MACH_REAL6410
+       bool "REAL6410"
+       select CPU_S3C6410
+       select S3C_DEV_HSMMC
+       select S3C_DEV_HSMMC1
+       select S3C64XX_SETUP_SDHCI
+       help
+         Machine support for the CoreWind REAL6410
+
 config MACH_SMDK6410
        bool "SMDK6410"
        select CPU_S3C6410
index 48d3dfac8dd734a76cbf5ce7f1ab3ea357ff7ca9..90221a2e0c5543c87dda5937b3fe9144091bf88a 100644 (file)
@@ -52,6 +52,7 @@ obj-$(CONFIG_PM)              += irq-pm.o
 obj-$(CONFIG_MACH_ANW6410)     += mach-anw6410.o
 obj-$(CONFIG_MACH_SMDK6400)    += mach-smdk6400.o
 obj-$(CONFIG_MACH_SMDK6410)    += mach-smdk6410.o
+obj-$(CONFIG_MACH_REAL6410)     += mach-real6410.o
 obj-$(CONFIG_MACH_NCP)         += mach-ncp.o
 obj-$(CONFIG_MACH_HMT)         += mach-hmt.o
 obj-$(CONFIG_MACH_SMARTQ)      += mach-smartq.o
index 5567e037b0d15a9d890c31c7a05a57deb9baf7c7..e7d03ab41d80d58b412aa383670e9daa27d10386 100644 (file)
@@ -697,7 +697,7 @@ static int s3c64xx_dma_init1(int chno, enum dma_ch chbase,
                chptr->number = chno;
                chptr->dmac = dmac;
                chptr->regs = regptr;
-               regptr += PL008_Cx_STRIDE;
+               regptr += PL080_Cx_STRIDE;
        }
 
        /* for the moment, permanently enable the controller */
index a3ac84a6548010815bde285679c645ff172ce6b2..42cc54e2ee3061824da68112789cdf7555231352 100644 (file)
@@ -15,4 +15,6 @@
 
 #define PHYS_OFFSET     UL(0x50000000)
 
+#define CONSISTENT_DMA_SIZE    SZ_8M
+
 #endif
diff --git a/arch/arm/mach-s3c64xx/mach-real6410.c b/arch/arm/mach-s3c64xx/mach-real6410.c
new file mode 100644 (file)
index 0000000..5c07d01
--- /dev/null
@@ -0,0 +1,152 @@
+/* linux/arch/arm/mach-s3c64xx/mach-real6410.c
+ *
+ * Copyright 2010 Darius Augulis <augulis.darius@gmail.com>
+ * Copyright 2008 Openmoko, Inc.
+ * Copyright 2008 Simtec Electronics
+ *     Ben Dooks <ben@simtec.co.uk>
+ *     http://armlinux.simtec.co.uk/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/init.h>
+#include <linux/dm9000.h>
+#include <linux/serial_core.h>
+#include <linux/platform_device.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <mach/map.h>
+#include <mach/s3c6410.h>
+#include <mach/regs-srom.h>
+#include <plat/cpu.h>
+#include <plat/devs.h>
+#include <plat/regs-serial.h>
+
+#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
+#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
+#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
+
+static struct s3c2410_uartcfg real6410_uartcfgs[] __initdata = {
+       [0] = {
+               .hwport      = 0,
+               .flags       = 0,
+               .ucon        = UCON,
+               .ulcon       = ULCON,
+               .ufcon       = UFCON,
+       },
+       [1] = {
+               .hwport      = 1,
+               .flags       = 0,
+               .ucon        = UCON,
+               .ulcon       = ULCON,
+               .ufcon       = UFCON,
+       },
+       [2] = {
+               .hwport      = 2,
+               .flags       = 0,
+               .ucon        = UCON,
+               .ulcon       = ULCON,
+               .ufcon       = UFCON,
+       },
+       [3] = {
+               .hwport      = 3,
+               .flags       = 0,
+               .ucon        = UCON,
+               .ulcon       = ULCON,
+               .ufcon       = UFCON,
+       },
+};
+
+/* DM9000AEP 10/100 ethernet controller */
+
+static struct resource real6410_dm9k_resource[] = {
+        [0] = {
+                .start = S3C64XX_PA_XM0CSN1,
+                .end   = S3C64XX_PA_XM0CSN1 + 1,
+                .flags = IORESOURCE_MEM
+        },
+        [1] = {
+                .start = S3C64XX_PA_XM0CSN1 + 4,
+                .end   = S3C64XX_PA_XM0CSN1 + 5,
+                .flags = IORESOURCE_MEM
+        },
+        [2] = {
+                .start = S3C_EINT(7),
+                .end   = S3C_EINT(7),
+                .flags = IORESOURCE_IRQ,
+        }
+};
+
+static struct dm9000_plat_data real6410_dm9k_pdata = {
+        .flags          = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
+};
+
+static struct platform_device real6410_device_eth = {
+        .name           = "dm9000",
+        .id             = -1,
+        .num_resources  = ARRAY_SIZE(real6410_dm9k_resource),
+        .resource       = real6410_dm9k_resource,
+        .dev            = {
+                .platform_data  = &real6410_dm9k_pdata,
+        },
+};
+
+static struct platform_device *real6410_devices[] __initdata = {
+       &real6410_device_eth,
+       &s3c_device_hsmmc0,
+       &s3c_device_hsmmc1,
+};
+
+static void __init real6410_map_io(void)
+{
+       s3c64xx_init_io(NULL, 0);
+       s3c24xx_init_clocks(12000000);
+       s3c24xx_init_uarts(real6410_uartcfgs, ARRAY_SIZE(real6410_uartcfgs));
+}
+
+static void __init real6410_machine_init(void)
+{
+       u32 cs1;
+
+       /* configure nCS1 width to 16 bits */
+
+       cs1 = __raw_readl(S3C64XX_SROM_BW) &
+               ~(S3C64XX_SROM_BW__CS_MASK << S3C64XX_SROM_BW__NCS1__SHIFT);
+       cs1 |= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT) |
+               (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT) |
+               (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT)) <<
+                       S3C64XX_SROM_BW__NCS1__SHIFT;
+       __raw_writel(cs1, S3C64XX_SROM_BW);
+
+       /* set timing for nCS1 suitable for ethernet chip */
+
+       __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT) |
+                       (6 << S3C64XX_SROM_BCX__TACP__SHIFT) |
+                       (4 << S3C64XX_SROM_BCX__TCAH__SHIFT) |
+                       (1 << S3C64XX_SROM_BCX__TCOH__SHIFT) |
+                       (13 << S3C64XX_SROM_BCX__TACC__SHIFT) |
+                       (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) |
+                       (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1);
+
+       platform_add_devices(real6410_devices, ARRAY_SIZE(real6410_devices));
+}
+
+MACHINE_START(REAL6410, "REAL6410")
+       /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
+       .phys_io        = S3C_PA_UART & 0xfff00000,
+       .io_pg_offst    = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
+       .boot_params    = S3C64XX_PA_SDRAM + 0x100,
+
+       .init_irq       = s3c6410_init_irq,
+       .map_io         = real6410_map_io,
+       .init_machine   = real6410_machine_init,
+       .timer          = &s3c24xx_timer,
+MACHINE_END
index 028d080dcd354dc1b5eba1a524e910e7168bf2b4..3a9639bc3d9b24df59de162b428a6965d2bba093 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm_backlight.h>
 #include <linux/serial_core.h>
+#include <linux/spi/spi_gpio.h>
 #include <linux/usb/gpio_vbus.h>
 
 #include <asm/mach-types.h>
@@ -166,7 +167,7 @@ static struct s3c2410_ts_mach_info smartq_touchscreen_pdata __initdata = {
 
 static struct s3c_sdhci_platdata smartq_internal_hsmmc_pdata = {
        .max_width              = 4,
-       /*.broken_card_detection        = true,*/
+       .cd_type                = S3C_SDHCI_CD_PERMANENT,
 };
 
 static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata = {
@@ -184,6 +185,33 @@ static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata = {
        },
 };
 
+static int __init smartq_lcd_setup_gpio(void)
+{
+       int ret;
+
+       ret = gpio_request(S3C64XX_GPM(3), "LCD power");
+       if (ret < 0)
+               return ret;
+
+       /* turn power off */
+       gpio_direction_output(S3C64XX_GPM(3), 0);
+
+       return 0;
+}
+
+/* GPM0 -> CS */
+static struct spi_gpio_platform_data smartq_lcd_control = {
+       .sck                    = S3C64XX_GPM(1),
+       .mosi                   = S3C64XX_GPM(2),
+       .miso                   = S3C64XX_GPM(2),
+};
+
+static struct platform_device smartq_lcd_control_device = {
+       .name                   = "spi-gpio",
+       .id                     = 1,
+       .dev.platform_data      = &smartq_lcd_control,
+};
+
 static void smartq_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
 {
        gpio_direction_output(S3C64XX_GPM(3), power);
@@ -199,6 +227,9 @@ static struct platform_device smartq_lcd_power_device = {
        .dev.platform_data      = &smartq_lcd_power_data,
 };
 
+static struct i2c_board_info smartq_i2c_devs[] __initdata = {
+       { I2C_BOARD_INFO("wm8987", 0x1a), },
+};
 
 static struct platform_device *smartq_devices[] __initdata = {
        &s3c_device_hsmmc1,     /* Init iNAND first, ... */
@@ -213,7 +244,9 @@ static struct platform_device *smartq_devices[] __initdata = {
        &s3c_device_timer[1],
        &s3c_device_ts,
        &s3c_device_usb_hsotg,
+       &s3c64xx_device_iis0,
        &smartq_backlight_device,
+       &smartq_lcd_control_device,
        &smartq_lcd_power_device,
        &smartq_usb_otg_vbus_dev,
 };
@@ -252,7 +285,6 @@ static int __init smartq_power_off_init(void)
        /* leave power on */
        gpio_direction_output(S3C64XX_GPK(15), 0);
 
-
        pm_power_off = smartq_power_off;
 
        return ret;
@@ -354,6 +386,10 @@ void __init smartq_machine_init(void)
        s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
        s3c24xx_ts_set_platdata(&smartq_touchscreen_pdata);
 
+       i2c_register_board_info(0, smartq_i2c_devs,
+                               ARRAY_SIZE(smartq_i2c_devs));
+
+       WARN_ON(smartq_lcd_setup_gpio());
        WARN_ON(smartq_power_off_init());
        WARN_ON(smartq_usb_host_init());
        WARN_ON(smartq_usb_otg_init());
index a065062ec2a417bbe729a490a20e542899a73ba0..a4d59b076e3d9d31b518160b28d87d65c93d1300 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/fb.h>
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
-#include <linux/i2c-gpio.h>
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/leds.h>
 
 #include "mach-smartq.h"
 
-static void __init smartq5_lcd_setup_gpio(void)
-{
-       gpio_request(S3C64XX_GPM(0), "LCD SCEN pin");
-       gpio_request(S3C64XX_GPM(1), "LCD SCL pin");
-       gpio_request(S3C64XX_GPM(2), "LCD SDA pin");
-       gpio_request(S3C64XX_GPM(3), "LCD power");
-
-       /* turn power off */
-       gpio_direction_output(S3C64XX_GPM(0), 1);
-       gpio_direction_input(S3C64XX_GPM(1));
-       gpio_direction_input(S3C64XX_GPM(2));
-       gpio_direction_output(S3C64XX_GPM(3), 0);
-}
-
-static struct i2c_gpio_platform_data smartq5_lcd_control = {
-       .sda_pin                = S3C64XX_GPM(2),
-       .scl_pin                = S3C64XX_GPM(1),
-};
-
-static struct platform_device smartq5_lcd_control_device = {
-       .name                   = "i2c-gpio",
-       .id                     = 1,
-       .dev.platform_data      = &smartq5_lcd_control,
-};
-
 static struct gpio_led smartq5_leds[] __initdata = {
        {
                .name                   = "smartq5:green",
@@ -134,10 +108,10 @@ static struct platform_device smartq5_buttons_device  = {
 
 static struct s3c_fb_pd_win smartq5_fb_win0 = {
        .win_mode       = {
-               .left_margin    = 40,
-               .right_margin   = 216,
-               .upper_margin   = 10,
-               .lower_margin   = 35,
+               .left_margin    = 216,
+               .right_margin   = 40,
+               .upper_margin   = 35,
+               .lower_margin   = 10,
                .hsync_len      = 1,
                .vsync_len      = 1,
                .xres           = 800,
@@ -159,7 +133,6 @@ static struct s3c_fb_platdata smartq5_lcd_pdata __initdata = {
 static struct platform_device *smartq5_devices[] __initdata = {
        &smartq5_leds_device,
        &smartq5_buttons_device,
-       &smartq5_lcd_control_device,
 };
 
 static void __init smartq5_machine_init(void)
@@ -167,7 +140,6 @@ static void __init smartq5_machine_init(void)
        s3c_fb_set_platdata(&smartq5_lcd_pdata);
 
        smartq_machine_init();
-       smartq5_lcd_setup_gpio();
 
        platform_add_devices(smartq5_devices, ARRAY_SIZE(smartq5_devices));
 }
index 0ecf451375464a902b431e0af5cee6148007780d..e50a7d781732fd2e7d072f647439421e7489c8f3 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/fb.h>
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
-#include <linux/i2c-gpio.h>
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/leds.h>
 
 #include "mach-smartq.h"
 
-static void __init smartq7_lcd_setup_gpio(void)
-{
-       gpio_request(S3C64XX_GPM(0), "LCD CSB pin");
-       gpio_request(S3C64XX_GPM(3), "LCD power");
-       gpio_request(S3C64XX_GPM(4), "LCD power status");
-
-       /* turn power off */
-       gpio_direction_output(S3C64XX_GPM(0), 1);
-       gpio_direction_output(S3C64XX_GPM(3), 0);
-       gpio_direction_input(S3C64XX_GPM(4));
-}
-
-static struct i2c_gpio_platform_data smartq7_lcd_control = {
-       .sda_pin                = S3C64XX_GPM(2),
-       .scl_pin                = S3C64XX_GPM(1),
-       .sda_is_open_drain      = 1,
-       .scl_is_open_drain      = 1,
-};
-
-static struct platform_device smartq7_lcd_control_device = {
-       .name                   = "i2c-gpio",
-       .id                     = 1,
-       .dev.platform_data      = &smartq7_lcd_control,
-};
-
 static struct gpio_led smartq7_leds[] __initdata = {
        {
                .name                   = "smartq7:red",
@@ -175,7 +149,6 @@ static struct s3c_fb_platdata smartq7_lcd_pdata __initdata = {
 static struct platform_device *smartq7_devices[] __initdata = {
        &smartq7_leds_device,
        &smartq7_buttons_device,
-       &smartq7_lcd_control_device,
 };
 
 static void __init smartq7_machine_init(void)
@@ -183,7 +156,6 @@ static void __init smartq7_machine_init(void)
        s3c_fb_set_platdata(&smartq7_lcd_pdata);
 
        smartq_machine_init();
-       smartq7_lcd_setup_gpio();
 
        platform_add_devices(smartq7_devices, ARRAY_SIZE(smartq7_devices));
 }
index 2d43128f939fdde8f2fa3ccf163febdc237c2f1b..d498219fff1bd34ed1c8b180a67c1ce24fe1835c 100644 (file)
@@ -155,6 +155,8 @@ static struct s3c_fb_pd_win smdk6410_fb_win0 = {
        },
        .max_bpp        = 32,
        .default_bpp    = 16,
+       .virtual_y      = 480 * 2,
+       .virtual_x      = 800,
 };
 
 /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
diff --git a/arch/arm/mach-w90x900/include/mach/i2c.h b/arch/arm/mach-w90x900/include/mach/i2c.h
new file mode 100644 (file)
index 0000000..9ffb12d
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __ASM_ARCH_NUC900_I2C_H
+#define __ASM_ARCH_NUC900_I2C_H
+
+struct nuc900_platform_i2c {
+       int             bus_num;
+       unsigned long   bus_freq;
+};
+
+#endif /* __ASM_ARCH_NUC900_I2C_H */
index 4529dd6232bc9b95d5055985542a0616190f50ec..7c0bde78116755dde5d24799b45ecedb36bb8b8b 100644 (file)
@@ -6,7 +6,7 @@
 
 config PLAT_SAMSUNG
        bool
-       depends on ARCH_S3C2410 || ARCH_S3C24A0 || ARCH_S3C64XX
+       depends on PLAT_S3C24XX || ARCH_S3C64XX || PLAT_S5P
        select NO_IOPORT
        default y
        help
index d4ed8e98edf7b23fb9fd676c92ecfe3bb14c9e3c..280c9b5ad9e375afafd3116cc75d8b6fc3eb12fd 100644 (file)
@@ -122,14 +122,6 @@ config ISCSI_IBFT_FIND
          is necessary for iSCSI Boot Firmware Table Attributes module to work
          properly.
 
-config ISCSI_BOOT_SYSFS
-       tristate "iSCSI Boot Sysfs Interface"
-       default n
-       help
-         This option enables support for exposing iSCSI boot information
-         via sysfs to userspace. If you wish to export this information,
-         say Y. Otherwise, say N.
-
 config ISCSI_IBFT
        tristate "iSCSI Boot Firmware Table Attributes module"
        select ISCSI_BOOT_SYSFS
index 5fe7e1662922703150c9bc525e50de0759d29457..1c3c17343dbeabb730d0bbc6313f7dca7ca1b364 100644 (file)
@@ -10,5 +10,4 @@ obj-$(CONFIG_DCDBAS)          += dcdbas.o
 obj-$(CONFIG_DMIID)            += dmi-id.o
 obj-$(CONFIG_ISCSI_IBFT_FIND)  += iscsi_ibft_find.o
 obj-$(CONFIG_ISCSI_IBFT)       += iscsi_ibft.o
-obj-$(CONFIG_ISCSI_BOOT_SYSFS) += iscsi_boot_sysfs.o
 obj-$(CONFIG_FIRMWARE_MEMMAP)  += memmap.o
index 15a9702e29416a959d8d6fed59559620eed8390f..6539ac2907e9538742214e22136ca25ef6a2c4e8 100644 (file)
@@ -448,6 +448,13 @@ config I2C_NOMADIK
          If you say yes to this option, support will be included for the
          I2C interface from ST-Ericsson's Nomadik and Ux500 architectures.
 
+config I2C_NUC900
+       tristate "NUC900 I2C Driver"
+       depends on ARCH_W90X900
+       help
+         Say Y here to include support for I2C controller in the
+         Winbond/Nuvoton NUC900 based System-on-Chip devices.
+
 config I2C_OCORES
        tristate "OpenCores I2C Controller"
        depends on EXPERIMENTAL
@@ -496,8 +503,8 @@ config I2C_PMCMSP
          will be called i2c-pmcmsp.
 
 config I2C_PNX
-       tristate "I2C bus support for Philips PNX targets"
-       depends on ARCH_PNX4008
+       tristate "I2C bus support for Philips PNX and NXP LPC targets"
+       depends on ARCH_PNX4008 || ARCH_LPC32XX
        help
          This driver supports the Philips IP3204 I2C IP block master and/or
          slave controller
index 936880bd1dc58404d4ed666919939729c7c99585..c3ef49230cba477f3a3c9505f8ba46f954e557c6 100644 (file)
@@ -43,6 +43,7 @@ obj-$(CONFIG_I2C_IXP2000)     += i2c-ixp2000.o
 obj-$(CONFIG_I2C_MPC)          += i2c-mpc.o
 obj-$(CONFIG_I2C_MV64XXX)      += i2c-mv64xxx.o
 obj-$(CONFIG_I2C_NOMADIK)      += i2c-nomadik.o
+obj-$(CONFIG_I2C_NUC900)       += i2c-nuc900.o
 obj-$(CONFIG_I2C_OCORES)       += i2c-ocores.o
 obj-$(CONFIG_I2C_OMAP)         += i2c-omap.o
 obj-$(CONFIG_I2C_PASEMI)       += i2c-pasemi.o
index 4523364e67221d3930cb3fd5c6ceb65b7fab7d4e..2222c87876b97bc711b6d739fd4a82deef7db330 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/cpufreq.h>
+#include <linux/gpio.h>
 
 #include <mach/hardware.h>
-
 #include <mach/i2c.h>
 
 /* ----- global defines ----------------------------------------------- */
 
 #define DAVINCI_I2C_TIMEOUT    (1*HZ)
+#define DAVINCI_I2C_MAX_TRIES  2
 #define I2C_DAVINCI_INTR_ALL    (DAVINCI_I2C_IMR_AAS | \
                                 DAVINCI_I2C_IMR_SCD | \
                                 DAVINCI_I2C_IMR_ARDY | \
 #define DAVINCI_I2C_IVR_NACK   0x02
 #define DAVINCI_I2C_IVR_AL     0x01
 
-#define DAVINCI_I2C_STR_BB     (1 << 12)
-#define DAVINCI_I2C_STR_RSFULL (1 << 11)
-#define DAVINCI_I2C_STR_SCD    (1 << 5)
-#define DAVINCI_I2C_STR_ARDY   (1 << 2)
-#define DAVINCI_I2C_STR_NACK   (1 << 1)
-#define DAVINCI_I2C_STR_AL     (1 << 0)
-
-#define DAVINCI_I2C_MDR_NACK   (1 << 15)
-#define DAVINCI_I2C_MDR_STT    (1 << 13)
-#define DAVINCI_I2C_MDR_STP    (1 << 11)
-#define DAVINCI_I2C_MDR_MST    (1 << 10)
-#define DAVINCI_I2C_MDR_TRX    (1 << 9)
-#define DAVINCI_I2C_MDR_XA     (1 << 8)
-#define DAVINCI_I2C_MDR_RM     (1 << 7)
-#define DAVINCI_I2C_MDR_IRS    (1 << 5)
-
-#define DAVINCI_I2C_IMR_AAS    (1 << 6)
-#define DAVINCI_I2C_IMR_SCD    (1 << 5)
-#define DAVINCI_I2C_IMR_XRDY   (1 << 4)
-#define DAVINCI_I2C_IMR_RRDY   (1 << 3)
-#define DAVINCI_I2C_IMR_ARDY   (1 << 2)
-#define DAVINCI_I2C_IMR_NACK   (1 << 1)
-#define DAVINCI_I2C_IMR_AL     (1 << 0)
-
-#define MOD_REG_BIT(val, mask, set) do { \
-       if (set) { \
-               val |= mask; \
-       } else { \
-               val &= ~mask; \
-       } \
-} while (0)
+#define DAVINCI_I2C_STR_BB     BIT(12)
+#define DAVINCI_I2C_STR_RSFULL BIT(11)
+#define DAVINCI_I2C_STR_SCD    BIT(5)
+#define DAVINCI_I2C_STR_ARDY   BIT(2)
+#define DAVINCI_I2C_STR_NACK   BIT(1)
+#define DAVINCI_I2C_STR_AL     BIT(0)
+
+#define DAVINCI_I2C_MDR_NACK   BIT(15)
+#define DAVINCI_I2C_MDR_STT    BIT(13)
+#define DAVINCI_I2C_MDR_STP    BIT(11)
+#define DAVINCI_I2C_MDR_MST    BIT(10)
+#define DAVINCI_I2C_MDR_TRX    BIT(9)
+#define DAVINCI_I2C_MDR_XA     BIT(8)
+#define DAVINCI_I2C_MDR_RM     BIT(7)
+#define DAVINCI_I2C_MDR_IRS    BIT(5)
+
+#define DAVINCI_I2C_IMR_AAS    BIT(6)
+#define DAVINCI_I2C_IMR_SCD    BIT(5)
+#define DAVINCI_I2C_IMR_XRDY   BIT(4)
+#define DAVINCI_I2C_IMR_RRDY   BIT(3)
+#define DAVINCI_I2C_IMR_ARDY   BIT(2)
+#define DAVINCI_I2C_IMR_NACK   BIT(1)
+#define DAVINCI_I2C_IMR_AL     BIT(0)
 
 struct davinci_i2c_dev {
        struct device           *dev;
@@ -113,8 +107,13 @@ struct davinci_i2c_dev {
        u8                      *buf;
        size_t                  buf_len;
        int                     irq;
+       int                     stop;
        u8                      terminate;
        struct i2c_adapter      adapter;
+#ifdef CONFIG_CPU_FREQ
+       struct completion       xfr_complete;
+       struct notifier_block   freq_transition;
+#endif
 };
 
 /* default platform data to use if not supplied in the platform_device */
@@ -134,12 +133,59 @@ static inline u16 davinci_i2c_read_reg(struct davinci_i2c_dev *i2c_dev, int reg)
        return __raw_readw(i2c_dev->base + reg);
 }
 
-/*
- * This functions configures I2C and brings I2C out of reset.
- * This function is called during I2C init function. This function
- * also gets called if I2C encounters any errors.
+/* Generate a pulse on the i2c clock pin. */
+static void generic_i2c_clock_pulse(unsigned int scl_pin)
+{
+       u16 i;
+
+       if (scl_pin) {
+               /* Send high and low on the SCL line */
+               for (i = 0; i < 9; i++) {
+                       gpio_set_value(scl_pin, 0);
+                       udelay(20);
+                       gpio_set_value(scl_pin, 1);
+                       udelay(20);
+               }
+       }
+}
+
+/* This routine does i2c bus recovery as specified in the
+ * i2c protocol Rev. 03 section 3.16 titled "Bus clear"
  */
-static int i2c_davinci_init(struct davinci_i2c_dev *dev)
+static void i2c_recover_bus(struct davinci_i2c_dev *dev)
+{
+       u32 flag = 0;
+       struct davinci_i2c_platform_data *pdata = dev->dev->platform_data;
+
+       dev_err(dev->dev, "initiating i2c bus recovery\n");
+       /* Send NACK to the slave */
+       flag = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
+       flag |=  DAVINCI_I2C_MDR_NACK;
+       /* write the data into mode register */
+       davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
+       if (pdata)
+               generic_i2c_clock_pulse(pdata->scl_pin);
+       /* Send STOP */
+       flag = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
+       flag |= DAVINCI_I2C_MDR_STP;
+       davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
+}
+
+static inline void davinci_i2c_reset_ctrl(struct davinci_i2c_dev *i2c_dev,
+                                                               int val)
+{
+       u16 w;
+
+       w = davinci_i2c_read_reg(i2c_dev, DAVINCI_I2C_MDR_REG);
+       if (!val)       /* put I2C into reset */
+               w &= ~DAVINCI_I2C_MDR_IRS;
+       else            /* take I2C out of reset */
+               w |= DAVINCI_I2C_MDR_IRS;
+
+       davinci_i2c_write_reg(i2c_dev, DAVINCI_I2C_MDR_REG, w);
+}
+
+static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
 {
        struct davinci_i2c_platform_data *pdata = dev->dev->platform_data;
        u16 psc;
@@ -148,15 +194,6 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
        u32 clkh;
        u32 clkl;
        u32 input_clock = clk_get_rate(dev->clk);
-       u16 w;
-
-       if (!pdata)
-               pdata = &davinci_i2c_platform_data_default;
-
-       /* put I2C into reset */
-       w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-       MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 0);
-       davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
 
        /* NOTE: I2C Clock divider programming info
         * As per I2C specs the following formulas provide prescaler
@@ -188,12 +225,32 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
        davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKH_REG, clkh);
        davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKL_REG, clkl);
 
+       dev_dbg(dev->dev, "input_clock = %d, CLK = %d\n", input_clock, clk);
+}
+
+/*
+ * This function configures I2C and brings I2C out of reset.
+ * This function is called during I2C init function. This function
+ * also gets called if I2C encounters any errors.
+ */
+static int i2c_davinci_init(struct davinci_i2c_dev *dev)
+{
+       struct davinci_i2c_platform_data *pdata = dev->dev->platform_data;
+
+       if (!pdata)
+               pdata = &davinci_i2c_platform_data_default;
+
+       /* put I2C into reset */
+       davinci_i2c_reset_ctrl(dev, 0);
+
+       /* compute clock dividers */
+       i2c_davinci_calc_clk_dividers(dev);
+
        /* Respond at reserved "SMBus Host" slave address" (and zero);
         * we seem to have no option to not respond...
         */
        davinci_i2c_write_reg(dev, DAVINCI_I2C_OAR_REG, 0x08);
 
-       dev_dbg(dev->dev, "input_clock = %d, CLK = %d\n", input_clock, clk);
        dev_dbg(dev->dev, "PSC  = %d\n",
                davinci_i2c_read_reg(dev, DAVINCI_I2C_PSC_REG));
        dev_dbg(dev->dev, "CLKL = %d\n",
@@ -204,9 +261,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
                pdata->bus_freq, pdata->bus_delay);
 
        /* Take the I2C module out of reset: */
-       w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-       MOD_REG_BIT(w, DAVINCI_I2C_MDR_IRS, 1);
-       davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
+       davinci_i2c_reset_ctrl(dev, 1);
 
        /* Enable interrupts */
        davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, I2C_DAVINCI_INTR_ALL);
@@ -221,14 +276,22 @@ static int i2c_davinci_wait_bus_not_busy(struct davinci_i2c_dev *dev,
                                         char allow_sleep)
 {
        unsigned long timeout;
+       static u16 to_cnt;
 
        timeout = jiffies + dev->adapter.timeout;
        while (davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG)
               & DAVINCI_I2C_STR_BB) {
-               if (time_after(jiffies, timeout)) {
-                       dev_warn(dev->dev,
-                                "timeout waiting for bus ready\n");
-                       return -ETIMEDOUT;
+               if (to_cnt <= DAVINCI_I2C_MAX_TRIES) {
+                       if (time_after(jiffies, timeout)) {
+                               dev_warn(dev->dev,
+                               "timeout waiting for bus ready\n");
+                               to_cnt++;
+                               return -ETIMEDOUT;
+                       } else {
+                               to_cnt = 0;
+                               i2c_recover_bus(dev);
+                               i2c_davinci_init(dev);
+                       }
                }
                if (allow_sleep)
                        schedule_timeout(1);
@@ -250,9 +313,6 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
        u16 w;
        int r;
 
-       if (msg->len == 0)
-               return -EINVAL;
-
        if (!pdata)
                pdata = &davinci_i2c_platform_data_default;
        /* Introduce a delay, required for some boards (e.g Davinci EVM) */
@@ -264,6 +324,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
 
        dev->buf = msg->buf;
        dev->buf_len = msg->len;
+       dev->stop = stop;
 
        davinci_i2c_write_reg(dev, DAVINCI_I2C_CNT_REG, dev->buf_len);
 
@@ -281,23 +342,40 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
                flag |= DAVINCI_I2C_MDR_TRX;
        if (stop)
                flag |= DAVINCI_I2C_MDR_STP;
+       if (msg->len == 0) {
+               flag |= DAVINCI_I2C_MDR_RM;
+               flag &= ~DAVINCI_I2C_MDR_STP;
+       }
 
        /* Enable receive or transmit interrupts */
        w = davinci_i2c_read_reg(dev, DAVINCI_I2C_IMR_REG);
        if (msg->flags & I2C_M_RD)
-               MOD_REG_BIT(w, DAVINCI_I2C_IMR_RRDY, 1);
+               w |= DAVINCI_I2C_IMR_RRDY;
        else
-               MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 1);
+               w |= DAVINCI_I2C_IMR_XRDY;
        davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, w);
 
        dev->terminate = 0;
+
        /* write the data into mode register */
        davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
 
+       /*
+        * First byte should be set here, not after interrupt,
+        * because transmit-data-ready interrupt can come before
+        * NACK-interrupt during sending of previous message and
+        * ICDXR may have wrong data
+        */
+       if ((!(msg->flags & I2C_M_RD)) && dev->buf_len) {
+               davinci_i2c_write_reg(dev, DAVINCI_I2C_DXR_REG, *dev->buf++);
+               dev->buf_len--;
+       }
+
        r = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
                                                      dev->adapter.timeout);
        if (r == 0) {
                dev_err(dev->dev, "controller timed out\n");
+               i2c_recover_bus(dev);
                i2c_davinci_init(dev);
                dev->buf_len = 0;
                return -ETIMEDOUT;
@@ -334,7 +412,7 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
                        return msg->len;
                if (stop) {
                        w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
-                       MOD_REG_BIT(w, DAVINCI_I2C_MDR_STP, 1);
+                       w |= DAVINCI_I2C_MDR_STP;
                        davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
                }
                return -EREMOTEIO;
@@ -367,12 +445,17 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
                if (ret < 0)
                        return ret;
        }
+
+#ifdef CONFIG_CPU_FREQ
+       complete(&dev->xfr_complete);
+#endif
+
        return num;
 }
 
 static u32 i2c_davinci_func(struct i2c_adapter *adap)
 {
-       return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
+       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
 static void terminate_read(struct davinci_i2c_dev *dev)
@@ -431,6 +514,14 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
                case DAVINCI_I2C_IVR_ARDY:
                        davinci_i2c_write_reg(dev,
                                DAVINCI_I2C_STR_REG, DAVINCI_I2C_STR_ARDY);
+                       if (((dev->buf_len == 0) && (dev->stop != 0)) ||
+                           (dev->cmd_err & DAVINCI_I2C_STR_NACK)) {
+                               w = davinci_i2c_read_reg(dev,
+                                                        DAVINCI_I2C_MDR_REG);
+                               w |= DAVINCI_I2C_MDR_STP;
+                               davinci_i2c_write_reg(dev,
+                                                     DAVINCI_I2C_MDR_REG, w);
+                       }
                        complete(&dev->cmd_complete);
                        break;
 
@@ -462,7 +553,7 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
 
                                w = davinci_i2c_read_reg(dev,
                                                         DAVINCI_I2C_IMR_REG);
-                               MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 0);
+                               w &= ~DAVINCI_I2C_IMR_XRDY;
                                davinci_i2c_write_reg(dev,
                                                      DAVINCI_I2C_IMR_REG,
                                                      w);
@@ -491,6 +582,48 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
        return count ? IRQ_HANDLED : IRQ_NONE;
 }
 
+#ifdef CONFIG_CPU_FREQ
+static int i2c_davinci_cpufreq_transition(struct notifier_block *nb,
+                                    unsigned long val, void *data)
+{
+       struct davinci_i2c_dev *dev;
+
+       dev = container_of(nb, struct davinci_i2c_dev, freq_transition);
+       if (val == CPUFREQ_PRECHANGE) {
+               wait_for_completion(&dev->xfr_complete);
+               davinci_i2c_reset_ctrl(dev, 0);
+       } else if (val == CPUFREQ_POSTCHANGE) {
+               i2c_davinci_calc_clk_dividers(dev);
+               davinci_i2c_reset_ctrl(dev, 1);
+       }
+
+       return 0;
+}
+
+static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
+{
+       dev->freq_transition.notifier_call = i2c_davinci_cpufreq_transition;
+
+       return cpufreq_register_notifier(&dev->freq_transition,
+                                        CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
+{
+       cpufreq_unregister_notifier(&dev->freq_transition,
+                                   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#else
+static inline int i2c_davinci_cpufreq_register(struct davinci_i2c_dev *dev)
+{
+       return 0;
+}
+
+static inline void i2c_davinci_cpufreq_deregister(struct davinci_i2c_dev *dev)
+{
+}
+#endif
+
 static struct i2c_algorithm i2c_davinci_algo = {
        .master_xfer    = i2c_davinci_xfer,
        .functionality  = i2c_davinci_func,
@@ -530,6 +663,9 @@ static int davinci_i2c_probe(struct platform_device *pdev)
        }
 
        init_completion(&dev->cmd_complete);
+#ifdef CONFIG_CPU_FREQ
+       init_completion(&dev->xfr_complete);
+#endif
        dev->dev = get_device(&pdev->dev);
        dev->irq = irq->start;
        platform_set_drvdata(pdev, dev);
@@ -541,7 +677,12 @@ static int davinci_i2c_probe(struct platform_device *pdev)
        }
        clk_enable(dev->clk);
 
-       dev->base = (void __iomem *)IO_ADDRESS(mem->start);
+       dev->base = ioremap(mem->start, resource_size(mem));
+       if (!dev->base) {
+               r = -EBUSY;
+               goto err_mem_ioremap;
+       }
+
        i2c_davinci_init(dev);
 
        r = request_irq(dev->irq, i2c_davinci_isr, 0, pdev->name, dev);
@@ -550,6 +691,12 @@ static int davinci_i2c_probe(struct platform_device *pdev)
                goto err_unuse_clocks;
        }
 
+       r = i2c_davinci_cpufreq_register(dev);
+       if (r) {
+               dev_err(&pdev->dev, "failed to register cpufreq\n");
+               goto err_free_irq;
+       }
+
        adap = &dev->adapter;
        i2c_set_adapdata(adap, dev);
        adap->owner = THIS_MODULE;
@@ -571,6 +718,8 @@ static int davinci_i2c_probe(struct platform_device *pdev)
 err_free_irq:
        free_irq(dev->irq, dev);
 err_unuse_clocks:
+       iounmap(dev->base);
+err_mem_ioremap:
        clk_disable(dev->clk);
        clk_put(dev->clk);
        dev->clk = NULL;
@@ -589,6 +738,8 @@ static int davinci_i2c_remove(struct platform_device *pdev)
        struct davinci_i2c_dev *dev = platform_get_drvdata(pdev);
        struct resource *mem;
 
+       i2c_davinci_cpufreq_deregister(dev);
+
        platform_set_drvdata(pdev, NULL);
        i2c_del_adapter(&dev->adapter);
        put_device(&pdev->dev);
@@ -599,6 +750,7 @@ static int davinci_i2c_remove(struct platform_device *pdev)
 
        davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0);
        free_irq(IRQ_I2C, dev);
+       iounmap(dev->base);
        kfree(dev);
 
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -606,6 +758,41 @@ static int davinci_i2c_remove(struct platform_device *pdev)
        return 0;
 }
 
+#ifdef CONFIG_PM
+static int davinci_i2c_suspend(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
+
+       /* put I2C into reset */
+       davinci_i2c_reset_ctrl(i2c_dev, 0);
+       clk_disable(i2c_dev->clk);
+
+       return 0;
+}
+
+static int davinci_i2c_resume(struct device *dev)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct davinci_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
+
+       clk_enable(i2c_dev->clk);
+       /* take I2C out of reset */
+       davinci_i2c_reset_ctrl(i2c_dev, 1);
+
+       return 0;
+}
+
+static const struct dev_pm_ops davinci_i2c_pm = {
+       .suspend        = davinci_i2c_suspend,
+       .resume         = davinci_i2c_resume,
+};
+
+#define davinci_i2c_pm_ops (&davinci_i2c_pm)
+#else
+#define davinci_i2c_pm_ops NULL
+#endif
+
 /* work with hotplug and coldplug */
 MODULE_ALIAS("platform:i2c_davinci");
 
@@ -615,6 +802,7 @@ static struct platform_driver davinci_i2c_driver = {
        .driver         = {
                .name   = "i2c_davinci",
                .owner  = THIS_MODULE,
+               .pm     = davinci_i2c_pm_ops,
        },
 };
 
diff --git a/drivers/i2c/busses/i2c-nuc900.c b/drivers/i2c/busses/i2c-nuc900.c
new file mode 100644 (file)
index 0000000..92d770d
--- /dev/null
@@ -0,0 +1,709 @@
+/*
+ * linux/drivers/i2c/busses/i2c-nuc900.c
+ *
+ * Copyright (c) 2010 Nuvoton technology corporation.
+ *
+ * This driver based on S3C2410 I2C driver of Ben Dooks <ben-Y5A6D6n0/KfQXOPxS62xeg@public.gmane.org>.
+ * Written by Wan ZongShun <mcuos.com-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation;version 2 of the License.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include <linux/i2c.h>
+#include <linux/i2c-id.h>
+#include <linux/init.h>
+#include <linux/time.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/cpufreq.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+
+#include <mach/mfp.h>
+#include <mach/i2c.h>
+
+/* nuc900 i2c registers offset */
+
+#define CSR            0x00
+#define DIVIDER                0x04
+#define CMDR           0x08
+#define SWR            0x0C
+#define RXR            0x10
+#define TXR            0x14
+
+/* nuc900 i2c CSR register bits */
+
+#define IRQEN          0x003
+#define I2CBUSY                0x400
+#define I2CSTART       0x018
+#define IRQFLAG                0x004
+#define ARBIT_LOST     0x200
+#define SLAVE_ACK      0x800
+
+/* nuc900 i2c CMDR register bits */
+
+#define I2C_CMD_START  0x10
+#define I2C_CMD_STOP   0x08
+#define I2C_CMD_READ   0x04
+#define I2C_CMD_WRITE  0x02
+#define I2C_CMD_NACK   0x01
+
+/* i2c controller state */
+
+enum nuc900_i2c_state {
+       STATE_IDLE,
+       STATE_START,
+       STATE_READ,
+       STATE_WRITE,
+       STATE_STOP
+};
+
+/* i2c controller private data */
+
+struct nuc900_i2c {
+       spinlock_t              lock;
+       wait_queue_head_t       wait;
+
+       struct i2c_msg          *msg;
+       unsigned int            msg_num;
+       unsigned int            msg_idx;
+       unsigned int            msg_ptr;
+       unsigned int            irq;
+
+       enum nuc900_i2c_state   state;
+
+       void __iomem            *regs;
+       struct clk              *clk;
+       struct device           *dev;
+       struct resource         *ioarea;
+       struct i2c_adapter      adap;
+};
+
+/* nuc900_i2c_master_complete
+ *
+ * complete the message and wake up the caller, using the given return code,
+ * or zero to mean ok.
+*/
+
+static inline void nuc900_i2c_master_complete(struct nuc900_i2c *i2c, int ret)
+{
+       dev_dbg(i2c->dev, "master_complete %d\n", ret);
+
+       i2c->msg_ptr = 0;
+       i2c->msg = NULL;
+       i2c->msg_idx++;
+       i2c->msg_num = 0;
+       if (ret)
+               i2c->msg_idx = ret;
+
+       wake_up(&i2c->wait);
+}
+
+/* irq enable/disable functions */
+
+static inline void nuc900_i2c_disable_irq(struct nuc900_i2c *i2c)
+{
+       unsigned long tmp;
+
+       tmp = readl(i2c->regs + CSR);
+       writel(tmp & ~IRQEN, i2c->regs + CSR);
+}
+
+static inline void nuc900_i2c_enable_irq(struct nuc900_i2c *i2c)
+{
+       unsigned long tmp;
+
+       tmp = readl(i2c->regs + CSR);
+       writel(tmp | IRQEN, i2c->regs + CSR);
+}
+
+
+/* nuc900_i2c_message_start
+ *
+ * put the start of a message onto the bus
+*/
+
+static void nuc900_i2c_message_start(struct nuc900_i2c *i2c,
+                                     struct i2c_msg *msg)
+{
+       unsigned int addr = (msg->addr & 0x7f) << 1;
+
+       if (msg->flags & I2C_M_RD)
+               addr |= 0x1;
+       writel(addr & 0xff, i2c->regs + TXR);
+       writel(I2C_CMD_START | I2C_CMD_WRITE, i2c->regs + CMDR);
+}
+
+static inline void nuc900_i2c_stop(struct nuc900_i2c *i2c, int ret)
+{
+
+       dev_dbg(i2c->dev, "STOP\n");
+
+       /* stop the transfer */
+       i2c->state = STATE_STOP;
+       writel(I2C_CMD_STOP, i2c->regs + CMDR);
+
+       nuc900_i2c_master_complete(i2c, ret);
+       nuc900_i2c_disable_irq(i2c);
+}
+
+/* helper functions to determine the current state in the set of
+ * messages we are sending
+*/
+
+/* is_lastmsg()
+ *
+ * returns TRUE if the current message is the last in the set
+*/
+
+static inline int is_lastmsg(struct nuc900_i2c *i2c)
+{
+       return i2c->msg_idx >= (i2c->msg_num - 1);
+}
+
+/* is_msglast
+ *
+ * returns TRUE if we this is the last byte in the current message
+*/
+
+static inline int is_msglast(struct nuc900_i2c *i2c)
+{
+       return i2c->msg_ptr == i2c->msg->len-1;
+}
+
+/* is_msgend
+ *
+ * returns TRUE if we reached the end of the current message
+*/
+
+static inline int is_msgend(struct nuc900_i2c *i2c)
+{
+       return i2c->msg_ptr >= i2c->msg->len;
+}
+
+/* i2c_nuc900_irq_nextbyte
+ *
+ * process an interrupt and work out what to do
+ */
+
+static void i2c_nuc900_irq_nextbyte(struct nuc900_i2c *i2c,
+                                                       unsigned long iicstat)
+{
+       unsigned char byte;
+
+       switch (i2c->state) {
+
+       case STATE_IDLE:
+               dev_err(i2c->dev, "%s: called in STATE_IDLE\n", __func__);
+               break;
+
+       case STATE_STOP:
+               dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__);
+               nuc900_i2c_disable_irq(i2c);
+               break;
+
+       case STATE_START:
+               /* last thing we did was send a start condition on the
+                * bus, or started a new i2c message
+                */
+
+               if (iicstat & SLAVE_ACK &&
+                   !(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
+                       /* ack was not received... */
+
+                       dev_dbg(i2c->dev, "ack was not received\n");
+                       nuc900_i2c_stop(i2c, -ENXIO);
+                       break;
+               }
+
+               if (i2c->msg->flags & I2C_M_RD)
+                       i2c->state = STATE_READ;
+               else
+                       i2c->state = STATE_WRITE;
+
+               /* terminate the transfer if there is nothing to do
+                * as this is used by the i2c probe to find devices.
+               */
+
+               if (is_lastmsg(i2c) && i2c->msg->len == 0) {
+                       nuc900_i2c_stop(i2c, 0);
+                       break;
+               }
+
+               if (i2c->state == STATE_READ)
+                       goto prepare_read;
+
+               /* fall through to the write state, as we will need to
+                * send a byte as well
+               */
+
+       case STATE_WRITE:
+               /* we are writing data to the device... check for the
+                * end of the message, and if so, work out what to do
+                */
+
+               if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) {
+                       if (iicstat & SLAVE_ACK) {
+                               dev_dbg(i2c->dev, "WRITE: No Ack\n");
+
+                               nuc900_i2c_stop(i2c, -ECONNREFUSED);
+                               break;
+                       }
+               }
+
+retry_write:
+
+               if (!is_msgend(i2c)) {
+                       byte = i2c->msg->buf[i2c->msg_ptr++];
+                       writeb(byte, i2c->regs + TXR);
+                       writel(I2C_CMD_WRITE, i2c->regs + CMDR);
+
+               } else if (!is_lastmsg(i2c)) {
+                       /* we need to go to the next i2c message */
+
+                       dev_dbg(i2c->dev, "WRITE: Next Message\n");
+
+                       i2c->msg_ptr = 0;
+                       i2c->msg_idx++;
+                       i2c->msg++;
+
+                       /* check to see if we need to do another message */
+                       if (i2c->msg->flags & I2C_M_NOSTART) {
+
+                               if (i2c->msg->flags & I2C_M_RD) {
+                                       /* cannot do this, the controller
+                                        * forces us to send a new START
+                                        * when we change direction
+                                       */
+
+                                       nuc900_i2c_stop(i2c, -EINVAL);
+                               }
+
+                               goto retry_write;
+                       } else {
+                               /* send the new start */
+                               nuc900_i2c_message_start(i2c, i2c->msg);
+                               i2c->state = STATE_START;
+                       }
+
+               } else {
+                       /* send stop */
+
+                       nuc900_i2c_stop(i2c, 0);
+               }
+               break;
+
+       case STATE_READ:
+               /* we have a byte of data in the data register, do
+                * something with it, and then work out wether we are
+                * going to do any more read/write
+                */
+
+               byte = readb(i2c->regs + RXR);
+               i2c->msg->buf[i2c->msg_ptr++] = byte;
+
+prepare_read:
+               if (is_msglast(i2c)) {
+                       /* last byte of buffer */
+
+                       if (is_lastmsg(i2c))
+                               writel(I2C_CMD_READ | I2C_CMD_NACK,
+                                                       i2c->regs + CMDR);
+
+               } else if (is_msgend(i2c)) {
+                       /* ok, we've read the entire buffer, see if there
+                        * is anything else we need to do
+                       */
+
+                       if (is_lastmsg(i2c)) {
+                               /* last message, send stop and complete */
+                               dev_dbg(i2c->dev, "READ: Send Stop\n");
+
+                               nuc900_i2c_stop(i2c, 0);
+                       } else {
+                               /* go to the next transfer */
+                               dev_dbg(i2c->dev, "READ: Next Transfer\n");
+
+                               i2c->msg_ptr = 0;
+                               i2c->msg_idx++;
+                               i2c->msg++;
+
+                               writel(I2C_CMD_READ, i2c->regs + CMDR);
+                       }
+
+               } else {
+                       writel(I2C_CMD_READ, i2c->regs + CMDR);
+               }
+
+               break;
+       }
+}
+
+/* nuc900_i2c_irq
+ *
+ * top level IRQ servicing routine
+*/
+
+static irqreturn_t nuc900_i2c_irq(int irqno, void *dev_id)
+{
+       struct nuc900_i2c *i2c = dev_id;
+       unsigned long status;
+
+       status = readl(i2c->regs + CSR);
+       writel(status | IRQFLAG, i2c->regs + CSR);
+
+       if (status & ARBIT_LOST) {
+               /* deal with arbitration loss */
+               dev_err(i2c->dev, "deal with arbitration loss\n");
+               goto out;
+       }
+
+       if (i2c->state == STATE_IDLE) {
+               dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n");
+               goto out;
+       }
+
+       /* pretty much this leaves us with the fact that we've
+        * transmitted or received whatever byte we last sent
+       */
+
+       i2c_nuc900_irq_nextbyte(i2c, status);
+
+ out:
+       return IRQ_HANDLED;
+}
+
+
+/* nuc900_i2c_set_master
+ *
+ * get the i2c bus for a master transaction
+*/
+
+static int nuc900_i2c_set_master(struct nuc900_i2c *i2c)
+{
+       int timeout = 400;
+
+       while (timeout-- > 0) {
+               if (((readl(i2c->regs + SWR) & I2CSTART) == I2CSTART) &&
+                               ((readl(i2c->regs + CSR) & I2CBUSY) == 0)) {
+                       return 0;
+               }
+
+               msleep(1);
+       }
+
+       return -ETIMEDOUT;
+}
+
+/* nuc900_i2c_doxfer
+ *
+ * this starts an i2c transfer
+*/
+
+static int nuc900_i2c_doxfer(struct nuc900_i2c *i2c,
+                             struct i2c_msg *msgs, int num)
+{
+       unsigned long iicstat, timeout;
+       int spins = 20;
+       int ret;
+
+       ret = nuc900_i2c_set_master(i2c);
+       if (ret != 0) {
+               dev_err(i2c->dev, "cannot get bus (error %d)\n", ret);
+               ret = -EAGAIN;
+               goto out;
+       }
+
+       spin_lock_irq(&i2c->lock);
+
+       i2c->msg     = msgs;
+       i2c->msg_num = num;
+       i2c->msg_ptr = 0;
+       i2c->msg_idx = 0;
+       i2c->state   = STATE_START;
+
+       nuc900_i2c_message_start(i2c, msgs);
+       spin_unlock_irq(&i2c->lock);
+
+       timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5);
+
+       ret = i2c->msg_idx;
+
+       /* having these next two as dev_err() makes life very
+        * noisy when doing an i2cdetect
+       */
+
+       if (timeout == 0)
+               dev_dbg(i2c->dev, "timeout\n");
+       else if (ret != num)
+               dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret);
+
+       /* ensure the stop has been through the bus */
+
+       dev_dbg(i2c->dev, "waiting for bus idle\n");
+
+       /* first, try busy waiting briefly */
+       do {
+               iicstat = readl(i2c->regs + CSR);
+       } while ((iicstat & I2CBUSY) && --spins);
+
+       /* if that timed out sleep */
+       if (!spins) {
+               msleep(1);
+               iicstat = readl(i2c->regs + CSR);
+       }
+
+       if (iicstat & I2CBUSY)
+               dev_warn(i2c->dev, "timeout waiting for bus idle\n");
+
+ out:
+       return ret;
+}
+
+/* nuc900_i2c_xfer
+ *
+ * first port of call from the i2c bus code when an message needs
+ * transferring across the i2c bus.
+*/
+
+static int nuc900_i2c_xfer(struct i2c_adapter *adap,
+                       struct i2c_msg *msgs, int num)
+{
+       struct nuc900_i2c *i2c = (struct nuc900_i2c *)adap->algo_data;
+       int retry;
+       int ret;
+
+       nuc900_i2c_enable_irq(i2c);
+
+       for (retry = 0; retry < adap->retries; retry++) {
+
+               ret = nuc900_i2c_doxfer(i2c, msgs, num);
+
+               if (ret != -EAGAIN)
+                       return ret;
+
+               dev_dbg(i2c->dev, "Retrying transmission (%d)\n", retry);
+
+               udelay(100);
+       }
+
+       return -EREMOTEIO;
+}
+
+/* declare our i2c functionality */
+static u32 nuc900_i2c_func(struct i2c_adapter *adap)
+{
+       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING;
+}
+
+/* i2c bus registration info */
+
+static const struct i2c_algorithm nuc900_i2c_algorithm = {
+       .master_xfer            = nuc900_i2c_xfer,
+       .functionality          = nuc900_i2c_func,
+};
+
+/* nuc900_i2c_probe
+ *
+ * called by the bus driver when a suitable device is found
+*/
+
+static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
+{
+       struct nuc900_i2c *i2c;
+       struct nuc900_platform_i2c *pdata;
+       struct resource *res;
+       int ret;
+
+       pdata = pdev->dev.platform_data;
+       if (!pdata) {
+               dev_err(&pdev->dev, "no platform data\n");
+               return -EINVAL;
+       }
+
+       i2c = kzalloc(sizeof(struct nuc900_i2c), GFP_KERNEL);
+       if (!i2c) {
+               dev_err(&pdev->dev, "no memory for state\n");
+               return -ENOMEM;
+       }
+
+       strlcpy(i2c->adap.name, "nuc900-i2c0", sizeof(i2c->adap.name));
+       i2c->adap.owner   = THIS_MODULE;
+       i2c->adap.algo    = &nuc900_i2c_algorithm;
+       i2c->adap.retries = 2;
+       i2c->adap.class   = I2C_CLASS_HWMON | I2C_CLASS_SPD;
+
+       spin_lock_init(&i2c->lock);
+       init_waitqueue_head(&i2c->wait);
+
+       /* find the clock and enable it */
+
+       i2c->dev = &pdev->dev;
+       i2c->clk = clk_get(&pdev->dev, NULL);
+       if (IS_ERR(i2c->clk)) {
+               dev_err(&pdev->dev, "cannot get clock\n");
+               ret = -ENOENT;
+               goto err_noclk;
+       }
+
+       dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
+
+       clk_enable(i2c->clk);
+
+       /* map the registers */
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (res == NULL) {
+               dev_err(&pdev->dev, "cannot find IO resource\n");
+               ret = -ENOENT;
+               goto err_clk;
+       }
+
+       i2c->ioarea = request_mem_region(res->start, resource_size(res),
+                                        pdev->name);
+
+       if (i2c->ioarea == NULL) {
+               dev_err(&pdev->dev, "cannot request IO\n");
+               ret = -ENXIO;
+               goto err_clk;
+       }
+
+       i2c->regs = ioremap(res->start, resource_size(res));
+
+       if (i2c->regs == NULL) {
+               dev_err(&pdev->dev, "cannot map IO\n");
+               ret = -ENXIO;
+               goto err_ioarea;
+       }
+
+       dev_dbg(&pdev->dev, "registers %p (%p, %p)\n",
+               i2c->regs, i2c->ioarea, res);
+
+       /* setup info block for the i2c core */
+
+       i2c->adap.algo_data = i2c;
+       i2c->adap.dev.parent = &pdev->dev;
+
+       mfp_set_groupg(&pdev->dev);
+
+       clk_get_rate(i2c->clk);
+
+       ret = (i2c->clk.apbfreq)/(pdata->bus_freq * 5) - 1;
+       writel(ret & 0xffff, i2c->regs + DIVIDER);
+
+       /* find the IRQ for this unit (note, this relies on the init call to
+        * ensure no current IRQs pending
+        */
+
+       i2c->irq = ret = platform_get_irq(pdev, 0);
+       if (ret <= 0) {
+               dev_err(&pdev->dev, "cannot find IRQ\n");
+               goto err_iomap;
+       }
+
+       ret = request_irq(i2c->irq, nuc900_i2c_irq, IRQF_DISABLED | IRQF_SHARED,
+                         dev_name(&pdev->dev), i2c);
+
+       if (ret != 0) {
+               dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
+               goto err_iomap;
+       }
+
+       /* Note, previous versions of the driver used i2c_add_adapter()
+        * to add the bus at any number. We now pass the bus number via
+        * the platform data, so if unset it will now default to always
+        * being bus 0.
+        */
+
+       i2c->adap.nr = pdata->bus_num;
+
+       ret = i2c_add_numbered_adapter(&i2c->adap);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "failed to add bus to i2c core\n");
+               goto err_irq;
+       }
+
+       platform_set_drvdata(pdev, i2c);
+
+       dev_info(&pdev->dev, "%s: NUC900 I2C adapter\n",
+                                               dev_name(&i2c->adap.dev));
+       return 0;
+
+ err_irq:
+       free_irq(i2c->irq, i2c);
+
+ err_iomap:
+       iounmap(i2c->regs);
+
+ err_ioarea:
+       release_resource(i2c->ioarea);
+       kfree(i2c->ioarea);
+
+ err_clk:
+       clk_disable(i2c->clk);
+       clk_put(i2c->clk);
+
+ err_noclk:
+       kfree(i2c);
+       return ret;
+}
+
+/* nuc900_i2c_remove
+ *
+ * called when device is removed from the bus
+*/
+
+static int __devexit nuc900_i2c_remove(struct platform_device *pdev)
+{
+       struct nuc900_i2c *i2c = platform_get_drvdata(pdev);
+
+       i2c_del_adapter(&i2c->adap);
+       free_irq(i2c->irq, i2c);
+
+       clk_disable(i2c->clk);
+       clk_put(i2c->clk);
+
+       iounmap(i2c->regs);
+
+       release_resource(i2c->ioarea);
+       kfree(i2c->ioarea);
+       kfree(i2c);
+
+       return 0;
+}
+
+static struct platform_driver nuc900_i2c_driver = {
+       .probe          = nuc900_i2c_probe,
+       .remove         = __devexit_p(nuc900_i2c_remove),
+       .driver         = {
+               .owner  = THIS_MODULE,
+               .name   = "nuc900-i2c0",
+       },
+};
+
+static int __init i2c_adap_nuc900_init(void)
+{
+       return platform_driver_register(&nuc900_i2c_driver);
+}
+
+static void __exit i2c_adap_nuc900_exit(void)
+{
+       platform_driver_unregister(&nuc900_i2c_driver);
+}
+subsys_initcall(i2c_adap_nuc900_init);
+module_exit(i2c_adap_nuc900_exit);
+
+MODULE_DESCRIPTION("NUC900 I2C Bus driver");
+MODULE_AUTHOR("Wan ZongShun, <mcuos.com-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:nuc900-i2c0");
index 020ff23d762f4c116eb208cc18e735c6cf69c6d4..c94e51b2651e9b0bb1af7b9904b295331a85c21b 100644 (file)
@@ -1001,7 +1001,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
        struct pxa_i2c *i2c;
        struct resource *res;
        struct i2c_pxa_platform_data *plat = dev->dev.platform_data;
-       struct platform_device_id *id = platform_get_device_id(dev);
+       const struct platform_device_id *id = platform_get_device_id(dev);
        int ret;
        int irq;
 
index b8f1719d7c0259d39e5700bbe7ae249a46d14e4b..c425681a1503d0f476192434b731bdc753a674a3 100644 (file)
@@ -8049,7 +8049,7 @@ union loginfo_type {
                        code_desc = ir_code_str[sas_loginfo.dw.code];
                        if (sas_loginfo.dw.subcode >=
                            ARRAY_SIZE(raid_sub_code_str))
-                       break;
+                               break;
                        if (sas_loginfo.dw.code == 0)
                                sub_code_desc =
                                    raid_sub_code_str[sas_loginfo.dw.subcode];
index 1145ea0792e6b32f86973a92c5f15e9cc8ea2e83..62a35822003ef5b0383c1c97ddaaaf05c1c7a479 100644 (file)
@@ -182,7 +182,7 @@ mmc_spi_readbytes(struct mmc_spi_host *host, unsigned len)
                                host->data_dma, sizeof(*host->data),
                                DMA_FROM_DEVICE);
 
-       status = spi_sync(host->spi, &host->readback);
+       status = spi_sync_locked(host->spi, &host->readback);
 
        if (host->dma_dev)
                dma_sync_single_for_cpu(host->dma_dev,
@@ -541,7 +541,7 @@ mmc_spi_command_send(struct mmc_spi_host *host,
                                host->data_dma, sizeof(*host->data),
                                DMA_BIDIRECTIONAL);
        }
-       status = spi_sync(host->spi, &host->m);
+       status = spi_sync_locked(host->spi, &host->m);
 
        if (host->dma_dev)
                dma_sync_single_for_cpu(host->dma_dev,
@@ -685,7 +685,7 @@ mmc_spi_writeblock(struct mmc_spi_host *host, struct spi_transfer *t,
                                host->data_dma, sizeof(*scratch),
                                DMA_BIDIRECTIONAL);
 
-       status = spi_sync(spi, &host->m);
+       status = spi_sync_locked(spi, &host->m);
 
        if (status != 0) {
                dev_dbg(&spi->dev, "write error (%d)\n", status);
@@ -822,7 +822,7 @@ mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t,
                                DMA_FROM_DEVICE);
        }
 
-       status = spi_sync(spi, &host->m);
+       status = spi_sync_locked(spi, &host->m);
 
        if (host->dma_dev) {
                dma_sync_single_for_cpu(host->dma_dev,
@@ -1018,7 +1018,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
                                        host->data_dma, sizeof(*scratch),
                                        DMA_BIDIRECTIONAL);
 
-               tmp = spi_sync(spi, &host->m);
+               tmp = spi_sync_locked(spi, &host->m);
 
                if (host->dma_dev)
                        dma_sync_single_for_cpu(host->dma_dev,
@@ -1084,6 +1084,9 @@ static void mmc_spi_request(struct mmc_host *mmc, struct mmc_request *mrq)
        }
 #endif
 
+       /* request exclusive bus access */
+       spi_bus_lock(host->spi->master);
+
        /* issue command; then optionally data and stop */
        status = mmc_spi_command_send(host, mrq, mrq->cmd, mrq->data != NULL);
        if (status == 0 && mrq->data) {
@@ -1094,6 +1097,9 @@ static void mmc_spi_request(struct mmc_host *mmc, struct mmc_request *mrq)
                        mmc_cs_off(host);
        }
 
+       /* release the bus */
+       spi_bus_unlock(host->spi->master);
+
        mmc_request_done(host->mmc, mrq);
 }
 
@@ -1290,23 +1296,6 @@ mmc_spi_detect_irq(int irq, void *mmc)
        return IRQ_HANDLED;
 }
 
-struct count_children {
-       unsigned        n;
-       struct bus_type *bus;
-};
-
-static int maybe_count_child(struct device *dev, void *c)
-{
-       struct count_children *ccp = c;
-
-       if (dev->bus == ccp->bus) {
-               if (ccp->n)
-                       return -EBUSY;
-               ccp->n++;
-       }
-       return 0;
-}
-
 static int mmc_spi_probe(struct spi_device *spi)
 {
        void                    *ones;
@@ -1338,32 +1327,6 @@ static int mmc_spi_probe(struct spi_device *spi)
                return status;
        }
 
-       /* We can use the bus safely iff nobody else will interfere with us.
-        * Most commands consist of one SPI message to issue a command, then
-        * several more to collect its response, then possibly more for data
-        * transfer.  Clocking access to other devices during that period will
-        * corrupt the command execution.
-        *
-        * Until we have software primitives which guarantee non-interference,
-        * we'll aim for a hardware-level guarantee.
-        *
-        * REVISIT we can't guarantee another device won't be added later...
-        */
-       if (spi->master->num_chipselect > 1) {
-               struct count_children cc;
-
-               cc.n = 0;
-               cc.bus = spi->dev.bus;
-               status = device_for_each_child(spi->dev.parent, &cc,
-                               maybe_count_child);
-               if (status < 0) {
-                       dev_err(&spi->dev, "can't share SPI bus\n");
-                       return status;
-               }
-
-               dev_warn(&spi->dev, "ASSUMING SPI bus stays unshared!\n");
-       }
-
        /* We need a supply of ones to transmit.  This is the only time
         * the CPU touches these, so cache coherency isn't a concern.
         *
index 6466231f338bdb95ef147a64f478bd8857b05535..bbf91aec64f555e532919f680a4702c99fcfd9b2 100644 (file)
@@ -370,6 +370,14 @@ config ISCSI_TCP
 
         http://open-iscsi.org
 
+config ISCSI_BOOT_SYSFS
+       tristate "iSCSI Boot Sysfs Interface"
+       default n
+       help
+         This option enables support for exposing iSCSI boot information
+         via sysfs to userspace. If you wish to export this information,
+         say Y. Otherwise, say N.
+
 source "drivers/scsi/cxgb3i/Kconfig"
 source "drivers/scsi/bnx2i/Kconfig"
 source "drivers/scsi/be2iscsi/Kconfig"
index 2a3fca2eca6ae00d8ec9f4a084610daf47a60ece..2703c6ec5e369a3464e7e2ac3100ff50acf1729f 100644 (file)
@@ -42,6 +42,7 @@ obj-$(CONFIG_FCOE)            += fcoe/
 obj-$(CONFIG_FCOE_FNIC)                += fnic/
 obj-$(CONFIG_ISCSI_TCP)        += libiscsi.o   libiscsi_tcp.o iscsi_tcp.o
 obj-$(CONFIG_INFINIBAND_ISER)  += libiscsi.o
+obj-$(CONFIG_ISCSI_BOOT_SYSFS) += iscsi_boot_sysfs.o
 obj-$(CONFIG_SCSI_A4000T)      += 53c700.o     a4000t.o
 obj-$(CONFIG_SCSI_ZORRO7XX)    += 53c700.o     zorro7xx.o
 obj-$(CONFIG_A3000_SCSI)       += a3000.o      wd33c93.o
index 84c275fb9f6bea798eb1d5e2c960e9b75abcc6e9..ceaca32e788dcd24d6d2ca583bdaf48dcaaeeeea 100644 (file)
@@ -2,6 +2,7 @@ config BE2ISCSI
        tristate "ServerEngines' 10Gbps iSCSI - BladeEngine 2"
        depends on PCI && SCSI && NET
        select SCSI_ISCSI_ATTRS
+       select ISCSI_BOOT_SYSFS
 
        help
        This driver implements the iSCSI functionality for ServerEngines'
index 40641d0845f4652844ff588c3c644a83d6097b78..5218de4ab35a35b2b6817dd591535f025507f32a 100644 (file)
@@ -162,6 +162,13 @@ struct be_mcc_mailbox {
 #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES         2
 #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES        3
 #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG                7
+#define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN              14
+#define OPCODE_COMMON_ISCSI_NTWK_CONFIGURE_STATELESS_IP_ADDR   17
+#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR                21
+#define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY   22
+#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
+#define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID         24
+#define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO           25
 #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
 #define OPCODE_COMMON_ISCSI_DEFQ_CREATE                 64
 #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY               65
@@ -237,11 +244,109 @@ struct be_cmd_resp_eq_create {
        u16 rsvd0;              /* sword */
 } __packed;
 
+struct mgmt_chap_format {
+       u32 flags;
+       u8  intr_chap_name[256];
+       u8  intr_secret[16];
+       u8  target_chap_name[256];
+       u8  target_secret[16];
+       u16 intr_chap_name_length;
+       u16 intr_secret_length;
+       u16 target_chap_name_length;
+       u16 target_secret_length;
+} __packed;
+
+struct mgmt_auth_method_format {
+       u8      auth_method_type;
+       u8      padding[3];
+       struct  mgmt_chap_format chap;
+} __packed;
+
+struct mgmt_conn_login_options {
+       u8 flags;
+       u8 header_digest;
+       u8 data_digest;
+       u8 rsvd0;
+       u32 max_recv_datasegment_len_ini;
+       u32 max_recv_datasegment_len_tgt;
+       u32 tcp_mss;
+       u32 tcp_window_size;
+       struct  mgmt_auth_method_format auth_data;
+} __packed;
+
+struct ip_address_format {
+       u16 size_of_structure;
+       u8 reserved;
+       u8 ip_type;
+       u8 ip_address[16];
+       u32 rsvd0;
+} __packed;
+
+struct mgmt_conn_info {
+       u32     connection_handle;
+       u32     connection_status;
+       u16     src_port;
+       u16     dest_port;
+       u16     dest_port_redirected;
+       u16     cid;
+       u32     estimated_throughput;
+       struct  ip_address_format       src_ipaddr;
+       struct  ip_address_format       dest_ipaddr;
+       struct  ip_address_format       dest_ipaddr_redirected;
+       struct  mgmt_conn_login_options negotiated_login_options;
+} __packed;
+
+struct mgmt_session_login_options {
+       u8      flags;
+       u8      error_recovery_level;
+       u16     rsvd0;
+       u32     first_burst_length;
+       u32     max_burst_length;
+       u16     max_connections;
+       u16     max_outstanding_r2t;
+       u16     default_time2wait;
+       u16     default_time2retain;
+} __packed;
+
+struct mgmt_session_info {
+       u32     session_handle;
+       u32     status;
+       u8      isid[6];
+       u16     tsih;
+       u32     session_flags;
+       u16     conn_count;
+       u16     pad;
+       u8      target_name[224];
+       u8      initiator_iscsiname[224];
+       struct  mgmt_session_login_options negotiated_login_options;
+       struct  mgmt_conn_info  conn_list[1];
+} __packed;
+
+struct  be_cmd_req_get_session {
+       struct be_cmd_req_hdr hdr;
+       u32 session_handle;
+} __packed;
+
+struct  be_cmd_resp_get_session {
+       struct be_cmd_resp_hdr hdr;
+       struct mgmt_session_info session_info;
+} __packed;
+
 struct mac_addr {
        u16 size_of_struct;
        u8 addr[ETH_ALEN];
 } __packed;
 
+struct be_cmd_req_get_boot_target {
+       struct be_cmd_req_hdr hdr;
+} __packed;
+
+struct be_cmd_resp_get_boot_target {
+       struct be_cmd_resp_hdr hdr;
+       u32  boot_session_count;
+       int  boot_session_handle;
+};
+
 struct be_cmd_req_mac_query {
        struct be_cmd_req_hdr hdr;
        u8 type;
@@ -426,6 +531,11 @@ int be_poll_mcc(struct be_ctrl_info *ctrl);
 int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
                                      struct beiscsi_hba *phba);
 unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba);
+unsigned int beiscsi_get_boot_target(struct beiscsi_hba *phba);
+unsigned int beiscsi_get_session_info(struct beiscsi_hba *phba,
+                                 u32 boot_session_handle,
+                                 struct be_dma_mem *nonemb_cmd);
+
 void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
 /*ISCSI Functuions */
 int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
@@ -601,14 +711,6 @@ struct be_eq_delay_params_in {
        struct eq_delay delay[8];
 } __packed;
 
-struct ip_address_format {
-       u16 size_of_structure;
-       u8 reserved;
-       u8 ip_type;
-       u8 ip_address[16];
-       u32 rsvd0;
-} __packed;
-
 struct tcp_connect_and_offload_in {
        struct be_cmd_req_hdr hdr;
        struct ip_address_format ip_address;
@@ -688,18 +790,29 @@ struct be_fw_cfg {
        u32 function_caps;
 } __packed;
 
-#define CMD_ISCSI_COMMAND_INVALIDATE  1
-#define ISCSI_OPCODE_SCSI_DATA_OUT      5
+struct be_all_if_id {
+       struct be_cmd_req_hdr hdr;
+       u32 if_count;
+       u32 if_hndl_list[1];
+} __packed;
+
+#define ISCSI_OPCODE_SCSI_DATA_OUT             5
+#define OPCODE_COMMON_MODIFY_EQ_DELAY          41
+#define OPCODE_COMMON_ISCSI_CLEANUP            59
+#define        OPCODE_COMMON_TCP_UPLOAD                56
 #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
-#define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
-#define OPCODE_COMMON_MODIFY_EQ_DELAY  41
-#define OPCODE_COMMON_ISCSI_CLEANUP    59
-#define        OPCODE_COMMON_TCP_UPLOAD        56
 #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
-/* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
-#define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
-#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
+#define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME      6
+#define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME      7
+#define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION  14
+#define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
 #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
+#define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET  52
+
+/* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
+#define CMD_ISCSI_COMMAND_INVALIDATE           1
+#define CMD_ISCSI_CONNECTION_INVALIDATE                0x8001
+#define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST     0x8002
 
 #define INI_WR_CMD                     1       /* Initiator write command */
 #define INI_TMF_CMD                    2       /* Initiator TMF command */
index 6d63e7b312cf61d33dfb0c5c7e9d11226168ba9a..7d4d2275573c138d9e1c5223e41928defd4649aa 100644 (file)
@@ -300,40 +300,16 @@ int beiscsi_get_host_param(struct Scsi_Host *shost,
                           enum iscsi_host_param param, char *buf)
 {
        struct beiscsi_hba *phba = (struct beiscsi_hba *)iscsi_host_priv(shost);
-       struct be_cmd_resp_get_mac_addr *resp;
-       struct be_mcc_wrb *wrb;
-       unsigned int tag, wrb_num;
        int len = 0;
-       unsigned short status, extd_status;
-       struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
+       int status;
 
        SE_DEBUG(DBG_LVL_8, "In beiscsi_get_host_param, param= %d\n", param);
        switch (param) {
        case ISCSI_HOST_PARAM_HWADDRESS:
-               tag = be_cmd_get_mac_addr(phba);
-               if (!tag) {
-                       SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed\n");
-                       return -EAGAIN;
-               } else
-                       wait_event_interruptible(phba->ctrl.mcc_wait[tag],
-                                                phba->ctrl.mcc_numtag[tag]);
-
-               wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16;
-               extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
-               status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
-               if (status || extd_status) {
-                       SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed"
-                                           " status = %d extd_status = %d\n",
-                                           status, extd_status);
-                       free_mcc_tag(&phba->ctrl, tag);
-                       return -EAGAIN;
-               } else {
-                       wrb = queue_get_wrb(mccq, wrb_num);
-                       free_mcc_tag(&phba->ctrl, tag);
-                       resp = embedded_payload(wrb);
-                       memcpy(phba->mac_address, resp->mac_address, ETH_ALEN);
-                       len = sysfs_format_mac(buf, phba->mac_address,
-                                              ETH_ALEN);
+               status = beiscsi_get_macaddr(buf, phba);
+               if (status < 0) {
+                       SE_DEBUG(DBG_LVL_1, "beiscsi_get_macaddr Failed\n");
+                       return status;
                }
                break;
        default:
@@ -342,6 +318,48 @@ int beiscsi_get_host_param(struct Scsi_Host *shost,
        return len;
 }
 
+int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba)
+{
+       struct be_cmd_resp_get_mac_addr *resp;
+       struct be_mcc_wrb *wrb;
+       unsigned int tag, wrb_num;
+       unsigned short status, extd_status;
+       struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
+       int rc;
+
+       if (phba->read_mac_address)
+               return sysfs_format_mac(buf, phba->mac_address,
+                                       ETH_ALEN);
+
+       tag = be_cmd_get_mac_addr(phba);
+       if (!tag) {
+               SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed\n");
+               return -EBUSY;
+       } else
+               wait_event_interruptible(phba->ctrl.mcc_wait[tag],
+                                        phba->ctrl.mcc_numtag[tag]);
+
+       wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16;
+       extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
+       status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
+       if (status || extd_status) {
+               SE_DEBUG(DBG_LVL_1, "Failed to get be_cmd_get_mac_addr"
+                                   " status = %d extd_status = %d\n",
+                                   status, extd_status);
+               free_mcc_tag(&phba->ctrl, tag);
+               return -EAGAIN;
+       }
+       wrb = queue_get_wrb(mccq, wrb_num);
+       free_mcc_tag(&phba->ctrl, tag);
+       resp = embedded_payload(wrb);
+       memcpy(phba->mac_address, resp->mac_address, ETH_ALEN);
+       rc = sysfs_format_mac(buf, phba->mac_address,
+                              ETH_ALEN);
+       phba->read_mac_address = 1;
+       return rc;
+}
+
+
 /**
  * beiscsi_conn_get_stats - get the iscsi stats
  * @cls_conn: pointer to iscsi cls conn
index 870cdb2a73e45070caa50e679c89b2ff7c9c9ed2..8950a702b9f4ab5941a9fe84bf24aa4a510be5b3 100644 (file)
@@ -54,6 +54,8 @@ int beiscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
 int beiscsi_get_host_param(struct Scsi_Host *shost,
                           enum iscsi_host_param param, char *buf);
 
+int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba);
+
 int beiscsi_set_param(struct iscsi_cls_conn *cls_conn,
                      enum iscsi_param param, char *buf, int buflen);
 
index 7436c5ad569706261c02fd7d7d95f793cedfcb1b..8220bde6c04c6f5aebae94e74b3c7ffd72f16d57 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/semaphore.h>
+#include <linux/iscsi_boot_sysfs.h>
 
 #include <scsi/libiscsi.h>
 #include <scsi/scsi_transport_iscsi.h>
@@ -211,6 +212,218 @@ unlock:
        return rc;
 }
 
+static ssize_t beiscsi_show_boot_tgt_info(void *data, int type, char *buf)
+{
+       struct beiscsi_hba *phba = data;
+       char *str = buf;
+       int rc;
+
+       switch (type) {
+       case ISCSI_BOOT_TGT_NAME:
+               rc = sprintf(buf, "%.*s\n",
+                               (int)strlen(phba->boot_sess.target_name),
+                               (char *)&phba->boot_sess.target_name);
+               break;
+       case ISCSI_BOOT_TGT_IP_ADDR:
+               if (phba->boot_sess.conn_list[0].dest_ipaddr.ip_type == 0x1)
+                       rc = sprintf(buf, "%pI4\n",
+                               (char *)&phba->boot_sess.conn_list[0].
+                               dest_ipaddr.ip_address);
+               else
+                       rc = sprintf(str, "%pI6\n",
+                               (char *)&phba->boot_sess.conn_list[0].
+                               dest_ipaddr.ip_address);
+               break;
+       case ISCSI_BOOT_TGT_PORT:
+               rc = sprintf(str, "%d\n", phba->boot_sess.conn_list[0].
+                                 dest_port);
+               break;
+
+       case ISCSI_BOOT_TGT_CHAP_NAME:
+               rc = sprintf(str,  "%.*s\n",
+                                     phba->boot_sess.conn_list[0].
+                                     negotiated_login_options.auth_data.chap.
+                                     target_chap_name_length,
+                                     (char *)&phba->boot_sess.conn_list[0].
+                                     negotiated_login_options.auth_data.chap.
+                                     target_chap_name);
+               break;
+       case ISCSI_BOOT_TGT_CHAP_SECRET:
+               rc = sprintf(str,  "%.*s\n",
+                                     phba->boot_sess.conn_list[0].
+                                     negotiated_login_options.auth_data.chap.
+                                     target_secret_length,
+                                     (char *)&phba->boot_sess.conn_list[0].
+                                     negotiated_login_options.auth_data.chap.
+                                     target_secret);
+
+               break;
+       case ISCSI_BOOT_TGT_REV_CHAP_NAME:
+               rc = sprintf(str,  "%.*s\n",
+                                     phba->boot_sess.conn_list[0].
+                                     negotiated_login_options.auth_data.chap.
+                                     intr_chap_name_length,
+                                     (char *)&phba->boot_sess.conn_list[0].
+                                     negotiated_login_options.auth_data.chap.
+                                     intr_chap_name);
+
+               break;
+       case ISCSI_BOOT_TGT_REV_CHAP_SECRET:
+                       rc = sprintf(str,  "%.*s\n",
+                                     phba->boot_sess.conn_list[0].
+                                     negotiated_login_options.auth_data.chap.
+                                     intr_secret_length,
+                                     (char *)&phba->boot_sess.conn_list[0].
+                                     negotiated_login_options.auth_data.chap.
+                                     intr_secret);
+               break;
+       case ISCSI_BOOT_TGT_FLAGS:
+                       rc = sprintf(str, "2\n");
+               break;
+       case ISCSI_BOOT_TGT_NIC_ASSOC:
+                       rc = sprintf(str, "0\n");
+               break;
+       default:
+               rc = -ENOSYS;
+               break;
+       }
+       return rc;
+}
+
+static ssize_t beiscsi_show_boot_ini_info(void *data, int type, char *buf)
+{
+       struct beiscsi_hba *phba = data;
+       char *str = buf;
+       int rc;
+
+       switch (type) {
+       case ISCSI_BOOT_INI_INITIATOR_NAME:
+               rc = sprintf(str, "%s\n", phba->boot_sess.initiator_iscsiname);
+               break;
+       default:
+               rc = -ENOSYS;
+               break;
+       }
+       return rc;
+}
+
+static ssize_t beiscsi_show_boot_eth_info(void *data, int type, char *buf)
+{
+       struct beiscsi_hba *phba = data;
+       char *str = buf;
+       int rc;
+
+       switch (type) {
+       case ISCSI_BOOT_ETH_FLAGS:
+                       rc = sprintf(str, "2\n");
+               break;
+       case ISCSI_BOOT_ETH_INDEX:
+                       rc = sprintf(str, "0\n");
+               break;
+       case ISCSI_BOOT_ETH_MAC:
+               rc  = beiscsi_get_macaddr(buf, phba);
+               if (rc < 0) {
+                       SE_DEBUG(DBG_LVL_1, "beiscsi_get_macaddr Failed\n");
+                       return rc;
+               }
+       break;
+       default:
+               rc = -ENOSYS;
+               break;
+       }
+       return rc;
+}
+
+
+static mode_t beiscsi_tgt_get_attr_visibility(void *data, int type)
+{
+       int rc;
+
+       switch (type) {
+       case ISCSI_BOOT_TGT_NAME:
+       case ISCSI_BOOT_TGT_IP_ADDR:
+       case ISCSI_BOOT_TGT_PORT:
+       case ISCSI_BOOT_TGT_CHAP_NAME:
+       case ISCSI_BOOT_TGT_CHAP_SECRET:
+       case ISCSI_BOOT_TGT_REV_CHAP_NAME:
+       case ISCSI_BOOT_TGT_REV_CHAP_SECRET:
+       case ISCSI_BOOT_TGT_NIC_ASSOC:
+       case ISCSI_BOOT_TGT_FLAGS:
+               rc = S_IRUGO;
+               break;
+       default:
+               rc = 0;
+               break;
+       }
+       return rc;
+}
+
+static mode_t beiscsi_ini_get_attr_visibility(void *data, int type)
+{
+       int rc;
+
+       switch (type) {
+       case ISCSI_BOOT_INI_INITIATOR_NAME:
+               rc = S_IRUGO;
+               break;
+       default:
+               rc = 0;
+               break;
+       }
+       return rc;
+}
+
+
+static mode_t beiscsi_eth_get_attr_visibility(void *data, int type)
+{
+       int rc;
+
+       switch (type) {
+       case ISCSI_BOOT_ETH_FLAGS:
+       case ISCSI_BOOT_ETH_MAC:
+       case ISCSI_BOOT_ETH_INDEX:
+               rc = S_IRUGO;
+               break;
+       default:
+               rc = 0;
+               break;
+       }
+       return rc;
+}
+
+static int beiscsi_setup_boot_info(struct beiscsi_hba *phba)
+{
+       struct iscsi_boot_kobj *boot_kobj;
+
+       phba->boot_kset = iscsi_boot_create_host_kset(phba->shost->host_no);
+       if (!phba->boot_kset)
+               return -ENOMEM;
+
+       /* get boot info using mgmt cmd */
+       boot_kobj = iscsi_boot_create_target(phba->boot_kset, 0, phba,
+                                            beiscsi_show_boot_tgt_info,
+                                            beiscsi_tgt_get_attr_visibility);
+       if (!boot_kobj)
+               goto free_kset;
+
+       boot_kobj = iscsi_boot_create_initiator(phba->boot_kset, 0, phba,
+                                            beiscsi_show_boot_ini_info,
+                                            beiscsi_ini_get_attr_visibility);
+       if (!boot_kobj)
+               goto free_kset;
+
+       boot_kobj = iscsi_boot_create_ethernet(phba->boot_kset, 0, phba,
+                                            beiscsi_show_boot_eth_info,
+                                            beiscsi_eth_get_attr_visibility);
+       if (!boot_kobj)
+               goto free_kset;
+       return 0;
+
+free_kset:
+       iscsi_boot_destroy_kset(phba->boot_kset);
+       return -ENOMEM;
+}
+
 /*------------------- PCI Driver operations and data ----------------- */
 static DEFINE_PCI_DEVICE_TABLE(beiscsi_pci_id_table) = {
        { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) },
@@ -268,6 +481,15 @@ static struct beiscsi_hba *beiscsi_hba_alloc(struct pci_dev *pcidev)
 
        if (iscsi_host_add(shost, &phba->pcidev->dev))
                goto free_devices;
+
+       if (beiscsi_setup_boot_info(phba))
+               /*
+                * log error but continue, because we may not be using
+                * iscsi boot.
+                */
+               shost_printk(KERN_ERR, phba->shost, "Could not set up "
+               "iSCSI boot info.");
+
        return phba;
 
 free_devices:
@@ -3279,6 +3501,89 @@ static void hwi_disable_intr(struct beiscsi_hba *phba)
                             "In hwi_disable_intr, Already Disabled\n");
 }
 
+static int beiscsi_get_boot_info(struct beiscsi_hba *phba)
+{
+       struct be_cmd_resp_get_boot_target *boot_resp;
+       struct be_cmd_resp_get_session *session_resp;
+       struct be_mcc_wrb *wrb;
+       struct be_dma_mem nonemb_cmd;
+       unsigned int tag, wrb_num;
+       unsigned short status, extd_status;
+       struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q;
+
+       tag = beiscsi_get_boot_target(phba);
+       if (!tag) {
+               SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed\n");
+               return -EAGAIN;
+       } else
+               wait_event_interruptible(phba->ctrl.mcc_wait[tag],
+                                        phba->ctrl.mcc_numtag[tag]);
+
+       wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16;
+       extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
+       status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
+       if (status || extd_status) {
+               SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed"
+                                   " status = %d extd_status = %d\n",
+                                   status, extd_status);
+               free_mcc_tag(&phba->ctrl, tag);
+               return -EBUSY;
+       }
+       wrb = queue_get_wrb(mccq, wrb_num);
+       free_mcc_tag(&phba->ctrl, tag);
+       boot_resp = embedded_payload(wrb);
+
+       if (boot_resp->boot_session_handle < 0) {
+               printk(KERN_ERR "No Boot Session for this pci_func,"
+                       "session Hndl = %d\n", boot_resp->boot_session_handle);
+               return -ENXIO;
+       }
+
+       nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
+                               sizeof(*session_resp),
+                               &nonemb_cmd.dma);
+       if (nonemb_cmd.va == NULL) {
+               SE_DEBUG(DBG_LVL_1,
+                        "Failed to allocate memory for"
+                        "beiscsi_get_session_info\n");
+               return -ENOMEM;
+       }
+
+       memset(nonemb_cmd.va, 0, sizeof(*session_resp));
+       tag = beiscsi_get_session_info(phba,
+               boot_resp->boot_session_handle, &nonemb_cmd);
+       if (!tag) {
+               SE_DEBUG(DBG_LVL_1, "beiscsi_get_session_info"
+                       " Failed\n");
+               goto boot_freemem;
+       } else
+               wait_event_interruptible(phba->ctrl.mcc_wait[tag],
+                                        phba->ctrl.mcc_numtag[tag]);
+
+       wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16;
+       extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8;
+       status = phba->ctrl.mcc_numtag[tag] & 0x000000FF;
+       if (status || extd_status) {
+               SE_DEBUG(DBG_LVL_1, "beiscsi_get_session_info Failed"
+                                   " status = %d extd_status = %d\n",
+                                   status, extd_status);
+               free_mcc_tag(&phba->ctrl, tag);
+               goto boot_freemem;
+       }
+       wrb = queue_get_wrb(mccq, wrb_num);
+       free_mcc_tag(&phba->ctrl, tag);
+       session_resp = nonemb_cmd.va ;
+       memcpy(&phba->boot_sess, &session_resp->session_info,
+              sizeof(struct mgmt_session_info));
+       pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
+                   nonemb_cmd.va, nonemb_cmd.dma);
+       return 0;
+boot_freemem:
+       pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
+                   nonemb_cmd.va, nonemb_cmd.dma);
+       return -ENOMEM;
+}
+
 static int beiscsi_init_port(struct beiscsi_hba *phba)
 {
        int ret;
@@ -3841,6 +4146,7 @@ static void beiscsi_remove(struct pci_dev *pcidev)
        iscsi_host_remove(phba->shost);
        pci_dev_put(phba->pcidev);
        iscsi_host_free(phba->shost);
+       iscsi_boot_destroy_kset(phba->boot_kset);
 }
 
 static void beiscsi_msix_enable(struct beiscsi_hba *phba)
@@ -3996,6 +4302,11 @@ static int __devinit beiscsi_dev_probe(struct pci_dev *pcidev,
                goto free_blkenbld;
        }
        hwi_enable_intr(phba);
+       ret = beiscsi_get_boot_info(phba);
+       if (ret < 0) {
+               shost_printk(KERN_ERR, phba->shost, "beiscsi_dev_probe-"
+                            "No Boot Devices !!!!!\n");
+       }
        SE_DEBUG(DBG_LVL_8, "\n\n\n SUCCESS - DRIVER LOADED\n\n\n");
        return 0;
 
index c643bb3736fc2849c23dd478e5e477d5ad2c2ebc..90eb74f6bcabae536e298542910c2edf73179829 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "be.h"
 #define DRV_NAME               "be2iscsi"
-#define BUILD_STR              "2.0.527.0"
+#define BUILD_STR              "2.0.549.0"
 #define BE_NAME                        "ServerEngines BladeEngine2" \
                                "Linux iSCSI Driver version" BUILD_STR
 #define DRV_DESC               BE_NAME " " "Driver"
@@ -63,7 +63,7 @@
 #define BEISCSI_SGLIST_ELEMENTS        30
 
 #define BEISCSI_CMD_PER_LUN    128     /* scsi_host->cmd_per_lun */
-#define BEISCSI_MAX_SECTORS    256     /* scsi_host->max_sectors */
+#define BEISCSI_MAX_SECTORS    2048    /* scsi_host->max_sectors */
 
 #define BEISCSI_MAX_CMD_LEN    16      /* scsi_host->max_cmd_len */
 #define BEISCSI_NUM_MAX_LUN    256     /* scsi_host->max_lun */
@@ -312,6 +312,7 @@ struct beiscsi_hba {
        struct list_head hba_queue;
        unsigned short *cid_array;
        struct iscsi_endpoint **ep_array;
+       struct iscsi_boot_kset *boot_kset;
        struct Scsi_Host *shost;
        struct {
                /**
@@ -342,6 +343,8 @@ struct beiscsi_hba {
        struct work_struct work_cqs;    /* The work being queued */
        struct be_ctrl_info ctrl;
        unsigned int generation;
+       unsigned int read_mac_address;
+       struct mgmt_session_info boot_sess;
        struct invalidate_command_table inv_tbl[128];
 
 };
index 3f3fab91a7d19d472f3f78b3b38556c721b20d86..26350e470bccf71ea47b8dd99f387a31aff21670 100644 (file)
 
 #include "be_mgmt.h"
 #include "be_iscsi.h"
+#include <scsi/scsi_transport_iscsi.h>
+
+unsigned int beiscsi_get_boot_target(struct beiscsi_hba *phba)
+{
+       struct be_ctrl_info *ctrl = &phba->ctrl;
+       struct be_mcc_wrb *wrb;
+       struct be_cmd_req_get_mac_addr *req;
+       unsigned int tag = 0;
+
+       SE_DEBUG(DBG_LVL_8, "In bescsi_get_boot_target\n");
+       spin_lock(&ctrl->mbox_lock);
+       tag = alloc_mcc_tag(phba);
+       if (!tag) {
+               spin_unlock(&ctrl->mbox_lock);
+               return tag;
+       }
+
+       wrb = wrb_from_mccq(phba);
+       req = embedded_payload(wrb);
+       wrb->tag0 |= tag;
+       be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);
+       be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
+                          OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET,
+                          sizeof(*req));
+
+       be_mcc_notify(phba);
+       spin_unlock(&ctrl->mbox_lock);
+       return tag;
+}
+
+unsigned int beiscsi_get_session_info(struct beiscsi_hba *phba,
+                                 u32 boot_session_handle,
+                                 struct be_dma_mem *nonemb_cmd)
+{
+       struct be_ctrl_info *ctrl = &phba->ctrl;
+       struct be_mcc_wrb *wrb;
+       unsigned int tag = 0;
+       struct  be_cmd_req_get_session *req;
+       struct be_cmd_resp_get_session *resp;
+       struct be_sge *sge;
+
+       SE_DEBUG(DBG_LVL_8, "In beiscsi_get_session_info\n");
+       spin_lock(&ctrl->mbox_lock);
+       tag = alloc_mcc_tag(phba);
+       if (!tag) {
+               spin_unlock(&ctrl->mbox_lock);
+               return tag;
+       }
+
+       nonemb_cmd->size = sizeof(*resp);
+       req = nonemb_cmd->va;
+       memset(req, 0, sizeof(*req));
+       wrb = wrb_from_mccq(phba);
+       sge = nonembedded_sgl(wrb);
+       wrb->tag0 |= tag;
+
+
+       wrb->tag0 |= tag;
+       be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1);
+       be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI_INI,
+                          OPCODE_ISCSI_INI_SESSION_GET_A_SESSION,
+                          sizeof(*resp));
+       req->session_handle = boot_session_handle;
+       sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd->dma));
+       sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF);
+       sge->len = cpu_to_le32(nonemb_cmd->size);
+
+       be_mcc_notify(phba);
+       spin_unlock(&ctrl->mbox_lock);
+       return tag;
+}
 
 int mgmt_get_fw_config(struct be_ctrl_info *ctrl,
                                struct beiscsi_hba *phba)
index bd96cecaa61902f82734a8aad5399268eb05a819..9f75a6d519a21bc032610cdd5a5a23e4c048af18 100644 (file)
@@ -433,6 +433,9 @@ static void ibmvfc_set_tgt_action(struct ibmvfc_target *tgt,
 {
        switch (tgt->action) {
        case IBMVFC_TGT_ACTION_DEL_RPORT:
+               if (action == IBMVFC_TGT_ACTION_DELETED_RPORT)
+                       tgt->action = action;
+       case IBMVFC_TGT_ACTION_DELETED_RPORT:
                break;
        default:
                if (action == IBMVFC_TGT_ACTION_DEL_RPORT)
@@ -2036,95 +2039,108 @@ static int ibmvfc_reset_device(struct scsi_device *sdev, int type, char *desc)
 }
 
 /**
- * ibmvfc_abort_task_set - Abort outstanding commands to the device
- * @sdev:      scsi device to abort commands
- *
- * This sends an Abort Task Set to the VIOS for the specified device. This does
- * NOT send any cancel to the VIOS. That must be done separately.
+ * ibmvfc_match_rport - Match function for specified remote port
+ * @evt:       ibmvfc event struct
+ * @device:    device to match (rport)
  *
  * Returns:
- *     0 on success / other on failure
+ *     1 if event matches rport / 0 if event does not match rport
  **/
-static int ibmvfc_abort_task_set(struct scsi_device *sdev)
+static int ibmvfc_match_rport(struct ibmvfc_event *evt, void *rport)
 {
-       struct ibmvfc_host *vhost = shost_priv(sdev->host);
-       struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
-       struct ibmvfc_cmd *tmf;
-       struct ibmvfc_event *evt, *found_evt;
-       union ibmvfc_iu rsp_iu;
-       struct ibmvfc_fcp_rsp *fc_rsp = &rsp_iu.cmd.rsp;
-       int rsp_rc = -EBUSY;
-       unsigned long flags;
-       int rsp_code = 0;
+       struct fc_rport *cmd_rport;
 
-       spin_lock_irqsave(vhost->host->host_lock, flags);
-       found_evt = NULL;
-       list_for_each_entry(evt, &vhost->sent, queue) {
-               if (evt->cmnd && evt->cmnd->device == sdev) {
-                       found_evt = evt;
-                       break;
-               }
-       }
-
-       if (!found_evt) {
-               if (vhost->log_level > IBMVFC_DEFAULT_LOG_LEVEL)
-                       sdev_printk(KERN_INFO, sdev, "No events found to abort\n");
-               spin_unlock_irqrestore(vhost->host->host_lock, flags);
-               return 0;
-       }
-
-       if (vhost->state == IBMVFC_ACTIVE) {
-               evt = ibmvfc_get_event(vhost);
-               ibmvfc_init_event(evt, ibmvfc_sync_completion, IBMVFC_CMD_FORMAT);
-
-               tmf = &evt->iu.cmd;
-               memset(tmf, 0, sizeof(*tmf));
-               tmf->resp.va = (u64)evt->crq.ioba + offsetof(struct ibmvfc_cmd, rsp);
-               tmf->resp.len = sizeof(tmf->rsp);
-               tmf->frame_type = IBMVFC_SCSI_FCP_TYPE;
-               tmf->payload_len = sizeof(tmf->iu);
-               tmf->resp_len = sizeof(tmf->rsp);
-               tmf->cancel_key = (unsigned long)sdev->hostdata;
-               tmf->tgt_scsi_id = rport->port_id;
-               int_to_scsilun(sdev->lun, &tmf->iu.lun);
-               tmf->flags = (IBMVFC_NO_MEM_DESC | IBMVFC_TMF);
-               tmf->iu.tmf_flags = IBMVFC_ABORT_TASK_SET;
-               evt->sync_iu = &rsp_iu;
-
-               init_completion(&evt->comp);
-               rsp_rc = ibmvfc_send_event(evt, vhost, default_timeout);
+       if (evt->cmnd) {
+               cmd_rport = starget_to_rport(scsi_target(evt->cmnd->device));
+               if (cmd_rport == rport)
+                       return 1;
        }
+       return 0;
+}
 
-       spin_unlock_irqrestore(vhost->host->host_lock, flags);
+/**
+ * ibmvfc_match_target - Match function for specified target
+ * @evt:       ibmvfc event struct
+ * @device:    device to match (starget)
+ *
+ * Returns:
+ *     1 if event matches starget / 0 if event does not match starget
+ **/
+static int ibmvfc_match_target(struct ibmvfc_event *evt, void *device)
+{
+       if (evt->cmnd && scsi_target(evt->cmnd->device) == device)
+               return 1;
+       return 0;
+}
 
-       if (rsp_rc != 0) {
-               sdev_printk(KERN_ERR, sdev, "Failed to send abort. rc=%d\n", rsp_rc);
-               return -EIO;
-       }
+/**
+ * ibmvfc_match_lun - Match function for specified LUN
+ * @evt:       ibmvfc event struct
+ * @device:    device to match (sdev)
+ *
+ * Returns:
+ *     1 if event matches sdev / 0 if event does not match sdev
+ **/
+static int ibmvfc_match_lun(struct ibmvfc_event *evt, void *device)
+{
+       if (evt->cmnd && evt->cmnd->device == device)
+               return 1;
+       return 0;
+}
 
-       sdev_printk(KERN_INFO, sdev, "Aborting outstanding commands\n");
-       wait_for_completion(&evt->comp);
+/**
+ * ibmvfc_wait_for_ops - Wait for ops to complete
+ * @vhost:     ibmvfc host struct
+ * @device:    device to match (starget or sdev)
+ * @match:     match function
+ *
+ * Returns:
+ *     SUCCESS / FAILED
+ **/
+static int ibmvfc_wait_for_ops(struct ibmvfc_host *vhost, void *device,
+                              int (*match) (struct ibmvfc_event *, void *))
+{
+       struct ibmvfc_event *evt;
+       DECLARE_COMPLETION_ONSTACK(comp);
+       int wait;
+       unsigned long flags;
+       signed long timeout = IBMVFC_ABORT_WAIT_TIMEOUT * HZ;
 
-       if (rsp_iu.cmd.status)
-               rsp_code = ibmvfc_get_err_result(&rsp_iu.cmd);
+       ENTER;
+       do {
+               wait = 0;
+               spin_lock_irqsave(vhost->host->host_lock, flags);
+               list_for_each_entry(evt, &vhost->sent, queue) {
+                       if (match(evt, device)) {
+                               evt->eh_comp = &comp;
+                               wait++;
+                       }
+               }
+               spin_unlock_irqrestore(vhost->host->host_lock, flags);
 
-       if (rsp_code) {
-               if (fc_rsp->flags & FCP_RSP_LEN_VALID)
-                       rsp_code = fc_rsp->data.info.rsp_code;
+               if (wait) {
+                       timeout = wait_for_completion_timeout(&comp, timeout);
 
-               sdev_printk(KERN_ERR, sdev, "Abort failed: %s (%x:%x) "
-                           "flags: %x fcp_rsp: %x, scsi_status: %x\n",
-                           ibmvfc_get_cmd_error(rsp_iu.cmd.status, rsp_iu.cmd.error),
-                           rsp_iu.cmd.status, rsp_iu.cmd.error, fc_rsp->flags, rsp_code,
-                           fc_rsp->scsi_status);
-               rsp_rc = -EIO;
-       } else
-               sdev_printk(KERN_INFO, sdev, "Abort successful\n");
+                       if (!timeout) {
+                               wait = 0;
+                               spin_lock_irqsave(vhost->host->host_lock, flags);
+                               list_for_each_entry(evt, &vhost->sent, queue) {
+                                       if (match(evt, device)) {
+                                               evt->eh_comp = NULL;
+                                               wait++;
+                                       }
+                               }
+                               spin_unlock_irqrestore(vhost->host->host_lock, flags);
+                               if (wait)
+                                       dev_err(vhost->dev, "Timed out waiting for aborted commands\n");
+                               LEAVE;
+                               return wait ? FAILED : SUCCESS;
+                       }
+               }
+       } while (wait);
 
-       spin_lock_irqsave(vhost->host->host_lock, flags);
-       ibmvfc_free_event(evt);
-       spin_unlock_irqrestore(vhost->host->host_lock, flags);
-       return rsp_rc;
+       LEAVE;
+       return SUCCESS;
 }
 
 /**
@@ -2212,88 +2228,130 @@ static int ibmvfc_cancel_all(struct scsi_device *sdev, int type)
 }
 
 /**
- * ibmvfc_match_target - Match function for specified target
+ * ibmvfc_match_key - Match function for specified cancel key
  * @evt:       ibmvfc event struct
- * @device:    device to match (starget)
+ * @key:       cancel key to match
  *
  * Returns:
- *     1 if event matches starget / 0 if event does not match starget
+ *     1 if event matches key / 0 if event does not match key
  **/
-static int ibmvfc_match_target(struct ibmvfc_event *evt, void *device)
+static int ibmvfc_match_key(struct ibmvfc_event *evt, void *key)
 {
-       if (evt->cmnd && scsi_target(evt->cmnd->device) == device)
-               return 1;
-       return 0;
-}
+       unsigned long cancel_key = (unsigned long)key;
 
-/**
- * ibmvfc_match_lun - Match function for specified LUN
- * @evt:       ibmvfc event struct
- * @device:    device to match (sdev)
- *
- * Returns:
- *     1 if event matches sdev / 0 if event does not match sdev
- **/
-static int ibmvfc_match_lun(struct ibmvfc_event *evt, void *device)
-{
-       if (evt->cmnd && evt->cmnd->device == device)
+       if (evt->crq.format == IBMVFC_CMD_FORMAT &&
+           evt->iu.cmd.cancel_key == cancel_key)
                return 1;
        return 0;
 }
 
 /**
- * ibmvfc_wait_for_ops - Wait for ops to complete
- * @vhost:     ibmvfc host struct
- * @device:    device to match (starget or sdev)
- * @match:     match function
+ * ibmvfc_abort_task_set - Abort outstanding commands to the device
+ * @sdev:      scsi device to abort commands
+ *
+ * This sends an Abort Task Set to the VIOS for the specified device. This does
+ * NOT send any cancel to the VIOS. That must be done separately.
  *
  * Returns:
- *     SUCCESS / FAILED
+ *     0 on success / other on failure
  **/
-static int ibmvfc_wait_for_ops(struct ibmvfc_host *vhost, void *device,
-                              int (*match) (struct ibmvfc_event *, void *))
+static int ibmvfc_abort_task_set(struct scsi_device *sdev)
 {
-       struct ibmvfc_event *evt;
-       DECLARE_COMPLETION_ONSTACK(comp);
-       int wait;
-       unsigned long flags;
-       signed long timeout = IBMVFC_ABORT_WAIT_TIMEOUT * HZ;
+       struct ibmvfc_host *vhost = shost_priv(sdev->host);
+       struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
+       struct ibmvfc_cmd *tmf;
+       struct ibmvfc_event *evt, *found_evt;
+       union ibmvfc_iu rsp_iu;
+       struct ibmvfc_fcp_rsp *fc_rsp = &rsp_iu.cmd.rsp;
+       int rc, rsp_rc = -EBUSY;
+       unsigned long flags, timeout = IBMVFC_ABORT_TIMEOUT;
+       int rsp_code = 0;
 
-       ENTER;
-       do {
-               wait = 0;
-               spin_lock_irqsave(vhost->host->host_lock, flags);
-               list_for_each_entry(evt, &vhost->sent, queue) {
-                       if (match(evt, device)) {
-                               evt->eh_comp = &comp;
-                               wait++;
-                       }
+       spin_lock_irqsave(vhost->host->host_lock, flags);
+       found_evt = NULL;
+       list_for_each_entry(evt, &vhost->sent, queue) {
+               if (evt->cmnd && evt->cmnd->device == sdev) {
+                       found_evt = evt;
+                       break;
                }
+       }
+
+       if (!found_evt) {
+               if (vhost->log_level > IBMVFC_DEFAULT_LOG_LEVEL)
+                       sdev_printk(KERN_INFO, sdev, "No events found to abort\n");
                spin_unlock_irqrestore(vhost->host->host_lock, flags);
+               return 0;
+       }
 
-               if (wait) {
-                       timeout = wait_for_completion_timeout(&comp, timeout);
+       if (vhost->state == IBMVFC_ACTIVE) {
+               evt = ibmvfc_get_event(vhost);
+               ibmvfc_init_event(evt, ibmvfc_sync_completion, IBMVFC_CMD_FORMAT);
 
-                       if (!timeout) {
-                               wait = 0;
-                               spin_lock_irqsave(vhost->host->host_lock, flags);
-                               list_for_each_entry(evt, &vhost->sent, queue) {
-                                       if (match(evt, device)) {
-                                               evt->eh_comp = NULL;
-                                               wait++;
-                                       }
-                               }
-                               spin_unlock_irqrestore(vhost->host->host_lock, flags);
-                               if (wait)
-                                       dev_err(vhost->dev, "Timed out waiting for aborted commands\n");
-                               LEAVE;
-                               return wait ? FAILED : SUCCESS;
-                       }
+               tmf = &evt->iu.cmd;
+               memset(tmf, 0, sizeof(*tmf));
+               tmf->resp.va = (u64)evt->crq.ioba + offsetof(struct ibmvfc_cmd, rsp);
+               tmf->resp.len = sizeof(tmf->rsp);
+               tmf->frame_type = IBMVFC_SCSI_FCP_TYPE;
+               tmf->payload_len = sizeof(tmf->iu);
+               tmf->resp_len = sizeof(tmf->rsp);
+               tmf->cancel_key = (unsigned long)sdev->hostdata;
+               tmf->tgt_scsi_id = rport->port_id;
+               int_to_scsilun(sdev->lun, &tmf->iu.lun);
+               tmf->flags = (IBMVFC_NO_MEM_DESC | IBMVFC_TMF);
+               tmf->iu.tmf_flags = IBMVFC_ABORT_TASK_SET;
+               evt->sync_iu = &rsp_iu;
+
+               init_completion(&evt->comp);
+               rsp_rc = ibmvfc_send_event(evt, vhost, default_timeout);
+       }
+
+       spin_unlock_irqrestore(vhost->host->host_lock, flags);
+
+       if (rsp_rc != 0) {
+               sdev_printk(KERN_ERR, sdev, "Failed to send abort. rc=%d\n", rsp_rc);
+               return -EIO;
+       }
+
+       sdev_printk(KERN_INFO, sdev, "Aborting outstanding commands\n");
+       timeout = wait_for_completion_timeout(&evt->comp, timeout);
+
+       if (!timeout) {
+               rc = ibmvfc_cancel_all(sdev, IBMVFC_TMF_ABORT_TASK_SET);
+               if (!rc) {
+                       rc = ibmvfc_wait_for_ops(vhost, sdev->hostdata, ibmvfc_match_key);
+                       if (rc == SUCCESS)
+                               rc = 0;
                }
-       } while (wait);
 
-       LEAVE;
-       return SUCCESS;
+               if (rc) {
+                       sdev_printk(KERN_INFO, sdev, "Cancel failed, resetting host\n");
+                       ibmvfc_reset_host(vhost);
+                       rsp_rc = 0;
+                       goto out;
+               }
+       }
+
+       if (rsp_iu.cmd.status)
+               rsp_code = ibmvfc_get_err_result(&rsp_iu.cmd);
+
+       if (rsp_code) {
+               if (fc_rsp->flags & FCP_RSP_LEN_VALID)
+                       rsp_code = fc_rsp->data.info.rsp_code;
+
+               sdev_printk(KERN_ERR, sdev, "Abort failed: %s (%x:%x) "
+                           "flags: %x fcp_rsp: %x, scsi_status: %x\n",
+                           ibmvfc_get_cmd_error(rsp_iu.cmd.status, rsp_iu.cmd.error),
+                           rsp_iu.cmd.status, rsp_iu.cmd.error, fc_rsp->flags, rsp_code,
+                           fc_rsp->scsi_status);
+               rsp_rc = -EIO;
+       } else
+               sdev_printk(KERN_INFO, sdev, "Abort successful\n");
+
+out:
+       spin_lock_irqsave(vhost->host->host_lock, flags);
+       ibmvfc_free_event(evt);
+       spin_unlock_irqrestore(vhost->host->host_lock, flags);
+       return rsp_rc;
 }
 
 /**
@@ -2350,18 +2408,6 @@ static int ibmvfc_eh_device_reset_handler(struct scsi_cmnd *cmd)
        return rc;
 }
 
-/**
- * ibmvfc_dev_cancel_all_abts - Device iterated cancel all function
- * @sdev:      scsi device struct
- * @data:      return code
- *
- **/
-static void ibmvfc_dev_cancel_all_abts(struct scsi_device *sdev, void *data)
-{
-       unsigned long *rc = data;
-       *rc |= ibmvfc_cancel_all(sdev, IBMVFC_TMF_ABORT_TASK_SET);
-}
-
 /**
  * ibmvfc_dev_cancel_all_reset - Device iterated cancel all function
  * @sdev:      scsi device struct
@@ -2374,18 +2420,6 @@ static void ibmvfc_dev_cancel_all_reset(struct scsi_device *sdev, void *data)
        *rc |= ibmvfc_cancel_all(sdev, IBMVFC_TMF_TGT_RESET);
 }
 
-/**
- * ibmvfc_dev_abort_all - Device iterated abort task set function
- * @sdev:      scsi device struct
- * @data:      return code
- *
- **/
-static void ibmvfc_dev_abort_all(struct scsi_device *sdev, void *data)
-{
-       unsigned long *rc = data;
-       *rc |= ibmvfc_abort_task_set(sdev);
-}
-
 /**
  * ibmvfc_eh_target_reset_handler - Reset the target
  * @cmd:       scsi command struct
@@ -2440,19 +2474,22 @@ static int ibmvfc_eh_host_reset_handler(struct scsi_cmnd *cmd)
  **/
 static void ibmvfc_terminate_rport_io(struct fc_rport *rport)
 {
-       struct scsi_target *starget = to_scsi_target(&rport->dev);
-       struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+       struct Scsi_Host *shost = rport_to_shost(rport);
        struct ibmvfc_host *vhost = shost_priv(shost);
-       unsigned long cancel_rc = 0;
-       unsigned long abort_rc = 0;
-       int rc = FAILED;
+       struct fc_rport *dev_rport;
+       struct scsi_device *sdev;
+       unsigned long rc;
 
        ENTER;
-       starget_for_each_device(starget, &cancel_rc, ibmvfc_dev_cancel_all_abts);
-       starget_for_each_device(starget, &abort_rc, ibmvfc_dev_abort_all);
+       shost_for_each_device(sdev, shost) {
+               dev_rport = starget_to_rport(scsi_target(sdev));
+               if (dev_rport != rport)
+                       continue;
+               ibmvfc_cancel_all(sdev, IBMVFC_TMF_ABORT_TASK_SET);
+               ibmvfc_abort_task_set(sdev);
+       }
 
-       if (!cancel_rc && !abort_rc)
-               rc = ibmvfc_wait_for_ops(vhost, starget, ibmvfc_match_target);
+       rc = ibmvfc_wait_for_ops(vhost, rport, ibmvfc_match_rport);
 
        if (rc == FAILED)
                ibmvfc_issue_fc_host_lip(shost);
@@ -4193,11 +4230,15 @@ static void ibmvfc_tgt_add_rport(struct ibmvfc_target *tgt)
        if (rport && tgt->action == IBMVFC_TGT_ACTION_DEL_RPORT) {
                tgt_dbg(tgt, "Deleting rport\n");
                list_del(&tgt->queue);
+               ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DELETED_RPORT);
                spin_unlock_irqrestore(vhost->host->host_lock, flags);
                fc_remote_port_delete(rport);
                del_timer_sync(&tgt->timer);
                kref_put(&tgt->kref, ibmvfc_release_tgt);
                return;
+       } else if (rport && tgt->action == IBMVFC_TGT_ACTION_DELETED_RPORT) {
+               spin_unlock_irqrestore(vhost->host->host_lock, flags);
+               return;
        }
 
        if (rport) {
@@ -4297,6 +4338,7 @@ static void ibmvfc_do_work(struct ibmvfc_host *vhost)
                                rport = tgt->rport;
                                tgt->rport = NULL;
                                list_del(&tgt->queue);
+                               ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DELETED_RPORT);
                                spin_unlock_irqrestore(vhost->host->host_lock, flags);
                                if (rport)
                                        fc_remote_port_delete(rport);
index d7e8dcd906504b157539ba1751d14d1a50bf3d82..608af394c8cf55d7046729bf7c80aac9f19976a1 100644 (file)
@@ -29,8 +29,8 @@
 #include "viosrp.h"
 
 #define IBMVFC_NAME    "ibmvfc"
-#define IBMVFC_DRIVER_VERSION          "1.0.8"
-#define IBMVFC_DRIVER_DATE             "(June 17, 2010)"
+#define IBMVFC_DRIVER_VERSION          "1.0.9"
+#define IBMVFC_DRIVER_DATE             "(August 5, 2010)"
 
 #define IBMVFC_DEFAULT_TIMEOUT 60
 #define IBMVFC_ADISC_CANCEL_TIMEOUT    45
@@ -38,6 +38,7 @@
 #define IBMVFC_ADISC_PLUS_CANCEL_TIMEOUT       \
                (IBMVFC_ADISC_TIMEOUT + IBMVFC_ADISC_CANCEL_TIMEOUT)
 #define IBMVFC_INIT_TIMEOUT            120
+#define IBMVFC_ABORT_TIMEOUT           8
 #define IBMVFC_ABORT_WAIT_TIMEOUT      40
 #define IBMVFC_MAX_REQUESTS_DEFAULT    100
 
@@ -597,6 +598,7 @@ enum ibmvfc_target_action {
        IBMVFC_TGT_ACTION_INIT,
        IBMVFC_TGT_ACTION_INIT_WAIT,
        IBMVFC_TGT_ACTION_DEL_RPORT,
+       IBMVFC_TGT_ACTION_DELETED_RPORT,
 };
 
 struct ibmvfc_target {
index eac4d09314eb95828ae8f308ec4cc5d77372c629..c797f6b48f05bccff273e06964c0dc06508de174 100644 (file)
@@ -1765,14 +1765,14 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *))
        struct fcoe_dev_stats *stats;
 
        lport = shost_priv(sc_cmd->device->host);
-       spin_unlock_irq(lport->host->host_lock);
 
        rval = fc_remote_port_chkready(rport);
        if (rval) {
                sc_cmd->result = rval;
                done(sc_cmd);
-               goto out;
+               return 0;
        }
+       spin_unlock_irq(lport->host->host_lock);
 
        if (!*(struct fc_remote_port **)rport->dd_data) {
                /*
index 3482d5a5aed21ada9e3adc8b58e125c6c7a01b4d..a50aa03b8ac1826c13d8acb22b6bb613c91e024e 100644 (file)
@@ -775,6 +775,7 @@ struct lpfc_hba {
        uint8_t temp_sensor_support;
        /* Fields used for heart beat. */
        unsigned long last_completion_time;
+       unsigned long skipped_hb;
        struct timer_list hb_tmofunc;
        uint8_t hb_outstanding;
        enum hba_temp_state over_temp_state;
@@ -817,6 +818,8 @@ struct lpfc_hba {
        uint32_t iocb_cnt;
        uint32_t iocb_max;
        atomic_t sdev_cnt;
+       uint8_t fips_spec_rev;
+       uint8_t fips_level;
 };
 
 static inline struct Scsi_Host *
index ad05b266e9501c4ab5f77084a3ff46f3e604cc53..23ce4570833588a2e645f9d64760e3676284d883 100644 (file)
@@ -1239,6 +1239,44 @@ lpfc_poll_store(struct device *dev, struct device_attribute *attr,
        return strlen(buf);
 }
 
+/**
+ * lpfc_fips_level_show - Return the current FIPS level for the HBA
+ * @dev: class unused variable.
+ * @attr: device attribute, not used.
+ * @buf: on return contains the module description text.
+ *
+ * Returns: size of formatted string.
+ **/
+static ssize_t
+lpfc_fips_level_show(struct device *dev,  struct device_attribute *attr,
+                    char *buf)
+{
+       struct Scsi_Host  *shost = class_to_shost(dev);
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+
+       return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_level);
+}
+
+/**
+ * lpfc_fips_rev_show - Return the FIPS Spec revision for the HBA
+ * @dev: class unused variable.
+ * @attr: device attribute, not used.
+ * @buf: on return contains the module description text.
+ *
+ * Returns: size of formatted string.
+ **/
+static ssize_t
+lpfc_fips_rev_show(struct device *dev,  struct device_attribute *attr,
+                  char *buf)
+{
+       struct Scsi_Host  *shost = class_to_shost(dev);
+       struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
+       struct lpfc_hba   *phba = vport->phba;
+
+       return snprintf(buf, PAGE_SIZE, "%d\n", phba->fips_spec_rev);
+}
+
 /**
  * lpfc_param_show - Return a cfg attribute value in decimal
  *
@@ -1677,6 +1715,8 @@ static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
 static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
 static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
 static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL);
+static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL);
+static DEVICE_ATTR(lpfc_fips_rev, S_IRUGO, lpfc_fips_rev_show, NULL);
 
 
 static char *lpfc_soft_wwn_key = "C99G71SL8032A";
@@ -3278,7 +3318,7 @@ LPFC_ATTR_R(enable_bg, 0, 0, 1, "Enable BlockGuard Support");
 #      - Default will result in registering capabilities for all profiles.
 #
 */
-unsigned int lpfc_prot_mask =   SHOST_DIX_TYPE0_PROTECTION;
+unsigned int lpfc_prot_mask = SHOST_DIF_TYPE1_PROTECTION;
 
 module_param(lpfc_prot_mask, uint, 0);
 MODULE_PARM_DESC(lpfc_prot_mask, "host protection mask");
@@ -3383,6 +3423,8 @@ struct device_attribute *lpfc_hba_attrs[] = {
        &dev_attr_iocb_hw,
        &dev_attr_txq_hw,
        &dev_attr_txcmplq_hw,
+       &dev_attr_lpfc_fips_level,
+       &dev_attr_lpfc_fips_rev,
        NULL,
 };
 
@@ -3409,6 +3451,8 @@ struct device_attribute *lpfc_vport_attrs[] = {
        &dev_attr_lpfc_max_scsicmpl_time,
        &dev_attr_lpfc_stat_data_ctrl,
        &dev_attr_lpfc_static_vport,
+       &dev_attr_lpfc_fips_level,
+       &dev_attr_lpfc_fips_rev,
        NULL,
 };
 
index d521569e66207be3c4aca25f47a95ca14c770fc4..49d0cf99c24c0194783d235a4ab143567e378f63 100644 (file)
@@ -2722,15 +2722,6 @@ lpfc_bsg_issue_mbox(struct lpfc_hba *phba, struct fc_bsg_job *job,
                                mbox_req->inExtWLen * sizeof(uint32_t));
                }
 
-               pmboxq->context2 = ext;
-               pmboxq->in_ext_byte_len =
-                       mbox_req->inExtWLen *
-                       sizeof(uint32_t);
-               pmboxq->out_ext_byte_len =
-                       mbox_req->outExtWLen *
-                       sizeof(uint32_t);
-               pmboxq->mbox_offset_word =
-                       mbox_req->mbOffset;
                pmboxq->context2 = ext;
                pmboxq->in_ext_byte_len =
                        mbox_req->inExtWLen * sizeof(uint32_t);
index a11f1ae7b98e5674cb666f97dbdaa32d86658e0e..75e2e569dedefb343e585333559d8e577176d466 100644 (file)
@@ -82,8 +82,7 @@ lpfc_memcpy_from_slim( void *dest, void __iomem *src, unsigned int bytes)
 static inline void
 lpfc_memcpy_to_slim( void __iomem *dest, void *src, unsigned int bytes)
 {
-       /* actually returns 1 byte past dest */
-       memcpy_toio( dest, src, bytes);
+       __iowrite32_copy(dest, src, bytes);
 }
 
 static inline void
index afbed6bc31f0599ca81ec6fea2da07ca7246727e..8d09191c327e7de39a347d7e56ba331b6bfde16d 100644 (file)
@@ -600,6 +600,14 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
                        vport->fc_flag |= FC_VPORT_NEEDS_INIT_VPI;
                        spin_unlock_irq(shost->host_lock);
                }
+       } else if ((phba->sli_rev == LPFC_SLI_REV4) &&
+               !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
+                       /*
+                        * Driver needs to re-reg VPI in order for f/w
+                        * to update the MAC address.
+                        */
+                       lpfc_register_new_vport(phba, vport, ndlp);
+                       return 0;
        }
 
        if (phba->sli_rev < LPFC_SLI_REV4) {
@@ -801,9 +809,12 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
                    (irsp->un.ulpWord[4] != IOERR_SLI_ABORTED)) {
                        lpfc_printf_log(phba, KERN_WARNING, LOG_FIP | LOG_ELS,
                                        "2611 FLOGI failed on registered "
-                                       "FCF record fcf_index:%d, trying "
-                                       "to perform round robin failover\n",
-                                       phba->fcf.current_rec.fcf_indx);
+                                       "FCF record fcf_index(%d), status: "
+                                       "x%x/x%x, tmo:x%x, trying to perform "
+                                       "round robin failover\n",
+                                       phba->fcf.current_rec.fcf_indx,
+                                       irsp->ulpStatus, irsp->un.ulpWord[4],
+                                       irsp->ulpTimeout);
                        fcf_index = lpfc_sli4_fcf_rr_next_index_get(phba);
                        if (fcf_index == LPFC_FCOE_FCF_NEXT_NONE) {
                                /*
@@ -841,6 +852,12 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
                        }
                }
 
+               /* FLOGI failure */
+               lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
+                               "2858 FLOGI failure Status:x%x/x%x TMO:x%x\n",
+                               irsp->ulpStatus, irsp->un.ulpWord[4],
+                               irsp->ulpTimeout);
+
                /* Check for retry */
                if (lpfc_els_retry(phba, cmdiocb, rspiocb))
                        goto out;
@@ -1291,6 +1308,8 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp,
        struct serv_parm *sp;
        uint8_t  name[sizeof(struct lpfc_name)];
        uint32_t rc, keepDID = 0;
+       int  put_node;
+       int  put_rport;
 
        /* Fabric nodes can have the same WWPN so we don't bother searching
         * by WWPN.  Just return the ndlp that was given to us.
@@ -1379,6 +1398,28 @@ lpfc_plogi_confirm_nport(struct lpfc_hba *phba, uint32_t *prsp,
                /* Two ndlps cannot have the same did */
                ndlp->nlp_DID = keepDID;
                lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
+               /* Since we are swapping the ndlp passed in with the new one
+                * and the did has already been swapped, copy over the
+                * state and names.
+                */
+               memcpy(&new_ndlp->nlp_portname, &ndlp->nlp_portname,
+                       sizeof(struct lpfc_name));
+               memcpy(&new_ndlp->nlp_nodename, &ndlp->nlp_nodename,
+                       sizeof(struct lpfc_name));
+               new_ndlp->nlp_state = ndlp->nlp_state;
+               /* Fix up the rport accordingly */
+               rport = ndlp->rport;
+               if (rport) {
+                       rdata = rport->dd_data;
+                       put_node = rdata->pnode != NULL;
+                       put_rport = ndlp->rport != NULL;
+                       rdata->pnode = NULL;
+                       ndlp->rport = NULL;
+                       if (put_node)
+                               lpfc_nlp_put(ndlp);
+                       if (put_rport)
+                               put_device(&rport->dev);
+               }
        }
        return new_ndlp;
 }
@@ -2880,6 +2921,17 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
                retry = 0;
 
        if (retry) {
+               if ((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_FDISC)) {
+                       /* Stop retrying PLOGI and FDISC if in FCF discovery */
+                       if (phba->fcf.fcf_flag & FCF_DISCOVERY) {
+                               lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
+                                                "2849 Stop retry ELS command "
+                                                "x%x to remote NPORT x%x, "
+                                                "Data: x%x x%x\n", cmd, did,
+                                                cmdiocb->retry, delay);
+                               return 0;
+                       }
+               }
 
                /* Retry ELS command <elsCmd> to remote NPORT <did> */
                lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
@@ -6076,8 +6128,12 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
 
        if (mb->mbxStatus) {
                lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
-                                "0915 Register VPI failed: 0x%x\n",
-                                mb->mbxStatus);
+                               "0915 Register VPI failed : Status: x%x"
+                               " upd bit: x%x \n", mb->mbxStatus,
+                                mb->un.varRegVpi.upd);
+               if (phba->sli_rev == LPFC_SLI_REV4 &&
+                       mb->un.varRegVpi.upd)
+                       goto mbox_err_exit ;
 
                switch (mb->mbxStatus) {
                case 0x11:      /* unsupported feature */
@@ -6142,7 +6198,7 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
                } else
                        lpfc_do_scr_ns_plogi(phba, vport);
        }
-
+mbox_err_exit:
        /* Now, we decrement the ndlp reference count held for this
         * callback function
         */
@@ -6387,6 +6443,14 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
                else
                        vport->fc_flag |= FC_LOGO_RCVD_DID_CHNG;
                spin_unlock_irq(shost->host_lock);
+       } else if ((phba->sli_rev == LPFC_SLI_REV4) &&
+               !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) {
+               /*
+                * Driver needs to re-reg VPI in order for f/w
+                * to update the MAC address.
+                */
+               lpfc_register_new_vport(phba, vport, ndlp);
+               return ;
        }
 
        if (vport->fc_flag & FC_VPORT_NEEDS_INIT_VPI)
index 0639c994349c55be5936a38852cbb23acabdb357..1f62ea8c165d7563bdb54566a16318b6b9e7a8f5 100644 (file)
@@ -588,7 +588,7 @@ lpfc_work_done(struct lpfc_hba *phba)
                                                        (status &
                                                         HA_RXMASK));
                }
-               if (pring->txq_cnt)
+               if ((phba->sli_rev == LPFC_SLI_REV4) && pring->txq_cnt)
                        lpfc_drain_txq(phba);
                /*
                 * Turn on Ring interrupts
@@ -1852,8 +1852,7 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
                                __lpfc_sli4_stop_fcf_redisc_wait_timer(phba);
                        else if (phba->fcf.fcf_flag & FCF_REDISC_FOV)
                                /* If in fast failover, mark it's completed */
-                               phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV |
-                                                       FCF_DISCOVERY);
+                               phba->fcf.fcf_flag &= ~FCF_REDISC_FOV;
                        spin_unlock_irq(&phba->hbalock);
                        lpfc_printf_log(phba, KERN_INFO, LOG_FIP,
                                        "2836 The new FCF record (x%x) "
@@ -2651,7 +2650,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
                spin_unlock_irq(&phba->hbalock);
                lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY,
                                "2778 Start FCF table scan at linkup\n");
-
                rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba,
                                                     LPFC_FCOE_FCF_GET_FIRST);
                if (rc) {
@@ -2660,6 +2658,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
                        spin_unlock_irq(&phba->hbalock);
                        goto out;
                }
+               /* Reset FCF roundrobin bmask for new discovery */
+               memset(phba->fcf.fcf_rr_bmask, 0,
+                      sizeof(*phba->fcf.fcf_rr_bmask));
        }
 
        return;
@@ -5097,6 +5098,7 @@ static void
 lpfc_unregister_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
 {
        struct lpfc_vport *vport = mboxq->vport;
+       struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
 
        if (mboxq->u.mb.mbxStatus) {
                lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX,
@@ -5104,6 +5106,9 @@ lpfc_unregister_vfi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
                        "HBA state x%x\n",
                        mboxq->u.mb.mbxStatus, vport->port_state);
        }
+       spin_lock_irq(shost->host_lock);
+       phba->pport->fc_flag &= ~FC_VFI_REGISTERED;
+       spin_unlock_irq(shost->host_lock);
        mempool_free(mboxq, phba->mbox_mem_pool);
        return;
 }
@@ -5285,6 +5290,10 @@ lpfc_unregister_fcf_rescan(struct lpfc_hba *phba)
        spin_lock_irq(&phba->hbalock);
        phba->fcf.fcf_flag |= FCF_INIT_DISC;
        spin_unlock_irq(&phba->hbalock);
+
+       /* Reset FCF roundrobin bmask for new discovery */
+       memset(phba->fcf.fcf_rr_bmask, 0, sizeof(*phba->fcf.fcf_rr_bmask));
+
        rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST);
 
        if (rc) {
index f5dbf2be3eab4995e9a940c99f99c133afac12cb..1676f61291e74848b3c3a235e38fe7ff5e3c7f20 100644 (file)
@@ -2291,7 +2291,8 @@ typedef struct {
 typedef struct {
 #ifdef __BIG_ENDIAN_BITFIELD
        uint32_t rsvd1;
-       uint32_t rsvd2:8;
+       uint32_t rsvd2:7;
+       uint32_t upd:1;
        uint32_t sid:24;
        uint32_t wwn[2];
        uint32_t rsvd5;
@@ -2300,7 +2301,8 @@ typedef struct {
 #else  /*  __LITTLE_ENDIAN */
        uint32_t rsvd1;
        uint32_t sid:24;
-       uint32_t rsvd2:8;
+       uint32_t upd:1;
+       uint32_t rsvd2:7;
        uint32_t wwn[2];
        uint32_t rsvd5;
        uint16_t vpi;
@@ -2806,11 +2808,15 @@ typedef struct {
        uint32_t rsvd6;           /* Reserved                             */
 
 #ifdef __BIG_ENDIAN_BITFIELD
-       uint32_t rsvd7      : 16;  /* Reserved                             */
+       uint32_t fips_rev   : 3;   /* FIPS Spec Revision                   */
+       uint32_t fips_level : 4;   /* FIPS Level                           */
+       uint32_t sec_err    : 9;   /* security crypto error                */
        uint32_t max_vpi    : 16;  /* Max number of virt N-Ports           */
 #else  /*  __LITTLE_ENDIAN */
        uint32_t max_vpi    : 16;  /* Max number of virt N-Ports           */
-       uint32_t rsvd7      : 16;  /* Reserved                             */
+       uint32_t sec_err    : 9;   /* security crypto error                */
+       uint32_t fips_level : 4;   /* FIPS Level                           */
+       uint32_t fips_rev   : 3;   /* FIPS Spec Revision                   */
 #endif
 
 } CONFIG_PORT_VAR;
@@ -3441,63 +3447,63 @@ struct sli3_bg_fields {
 static inline uint32_t
 lpfc_bgs_get_bidir_bg_prof(uint32_t bgstat)
 {
-       return (le32_to_cpu(bgstat) & BGS_BIDIR_BG_PROF_MASK) >>
+       return (bgstat & BGS_BIDIR_BG_PROF_MASK) >>
                                BGS_BIDIR_BG_PROF_SHIFT;
 }
 
 static inline uint32_t
 lpfc_bgs_get_bidir_err_cond(uint32_t bgstat)
 {
-       return (le32_to_cpu(bgstat) & BGS_BIDIR_ERR_COND_FLAGS_MASK) >>
+       return (bgstat & BGS_BIDIR_ERR_COND_FLAGS_MASK) >>
                                BGS_BIDIR_ERR_COND_SHIFT;
 }
 
 static inline uint32_t
 lpfc_bgs_get_bg_prof(uint32_t bgstat)
 {
-       return (le32_to_cpu(bgstat) & BGS_BG_PROFILE_MASK) >>
+       return (bgstat & BGS_BG_PROFILE_MASK) >>
                                BGS_BG_PROFILE_SHIFT;
 }
 
 static inline uint32_t
 lpfc_bgs_get_invalid_prof(uint32_t bgstat)
 {
-       return (le32_to_cpu(bgstat) & BGS_INVALID_PROF_MASK) >>
+       return (bgstat & BGS_INVALID_PROF_MASK) >>
                                BGS_INVALID_PROF_SHIFT;
 }
 
 static inline uint32_t
 lpfc_bgs_get_uninit_dif_block(uint32_t bgstat)
 {
-       return (le32_to_cpu(bgstat) & BGS_UNINIT_DIF_BLOCK_MASK) >>
+       return (bgstat & BGS_UNINIT_DIF_BLOCK_MASK) >>
                                BGS_UNINIT_DIF_BLOCK_SHIFT;
 }
 
 static inline uint32_t
 lpfc_bgs_get_hi_water_mark_present(uint32_t bgstat)
 {
-       return (le32_to_cpu(bgstat) & BGS_HI_WATER_MARK_PRESENT_MASK) >>
+       return (bgstat & BGS_HI_WATER_MARK_PRESENT_MASK) >>
                                BGS_HI_WATER_MARK_PRESENT_SHIFT;
 }
 
 static inline uint32_t
 lpfc_bgs_get_reftag_err(uint32_t bgstat)
 {
-       return (le32_to_cpu(bgstat) & BGS_REFTAG_ERR_MASK) >>
+       return (bgstat & BGS_REFTAG_ERR_MASK) >>
                                BGS_REFTAG_ERR_SHIFT;
 }
 
 static inline uint32_t
 lpfc_bgs_get_apptag_err(uint32_t bgstat)
 {
-       return (le32_to_cpu(bgstat) & BGS_APPTAG_ERR_MASK) >>
+       return (bgstat & BGS_APPTAG_ERR_MASK) >>
                                BGS_APPTAG_ERR_SHIFT;
 }
 
 static inline uint32_t
 lpfc_bgs_get_guard_err(uint32_t bgstat)
 {
-       return (le32_to_cpu(bgstat) & BGS_GUARD_ERR_MASK) >>
+       return (bgstat & BGS_GUARD_ERR_MASK) >>
                                BGS_GUARD_ERR_SHIFT;
 }
 
index 2786ee3b605dd6bb1567641e6db1a270f873b589..da9ba06ad5831a0e8b59d821750263aa45914757 100644 (file)
@@ -1032,27 +1032,46 @@ lpfc_hb_timeout_handler(struct lpfc_hba *phba)
        /* If there is no heart beat outstanding, issue a heartbeat command */
        if (phba->cfg_enable_hba_heartbeat) {
                if (!phba->hb_outstanding) {
-                       pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
-                       if (!pmboxq) {
-                               mod_timer(&phba->hb_tmofunc,
-                                         jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
-                               return;
-                       }
+                       if ((!(psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) &&
+                               (list_empty(&psli->mboxq))) {
+                               pmboxq = mempool_alloc(phba->mbox_mem_pool,
+                                                       GFP_KERNEL);
+                               if (!pmboxq) {
+                                       mod_timer(&phba->hb_tmofunc,
+                                                jiffies +
+                                                HZ * LPFC_HB_MBOX_INTERVAL);
+                                       return;
+                               }
 
-                       lpfc_heart_beat(phba, pmboxq);
-                       pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl;
-                       pmboxq->vport = phba->pport;
-                       retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
+                               lpfc_heart_beat(phba, pmboxq);
+                               pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl;
+                               pmboxq->vport = phba->pport;
+                               retval = lpfc_sli_issue_mbox(phba, pmboxq,
+                                               MBX_NOWAIT);
+
+                               if (retval != MBX_BUSY &&
+                                       retval != MBX_SUCCESS) {
+                                       mempool_free(pmboxq,
+                                                       phba->mbox_mem_pool);
+                                       mod_timer(&phba->hb_tmofunc,
+                                               jiffies +
+                                               HZ * LPFC_HB_MBOX_INTERVAL);
+                                       return;
+                               }
+                               phba->skipped_hb = 0;
+                               phba->hb_outstanding = 1;
+                       } else if (time_before_eq(phba->last_completion_time,
+                                       phba->skipped_hb)) {
+                               lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
+                                       "2857 Last completion time not "
+                                       " updated in %d ms\n",
+                                       jiffies_to_msecs(jiffies
+                                                - phba->last_completion_time));
+                       } else
+                               phba->skipped_hb = jiffies;
 
-                       if (retval != MBX_BUSY && retval != MBX_SUCCESS) {
-                               mempool_free(pmboxq, phba->mbox_mem_pool);
-                               mod_timer(&phba->hb_tmofunc,
-                                         jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
-                               return;
-                       }
                        mod_timer(&phba->hb_tmofunc,
                                  jiffies + HZ * LPFC_HB_MBOX_TIMEOUT);
-                       phba->hb_outstanding = 1;
                        return;
                } else {
                        /*
@@ -3281,10 +3300,10 @@ lpfc_sli4_perform_vport_cvl(struct lpfc_vport *vport)
                if (!ndlp)
                        return 0;
        }
-       if (phba->pport->port_state <= LPFC_FLOGI)
+       if (phba->pport->port_state < LPFC_FLOGI)
                return NULL;
        /* If virtual link is not yet instantiated ignore CVL */
-       if (vport->port_state <= LPFC_FDISC)
+       if ((vport != phba->pport) && (vport->port_state < LPFC_FDISC))
                return NULL;
        shost = lpfc_shost_from_vport(vport);
        if (!shost)
@@ -3357,21 +3376,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba,
                                        "evt_tag:x%x, fcf_index:x%x\n",
                                        acqe_fcoe->event_tag,
                                        acqe_fcoe->index);
-               /* If the FCF discovery is in progress, do nothing. */
-               spin_lock_irq(&phba->hbalock);
-               if (phba->hba_flag & FCF_DISC_INPROGRESS) {
-                       spin_unlock_irq(&phba->hbalock);
-                       break;
-               }
-               /* If fast FCF failover rescan event is pending, do nothing */
-               if (phba->fcf.fcf_flag & FCF_REDISC_EVT) {
-                       spin_unlock_irq(&phba->hbalock);
-                       break;
-               }
-               spin_unlock_irq(&phba->hbalock);
-
-               if ((phba->fcf.fcf_flag & FCF_DISCOVERY) &&
-                   !(phba->fcf.fcf_flag & FCF_REDISC_FOV)) {
+               if (phba->fcf.fcf_flag & FCF_DISCOVERY) {
                        /*
                         * During period of FCF discovery, read the FCF
                         * table record indexed by the event to update
@@ -3385,13 +3390,26 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba,
                                        acqe_fcoe->index);
                        rc = lpfc_sli4_read_fcf_rec(phba, acqe_fcoe->index);
                }
-               /* If the FCF has been in discovered state, do nothing. */
+
+               /* If the FCF discovery is in progress, do nothing. */
                spin_lock_irq(&phba->hbalock);
+               if (phba->hba_flag & FCF_DISC_INPROGRESS) {
+                       spin_unlock_irq(&phba->hbalock);
+                       break;
+               }
+               /* If fast FCF failover rescan event is pending, do nothing */
+               if (phba->fcf.fcf_flag & FCF_REDISC_EVT) {
+                       spin_unlock_irq(&phba->hbalock);
+                       break;
+               }
+
+               /* If the FCF has been in discovered state, do nothing. */
                if (phba->fcf.fcf_flag & FCF_SCAN_DONE) {
                        spin_unlock_irq(&phba->hbalock);
                        break;
                }
                spin_unlock_irq(&phba->hbalock);
+
                /* Otherwise, scan the entire FCF table and re-discover SAN */
                lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY,
                                "2770 Start FCF table scan due to new FCF "
@@ -3417,13 +3435,9 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba,
                        "2549 FCF disconnected from network index 0x%x"
                        " tag 0x%x\n", acqe_fcoe->index,
                        acqe_fcoe->event_tag);
-               /* If the event is not for currently used fcf do nothing */
-               if (phba->fcf.current_rec.fcf_indx != acqe_fcoe->index)
-                       break;
-               /* We request port to rediscover the entire FCF table for
-                * a fast recovery from case that the current FCF record
-                * is no longer valid if we are not in the middle of FCF
-                * failover process already.
+               /*
+                * If we are in the middle of FCF failover process, clear
+                * the corresponding FCF bit in the roundrobin bitmap.
                 */
                spin_lock_irq(&phba->hbalock);
                if (phba->fcf.fcf_flag & FCF_DISCOVERY) {
@@ -3432,9 +3446,23 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba,
                        lpfc_sli4_fcf_rr_index_clear(phba, acqe_fcoe->index);
                        break;
                }
+               spin_unlock_irq(&phba->hbalock);
+
+               /* If the event is not for currently used fcf do nothing */
+               if (phba->fcf.current_rec.fcf_indx != acqe_fcoe->index)
+                       break;
+
+               /*
+                * Otherwise, request the port to rediscover the entire FCF
+                * table for a fast recovery from case that the current FCF
+                * is no longer valid as we are not in the middle of FCF
+                * failover process already.
+                */
+               spin_lock_irq(&phba->hbalock);
                /* Mark the fast failover process in progress */
                phba->fcf.fcf_flag |= FCF_DEAD_DISC;
                spin_unlock_irq(&phba->hbalock);
+
                lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY,
                                "2771 Start FCF fast failover process due to "
                                "FCF DEAD event: evt_tag:x%x, fcf_index:x%x "
@@ -3454,12 +3482,16 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba,
                         * as a link down to FCF registration.
                         */
                        lpfc_sli4_fcf_dead_failthrough(phba);
-               } else
-                       /* Handling fast FCF failover to a DEAD FCF event
-                        * is considered equalivant to receiving CVL to all
-                        * vports.
+               } else {
+                       /* Reset FCF roundrobin bmask for new discovery */
+                       memset(phba->fcf.fcf_rr_bmask, 0,
+                              sizeof(*phba->fcf.fcf_rr_bmask));
+                       /*
+                        * Handling fast FCF failover to a DEAD FCF event is
+                        * considered equalivant to receiving CVL to all vports.
                         */
                        lpfc_sli4_perform_all_vport_cvl(phba);
+               }
                break;
        case LPFC_FCOE_EVENT_TYPE_CVL:
                lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY,
@@ -3534,7 +3566,13 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba,
                                 * the current registered FCF entry.
                                 */
                                lpfc_retry_pport_discovery(phba);
-                       }
+                       } else
+                               /*
+                                * Reset FCF roundrobin bmask for new
+                                * discovery.
+                                */
+                               memset(phba->fcf.fcf_rr_bmask, 0,
+                                      sizeof(*phba->fcf.fcf_rr_bmask));
                }
                break;
        default:
index 9c2c7c7140c77ae7bff21d18e8b058b913e93b55..0dfa310cd609318cb0c772f85ea344acdef2c5ea 100644 (file)
@@ -815,9 +815,15 @@ void
 lpfc_reg_vpi(struct lpfc_vport *vport, LPFC_MBOXQ_t *pmb)
 {
        MAILBOX_t *mb = &pmb->u.mb;
+       struct lpfc_hba *phba = vport->phba;
 
        memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
-
+       /*
+        * Set the re-reg VPI bit for f/w to update the MAC address.
+        */
+       if ((phba->sli_rev == LPFC_SLI_REV4) &&
+               !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI))
+               mb->un.varRegVpi.upd = 1;
        mb->un.varRegVpi.vpi = vport->vpi + vport->phba->vpi_base;
        mb->un.varRegVpi.sid = vport->fc_myDID;
        mb->un.varRegVpi.vfi = vport->vfi + vport->phba->vfi_base;
index c818a7255962845ac258462545cd6ac6b70c9133..2e51aa6b45b3a90fb88c8f4ee6e1ea3f0082091f 100644 (file)
@@ -1325,7 +1325,7 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
        bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR);
        pde5->reftag = reftag;
 
-       /* Endian convertion if necessary for PDE5 */
+       /* Endianness conversion if necessary for PDE5 */
        pde5->word0 = cpu_to_le32(pde5->word0);
        pde5->reftag = cpu_to_le32(pde5->reftag);
 
@@ -1347,7 +1347,7 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
        bf_set(pde6_ai, pde6, 1);
        bf_set(pde6_apptagval, pde6, apptagval);
 
-       /* Endian convertion if necessary for PDE6 */
+       /* Endianness conversion if necessary for PDE6 */
        pde6->word0 = cpu_to_le32(pde6->word0);
        pde6->word1 = cpu_to_le32(pde6->word1);
        pde6->word2 = cpu_to_le32(pde6->word2);
@@ -1459,7 +1459,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
                bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR);
                pde5->reftag = reftag;
 
-               /* Endian convertion if necessary for PDE5 */
+               /* Endianness conversion if necessary for PDE5 */
                pde5->word0 = cpu_to_le32(pde5->word0);
                pde5->reftag = cpu_to_le32(pde5->reftag);
 
@@ -1479,7 +1479,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
                bf_set(pde6_ai, pde6, 1);
                bf_set(pde6_apptagval, pde6, apptagval);
 
-               /* Endian convertion if necessary for PDE6 */
+               /* Endianness conversion if necessary for PDE6 */
                pde6->word0 = cpu_to_le32(pde6->word0);
                pde6->word1 = cpu_to_le32(pde6->word1);
                pde6->word2 = cpu_to_le32(pde6->word2);
index e758eae0d0fd7b69445e4deb0f934dd206181828..fb8905f893f53ffcdd2cf71c79a5d04b87d9cd9c 100644 (file)
@@ -1046,7 +1046,7 @@ lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
        } else
                spin_unlock_irq(&phba->hbalock);
 
-       lpfc_printf_log(phba, KERN_ERR,LOG_SLI,
+       lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
                        "0318 Failed to allocate IOTAG.last IOTAG is %d\n",
                        psli->last_iotag);
 
@@ -3914,7 +3914,8 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode)
                phba->sli3_options &= ~(LPFC_SLI3_NPIV_ENABLED |
                                        LPFC_SLI3_HBQ_ENABLED |
                                        LPFC_SLI3_CRP_ENABLED |
-                                       LPFC_SLI3_BG_ENABLED);
+                                       LPFC_SLI3_BG_ENABLED |
+                                       LPFC_SLI3_DSS_ENABLED);
                if (rc != MBX_SUCCESS) {
                        lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
                                "0442 Adapter failed to init, mbxCmd x%x "
@@ -3949,8 +3950,23 @@ lpfc_sli_config_port(struct lpfc_hba *phba, int sli_mode)
 
                } else
                        phba->max_vpi = 0;
-               if (pmb->u.mb.un.varCfgPort.gdss)
+               phba->fips_level = 0;
+               phba->fips_spec_rev = 0;
+               if (pmb->u.mb.un.varCfgPort.gdss) {
                        phba->sli3_options |= LPFC_SLI3_DSS_ENABLED;
+                       phba->fips_level = pmb->u.mb.un.varCfgPort.fips_level;
+                       phba->fips_spec_rev = pmb->u.mb.un.varCfgPort.fips_rev;
+                       lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
+                                       "2850 Security Crypto Active. FIPS x%d "
+                                       "(Spec Rev: x%d)",
+                                       phba->fips_level, phba->fips_spec_rev);
+               }
+               if (pmb->u.mb.un.varCfgPort.sec_err) {
+                       lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+                                       "2856 Config Port Security Crypto "
+                                       "Error: x%x ",
+                                       pmb->u.mb.un.varCfgPort.sec_err);
+               }
                if (pmb->u.mb.un.varCfgPort.gerbm)
                        phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED;
                if (pmb->u.mb.un.varCfgPort.gcrp)
@@ -9040,6 +9056,7 @@ lpfc_sli4_sp_handle_cqe(struct lpfc_hba *phba, struct lpfc_queue *cq,
        switch (bf_get(lpfc_cqe_code, &cqevt)) {
        case CQE_CODE_COMPL_WQE:
                /* Process the WQ/RQ complete event */
+               phba->last_completion_time = jiffies;
                workposted = lpfc_sli4_sp_handle_els_wcqe(phba,
                                (struct lpfc_wcqe_complete *)&cqevt);
                break;
@@ -9050,11 +9067,13 @@ lpfc_sli4_sp_handle_cqe(struct lpfc_hba *phba, struct lpfc_queue *cq,
                break;
        case CQE_CODE_XRI_ABORTED:
                /* Process the WQ XRI abort event */
+               phba->last_completion_time = jiffies;
                workposted = lpfc_sli4_sp_handle_abort_xri_wcqe(phba, cq,
                                (struct sli4_wcqe_xri_aborted *)&cqevt);
                break;
        case CQE_CODE_RECEIVE:
                /* Process the RQ event */
+               phba->last_completion_time = jiffies;
                workposted = lpfc_sli4_sp_handle_rcqe(phba,
                                (struct lpfc_rcqe *)&cqevt);
                break;
@@ -9276,7 +9295,6 @@ lpfc_sli4_fp_handle_wcqe(struct lpfc_hba *phba, struct lpfc_queue *cq,
 {
        struct lpfc_wcqe_release wcqe;
        bool workposted = false;
-       unsigned long iflag;
 
        /* Copy the work queue CQE and convert endian order if needed */
        lpfc_sli_pcimem_bcopy(cqe, &wcqe, sizeof(struct lpfc_cqe));
@@ -9285,9 +9303,7 @@ lpfc_sli4_fp_handle_wcqe(struct lpfc_hba *phba, struct lpfc_queue *cq,
        switch (bf_get(lpfc_wcqe_c_code, &wcqe)) {
        case CQE_CODE_COMPL_WQE:
                /* Process the WQ complete event */
-               spin_lock_irqsave(&phba->hbalock, iflag);
                phba->last_completion_time = jiffies;
-               spin_unlock_irqrestore(&phba->hbalock, iflag);
                lpfc_sli4_fp_handle_fcp_wcqe(phba,
                                (struct lpfc_wcqe_complete *)&wcqe);
                break;
@@ -9298,6 +9314,7 @@ lpfc_sli4_fp_handle_wcqe(struct lpfc_hba *phba, struct lpfc_queue *cq,
                break;
        case CQE_CODE_XRI_ABORTED:
                /* Process the WQ XRI abort event */
+               phba->last_completion_time = jiffies;
                workposted = lpfc_sli4_sp_handle_abort_xri_wcqe(phba, cq,
                                (struct sli4_wcqe_xri_aborted *)&wcqe);
                break;
@@ -12278,12 +12295,9 @@ lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index)
                spin_lock_irq(&phba->hbalock);
                phba->hba_flag |= FCF_DISC_INPROGRESS;
                spin_unlock_irq(&phba->hbalock);
-               /* Reset FCF round robin index bmask for new scan */
-               if (fcf_index == LPFC_FCOE_FCF_GET_FIRST) {
-                       memset(phba->fcf.fcf_rr_bmask, 0,
-                              sizeof(*phba->fcf.fcf_rr_bmask));
+               /* Reset eligible FCF count for new scan */
+               if (fcf_index == LPFC_FCOE_FCF_GET_FIRST)
                        phba->fcf.eligible_fcf_cnt = 0;
-               }
                error = 0;
        }
 fail_fcf_scan:
index d28830af71d8c36dc92eaddd1321731c9226835b..61afb3420a961e4da66e1db5da673a61180b58b9 100644 (file)
@@ -18,7 +18,7 @@
  * included with this package.                                     *
  *******************************************************************/
 
-#define LPFC_DRIVER_VERSION "8.3.15"
+#define LPFC_DRIVER_VERSION "8.3.16"
 #define LPFC_DRIVER_NAME               "lpfc"
 #define LPFC_SP_DRIVER_HANDLER_NAME    "lpfc:sp"
 #define LPFC_FP_DRIVER_HANDLER_NAME    "lpfc:fp"
index 58d1134935ef6860ec0087d549b4b399886db2de..9793aa6afb1061cfc035e3b1b826a375a78a7296 100644 (file)
@@ -4199,8 +4199,10 @@ static int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha,
        circularQ = &pm8001_ha->inbnd_q_tbl[0];
        memset(&nvmd_req, 0, sizeof(nvmd_req));
        rc = pm8001_tag_alloc(pm8001_ha, &tag);
-       if (rc)
+       if (rc) {
+               kfree(fw_control_context);
                return rc;
+       }
        ccb = &pm8001_ha->ccb_info[tag];
        ccb->ccb_tag = tag;
        ccb->fw_control_context = fw_control_context;
@@ -4276,8 +4278,10 @@ static int pm8001_chip_set_nvmd_req(struct pm8001_hba_info *pm8001_ha,
                ioctl_payload->length);
        memset(&nvmd_req, 0, sizeof(nvmd_req));
        rc = pm8001_tag_alloc(pm8001_ha, &tag);
-       if (rc)
+       if (rc) {
+               kfree(fw_control_context);
                return rc;
+       }
        ccb = &pm8001_ha->ccb_info[tag];
        ccb->fw_control_context = fw_control_context;
        ccb->ccb_tag = tag;
@@ -4387,6 +4391,7 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
                        fw_control->len, 0) != 0) {
                                PM8001_FAIL_DBG(pm8001_ha,
                                        pm8001_printk("Mem alloc failure\n"));
+                               kfree(fw_control_context);
                                return -ENOMEM;
                }
        }
@@ -4401,8 +4406,10 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha,
        fw_control_context->virtAddr = buffer;
        fw_control_context->len = fw_control->len;
        rc = pm8001_tag_alloc(pm8001_ha, &tag);
-       if (rc)
+       if (rc) {
+               kfree(fw_control_context);
                return rc;
+       }
        ccb = &pm8001_ha->ccb_info[tag];
        ccb->fw_control_context = fw_control_context;
        ccb->ccb_tag = tag;
index a79da8dd206455dc35b92e84e62893c262d18a5c..9dc0a6616edd566656154413a96f41043e886447 100644 (file)
 #include "ql4_dbg.h"
 #include "ql4_nx.h"
 
+#if defined(CONFIG_PCIEAER)
+#include <linux/aer.h>
+#else
+/* AER releated */
+static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev)
+{
+       return -EINVAL;
+}
+static inline int pci_disable_pcie_error_reporting(struct pci_dev *dev)
+{
+       return -EINVAL;
+}
+static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
+{
+       return -EINVAL;
+}
+#endif
+
 #ifndef PCI_DEVICE_ID_QLOGIC_ISP4010
 #define PCI_DEVICE_ID_QLOGIC_ISP4010   0x4010
 #endif
 #define ISCSI_ALIAS_SIZE               32      /* ISCSI Alias name size */
 #define ISCSI_NAME_SIZE                        0xE0    /* ISCSI Name size */
 
+#define QL4_SESS_RECOVERY_TMO          30      /* iSCSI session */
+                                               /* recovery timeout */
+
 #define LSDW(x) ((u32)((u64)(x)))
 #define MSDW(x) ((u32)((((u64)(x)) >> 16) >> 16))
 
@@ -249,7 +270,6 @@ struct ddb_entry {
        uint32_t default_time2wait; /* Default Min time between
                                     * relogins (+aens) */
 
-       atomic_t port_down_timer; /* Device connection timer */
        atomic_t retry_relogin_timer; /* Min Time between relogins
                                       * (4000 only) */
        atomic_t relogin_timer; /* Max Time to wait for relogin to complete */
@@ -378,7 +398,9 @@ struct scsi_qla_host {
 #define AF_MSI_ENABLED                 16 /* 0x00010000 */
 #define AF_MSIX_ENABLED                        17 /* 0x00020000 */
 #define AF_MBOX_COMMAND_NOPOLL         18 /* 0x00040000 */
-
+#define AF_FW_RECOVERY                 19 /* 0x00080000 */
+#define AF_EEH_BUSY                    20 /* 0x00100000 */
+#define AF_PCI_CHANNEL_IO_PERM_FAILURE 21 /* 0x00200000 */
 
        unsigned long dpc_flags;
 
@@ -474,7 +496,6 @@ struct scsi_qla_host {
        uint32_t timer_active;
 
        /* Recovery Timers */
-       uint32_t port_down_retry_count;
        uint32_t discovery_wait;
        atomic_t check_relogin_timeouts;
        uint32_t retry_reset_ha_cnt;
@@ -615,6 +636,15 @@ static inline int is_qla8022(struct scsi_qla_host *ha)
        return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8022;
 }
 
+/* Note: Currently AER/EEH is now supported only for 8022 cards
+ * This function needs to be updated when AER/EEH is enabled
+ * for other cards.
+ */
+static inline int is_aer_supported(struct scsi_qla_host *ha)
+{
+       return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8022;
+}
+
 static inline int adapter_up(struct scsi_qla_host *ha)
 {
        return (test_bit(AF_ONLINE, &ha->flags) != 0) &&
index c94c9ddfb3a61a2ddbbedf6f931d0ec5058662a0..0336c6db8cb3b338a15bf42608dcdfc1c12c8bfd 100644 (file)
@@ -673,17 +673,17 @@ struct flash_sys_info {
 };     /* 200 */
 
 struct mbx_sys_info {
-       uint8_t board_id_str[16];       /* Keep board ID string first */
-                                       /* in this structure for GUI. */
-       uint16_t board_id;      /* board ID code */
-       uint16_t phys_port_cnt; /* number of physical network ports */
-       uint16_t port_num;      /* network port for this PCI function */
+       uint8_t board_id_str[16];   /*  0-f  Keep board ID string first */
+                               /* in this structure for GUI. */
+       uint16_t board_id;      /* 10-11 board ID code */
+       uint16_t phys_port_cnt; /* 12-13 number of physical network ports */
+       uint16_t port_num;      /* 14-15 network port for this PCI function */
                                /* (port 0 is first port) */
-       uint8_t mac_addr[6];    /* MAC address for this PCI function */
-       uint32_t iscsi_pci_func_cnt;    /* number of iSCSI PCI functions */
-       uint32_t pci_func;              /* this PCI function */
-       unsigned char serial_number[16];        /* serial number string */
-       uint8_t reserved[16];
+       uint8_t mac_addr[6];    /* 16-1b MAC address for this PCI function */
+       uint32_t iscsi_pci_func_cnt;  /* 1c-1f number of iSCSI PCI functions */
+       uint32_t pci_func;            /* 20-23 this PCI function */
+       unsigned char serial_number[16];  /* 24-33 serial number string */
+       uint8_t reserved[12];             /* 34-3f */
 };
 
 struct crash_record {
index c9cd5d6db98240b809be2f26a6d69a797fa8048f..f065204e401b55cba2010557ab8ca81105a66ccb 100644 (file)
@@ -93,6 +93,7 @@ void qla4xxx_free_irqs(struct scsi_qla_host *ha);
 void qla4xxx_process_response_queue(struct scsi_qla_host *ha);
 void qla4xxx_wake_dpc(struct scsi_qla_host *ha);
 void qla4xxx_get_conn_event_log(struct scsi_qla_host *ha);
+void qla4xxx_mailbox_premature_completion(struct scsi_qla_host *ha);
 
 void qla4_8xxx_pci_config(struct scsi_qla_host *);
 int qla4_8xxx_iospace_config(struct scsi_qla_host *ha);
@@ -131,6 +132,7 @@ void qla4_8xxx_idc_unlock(struct scsi_qla_host *ha);
 int qla4_8xxx_device_state_handler(struct scsi_qla_host *ha);
 void qla4_8xxx_need_qsnt_handler(struct scsi_qla_host *ha);
 void qla4_8xxx_clear_drv_active(struct scsi_qla_host *ha);
+inline void qla4_8xxx_set_drv_active(struct scsi_qla_host *ha);
 
 extern int ql4xextended_error_logging;
 extern int ql4xdiscoverywait;
index 30073577c3a4f9d68be00d5d931364069b661d47..4c9be77ee70b81a21a9bda19cd8116b3352bed98 100644 (file)
@@ -308,7 +308,6 @@ static int qla4xxx_fw_ready(struct scsi_qla_host *ha)
                        DEBUG2(printk("scsi%ld: %s: unable to get firmware "
                                      "state\n", ha->host_no, __func__));
                        break;
-
                }
 
                if (ha->firmware_state & FW_STATE_ERROR) {
@@ -445,6 +444,16 @@ static int qla4xxx_init_firmware(struct scsi_qla_host *ha)
 {
        int status = QLA_ERROR;
 
+       if (is_aer_supported(ha) &&
+           test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags))
+               return status;
+
+       /* For 82xx, stop firmware before initializing because if BIOS
+        * has previously initialized firmware, then driver's initialize
+        * firmware will fail. */
+       if (is_qla8022(ha))
+               qla4_8xxx_stop_firmware(ha);
+
        ql4_printk(KERN_INFO, ha, "Initializing firmware..\n");
        if (qla4xxx_initialize_fw_cb(ha) == QLA_ERROR) {
                DEBUG2(printk("scsi%ld: %s: Failed to initialize firmware "
@@ -669,7 +678,6 @@ static struct ddb_entry * qla4xxx_alloc_ddb(struct scsi_qla_host *ha,
        }
 
        ddb_entry->fw_ddb_index = fw_ddb_index;
-       atomic_set(&ddb_entry->port_down_timer, ha->port_down_retry_count);
        atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
        atomic_set(&ddb_entry->relogin_timer, 0);
        atomic_set(&ddb_entry->relogin_retry_count, 0);
@@ -1556,8 +1564,6 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
        /* Device is back online. */
        if (ddb_entry->fw_ddb_device_state == DDB_DS_SESSION_ACTIVE) {
                atomic_set(&ddb_entry->state, DDB_STATE_ONLINE);
-               atomic_set(&ddb_entry->port_down_timer,
-                          ha->port_down_retry_count);
                atomic_set(&ddb_entry->relogin_retry_count, 0);
                atomic_set(&ddb_entry->relogin_timer, 0);
                clear_bit(DF_RELOGIN, &ddb_entry->flags);
index f89973deac5ba6735d71a59bc57bc26649689838..4ef9ba112ee87ecd55e4815a6572db9d9bf43106 100644 (file)
@@ -19,7 +19,7 @@ qla4xxx_space_in_req_ring(struct scsi_qla_host *ha, uint16_t req_cnt)
 
        /* Calculate number of free request entries. */
        if ((req_cnt + 2) >= ha->req_q_count) {
-               cnt = (uint16_t) le32_to_cpu(ha->shadow_regs->req_q_out);
+               cnt = (uint16_t) ha->isp_ops->rd_shdw_req_q_out(ha);
                if (ha->request_in < cnt)
                        ha->req_q_count = cnt - ha->request_in;
                else
index aa65697a86b4718ccf4db3504ba37e396cf58126..2a1ab63f3eb0165de7a147be1eeef222c0b03e9a 100644 (file)
@@ -816,6 +816,9 @@ irqreturn_t qla4_8xxx_intr_handler(int irq, void *dev_id)
        unsigned long flags = 0;
        uint8_t reqs_count = 0;
 
+       if (unlikely(pci_channel_offline(ha->pdev)))
+               return IRQ_HANDLED;
+
        ha->isr_count++;
        status = qla4_8xxx_rd_32(ha, ISR_INT_VECTOR);
        if (!(status & ha->nx_legacy_intr.int_vec_bit))
index 940ee561ee0a78102ba06261987ccc5ca76bbd5a..90021704d8cac0e37a30c2b788e8f40a17875229 100644 (file)
@@ -39,6 +39,22 @@ int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
                              "pointer\n", ha->host_no, __func__));
                return status;
        }
+
+       if (is_qla8022(ha) &&
+           test_bit(AF_FW_RECOVERY, &ha->flags)) {
+               DEBUG2(ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: prematurely "
+                   "completing mbx cmd as firmware recovery detected\n",
+                   ha->host_no, __func__));
+               return status;
+       }
+
+       if ((is_aer_supported(ha)) &&
+           (test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags))) {
+               DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Perm failure on EEH, "
+                   "timeout MBX Exiting.\n", ha->host_no, __func__));
+               return status;
+       }
+
        /* Mailbox code active */
        wait_count = MBOX_TOV * 100;
 
@@ -150,6 +166,7 @@ int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
                while (test_bit(AF_MBOX_COMMAND_DONE, &ha->flags) == 0) {
                        if (time_after_eq(jiffies, wait_count))
                                break;
+
                        /*
                         * Service the interrupt.
                         * The ISR will save the mailbox status registers
@@ -196,6 +213,14 @@ int qla4xxx_mailbox_command(struct scsi_qla_host *ha, uint8_t inCount,
 
        /* Check for mailbox timeout. */
        if (!test_bit(AF_MBOX_COMMAND_DONE, &ha->flags)) {
+               if (is_qla8022(ha) &&
+                   test_bit(AF_FW_RECOVERY, &ha->flags)) {
+                       DEBUG2(ql4_printk(KERN_INFO, ha,
+                           "scsi%ld: %s: prematurely completing mbx cmd as "
+                           "firmware recovery detected\n",
+                           ha->host_no, __func__));
+                       goto mbox_exit;
+               }
                DEBUG2(printk("scsi%ld: Mailbox Cmd 0x%08X timed out ...,"
                              " Scheduling Adapter Reset\n", ha->host_no,
                              mbx_cmd[0]));
@@ -246,6 +271,28 @@ mbox_exit:
        return status;
 }
 
+void qla4xxx_mailbox_premature_completion(struct scsi_qla_host *ha)
+{
+       set_bit(AF_FW_RECOVERY, &ha->flags);
+       ql4_printk(KERN_INFO, ha, "scsi%ld: %s: set FW RECOVERY!\n",
+           ha->host_no, __func__);
+
+       if (test_bit(AF_MBOX_COMMAND, &ha->flags)) {
+               if (test_bit(AF_MBOX_COMMAND_NOPOLL, &ha->flags)) {
+                       complete(&ha->mbx_intr_comp);
+                       ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Due to fw "
+                           "recovery, doing premature completion of "
+                           "mbx cmd\n", ha->host_no, __func__);
+
+               } else {
+                       set_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
+                       ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Due to fw "
+                           "recovery, doing premature completion of "
+                           "polling mbx cmd\n", ha->host_no, __func__);
+               }
+       }
+}
+
 static uint8_t
 qla4xxx_set_ifcb(struct scsi_qla_host *ha, uint32_t *mbox_cmd,
                 uint32_t *mbox_sts, dma_addr_t init_fw_cb_dma)
@@ -361,7 +408,6 @@ qla4xxx_update_local_ifcb(struct scsi_qla_host *ha,
               min(sizeof(ha->alias), sizeof(init_fw_cb->Alias)));*/
 
        /* Save Command Line Paramater info */
-       ha->port_down_retry_count = le16_to_cpu(init_fw_cb->conn_ka_timeout);
        ha->discovery_wait = ql4xdiscoverywait;
 
        if (ha->acb_version == ACB_SUPPORTED) {
index 3e119ae78397312850849e5e8496cb75f9bc144d..e031a734836ed37a372e2f0cf105a029dad46980 100644 (file)
@@ -1418,7 +1418,7 @@ static int qla4_8xxx_rcvpeg_ready(struct scsi_qla_host *ha)
        return QLA_SUCCESS;
 }
 
-static inline void
+inline void
 qla4_8xxx_set_drv_active(struct scsi_qla_host *ha)
 {
        uint32_t drv_active;
@@ -1441,11 +1441,15 @@ qla4_8xxx_clear_drv_active(struct scsi_qla_host *ha)
 static inline int
 qla4_8xxx_need_reset(struct scsi_qla_host *ha)
 {
-       uint32_t drv_state;
+       uint32_t drv_state, drv_active;
        int rval;
 
+       drv_active = qla4_8xxx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE);
        drv_state = qla4_8xxx_rd_32(ha, QLA82XX_CRB_DRV_STATE);
        rval = drv_state & (1 << (ha->func_num * 4));
+       if ((test_bit(AF_EEH_BUSY, &ha->flags)) && drv_active)
+               rval = 1;
+
        return rval;
 }
 
@@ -1949,7 +1953,8 @@ qla4_8xxx_get_fdt_info(struct scsi_qla_host *ha)
        uint16_t cnt, chksum;
        uint16_t *wptr;
        struct qla_fdt_layout *fdt;
-       uint16_t mid, fid;
+       uint16_t mid = 0;
+       uint16_t fid = 0;
        struct ql82xx_hw_data *hw = &ha->hw;
 
        hw->flash_conf_off = FARX_ACCESS_FLASH_CONF;
@@ -2105,6 +2110,9 @@ qla4_8xxx_isp_reset(struct scsi_qla_host *ha)
        qla4_8xxx_clear_rst_ready(ha);
        qla4_8xxx_idc_unlock(ha);
 
+       if (rval == QLA_SUCCESS)
+               clear_bit(AF_FW_RECOVERY, &ha->flags);
+
        return rval;
 }
 
@@ -2145,7 +2153,8 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
                goto exit_validate_mac82;
        }
 
-       if (mbox_sts[4] < sizeof(*sys_info)) {
+       /* Make sure we receive the minimum required data to cache internally */
+       if (mbox_sts[4] < offsetof(struct mbx_sys_info, reserved)) {
                DEBUG2(printk("scsi%ld: %s: GET_SYS_INFO data receive"
                    " error (%x)\n", ha->host_no, __func__, mbox_sts[4]));
                goto exit_validate_mac82;
index 5529b2a39741ab5a01f73df362f5cff8991e279b..370d40ff15296ff8c1c19f3294a011ba94450b75 100644 (file)
@@ -163,10 +163,10 @@ static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session)
        if (atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE) {
                atomic_set(&ddb_entry->state, DDB_STATE_DEAD);
 
-               DEBUG2(printk("scsi%ld: %s: ddb [%d] port down retry count "
+               DEBUG2(printk("scsi%ld: %s: ddb [%d] session recovery timeout "
                              "of (%d) secs exhausted, marking device DEAD.\n",
                              ha->host_no, __func__, ddb_entry->fw_ddb_index,
-                             ha->port_down_retry_count));
+                             QL4_SESS_RECOVERY_TMO));
 
                qla4xxx_wake_dpc(ha);
        }
@@ -298,7 +298,8 @@ int qla4xxx_add_sess(struct ddb_entry *ddb_entry)
 {
        int err;
 
-       ddb_entry->sess->recovery_tmo = ddb_entry->ha->port_down_retry_count;
+       ddb_entry->sess->recovery_tmo = QL4_SESS_RECOVERY_TMO;
+
        err = iscsi_add_session(ddb_entry->sess, ddb_entry->fw_ddb_index);
        if (err) {
                DEBUG2(printk(KERN_ERR "Could not add session.\n"));
@@ -474,6 +475,14 @@ static int qla4xxx_queuecommand(struct scsi_cmnd *cmd,
        struct srb *srb;
        int rval;
 
+       if (test_bit(AF_EEH_BUSY, &ha->flags)) {
+               if (test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags))
+                       cmd->result = DID_NO_CONNECT << 16;
+               else
+                       cmd->result = DID_REQUEUE << 16;
+               goto qc_fail_command;
+       }
+
        if (!sess) {
                cmd->result = DID_IMM_RETRY << 16;
                goto qc_fail_command;
@@ -654,6 +663,13 @@ static void qla4_8xxx_check_fw_alive(struct scsi_qla_host *ha)
        uint32_t fw_heartbeat_counter, halt_status;
 
        fw_heartbeat_counter = qla4_8xxx_rd_32(ha, QLA82XX_PEG_ALIVE_COUNTER);
+       /* If PEG_ALIVE_COUNTER is 0xffffffff, AER/EEH is in progress, ignore */
+       if (fw_heartbeat_counter == 0xffffffff) {
+               DEBUG2(printk(KERN_WARNING "scsi%ld: %s: Device in frozen "
+                   "state, QLA82XX_PEG_ALIVE_COUNTER is 0xffffffff\n",
+                   ha->host_no, __func__));
+               return;
+       }
 
        if (ha->fw_heartbeat_counter == fw_heartbeat_counter) {
                ha->seconds_since_last_heartbeat++;
@@ -662,6 +678,7 @@ static void qla4_8xxx_check_fw_alive(struct scsi_qla_host *ha)
                        ha->seconds_since_last_heartbeat = 0;
                        halt_status = qla4_8xxx_rd_32(ha,
                            QLA82XX_PEG_HALT_STATUS1);
+
                        /* Since we cannot change dev_state in interrupt
                         * context, set appropriate DPC flag then wakeup
                         * DPC */
@@ -673,6 +690,7 @@ static void qla4_8xxx_check_fw_alive(struct scsi_qla_host *ha)
                                set_bit(DPC_RESET_HA, &ha->dpc_flags);
                        }
                        qla4xxx_wake_dpc(ha);
+                       qla4xxx_mailbox_premature_completion(ha);
                }
        }
        ha->fw_heartbeat_counter = fw_heartbeat_counter;
@@ -698,6 +716,7 @@ void qla4_8xxx_watchdog(struct scsi_qla_host *ha)
                            ha->host_no, __func__);
                        set_bit(DPC_RESET_HA, &ha->dpc_flags);
                        qla4xxx_wake_dpc(ha);
+                       qla4xxx_mailbox_premature_completion(ha);
                } else if (dev_state == QLA82XX_DEV_NEED_QUIESCENT &&
                    !test_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags)) {
                        printk("scsi%ld: %s: HW State: NEED QUIES!\n",
@@ -719,6 +738,19 @@ static void qla4xxx_timer(struct scsi_qla_host *ha)
 {
        struct ddb_entry *ddb_entry, *dtemp;
        int start_dpc = 0;
+       uint16_t w;
+
+       /* If we are in the middle of AER/EEH processing
+        * skip any processing and reschedule the timer
+        */
+       if (test_bit(AF_EEH_BUSY, &ha->flags)) {
+               mod_timer(&ha->timer, jiffies + HZ);
+               return;
+       }
+
+       /* Hardware read to trigger an EEH error during mailbox waits. */
+       if (!pci_channel_offline(ha->pdev))
+               pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w);
 
        if (test_bit(AF_HBA_GOING_AWAY, &ha->flags)) {
                DEBUG2(ql4_printk(KERN_INFO, ha, "%s exited. HBA GOING AWAY\n",
@@ -1207,7 +1239,13 @@ static void qla4xxx_do_dpc(struct work_struct *work)
 
        /* Initialization not yet finished. Don't do anything yet. */
        if (!test_bit(AF_INIT_DONE, &ha->flags))
-               return;
+               goto do_dpc_exit;
+
+       if (test_bit(AF_EEH_BUSY, &ha->flags)) {
+               DEBUG2(printk(KERN_INFO "scsi%ld: %s: flags = %lx\n",
+                   ha->host_no, __func__, ha->flags));
+               goto do_dpc_exit;
+       }
 
        /* HBA is in the process of being permanently disabled.
         * Don't process anything */
@@ -1346,6 +1384,8 @@ dpc_post_reset_ha:
                        }
                }
        }
+
+do_dpc_exit:
        clear_bit(AF_DPC_SCHEDULED, &ha->flags);
 }
 
@@ -1612,6 +1652,8 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
        ha->host = host;
        ha->host_no = host->host_no;
 
+       pci_enable_pcie_error_reporting(pdev);
+
        /* Setup Runtime configurable options */
        if (is_qla8022(ha)) {
                ha->isp_ops = &qla4_8xxx_isp_ops;
@@ -1630,6 +1672,10 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
                ha->isp_ops = &qla4xxx_isp_ops;
        }
 
+       /* Set EEH reset type to fundamental if required by hba */
+       if (is_qla8022(ha))
+               pdev->needs_freset = 1;
+
        /* Configure PCI I/O space. */
        ret = ha->isp_ops->iospace_config(ha);
        if (ret)
@@ -1726,6 +1772,7 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
                }
        }
 
+       pci_save_state(ha->pdev);
        ha->isp_ops->enable_intrs(ha);
 
        /* Start timer thread. */
@@ -1752,6 +1799,7 @@ probe_failed:
        qla4xxx_free_adapter(ha);
 
 probe_failed_ioconfig:
+       pci_disable_pcie_error_reporting(pdev);
        scsi_host_put(ha->host);
 
 probe_disable_device:
@@ -1781,6 +1829,7 @@ static void __devexit qla4xxx_remove_adapter(struct pci_dev *pdev)
 
        scsi_host_put(ha->host);
 
+       pci_disable_pcie_error_reporting(pdev);
        pci_disable_device(pdev);
        pci_set_drvdata(pdev, NULL);
 }
@@ -1877,6 +1926,17 @@ static int qla4xxx_eh_wait_on_command(struct scsi_qla_host *ha,
        int done = 0;
        struct srb *rp;
        uint32_t max_wait_time = EH_WAIT_CMD_TOV;
+       int ret = SUCCESS;
+
+       /* Dont wait on command if PCI error is being handled
+        * by PCI AER driver
+        */
+       if (unlikely(pci_channel_offline(ha->pdev)) ||
+           (test_bit(AF_EEH_BUSY, &ha->flags))) {
+               ql4_printk(KERN_WARNING, ha, "scsi%ld: Return from %s\n",
+                   ha->host_no, __func__);
+               return ret;
+       }
 
        do {
                /* Checking to see if its returned to OS */
@@ -2172,6 +2232,252 @@ static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd)
        return return_status;
 }
 
+/* PCI AER driver recovers from all correctable errors w/o
+ * driver intervention. For uncorrectable errors PCI AER
+ * driver calls the following device driver's callbacks
+ *
+ * - Fatal Errors - link_reset
+ * - Non-Fatal Errors - driver's pci_error_detected() which
+ * returns CAN_RECOVER, NEED_RESET or DISCONNECT.
+ *
+ * PCI AER driver calls
+ * CAN_RECOVER - driver's pci_mmio_enabled(), mmio_enabled
+ *               returns RECOVERED or NEED_RESET if fw_hung
+ * NEED_RESET - driver's slot_reset()
+ * DISCONNECT - device is dead & cannot recover
+ * RECOVERED - driver's pci_resume()
+ */
+static pci_ers_result_t
+qla4xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
+{
+       struct scsi_qla_host *ha = pci_get_drvdata(pdev);
+
+       ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: error detected:state %x\n",
+           ha->host_no, __func__, state);
+
+       if (!is_aer_supported(ha))
+               return PCI_ERS_RESULT_NONE;
+
+       switch (state) {
+       case pci_channel_io_normal:
+               clear_bit(AF_EEH_BUSY, &ha->flags);
+               return PCI_ERS_RESULT_CAN_RECOVER;
+       case pci_channel_io_frozen:
+               set_bit(AF_EEH_BUSY, &ha->flags);
+               qla4xxx_mailbox_premature_completion(ha);
+               qla4xxx_free_irqs(ha);
+               pci_disable_device(pdev);
+               return PCI_ERS_RESULT_NEED_RESET;
+       case pci_channel_io_perm_failure:
+               set_bit(AF_EEH_BUSY, &ha->flags);
+               set_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags);
+               qla4xxx_abort_active_cmds(ha, DID_NO_CONNECT << 16);
+               return PCI_ERS_RESULT_DISCONNECT;
+       }
+       return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/**
+ * qla4xxx_pci_mmio_enabled() gets called if
+ * qla4xxx_pci_error_detected() returns PCI_ERS_RESULT_CAN_RECOVER
+ * and read/write to the device still works.
+ **/
+static pci_ers_result_t
+qla4xxx_pci_mmio_enabled(struct pci_dev *pdev)
+{
+       struct scsi_qla_host *ha = pci_get_drvdata(pdev);
+
+       if (!is_aer_supported(ha))
+               return PCI_ERS_RESULT_NONE;
+
+       if (test_bit(AF_FW_RECOVERY, &ha->flags)) {
+               ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: firmware hang  -- "
+                   "mmio_enabled\n", ha->host_no, __func__);
+               return PCI_ERS_RESULT_NEED_RESET;
+       } else
+               return PCI_ERS_RESULT_RECOVERED;
+}
+
+uint32_t qla4_8xxx_error_recovery(struct scsi_qla_host *ha)
+{
+       uint32_t rval = QLA_ERROR;
+       int fn;
+       struct pci_dev *other_pdev = NULL;
+
+       ql4_printk(KERN_WARNING, ha, "scsi%ld: In %s\n", ha->host_no, __func__);
+
+       set_bit(DPC_RESET_ACTIVE, &ha->dpc_flags);
+
+       if (test_bit(AF_ONLINE, &ha->flags)) {
+               clear_bit(AF_ONLINE, &ha->flags);
+               qla4xxx_mark_all_devices_missing(ha);
+               qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
+               qla4xxx_abort_active_cmds(ha, DID_RESET << 16);
+       }
+
+       fn = PCI_FUNC(ha->pdev->devfn);
+       while (fn > 0) {
+               fn--;
+               ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Finding PCI device at "
+                   "func %x\n", ha->host_no, __func__, fn);
+               /* Get the pci device given the domain, bus,
+                * slot/function number */
+               other_pdev =
+                   pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus),
+                   ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn),
+                   fn));
+
+               if (!other_pdev)
+                       continue;
+
+               if (atomic_read(&other_pdev->enable_cnt)) {
+                       ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Found PCI "
+                           "func in enabled state%x\n", ha->host_no,
+                           __func__, fn);
+                       pci_dev_put(other_pdev);
+                       break;
+               }
+               pci_dev_put(other_pdev);
+       }
+
+       /* The first function on the card, the reset owner will
+        * start & initialize the firmware. The other functions
+        * on the card will reset the firmware context
+        */
+       if (!fn) {
+               ql4_printk(KERN_INFO, ha, "scsi%ld: %s: devfn being reset "
+                   "0x%x is the owner\n", ha->host_no, __func__,
+                   ha->pdev->devfn);
+
+               qla4_8xxx_idc_lock(ha);
+               qla4_8xxx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
+                   QLA82XX_DEV_COLD);
+
+               qla4_8xxx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION,
+                   QLA82XX_IDC_VERSION);
+
+               qla4_8xxx_idc_unlock(ha);
+               clear_bit(AF_FW_RECOVERY, &ha->flags);
+               rval = qla4xxx_initialize_adapter(ha, PRESERVE_DDB_LIST);
+               qla4_8xxx_idc_lock(ha);
+
+               if (rval != QLA_SUCCESS) {
+                       ql4_printk(KERN_INFO, ha, "scsi%ld: %s: HW State: "
+                           "FAILED\n", ha->host_no, __func__);
+                       qla4_8xxx_clear_drv_active(ha);
+                       qla4_8xxx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
+                           QLA82XX_DEV_FAILED);
+               } else {
+                       ql4_printk(KERN_INFO, ha, "scsi%ld: %s: HW State: "
+                           "READY\n", ha->host_no, __func__);
+                       qla4_8xxx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
+                           QLA82XX_DEV_READY);
+                       /* Clear driver state register */
+                       qla4_8xxx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0);
+                       qla4_8xxx_set_drv_active(ha);
+                       ha->isp_ops->enable_intrs(ha);
+               }
+               qla4_8xxx_idc_unlock(ha);
+       } else {
+               ql4_printk(KERN_INFO, ha, "scsi%ld: %s: devfn 0x%x is not "
+                   "the reset owner\n", ha->host_no, __func__,
+                   ha->pdev->devfn);
+               if ((qla4_8xxx_rd_32(ha, QLA82XX_CRB_DEV_STATE) ==
+                   QLA82XX_DEV_READY)) {
+                       clear_bit(AF_FW_RECOVERY, &ha->flags);
+                       rval = qla4xxx_initialize_adapter(ha,
+                           PRESERVE_DDB_LIST);
+                       if (rval == QLA_SUCCESS)
+                               ha->isp_ops->enable_intrs(ha);
+                       qla4_8xxx_idc_lock(ha);
+                       qla4_8xxx_set_drv_active(ha);
+                       qla4_8xxx_idc_unlock(ha);
+               }
+       }
+       clear_bit(DPC_RESET_ACTIVE, &ha->dpc_flags);
+       return rval;
+}
+
+static pci_ers_result_t
+qla4xxx_pci_slot_reset(struct pci_dev *pdev)
+{
+       pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT;
+       struct scsi_qla_host *ha = pci_get_drvdata(pdev);
+       int rc;
+
+       ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: slot_reset\n",
+           ha->host_no, __func__);
+
+       if (!is_aer_supported(ha))
+               return PCI_ERS_RESULT_NONE;
+
+       /* Restore the saved state of PCIe device -
+        * BAR registers, PCI Config space, PCIX, MSI,
+        * IOV states
+        */
+       pci_restore_state(pdev);
+
+       /* pci_restore_state() clears the saved_state flag of the device
+        * save restored state which resets saved_state flag
+        */
+       pci_save_state(pdev);
+
+       /* Initialize device or resume if in suspended state */
+       rc = pci_enable_device(pdev);
+       if (rc) {
+               ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: Cant re-enable "
+                   "device after reset\n", ha->host_no, __func__);
+               goto exit_slot_reset;
+       }
+
+       ret = qla4xxx_request_irqs(ha);
+       if (ret) {
+               ql4_printk(KERN_WARNING, ha, "Failed to reserve interrupt %d"
+                   " already in use.\n", pdev->irq);
+               goto exit_slot_reset;
+       }
+
+       if (is_qla8022(ha)) {
+               if (qla4_8xxx_error_recovery(ha) == QLA_SUCCESS) {
+                       ret = PCI_ERS_RESULT_RECOVERED;
+                       goto exit_slot_reset;
+               } else
+                       goto exit_slot_reset;
+       }
+
+exit_slot_reset:
+       ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: Return=%x\n"
+           "device after reset\n", ha->host_no, __func__, ret);
+       return ret;
+}
+
+static void
+qla4xxx_pci_resume(struct pci_dev *pdev)
+{
+       struct scsi_qla_host *ha = pci_get_drvdata(pdev);
+       int ret;
+
+       ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: pci_resume\n",
+           ha->host_no, __func__);
+
+       ret = qla4xxx_wait_for_hba_online(ha);
+       if (ret != QLA_SUCCESS) {
+               ql4_printk(KERN_ERR, ha, "scsi%ld: %s: the device failed to "
+                   "resume I/O from slot/link_reset\n", ha->host_no,
+                    __func__);
+       }
+
+       pci_cleanup_aer_uncorrect_error_status(pdev);
+       clear_bit(AF_EEH_BUSY, &ha->flags);
+}
+
+static struct pci_error_handlers qla4xxx_err_handler = {
+       .error_detected = qla4xxx_pci_error_detected,
+       .mmio_enabled = qla4xxx_pci_mmio_enabled,
+       .slot_reset = qla4xxx_pci_slot_reset,
+       .resume = qla4xxx_pci_resume,
+};
+
 static struct pci_device_id qla4xxx_pci_tbl[] = {
        {
                .vendor         = PCI_VENDOR_ID_QLOGIC,
@@ -2206,6 +2512,7 @@ static struct pci_driver qla4xxx_pci_driver = {
        .id_table       = qla4xxx_pci_tbl,
        .probe          = qla4xxx_probe_adapter,
        .remove         = qla4xxx_remove_adapter,
+       .err_handler = &qla4xxx_err_handler,
 };
 
 static int __init qla4xxx_module_init(void)
index c905dbd753319f134df6a03081da87df82875fc2..a77b973f2cbc607c60c510b8f1e58ae048fb3c42 100644 (file)
@@ -5,4 +5,4 @@
  * See LICENSE.qla4xxx for copyright and licensing details.
  */
 
-#define QLA4XXX_DRIVER_VERSION "5.02.00-k2"
+#define QLA4XXX_DRIVER_VERSION "5.02.00-k3"
index bbbc186dbc1a413f0ef0e77c07710fa11bfb03e6..1de30eb83bb097664056209ec6d06a470385b76d 100644 (file)
@@ -473,14 +473,17 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
                 */
                return SUCCESS;
        case RESERVATION_CONFLICT:
-               /*
-                * let issuer deal with this, it could be just fine
-                */
-               return SUCCESS;
+               if (scmd->cmnd[0] == TEST_UNIT_READY)
+                       /* it is a success, we probed the device and
+                        * found it */
+                       return SUCCESS;
+               /* otherwise, we failed to send the command */
+               return FAILED;
        case QUEUE_FULL:
                scsi_handle_queue_full(scmd->device);
                /* fall through */
        case BUSY:
+               return NEEDS_RETRY;
        default:
                return FAILED;
        }
index 66241dd525ae7fac133197064a0eaa86e5e0e624..c399be9799213ed4a604436b14f2767a5f6f2cde 100644 (file)
@@ -185,6 +185,7 @@ static void scsi_tgt_cmd_destroy(struct work_struct *work)
        dprintk("cmd %p %d %u\n", cmd, cmd->sc_data_direction,
                rq_data_dir(cmd->request));
        scsi_unmap_user_pages(tcmd);
+       tcmd->rq->bio = NULL;
        scsi_host_put_command(scsi_tgt_cmd_to_host(cmd), cmd);
 }
 
index f0a1418ce66078bcb58b5485de978f3dbdb2a49b..acd35d1ebd12621e35a05324daa450992b081f17 100644 (file)
@@ -1723,7 +1723,7 @@ static void pl022_cleanup(struct spi_device *spi)
 }
 
 
-static int __init
+static int __devinit
 pl022_probe(struct amba_device *adev, struct amba_id *id)
 {
        struct device *dev = &adev->dev;
@@ -1838,7 +1838,7 @@ pl022_probe(struct amba_device *adev, struct amba_id *id)
        return status;
 }
 
-static int __exit
+static int __devexit
 pl022_remove(struct amba_device *adev)
 {
        struct pl022 *pl022 = amba_get_drvdata(adev);
@@ -1970,7 +1970,7 @@ static struct amba_driver pl022_driver = {
        },
        .id_table       = pl022_ids,
        .probe          = pl022_probe,
-       .remove         = __exit_p(pl022_remove),
+       .remove         = __devexit_p(pl022_remove),
        .suspend        = pl022_suspend,
        .resume         = pl022_resume,
 };
index cddbfceb324f6ccbef716395ddbf2190e3538435..77d9e7ee8b27b6502d39dcc1b08aaa827b8fd96b 100644 (file)
@@ -406,9 +406,9 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id)
 }
 
 /* bus_num is used only for the case dev->platform_data == NULL */
-static int __init mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
-                                          u32 size, unsigned int irq,
-                                          s16 bus_num)
+static int __devinit mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
+                                             u32 size, unsigned int irq,
+                                             s16 bus_num)
 {
        struct fsl_spi_platform_data *pdata = dev->platform_data;
        struct mpc512x_psc_spi *mps;
@@ -492,7 +492,7 @@ free_master:
        return ret;
 }
 
-static int __exit mpc512x_psc_spi_do_remove(struct device *dev)
+static int __devexit mpc512x_psc_spi_do_remove(struct device *dev)
 {
        struct spi_master *master = dev_get_drvdata(dev);
        struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
@@ -507,8 +507,8 @@ static int __exit mpc512x_psc_spi_do_remove(struct device *dev)
        return 0;
 }
 
-static int __init mpc512x_psc_spi_of_probe(struct platform_device *op,
-                                          const struct of_device_id *match)
+static int __devinit mpc512x_psc_spi_of_probe(struct platform_device *op,
+                                             const struct of_device_id *match)
 {
        const u32 *regaddr_p;
        u64 regaddr64, size64;
@@ -539,7 +539,7 @@ static int __init mpc512x_psc_spi_of_probe(struct platform_device *op,
                                irq_of_parse_and_map(op->dev.of_node, 0), id);
 }
 
-static int __exit mpc512x_psc_spi_of_remove(struct platform_device *op)
+static int __devexit mpc512x_psc_spi_of_remove(struct platform_device *op)
 {
        return mpc512x_psc_spi_do_remove(&op->dev);
 }
@@ -553,7 +553,7 @@ MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match);
 
 static struct of_platform_driver mpc512x_psc_spi_of_driver = {
        .probe = mpc512x_psc_spi_of_probe,
-       .remove = __exit_p(mpc512x_psc_spi_of_remove),
+       .remove = __devexit_p(mpc512x_psc_spi_of_remove),
        .driver = {
                .name = "mpc512x-psc-spi",
                .owner = THIS_MODULE,
index 24668b30a52d4a88a6bec93499e82c35886f7f31..9bd1c92ad96e89abe988dea3def8b37944643e30 100644 (file)
@@ -141,7 +141,12 @@ static void spi100k_write_data(struct spi_master *master, int len, int data)
 {
        struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
 
-       /* write 16-bit word */
+       /* write 16-bit word, shifting 8-bit data if necessary */
+       if (len <= 8) {
+               data <<= 8;
+               len = 16;
+       }
+
        spi100k_enable_clock(master);
        writew( data , spi100k->base + SPI_TX_MSB);
 
@@ -162,6 +167,10 @@ static int spi100k_read_data(struct spi_master *master, int len)
        int dataH,dataL;
        struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
 
+       /* Always do at least 16 bits */
+       if (len <= 8)
+               len = 16;
+
        spi100k_enable_clock(master);
        writew(SPI_CTRL_SEN(0) |
               SPI_CTRL_WORD_SIZE(len) |
@@ -214,10 +223,6 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
        c = count;
        word_len = cs->word_len;
 
-       /* RX_ONLY mode needs dummy data in TX reg */
-       if (xfer->tx_buf == NULL)
-               spi100k_write_data(spi->master,word_len, 0);
-
        if (word_len <= 8) {
                u8              *rx;
                const u8        *tx;
@@ -227,9 +232,9 @@ omap1_spi100k_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
                do {
                        c-=1;
                        if (xfer->tx_buf != NULL)
-                               spi100k_write_data(spi->master,word_len, *tx);
+                               spi100k_write_data(spi->master, word_len, *tx++);
                        if (xfer->rx_buf != NULL)
-                               *rx = spi100k_read_data(spi->master,word_len);
+                               *rx++ = spi100k_read_data(spi->master, word_len);
                } while(c);
        } else if (word_len <= 16) {
                u16             *rx;
@@ -380,10 +385,6 @@ static void omap1_spi100k_work(struct work_struct *work)
                        if (t->len) {
                                unsigned count;
 
-                               /* RX_ONLY mode needs dummy data in TX reg */
-                               if (t->tx_buf == NULL)
-                                       spi100k_write_data(spi->master, 8, 0);
-
                                count = omap1_spi100k_txrx_pio(spi, t);
                                m->actual_length += count;
 
index 1bb1b88780cefc4cd69e88e15d4e1f5413c55d1e..a9e5c79ae52a04a43aebabeacfc2d3cc29e03e77 100644 (file)
@@ -528,6 +528,10 @@ int spi_register_master(struct spi_master *master)
                dynamic = 1;
        }
 
+       spin_lock_init(&master->bus_lock_spinlock);
+       mutex_init(&master->bus_lock_mutex);
+       master->bus_lock_flag = 0;
+
        /* register the device, then userspace will see it.
         * registration fails if the bus ID is in use.
         */
@@ -670,6 +674,35 @@ int spi_setup(struct spi_device *spi)
 }
 EXPORT_SYMBOL_GPL(spi_setup);
 
+static int __spi_async(struct spi_device *spi, struct spi_message *message)
+{
+       struct spi_master *master = spi->master;
+
+       /* Half-duplex links include original MicroWire, and ones with
+        * only one data pin like SPI_3WIRE (switches direction) or where
+        * either MOSI or MISO is missing.  They can also be caused by
+        * software limitations.
+        */
+       if ((master->flags & SPI_MASTER_HALF_DUPLEX)
+                       || (spi->mode & SPI_3WIRE)) {
+               struct spi_transfer *xfer;
+               unsigned flags = master->flags;
+
+               list_for_each_entry(xfer, &message->transfers, transfer_list) {
+                       if (xfer->rx_buf && xfer->tx_buf)
+                               return -EINVAL;
+                       if ((flags & SPI_MASTER_NO_TX) && xfer->tx_buf)
+                               return -EINVAL;
+                       if ((flags & SPI_MASTER_NO_RX) && xfer->rx_buf)
+                               return -EINVAL;
+               }
+       }
+
+       message->spi = spi;
+       message->status = -EINPROGRESS;
+       return master->transfer(spi, message);
+}
+
 /**
  * spi_async - asynchronous SPI transfer
  * @spi: device with which data will be exchanged
@@ -702,33 +735,68 @@ EXPORT_SYMBOL_GPL(spi_setup);
 int spi_async(struct spi_device *spi, struct spi_message *message)
 {
        struct spi_master *master = spi->master;
+       int ret;
+       unsigned long flags;
 
-       /* Half-duplex links include original MicroWire, and ones with
-        * only one data pin like SPI_3WIRE (switches direction) or where
-        * either MOSI or MISO is missing.  They can also be caused by
-        * software limitations.
-        */
-       if ((master->flags & SPI_MASTER_HALF_DUPLEX)
-                       || (spi->mode & SPI_3WIRE)) {
-               struct spi_transfer *xfer;
-               unsigned flags = master->flags;
+       spin_lock_irqsave(&master->bus_lock_spinlock, flags);
 
-               list_for_each_entry(xfer, &message->transfers, transfer_list) {
-                       if (xfer->rx_buf && xfer->tx_buf)
-                               return -EINVAL;
-                       if ((flags & SPI_MASTER_NO_TX) && xfer->tx_buf)
-                               return -EINVAL;
-                       if ((flags & SPI_MASTER_NO_RX) && xfer->rx_buf)
-                               return -EINVAL;
-               }
-       }
+       if (master->bus_lock_flag)
+               ret = -EBUSY;
+       else
+               ret = __spi_async(spi, message);
 
-       message->spi = spi;
-       message->status = -EINPROGRESS;
-       return master->transfer(spi, message);
+       spin_unlock_irqrestore(&master->bus_lock_spinlock, flags);
+
+       return ret;
 }
 EXPORT_SYMBOL_GPL(spi_async);
 
+/**
+ * spi_async_locked - version of spi_async with exclusive bus usage
+ * @spi: device with which data will be exchanged
+ * @message: describes the data transfers, including completion callback
+ * Context: any (irqs may be blocked, etc)
+ *
+ * This call may be used in_irq and other contexts which can't sleep,
+ * as well as from task contexts which can sleep.
+ *
+ * The completion callback is invoked in a context which can't sleep.
+ * Before that invocation, the value of message->status is undefined.
+ * When the callback is issued, message->status holds either zero (to
+ * indicate complete success) or a negative error code.  After that
+ * callback returns, the driver which issued the transfer request may
+ * deallocate the associated memory; it's no longer in use by any SPI
+ * core or controller driver code.
+ *
+ * Note that although all messages to a spi_device are handled in
+ * FIFO order, messages may go to different devices in other orders.
+ * Some device might be higher priority, or have various "hard" access
+ * time requirements, for example.
+ *
+ * On detection of any fault during the transfer, processing of
+ * the entire message is aborted, and the device is deselected.
+ * Until returning from the associated message completion callback,
+ * no other spi_message queued to that device will be processed.
+ * (This rule applies equally to all the synchronous transfer calls,
+ * which are wrappers around this core asynchronous primitive.)
+ */
+int spi_async_locked(struct spi_device *spi, struct spi_message *message)
+{
+       struct spi_master *master = spi->master;
+       int ret;
+       unsigned long flags;
+
+       spin_lock_irqsave(&master->bus_lock_spinlock, flags);
+
+       ret = __spi_async(spi, message);
+
+       spin_unlock_irqrestore(&master->bus_lock_spinlock, flags);
+
+       return ret;
+
+}
+EXPORT_SYMBOL_GPL(spi_async_locked);
+
 
 /*-------------------------------------------------------------------------*/
 
@@ -742,6 +810,32 @@ static void spi_complete(void *arg)
        complete(arg);
 }
 
+static int __spi_sync(struct spi_device *spi, struct spi_message *message,
+                     int bus_locked)
+{
+       DECLARE_COMPLETION_ONSTACK(done);
+       int status;
+       struct spi_master *master = spi->master;
+
+       message->complete = spi_complete;
+       message->context = &done;
+
+       if (!bus_locked)
+               mutex_lock(&master->bus_lock_mutex);
+
+       status = spi_async_locked(spi, message);
+
+       if (!bus_locked)
+               mutex_unlock(&master->bus_lock_mutex);
+
+       if (status == 0) {
+               wait_for_completion(&done);
+               status = message->status;
+       }
+       message->context = NULL;
+       return status;
+}
+
 /**
  * spi_sync - blocking/synchronous SPI data transfers
  * @spi: device with which data will be exchanged
@@ -765,21 +859,86 @@ static void spi_complete(void *arg)
  */
 int spi_sync(struct spi_device *spi, struct spi_message *message)
 {
-       DECLARE_COMPLETION_ONSTACK(done);
-       int status;
-
-       message->complete = spi_complete;
-       message->context = &done;
-       status = spi_async(spi, message);
-       if (status == 0) {
-               wait_for_completion(&done);
-               status = message->status;
-       }
-       message->context = NULL;
-       return status;
+       return __spi_sync(spi, message, 0);
 }
 EXPORT_SYMBOL_GPL(spi_sync);
 
+/**
+ * spi_sync_locked - version of spi_sync with exclusive bus usage
+ * @spi: device with which data will be exchanged
+ * @message: describes the data transfers
+ * Context: can sleep
+ *
+ * This call may only be used from a context that may sleep.  The sleep
+ * is non-interruptible, and has no timeout.  Low-overhead controller
+ * drivers may DMA directly into and out of the message buffers.
+ *
+ * This call should be used by drivers that require exclusive access to the
+ * SPI bus. It has to be preceeded by a spi_bus_lock call. The SPI bus must
+ * be released by a spi_bus_unlock call when the exclusive access is over.
+ *
+ * It returns zero on success, else a negative error code.
+ */
+int spi_sync_locked(struct spi_device *spi, struct spi_message *message)
+{
+       return __spi_sync(spi, message, 1);
+}
+EXPORT_SYMBOL_GPL(spi_sync_locked);
+
+/**
+ * spi_bus_lock - obtain a lock for exclusive SPI bus usage
+ * @master: SPI bus master that should be locked for exclusive bus access
+ * Context: can sleep
+ *
+ * This call may only be used from a context that may sleep.  The sleep
+ * is non-interruptible, and has no timeout.
+ *
+ * This call should be used by drivers that require exclusive access to the
+ * SPI bus. The SPI bus must be released by a spi_bus_unlock call when the
+ * exclusive access is over. Data transfer must be done by spi_sync_locked
+ * and spi_async_locked calls when the SPI bus lock is held.
+ *
+ * It returns zero on success, else a negative error code.
+ */
+int spi_bus_lock(struct spi_master *master)
+{
+       unsigned long flags;
+
+       mutex_lock(&master->bus_lock_mutex);
+
+       spin_lock_irqsave(&master->bus_lock_spinlock, flags);
+       master->bus_lock_flag = 1;
+       spin_unlock_irqrestore(&master->bus_lock_spinlock, flags);
+
+       /* mutex remains locked until spi_bus_unlock is called */
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(spi_bus_lock);
+
+/**
+ * spi_bus_unlock - release the lock for exclusive SPI bus usage
+ * @master: SPI bus master that was locked for exclusive bus access
+ * Context: can sleep
+ *
+ * This call may only be used from a context that may sleep.  The sleep
+ * is non-interruptible, and has no timeout.
+ *
+ * This call releases an SPI bus lock previously obtained by an spi_bus_lock
+ * call.
+ *
+ * It returns zero on success, else a negative error code.
+ */
+int spi_bus_unlock(struct spi_master *master)
+{
+       master->bus_lock_flag = 0;
+
+       mutex_unlock(&master->bus_lock_mutex);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(spi_bus_unlock);
+
 /* portable code must never pass more than 32 bytes */
 #define        SPI_BUFSIZ      max(32,SMP_CACHE_BYTES)
 
index 5265330a528fb2a367f164465fefb0b496e25c31..8b55724d5f390152b7005d15b667f4f18f8ac788 100644 (file)
@@ -259,7 +259,6 @@ static void bitbang_work(struct work_struct *work)
        struct spi_bitbang      *bitbang =
                container_of(work, struct spi_bitbang, work);
        unsigned long           flags;
-       int                     do_setup = -1;
        int                     (*setup_transfer)(struct spi_device *,
                                        struct spi_transfer *);
 
@@ -275,6 +274,7 @@ static void bitbang_work(struct work_struct *work)
                unsigned                tmp;
                unsigned                cs_change;
                int                     status;
+               int                     do_setup = -1;
 
                m = container_of(bitbang->queue.next, struct spi_message,
                                queue);
@@ -307,6 +307,8 @@ static void bitbang_work(struct work_struct *work)
                                status = setup_transfer(spi, t);
                                if (status < 0)
                                        break;
+                               if (do_setup == -1)
+                                       do_setup = 0;
                        }
 
                        /* set up default clock polarity, and activate chip;
@@ -367,11 +369,6 @@ static void bitbang_work(struct work_struct *work)
                m->status = status;
                m->complete(m->context);
 
-               /* restore speed and wordsize if it was overridden */
-               if (do_setup == 1)
-                       setup_transfer(spi, NULL);
-               do_setup = 0;
-
                /* normally deactivate chipselect ... unless no error and
                 * cs_change has hinted that the next message will probably
                 * be for this chip too.
index fc033bbf9180dc1adbdd20e33b9375e4cfd14fbe..c16bf853c3eb3f3a0c7ab3c3c8731cc179d30a15 100644 (file)
@@ -44,7 +44,7 @@
 
 static inline u32
 bitbang_txrx_be_cpha0(struct spi_device *spi,
-               unsigned nsecs, unsigned cpol,
+               unsigned nsecs, unsigned cpol, unsigned flags,
                u32 word, u8 bits)
 {
        /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */
@@ -53,7 +53,8 @@ bitbang_txrx_be_cpha0(struct spi_device *spi,
        for (word <<= (32 - bits); likely(bits); bits--) {
 
                /* setup MSB (to slave) on trailing edge */
-               setmosi(spi, word & (1 << 31));
+               if ((flags & SPI_MASTER_NO_TX) == 0)
+                       setmosi(spi, word & (1 << 31));
                spidelay(nsecs);        /* T(setup) */
 
                setsck(spi, !cpol);
@@ -61,7 +62,8 @@ bitbang_txrx_be_cpha0(struct spi_device *spi,
 
                /* sample MSB (from slave) on leading edge */
                word <<= 1;
-               word |= getmiso(spi);
+               if ((flags & SPI_MASTER_NO_RX) == 0)
+                       word |= getmiso(spi);
                setsck(spi, cpol);
        }
        return word;
@@ -69,7 +71,7 @@ bitbang_txrx_be_cpha0(struct spi_device *spi,
 
 static inline u32
 bitbang_txrx_be_cpha1(struct spi_device *spi,
-               unsigned nsecs, unsigned cpol,
+               unsigned nsecs, unsigned cpol, unsigned flags,
                u32 word, u8 bits)
 {
        /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */
@@ -79,7 +81,8 @@ bitbang_txrx_be_cpha1(struct spi_device *spi,
 
                /* setup MSB (to slave) on leading edge */
                setsck(spi, !cpol);
-               setmosi(spi, word & (1 << 31));
+               if ((flags & SPI_MASTER_NO_TX) == 0)
+                       setmosi(spi, word & (1 << 31));
                spidelay(nsecs); /* T(setup) */
 
                setsck(spi, cpol);
@@ -87,7 +90,8 @@ bitbang_txrx_be_cpha1(struct spi_device *spi,
 
                /* sample MSB (from slave) on trailing edge */
                word <<= 1;
-               word |= getmiso(spi);
+               if ((flags & SPI_MASTER_NO_RX) == 0)
+                       word |= getmiso(spi);
        }
        return word;
 }
index 8b52812811110d5a1ff4835813a4f613c5713f0c..0d4ceba3b5900258c071c86ebd1ff02ad50a2cdf 100644 (file)
@@ -156,7 +156,7 @@ butterfly_txrx_word_mode0(struct spi_device *spi,
                unsigned nsecs,
                u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
+       return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
 }
 
 /*----------------------------------------------------------------------*/
index 7edbd5807e0eb05e1e72242d0e304c034c4ae11b..e24a63498acb84f7e4f9f83710aca3fadefcc177 100644 (file)
@@ -146,25 +146,63 @@ static inline int getmiso(const struct spi_device *spi)
 static u32 spi_gpio_txrx_word_mode0(struct spi_device *spi,
                unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
+       return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
 }
 
 static u32 spi_gpio_txrx_word_mode1(struct spi_device *spi,
                unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha1(spi, nsecs, 0, word, bits);
+       return bitbang_txrx_be_cpha1(spi, nsecs, 0, 0, word, bits);
 }
 
 static u32 spi_gpio_txrx_word_mode2(struct spi_device *spi,
                unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha0(spi, nsecs, 1, word, bits);
+       return bitbang_txrx_be_cpha0(spi, nsecs, 1, 0, word, bits);
 }
 
 static u32 spi_gpio_txrx_word_mode3(struct spi_device *spi,
                unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha1(spi, nsecs, 1, word, bits);
+       return bitbang_txrx_be_cpha1(spi, nsecs, 1, 0, word, bits);
+}
+
+/*
+ * These functions do not call setmosi or getmiso if respective flag
+ * (SPI_MASTER_NO_RX or SPI_MASTER_NO_TX) is set, so they are safe to
+ * call when such pin is not present or defined in the controller.
+ * A separate set of callbacks is defined to get highest possible
+ * speed in the generic case (when both MISO and MOSI lines are
+ * available), as optimiser will remove the checks when argument is
+ * constant.
+ */
+
+static u32 spi_gpio_spec_txrx_word_mode0(struct spi_device *spi,
+               unsigned nsecs, u32 word, u8 bits)
+{
+       unsigned flags = spi->master->flags;
+       return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits);
+}
+
+static u32 spi_gpio_spec_txrx_word_mode1(struct spi_device *spi,
+               unsigned nsecs, u32 word, u8 bits)
+{
+       unsigned flags = spi->master->flags;
+       return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits);
+}
+
+static u32 spi_gpio_spec_txrx_word_mode2(struct spi_device *spi,
+               unsigned nsecs, u32 word, u8 bits)
+{
+       unsigned flags = spi->master->flags;
+       return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits);
+}
+
+static u32 spi_gpio_spec_txrx_word_mode3(struct spi_device *spi,
+               unsigned nsecs, u32 word, u8 bits)
+{
+       unsigned flags = spi->master->flags;
+       return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits);
 }
 
 /*----------------------------------------------------------------------*/
@@ -232,19 +270,30 @@ static int __init spi_gpio_alloc(unsigned pin, const char *label, bool is_in)
 }
 
 static int __init
-spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label)
+spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label,
+       u16 *res_flags)
 {
        int value;
 
        /* NOTE:  SPI_*_GPIO symbols may reference "pdata" */
 
-       value = spi_gpio_alloc(SPI_MOSI_GPIO, label, false);
-       if (value)
-               goto done;
+       if (SPI_MOSI_GPIO != SPI_GPIO_NO_MOSI) {
+               value = spi_gpio_alloc(SPI_MOSI_GPIO, label, false);
+               if (value)
+                       goto done;
+       } else {
+               /* HW configuration without MOSI pin */
+               *res_flags |= SPI_MASTER_NO_TX;
+       }
 
-       value = spi_gpio_alloc(SPI_MISO_GPIO, label, true);
-       if (value)
-               goto free_mosi;
+       if (SPI_MISO_GPIO != SPI_GPIO_NO_MISO) {
+               value = spi_gpio_alloc(SPI_MISO_GPIO, label, true);
+               if (value)
+                       goto free_mosi;
+       } else {
+               /* HW configuration without MISO pin */
+               *res_flags |= SPI_MASTER_NO_RX;
+       }
 
        value = spi_gpio_alloc(SPI_SCK_GPIO, label, false);
        if (value)
@@ -253,9 +302,11 @@ spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label)
        goto done;
 
 free_miso:
-       gpio_free(SPI_MISO_GPIO);
+       if (SPI_MISO_GPIO != SPI_GPIO_NO_MISO)
+               gpio_free(SPI_MISO_GPIO);
 free_mosi:
-       gpio_free(SPI_MOSI_GPIO);
+       if (SPI_MOSI_GPIO != SPI_GPIO_NO_MOSI)
+               gpio_free(SPI_MOSI_GPIO);
 done:
        return value;
 }
@@ -266,6 +317,7 @@ static int __init spi_gpio_probe(struct platform_device *pdev)
        struct spi_master               *master;
        struct spi_gpio                 *spi_gpio;
        struct spi_gpio_platform_data   *pdata;
+       u16 master_flags = 0;
 
        pdata = pdev->dev.platform_data;
 #ifdef GENERIC_BITBANG
@@ -273,7 +325,7 @@ static int __init spi_gpio_probe(struct platform_device *pdev)
                return -ENODEV;
 #endif
 
-       status = spi_gpio_request(pdata, dev_name(&pdev->dev));
+       status = spi_gpio_request(pdata, dev_name(&pdev->dev), &master_flags);
        if (status < 0)
                return status;
 
@@ -289,6 +341,7 @@ static int __init spi_gpio_probe(struct platform_device *pdev)
        if (pdata)
                spi_gpio->pdata = *pdata;
 
+       master->flags = master_flags;
        master->bus_num = pdev->id;
        master->num_chipselect = SPI_N_CHIPSEL;
        master->setup = spi_gpio_setup;
@@ -296,10 +349,18 @@ static int __init spi_gpio_probe(struct platform_device *pdev)
 
        spi_gpio->bitbang.master = spi_master_get(master);
        spi_gpio->bitbang.chipselect = spi_gpio_chipselect;
-       spi_gpio->bitbang.txrx_word[SPI_MODE_0] = spi_gpio_txrx_word_mode0;
-       spi_gpio->bitbang.txrx_word[SPI_MODE_1] = spi_gpio_txrx_word_mode1;
-       spi_gpio->bitbang.txrx_word[SPI_MODE_2] = spi_gpio_txrx_word_mode2;
-       spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_txrx_word_mode3;
+
+       if ((master_flags & (SPI_MASTER_NO_RX | SPI_MASTER_NO_RX)) == 0) {
+               spi_gpio->bitbang.txrx_word[SPI_MODE_0] = spi_gpio_txrx_word_mode0;
+               spi_gpio->bitbang.txrx_word[SPI_MODE_1] = spi_gpio_txrx_word_mode1;
+               spi_gpio->bitbang.txrx_word[SPI_MODE_2] = spi_gpio_txrx_word_mode2;
+               spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_txrx_word_mode3;
+       } else {
+               spi_gpio->bitbang.txrx_word[SPI_MODE_0] = spi_gpio_spec_txrx_word_mode0;
+               spi_gpio->bitbang.txrx_word[SPI_MODE_1] = spi_gpio_spec_txrx_word_mode1;
+               spi_gpio->bitbang.txrx_word[SPI_MODE_2] = spi_gpio_spec_txrx_word_mode2;
+               spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_spec_txrx_word_mode3;
+       }
        spi_gpio->bitbang.setup_transfer = spi_bitbang_setup_transfer;
        spi_gpio->bitbang.flags = SPI_CS_HIGH;
 
@@ -307,8 +368,10 @@ static int __init spi_gpio_probe(struct platform_device *pdev)
        if (status < 0) {
                spi_master_put(spi_gpio->bitbang.master);
 gpio_free:
-               gpio_free(SPI_MISO_GPIO);
-               gpio_free(SPI_MOSI_GPIO);
+               if (SPI_MISO_GPIO != SPI_GPIO_NO_MISO)
+                       gpio_free(SPI_MISO_GPIO);
+               if (SPI_MOSI_GPIO != SPI_GPIO_NO_MOSI)
+                       gpio_free(SPI_MOSI_GPIO);
                gpio_free(SPI_SCK_GPIO);
                spi_master_put(master);
        }
@@ -331,8 +394,10 @@ static int __exit spi_gpio_remove(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, NULL);
 
-       gpio_free(SPI_MISO_GPIO);
-       gpio_free(SPI_MOSI_GPIO);
+       if (SPI_MISO_GPIO != SPI_GPIO_NO_MISO)
+               gpio_free(SPI_MISO_GPIO);
+       if (SPI_MOSI_GPIO != SPI_GPIO_NO_MOSI)
+               gpio_free(SPI_MOSI_GPIO);
        gpio_free(SPI_SCK_GPIO);
 
        return status;
index 86fb7b5993db124a763fb6a3ad52a863f96fb450..7746a41ab6d6dd958f5cf75d8d01e090b76ca12d 100644 (file)
@@ -191,7 +191,7 @@ static void lm70_chipselect(struct spi_device *spi, int value)
  */
 static u32 lm70_txrx(struct spi_device *spi, unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
+       return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
 }
 
 static void spi_lm70llp_attach(struct parport *p)
index 8979a75dbd7b5cc2d0c77459fcab43966f36c03e..be991359bf9282cde5eaaa0eaa7fb0316dcf0d76 100644 (file)
@@ -64,25 +64,25 @@ static inline u32 getmiso(struct spi_device *dev)
 static u32 s3c2410_spigpio_txrx_mode0(struct spi_device *spi,
                                      unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
+       return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
 }
 
 static u32 s3c2410_spigpio_txrx_mode1(struct spi_device *spi,
                                      unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha1(spi, nsecs, 0, word, bits);
+       return bitbang_txrx_be_cpha1(spi, nsecs, 0, 0, word, bits);
 }
 
 static u32 s3c2410_spigpio_txrx_mode2(struct spi_device *spi,
                                      unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha0(spi, nsecs, 1, word, bits);
+       return bitbang_txrx_be_cpha0(spi, nsecs, 1, 0, word, bits);
 }
 
 static u32 s3c2410_spigpio_txrx_mode3(struct spi_device *spi,
                                      unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha1(spi, nsecs, 1, word, bits);
+       return bitbang_txrx_be_cpha1(spi, nsecs, 1, 0, word, bits);
 }
 
 
index a511be7961a0a843f0d46c0b37dfb0c3dfd06175..5c6439161199a8cf604bd3b6bf08cd713d7ea912 100644 (file)
@@ -83,25 +83,25 @@ static inline u32 getmiso(struct spi_device *dev)
 static u32 sh_sci_spi_txrx_mode0(struct spi_device *spi,
                                      unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
+       return bitbang_txrx_be_cpha0(spi, nsecs, 0, 0, word, bits);
 }
 
 static u32 sh_sci_spi_txrx_mode1(struct spi_device *spi,
                                      unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha1(spi, nsecs, 0, word, bits);
+       return bitbang_txrx_be_cpha1(spi, nsecs, 0, 0, word, bits);
 }
 
 static u32 sh_sci_spi_txrx_mode2(struct spi_device *spi,
                                      unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha0(spi, nsecs, 1, word, bits);
+       return bitbang_txrx_be_cpha0(spi, nsecs, 1, 0, word, bits);
 }
 
 static u32 sh_sci_spi_txrx_mode3(struct spi_device *spi,
                                      unsigned nsecs, u32 word, u8 bits)
 {
-       return bitbang_txrx_be_cpha1(spi, nsecs, 1, word, bits);
+       return bitbang_txrx_be_cpha1(spi, nsecs, 1, 0, word, bits);
 }
 
 static void sh_sci_spi_chipselect(struct spi_device *dev, int value)
index af56071b06f92ea23368947a4daffad12e03e660..ae0a5286f558f334859a6d5a2163c18bcc974c3e 100644 (file)
@@ -262,6 +262,13 @@ struct spi_master {
 #define SPI_MASTER_NO_RX       BIT(1)          /* can't do buffer read */
 #define SPI_MASTER_NO_TX       BIT(2)          /* can't do buffer write */
 
+       /* lock and mutex for SPI bus locking */
+       spinlock_t              bus_lock_spinlock;
+       struct mutex            bus_lock_mutex;
+
+       /* flag indicating that the SPI bus is locked for exclusive use */
+       bool                    bus_lock_flag;
+
        /* Setup mode and clock, etc (spi driver may call many times).
         *
         * IMPORTANT:  this may be called when transfers to another
@@ -542,6 +549,8 @@ static inline void spi_message_free(struct spi_message *m)
 
 extern int spi_setup(struct spi_device *spi);
 extern int spi_async(struct spi_device *spi, struct spi_message *message);
+extern int spi_async_locked(struct spi_device *spi,
+                           struct spi_message *message);
 
 /*---------------------------------------------------------------------------*/
 
@@ -551,6 +560,9 @@ extern int spi_async(struct spi_device *spi, struct spi_message *message);
  */
 
 extern int spi_sync(struct spi_device *spi, struct spi_message *message);
+extern int spi_sync_locked(struct spi_device *spi, struct spi_message *message);
+extern int spi_bus_lock(struct spi_master *master);
+extern int spi_bus_unlock(struct spi_master *master);
 
 /**
  * spi_write - SPI synchronous write
index ca6782ee4b9fce4f9208020e552129db6f0fbd5a..369b3d7d5b956069f3773e6fd4610cb278c8f757 100644 (file)
  * SPI_GPIO_NO_CHIPSELECT to the controller_data:
  *             .controller_data = (void *) SPI_GPIO_NO_CHIPSELECT;
  *
+ * If the MISO or MOSI pin is not available then it should be set to
+ * SPI_GPIO_NO_MISO or SPI_GPIO_NO_MOSI.
+ *
  * If the bitbanged bus is later switched to a "native" controller,
  * that platform_device and controller_data should be removed.
  */
 
 #define SPI_GPIO_NO_CHIPSELECT         ((unsigned long)-1l)
+#define SPI_GPIO_NO_MISO               ((unsigned long)-1l)
+#define SPI_GPIO_NO_MOSI               ((unsigned long)-1l)
 
 /**
  * struct spi_gpio_platform_data - parameter for bitbanged SPI master
index 9b3b73f4ae9c77350abd052abbdc889634258801..b6e5fd23cc5a48e13f49b0d824ca3cc9713bd3ab 100644 (file)
@@ -2792,24 +2792,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
        spinlock_t *ptl;
        pte_t entry;
 
-       if (check_stack_guard_page(vma, address) < 0) {
-               pte_unmap(page_table);
+       pte_unmap(page_table);
+
+       /* Check if we need to add a guard page to the stack */
+       if (check_stack_guard_page(vma, address) < 0)
                return VM_FAULT_SIGBUS;
-       }
 
+       /* Use the zero-page for reads */
        if (!(flags & FAULT_FLAG_WRITE)) {
                entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
                                                vma->vm_page_prot));
-               ptl = pte_lockptr(mm, pmd);
-               spin_lock(ptl);
+               page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
                if (!pte_none(*page_table))
                        goto unlock;
                goto setpte;
        }
 
        /* Allocate our own private page. */
-       pte_unmap(page_table);
-
        if (unlikely(anon_vma_prepare(vma)))
                goto oom;
        page = alloc_zeroed_user_highpage_movable(vma, address);