diff options
182 files changed, 7053 insertions, 1550 deletions
diff --git a/Documentation/video4linux/CARDLIST.cx88 b/Documentation/video4linux/CARDLIST.cx88 index 89093f531727..0736518b2f88 100644 --- a/Documentation/video4linux/CARDLIST.cx88 +++ b/Documentation/video4linux/CARDLIST.cx88 | |||
| @@ -6,8 +6,8 @@ | |||
| 6 | 5 -> Leadtek Winfast 2000XP Expert [107d:6611,107d:6613] | 6 | 5 -> Leadtek Winfast 2000XP Expert [107d:6611,107d:6613] |
| 7 | 6 -> AverTV Studio 303 (M126) [1461:000b] | 7 | 6 -> AverTV Studio 303 (M126) [1461:000b] |
| 8 | 7 -> MSI TV-@nywhere Master [1462:8606] | 8 | 7 -> MSI TV-@nywhere Master [1462:8606] |
| 9 | 8 -> Leadtek Winfast DV2000 [107d:6620] | 9 | 8 -> Leadtek Winfast DV2000 [107d:6620,107d:6621] |
| 10 | 9 -> Leadtek PVR 2000 [107d:663b,107d:663c,107d:6632] | 10 | 9 -> Leadtek PVR 2000 [107d:663b,107d:663c,107d:6632,107d:6630,107d:6638,107d:6631,107d:6637,107d:663d] |
| 11 | 10 -> IODATA GV-VCP3/PCI [10fc:d003] | 11 | 10 -> IODATA GV-VCP3/PCI [10fc:d003] |
| 12 | 11 -> Prolink PlayTV PVR | 12 | 11 -> Prolink PlayTV PVR |
| 13 | 12 -> ASUS PVR-416 [1043:4823,1461:c111] | 13 | 12 -> ASUS PVR-416 [1043:4823,1461:c111] |
| @@ -59,7 +59,7 @@ | |||
| 59 | 58 -> Pinnacle PCTV HD 800i [11bd:0051] | 59 | 58 -> Pinnacle PCTV HD 800i [11bd:0051] |
| 60 | 59 -> DViCO FusionHDTV 5 PCI nano [18ac:d530] | 60 | 59 -> DViCO FusionHDTV 5 PCI nano [18ac:d530] |
| 61 | 60 -> Pinnacle Hybrid PCTV [12ab:1788] | 61 | 60 -> Pinnacle Hybrid PCTV [12ab:1788] |
| 62 | 61 -> Winfast TV2000 XP Global [107d:6f18] | 62 | 61 -> Leadtek TV2000 XP Global [107d:6f18,107d:6618] |
| 63 | 62 -> PowerColor RA330 [14f1:ea3d] | 63 | 62 -> PowerColor RA330 [14f1:ea3d] |
| 64 | 63 -> Geniatech X8000-MT DVBT [14f1:8852] | 64 | 63 -> Geniatech X8000-MT DVBT [14f1:8852] |
| 65 | 64 -> DViCO FusionHDTV DVB-T PRO [18ac:db30] | 65 | 64 -> DViCO FusionHDTV DVB-T PRO [18ac:db30] |
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx index a98a688c11b8..873630e7e53e 100644 --- a/Documentation/video4linux/CARDLIST.em28xx +++ b/Documentation/video4linux/CARDLIST.em28xx | |||
| @@ -65,3 +65,4 @@ | |||
| 65 | 67 -> Terratec Grabby (em2860) [0ccd:0096] | 65 | 67 -> Terratec Grabby (em2860) [0ccd:0096] |
| 66 | 68 -> Terratec AV350 (em2860) [0ccd:0084] | 66 | 68 -> Terratec AV350 (em2860) [0ccd:0084] |
| 67 | 69 -> KWorld ATSC 315U HDTV TV Box (em2882) [eb1a:a313] | 67 | 69 -> KWorld ATSC 315U HDTV TV Box (em2882) [eb1a:a313] |
| 68 | 70 -> Evga inDtube (em2882) | ||
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index d54c1e4c6a9c..ba4706afc5fb 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt | |||
| @@ -390,6 +390,30 @@ later date. It differs between i2c drivers and as such can be confusing. | |||
| 390 | To see which chip variants are supported you can look in the i2c driver code | 390 | To see which chip variants are supported you can look in the i2c driver code |
| 391 | for the i2c_device_id table. This lists all the possibilities. | 391 | for the i2c_device_id table. This lists all the possibilities. |
| 392 | 392 | ||
| 393 | There are two more helper functions: | ||
| 394 | |||
| 395 | v4l2_i2c_new_subdev_cfg: this function adds new irq and platform_data | ||
| 396 | arguments and has both 'addr' and 'probed_addrs' arguments: if addr is not | ||
| 397 | 0 then that will be used (non-probing variant), otherwise the probed_addrs | ||
| 398 | are probed. | ||
| 399 | |||
| 400 | For example: this will probe for address 0x10: | ||
| 401 | |||
| 402 | struct v4l2_subdev *sd = v4l2_i2c_new_subdev_cfg(v4l2_dev, adapter, | ||
| 403 | "module_foo", "chipid", 0, NULL, 0, I2C_ADDRS(0x10)); | ||
| 404 | |||
| 405 | v4l2_i2c_new_subdev_board uses an i2c_board_info struct which is passed | ||
| 406 | to the i2c driver and replaces the irq, platform_data and addr arguments. | ||
| 407 | |||
| 408 | If the subdev supports the s_config core ops, then that op is called with | ||
| 409 | the irq and platform_data arguments after the subdev was setup. The older | ||
| 410 | v4l2_i2c_new_(probed_)subdev functions will call s_config as well, but with | ||
| 411 | irq set to 0 and platform_data set to NULL. | ||
| 412 | |||
| 413 | Note that in the next kernel release the functions v4l2_i2c_new_subdev, | ||
| 414 | v4l2_i2c_new_probed_subdev and v4l2_i2c_new_probed_subdev_addr will all be | ||
| 415 | replaced by a single v4l2_i2c_new_subdev that is identical to | ||
| 416 | v4l2_i2c_new_subdev_cfg but without the irq and platform_data arguments. | ||
| 393 | 417 | ||
| 394 | struct video_device | 418 | struct video_device |
| 395 | ------------------- | 419 | ------------------- |
diff --git a/Documentation/watchdog/hpwdt.txt b/Documentation/watchdog/hpwdt.txt index 127839e53043..9c24d5ffbb06 100644 --- a/Documentation/watchdog/hpwdt.txt +++ b/Documentation/watchdog/hpwdt.txt | |||
| @@ -19,30 +19,41 @@ Last reviewed: 06/02/2009 | |||
| 19 | not be updated in a timely fashion and a hardware system reset (also known as | 19 | not be updated in a timely fashion and a hardware system reset (also known as |
| 20 | an Automatic Server Recovery (ASR)) event will occur. | 20 | an Automatic Server Recovery (ASR)) event will occur. |
| 21 | 21 | ||
| 22 | The hpwdt driver also has three (3) module parameters. They are the following: | 22 | The hpwdt driver also has four (4) module parameters. They are the following: |
| 23 | 23 | ||
| 24 | soft_margin - allows the user to set the watchdog timer value | 24 | soft_margin - allows the user to set the watchdog timer value |
| 25 | allow_kdump - allows the user to save off a kernel dump image after an NMI | 25 | allow_kdump - allows the user to save off a kernel dump image after an NMI |
| 26 | nowayout - basic watchdog parameter that does not allow the timer to | 26 | nowayout - basic watchdog parameter that does not allow the timer to |
| 27 | be restarted or an impending ASR to be escaped. | 27 | be restarted or an impending ASR to be escaped. |
| 28 | priority - determines whether or not the hpwdt driver is first on the | ||
| 29 | die_notify list to handle NMIs or last. The default value | ||
| 30 | for this module parameter is 0 or LAST. If the user wants to | ||
| 31 | enable NMI sourcing then reload the hpwdt driver with | ||
| 32 | priority=1 (and boot with nmi_watchdog=0). | ||
| 28 | 33 | ||
| 29 | NOTE: More information about watchdog drivers in general, including the ioctl | 34 | NOTE: More information about watchdog drivers in general, including the ioctl |
| 30 | interface to /dev/watchdog can be found in | 35 | interface to /dev/watchdog can be found in |
| 31 | Documentation/watchdog/watchdog-api.txt and Documentation/IPMI.txt. | 36 | Documentation/watchdog/watchdog-api.txt and Documentation/IPMI.txt. |
| 32 | 37 | ||
| 33 | The NMI sourcing capability is disabled when the driver discovers that the | 38 | The priority parameter was introduced due to other kernel software that relied |
| 34 | nmi_watchdog is turned on (nmi_watchdog = 1). This is due to the inability to | 39 | on handling NMIs (like oprofile). Keeping hpwdt's priority at 0 (or LAST) |
| 40 | enables the users of NMIs for non critical events to be work as expected. | ||
| 41 | |||
| 42 | The NMI sourcing capability is disabled by default due to the inability to | ||
| 35 | distinguish between "NMI Watchdog Ticks" and "HW generated NMI events" in the | 43 | distinguish between "NMI Watchdog Ticks" and "HW generated NMI events" in the |
| 36 | Linux kernel. What this means is that the hpwdt nmi handler code is called | 44 | Linux kernel. What this means is that the hpwdt nmi handler code is called |
| 37 | each time the NMI signal fires off. This could amount to several thousands of | 45 | each time the NMI signal fires off. This could amount to several thousands of |
| 38 | NMIs in a matter of seconds. If a user sees the Linux kernel's "dazed and | 46 | NMIs in a matter of seconds. If a user sees the Linux kernel's "dazed and |
| 39 | confused" message in the logs or if the system gets into a hung state, then | 47 | confused" message in the logs or if the system gets into a hung state, then |
| 40 | the user should reboot with nmi_watchdog=0. | 48 | the hpwdt driver can be reloaded with the "priority" module parameter set |
| 49 | (priority=1). | ||
| 41 | 50 | ||
| 42 | 1. If the kernel has not been booted with nmi_watchdog turned off then | 51 | 1. If the kernel has not been booted with nmi_watchdog turned off then |
| 43 | edit /boot/grub/menu.lst and place the nmi_watchdog=0 at the end of the | 52 | edit /boot/grub/menu.lst and place the nmi_watchdog=0 at the end of the |
| 44 | currently booting kernel line. | 53 | currently booting kernel line. |
| 45 | 2. reboot the sever | 54 | 2. reboot the sever |
| 55 | 3. Once the system comes up perform a rmmod hpwdt | ||
| 56 | 4. insmod /lib/modules/`uname -r`/kernel/drivers/char/watchdog/hpwdt.ko priority=1 | ||
| 46 | 57 | ||
| 47 | Now, the hpwdt can successfully receive and source the NMI and provide a log | 58 | Now, the hpwdt can successfully receive and source the NMI and provide a log |
| 48 | message that details the reason for the NMI (as determined by the HP BIOS). | 59 | message that details the reason for the NMI (as determined by the HP BIOS). |
diff --git a/MAINTAINERS b/MAINTAINERS index 02f6f78b561f..303129ab4b75 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -2482,6 +2482,14 @@ F: drivers/net/wan/pc300too.c | |||
| 2482 | F: drivers/net/wan/pci200syn.c | 2482 | F: drivers/net/wan/pci200syn.c |
| 2483 | F: drivers/net/wan/wanxl* | 2483 | F: drivers/net/wan/wanxl* |
| 2484 | 2484 | ||
| 2485 | GENERIC INCLUDE/ASM HEADER FILES | ||
| 2486 | P: Arnd Bergmann | ||
| 2487 | M: arnd@arndb.de | ||
| 2488 | L: linux-arch@vger.kernel.org | ||
| 2489 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git | ||
| 2490 | S: Maintained | ||
| 2491 | F: include/asm-generic | ||
| 2492 | |||
| 2485 | GFS2 FILE SYSTEM | 2493 | GFS2 FILE SYSTEM |
| 2486 | P: Steven Whitehouse | 2494 | P: Steven Whitehouse |
| 2487 | M: swhiteho@redhat.com | 2495 | M: swhiteho@redhat.com |
| @@ -2824,10 +2832,10 @@ S: Supported | |||
| 2824 | F: drivers/scsi/ips.* | 2832 | F: drivers/scsi/ips.* |
| 2825 | 2833 | ||
| 2826 | IDE SUBSYSTEM | 2834 | IDE SUBSYSTEM |
| 2827 | P: Bartlomiej Zolnierkiewicz | 2835 | P: David S. Miller |
| 2828 | M: bzolnier@gmail.com | 2836 | M: davem@davemloft.net |
| 2829 | L: linux-ide@vger.kernel.org | 2837 | L: linux-ide@vger.kernel.org |
| 2830 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6.git | 2838 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide-2.6.git |
| 2831 | S: Maintained | 2839 | S: Maintained |
| 2832 | F: Documentation/ide/ | 2840 | F: Documentation/ide/ |
| 2833 | F: drivers/ide/ | 2841 | F: drivers/ide/ |
diff --git a/arch/cris/arch-v10/kernel/dma.c b/arch/cris/arch-v10/kernel/dma.c index 929e68666299..d31504b4a19e 100644 --- a/arch/cris/arch-v10/kernel/dma.c +++ b/arch/cris/arch-v10/kernel/dma.c | |||
| @@ -24,7 +24,7 @@ int cris_request_dma(unsigned int dmanr, const char * device_id, | |||
| 24 | unsigned long int gens; | 24 | unsigned long int gens; |
| 25 | int fail = -EINVAL; | 25 | int fail = -EINVAL; |
| 26 | 26 | ||
| 27 | if ((dmanr < 0) || (dmanr >= MAX_DMA_CHANNELS)) { | 27 | if (dmanr >= MAX_DMA_CHANNELS) { |
| 28 | printk(KERN_CRIT "cris_request_dma: invalid DMA channel %u\n", dmanr); | 28 | printk(KERN_CRIT "cris_request_dma: invalid DMA channel %u\n", dmanr); |
| 29 | return -EINVAL; | 29 | return -EINVAL; |
| 30 | } | 30 | } |
| @@ -213,7 +213,7 @@ int cris_request_dma(unsigned int dmanr, const char * device_id, | |||
| 213 | void cris_free_dma(unsigned int dmanr, const char * device_id) | 213 | void cris_free_dma(unsigned int dmanr, const char * device_id) |
| 214 | { | 214 | { |
| 215 | unsigned long flags; | 215 | unsigned long flags; |
| 216 | if ((dmanr < 0) || (dmanr >= MAX_DMA_CHANNELS)) { | 216 | if (dmanr >= MAX_DMA_CHANNELS) { |
| 217 | printk(KERN_CRIT "cris_free_dma: invalid DMA channel %u\n", dmanr); | 217 | printk(KERN_CRIT "cris_free_dma: invalid DMA channel %u\n", dmanr); |
| 218 | return; | 218 | return; |
| 219 | } | 219 | } |
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c index 67c61ea86813..fd529a0ec758 100644 --- a/arch/cris/arch-v32/drivers/cryptocop.c +++ b/arch/cris/arch-v32/drivers/cryptocop.c | |||
| @@ -1395,7 +1395,7 @@ static int create_md5_pad(int alloc_flag, unsigned long long hashed_length, char | |||
| 1395 | if (padlen < MD5_MIN_PAD_LENGTH) padlen += MD5_BLOCK_LENGTH; | 1395 | if (padlen < MD5_MIN_PAD_LENGTH) padlen += MD5_BLOCK_LENGTH; |
| 1396 | 1396 | ||
| 1397 | p = kmalloc(padlen, alloc_flag); | 1397 | p = kmalloc(padlen, alloc_flag); |
| 1398 | if (!pad) return -ENOMEM; | 1398 | if (!p) return -ENOMEM; |
| 1399 | 1399 | ||
| 1400 | *p = 0x80; | 1400 | *p = 0x80; |
| 1401 | memset(p+1, 0, padlen - 1); | 1401 | memset(p+1, 0, padlen - 1); |
| @@ -1427,7 +1427,7 @@ static int create_sha1_pad(int alloc_flag, unsigned long long hashed_length, cha | |||
| 1427 | if (padlen < SHA1_MIN_PAD_LENGTH) padlen += SHA1_BLOCK_LENGTH; | 1427 | if (padlen < SHA1_MIN_PAD_LENGTH) padlen += SHA1_BLOCK_LENGTH; |
| 1428 | 1428 | ||
| 1429 | p = kmalloc(padlen, alloc_flag); | 1429 | p = kmalloc(padlen, alloc_flag); |
| 1430 | if (!pad) return -ENOMEM; | 1430 | if (!p) return -ENOMEM; |
| 1431 | 1431 | ||
| 1432 | *p = 0x80; | 1432 | *p = 0x80; |
| 1433 | memset(p+1, 0, padlen - 1); | 1433 | memset(p+1, 0, padlen - 1); |
diff --git a/arch/cris/arch-v32/kernel/irq.c b/arch/cris/arch-v32/kernel/irq.c index d70b445f4a8f..57668db25031 100644 --- a/arch/cris/arch-v32/kernel/irq.c +++ b/arch/cris/arch-v32/kernel/irq.c | |||
| @@ -430,8 +430,8 @@ crisv32_do_multiple(struct pt_regs* regs) | |||
| 430 | masked[i] &= ~TIMER_MASK; | 430 | masked[i] &= ~TIMER_MASK; |
| 431 | do_IRQ(TIMER0_INTR_VECT, regs); | 431 | do_IRQ(TIMER0_INTR_VECT, regs); |
| 432 | } | 432 | } |
| 433 | } | ||
| 434 | #endif | 433 | #endif |
| 434 | } | ||
| 435 | 435 | ||
| 436 | #ifdef IGNORE_MASK | 436 | #ifdef IGNORE_MASK |
| 437 | /* Remove IRQs that can't be handled as multiple. */ | 437 | /* Remove IRQs that can't be handled as multiple. */ |
diff --git a/arch/cris/arch-v32/lib/Makefile b/arch/cris/arch-v32/lib/Makefile index eb4aad1f1158..dd296b9db034 100644 --- a/arch/cris/arch-v32/lib/Makefile +++ b/arch/cris/arch-v32/lib/Makefile | |||
| @@ -3,5 +3,5 @@ | |||
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | lib-y = checksum.o checksumcopy.o string.o usercopy.o memset.o \ | 5 | lib-y = checksum.o checksumcopy.o string.o usercopy.o memset.o \ |
| 6 | csumcpfruser.o spinlock.o delay.o | 6 | csumcpfruser.o spinlock.o delay.o strcmp.o |
| 7 | 7 | ||
diff --git a/arch/cris/arch-v32/lib/strcmp.S b/arch/cris/arch-v32/lib/strcmp.S new file mode 100644 index 000000000000..8f7a1ee62591 --- /dev/null +++ b/arch/cris/arch-v32/lib/strcmp.S | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | ; strcmp.S -- CRISv32 version. | ||
| 2 | ; Copyright (C) 2008 AXIS Communications AB | ||
| 3 | ; Written by Edgar E. Iglesias | ||
| 4 | ; | ||
| 5 | ; This source code is licensed under the GNU General Public License, | ||
| 6 | ; Version 2. See the file COPYING for more details. | ||
| 7 | |||
| 8 | .global strcmp | ||
| 9 | .type strcmp,@function | ||
| 10 | strcmp: | ||
| 11 | 1: | ||
| 12 | move.b [$r10+], $r12 | ||
| 13 | seq $r13 | ||
| 14 | sub.b [$r11+], $r12 | ||
| 15 | or.b $r12, $r13 | ||
| 16 | beq 1b | ||
| 17 | nop | ||
| 18 | |||
| 19 | ret | ||
| 20 | movs.b $r12, $r10 | ||
| 21 | .size strcmp, . - strcmp | ||
diff --git a/arch/cris/include/arch-v32/arch/spinlock.h b/arch/cris/include/arch-v32/arch/spinlock.h index 129756b96661..367a53ea10c5 100644 --- a/arch/cris/include/arch-v32/arch/spinlock.h +++ b/arch/cris/include/arch-v32/arch/spinlock.h | |||
| @@ -78,7 +78,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw) | |||
| 78 | { | 78 | { |
| 79 | __raw_spin_lock(&rw->slock); | 79 | __raw_spin_lock(&rw->slock); |
| 80 | while (rw->lock != RW_LOCK_BIAS); | 80 | while (rw->lock != RW_LOCK_BIAS); |
| 81 | rw->lock == 0; | 81 | rw->lock = 0; |
| 82 | __raw_spin_unlock(&rw->slock); | 82 | __raw_spin_unlock(&rw->slock); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| @@ -93,7 +93,7 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw) | |||
| 93 | { | 93 | { |
| 94 | __raw_spin_lock(&rw->slock); | 94 | __raw_spin_lock(&rw->slock); |
| 95 | while (rw->lock != RW_LOCK_BIAS); | 95 | while (rw->lock != RW_LOCK_BIAS); |
| 96 | rw->lock == RW_LOCK_BIAS; | 96 | rw->lock = RW_LOCK_BIAS; |
| 97 | __raw_spin_unlock(&rw->slock); | 97 | __raw_spin_unlock(&rw->slock); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| @@ -114,7 +114,7 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw) | |||
| 114 | int ret = 0; | 114 | int ret = 0; |
| 115 | __raw_spin_lock(&rw->slock); | 115 | __raw_spin_lock(&rw->slock); |
| 116 | if (rw->lock == RW_LOCK_BIAS) { | 116 | if (rw->lock == RW_LOCK_BIAS) { |
| 117 | rw->lock == 0; | 117 | rw->lock = 0; |
| 118 | ret = 1; | 118 | ret = 1; |
| 119 | } | 119 | } |
| 120 | __raw_spin_unlock(&rw->slock); | 120 | __raw_spin_unlock(&rw->slock); |
diff --git a/arch/cris/include/asm/string.h b/arch/cris/include/asm/string.h index 691190e99a27..d5db39f9eea1 100644 --- a/arch/cris/include/asm/string.h +++ b/arch/cris/include/asm/string.h | |||
| @@ -11,4 +11,10 @@ extern void *memcpy(void *, const void *, size_t); | |||
| 11 | #define __HAVE_ARCH_MEMSET | 11 | #define __HAVE_ARCH_MEMSET |
| 12 | extern void *memset(void *, int, size_t); | 12 | extern void *memset(void *, int, size_t); |
| 13 | 13 | ||
| 14 | #ifdef CONFIG_ETRAX_ARCH_V32 | ||
| 15 | /* For v32 we provide strcmp. */ | ||
| 16 | #define __HAVE_ARCH_STRCMP | ||
| 17 | extern int strcmp(const char *s1, const char *s2); | ||
| 18 | #endif | ||
| 19 | |||
| 14 | #endif | 20 | #endif |
diff --git a/arch/h8300/Kconfig.cpu b/arch/h8300/Kconfig.cpu index b65dcfe51d9c..6e2ecff199c5 100644 --- a/arch/h8300/Kconfig.cpu +++ b/arch/h8300/Kconfig.cpu | |||
| @@ -13,7 +13,7 @@ config H8300H_GENERIC | |||
| 13 | 13 | ||
| 14 | config H8300H_AKI3068NET | 14 | config H8300H_AKI3068NET |
| 15 | bool "AE-3068/69" | 15 | bool "AE-3068/69" |
| 16 | select CONFIG_H83068 | 16 | select H83068 |
| 17 | help | 17 | help |
| 18 | AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support | 18 | AKI-H8/3068F / AKI-H8/3069F Flashmicom LAN Board Support |
| 19 | More Information. (Japanese Only) | 19 | More Information. (Japanese Only) |
| @@ -24,7 +24,7 @@ config H8300H_AKI3068NET | |||
| 24 | 24 | ||
| 25 | config H8300H_H8MAX | 25 | config H8300H_H8MAX |
| 26 | bool "H8MAX" | 26 | bool "H8MAX" |
| 27 | select CONFIG_H83068 | 27 | select H83068 |
| 28 | help | 28 | help |
| 29 | H8MAX Evaluation Board Support | 29 | H8MAX Evaluation Board Support |
| 30 | More Information. (Japanese Only) | 30 | More Information. (Japanese Only) |
| @@ -32,7 +32,7 @@ config H8300H_H8MAX | |||
| 32 | 32 | ||
| 33 | config H8300H_SIM | 33 | config H8300H_SIM |
| 34 | bool "H8/300H Simulator" | 34 | bool "H8/300H Simulator" |
| 35 | select CONFIG_H83007 | 35 | select H83007 |
| 36 | help | 36 | help |
| 37 | GDB Simulator Support | 37 | GDB Simulator Support |
| 38 | More Information. | 38 | More Information. |
| @@ -45,7 +45,7 @@ config H8S_GENERIC | |||
| 45 | 45 | ||
| 46 | config H8S_EDOSK2674 | 46 | config H8S_EDOSK2674 |
| 47 | bool "EDOSK-2674" | 47 | bool "EDOSK-2674" |
| 48 | select CONFIG_H8S2768 | 48 | select H8S2678 |
| 49 | help | 49 | help |
| 50 | Renesas EDOSK-2674 Evaluation Board Support | 50 | Renesas EDOSK-2674 Evaluation Board Support |
| 51 | More Information. | 51 | More Information. |
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ac1c620d1c7d..e2bdd7b94fd9 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig | |||
| @@ -15,7 +15,7 @@ config SUPERH | |||
| 15 | select HAVE_IOREMAP_PROT if MMU | 15 | select HAVE_IOREMAP_PROT if MMU |
| 16 | select HAVE_ARCH_TRACEHOOK | 16 | select HAVE_ARCH_TRACEHOOK |
| 17 | select HAVE_DMA_API_DEBUG | 17 | select HAVE_DMA_API_DEBUG |
| 18 | select HAVE_PERF_COUNTER | 18 | select HAVE_PERF_COUNTERS |
| 19 | select RTC_LIB | 19 | select RTC_LIB |
| 20 | select GENERIC_ATOMIC64 | 20 | select GENERIC_ATOMIC64 |
| 21 | help | 21 | help |
| @@ -71,6 +71,9 @@ config GENERIC_HARDIRQS_NO__DO_IRQ | |||
| 71 | config GENERIC_IRQ_PROBE | 71 | config GENERIC_IRQ_PROBE |
| 72 | def_bool y | 72 | def_bool y |
| 73 | 73 | ||
| 74 | config IRQ_PER_CPU | ||
| 75 | def_bool y | ||
| 76 | |||
| 74 | config GENERIC_GPIO | 77 | config GENERIC_GPIO |
| 75 | def_bool n | 78 | def_bool n |
| 76 | 79 | ||
| @@ -151,6 +154,9 @@ config ARCH_NO_VIRT_TO_BUS | |||
| 151 | config ARCH_HAS_DEFAULT_IDLE | 154 | config ARCH_HAS_DEFAULT_IDLE |
| 152 | def_bool y | 155 | def_bool y |
| 153 | 156 | ||
| 157 | config ARCH_HAS_CPU_IDLE_WAIT | ||
| 158 | def_bool y | ||
| 159 | |||
| 154 | config IO_TRAPPED | 160 | config IO_TRAPPED |
| 155 | bool | 161 | bool |
| 156 | 162 | ||
| @@ -411,6 +417,8 @@ config CPU_SUBTYPE_SH7786 | |||
| 411 | select CPU_HAS_PTEAEX | 417 | select CPU_HAS_PTEAEX |
| 412 | select ARCH_SPARSEMEM_ENABLE | 418 | select ARCH_SPARSEMEM_ENABLE |
| 413 | select SYS_SUPPORTS_NUMA | 419 | select SYS_SUPPORTS_NUMA |
| 420 | select SYS_SUPPORTS_SMP | ||
| 421 | select GENERIC_CLOCKEVENTS_BROADCAST if SMP | ||
| 414 | 422 | ||
| 415 | config CPU_SUBTYPE_SHX3 | 423 | config CPU_SUBTYPE_SHX3 |
| 416 | bool "Support SH-X3 processor" | 424 | bool "Support SH-X3 processor" |
| @@ -648,7 +656,7 @@ config NR_CPUS | |||
| 648 | int "Maximum number of CPUs (2-32)" | 656 | int "Maximum number of CPUs (2-32)" |
| 649 | range 2 32 | 657 | range 2 32 |
| 650 | depends on SMP | 658 | depends on SMP |
| 651 | default "4" if CPU_SHX3 | 659 | default "4" if CPU_SUBTYPE_SHX3 |
| 652 | default "2" | 660 | default "2" |
| 653 | help | 661 | help |
| 654 | This allows you to specify the maximum number of CPUs which this | 662 | This allows you to specify the maximum number of CPUs which this |
diff --git a/arch/sh/include/asm/dma-mapping.h b/arch/sh/include/asm/dma-mapping.h index ea9d4f41c9d2..69d56dd4c968 100644 --- a/arch/sh/include/asm/dma-mapping.h +++ b/arch/sh/include/asm/dma-mapping.h | |||
| @@ -97,7 +97,7 @@ static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address, | |||
| 97 | dma_unmap_single(dev, dma_address, size, dir); | 97 | dma_unmap_single(dev, dma_address, size, dir); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | static inline void dma_sync_single(struct device *dev, dma_addr_t dma_handle, | 100 | static inline void __dma_sync_single(struct device *dev, dma_addr_t dma_handle, |
| 101 | size_t size, enum dma_data_direction dir) | 101 | size_t size, enum dma_data_direction dir) |
| 102 | { | 102 | { |
| 103 | #if defined(CONFIG_PCI) && !defined(CONFIG_SH_PCIDMA_NONCOHERENT) | 103 | #if defined(CONFIG_PCI) && !defined(CONFIG_SH_PCIDMA_NONCOHERENT) |
| @@ -119,7 +119,7 @@ static inline void dma_sync_single_range(struct device *dev, | |||
| 119 | dma_cache_sync(dev, phys_to_virt(dma_handle) + offset, size, dir); | 119 | dma_cache_sync(dev, phys_to_virt(dma_handle) + offset, size, dir); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | static inline void dma_sync_sg(struct device *dev, struct scatterlist *sg, | 122 | static inline void __dma_sync_sg(struct device *dev, struct scatterlist *sg, |
| 123 | int nelems, enum dma_data_direction dir) | 123 | int nelems, enum dma_data_direction dir) |
| 124 | { | 124 | { |
| 125 | int i; | 125 | int i; |
| @@ -137,7 +137,7 @@ static inline void dma_sync_single_for_cpu(struct device *dev, | |||
| 137 | dma_addr_t dma_handle, size_t size, | 137 | dma_addr_t dma_handle, size_t size, |
| 138 | enum dma_data_direction dir) | 138 | enum dma_data_direction dir) |
| 139 | { | 139 | { |
| 140 | dma_sync_single(dev, dma_handle, size, dir); | 140 | __dma_sync_single(dev, dma_handle, size, dir); |
| 141 | debug_dma_sync_single_for_cpu(dev, dma_handle, size, dir); | 141 | debug_dma_sync_single_for_cpu(dev, dma_handle, size, dir); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| @@ -146,7 +146,7 @@ static inline void dma_sync_single_for_device(struct device *dev, | |||
| 146 | size_t size, | 146 | size_t size, |
| 147 | enum dma_data_direction dir) | 147 | enum dma_data_direction dir) |
| 148 | { | 148 | { |
| 149 | dma_sync_single(dev, dma_handle, size, dir); | 149 | __dma_sync_single(dev, dma_handle, size, dir); |
| 150 | debug_dma_sync_single_for_device(dev, dma_handle, size, dir); | 150 | debug_dma_sync_single_for_device(dev, dma_handle, size, dir); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| @@ -177,7 +177,7 @@ static inline void dma_sync_sg_for_cpu(struct device *dev, | |||
| 177 | struct scatterlist *sg, int nelems, | 177 | struct scatterlist *sg, int nelems, |
| 178 | enum dma_data_direction dir) | 178 | enum dma_data_direction dir) |
| 179 | { | 179 | { |
| 180 | dma_sync_sg(dev, sg, nelems, dir); | 180 | __dma_sync_sg(dev, sg, nelems, dir); |
| 181 | debug_dma_sync_sg_for_cpu(dev, sg, nelems, dir); | 181 | debug_dma_sync_sg_for_cpu(dev, sg, nelems, dir); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| @@ -185,7 +185,7 @@ static inline void dma_sync_sg_for_device(struct device *dev, | |||
| 185 | struct scatterlist *sg, int nelems, | 185 | struct scatterlist *sg, int nelems, |
| 186 | enum dma_data_direction dir) | 186 | enum dma_data_direction dir) |
| 187 | { | 187 | { |
| 188 | dma_sync_sg(dev, sg, nelems, dir); | 188 | __dma_sync_sg(dev, sg, nelems, dir); |
| 189 | debug_dma_sync_sg_for_device(dev, sg, nelems, dir); | 189 | debug_dma_sync_sg_for_device(dev, sg, nelems, dir); |
| 190 | } | 190 | } |
| 191 | 191 | ||
diff --git a/arch/sh/include/asm/system.h b/arch/sh/include/asm/system.h index a88895e6dcb0..ab79e1f4fbe0 100644 --- a/arch/sh/include/asm/system.h +++ b/arch/sh/include/asm/system.h | |||
| @@ -154,6 +154,7 @@ extern struct dentry *sh_debugfs_root; | |||
| 154 | 154 | ||
| 155 | void per_cpu_trap_init(void); | 155 | void per_cpu_trap_init(void); |
| 156 | void default_idle(void); | 156 | void default_idle(void); |
| 157 | void cpu_idle_wait(void); | ||
| 157 | 158 | ||
| 158 | asmlinkage void break_point_trap(void); | 159 | asmlinkage void break_point_trap(void); |
| 159 | 160 | ||
diff --git a/arch/sh/kernel/cpu/sh4a/Makefile b/arch/sh/kernel/cpu/sh4a/Makefile index 96ea09ca8cc1..ebdd391d5f42 100644 --- a/arch/sh/kernel/cpu/sh4a/Makefile +++ b/arch/sh/kernel/cpu/sh4a/Makefile | |||
| @@ -16,7 +16,7 @@ obj-$(CONFIG_CPU_SUBTYPE_SH7366) += setup-sh7366.o | |||
| 16 | obj-$(CONFIG_CPU_SUBTYPE_SHX3) += setup-shx3.o | 16 | obj-$(CONFIG_CPU_SUBTYPE_SHX3) += setup-shx3.o |
| 17 | 17 | ||
| 18 | # SMP setup | 18 | # SMP setup |
| 19 | smp-$(CONFIG_CPU_SUBTYPE_SHX3) := smp-shx3.o | 19 | smp-$(CONFIG_CPU_SHX3) := smp-shx3.o |
| 20 | 20 | ||
| 21 | # Primary on-chip clocks (common) | 21 | # Primary on-chip clocks (common) |
| 22 | clock-$(CONFIG_CPU_SUBTYPE_SH7763) := clock-sh7763.o | 22 | clock-$(CONFIG_CPU_SUBTYPE_SH7763) := clock-sh7763.o |
| @@ -38,6 +38,6 @@ pinmux-$(CONFIG_CPU_SUBTYPE_SH7724) := pinmux-sh7724.o | |||
| 38 | pinmux-$(CONFIG_CPU_SUBTYPE_SH7785) := pinmux-sh7785.o | 38 | pinmux-$(CONFIG_CPU_SUBTYPE_SH7785) := pinmux-sh7785.o |
| 39 | pinmux-$(CONFIG_CPU_SUBTYPE_SH7786) := pinmux-sh7786.o | 39 | pinmux-$(CONFIG_CPU_SUBTYPE_SH7786) := pinmux-sh7786.o |
| 40 | 40 | ||
| 41 | obj-y += $(clock-y) | 41 | obj-y += $(clock-y) |
| 42 | obj-$(CONFIG_SMP) += $(smp-y) | 42 | obj-$(CONFIG_SMP) += $(smp-y) |
| 43 | obj-$(CONFIG_GENERIC_GPIO) += $(pinmux-y) | 43 | obj-$(CONFIG_GENERIC_GPIO) += $(pinmux-y) |
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c index 93e0d2c017e8..b70049470a0b 100644 --- a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c +++ b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c | |||
| @@ -595,9 +595,8 @@ enum { | |||
| 595 | HSPI, | 595 | HSPI, |
| 596 | GPIO0, GPIO1, | 596 | GPIO0, GPIO1, |
| 597 | Thermal, | 597 | Thermal, |
| 598 | INTC0, INTC1, INTC2, INTC3, INTC4, INTC5, INTC6, INTC7, | 598 | INTICI0, INTICI1, INTICI2, INTICI3, |
| 599 | 599 | INTICI4, INTICI5, INTICI6, INTICI7, | |
| 600 | /* interrupt groups */ | ||
| 601 | }; | 600 | }; |
| 602 | 601 | ||
| 603 | static struct intc_vect vectors[] __initdata = { | 602 | static struct intc_vect vectors[] __initdata = { |
| @@ -638,10 +637,12 @@ static struct intc_vect vectors[] __initdata = { | |||
| 638 | INTC_VECT(HSPI, 0xe80), | 637 | INTC_VECT(HSPI, 0xe80), |
| 639 | INTC_VECT(GPIO0, 0xea0), INTC_VECT(GPIO1, 0xec0), | 638 | INTC_VECT(GPIO0, 0xea0), INTC_VECT(GPIO1, 0xec0), |
| 640 | INTC_VECT(Thermal, 0xee0), | 639 | INTC_VECT(Thermal, 0xee0), |
| 640 | INTC_VECT(INTICI0, 0xf00), INTC_VECT(INTICI1, 0xf20), | ||
| 641 | INTC_VECT(INTICI2, 0xf40), INTC_VECT(INTICI3, 0xf60), | ||
| 642 | INTC_VECT(INTICI4, 0xf80), INTC_VECT(INTICI5, 0xfa0), | ||
| 643 | INTC_VECT(INTICI6, 0xfc0), INTC_VECT(INTICI7, 0xfe0), | ||
| 641 | }; | 644 | }; |
| 642 | 645 | ||
| 643 | /* FIXME: Main CPU support only now */ | ||
| 644 | #if 1 /* Main CPU */ | ||
| 645 | #define CnINTMSK0 0xfe410030 | 646 | #define CnINTMSK0 0xfe410030 |
| 646 | #define CnINTMSK1 0xfe410040 | 647 | #define CnINTMSK1 0xfe410040 |
| 647 | #define CnINTMSKCLR0 0xfe410050 | 648 | #define CnINTMSKCLR0 0xfe410050 |
| @@ -654,21 +655,6 @@ static struct intc_vect vectors[] __initdata = { | |||
| 654 | #define CnINT2MSKCR1 0xfe410a34 | 655 | #define CnINT2MSKCR1 0xfe410a34 |
| 655 | #define CnINT2MSKCR2 0xfe410a38 | 656 | #define CnINT2MSKCR2 0xfe410a38 |
| 656 | #define CnINT2MSKCR3 0xfe410a3c | 657 | #define CnINT2MSKCR3 0xfe410a3c |
| 657 | #else /* Sub CPU */ | ||
| 658 | #define CnINTMSK0 0xfe410034 | ||
| 659 | #define CnINTMSK1 0xfe410044 | ||
| 660 | #define CnINTMSKCLR0 0xfe410054 | ||
| 661 | #define CnINTMSKCLR1 0xfe410064 | ||
| 662 | #define CnINT2MSKR0 0xfe410b20 | ||
| 663 | #define CnINT2MSKR1 0xfe410b24 | ||
| 664 | #define CnINT2MSKR2 0xfe410b28 | ||
| 665 | #define CnINT2MSKR3 0xfe410b2c | ||
| 666 | #define CnINT2MSKCR0 0xfe410b30 | ||
| 667 | #define CnINT2MSKCR1 0xfe410b34 | ||
| 668 | #define CnINT2MSKCR2 0xfe410b38 | ||
| 669 | #define CnINT2MSKCR3 0xfe410b3c | ||
| 670 | #endif | ||
| 671 | |||
| 672 | #define INTMSK2 0xfe410068 | 658 | #define INTMSK2 0xfe410068 |
| 673 | #define INTMSKCLR2 0xfe41006c | 659 | #define INTMSKCLR2 0xfe41006c |
| 674 | 660 | ||
| @@ -753,6 +739,9 @@ static struct intc_prio_reg prio_registers[] __initdata = { | |||
| 753 | GPIO1, Thermal } }, | 739 | GPIO1, Thermal } }, |
| 754 | { 0xfe41085c, 0, 32, 8, /* INT2PRI23 */ { 0, 0, 0, 0 } }, | 740 | { 0xfe41085c, 0, 32, 8, /* INT2PRI23 */ { 0, 0, 0, 0 } }, |
| 755 | { 0xfe410860, 0, 32, 8, /* INT2PRI24 */ { 0, 0, 0, 0 } }, | 741 | { 0xfe410860, 0, 32, 8, /* INT2PRI24 */ { 0, 0, 0, 0 } }, |
| 742 | { 0xfe410090, 0xfe4100a0, 32, 4, /* CnICIPRI / CnICIPRICLR */ | ||
| 743 | { INTICI7, INTICI6, INTICI5, INTICI4, | ||
| 744 | INTICI3, INTICI2, INTICI1, INTICI0 }, INTC_SMP(4, 2) }, | ||
| 756 | }; | 745 | }; |
| 757 | 746 | ||
| 758 | static DECLARE_INTC_DESC(intc_desc, "sh7786", vectors, NULL, | 747 | static DECLARE_INTC_DESC(intc_desc, "sh7786", vectors, NULL, |
diff --git a/arch/sh/kernel/idle.c b/arch/sh/kernel/idle.c index f35ed0348850..27ff2dc093c7 100644 --- a/arch/sh/kernel/idle.c +++ b/arch/sh/kernel/idle.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * The idle loop for all SuperH platforms. | 2 | * The idle loop for all SuperH platforms. |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2002 - 2008 Paul Mundt | 4 | * Copyright (C) 2002 - 2009 Paul Mundt |
| 5 | * | 5 | * |
| 6 | * This file is subject to the terms and conditions of the GNU General Public | 6 | * This file is subject to the terms and conditions of the GNU General Public |
| 7 | * License. See the file "COPYING" in the main directory of this archive | 7 | * License. See the file "COPYING" in the main directory of this archive |
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/preempt.h> | 15 | #include <linux/preempt.h> |
| 16 | #include <linux/thread_info.h> | 16 | #include <linux/thread_info.h> |
| 17 | #include <linux/irqflags.h> | 17 | #include <linux/irqflags.h> |
| 18 | #include <linux/smp.h> | ||
| 18 | #include <asm/pgalloc.h> | 19 | #include <asm/pgalloc.h> |
| 19 | #include <asm/system.h> | 20 | #include <asm/system.h> |
| 20 | #include <asm/atomic.h> | 21 | #include <asm/atomic.h> |
| @@ -79,3 +80,23 @@ void cpu_idle(void) | |||
| 79 | check_pgt_cache(); | 80 | check_pgt_cache(); |
| 80 | } | 81 | } |
| 81 | } | 82 | } |
| 83 | |||
| 84 | static void do_nothing(void *unused) | ||
| 85 | { | ||
| 86 | } | ||
| 87 | |||
| 88 | /* | ||
| 89 | * cpu_idle_wait - Used to ensure that all the CPUs discard old value of | ||
| 90 | * pm_idle and update to new pm_idle value. Required while changing pm_idle | ||
| 91 | * handler on SMP systems. | ||
| 92 | * | ||
| 93 | * Caller must have changed pm_idle to the new value before the call. Old | ||
| 94 | * pm_idle value will not be used by any CPU after the return of this function. | ||
| 95 | */ | ||
| 96 | void cpu_idle_wait(void) | ||
| 97 | { | ||
| 98 | smp_mb(); | ||
| 99 | /* kick all the CPUs so that they exit out of pm_idle */ | ||
| 100 | smp_call_function(do_nothing, NULL, 1); | ||
| 101 | } | ||
| 102 | EXPORT_SYMBOL_GPL(cpu_idle_wait); | ||
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index ee8e6bbe882c..fe532aeaa16d 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c | |||
| @@ -70,7 +70,7 @@ static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot) | |||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, prot)); | 72 | set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, prot)); |
| 73 | flush_tlb_one(get_asid(), addr); | 73 | local_flush_tlb_one(get_asid(), addr); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | /* | 76 | /* |
| @@ -177,10 +177,8 @@ void __init paging_init(void) | |||
| 177 | 177 | ||
| 178 | free_area_init_nodes(max_zone_pfns); | 178 | free_area_init_nodes(max_zone_pfns); |
| 179 | 179 | ||
| 180 | #ifdef CONFIG_SUPERH32 | ||
| 181 | /* Set up the uncached fixmap */ | 180 | /* Set up the uncached fixmap */ |
| 182 | set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start)); | 181 | set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start)); |
| 183 | #endif | ||
| 184 | } | 182 | } |
| 185 | 183 | ||
| 186 | static struct kcore_list kcore_mem, kcore_vmalloc; | 184 | static struct kcore_list kcore_mem, kcore_vmalloc; |
diff --git a/block/bsg.c b/block/bsg.c index 54106f052f70..e7d475254248 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
| @@ -315,7 +315,6 @@ out: | |||
| 315 | blk_put_request(rq); | 315 | blk_put_request(rq); |
| 316 | if (next_rq) { | 316 | if (next_rq) { |
| 317 | blk_rq_unmap_user(next_rq->bio); | 317 | blk_rq_unmap_user(next_rq->bio); |
| 318 | next_rq->bio = NULL; | ||
| 319 | blk_put_request(next_rq); | 318 | blk_put_request(next_rq); |
| 320 | } | 319 | } |
| 321 | return ERR_PTR(ret); | 320 | return ERR_PTR(ret); |
| @@ -449,7 +448,6 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr, | |||
| 449 | hdr->dout_resid = rq->resid_len; | 448 | hdr->dout_resid = rq->resid_len; |
| 450 | hdr->din_resid = rq->next_rq->resid_len; | 449 | hdr->din_resid = rq->next_rq->resid_len; |
| 451 | blk_rq_unmap_user(bidi_bio); | 450 | blk_rq_unmap_user(bidi_bio); |
| 452 | rq->next_rq->bio = NULL; | ||
| 453 | blk_put_request(rq->next_rq); | 451 | blk_put_request(rq->next_rq); |
| 454 | } else if (rq_data_dir(rq) == READ) | 452 | } else if (rq_data_dir(rq) == READ) |
| 455 | hdr->din_resid = rq->resid_len; | 453 | hdr->din_resid = rq->resid_len; |
| @@ -468,7 +466,6 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr, | |||
| 468 | blk_rq_unmap_user(bio); | 466 | blk_rq_unmap_user(bio); |
| 469 | if (rq->cmd != rq->__cmd) | 467 | if (rq->cmd != rq->__cmd) |
| 470 | kfree(rq->cmd); | 468 | kfree(rq->cmd); |
| 471 | rq->bio = NULL; | ||
| 472 | blk_put_request(rq); | 469 | blk_put_request(rq); |
| 473 | 470 | ||
| 474 | return ret; | 471 | return ret; |
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 2aa1908e5ce0..b17c57f85032 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
| @@ -679,6 +679,14 @@ config PATA_PLATFORM | |||
| 679 | 679 | ||
| 680 | If unsure, say N. | 680 | If unsure, say N. |
| 681 | 681 | ||
| 682 | config PATA_AT91 | ||
| 683 | tristate "PATA support for AT91SAM9260" | ||
| 684 | depends on ARM && ARCH_AT91 | ||
| 685 | help | ||
| 686 | This option enables support for IDE devices on the Atmel AT91SAM9260 SoC. | ||
| 687 | |||
| 688 | If unsure, say N. | ||
| 689 | |||
| 682 | config PATA_OF_PLATFORM | 690 | config PATA_OF_PLATFORM |
| 683 | tristate "OpenFirmware platform device PATA support" | 691 | tristate "OpenFirmware platform device PATA support" |
| 684 | depends on PATA_PLATFORM && PPC_OF | 692 | depends on PATA_PLATFORM && PPC_OF |
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 1558059874f0..38906f9bbb4e 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile | |||
| @@ -72,6 +72,7 @@ obj-$(CONFIG_PATA_SCH) += pata_sch.o | |||
| 72 | obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o | 72 | obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o |
| 73 | obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o | 73 | obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o |
| 74 | obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o | 74 | obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o |
| 75 | obj-$(CONFIG_PATA_AT91) += pata_at91.o | ||
| 75 | obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o | 76 | obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o |
| 76 | obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o | 77 | obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o |
| 77 | # Should be last but two libata driver | 78 | # Should be last but two libata driver |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index ca4d208ddf3b..045a486a09ea 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
| @@ -125,19 +125,19 @@ MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link spe | |||
| 125 | 125 | ||
| 126 | static int atapi_enabled = 1; | 126 | static int atapi_enabled = 1; |
| 127 | module_param(atapi_enabled, int, 0444); | 127 | module_param(atapi_enabled, int, 0444); |
| 128 | MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); | 128 | MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on [default])"); |
| 129 | 129 | ||
| 130 | static int atapi_dmadir = 0; | 130 | static int atapi_dmadir = 0; |
| 131 | module_param(atapi_dmadir, int, 0444); | 131 | module_param(atapi_dmadir, int, 0444); |
| 132 | MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off, 1=on)"); | 132 | MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off [default], 1=on)"); |
| 133 | 133 | ||
| 134 | int atapi_passthru16 = 1; | 134 | int atapi_passthru16 = 1; |
| 135 | module_param(atapi_passthru16, int, 0444); | 135 | module_param(atapi_passthru16, int, 0444); |
| 136 | MODULE_PARM_DESC(atapi_passthru16, "Enable ATA_16 passthru for ATAPI devices; on by default (0=off, 1=on)"); | 136 | MODULE_PARM_DESC(atapi_passthru16, "Enable ATA_16 passthru for ATAPI devices (0=off, 1=on [default])"); |
| 137 | 137 | ||
| 138 | int libata_fua = 0; | 138 | int libata_fua = 0; |
| 139 | module_param_named(fua, libata_fua, int, 0444); | 139 | module_param_named(fua, libata_fua, int, 0444); |
| 140 | MODULE_PARM_DESC(fua, "FUA support (0=off, 1=on)"); | 140 | MODULE_PARM_DESC(fua, "FUA support (0=off [default], 1=on)"); |
| 141 | 141 | ||
| 142 | static int ata_ignore_hpa; | 142 | static int ata_ignore_hpa; |
| 143 | module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644); | 143 | module_param_named(ignore_hpa, ata_ignore_hpa, int, 0644); |
| @@ -153,11 +153,11 @@ MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)"); | |||
| 153 | 153 | ||
| 154 | int libata_noacpi = 0; | 154 | int libata_noacpi = 0; |
| 155 | module_param_named(noacpi, libata_noacpi, int, 0444); | 155 | module_param_named(noacpi, libata_noacpi, int, 0444); |
| 156 | MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in probe/suspend/resume when set"); | 156 | MODULE_PARM_DESC(noacpi, "Disable the use of ACPI in probe/suspend/resume (0=off [default], 1=on)"); |
| 157 | 157 | ||
| 158 | int libata_allow_tpm = 0; | 158 | int libata_allow_tpm = 0; |
| 159 | module_param_named(allow_tpm, libata_allow_tpm, int, 0444); | 159 | module_param_named(allow_tpm, libata_allow_tpm, int, 0444); |
| 160 | MODULE_PARM_DESC(allow_tpm, "Permit the use of TPM commands"); | 160 | MODULE_PARM_DESC(allow_tpm, "Permit the use of TPM commands (0=off [default], 1=on)"); |
| 161 | 161 | ||
| 162 | MODULE_AUTHOR("Jeff Garzik"); | 162 | MODULE_AUTHOR("Jeff Garzik"); |
| 163 | MODULE_DESCRIPTION("Library module for ATA devices"); | 163 | MODULE_DESCRIPTION("Library module for ATA devices"); |
| @@ -1993,11 +1993,17 @@ unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) | |||
| 1993 | * Check if the current speed of the device requires IORDY. Used | 1993 | * Check if the current speed of the device requires IORDY. Used |
| 1994 | * by various controllers for chip configuration. | 1994 | * by various controllers for chip configuration. |
| 1995 | */ | 1995 | */ |
| 1996 | |||
| 1997 | unsigned int ata_pio_need_iordy(const struct ata_device *adev) | 1996 | unsigned int ata_pio_need_iordy(const struct ata_device *adev) |
| 1998 | { | 1997 | { |
| 1999 | /* Controller doesn't support IORDY. Probably a pointless check | 1998 | /* Don't set IORDY if we're preparing for reset. IORDY may |
| 2000 | as the caller should know this */ | 1999 | * lead to controller lock up on certain controllers if the |
| 2000 | * port is not occupied. See bko#11703 for details. | ||
| 2001 | */ | ||
| 2002 | if (adev->link->ap->pflags & ATA_PFLAG_RESETTING) | ||
| 2003 | return 0; | ||
| 2004 | /* Controller doesn't support IORDY. Probably a pointless | ||
| 2005 | * check as the caller should know this. | ||
| 2006 | */ | ||
| 2001 | if (adev->link->ap->flags & ATA_FLAG_NO_IORDY) | 2007 | if (adev->link->ap->flags & ATA_FLAG_NO_IORDY) |
| 2002 | return 0; | 2008 | return 0; |
| 2003 | /* CF spec. r4.1 Table 22 says no iordy on PIO5 and PIO6. */ | 2009 | /* CF spec. r4.1 Table 22 says no iordy on PIO5 and PIO6. */ |
| @@ -2020,7 +2026,6 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
| 2020 | * Compute the highest mode possible if we are not using iordy. Return | 2026 | * Compute the highest mode possible if we are not using iordy. Return |
| 2021 | * -1 if no iordy mode is available. | 2027 | * -1 if no iordy mode is available. |
| 2022 | */ | 2028 | */ |
| 2023 | |||
| 2024 | static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) | 2029 | static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) |
| 2025 | { | 2030 | { |
| 2026 | /* If we have no drive specific rule, then PIO 2 is non IORDY */ | 2031 | /* If we have no drive specific rule, then PIO 2 is non IORDY */ |
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c new file mode 100644 index 000000000000..4b27617be26d --- /dev/null +++ b/drivers/ata/pata_at91.c | |||
| @@ -0,0 +1,361 @@ | |||
| 1 | /* | ||
| 2 | * PATA driver for AT91SAM9260 Static Memory Controller | ||
| 3 | * with CompactFlash interface in True IDE mode | ||
| 4 | * | ||
| 5 | * Copyright (C) 2009 Matyukevich Sergey | ||
| 6 | * | ||
| 7 | * Based on: | ||
| 8 | * * generic platform driver by Paul Mundt: drivers/ata/pata_platform.c | ||
| 9 | * * pata_at32 driver by Kristoffer Nyborg Gregertsen | ||
| 10 | * * at91_ide driver by Stanislaw Gruszka | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms of the GNU General Public License version 2 | ||
| 14 | * as published by the Free Software Foundation. | ||
| 15 | * | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <linux/kernel.h> | ||
| 19 | #include <linux/module.h> | ||
| 20 | #include <linux/init.h> | ||
| 21 | #include <linux/blkdev.h> | ||
| 22 | #include <scsi/scsi_host.h> | ||
| 23 | #include <linux/ata.h> | ||
| 24 | #include <linux/clk.h> | ||
| 25 | #include <linux/libata.h> | ||
| 26 | #include <linux/platform_device.h> | ||
| 27 | #include <linux/ata_platform.h> | ||
| 28 | |||
| 29 | #include <mach/at91sam9260_matrix.h> | ||
| 30 | #include <mach/at91sam9_smc.h> | ||
| 31 | #include <mach/at91sam9260.h> | ||
| 32 | #include <mach/board.h> | ||
| 33 | #include <mach/gpio.h> | ||
| 34 | |||
| 35 | |||
| 36 | #define DRV_NAME "pata_at91" | ||
| 37 | #define DRV_VERSION "0.1" | ||
| 38 | |||
| 39 | #define CF_IDE_OFFSET 0x00c00000 | ||
| 40 | #define CF_ALT_IDE_OFFSET 0x00e00000 | ||
| 41 | #define CF_IDE_RES_SIZE 0x08 | ||
| 42 | |||
| 43 | struct at91_ide_info { | ||
| 44 | unsigned long mode; | ||
| 45 | unsigned int cs; | ||
| 46 | |||
| 47 | void __iomem *ide_addr; | ||
| 48 | void __iomem *alt_addr; | ||
| 49 | }; | ||
| 50 | |||
| 51 | const struct ata_timing initial_timing = | ||
| 52 | {XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0}; | ||
| 53 | |||
| 54 | static unsigned int calc_mck_cycles(unsigned int ns, unsigned int mck_hz) | ||
| 55 | { | ||
| 56 | unsigned long mul; | ||
| 57 | |||
| 58 | /* | ||
| 59 | * cycles = x [nsec] * f [Hz] / 10^9 [ns in sec] = | ||
| 60 | * x * (f / 1_000_000_000) = | ||
| 61 | * x * ((f * 65536) / 1_000_000_000) / 65536 = | ||
| 62 | * x * (((f / 10_000) * 65536) / 100_000) / 65536 = | ||
| 63 | */ | ||
| 64 | |||
| 65 | mul = (mck_hz / 10000) << 16; | ||
| 66 | mul /= 100000; | ||
| 67 | |||
| 68 | return (ns * mul + 65536) >> 16; /* rounding */ | ||
| 69 | } | ||
| 70 | |||
| 71 | static void set_smc_mode(struct at91_ide_info *info) | ||
| 72 | { | ||
| 73 | at91_sys_write(AT91_SMC_MODE(info->cs), info->mode); | ||
| 74 | return; | ||
| 75 | } | ||
| 76 | |||
| 77 | static void set_smc_timing(struct device *dev, | ||
| 78 | struct at91_ide_info *info, const struct ata_timing *ata) | ||
| 79 | { | ||
| 80 | int read_cycle, write_cycle, active, recover; | ||
| 81 | int nrd_setup, nrd_pulse, nrd_recover; | ||
| 82 | int nwe_setup, nwe_pulse; | ||
| 83 | |||
| 84 | int ncs_write_setup, ncs_write_pulse; | ||
| 85 | int ncs_read_setup, ncs_read_pulse; | ||
| 86 | |||
| 87 | unsigned int mck_hz; | ||
| 88 | struct clk *mck; | ||
| 89 | |||
| 90 | read_cycle = ata->cyc8b; | ||
| 91 | nrd_setup = ata->setup; | ||
| 92 | nrd_pulse = ata->act8b; | ||
| 93 | nrd_recover = ata->rec8b; | ||
| 94 | |||
| 95 | mck = clk_get(NULL, "mck"); | ||
| 96 | BUG_ON(IS_ERR(mck)); | ||
| 97 | mck_hz = clk_get_rate(mck); | ||
| 98 | |||
| 99 | read_cycle = calc_mck_cycles(read_cycle, mck_hz); | ||
| 100 | nrd_setup = calc_mck_cycles(nrd_setup, mck_hz); | ||
| 101 | nrd_pulse = calc_mck_cycles(nrd_pulse, mck_hz); | ||
| 102 | nrd_recover = calc_mck_cycles(nrd_recover, mck_hz); | ||
| 103 | |||
| 104 | clk_put(mck); | ||
| 105 | |||
| 106 | active = nrd_setup + nrd_pulse; | ||
| 107 | recover = read_cycle - active; | ||
| 108 | |||
| 109 | /* Need at least two cycles recovery */ | ||
| 110 | if (recover < 2) | ||
| 111 | read_cycle = active + 2; | ||
| 112 | |||
| 113 | /* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */ | ||
| 114 | ncs_read_setup = 1; | ||
| 115 | ncs_read_pulse = read_cycle - 2; | ||
| 116 | |||
| 117 | /* Write timings same as read timings */ | ||
| 118 | write_cycle = read_cycle; | ||
| 119 | nwe_setup = nrd_setup; | ||
| 120 | nwe_pulse = nrd_pulse; | ||
| 121 | ncs_write_setup = ncs_read_setup; | ||
| 122 | ncs_write_pulse = ncs_read_pulse; | ||
| 123 | |||
| 124 | dev_dbg(dev, "ATA timings: nrd_setup = %d nrd_pulse = %d nrd_cycle = %d\n", | ||
| 125 | nrd_setup, nrd_pulse, read_cycle); | ||
| 126 | dev_dbg(dev, "ATA timings: nwe_setup = %d nwe_pulse = %d nwe_cycle = %d\n", | ||
| 127 | nwe_setup, nwe_pulse, write_cycle); | ||
| 128 | dev_dbg(dev, "ATA timings: ncs_read_setup = %d ncs_read_pulse = %d\n", | ||
| 129 | ncs_read_setup, ncs_read_pulse); | ||
| 130 | dev_dbg(dev, "ATA timings: ncs_write_setup = %d ncs_write_pulse = %d\n", | ||
| 131 | ncs_write_setup, ncs_write_pulse); | ||
| 132 | |||
| 133 | at91_sys_write(AT91_SMC_SETUP(info->cs), | ||
| 134 | AT91_SMC_NWESETUP_(nwe_setup) | | ||
| 135 | AT91_SMC_NRDSETUP_(nrd_setup) | | ||
| 136 | AT91_SMC_NCS_WRSETUP_(ncs_write_setup) | | ||
| 137 | AT91_SMC_NCS_RDSETUP_(ncs_read_setup)); | ||
| 138 | |||
| 139 | at91_sys_write(AT91_SMC_PULSE(info->cs), | ||
| 140 | AT91_SMC_NWEPULSE_(nwe_pulse) | | ||
| 141 | AT91_SMC_NRDPULSE_(nrd_pulse) | | ||
| 142 | AT91_SMC_NCS_WRPULSE_(ncs_write_pulse) | | ||
| 143 | AT91_SMC_NCS_RDPULSE_(ncs_read_pulse)); | ||
| 144 | |||
| 145 | at91_sys_write(AT91_SMC_CYCLE(info->cs), | ||
| 146 | AT91_SMC_NWECYCLE_(write_cycle) | | ||
| 147 | AT91_SMC_NRDCYCLE_(read_cycle)); | ||
| 148 | |||
| 149 | return; | ||
| 150 | } | ||
| 151 | |||
| 152 | static void pata_at91_set_piomode(struct ata_port *ap, struct ata_device *adev) | ||
| 153 | { | ||
| 154 | struct at91_ide_info *info = ap->host->private_data; | ||
| 155 | struct ata_timing timing; | ||
| 156 | int ret; | ||
| 157 | |||
| 158 | /* Compute ATA timing and set it to SMC */ | ||
| 159 | ret = ata_timing_compute(adev, adev->pio_mode, &timing, 1000, 0); | ||
| 160 | if (ret) { | ||
| 161 | dev_warn(ap->dev, "Failed to compute ATA timing %d, \ | ||
| 162 | set PIO_0 timing\n", ret); | ||
| 163 | set_smc_timing(ap->dev, info, &initial_timing); | ||
| 164 | } else { | ||
| 165 | set_smc_timing(ap->dev, info, &timing); | ||
| 166 | } | ||
| 167 | |||
| 168 | /* Setup SMC mode */ | ||
| 169 | set_smc_mode(info); | ||
| 170 | |||
| 171 | return; | ||
| 172 | } | ||
| 173 | |||
| 174 | static unsigned int pata_at91_data_xfer_noirq(struct ata_device *dev, | ||
| 175 | unsigned char *buf, unsigned int buflen, int rw) | ||
| 176 | { | ||
| 177 | struct at91_ide_info *info = dev->link->ap->host->private_data; | ||
| 178 | unsigned int consumed; | ||
| 179 | unsigned long flags; | ||
| 180 | unsigned int mode; | ||
| 181 | |||
| 182 | local_irq_save(flags); | ||
| 183 | mode = at91_sys_read(AT91_SMC_MODE(info->cs)); | ||
| 184 | |||
| 185 | /* set 16bit mode before writing data */ | ||
| 186 | at91_sys_write(AT91_SMC_MODE(info->cs), | ||
| 187 | (mode & ~AT91_SMC_DBW) | AT91_SMC_DBW_16); | ||
| 188 | |||
| 189 | consumed = ata_sff_data_xfer(dev, buf, buflen, rw); | ||
| 190 | |||
| 191 | /* restore 8bit mode after data is written */ | ||
| 192 | at91_sys_write(AT91_SMC_MODE(info->cs), | ||
| 193 | (mode & ~AT91_SMC_DBW) | AT91_SMC_DBW_8); | ||
| 194 | |||
| 195 | local_irq_restore(flags); | ||
| 196 | return consumed; | ||
| 197 | } | ||
| 198 | |||
| 199 | static struct scsi_host_template pata_at91_sht = { | ||
| 200 | ATA_PIO_SHT(DRV_NAME), | ||
| 201 | }; | ||
| 202 | |||
| 203 | static struct ata_port_operations pata_at91_port_ops = { | ||
| 204 | .inherits = &ata_sff_port_ops, | ||
| 205 | |||
| 206 | .sff_data_xfer = pata_at91_data_xfer_noirq, | ||
| 207 | .set_piomode = pata_at91_set_piomode, | ||
| 208 | .cable_detect = ata_cable_40wire, | ||
| 209 | .port_start = ATA_OP_NULL, | ||
| 210 | }; | ||
| 211 | |||
| 212 | static int __devinit pata_at91_probe(struct platform_device *pdev) | ||
| 213 | { | ||
| 214 | struct at91_cf_data *board = pdev->dev.platform_data; | ||
| 215 | struct device *dev = &pdev->dev; | ||
| 216 | struct at91_ide_info *info; | ||
| 217 | struct resource *mem_res; | ||
| 218 | struct ata_host *host; | ||
| 219 | struct ata_port *ap; | ||
| 220 | int irq_flags = 0; | ||
| 221 | int irq = 0; | ||
| 222 | int ret; | ||
| 223 | |||
| 224 | /* get platform resources: IO/CTL memories and irq/rst pins */ | ||
| 225 | |||
| 226 | if (pdev->num_resources != 1) { | ||
| 227 | dev_err(&pdev->dev, "invalid number of resources\n"); | ||
| 228 | return -EINVAL; | ||
| 229 | } | ||
| 230 | |||
| 231 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 232 | |||
| 233 | if (!mem_res) { | ||
| 234 | dev_err(dev, "failed to get mem resource\n"); | ||
| 235 | return -EINVAL; | ||
| 236 | } | ||
| 237 | |||
| 238 | irq = board->irq_pin; | ||
| 239 | |||
| 240 | /* init ata host */ | ||
| 241 | |||
| 242 | host = ata_host_alloc(dev, 1); | ||
| 243 | |||
| 244 | if (!host) | ||
| 245 | return -ENOMEM; | ||
| 246 | |||
| 247 | ap = host->ports[0]; | ||
| 248 | ap->ops = &pata_at91_port_ops; | ||
| 249 | ap->flags |= ATA_FLAG_SLAVE_POSS; | ||
| 250 | ap->pio_mask = ATA_PIO4; | ||
| 251 | |||
| 252 | if (!irq) { | ||
| 253 | ap->flags |= ATA_FLAG_PIO_POLLING; | ||
| 254 | ata_port_desc(ap, "no IRQ, using PIO polling"); | ||
| 255 | } | ||
| 256 | |||
| 257 | info = kzalloc(sizeof(*info), GFP_KERNEL); | ||
| 258 | |||
| 259 | if (!info) { | ||
| 260 | dev_err(dev, "failed to allocate memory for private data\n"); | ||
| 261 | return -ENOMEM; | ||
| 262 | } | ||
| 263 | |||
| 264 | info->cs = board->chipselect; | ||
| 265 | info->mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | | ||
| 266 | AT91_SMC_EXNWMODE_READY | AT91_SMC_BAT_SELECT | | ||
| 267 | AT91_SMC_DBW_8 | AT91_SMC_TDF_(0); | ||
| 268 | |||
| 269 | info->ide_addr = devm_ioremap(dev, | ||
| 270 | mem_res->start + CF_IDE_OFFSET, CF_IDE_RES_SIZE); | ||
| 271 | |||
| 272 | if (!info->ide_addr) { | ||
| 273 | dev_err(dev, "failed to map IO base\n"); | ||
| 274 | ret = -ENOMEM; | ||
| 275 | goto err_ide_ioremap; | ||
| 276 | } | ||
| 277 | |||
| 278 | info->alt_addr = devm_ioremap(dev, | ||
| 279 | mem_res->start + CF_ALT_IDE_OFFSET, CF_IDE_RES_SIZE); | ||
| 280 | |||
| 281 | if (!info->alt_addr) { | ||
| 282 | dev_err(dev, "failed to map CTL base\n"); | ||
| 283 | ret = -ENOMEM; | ||
| 284 | goto err_alt_ioremap; | ||
| 285 | } | ||
| 286 | |||
| 287 | ap->ioaddr.cmd_addr = info->ide_addr; | ||
| 288 | ap->ioaddr.ctl_addr = info->alt_addr + 0x06; | ||
| 289 | ap->ioaddr.altstatus_addr = ap->ioaddr.ctl_addr; | ||
| 290 | |||
| 291 | ata_sff_std_ports(&ap->ioaddr); | ||
| 292 | |||
| 293 | ata_port_desc(ap, "mmio cmd 0x%llx ctl 0x%llx", | ||
| 294 | (unsigned long long)mem_res->start + CF_IDE_OFFSET, | ||
| 295 | (unsigned long long)mem_res->start + CF_ALT_IDE_OFFSET); | ||
| 296 | |||
| 297 | host->private_data = info; | ||
| 298 | |||
| 299 | return ata_host_activate(host, irq ? gpio_to_irq(irq) : 0, | ||
| 300 | irq ? ata_sff_interrupt : NULL, | ||
| 301 | irq_flags, &pata_at91_sht); | ||
| 302 | |||
| 303 | err_alt_ioremap: | ||
| 304 | devm_iounmap(dev, info->ide_addr); | ||
| 305 | |||
| 306 | err_ide_ioremap: | ||
| 307 | kfree(info); | ||
| 308 | |||
| 309 | return ret; | ||
| 310 | } | ||
| 311 | |||
| 312 | static int __devexit pata_at91_remove(struct platform_device *pdev) | ||
| 313 | { | ||
| 314 | struct ata_host *host = dev_get_drvdata(&pdev->dev); | ||
| 315 | struct at91_ide_info *info = host->private_data; | ||
| 316 | struct device *dev = &pdev->dev; | ||
| 317 | |||
| 318 | if (!host) | ||
| 319 | return 0; | ||
| 320 | |||
| 321 | ata_host_detach(host); | ||
| 322 | |||
| 323 | if (!info) | ||
| 324 | return 0; | ||
| 325 | |||
| 326 | devm_iounmap(dev, info->ide_addr); | ||
| 327 | devm_iounmap(dev, info->alt_addr); | ||
| 328 | |||
| 329 | kfree(info); | ||
| 330 | return 0; | ||
| 331 | } | ||
| 332 | |||
| 333 | static struct platform_driver pata_at91_driver = { | ||
| 334 | .probe = pata_at91_probe, | ||
| 335 | .remove = __devexit_p(pata_at91_remove), | ||
| 336 | .driver = { | ||
| 337 | .name = DRV_NAME, | ||
| 338 | .owner = THIS_MODULE, | ||
| 339 | }, | ||
| 340 | }; | ||
| 341 | |||
| 342 | static int __init pata_at91_init(void) | ||
| 343 | { | ||
| 344 | return platform_driver_register(&pata_at91_driver); | ||
| 345 | } | ||
| 346 | |||
| 347 | static void __exit pata_at91_exit(void) | ||
| 348 | { | ||
| 349 | platform_driver_unregister(&pata_at91_driver); | ||
| 350 | } | ||
| 351 | |||
| 352 | |||
| 353 | module_init(pata_at91_init); | ||
| 354 | module_exit(pata_at91_exit); | ||
| 355 | |||
| 356 | |||
| 357 | MODULE_LICENSE("GPL"); | ||
| 358 | MODULE_DESCRIPTION("Driver for CF in True IDE mode on AT91SAM9260 SoC"); | ||
| 359 | MODULE_AUTHOR("Matyukevich Sergey"); | ||
| 360 | MODULE_VERSION(DRV_VERSION); | ||
| 361 | |||
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c index 36b8629203be..94eaa432c40a 100644 --- a/drivers/ata/sata_fsl.c +++ b/drivers/ata/sata_fsl.c | |||
| @@ -1378,6 +1378,37 @@ static int sata_fsl_remove(struct of_device *ofdev) | |||
| 1378 | return 0; | 1378 | return 0; |
| 1379 | } | 1379 | } |
| 1380 | 1380 | ||
| 1381 | #ifdef CONFIG_PM | ||
| 1382 | static int sata_fsl_suspend(struct of_device *op, pm_message_t state) | ||
| 1383 | { | ||
| 1384 | struct ata_host *host = dev_get_drvdata(&op->dev); | ||
| 1385 | return ata_host_suspend(host, state); | ||
| 1386 | } | ||
| 1387 | |||
| 1388 | static int sata_fsl_resume(struct of_device *op) | ||
| 1389 | { | ||
| 1390 | struct ata_host *host = dev_get_drvdata(&op->dev); | ||
| 1391 | struct sata_fsl_host_priv *host_priv = host->private_data; | ||
| 1392 | int ret; | ||
| 1393 | void __iomem *hcr_base = host_priv->hcr_base; | ||
| 1394 | struct ata_port *ap = host->ports[0]; | ||
| 1395 | struct sata_fsl_port_priv *pp = ap->private_data; | ||
| 1396 | |||
| 1397 | ret = sata_fsl_init_controller(host); | ||
| 1398 | if (ret) { | ||
| 1399 | dev_printk(KERN_ERR, &op->dev, | ||
| 1400 | "Error initialize hardware\n"); | ||
| 1401 | return ret; | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | /* Recovery the CHBA register in host controller cmd register set */ | ||
| 1405 | iowrite32(pp->cmdslot_paddr & 0xffffffff, hcr_base + CHBA); | ||
| 1406 | |||
| 1407 | ata_host_resume(host); | ||
| 1408 | return 0; | ||
| 1409 | } | ||
| 1410 | #endif | ||
| 1411 | |||
| 1381 | static struct of_device_id fsl_sata_match[] = { | 1412 | static struct of_device_id fsl_sata_match[] = { |
| 1382 | { | 1413 | { |
| 1383 | .compatible = "fsl,pq-sata", | 1414 | .compatible = "fsl,pq-sata", |
| @@ -1392,6 +1423,10 @@ static struct of_platform_driver fsl_sata_driver = { | |||
| 1392 | .match_table = fsl_sata_match, | 1423 | .match_table = fsl_sata_match, |
| 1393 | .probe = sata_fsl_probe, | 1424 | .probe = sata_fsl_probe, |
| 1394 | .remove = sata_fsl_remove, | 1425 | .remove = sata_fsl_remove, |
| 1426 | #ifdef CONFIG_PM | ||
| 1427 | .suspend = sata_fsl_suspend, | ||
| 1428 | .resume = sata_fsl_resume, | ||
| 1429 | #endif | ||
| 1395 | }; | 1430 | }; |
| 1396 | 1431 | ||
| 1397 | static int __init sata_fsl_init(void) | 1432 | static int __init sata_fsl_init(void) |
diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c index 03c86209446f..680e5975217f 100644 --- a/drivers/ide/cmd64x.c +++ b/drivers/ide/cmd64x.c | |||
| @@ -389,8 +389,7 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { | |||
| 389 | .init_chipset = init_chipset_cmd64x, | 389 | .init_chipset = init_chipset_cmd64x, |
| 390 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, | 390 | .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, |
| 391 | .port_ops = &cmd648_port_ops, | 391 | .port_ops = &cmd648_port_ops, |
| 392 | .host_flags = IDE_HFLAG_SERIALIZE | | 392 | .host_flags = IDE_HFLAG_ABUSE_PREFETCH, |
| 393 | IDE_HFLAG_ABUSE_PREFETCH, | ||
| 394 | .pio_mask = ATA_PIO5, | 393 | .pio_mask = ATA_PIO5, |
| 395 | .mwdma_mask = ATA_MWDMA2, | 394 | .mwdma_mask = ATA_MWDMA2, |
| 396 | .udma_mask = ATA_UDMA2, | 395 | .udma_mask = ATA_UDMA2, |
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index ce511d8748ce..5be1bd4fc7ed 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c | |||
| @@ -514,7 +514,7 @@ static struct notifier_block nb = { | |||
| 514 | .notifier_call = netevent_callback | 514 | .notifier_call = netevent_callback |
| 515 | }; | 515 | }; |
| 516 | 516 | ||
| 517 | static int addr_init(void) | 517 | static int __init addr_init(void) |
| 518 | { | 518 | { |
| 519 | addr_wq = create_singlethread_workqueue("ib_addr"); | 519 | addr_wq = create_singlethread_workqueue("ib_addr"); |
| 520 | if (!addr_wq) | 520 | if (!addr_wq) |
| @@ -524,7 +524,7 @@ static int addr_init(void) | |||
| 524 | return 0; | 524 | return 0; |
| 525 | } | 525 | } |
| 526 | 526 | ||
| 527 | static void addr_cleanup(void) | 527 | static void __exit addr_cleanup(void) |
| 528 | { | 528 | { |
| 529 | unregister_netevent_notifier(&nb); | 529 | unregister_netevent_notifier(&nb); |
| 530 | destroy_workqueue(addr_wq); | 530 | destroy_workqueue(addr_wq); |
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 851de83ff455..075317884b53 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
| @@ -2960,7 +2960,7 @@ static void cma_remove_one(struct ib_device *device) | |||
| 2960 | kfree(cma_dev); | 2960 | kfree(cma_dev); |
| 2961 | } | 2961 | } |
| 2962 | 2962 | ||
| 2963 | static int cma_init(void) | 2963 | static int __init cma_init(void) |
| 2964 | { | 2964 | { |
| 2965 | int ret, low, high, remaining; | 2965 | int ret, low, high, remaining; |
| 2966 | 2966 | ||
| @@ -2990,7 +2990,7 @@ err: | |||
| 2990 | return ret; | 2990 | return ret; |
| 2991 | } | 2991 | } |
| 2992 | 2992 | ||
| 2993 | static void cma_cleanup(void) | 2993 | static void __exit cma_cleanup(void) |
| 2994 | { | 2994 | { |
| 2995 | ib_unregister_client(&cma_client); | 2995 | ib_unregister_client(&cma_client); |
| 2996 | unregister_netdevice_notifier(&cma_nb); | 2996 | unregister_netdevice_notifier(&cma_nb); |
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c index 9209c5332dfe..8b92f85d4dd0 100644 --- a/drivers/infiniband/hw/ehca/ehca_hca.c +++ b/drivers/infiniband/hw/ehca/ehca_hca.c | |||
| @@ -319,7 +319,7 @@ int ehca_query_gid(struct ib_device *ibdev, u8 port, | |||
| 319 | ib_device); | 319 | ib_device); |
| 320 | struct hipz_query_port *rblock; | 320 | struct hipz_query_port *rblock; |
| 321 | 321 | ||
| 322 | if (index > 255) { | 322 | if (index < 0 || index > 255) { |
| 323 | ehca_err(&shca->ib_device, "Invalid index: %x.", index); | 323 | ehca_err(&shca->ib_device, "Invalid index: %x.", index); |
| 324 | return -EINVAL; | 324 | return -EINVAL; |
| 325 | } | 325 | } |
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c index ce4e6eff4792..fab18a2c74a8 100644 --- a/drivers/infiniband/hw/ehca/ehca_main.c +++ b/drivers/infiniband/hw/ehca/ehca_main.c | |||
| @@ -52,7 +52,7 @@ | |||
| 52 | #include "ehca_tools.h" | 52 | #include "ehca_tools.h" |
| 53 | #include "hcp_if.h" | 53 | #include "hcp_if.h" |
| 54 | 54 | ||
| 55 | #define HCAD_VERSION "0027" | 55 | #define HCAD_VERSION "0028" |
| 56 | 56 | ||
| 57 | MODULE_LICENSE("Dual BSD/GPL"); | 57 | MODULE_LICENSE("Dual BSD/GPL"); |
| 58 | MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>"); | 58 | MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>"); |
| @@ -506,6 +506,7 @@ static int ehca_init_device(struct ehca_shca *shca) | |||
| 506 | shca->ib_device.detach_mcast = ehca_detach_mcast; | 506 | shca->ib_device.detach_mcast = ehca_detach_mcast; |
| 507 | shca->ib_device.process_mad = ehca_process_mad; | 507 | shca->ib_device.process_mad = ehca_process_mad; |
| 508 | shca->ib_device.mmap = ehca_mmap; | 508 | shca->ib_device.mmap = ehca_mmap; |
| 509 | shca->ib_device.dma_ops = &ehca_dma_mapping_ops; | ||
| 509 | 510 | ||
| 510 | if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) { | 511 | if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) { |
| 511 | shca->ib_device.uverbs_cmd_mask |= | 512 | shca->ib_device.uverbs_cmd_mask |= |
| @@ -1028,17 +1029,23 @@ static int __init ehca_module_init(void) | |||
| 1028 | goto module_init1; | 1029 | goto module_init1; |
| 1029 | } | 1030 | } |
| 1030 | 1031 | ||
| 1032 | ret = ehca_create_busmap(); | ||
| 1033 | if (ret) { | ||
| 1034 | ehca_gen_err("Cannot create busmap."); | ||
| 1035 | goto module_init2; | ||
| 1036 | } | ||
| 1037 | |||
| 1031 | ret = ibmebus_register_driver(&ehca_driver); | 1038 | ret = ibmebus_register_driver(&ehca_driver); |
| 1032 | if (ret) { | 1039 | if (ret) { |
| 1033 | ehca_gen_err("Cannot register eHCA device driver"); | 1040 | ehca_gen_err("Cannot register eHCA device driver"); |
| 1034 | ret = -EINVAL; | 1041 | ret = -EINVAL; |
| 1035 | goto module_init2; | 1042 | goto module_init3; |
| 1036 | } | 1043 | } |
| 1037 | 1044 | ||
| 1038 | ret = register_memory_notifier(&ehca_mem_nb); | 1045 | ret = register_memory_notifier(&ehca_mem_nb); |
| 1039 | if (ret) { | 1046 | if (ret) { |
| 1040 | ehca_gen_err("Failed registering memory add/remove notifier"); | 1047 | ehca_gen_err("Failed registering memory add/remove notifier"); |
| 1041 | goto module_init3; | 1048 | goto module_init4; |
| 1042 | } | 1049 | } |
| 1043 | 1050 | ||
| 1044 | if (ehca_poll_all_eqs != 1) { | 1051 | if (ehca_poll_all_eqs != 1) { |
| @@ -1053,9 +1060,12 @@ static int __init ehca_module_init(void) | |||
| 1053 | 1060 | ||
| 1054 | return 0; | 1061 | return 0; |
| 1055 | 1062 | ||
| 1056 | module_init3: | 1063 | module_init4: |
| 1057 | ibmebus_unregister_driver(&ehca_driver); | 1064 | ibmebus_unregister_driver(&ehca_driver); |
| 1058 | 1065 | ||
| 1066 | module_init3: | ||
| 1067 | ehca_destroy_busmap(); | ||
| 1068 | |||
| 1059 | module_init2: | 1069 | module_init2: |
| 1060 | ehca_destroy_slab_caches(); | 1070 | ehca_destroy_slab_caches(); |
| 1061 | 1071 | ||
| @@ -1073,6 +1083,8 @@ static void __exit ehca_module_exit(void) | |||
| 1073 | 1083 | ||
| 1074 | unregister_memory_notifier(&ehca_mem_nb); | 1084 | unregister_memory_notifier(&ehca_mem_nb); |
| 1075 | 1085 | ||
| 1086 | ehca_destroy_busmap(); | ||
| 1087 | |||
| 1076 | ehca_destroy_slab_caches(); | 1088 | ehca_destroy_slab_caches(); |
| 1077 | 1089 | ||
| 1078 | ehca_destroy_comp_pool(); | 1090 | ehca_destroy_comp_pool(); |
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c index 72f83f7df614..7663a2a9f130 100644 --- a/drivers/infiniband/hw/ehca/ehca_mrmw.c +++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c | |||
| @@ -53,6 +53,38 @@ | |||
| 53 | /* max number of rpages (per hcall register_rpages) */ | 53 | /* max number of rpages (per hcall register_rpages) */ |
| 54 | #define MAX_RPAGES 512 | 54 | #define MAX_RPAGES 512 |
| 55 | 55 | ||
| 56 | /* DMEM toleration management */ | ||
| 57 | #define EHCA_SECTSHIFT SECTION_SIZE_BITS | ||
| 58 | #define EHCA_SECTSIZE (1UL << EHCA_SECTSHIFT) | ||
| 59 | #define EHCA_HUGEPAGESHIFT 34 | ||
| 60 | #define EHCA_HUGEPAGE_SIZE (1UL << EHCA_HUGEPAGESHIFT) | ||
| 61 | #define EHCA_HUGEPAGE_PFN_MASK ((EHCA_HUGEPAGE_SIZE - 1) >> PAGE_SHIFT) | ||
| 62 | #define EHCA_INVAL_ADDR 0xFFFFFFFFFFFFFFFFULL | ||
| 63 | #define EHCA_DIR_INDEX_SHIFT 13 /* 8k Entries in 64k block */ | ||
| 64 | #define EHCA_TOP_INDEX_SHIFT (EHCA_DIR_INDEX_SHIFT * 2) | ||
| 65 | #define EHCA_MAP_ENTRIES (1 << EHCA_DIR_INDEX_SHIFT) | ||
| 66 | #define EHCA_TOP_MAP_SIZE (0x10000) /* currently fixed map size */ | ||
| 67 | #define EHCA_DIR_MAP_SIZE (0x10000) | ||
| 68 | #define EHCA_ENT_MAP_SIZE (0x10000) | ||
| 69 | #define EHCA_INDEX_MASK (EHCA_MAP_ENTRIES - 1) | ||
| 70 | |||
| 71 | static unsigned long ehca_mr_len; | ||
| 72 | |||
| 73 | /* | ||
| 74 | * Memory map data structures | ||
| 75 | */ | ||
| 76 | struct ehca_dir_bmap { | ||
| 77 | u64 ent[EHCA_MAP_ENTRIES]; | ||
| 78 | }; | ||
| 79 | struct ehca_top_bmap { | ||
| 80 | struct ehca_dir_bmap *dir[EHCA_MAP_ENTRIES]; | ||
| 81 | }; | ||
| 82 | struct ehca_bmap { | ||
| 83 | struct ehca_top_bmap *top[EHCA_MAP_ENTRIES]; | ||
| 84 | }; | ||
| 85 | |||
| 86 | static struct ehca_bmap *ehca_bmap; | ||
| 87 | |||
| 56 | static struct kmem_cache *mr_cache; | 88 | static struct kmem_cache *mr_cache; |
| 57 | static struct kmem_cache *mw_cache; | 89 | static struct kmem_cache *mw_cache; |
| 58 | 90 | ||
| @@ -68,6 +100,8 @@ enum ehca_mr_pgsize { | |||
| 68 | #define EHCA_MR_PGSHIFT1M 20 | 100 | #define EHCA_MR_PGSHIFT1M 20 |
| 69 | #define EHCA_MR_PGSHIFT16M 24 | 101 | #define EHCA_MR_PGSHIFT16M 24 |
| 70 | 102 | ||
| 103 | static u64 ehca_map_vaddr(void *caddr); | ||
| 104 | |||
| 71 | static u32 ehca_encode_hwpage_size(u32 pgsize) | 105 | static u32 ehca_encode_hwpage_size(u32 pgsize) |
| 72 | { | 106 | { |
| 73 | int log = ilog2(pgsize); | 107 | int log = ilog2(pgsize); |
| @@ -135,7 +169,8 @@ struct ib_mr *ehca_get_dma_mr(struct ib_pd *pd, int mr_access_flags) | |||
| 135 | goto get_dma_mr_exit0; | 169 | goto get_dma_mr_exit0; |
| 136 | } | 170 | } |
| 137 | 171 | ||
| 138 | ret = ehca_reg_maxmr(shca, e_maxmr, (u64 *)KERNELBASE, | 172 | ret = ehca_reg_maxmr(shca, e_maxmr, |
| 173 | (void *)ehca_map_vaddr((void *)KERNELBASE), | ||
| 139 | mr_access_flags, e_pd, | 174 | mr_access_flags, e_pd, |
| 140 | &e_maxmr->ib.ib_mr.lkey, | 175 | &e_maxmr->ib.ib_mr.lkey, |
| 141 | &e_maxmr->ib.ib_mr.rkey); | 176 | &e_maxmr->ib.ib_mr.rkey); |
| @@ -251,7 +286,7 @@ struct ib_mr *ehca_reg_phys_mr(struct ib_pd *pd, | |||
| 251 | 286 | ||
| 252 | ret = ehca_reg_mr(shca, e_mr, iova_start, size, mr_access_flags, | 287 | ret = ehca_reg_mr(shca, e_mr, iova_start, size, mr_access_flags, |
| 253 | e_pd, &pginfo, &e_mr->ib.ib_mr.lkey, | 288 | e_pd, &pginfo, &e_mr->ib.ib_mr.lkey, |
| 254 | &e_mr->ib.ib_mr.rkey); | 289 | &e_mr->ib.ib_mr.rkey, EHCA_REG_MR); |
| 255 | if (ret) { | 290 | if (ret) { |
| 256 | ib_mr = ERR_PTR(ret); | 291 | ib_mr = ERR_PTR(ret); |
| 257 | goto reg_phys_mr_exit1; | 292 | goto reg_phys_mr_exit1; |
| @@ -370,7 +405,7 @@ reg_user_mr_fallback: | |||
| 370 | 405 | ||
| 371 | ret = ehca_reg_mr(shca, e_mr, (u64 *)virt, length, mr_access_flags, | 406 | ret = ehca_reg_mr(shca, e_mr, (u64 *)virt, length, mr_access_flags, |
| 372 | e_pd, &pginfo, &e_mr->ib.ib_mr.lkey, | 407 | e_pd, &pginfo, &e_mr->ib.ib_mr.lkey, |
| 373 | &e_mr->ib.ib_mr.rkey); | 408 | &e_mr->ib.ib_mr.rkey, EHCA_REG_MR); |
| 374 | if (ret == -EINVAL && pginfo.hwpage_size > PAGE_SIZE) { | 409 | if (ret == -EINVAL && pginfo.hwpage_size > PAGE_SIZE) { |
| 375 | ehca_warn(pd->device, "failed to register mr " | 410 | ehca_warn(pd->device, "failed to register mr " |
| 376 | "with hwpage_size=%llx", hwpage_size); | 411 | "with hwpage_size=%llx", hwpage_size); |
| @@ -794,7 +829,7 @@ struct ib_fmr *ehca_alloc_fmr(struct ib_pd *pd, | |||
| 794 | ret = ehca_reg_mr(shca, e_fmr, NULL, | 829 | ret = ehca_reg_mr(shca, e_fmr, NULL, |
| 795 | fmr_attr->max_pages * (1 << fmr_attr->page_shift), | 830 | fmr_attr->max_pages * (1 << fmr_attr->page_shift), |
| 796 | mr_access_flags, e_pd, &pginfo, | 831 | mr_access_flags, e_pd, &pginfo, |
| 797 | &tmp_lkey, &tmp_rkey); | 832 | &tmp_lkey, &tmp_rkey, EHCA_REG_MR); |
| 798 | if (ret) { | 833 | if (ret) { |
| 799 | ib_fmr = ERR_PTR(ret); | 834 | ib_fmr = ERR_PTR(ret); |
| 800 | goto alloc_fmr_exit1; | 835 | goto alloc_fmr_exit1; |
| @@ -983,6 +1018,10 @@ free_fmr_exit0: | |||
| 983 | 1018 | ||
| 984 | /*----------------------------------------------------------------------*/ | 1019 | /*----------------------------------------------------------------------*/ |
| 985 | 1020 | ||
| 1021 | static int ehca_reg_bmap_mr_rpages(struct ehca_shca *shca, | ||
| 1022 | struct ehca_mr *e_mr, | ||
| 1023 | struct ehca_mr_pginfo *pginfo); | ||
| 1024 | |||
| 986 | int ehca_reg_mr(struct ehca_shca *shca, | 1025 | int ehca_reg_mr(struct ehca_shca *shca, |
| 987 | struct ehca_mr *e_mr, | 1026 | struct ehca_mr *e_mr, |
| 988 | u64 *iova_start, | 1027 | u64 *iova_start, |
| @@ -991,7 +1030,8 @@ int ehca_reg_mr(struct ehca_shca *shca, | |||
| 991 | struct ehca_pd *e_pd, | 1030 | struct ehca_pd *e_pd, |
| 992 | struct ehca_mr_pginfo *pginfo, | 1031 | struct ehca_mr_pginfo *pginfo, |
| 993 | u32 *lkey, /*OUT*/ | 1032 | u32 *lkey, /*OUT*/ |
| 994 | u32 *rkey) /*OUT*/ | 1033 | u32 *rkey, /*OUT*/ |
| 1034 | enum ehca_reg_type reg_type) | ||
| 995 | { | 1035 | { |
| 996 | int ret; | 1036 | int ret; |
| 997 | u64 h_ret; | 1037 | u64 h_ret; |
| @@ -1015,7 +1055,13 @@ int ehca_reg_mr(struct ehca_shca *shca, | |||
| 1015 | 1055 | ||
| 1016 | e_mr->ipz_mr_handle = hipzout.handle; | 1056 | e_mr->ipz_mr_handle = hipzout.handle; |
| 1017 | 1057 | ||
| 1018 | ret = ehca_reg_mr_rpages(shca, e_mr, pginfo); | 1058 | if (reg_type == EHCA_REG_BUSMAP_MR) |
| 1059 | ret = ehca_reg_bmap_mr_rpages(shca, e_mr, pginfo); | ||
| 1060 | else if (reg_type == EHCA_REG_MR) | ||
| 1061 | ret = ehca_reg_mr_rpages(shca, e_mr, pginfo); | ||
| 1062 | else | ||
| 1063 | ret = -EINVAL; | ||
| 1064 | |||
| 1019 | if (ret) | 1065 | if (ret) |
| 1020 | goto ehca_reg_mr_exit1; | 1066 | goto ehca_reg_mr_exit1; |
| 1021 | 1067 | ||
| @@ -1316,7 +1362,7 @@ int ehca_rereg_mr(struct ehca_shca *shca, | |||
| 1316 | e_mr->fmr_map_cnt = save_mr.fmr_map_cnt; | 1362 | e_mr->fmr_map_cnt = save_mr.fmr_map_cnt; |
| 1317 | 1363 | ||
| 1318 | ret = ehca_reg_mr(shca, e_mr, iova_start, size, acl, | 1364 | ret = ehca_reg_mr(shca, e_mr, iova_start, size, acl, |
| 1319 | e_pd, pginfo, lkey, rkey); | 1365 | e_pd, pginfo, lkey, rkey, EHCA_REG_MR); |
| 1320 | if (ret) { | 1366 | if (ret) { |
| 1321 | u32 offset = (u64)(&e_mr->flags) - (u64)e_mr; | 1367 | u32 offset = (u64)(&e_mr->flags) - (u64)e_mr; |
| 1322 | memcpy(&e_mr->flags, &(save_mr.flags), | 1368 | memcpy(&e_mr->flags, &(save_mr.flags), |
| @@ -1409,7 +1455,7 @@ int ehca_unmap_one_fmr(struct ehca_shca *shca, | |||
| 1409 | ret = ehca_reg_mr(shca, e_fmr, NULL, | 1455 | ret = ehca_reg_mr(shca, e_fmr, NULL, |
| 1410 | (e_fmr->fmr_max_pages * e_fmr->fmr_page_size), | 1456 | (e_fmr->fmr_max_pages * e_fmr->fmr_page_size), |
| 1411 | e_fmr->acl, e_pd, &pginfo, &tmp_lkey, | 1457 | e_fmr->acl, e_pd, &pginfo, &tmp_lkey, |
| 1412 | &tmp_rkey); | 1458 | &tmp_rkey, EHCA_REG_MR); |
| 1413 | if (ret) { | 1459 | if (ret) { |
| 1414 | u32 offset = (u64)(&e_fmr->flags) - (u64)e_fmr; | 1460 | u32 offset = (u64)(&e_fmr->flags) - (u64)e_fmr; |
| 1415 | memcpy(&e_fmr->flags, &(save_mr.flags), | 1461 | memcpy(&e_fmr->flags, &(save_mr.flags), |
| @@ -1478,6 +1524,90 @@ ehca_reg_smr_exit0: | |||
| 1478 | } /* end ehca_reg_smr() */ | 1524 | } /* end ehca_reg_smr() */ |
| 1479 | 1525 | ||
| 1480 | /*----------------------------------------------------------------------*/ | 1526 | /*----------------------------------------------------------------------*/ |
| 1527 | static inline void *ehca_calc_sectbase(int top, int dir, int idx) | ||
| 1528 | { | ||
| 1529 | unsigned long ret = idx; | ||
| 1530 | ret |= dir << EHCA_DIR_INDEX_SHIFT; | ||
| 1531 | ret |= top << EHCA_TOP_INDEX_SHIFT; | ||
| 1532 | return abs_to_virt(ret << SECTION_SIZE_BITS); | ||
| 1533 | } | ||
| 1534 | |||
| 1535 | #define ehca_bmap_valid(entry) \ | ||
| 1536 | ((u64)entry != (u64)EHCA_INVAL_ADDR) | ||
| 1537 | |||
| 1538 | static u64 ehca_reg_mr_section(int top, int dir, int idx, u64 *kpage, | ||
| 1539 | struct ehca_shca *shca, struct ehca_mr *mr, | ||
| 1540 | struct ehca_mr_pginfo *pginfo) | ||
| 1541 | { | ||
| 1542 | u64 h_ret = 0; | ||
| 1543 | unsigned long page = 0; | ||
| 1544 | u64 rpage = virt_to_abs(kpage); | ||
| 1545 | int page_count; | ||
| 1546 | |||
| 1547 | void *sectbase = ehca_calc_sectbase(top, dir, idx); | ||
| 1548 | if ((unsigned long)sectbase & (pginfo->hwpage_size - 1)) { | ||
| 1549 | ehca_err(&shca->ib_device, "reg_mr_section will probably fail:" | ||
| 1550 | "hwpage_size does not fit to " | ||
| 1551 | "section start address"); | ||
| 1552 | } | ||
| 1553 | page_count = EHCA_SECTSIZE / pginfo->hwpage_size; | ||
| 1554 | |||
| 1555 | while (page < page_count) { | ||
| 1556 | u64 rnum; | ||
| 1557 | for (rnum = 0; (rnum < MAX_RPAGES) && (page < page_count); | ||
| 1558 | rnum++) { | ||
| 1559 | void *pg = sectbase + ((page++) * pginfo->hwpage_size); | ||
| 1560 | kpage[rnum] = virt_to_abs(pg); | ||
| 1561 | } | ||
| 1562 | |||
| 1563 | h_ret = hipz_h_register_rpage_mr(shca->ipz_hca_handle, mr, | ||
| 1564 | ehca_encode_hwpage_size(pginfo->hwpage_size), | ||
| 1565 | 0, rpage, rnum); | ||
| 1566 | |||
| 1567 | if ((h_ret != H_SUCCESS) && (h_ret != H_PAGE_REGISTERED)) { | ||
| 1568 | ehca_err(&shca->ib_device, "register_rpage_mr failed"); | ||
| 1569 | return h_ret; | ||
| 1570 | } | ||
| 1571 | } | ||
| 1572 | return h_ret; | ||
| 1573 | } | ||
| 1574 | |||
| 1575 | static u64 ehca_reg_mr_sections(int top, int dir, u64 *kpage, | ||
| 1576 | struct ehca_shca *shca, struct ehca_mr *mr, | ||
| 1577 | struct ehca_mr_pginfo *pginfo) | ||
| 1578 | { | ||
| 1579 | u64 hret = H_SUCCESS; | ||
| 1580 | int idx; | ||
| 1581 | |||
| 1582 | for (idx = 0; idx < EHCA_MAP_ENTRIES; idx++) { | ||
| 1583 | if (!ehca_bmap_valid(ehca_bmap->top[top]->dir[dir]->ent[idx])) | ||
| 1584 | continue; | ||
| 1585 | |||
| 1586 | hret = ehca_reg_mr_section(top, dir, idx, kpage, shca, mr, | ||
| 1587 | pginfo); | ||
| 1588 | if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED)) | ||
| 1589 | return hret; | ||
| 1590 | } | ||
| 1591 | return hret; | ||
| 1592 | } | ||
| 1593 | |||
| 1594 | static u64 ehca_reg_mr_dir_sections(int top, u64 *kpage, struct ehca_shca *shca, | ||
| 1595 | struct ehca_mr *mr, | ||
| 1596 | struct ehca_mr_pginfo *pginfo) | ||
| 1597 | { | ||
| 1598 | u64 hret = H_SUCCESS; | ||
| 1599 | int dir; | ||
| 1600 | |||
| 1601 | for (dir = 0; dir < EHCA_MAP_ENTRIES; dir++) { | ||
| 1602 | if (!ehca_bmap_valid(ehca_bmap->top[top]->dir[dir])) | ||
| 1603 | continue; | ||
| 1604 | |||
| 1605 | hret = ehca_reg_mr_sections(top, dir, kpage, shca, mr, pginfo); | ||
| 1606 | if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED)) | ||
| 1607 | return hret; | ||
| 1608 | } | ||
| 1609 | return hret; | ||
| 1610 | } | ||
| 1481 | 1611 | ||
| 1482 | /* register internal max-MR to internal SHCA */ | 1612 | /* register internal max-MR to internal SHCA */ |
| 1483 | int ehca_reg_internal_maxmr( | 1613 | int ehca_reg_internal_maxmr( |
| @@ -1495,6 +1625,11 @@ int ehca_reg_internal_maxmr( | |||
| 1495 | u32 num_hwpages; | 1625 | u32 num_hwpages; |
| 1496 | u64 hw_pgsize; | 1626 | u64 hw_pgsize; |
| 1497 | 1627 | ||
| 1628 | if (!ehca_bmap) { | ||
| 1629 | ret = -EFAULT; | ||
| 1630 | goto ehca_reg_internal_maxmr_exit0; | ||
| 1631 | } | ||
| 1632 | |||
| 1498 | e_mr = ehca_mr_new(); | 1633 | e_mr = ehca_mr_new(); |
| 1499 | if (!e_mr) { | 1634 | if (!e_mr) { |
| 1500 | ehca_err(&shca->ib_device, "out of memory"); | 1635 | ehca_err(&shca->ib_device, "out of memory"); |
| @@ -1504,8 +1639,8 @@ int ehca_reg_internal_maxmr( | |||
| 1504 | e_mr->flags |= EHCA_MR_FLAG_MAXMR; | 1639 | e_mr->flags |= EHCA_MR_FLAG_MAXMR; |
| 1505 | 1640 | ||
| 1506 | /* register internal max-MR on HCA */ | 1641 | /* register internal max-MR on HCA */ |
| 1507 | size_maxmr = (u64)high_memory - PAGE_OFFSET; | 1642 | size_maxmr = ehca_mr_len; |
| 1508 | iova_start = (u64 *)KERNELBASE; | 1643 | iova_start = (u64 *)ehca_map_vaddr((void *)KERNELBASE); |
| 1509 | ib_pbuf.addr = 0; | 1644 | ib_pbuf.addr = 0; |
| 1510 | ib_pbuf.size = size_maxmr; | 1645 | ib_pbuf.size = size_maxmr; |
| 1511 | num_kpages = NUM_CHUNKS(((u64)iova_start % PAGE_SIZE) + size_maxmr, | 1646 | num_kpages = NUM_CHUNKS(((u64)iova_start % PAGE_SIZE) + size_maxmr, |
| @@ -1524,7 +1659,7 @@ int ehca_reg_internal_maxmr( | |||
| 1524 | 1659 | ||
| 1525 | ret = ehca_reg_mr(shca, e_mr, iova_start, size_maxmr, 0, e_pd, | 1660 | ret = ehca_reg_mr(shca, e_mr, iova_start, size_maxmr, 0, e_pd, |
| 1526 | &pginfo, &e_mr->ib.ib_mr.lkey, | 1661 | &pginfo, &e_mr->ib.ib_mr.lkey, |
| 1527 | &e_mr->ib.ib_mr.rkey); | 1662 | &e_mr->ib.ib_mr.rkey, EHCA_REG_BUSMAP_MR); |
| 1528 | if (ret) { | 1663 | if (ret) { |
| 1529 | ehca_err(&shca->ib_device, "reg of internal max MR failed, " | 1664 | ehca_err(&shca->ib_device, "reg of internal max MR failed, " |
| 1530 | "e_mr=%p iova_start=%p size_maxmr=%llx num_kpages=%x " | 1665 | "e_mr=%p iova_start=%p size_maxmr=%llx num_kpages=%x " |
| @@ -2077,8 +2212,8 @@ int ehca_mr_is_maxmr(u64 size, | |||
| 2077 | u64 *iova_start) | 2212 | u64 *iova_start) |
| 2078 | { | 2213 | { |
| 2079 | /* a MR is treated as max-MR only if it fits following: */ | 2214 | /* a MR is treated as max-MR only if it fits following: */ |
| 2080 | if ((size == ((u64)high_memory - PAGE_OFFSET)) && | 2215 | if ((size == ehca_mr_len) && |
| 2081 | (iova_start == (void *)KERNELBASE)) { | 2216 | (iova_start == (void *)ehca_map_vaddr((void *)KERNELBASE))) { |
| 2082 | ehca_gen_dbg("this is a max-MR"); | 2217 | ehca_gen_dbg("this is a max-MR"); |
| 2083 | return 1; | 2218 | return 1; |
| 2084 | } else | 2219 | } else |
| @@ -2184,3 +2319,350 @@ void ehca_cleanup_mrmw_cache(void) | |||
| 2184 | if (mw_cache) | 2319 | if (mw_cache) |
| 2185 | kmem_cache_destroy(mw_cache); | 2320 | kmem_cache_destroy(mw_cache); |
| 2186 | } | 2321 | } |
| 2322 | |||
| 2323 | static inline int ehca_init_top_bmap(struct ehca_top_bmap *ehca_top_bmap, | ||
| 2324 | int dir) | ||
| 2325 | { | ||
| 2326 | if (!ehca_bmap_valid(ehca_top_bmap->dir[dir])) { | ||
| 2327 | ehca_top_bmap->dir[dir] = | ||
| 2328 | kmalloc(sizeof(struct ehca_dir_bmap), GFP_KERNEL); | ||
| 2329 | if (!ehca_top_bmap->dir[dir]) | ||
| 2330 | return -ENOMEM; | ||
| 2331 | /* Set map block to 0xFF according to EHCA_INVAL_ADDR */ | ||
| 2332 | memset(ehca_top_bmap->dir[dir], 0xFF, EHCA_ENT_MAP_SIZE); | ||
| 2333 | } | ||
| 2334 | return 0; | ||
| 2335 | } | ||
| 2336 | |||
| 2337 | static inline int ehca_init_bmap(struct ehca_bmap *ehca_bmap, int top, int dir) | ||
| 2338 | { | ||
| 2339 | if (!ehca_bmap_valid(ehca_bmap->top[top])) { | ||
| 2340 | ehca_bmap->top[top] = | ||
| 2341 | kmalloc(sizeof(struct ehca_top_bmap), GFP_KERNEL); | ||
| 2342 | if (!ehca_bmap->top[top]) | ||
| 2343 | return -ENOMEM; | ||
| 2344 | /* Set map block to 0xFF according to EHCA_INVAL_ADDR */ | ||
| 2345 | memset(ehca_bmap->top[top], 0xFF, EHCA_DIR_MAP_SIZE); | ||
| 2346 | } | ||
| 2347 | return ehca_init_top_bmap(ehca_bmap->top[top], dir); | ||
| 2348 | } | ||
| 2349 | |||
| 2350 | static inline int ehca_calc_index(unsigned long i, unsigned long s) | ||
| 2351 | { | ||
| 2352 | return (i >> s) & EHCA_INDEX_MASK; | ||
| 2353 | } | ||
| 2354 | |||
| 2355 | void ehca_destroy_busmap(void) | ||
| 2356 | { | ||
| 2357 | int top, dir; | ||
| 2358 | |||
| 2359 | if (!ehca_bmap) | ||
| 2360 | return; | ||
| 2361 | |||
| 2362 | for (top = 0; top < EHCA_MAP_ENTRIES; top++) { | ||
| 2363 | if (!ehca_bmap_valid(ehca_bmap->top[top])) | ||
| 2364 | continue; | ||
| 2365 | for (dir = 0; dir < EHCA_MAP_ENTRIES; dir++) { | ||
| 2366 | if (!ehca_bmap_valid(ehca_bmap->top[top]->dir[dir])) | ||
| 2367 | continue; | ||
| 2368 | |||
| 2369 | kfree(ehca_bmap->top[top]->dir[dir]); | ||
| 2370 | } | ||
| 2371 | |||
| 2372 | kfree(ehca_bmap->top[top]); | ||
| 2373 | } | ||
| 2374 | |||
| 2375 | kfree(ehca_bmap); | ||
| 2376 | ehca_bmap = NULL; | ||
| 2377 | } | ||
| 2378 | |||
| 2379 | static int ehca_update_busmap(unsigned long pfn, unsigned long nr_pages) | ||
| 2380 | { | ||
| 2381 | unsigned long i, start_section, end_section; | ||
| 2382 | int top, dir, idx; | ||
| 2383 | |||
| 2384 | if (!nr_pages) | ||
| 2385 | return 0; | ||
| 2386 | |||
| 2387 | if (!ehca_bmap) { | ||
| 2388 | ehca_bmap = kmalloc(sizeof(struct ehca_bmap), GFP_KERNEL); | ||
| 2389 | if (!ehca_bmap) | ||
| 2390 | return -ENOMEM; | ||
| 2391 | /* Set map block to 0xFF according to EHCA_INVAL_ADDR */ | ||
| 2392 | memset(ehca_bmap, 0xFF, EHCA_TOP_MAP_SIZE); | ||
| 2393 | } | ||
| 2394 | |||
| 2395 | start_section = phys_to_abs(pfn * PAGE_SIZE) / EHCA_SECTSIZE; | ||
| 2396 | end_section = phys_to_abs((pfn + nr_pages) * PAGE_SIZE) / EHCA_SECTSIZE; | ||
| 2397 | for (i = start_section; i < end_section; i++) { | ||
| 2398 | int ret; | ||
| 2399 | top = ehca_calc_index(i, EHCA_TOP_INDEX_SHIFT); | ||
| 2400 | dir = ehca_calc_index(i, EHCA_DIR_INDEX_SHIFT); | ||
| 2401 | idx = i & EHCA_INDEX_MASK; | ||
| 2402 | |||
| 2403 | ret = ehca_init_bmap(ehca_bmap, top, dir); | ||
| 2404 | if (ret) { | ||
| 2405 | ehca_destroy_busmap(); | ||
| 2406 | return ret; | ||
| 2407 | } | ||
| 2408 | ehca_bmap->top[top]->dir[dir]->ent[idx] = ehca_mr_len; | ||
| 2409 | ehca_mr_len += EHCA_SECTSIZE; | ||
| 2410 | } | ||
| 2411 | return 0; | ||
| 2412 | } | ||
| 2413 | |||
| 2414 | static int ehca_is_hugepage(unsigned long pfn) | ||
| 2415 | { | ||
| 2416 | int page_order; | ||
| 2417 | |||
| 2418 | if (pfn & EHCA_HUGEPAGE_PFN_MASK) | ||
| 2419 | return 0; | ||
| 2420 | |||
| 2421 | page_order = compound_order(pfn_to_page(pfn)); | ||
| 2422 | if (page_order + PAGE_SHIFT != EHCA_HUGEPAGESHIFT) | ||
| 2423 | return 0; | ||
| 2424 | |||
| 2425 | return 1; | ||
| 2426 | } | ||
| 2427 | |||
| 2428 | static int ehca_create_busmap_callback(unsigned long initial_pfn, | ||
| 2429 | unsigned long total_nr_pages, void *arg) | ||
| 2430 | { | ||
| 2431 | int ret; | ||
| 2432 | unsigned long pfn, start_pfn, end_pfn, nr_pages; | ||
| 2433 | |||
| 2434 | if ((total_nr_pages * PAGE_SIZE) < EHCA_HUGEPAGE_SIZE) | ||
| 2435 | return ehca_update_busmap(initial_pfn, total_nr_pages); | ||
| 2436 | |||
| 2437 | /* Given chunk is >= 16GB -> check for hugepages */ | ||
| 2438 | start_pfn = initial_pfn; | ||
| 2439 | end_pfn = initial_pfn + total_nr_pages; | ||
| 2440 | pfn = start_pfn; | ||
| 2441 | |||
| 2442 | while (pfn < end_pfn) { | ||
| 2443 | if (ehca_is_hugepage(pfn)) { | ||
| 2444 | /* Add mem found in front of the hugepage */ | ||
| 2445 | nr_pages = pfn - start_pfn; | ||
| 2446 | ret = ehca_update_busmap(start_pfn, nr_pages); | ||
| 2447 | if (ret) | ||
| 2448 | return ret; | ||
| 2449 | /* Skip the hugepage */ | ||
| 2450 | pfn += (EHCA_HUGEPAGE_SIZE / PAGE_SIZE); | ||
| 2451 | start_pfn = pfn; | ||
| 2452 | } else | ||
| 2453 | pfn += (EHCA_SECTSIZE / PAGE_SIZE); | ||
| 2454 | } | ||
| 2455 | |||
| 2456 | /* Add mem found behind the hugepage(s) */ | ||
| 2457 | nr_pages = pfn - start_pfn; | ||
| 2458 | return ehca_update_busmap(start_pfn, nr_pages); | ||
| 2459 | } | ||
| 2460 | |||
| 2461 | int ehca_create_busmap(void) | ||
| 2462 | { | ||
| 2463 | int ret; | ||
| 2464 | |||
| 2465 | ehca_mr_len = 0; | ||
| 2466 | ret = walk_memory_resource(0, 1ULL << MAX_PHYSMEM_BITS, NULL, | ||
| 2467 | ehca_create_busmap_callback); | ||
| 2468 | return ret; | ||
| 2469 | } | ||
| 2470 | |||
| 2471 | static int ehca_reg_bmap_mr_rpages(struct ehca_shca *shca, | ||
| 2472 | struct ehca_mr *e_mr, | ||
| 2473 | struct ehca_mr_pginfo *pginfo) | ||
| 2474 | { | ||
| 2475 | int top; | ||
| 2476 | u64 hret, *kpage; | ||
| 2477 | |||
| 2478 | kpage = ehca_alloc_fw_ctrlblock(GFP_KERNEL); | ||
| 2479 | if (!kpage) { | ||
| 2480 | ehca_err(&shca->ib_device, "kpage alloc failed"); | ||
| 2481 | return -ENOMEM; | ||
| 2482 | } | ||
| 2483 | for (top = 0; top < EHCA_MAP_ENTRIES; top++) { | ||
| 2484 | if (!ehca_bmap_valid(ehca_bmap->top[top])) | ||
| 2485 | continue; | ||
| 2486 | hret = ehca_reg_mr_dir_sections(top, kpage, shca, e_mr, pginfo); | ||
| 2487 | if ((hret != H_PAGE_REGISTERED) && (hret != H_SUCCESS)) | ||
| 2488 | break; | ||
| 2489 | } | ||
| 2490 | |||
| 2491 | ehca_free_fw_ctrlblock(kpage); | ||
| 2492 | |||
| 2493 | if (hret == H_SUCCESS) | ||
| 2494 | return 0; /* Everything is fine */ | ||
| 2495 | else { | ||
| 2496 | ehca_err(&shca->ib_device, "ehca_reg_bmap_mr_rpages failed, " | ||
| 2497 | "h_ret=%lli e_mr=%p top=%x lkey=%x " | ||
| 2498 | "hca_hndl=%llx mr_hndl=%llx", hret, e_mr, top, | ||
| 2499 | e_mr->ib.ib_mr.lkey, | ||
| 2500 | shca->ipz_hca_handle.handle, | ||
| 2501 | e_mr->ipz_mr_handle.handle); | ||
| 2502 | return ehca2ib_return_code(hret); | ||
| 2503 | } | ||
| 2504 | } | ||
| 2505 | |||
| 2506 | static u64 ehca_map_vaddr(void *caddr) | ||
| 2507 | { | ||
| 2508 | int top, dir, idx; | ||
| 2509 | unsigned long abs_addr, offset; | ||
| 2510 | u64 entry; | ||
| 2511 | |||
| 2512 | if (!ehca_bmap) | ||
| 2513 | return EHCA_INVAL_ADDR; | ||
| 2514 | |||
| 2515 | abs_addr = virt_to_abs(caddr); | ||
| 2516 | top = ehca_calc_index(abs_addr, EHCA_TOP_INDEX_SHIFT + EHCA_SECTSHIFT); | ||
| 2517 | if (!ehca_bmap_valid(ehca_bmap->top[top])) | ||
| 2518 | return EHCA_INVAL_ADDR; | ||
| 2519 | |||
| 2520 | dir = ehca_calc_index(abs_addr, EHCA_DIR_INDEX_SHIFT + EHCA_SECTSHIFT); | ||
| 2521 | if (!ehca_bmap_valid(ehca_bmap->top[top]->dir[dir])) | ||
| 2522 | return EHCA_INVAL_ADDR; | ||
| 2523 | |||
| 2524 | idx = ehca_calc_index(abs_addr, EHCA_SECTSHIFT); | ||
| 2525 | |||
| 2526 | entry = ehca_bmap->top[top]->dir[dir]->ent[idx]; | ||
| 2527 | if (ehca_bmap_valid(entry)) { | ||
| 2528 | offset = (unsigned long)caddr & (EHCA_SECTSIZE - 1); | ||
| 2529 | return entry | offset; | ||
| 2530 | } else | ||
| 2531 | return EHCA_INVAL_ADDR; | ||
| 2532 | } | ||
| 2533 | |||
| 2534 | static int ehca_dma_mapping_error(struct ib_device *dev, u64 dma_addr) | ||
| 2535 | { | ||
| 2536 | return dma_addr == EHCA_INVAL_ADDR; | ||
| 2537 | } | ||
| 2538 | |||
| 2539 | static u64 ehca_dma_map_single(struct ib_device *dev, void *cpu_addr, | ||
| 2540 | size_t size, enum dma_data_direction direction) | ||
| 2541 | { | ||
| 2542 | if (cpu_addr) | ||
| 2543 | return ehca_map_vaddr(cpu_addr); | ||
| 2544 | else | ||
| 2545 | return EHCA_INVAL_ADDR; | ||
| 2546 | } | ||
| 2547 | |||
| 2548 | static void ehca_dma_unmap_single(struct ib_device *dev, u64 addr, size_t size, | ||
| 2549 | enum dma_data_direction direction) | ||
| 2550 | { | ||
| 2551 | /* This is only a stub; nothing to be done here */ | ||
| 2552 | } | ||
| 2553 | |||
| 2554 | static u64 ehca_dma_map_page(struct ib_device *dev, struct page *page, | ||
| 2555 | unsigned long offset, size_t size, | ||
| 2556 | enum dma_data_direction direction) | ||
| 2557 | { | ||
| 2558 | u64 addr; | ||
| 2559 | |||
| 2560 | if (offset + size > PAGE_SIZE) | ||
| 2561 | return EHCA_INVAL_ADDR; | ||
| 2562 | |||
| 2563 | addr = ehca_map_vaddr(page_address(page)); | ||
| 2564 | if (!ehca_dma_mapping_error(dev, addr)) | ||
| 2565 | addr += offset; | ||
| 2566 | |||
| 2567 | return addr; | ||
| 2568 | } | ||
| 2569 | |||
| 2570 | static void ehca_dma_unmap_page(struct ib_device *dev, u64 addr, size_t size, | ||
| 2571 | enum dma_data_direction direction) | ||
| 2572 | { | ||
| 2573 | /* This is only a stub; nothing to be done here */ | ||
| 2574 | } | ||
| 2575 | |||
| 2576 | static int ehca_dma_map_sg(struct ib_device *dev, struct scatterlist *sgl, | ||
| 2577 | int nents, enum dma_data_direction direction) | ||
| 2578 | { | ||
| 2579 | struct scatterlist *sg; | ||
| 2580 | int i; | ||
| 2581 | |||
| 2582 | for_each_sg(sgl, sg, nents, i) { | ||
| 2583 | u64 addr; | ||
| 2584 | addr = ehca_map_vaddr(sg_virt(sg)); | ||
| 2585 | if (ehca_dma_mapping_error(dev, addr)) | ||
| 2586 | return 0; | ||
| 2587 | |||
| 2588 | sg->dma_address = addr; | ||
| 2589 | sg->dma_length = sg->length; | ||
| 2590 | } | ||
| 2591 | return nents; | ||
| 2592 | } | ||
| 2593 | |||
| 2594 | static void ehca_dma_unmap_sg(struct ib_device *dev, struct scatterlist *sg, | ||
| 2595 | int nents, enum dma_data_direction direction) | ||
| 2596 | { | ||
| 2597 | /* This is only a stub; nothing to be done here */ | ||
| 2598 | } | ||
| 2599 | |||
| 2600 | static u64 ehca_dma_address(struct ib_device *dev, struct scatterlist *sg) | ||
| 2601 | { | ||
| 2602 | return sg->dma_address; | ||
| 2603 | } | ||
| 2604 | |||
| 2605 | static unsigned int ehca_dma_len(struct ib_device *dev, struct scatterlist *sg) | ||
| 2606 | { | ||
| 2607 | return sg->length; | ||
| 2608 | } | ||
| 2609 | |||
| 2610 | static void ehca_dma_sync_single_for_cpu(struct ib_device *dev, u64 addr, | ||
| 2611 | size_t size, | ||
| 2612 | enum dma_data_direction dir) | ||
| 2613 | { | ||
| 2614 | dma_sync_single_for_cpu(dev->dma_device, addr, size, dir); | ||
| 2615 | } | ||
| 2616 | |||
| 2617 | static void ehca_dma_sync_single_for_device(struct ib_device *dev, u64 addr, | ||
| 2618 | size_t size, | ||
| 2619 | enum dma_data_direction dir) | ||
| 2620 | { | ||
| 2621 | dma_sync_single_for_device(dev->dma_device, addr, size, dir); | ||
| 2622 | } | ||
| 2623 | |||
| 2624 | static void *ehca_dma_alloc_coherent(struct ib_device *dev, size_t size, | ||
| 2625 | u64 *dma_handle, gfp_t flag) | ||
| 2626 | { | ||
| 2627 | struct page *p; | ||
| 2628 | void *addr = NULL; | ||
| 2629 | u64 dma_addr; | ||
| 2630 | |||
| 2631 | p = alloc_pages(flag, get_order(size)); | ||
| 2632 | if (p) { | ||
| 2633 | addr = page_address(p); | ||
| 2634 | dma_addr = ehca_map_vaddr(addr); | ||
| 2635 | if (ehca_dma_mapping_error(dev, dma_addr)) { | ||
| 2636 | free_pages((unsigned long)addr, get_order(size)); | ||
| 2637 | return NULL; | ||
| 2638 | } | ||
| 2639 | if (dma_handle) | ||
| 2640 | *dma_handle = dma_addr; | ||
| 2641 | return addr; | ||
| 2642 | } | ||
| 2643 | return NULL; | ||
| 2644 | } | ||
| 2645 | |||
| 2646 | static void ehca_dma_free_coherent(struct ib_device *dev, size_t size, | ||
| 2647 | void *cpu_addr, u64 dma_handle) | ||
| 2648 | { | ||
| 2649 | if (cpu_addr && size) | ||
| 2650 | free_pages((unsigned long)cpu_addr, get_order(size)); | ||
| 2651 | } | ||
| 2652 | |||
| 2653 | |||
| 2654 | struct ib_dma_mapping_ops ehca_dma_mapping_ops = { | ||
| 2655 | .mapping_error = ehca_dma_mapping_error, | ||
| 2656 | .map_single = ehca_dma_map_single, | ||
| 2657 | .unmap_single = ehca_dma_unmap_single, | ||
| 2658 | .map_page = ehca_dma_map_page, | ||
| 2659 | .unmap_page = ehca_dma_unmap_page, | ||
| 2660 | .map_sg = ehca_dma_map_sg, | ||
| 2661 | .unmap_sg = ehca_dma_unmap_sg, | ||
| 2662 | .dma_address = ehca_dma_address, | ||
| 2663 | .dma_len = ehca_dma_len, | ||
| 2664 | .sync_single_for_cpu = ehca_dma_sync_single_for_cpu, | ||
| 2665 | .sync_single_for_device = ehca_dma_sync_single_for_device, | ||
| 2666 | .alloc_coherent = ehca_dma_alloc_coherent, | ||
| 2667 | .free_coherent = ehca_dma_free_coherent, | ||
| 2668 | }; | ||
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.h b/drivers/infiniband/hw/ehca/ehca_mrmw.h index bc8f4e31c123..50d8b51306dd 100644 --- a/drivers/infiniband/hw/ehca/ehca_mrmw.h +++ b/drivers/infiniband/hw/ehca/ehca_mrmw.h | |||
| @@ -42,6 +42,11 @@ | |||
| 42 | #ifndef _EHCA_MRMW_H_ | 42 | #ifndef _EHCA_MRMW_H_ |
| 43 | #define _EHCA_MRMW_H_ | 43 | #define _EHCA_MRMW_H_ |
| 44 | 44 | ||
| 45 | enum ehca_reg_type { | ||
| 46 | EHCA_REG_MR, | ||
| 47 | EHCA_REG_BUSMAP_MR | ||
| 48 | }; | ||
| 49 | |||
| 45 | int ehca_reg_mr(struct ehca_shca *shca, | 50 | int ehca_reg_mr(struct ehca_shca *shca, |
| 46 | struct ehca_mr *e_mr, | 51 | struct ehca_mr *e_mr, |
| 47 | u64 *iova_start, | 52 | u64 *iova_start, |
| @@ -50,7 +55,8 @@ int ehca_reg_mr(struct ehca_shca *shca, | |||
| 50 | struct ehca_pd *e_pd, | 55 | struct ehca_pd *e_pd, |
| 51 | struct ehca_mr_pginfo *pginfo, | 56 | struct ehca_mr_pginfo *pginfo, |
| 52 | u32 *lkey, | 57 | u32 *lkey, |
| 53 | u32 *rkey); | 58 | u32 *rkey, |
| 59 | enum ehca_reg_type reg_type); | ||
| 54 | 60 | ||
| 55 | int ehca_reg_mr_rpages(struct ehca_shca *shca, | 61 | int ehca_reg_mr_rpages(struct ehca_shca *shca, |
| 56 | struct ehca_mr *e_mr, | 62 | struct ehca_mr *e_mr, |
| @@ -118,4 +124,9 @@ void ehca_mrmw_reverse_map_acl(const u32 *hipz_acl, | |||
| 118 | 124 | ||
| 119 | void ehca_mr_deletenew(struct ehca_mr *mr); | 125 | void ehca_mr_deletenew(struct ehca_mr *mr); |
| 120 | 126 | ||
| 127 | int ehca_create_busmap(void); | ||
| 128 | |||
| 129 | void ehca_destroy_busmap(void); | ||
| 130 | |||
| 131 | extern struct ib_dma_mapping_ops ehca_dma_mapping_ops; | ||
| 121 | #endif /*_EHCA_MRMW_H_*/ | 132 | #endif /*_EHCA_MRMW_H_*/ |
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c index d606edf10858..065b20899876 100644 --- a/drivers/infiniband/hw/mthca/mthca_mr.c +++ b/drivers/infiniband/hw/mthca/mthca_mr.c | |||
| @@ -352,10 +352,14 @@ static void mthca_arbel_write_mtt_seg(struct mthca_dev *dev, | |||
| 352 | 352 | ||
| 353 | BUG_ON(!mtts); | 353 | BUG_ON(!mtts); |
| 354 | 354 | ||
| 355 | dma_sync_single_for_cpu(&dev->pdev->dev, dma_handle, | ||
| 356 | list_len * sizeof (u64), DMA_TO_DEVICE); | ||
| 357 | |||
| 355 | for (i = 0; i < list_len; ++i) | 358 | for (i = 0; i < list_len; ++i) |
| 356 | mtts[i] = cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT); | 359 | mtts[i] = cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT); |
| 357 | 360 | ||
| 358 | dma_sync_single(&dev->pdev->dev, dma_handle, list_len * sizeof (u64), DMA_TO_DEVICE); | 361 | dma_sync_single_for_device(&dev->pdev->dev, dma_handle, |
| 362 | list_len * sizeof (u64), DMA_TO_DEVICE); | ||
| 359 | } | 363 | } |
| 360 | 364 | ||
| 361 | int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, | 365 | int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, |
| @@ -803,12 +807,15 @@ int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, | |||
| 803 | 807 | ||
| 804 | wmb(); | 808 | wmb(); |
| 805 | 809 | ||
| 810 | dma_sync_single_for_cpu(&dev->pdev->dev, fmr->mem.arbel.dma_handle, | ||
| 811 | list_len * sizeof(u64), DMA_TO_DEVICE); | ||
| 812 | |||
| 806 | for (i = 0; i < list_len; ++i) | 813 | for (i = 0; i < list_len; ++i) |
| 807 | fmr->mem.arbel.mtts[i] = cpu_to_be64(page_list[i] | | 814 | fmr->mem.arbel.mtts[i] = cpu_to_be64(page_list[i] | |
| 808 | MTHCA_MTT_FLAG_PRESENT); | 815 | MTHCA_MTT_FLAG_PRESENT); |
| 809 | 816 | ||
| 810 | dma_sync_single(&dev->pdev->dev, fmr->mem.arbel.dma_handle, | 817 | dma_sync_single_for_device(&dev->pdev->dev, fmr->mem.arbel.dma_handle, |
| 811 | list_len * sizeof(u64), DMA_TO_DEVICE); | 818 | list_len * sizeof(u64), DMA_TO_DEVICE); |
| 812 | 819 | ||
| 813 | fmr->mem.arbel.mpt->key = cpu_to_be32(key); | 820 | fmr->mem.arbel.mpt->key = cpu_to_be32(key); |
| 814 | fmr->mem.arbel.mpt->lkey = cpu_to_be32(key); | 821 | fmr->mem.arbel.mpt->lkey = cpu_to_be32(key); |
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c index 11c7d6642014..114b802771ad 100644 --- a/drivers/infiniband/hw/nes/nes_cm.c +++ b/drivers/infiniband/hw/nes/nes_cm.c | |||
| @@ -472,6 +472,7 @@ int schedule_nes_timer(struct nes_cm_node *cm_node, struct sk_buff *skb, | |||
| 472 | 472 | ||
| 473 | static void nes_retrans_expired(struct nes_cm_node *cm_node) | 473 | static void nes_retrans_expired(struct nes_cm_node *cm_node) |
| 474 | { | 474 | { |
| 475 | struct iw_cm_id *cm_id = cm_node->cm_id; | ||
| 475 | switch (cm_node->state) { | 476 | switch (cm_node->state) { |
| 476 | case NES_CM_STATE_SYN_RCVD: | 477 | case NES_CM_STATE_SYN_RCVD: |
| 477 | case NES_CM_STATE_CLOSING: | 478 | case NES_CM_STATE_CLOSING: |
| @@ -479,7 +480,9 @@ static void nes_retrans_expired(struct nes_cm_node *cm_node) | |||
| 479 | break; | 480 | break; |
| 480 | case NES_CM_STATE_LAST_ACK: | 481 | case NES_CM_STATE_LAST_ACK: |
| 481 | case NES_CM_STATE_FIN_WAIT1: | 482 | case NES_CM_STATE_FIN_WAIT1: |
| 482 | case NES_CM_STATE_MPAREJ_RCVD: | 483 | if (cm_node->cm_id) |
| 484 | cm_id->rem_ref(cm_id); | ||
| 485 | cm_node->state = NES_CM_STATE_CLOSED; | ||
| 483 | send_reset(cm_node, NULL); | 486 | send_reset(cm_node, NULL); |
| 484 | break; | 487 | break; |
| 485 | default: | 488 | default: |
| @@ -1406,6 +1409,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb, | |||
| 1406 | case NES_CM_STATE_CLOSED: | 1409 | case NES_CM_STATE_CLOSED: |
| 1407 | drop_packet(skb); | 1410 | drop_packet(skb); |
| 1408 | break; | 1411 | break; |
| 1412 | case NES_CM_STATE_FIN_WAIT1: | ||
| 1409 | case NES_CM_STATE_LAST_ACK: | 1413 | case NES_CM_STATE_LAST_ACK: |
| 1410 | cm_node->cm_id->rem_ref(cm_node->cm_id); | 1414 | cm_node->cm_id->rem_ref(cm_node->cm_id); |
| 1411 | case NES_CM_STATE_TIME_WAIT: | 1415 | case NES_CM_STATE_TIME_WAIT: |
| @@ -1413,8 +1417,6 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb, | |||
| 1413 | rem_ref_cm_node(cm_node->cm_core, cm_node); | 1417 | rem_ref_cm_node(cm_node->cm_core, cm_node); |
| 1414 | drop_packet(skb); | 1418 | drop_packet(skb); |
| 1415 | break; | 1419 | break; |
| 1416 | case NES_CM_STATE_FIN_WAIT1: | ||
| 1417 | nes_debug(NES_DBG_CM, "Bad state %s[%u]\n", __func__, __LINE__); | ||
| 1418 | default: | 1420 | default: |
| 1419 | drop_packet(skb); | 1421 | drop_packet(skb); |
| 1420 | break; | 1422 | break; |
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index 64d5cfd8f380..21e0fd336cf7 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c | |||
| @@ -654,7 +654,7 @@ static int nes_query_device(struct ib_device *ibdev, struct ib_device_attr *prop | |||
| 654 | default: | 654 | default: |
| 655 | props->max_qp_rd_atom = 0; | 655 | props->max_qp_rd_atom = 0; |
| 656 | } | 656 | } |
| 657 | props->max_qp_init_rd_atom = props->max_qp_wr; | 657 | props->max_qp_init_rd_atom = props->max_qp_rd_atom; |
| 658 | props->atomic_cap = IB_ATOMIC_NONE; | 658 | props->atomic_cap = IB_ATOMIC_NONE; |
| 659 | props->max_map_per_fmr = 1; | 659 | props->max_map_per_fmr = 1; |
| 660 | 660 | ||
diff --git a/drivers/media/common/ir-keymaps.c b/drivers/media/common/ir-keymaps.c index 3fe158ac7bbf..4216328552f6 100644 --- a/drivers/media/common/ir-keymaps.c +++ b/drivers/media/common/ir-keymaps.c | |||
| @@ -2750,3 +2750,26 @@ IR_KEYTAB_TYPE ir_codes_dm1105_nec[IR_KEYTAB_SIZE] = { | |||
| 2750 | [0x1b] = KEY_B, /*recall*/ | 2750 | [0x1b] = KEY_B, /*recall*/ |
| 2751 | }; | 2751 | }; |
| 2752 | EXPORT_SYMBOL_GPL(ir_codes_dm1105_nec); | 2752 | EXPORT_SYMBOL_GPL(ir_codes_dm1105_nec); |
| 2753 | |||
| 2754 | /* EVGA inDtube | ||
| 2755 | Devin Heitmueller <devin.heitmueller@gmail.com> | ||
| 2756 | */ | ||
| 2757 | IR_KEYTAB_TYPE ir_codes_evga_indtube[IR_KEYTAB_SIZE] = { | ||
| 2758 | [0x12] = KEY_POWER, | ||
| 2759 | [0x02] = KEY_MODE, /* TV */ | ||
| 2760 | [0x14] = KEY_MUTE, | ||
| 2761 | [0x1a] = KEY_CHANNELUP, | ||
| 2762 | [0x16] = KEY_TV2, /* PIP */ | ||
| 2763 | [0x1d] = KEY_VOLUMEUP, | ||
| 2764 | [0x05] = KEY_CHANNELDOWN, | ||
| 2765 | [0x0f] = KEY_PLAYPAUSE, | ||
| 2766 | [0x19] = KEY_VOLUMEDOWN, | ||
| 2767 | [0x1c] = KEY_REWIND, | ||
| 2768 | [0x0d] = KEY_RECORD, | ||
| 2769 | [0x18] = KEY_FORWARD, | ||
| 2770 | [0x1e] = KEY_PREVIOUS, | ||
| 2771 | [0x1b] = KEY_STOP, | ||
| 2772 | [0x1f] = KEY_NEXT, | ||
| 2773 | [0x13] = KEY_CAMERA, | ||
| 2774 | }; | ||
| 2775 | EXPORT_SYMBOL_GPL(ir_codes_evga_indtube); | ||
diff --git a/drivers/media/dvb/frontends/stv0900.h b/drivers/media/dvb/frontends/stv0900.h index 8a1332c2031d..bf4e9b633044 100644 --- a/drivers/media/dvb/frontends/stv0900.h +++ b/drivers/media/dvb/frontends/stv0900.h | |||
| @@ -29,6 +29,11 @@ | |||
| 29 | #include <linux/dvb/frontend.h> | 29 | #include <linux/dvb/frontend.h> |
| 30 | #include "dvb_frontend.h" | 30 | #include "dvb_frontend.h" |
| 31 | 31 | ||
| 32 | struct stv0900_reg { | ||
| 33 | u16 addr; | ||
| 34 | u8 val; | ||
| 35 | }; | ||
| 36 | |||
| 32 | struct stv0900_config { | 37 | struct stv0900_config { |
| 33 | u8 demod_address; | 38 | u8 demod_address; |
| 34 | u32 xtal; | 39 | u32 xtal; |
| @@ -38,7 +43,7 @@ struct stv0900_config { | |||
| 38 | 43 | ||
| 39 | u8 path1_mode; | 44 | u8 path1_mode; |
| 40 | u8 path2_mode; | 45 | u8 path2_mode; |
| 41 | 46 | struct stv0900_reg *ts_config_regs; | |
| 42 | u8 tun1_maddress;/* 0, 1, 2, 3 for 0xc0, 0xc2, 0xc4, 0xc6 */ | 47 | u8 tun1_maddress;/* 0, 1, 2, 3 for 0xc0, 0xc2, 0xc4, 0xc6 */ |
| 43 | u8 tun2_maddress; | 48 | u8 tun2_maddress; |
| 44 | u8 tun1_adc;/* 1 for stv6110, 2 for stb6100 */ | 49 | u8 tun1_adc;/* 1 for stv6110, 2 for stb6100 */ |
diff --git a/drivers/media/dvb/frontends/stv0900_core.c b/drivers/media/dvb/frontends/stv0900_core.c index 8499bcf7f251..1da045fbb4ef 100644 --- a/drivers/media/dvb/frontends/stv0900_core.c +++ b/drivers/media/dvb/frontends/stv0900_core.c | |||
| @@ -149,31 +149,31 @@ void stv0900_write_reg(struct stv0900_internal *i_params, u16 reg_addr, | |||
| 149 | dprintk(KERN_ERR "%s: i2c error %d\n", __func__, ret); | 149 | dprintk(KERN_ERR "%s: i2c error %d\n", __func__, ret); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | u8 stv0900_read_reg(struct stv0900_internal *i_params, u16 reg_addr) | 152 | u8 stv0900_read_reg(struct stv0900_internal *i_params, u16 reg) |
| 153 | { | 153 | { |
| 154 | u8 data[2]; | ||
| 155 | int ret; | 154 | int ret; |
| 156 | struct i2c_msg i2cmsg = { | 155 | u8 b0[] = { MSB(reg), LSB(reg) }; |
| 157 | .addr = i_params->i2c_addr, | 156 | u8 buf = 0; |
| 158 | .flags = 0, | 157 | struct i2c_msg msg[] = { |
| 159 | .len = 2, | 158 | { |
| 160 | .buf = data, | 159 | .addr = i_params->i2c_addr, |
| 160 | .flags = 0, | ||
| 161 | .buf = b0, | ||
| 162 | .len = 2, | ||
| 163 | }, { | ||
| 164 | .addr = i_params->i2c_addr, | ||
| 165 | .flags = I2C_M_RD, | ||
| 166 | .buf = &buf, | ||
| 167 | .len = 1, | ||
| 168 | }, | ||
| 161 | }; | 169 | }; |
| 162 | 170 | ||
| 163 | data[0] = MSB(reg_addr); | 171 | ret = i2c_transfer(i_params->i2c_adap, msg, 2); |
| 164 | data[1] = LSB(reg_addr); | 172 | if (ret != 2) |
| 165 | 173 | dprintk(KERN_ERR "%s: i2c error %d, reg[0x%02x]\n", | |
| 166 | ret = i2c_transfer(i_params->i2c_adap, &i2cmsg, 1); | 174 | __func__, ret, reg); |
| 167 | if (ret != 1) | ||
| 168 | dprintk(KERN_ERR "%s: i2c error %d\n", __func__, ret); | ||
| 169 | |||
| 170 | i2cmsg.flags = I2C_M_RD; | ||
| 171 | i2cmsg.len = 1; | ||
| 172 | ret = i2c_transfer(i_params->i2c_adap, &i2cmsg, 1); | ||
| 173 | if (ret != 1) | ||
| 174 | dprintk(KERN_ERR "%s: i2c error %d\n", __func__, ret); | ||
| 175 | 175 | ||
| 176 | return data[0]; | 176 | return buf; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | void extract_mask_pos(u32 label, u8 *mask, u8 *pos) | 179 | void extract_mask_pos(u32 label, u8 *mask, u8 *pos) |
| @@ -712,6 +712,44 @@ static s32 stv0900_carr_get_quality(struct dvb_frontend *fe, | |||
| 712 | return c_n; | 712 | return c_n; |
| 713 | } | 713 | } |
| 714 | 714 | ||
| 715 | static int stv0900_read_ucblocks(struct dvb_frontend *fe, u32 * ucblocks) | ||
| 716 | { | ||
| 717 | struct stv0900_state *state = fe->demodulator_priv; | ||
| 718 | struct stv0900_internal *i_params = state->internal; | ||
| 719 | enum fe_stv0900_demod_num demod = state->demod; | ||
| 720 | u8 err_val1, err_val0; | ||
| 721 | s32 err_field1, err_field0; | ||
| 722 | u32 header_err_val = 0; | ||
| 723 | |||
| 724 | *ucblocks = 0x0; | ||
| 725 | if (stv0900_get_standard(fe, demod) == STV0900_DVBS2_STANDARD) { | ||
| 726 | /* DVB-S2 delineator errors count */ | ||
| 727 | |||
| 728 | /* retreiving number for errnous headers */ | ||
| 729 | dmd_reg(err_field0, R0900_P1_BBFCRCKO0, | ||
| 730 | R0900_P2_BBFCRCKO0); | ||
| 731 | dmd_reg(err_field1, R0900_P1_BBFCRCKO1, | ||
| 732 | R0900_P2_BBFCRCKO1); | ||
| 733 | |||
| 734 | err_val1 = stv0900_read_reg(i_params, err_field1); | ||
| 735 | err_val0 = stv0900_read_reg(i_params, err_field0); | ||
| 736 | header_err_val = (err_val1<<8) | err_val0; | ||
| 737 | |||
| 738 | /* retreiving number for errnous packets */ | ||
| 739 | dmd_reg(err_field0, R0900_P1_UPCRCKO0, | ||
| 740 | R0900_P2_UPCRCKO0); | ||
| 741 | dmd_reg(err_field1, R0900_P1_UPCRCKO1, | ||
| 742 | R0900_P2_UPCRCKO1); | ||
| 743 | |||
| 744 | err_val1 = stv0900_read_reg(i_params, err_field1); | ||
| 745 | err_val0 = stv0900_read_reg(i_params, err_field0); | ||
| 746 | *ucblocks = (err_val1<<8) | err_val0; | ||
| 747 | *ucblocks += header_err_val; | ||
| 748 | } | ||
| 749 | |||
| 750 | return 0; | ||
| 751 | } | ||
| 752 | |||
| 715 | static int stv0900_read_snr(struct dvb_frontend *fe, u16 *snr) | 753 | static int stv0900_read_snr(struct dvb_frontend *fe, u16 *snr) |
| 716 | { | 754 | { |
| 717 | *snr = stv0900_carr_get_quality(fe, | 755 | *snr = stv0900_carr_get_quality(fe, |
| @@ -1355,7 +1393,7 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe, | |||
| 1355 | struct stv0900_state *state = fe->demodulator_priv; | 1393 | struct stv0900_state *state = fe->demodulator_priv; |
| 1356 | enum fe_stv0900_error error = STV0900_NO_ERROR; | 1394 | enum fe_stv0900_error error = STV0900_NO_ERROR; |
| 1357 | enum fe_stv0900_error demodError = STV0900_NO_ERROR; | 1395 | enum fe_stv0900_error demodError = STV0900_NO_ERROR; |
| 1358 | int selosci; | 1396 | int selosci, i; |
| 1359 | 1397 | ||
| 1360 | struct stv0900_inode *temp_int = find_inode(state->i2c_adap, | 1398 | struct stv0900_inode *temp_int = find_inode(state->i2c_adap, |
| 1361 | state->config->demod_address); | 1399 | state->config->demod_address); |
| @@ -1402,7 +1440,23 @@ static enum fe_stv0900_error stv0900_init_internal(struct dvb_frontend *fe, | |||
| 1402 | stv0900_write_bits(state->internal, F0900_P1_ROLLOFF_CONTROL, p_init->rolloff); | 1440 | stv0900_write_bits(state->internal, F0900_P1_ROLLOFF_CONTROL, p_init->rolloff); |
| 1403 | stv0900_write_bits(state->internal, F0900_P2_ROLLOFF_CONTROL, p_init->rolloff); | 1441 | stv0900_write_bits(state->internal, F0900_P2_ROLLOFF_CONTROL, p_init->rolloff); |
| 1404 | 1442 | ||
| 1405 | stv0900_set_ts_parallel_serial(state->internal, p_init->path1_ts_clock, p_init->path2_ts_clock); | 1443 | state->internal->ts_config = p_init->ts_config; |
| 1444 | if (state->internal->ts_config == NULL) | ||
| 1445 | stv0900_set_ts_parallel_serial(state->internal, | ||
| 1446 | p_init->path1_ts_clock, | ||
| 1447 | p_init->path2_ts_clock); | ||
| 1448 | else { | ||
| 1449 | for (i = 0; state->internal->ts_config[i].addr != 0xffff; i++) | ||
| 1450 | stv0900_write_reg(state->internal, | ||
| 1451 | state->internal->ts_config[i].addr, | ||
| 1452 | state->internal->ts_config[i].val); | ||
| 1453 | |||
| 1454 | stv0900_write_bits(state->internal, F0900_P2_RST_HWARE, 1); | ||
| 1455 | stv0900_write_bits(state->internal, F0900_P2_RST_HWARE, 0); | ||
| 1456 | stv0900_write_bits(state->internal, F0900_P1_RST_HWARE, 1); | ||
| 1457 | stv0900_write_bits(state->internal, F0900_P1_RST_HWARE, 0); | ||
| 1458 | } | ||
| 1459 | |||
| 1406 | stv0900_write_bits(state->internal, F0900_P1_TUN_MADDRESS, p_init->tun1_maddress); | 1460 | stv0900_write_bits(state->internal, F0900_P1_TUN_MADDRESS, p_init->tun1_maddress); |
| 1407 | switch (p_init->tuner1_adc) { | 1461 | switch (p_init->tuner1_adc) { |
| 1408 | case 1: | 1462 | case 1: |
| @@ -1882,6 +1936,7 @@ static struct dvb_frontend_ops stv0900_ops = { | |||
| 1882 | .read_ber = stv0900_read_ber, | 1936 | .read_ber = stv0900_read_ber, |
| 1883 | .read_signal_strength = stv0900_read_signal_strength, | 1937 | .read_signal_strength = stv0900_read_signal_strength, |
| 1884 | .read_snr = stv0900_read_snr, | 1938 | .read_snr = stv0900_read_snr, |
| 1939 | .read_ucblocks = stv0900_read_ucblocks, | ||
| 1885 | }; | 1940 | }; |
| 1886 | 1941 | ||
| 1887 | struct dvb_frontend *stv0900_attach(const struct stv0900_config *config, | 1942 | struct dvb_frontend *stv0900_attach(const struct stv0900_config *config, |
| @@ -1915,6 +1970,7 @@ struct dvb_frontend *stv0900_attach(const struct stv0900_config *config, | |||
| 1915 | init_params.tun1_iq_inversion = STV0900_IQ_NORMAL; | 1970 | init_params.tun1_iq_inversion = STV0900_IQ_NORMAL; |
| 1916 | init_params.tuner1_adc = config->tun1_adc; | 1971 | init_params.tuner1_adc = config->tun1_adc; |
| 1917 | init_params.path2_ts_clock = config->path2_mode; | 1972 | init_params.path2_ts_clock = config->path2_mode; |
| 1973 | init_params.ts_config = config->ts_config_regs; | ||
| 1918 | init_params.tun2_maddress = config->tun2_maddress; | 1974 | init_params.tun2_maddress = config->tun2_maddress; |
| 1919 | init_params.tuner2_adc = config->tun2_adc; | 1975 | init_params.tuner2_adc = config->tun2_adc; |
| 1920 | init_params.tun2_iq_inversion = STV0900_IQ_SWAPPED; | 1976 | init_params.tun2_iq_inversion = STV0900_IQ_SWAPPED; |
diff --git a/drivers/media/dvb/frontends/stv0900_priv.h b/drivers/media/dvb/frontends/stv0900_priv.h index 67dc8ec634e2..5ed7a145c7d3 100644 --- a/drivers/media/dvb/frontends/stv0900_priv.h +++ b/drivers/media/dvb/frontends/stv0900_priv.h | |||
| @@ -271,6 +271,7 @@ struct stv0900_init_params{ | |||
| 271 | 271 | ||
| 272 | /* IQ from the tuner2 to the demod */ | 272 | /* IQ from the tuner2 to the demod */ |
| 273 | enum stv0900_iq_inversion tun2_iq_inversion; | 273 | enum stv0900_iq_inversion tun2_iq_inversion; |
| 274 | struct stv0900_reg *ts_config; | ||
| 274 | }; | 275 | }; |
| 275 | 276 | ||
| 276 | struct stv0900_search_params { | 277 | struct stv0900_search_params { |
| @@ -363,6 +364,7 @@ struct stv0900_internal{ | |||
| 363 | u8 i2c_addr; | 364 | u8 i2c_addr; |
| 364 | u8 clkmode;/* 0 for CLKI, 2 for XTALI */ | 365 | u8 clkmode;/* 0 for CLKI, 2 for XTALI */ |
| 365 | u8 chip_id; | 366 | u8 chip_id; |
| 367 | struct stv0900_reg *ts_config; | ||
| 366 | enum fe_stv0900_error errs; | 368 | enum fe_stv0900_error errs; |
| 367 | int dmds_used; | 369 | int dmds_used; |
| 368 | }; | 370 | }; |
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index 96ef745a2e4e..488bdfb34fb3 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c | |||
| @@ -2674,7 +2674,7 @@ static u8 stv090x_optimize_carloop(struct stv090x_state *state, enum stv090x_mod | |||
| 2674 | 2674 | ||
| 2675 | static u8 stv090x_optimize_carloop_short(struct stv090x_state *state) | 2675 | static u8 stv090x_optimize_carloop_short(struct stv090x_state *state) |
| 2676 | { | 2676 | { |
| 2677 | struct stv090x_short_frame_crloop *short_crl; | 2677 | struct stv090x_short_frame_crloop *short_crl = NULL; |
| 2678 | s32 index = 0; | 2678 | s32 index = 0; |
| 2679 | u8 aclc = 0x0b; | 2679 | u8 aclc = 0x0b; |
| 2680 | 2680 | ||
| @@ -2694,10 +2694,13 @@ static u8 stv090x_optimize_carloop_short(struct stv090x_state *state) | |||
| 2694 | break; | 2694 | break; |
| 2695 | } | 2695 | } |
| 2696 | 2696 | ||
| 2697 | if (state->dev_ver >= 0x30) | 2697 | if (state->dev_ver >= 0x30) { |
| 2698 | short_crl = stv090x_s2_short_crl_cut20; | 2698 | /* Cut 3.0 and up */ |
| 2699 | else if (state->dev_ver >= 0x20) | ||
| 2700 | short_crl = stv090x_s2_short_crl_cut30; | 2699 | short_crl = stv090x_s2_short_crl_cut30; |
| 2700 | } else { | ||
| 2701 | /* Cut 2.0 and up: we don't support cuts older than 2.0 */ | ||
| 2702 | short_crl = stv090x_s2_short_crl_cut20; | ||
| 2703 | } | ||
| 2701 | 2704 | ||
| 2702 | if (state->srate <= 3000000) | 2705 | if (state->srate <= 3000000) |
| 2703 | aclc = short_crl[index].crl_2; | 2706 | aclc = short_crl[index].crl_2; |
diff --git a/drivers/media/dvb/frontends/tda10048.c b/drivers/media/dvb/frontends/tda10048.c index 4302c563a6b8..cc8862ce4aae 100644 --- a/drivers/media/dvb/frontends/tda10048.c +++ b/drivers/media/dvb/frontends/tda10048.c | |||
| @@ -210,6 +210,7 @@ static struct pll_tab { | |||
| 210 | { TDA10048_CLK_4000, TDA10048_IF_36130, 10, 0, 0 }, | 210 | { TDA10048_CLK_4000, TDA10048_IF_36130, 10, 0, 0 }, |
| 211 | { TDA10048_CLK_16000, TDA10048_IF_3300, 10, 3, 0 }, | 211 | { TDA10048_CLK_16000, TDA10048_IF_3300, 10, 3, 0 }, |
| 212 | { TDA10048_CLK_16000, TDA10048_IF_3500, 10, 3, 0 }, | 212 | { TDA10048_CLK_16000, TDA10048_IF_3500, 10, 3, 0 }, |
| 213 | { TDA10048_CLK_16000, TDA10048_IF_3800, 10, 3, 0 }, | ||
| 213 | { TDA10048_CLK_16000, TDA10048_IF_4000, 10, 3, 0 }, | 214 | { TDA10048_CLK_16000, TDA10048_IF_4000, 10, 3, 0 }, |
| 214 | { TDA10048_CLK_16000, TDA10048_IF_4300, 10, 3, 0 }, | 215 | { TDA10048_CLK_16000, TDA10048_IF_4300, 10, 3, 0 }, |
| 215 | { TDA10048_CLK_16000, TDA10048_IF_36130, 10, 3, 0 }, | 216 | { TDA10048_CLK_16000, TDA10048_IF_36130, 10, 3, 0 }, |
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c index 32be382f0e97..a246903c3341 100644 --- a/drivers/media/dvb/siano/smscoreapi.c +++ b/drivers/media/dvb/siano/smscoreapi.c | |||
| @@ -1422,8 +1422,8 @@ int smscore_gpio_configure(struct smscore_device_t *coredev, u8 PinNum, | |||
| 1422 | struct smscore_gpio_config *pGpioConfig) { | 1422 | struct smscore_gpio_config *pGpioConfig) { |
| 1423 | 1423 | ||
| 1424 | u32 totalLen; | 1424 | u32 totalLen; |
| 1425 | u32 TranslatedPinNum; | 1425 | u32 TranslatedPinNum = 0; |
| 1426 | u32 GroupNum; | 1426 | u32 GroupNum = 0; |
| 1427 | u32 ElectricChar; | 1427 | u32 ElectricChar; |
| 1428 | u32 groupCfg; | 1428 | u32 groupCfg; |
| 1429 | void *buffer; | 1429 | void *buffer; |
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c index 393623818ade..3cd76dddb6aa 100644 --- a/drivers/media/radio/radio-tea5764.c +++ b/drivers/media/radio/radio-tea5764.c | |||
| @@ -322,7 +322,9 @@ static int vidioc_g_tuner(struct file *file, void *priv, | |||
| 322 | v->rangehigh = FREQ_MAX * FREQ_MUL; | 322 | v->rangehigh = FREQ_MAX * FREQ_MUL; |
| 323 | v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; | 323 | v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; |
| 324 | if (r->tunchk & TEA5764_TUNCHK_STEREO) | 324 | if (r->tunchk & TEA5764_TUNCHK_STEREO) |
| 325 | v->rxsubchans = V4L2_TUNER_SUB_STEREO; | 325 | v->rxsubchans = V4L2_TUNER_SUB_STEREO; |
| 326 | else | ||
| 327 | v->rxsubchans = V4L2_TUNER_SUB_MONO; | ||
| 326 | v->audmode = tea5764_get_audout_mode(radio); | 328 | v->audmode = tea5764_get_audout_mode(radio); |
| 327 | v->signal = TEA5764_TUNCHK_LEVEL(r->tunchk) * 0xffff / 0xf; | 329 | v->signal = TEA5764_TUNCHK_LEVEL(r->tunchk) * 0xffff / 0xf; |
| 328 | v->afc = TEA5764_TUNCHK_IFCNT(r->tunchk); | 330 | v->afc = TEA5764_TUNCHK_IFCNT(r->tunchk); |
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 94f440535c64..061e147f6f26 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
| @@ -866,9 +866,13 @@ config USB_W9968CF | |||
| 866 | module will be called w9968cf. | 866 | module will be called w9968cf. |
| 867 | 867 | ||
| 868 | config USB_OV511 | 868 | config USB_OV511 |
| 869 | tristate "USB OV511 Camera support" | 869 | tristate "USB OV511 Camera support (DEPRECATED)" |
| 870 | depends on VIDEO_V4L1 | 870 | depends on VIDEO_V4L1 |
| 871 | ---help--- | 871 | ---help--- |
| 872 | This driver is DEPRECATED please use the gspca ov519 module | ||
| 873 | instead. Note that for the ov511 / ov518 support of the gspca module | ||
| 874 | you need atleast version 0.6.0 of libv4l. | ||
| 875 | |||
| 872 | Say Y here if you want to connect this type of camera to your | 876 | Say Y here if you want to connect this type of camera to your |
| 873 | computer's USB port. See <file:Documentation/video4linux/ov511.txt> | 877 | computer's USB port. See <file:Documentation/video4linux/ov511.txt> |
| 874 | for more information and for a list of supported cameras. | 878 | for more information and for a list of supported cameras. |
diff --git a/drivers/media/video/cx18/cx18-controls.c b/drivers/media/video/cx18/cx18-controls.c index 8e35c3aed544..5136df198338 100644 --- a/drivers/media/video/cx18/cx18-controls.c +++ b/drivers/media/video/cx18/cx18-controls.c | |||
| @@ -61,6 +61,8 @@ int cx18_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qctrl) | |||
| 61 | 61 | ||
| 62 | switch (qctrl->id) { | 62 | switch (qctrl->id) { |
| 63 | /* Standard V4L2 controls */ | 63 | /* Standard V4L2 controls */ |
| 64 | case V4L2_CID_USER_CLASS: | ||
| 65 | return v4l2_ctrl_query_fill(qctrl, 0, 0, 0, 0); | ||
| 64 | case V4L2_CID_BRIGHTNESS: | 66 | case V4L2_CID_BRIGHTNESS: |
| 65 | case V4L2_CID_HUE: | 67 | case V4L2_CID_HUE: |
| 66 | case V4L2_CID_SATURATION: | 68 | case V4L2_CID_SATURATION: |
diff --git a/drivers/media/video/cx231xx/cx231xx-avcore.c b/drivers/media/video/cx231xx/cx231xx-avcore.c index 6a9464079b4c..28f48f41f218 100644 --- a/drivers/media/video/cx231xx/cx231xx-avcore.c +++ b/drivers/media/video/cx231xx/cx231xx-avcore.c | |||
| @@ -1052,22 +1052,13 @@ int cx231xx_set_audio_decoder_input(struct cx231xx *dev, | |||
| 1052 | /* Set resolution of the video */ | 1052 | /* Set resolution of the video */ |
| 1053 | int cx231xx_resolution_set(struct cx231xx *dev) | 1053 | int cx231xx_resolution_set(struct cx231xx *dev) |
| 1054 | { | 1054 | { |
| 1055 | int width, height; | ||
| 1056 | u32 hscale, vscale; | ||
| 1057 | int status = 0; | ||
| 1058 | |||
| 1059 | width = dev->width; | ||
| 1060 | height = dev->height; | ||
| 1061 | |||
| 1062 | get_scale(dev, width, height, &hscale, &vscale); | ||
| 1063 | |||
| 1064 | /* set horzontal scale */ | 1055 | /* set horzontal scale */ |
| 1065 | status = vid_blk_write_word(dev, HSCALE_CTRL, hscale); | 1056 | int status = vid_blk_write_word(dev, HSCALE_CTRL, dev->hscale); |
| 1057 | if (status) | ||
| 1058 | return status; | ||
| 1066 | 1059 | ||
| 1067 | /* set vertical scale */ | 1060 | /* set vertical scale */ |
| 1068 | status = vid_blk_write_word(dev, VSCALE_CTRL, vscale); | 1061 | return vid_blk_write_word(dev, VSCALE_CTRL, dev->vscale); |
| 1069 | |||
| 1070 | return status; | ||
| 1071 | } | 1062 | } |
| 1072 | 1063 | ||
| 1073 | /****************************************************************************** | 1064 | /****************************************************************************** |
| @@ -2055,7 +2046,7 @@ int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type) | |||
| 2055 | 2046 | ||
| 2056 | int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type) | 2047 | int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type) |
| 2057 | { | 2048 | { |
| 2058 | int rc; | 2049 | int rc = -1; |
| 2059 | u32 ep_mask = -1; | 2050 | u32 ep_mask = -1; |
| 2060 | struct pcb_config *pcb_config; | 2051 | struct pcb_config *pcb_config; |
| 2061 | 2052 | ||
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c index a23ae73fe634..609bae6098d3 100644 --- a/drivers/media/video/cx231xx/cx231xx-video.c +++ b/drivers/media/video/cx231xx/cx231xx-video.c | |||
| @@ -893,9 +893,9 @@ static int check_dev(struct cx231xx *dev) | |||
| 893 | return 0; | 893 | return 0; |
| 894 | } | 894 | } |
| 895 | 895 | ||
| 896 | void get_scale(struct cx231xx *dev, | 896 | static void get_scale(struct cx231xx *dev, |
| 897 | unsigned int width, unsigned int height, | 897 | unsigned int width, unsigned int height, |
| 898 | unsigned int *hscale, unsigned int *vscale) | 898 | unsigned int *hscale, unsigned int *vscale) |
| 899 | { | 899 | { |
| 900 | unsigned int maxw = norm_maxw(dev); | 900 | unsigned int maxw = norm_maxw(dev); |
| 901 | unsigned int maxh = norm_maxh(dev); | 901 | unsigned int maxh = norm_maxh(dev); |
| @@ -907,10 +907,6 @@ void get_scale(struct cx231xx *dev, | |||
| 907 | *vscale = (((unsigned long)maxh) << 12) / height - 4096L; | 907 | *vscale = (((unsigned long)maxh) << 12) / height - 4096L; |
| 908 | if (*vscale >= 0x4000) | 908 | if (*vscale >= 0x4000) |
| 909 | *vscale = 0x3fff; | 909 | *vscale = 0x3fff; |
| 910 | |||
| 911 | dev->hscale = *hscale; | ||
| 912 | dev->vscale = *vscale; | ||
| 913 | |||
| 914 | } | 910 | } |
| 915 | 911 | ||
| 916 | /* ------------------------------------------------------------------ | 912 | /* ------------------------------------------------------------------ |
| @@ -955,8 +951,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
| 955 | { | 951 | { |
| 956 | struct cx231xx_fh *fh = priv; | 952 | struct cx231xx_fh *fh = priv; |
| 957 | struct cx231xx *dev = fh->dev; | 953 | struct cx231xx *dev = fh->dev; |
| 958 | int width = f->fmt.pix.width; | 954 | unsigned int width = f->fmt.pix.width; |
| 959 | int height = f->fmt.pix.height; | 955 | unsigned int height = f->fmt.pix.height; |
| 960 | unsigned int maxw = norm_maxw(dev); | 956 | unsigned int maxw = norm_maxw(dev); |
| 961 | unsigned int maxh = norm_maxh(dev); | 957 | unsigned int maxh = norm_maxh(dev); |
| 962 | unsigned int hscale, vscale; | 958 | unsigned int hscale, vscale; |
| @@ -971,17 +967,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
| 971 | 967 | ||
| 972 | /* width must even because of the YUYV format | 968 | /* width must even because of the YUYV format |
| 973 | height must be even because of interlacing */ | 969 | height must be even because of interlacing */ |
| 974 | height &= 0xfffe; | 970 | v4l_bound_align_image(&width, 48, maxw, 1, &height, 32, maxh, 1, 0); |
| 975 | width &= 0xfffe; | ||
| 976 | |||
| 977 | if (unlikely(height < 32)) | ||
| 978 | height = 32; | ||
| 979 | if (unlikely(height > maxh)) | ||
| 980 | height = maxh; | ||
| 981 | if (unlikely(width < 48)) | ||
| 982 | width = 48; | ||
| 983 | if (unlikely(width > maxw)) | ||
| 984 | width = maxw; | ||
| 985 | 971 | ||
| 986 | get_scale(dev, width, height, &hscale, &vscale); | 972 | get_scale(dev, width, height, &hscale, &vscale); |
| 987 | 973 | ||
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h index e38eb2d425f7..a0f823ac6b8d 100644 --- a/drivers/media/video/cx231xx/cx231xx.h +++ b/drivers/media/video/cx231xx/cx231xx.h | |||
| @@ -722,9 +722,6 @@ int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input); | |||
| 722 | int cx231xx_set_decoder_video_input(struct cx231xx *dev, u8 pin_type, u8 input); | 722 | int cx231xx_set_decoder_video_input(struct cx231xx *dev, u8 pin_type, u8 input); |
| 723 | int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev); | 723 | int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev); |
| 724 | int cx231xx_set_audio_input(struct cx231xx *dev, u8 input); | 724 | int cx231xx_set_audio_input(struct cx231xx *dev, u8 input); |
| 725 | void get_scale(struct cx231xx *dev, | ||
| 726 | unsigned int width, unsigned int height, | ||
| 727 | unsigned int *hscale, unsigned int *vscale); | ||
| 728 | 725 | ||
| 729 | /* Provided by cx231xx-video.c */ | 726 | /* Provided by cx231xx-video.c */ |
| 730 | int cx231xx_register_extension(struct cx231xx_ops *dev); | 727 | int cx231xx_register_extension(struct cx231xx_ops *dev); |
diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c index 8ded52946334..4c8e95853fa3 100644 --- a/drivers/media/video/cx2341x.c +++ b/drivers/media/video/cx2341x.c | |||
| @@ -500,6 +500,8 @@ int cx2341x_ctrl_query(const struct cx2341x_mpeg_params *params, | |||
| 500 | int err; | 500 | int err; |
| 501 | 501 | ||
| 502 | switch (qctrl->id) { | 502 | switch (qctrl->id) { |
| 503 | case V4L2_CID_MPEG_CLASS: | ||
| 504 | return v4l2_ctrl_query_fill(qctrl, 0, 0, 0, 0); | ||
| 503 | case V4L2_CID_MPEG_STREAM_TYPE: | 505 | case V4L2_CID_MPEG_STREAM_TYPE: |
| 504 | return v4l2_ctrl_query_fill(qctrl, | 506 | return v4l2_ctrl_query_fill(qctrl, |
| 505 | V4L2_MPEG_STREAM_TYPE_MPEG2_PS, | 507 | V4L2_MPEG_STREAM_TYPE_MPEG2_PS, |
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c index e236df23370e..48a975134ac5 100644 --- a/drivers/media/video/cx23885/cx23885-dvb.c +++ b/drivers/media/video/cx23885/cx23885-dvb.c | |||
| @@ -45,6 +45,7 @@ | |||
| 45 | #include "dibx000_common.h" | 45 | #include "dibx000_common.h" |
| 46 | #include "zl10353.h" | 46 | #include "zl10353.h" |
| 47 | #include "stv0900.h" | 47 | #include "stv0900.h" |
| 48 | #include "stv0900_reg.h" | ||
| 48 | #include "stv6110.h" | 49 | #include "stv6110.h" |
| 49 | #include "lnbh24.h" | 50 | #include "lnbh24.h" |
| 50 | #include "cx24116.h" | 51 | #include "cx24116.h" |
| @@ -242,12 +243,22 @@ static struct tda18271_std_map hauppauge_tda18271_std_map = { | |||
| 242 | .if_lvl = 6, .rfagc_top = 0x37 }, | 243 | .if_lvl = 6, .rfagc_top = 0x37 }, |
| 243 | }; | 244 | }; |
| 244 | 245 | ||
| 246 | static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = { | ||
| 247 | .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4, | ||
| 248 | .if_lvl = 1, .rfagc_top = 0x37, }, | ||
| 249 | .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5, | ||
| 250 | .if_lvl = 1, .rfagc_top = 0x37, }, | ||
| 251 | .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6, | ||
| 252 | .if_lvl = 1, .rfagc_top = 0x37, }, | ||
| 253 | }; | ||
| 254 | |||
| 245 | static struct tda18271_config hauppauge_tda18271_config = { | 255 | static struct tda18271_config hauppauge_tda18271_config = { |
| 246 | .std_map = &hauppauge_tda18271_std_map, | 256 | .std_map = &hauppauge_tda18271_std_map, |
| 247 | .gate = TDA18271_GATE_ANALOG, | 257 | .gate = TDA18271_GATE_ANALOG, |
| 248 | }; | 258 | }; |
| 249 | 259 | ||
| 250 | static struct tda18271_config hauppauge_hvr1200_tuner_config = { | 260 | static struct tda18271_config hauppauge_hvr1200_tuner_config = { |
| 261 | .std_map = &hauppauge_hvr1200_tda18271_std_map, | ||
| 251 | .gate = TDA18271_GATE_ANALOG, | 262 | .gate = TDA18271_GATE_ANALOG, |
| 252 | }; | 263 | }; |
| 253 | 264 | ||
| @@ -370,13 +381,25 @@ static struct zl10353_config dvico_fusionhdtv_xc3028 = { | |||
| 370 | .disable_i2c_gate_ctrl = 1, | 381 | .disable_i2c_gate_ctrl = 1, |
| 371 | }; | 382 | }; |
| 372 | 383 | ||
| 384 | static struct stv0900_reg stv0900_ts_regs[] = { | ||
| 385 | { R0900_TSGENERAL, 0x00 }, | ||
| 386 | { R0900_P1_TSSPEED, 0x40 }, | ||
| 387 | { R0900_P2_TSSPEED, 0x40 }, | ||
| 388 | { R0900_P1_TSCFGM, 0xc0 }, | ||
| 389 | { R0900_P2_TSCFGM, 0xc0 }, | ||
| 390 | { R0900_P1_TSCFGH, 0xe0 }, | ||
| 391 | { R0900_P2_TSCFGH, 0xe0 }, | ||
| 392 | { R0900_P1_TSCFGL, 0x20 }, | ||
| 393 | { R0900_P2_TSCFGL, 0x20 }, | ||
| 394 | { 0xffff, 0xff }, /* terminate */ | ||
| 395 | }; | ||
| 396 | |||
| 373 | static struct stv0900_config netup_stv0900_config = { | 397 | static struct stv0900_config netup_stv0900_config = { |
| 374 | .demod_address = 0x68, | 398 | .demod_address = 0x68, |
| 375 | .xtal = 27000000, | 399 | .xtal = 27000000, |
| 376 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ | 400 | .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ |
| 377 | .diseqc_mode = 2,/* 2/3 PWM */ | 401 | .diseqc_mode = 2,/* 2/3 PWM */ |
| 378 | .path1_mode = 2,/*Serial continues clock */ | 402 | .ts_config_regs = stv0900_ts_regs, |
| 379 | .path2_mode = 2,/*Serial continues clock */ | ||
| 380 | .tun1_maddress = 0,/* 0x60 */ | 403 | .tun1_maddress = 0,/* 0x60 */ |
| 381 | .tun2_maddress = 3,/* 0x63 */ | 404 | .tun2_maddress = 3,/* 0x63 */ |
| 382 | .tun1_adc = 1,/* 1 Vpp */ | 405 | .tun1_adc = 1,/* 1 Vpp */ |
| @@ -736,7 +759,8 @@ static int dvb_register(struct cx23885_tsport *port) | |||
| 736 | if (!dvb_attach(lnbh24_attach, | 759 | if (!dvb_attach(lnbh24_attach, |
| 737 | fe0->dvb.frontend, | 760 | fe0->dvb.frontend, |
| 738 | &i2c_bus->i2c_adap, | 761 | &i2c_bus->i2c_adap, |
| 739 | LNBH24_PCL, 0, 0x09)) | 762 | LNBH24_PCL, |
| 763 | LNBH24_TTX, 0x09)) | ||
| 740 | printk(KERN_ERR | 764 | printk(KERN_ERR |
| 741 | "No LNBH24 found!\n"); | 765 | "No LNBH24 found!\n"); |
| 742 | 766 | ||
| @@ -756,7 +780,8 @@ static int dvb_register(struct cx23885_tsport *port) | |||
| 756 | if (!dvb_attach(lnbh24_attach, | 780 | if (!dvb_attach(lnbh24_attach, |
| 757 | fe0->dvb.frontend, | 781 | fe0->dvb.frontend, |
| 758 | &i2c_bus->i2c_adap, | 782 | &i2c_bus->i2c_adap, |
| 759 | LNBH24_PCL, 0, 0x0a)) | 783 | LNBH24_PCL, |
| 784 | LNBH24_TTX, 0x0a)) | ||
| 760 | printk(KERN_ERR | 785 | printk(KERN_ERR |
| 761 | "No LNBH24 found!\n"); | 786 | "No LNBH24 found!\n"); |
| 762 | 787 | ||
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index 66bbd2e71105..70836af3ab48 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
| @@ -963,15 +963,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
| 963 | } | 963 | } |
| 964 | 964 | ||
| 965 | f->fmt.pix.field = field; | 965 | f->fmt.pix.field = field; |
| 966 | if (f->fmt.pix.height < 32) | 966 | v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, |
| 967 | f->fmt.pix.height = 32; | 967 | &f->fmt.pix.height, 32, maxh, 0, 0); |
| 968 | if (f->fmt.pix.height > maxh) | ||
| 969 | f->fmt.pix.height = maxh; | ||
| 970 | if (f->fmt.pix.width < 48) | ||
| 971 | f->fmt.pix.width = 48; | ||
| 972 | if (f->fmt.pix.width > maxw) | ||
| 973 | f->fmt.pix.width = maxw; | ||
| 974 | f->fmt.pix.width &= ~0x03; | ||
| 975 | f->fmt.pix.bytesperline = | 968 | f->fmt.pix.bytesperline = |
| 976 | (f->fmt.pix.width * fmt->depth) >> 3; | 969 | (f->fmt.pix.width * fmt->depth) >> 3; |
| 977 | f->fmt.pix.sizeimage = | 970 | f->fmt.pix.sizeimage = |
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index 94b7a52629d0..a5cc1c1fc2d6 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c | |||
| @@ -1524,33 +1524,45 @@ static const struct cx88_board cx88_boards[] = { | |||
| 1524 | }, | 1524 | }, |
| 1525 | .mpeg = CX88_MPEG_DVB, | 1525 | .mpeg = CX88_MPEG_DVB, |
| 1526 | }, | 1526 | }, |
| 1527 | /* Terry Wu <terrywu2009@gmail.com> */ | ||
| 1528 | /* TV Audio : set GPIO 2, 18, 19 value to 0, 1, 0 */ | ||
| 1529 | /* FM Audio : set GPIO 2, 18, 19 value to 0, 0, 0 */ | ||
| 1530 | /* Line-in Audio : set GPIO 2, 18, 19 value to 0, 1, 1 */ | ||
| 1531 | /* Mute Audio : set GPIO 2 value to 1 */ | ||
| 1527 | [CX88_BOARD_WINFAST_TV2000_XP_GLOBAL] = { | 1532 | [CX88_BOARD_WINFAST_TV2000_XP_GLOBAL] = { |
| 1528 | .name = "Winfast TV2000 XP Global", | 1533 | .name = "Leadtek TV2000 XP Global", |
| 1529 | .tuner_type = TUNER_XC2028, | 1534 | .tuner_type = TUNER_XC2028, |
| 1530 | .tuner_addr = 0x61, | 1535 | .tuner_addr = 0x61, |
| 1536 | .radio_type = TUNER_XC2028, | ||
| 1537 | .radio_addr = 0x61, | ||
| 1531 | .input = { { | 1538 | .input = { { |
| 1532 | .type = CX88_VMUX_TELEVISION, | 1539 | .type = CX88_VMUX_TELEVISION, |
| 1533 | .vmux = 0, | 1540 | .vmux = 0, |
| 1534 | .gpio0 = 0x0400, /* pin 2:mute = 0 (off?) */ | 1541 | .gpio0 = 0x0400, /* pin 2 = 0 */ |
| 1535 | .gpio1 = 0x0000, | 1542 | .gpio1 = 0x0000, |
| 1536 | .gpio2 = 0x0800, /* pin 19:audio = 0 (tv) */ | 1543 | .gpio2 = 0x0C04, /* pin 18 = 1, pin 19 = 0 */ |
| 1537 | 1544 | .gpio3 = 0x0000, | |
| 1538 | }, { | 1545 | }, { |
| 1539 | .type = CX88_VMUX_COMPOSITE1, | 1546 | .type = CX88_VMUX_COMPOSITE1, |
| 1540 | .vmux = 1, | 1547 | .vmux = 1, |
| 1541 | .gpio0 = 0x0400, /* probably? or 0x0404 to turn mute on */ | 1548 | .gpio0 = 0x0400, /* pin 2 = 0 */ |
| 1542 | .gpio1 = 0x0000, | 1549 | .gpio1 = 0x0000, |
| 1543 | .gpio2 = 0x0808, /* pin 19:audio = 1 (line) */ | 1550 | .gpio2 = 0x0C0C, /* pin 18 = 1, pin 19 = 1 */ |
| 1544 | 1551 | .gpio3 = 0x0000, | |
| 1545 | }, { | 1552 | }, { |
| 1546 | .type = CX88_VMUX_SVIDEO, | 1553 | .type = CX88_VMUX_SVIDEO, |
| 1547 | .vmux = 2, | 1554 | .vmux = 2, |
| 1555 | .gpio0 = 0x0400, /* pin 2 = 0 */ | ||
| 1556 | .gpio1 = 0x0000, | ||
| 1557 | .gpio2 = 0x0C0C, /* pin 18 = 1, pin 19 = 1 */ | ||
| 1558 | .gpio3 = 0x0000, | ||
| 1548 | } }, | 1559 | } }, |
| 1549 | .radio = { | 1560 | .radio = { |
| 1550 | .type = CX88_RADIO, | 1561 | .type = CX88_RADIO, |
| 1551 | .gpio0 = 0x004ff, | 1562 | .gpio0 = 0x0400, /* pin 2 = 0 */ |
| 1552 | .gpio1 = 0x010ff, | 1563 | .gpio1 = 0x0000, |
| 1553 | .gpio2 = 0x0ff, | 1564 | .gpio2 = 0x0C00, /* pin 18 = 0, pin 19 = 0 */ |
| 1565 | .gpio3 = 0x0000, | ||
| 1554 | }, | 1566 | }, |
| 1555 | }, | 1567 | }, |
| 1556 | [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = { | 1568 | [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = { |
| @@ -2438,6 +2450,41 @@ static const struct cx88_subid cx88_subids[] = { | |||
| 2438 | .subvendor = 0x107d, | 2450 | .subvendor = 0x107d, |
| 2439 | .subdevice = 0x6654, | 2451 | .subdevice = 0x6654, |
| 2440 | .card = CX88_BOARD_WINFAST_DTV1800H, | 2452 | .card = CX88_BOARD_WINFAST_DTV1800H, |
| 2453 | }, { | ||
| 2454 | /* PVR2000 PAL Model [107d:6630] */ | ||
| 2455 | .subvendor = 0x107d, | ||
| 2456 | .subdevice = 0x6630, | ||
| 2457 | .card = CX88_BOARD_LEADTEK_PVR2000, | ||
| 2458 | }, { | ||
| 2459 | /* PVR2000 PAL Model [107d:6638] */ | ||
| 2460 | .subvendor = 0x107d, | ||
| 2461 | .subdevice = 0x6638, | ||
| 2462 | .card = CX88_BOARD_LEADTEK_PVR2000, | ||
| 2463 | }, { | ||
| 2464 | /* PVR2000 NTSC Model [107d:6631] */ | ||
| 2465 | .subvendor = 0x107d, | ||
| 2466 | .subdevice = 0x6631, | ||
| 2467 | .card = CX88_BOARD_LEADTEK_PVR2000, | ||
| 2468 | }, { | ||
| 2469 | /* PVR2000 NTSC Model [107d:6637] */ | ||
| 2470 | .subvendor = 0x107d, | ||
| 2471 | .subdevice = 0x6637, | ||
| 2472 | .card = CX88_BOARD_LEADTEK_PVR2000, | ||
| 2473 | }, { | ||
| 2474 | /* PVR2000 NTSC Model [107d:663d] */ | ||
| 2475 | .subvendor = 0x107d, | ||
| 2476 | .subdevice = 0x663d, | ||
| 2477 | .card = CX88_BOARD_LEADTEK_PVR2000, | ||
| 2478 | }, { | ||
| 2479 | /* DV2000 NTSC Model [107d:6621] */ | ||
| 2480 | .subvendor = 0x107d, | ||
| 2481 | .subdevice = 0x6621, | ||
| 2482 | .card = CX88_BOARD_WINFAST_DV2000, | ||
| 2483 | }, { | ||
| 2484 | /* TV2000 XP Global [107d:6618] */ | ||
| 2485 | .subvendor = 0x107d, | ||
| 2486 | .subdevice = 0x6618, | ||
| 2487 | .card = CX88_BOARD_WINFAST_TV2000_XP_GLOBAL, | ||
| 2441 | }, | 2488 | }, |
| 2442 | }; | 2489 | }; |
| 2443 | 2490 | ||
| @@ -2446,12 +2493,6 @@ static const struct cx88_subid cx88_subids[] = { | |||
| 2446 | 2493 | ||
| 2447 | static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data) | 2494 | static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data) |
| 2448 | { | 2495 | { |
| 2449 | /* This is just for the "Winfast 2000XP Expert" board ATM; I don't have data on | ||
| 2450 | * any others. | ||
| 2451 | * | ||
| 2452 | * Byte 0 is 1 on the NTSC board. | ||
| 2453 | */ | ||
| 2454 | |||
| 2455 | if (eeprom_data[4] != 0x7d || | 2496 | if (eeprom_data[4] != 0x7d || |
| 2456 | eeprom_data[5] != 0x10 || | 2497 | eeprom_data[5] != 0x10 || |
| 2457 | eeprom_data[7] != 0x66) { | 2498 | eeprom_data[7] != 0x66) { |
| @@ -2459,8 +2500,19 @@ static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data) | |||
| 2459 | return; | 2500 | return; |
| 2460 | } | 2501 | } |
| 2461 | 2502 | ||
| 2462 | core->board.tuner_type = (eeprom_data[6] == 0x13) ? | 2503 | /* Terry Wu <terrywu2009@gmail.com> */ |
| 2463 | TUNER_PHILIPS_FM1236_MK3 : TUNER_PHILIPS_FM1216ME_MK3; | 2504 | switch (eeprom_data[6]) { |
| 2505 | case 0x13: /* SSID 6613 for TV2000 XP Expert NTSC Model */ | ||
| 2506 | case 0x21: /* SSID 6621 for DV2000 NTSC Model */ | ||
| 2507 | case 0x31: /* SSID 6631 for PVR2000 NTSC Model */ | ||
| 2508 | case 0x37: /* SSID 6637 for PVR2000 NTSC Model */ | ||
| 2509 | case 0x3d: /* SSID 6637 for PVR2000 NTSC Model */ | ||
| 2510 | core->board.tuner_type = TUNER_PHILIPS_FM1236_MK3; | ||
| 2511 | break; | ||
| 2512 | default: | ||
| 2513 | core->board.tuner_type = TUNER_PHILIPS_FM1216ME_MK3; | ||
| 2514 | break; | ||
| 2515 | } | ||
| 2464 | 2516 | ||
| 2465 | info_printk(core, "Leadtek Winfast 2000XP Expert config: " | 2517 | info_printk(core, "Leadtek Winfast 2000XP Expert config: " |
| 2466 | "tuner=%d, eeprom[0]=0x%02x\n", | 2518 | "tuner=%d, eeprom[0]=0x%02x\n", |
| @@ -2713,7 +2765,6 @@ static int cx88_xc2028_tuner_callback(struct cx88_core *core, | |||
| 2713 | { | 2765 | { |
| 2714 | /* Board-specific callbacks */ | 2766 | /* Board-specific callbacks */ |
| 2715 | switch (core->boardnr) { | 2767 | switch (core->boardnr) { |
| 2716 | case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: | ||
| 2717 | case CX88_BOARD_POWERCOLOR_REAL_ANGEL: | 2768 | case CX88_BOARD_POWERCOLOR_REAL_ANGEL: |
| 2718 | case CX88_BOARD_GENIATECH_X8000_MT: | 2769 | case CX88_BOARD_GENIATECH_X8000_MT: |
| 2719 | case CX88_BOARD_KWORLD_ATSC_120: | 2770 | case CX88_BOARD_KWORLD_ATSC_120: |
| @@ -2725,6 +2776,7 @@ static int cx88_xc2028_tuner_callback(struct cx88_core *core, | |||
| 2725 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: | 2776 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: |
| 2726 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: | 2777 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: |
| 2727 | return cx88_dvico_xc2028_callback(core, command, arg); | 2778 | return cx88_dvico_xc2028_callback(core, command, arg); |
| 2779 | case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: | ||
| 2728 | case CX88_BOARD_WINFAST_DTV1800H: | 2780 | case CX88_BOARD_WINFAST_DTV1800H: |
| 2729 | return cx88_xc3028_winfast1800h_callback(core, command, arg); | 2781 | return cx88_xc3028_winfast1800h_callback(core, command, arg); |
| 2730 | } | 2782 | } |
| @@ -2914,6 +2966,7 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core) | |||
| 2914 | udelay(1000); | 2966 | udelay(1000); |
| 2915 | break; | 2967 | break; |
| 2916 | 2968 | ||
| 2969 | case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: | ||
| 2917 | case CX88_BOARD_WINFAST_DTV1800H: | 2970 | case CX88_BOARD_WINFAST_DTV1800H: |
| 2918 | /* GPIO 12 (xc3028 tuner reset) */ | 2971 | /* GPIO 12 (xc3028 tuner reset) */ |
| 2919 | cx_set(MO_GP1_IO, 0x1010); | 2972 | cx_set(MO_GP1_IO, 0x1010); |
| @@ -2950,6 +3003,7 @@ void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl) | |||
| 2950 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: | 3003 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: |
| 2951 | ctl->demod = XC3028_FE_OREN538; | 3004 | ctl->demod = XC3028_FE_OREN538; |
| 2952 | break; | 3005 | break; |
| 3006 | case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: | ||
| 2953 | case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME: | 3007 | case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME: |
| 2954 | case CX88_BOARD_PROLINK_PV_8000GT: | 3008 | case CX88_BOARD_PROLINK_PV_8000GT: |
| 2955 | /* | 3009 | /* |
| @@ -2993,6 +3047,8 @@ static void cx88_card_setup(struct cx88_core *core) | |||
| 2993 | if (0 == core->i2c_rc) | 3047 | if (0 == core->i2c_rc) |
| 2994 | gdi_eeprom(core, eeprom); | 3048 | gdi_eeprom(core, eeprom); |
| 2995 | break; | 3049 | break; |
| 3050 | case CX88_BOARD_LEADTEK_PVR2000: | ||
| 3051 | case CX88_BOARD_WINFAST_DV2000: | ||
| 2996 | case CX88_BOARD_WINFAST2000XP_EXPERT: | 3052 | case CX88_BOARD_WINFAST2000XP_EXPERT: |
| 2997 | if (0 == core->i2c_rc) | 3053 | if (0 == core->i2c_rc) |
| 2998 | leadtek_eeprom(core, eeprom); | 3054 | leadtek_eeprom(core, eeprom); |
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 0ccac702bea4..b12770848c00 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
| @@ -1111,15 +1111,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
| 1111 | } | 1111 | } |
| 1112 | 1112 | ||
| 1113 | f->fmt.pix.field = field; | 1113 | f->fmt.pix.field = field; |
| 1114 | if (f->fmt.pix.height < 32) | 1114 | v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, |
| 1115 | f->fmt.pix.height = 32; | 1115 | &f->fmt.pix.height, 32, maxh, 0, 0); |
| 1116 | if (f->fmt.pix.height > maxh) | ||
| 1117 | f->fmt.pix.height = maxh; | ||
| 1118 | if (f->fmt.pix.width < 48) | ||
| 1119 | f->fmt.pix.width = 48; | ||
| 1120 | if (f->fmt.pix.width > maxw) | ||
| 1121 | f->fmt.pix.width = maxw; | ||
| 1122 | f->fmt.pix.width &= ~0x03; | ||
| 1123 | f->fmt.pix.bytesperline = | 1116 | f->fmt.pix.bytesperline = |
| 1124 | (f->fmt.pix.width * fmt->depth) >> 3; | 1117 | (f->fmt.pix.width * fmt->depth) >> 3; |
| 1125 | f->fmt.pix.sizeimage = | 1118 | f->fmt.pix.sizeimage = |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 00cc791a9e44..c43fdb9bc888 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
| @@ -139,6 +139,24 @@ static struct em28xx_reg_seq kworld_330u_digital[] = { | |||
| 139 | { -1, -1, -1, -1}, | 139 | { -1, -1, -1, -1}, |
| 140 | }; | 140 | }; |
| 141 | 141 | ||
| 142 | /* Evga inDtube | ||
| 143 | GPIO0 - Enable digital power (s5h1409) - low to enable | ||
| 144 | GPIO1 - Enable analog power (tvp5150/emp202) - low to enable | ||
| 145 | GPIO4 - xc3028 reset | ||
| 146 | GOP3 - s5h1409 reset | ||
| 147 | */ | ||
| 148 | static struct em28xx_reg_seq evga_indtube_analog[] = { | ||
| 149 | {EM28XX_R08_GPIO, 0x79, 0xff, 60}, | ||
| 150 | { -1, -1, -1, -1}, | ||
| 151 | }; | ||
| 152 | |||
| 153 | static struct em28xx_reg_seq evga_indtube_digital[] = { | ||
| 154 | {EM28XX_R08_GPIO, 0x7a, 0xff, 1}, | ||
| 155 | {EM2880_R04_GPO, 0x04, 0xff, 10}, | ||
| 156 | {EM2880_R04_GPO, 0x0c, 0xff, 1}, | ||
| 157 | { -1, -1, -1, -1}, | ||
| 158 | }; | ||
| 159 | |||
| 142 | /* Callback for the most boards */ | 160 | /* Callback for the most boards */ |
| 143 | static struct em28xx_reg_seq default_tuner_gpio[] = { | 161 | static struct em28xx_reg_seq default_tuner_gpio[] = { |
| 144 | {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, | 162 | {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, |
| @@ -1449,6 +1467,33 @@ struct em28xx_board em28xx_boards[] = { | |||
| 1449 | .gpio = terratec_av350_unmute_gpio, | 1467 | .gpio = terratec_av350_unmute_gpio, |
| 1450 | } }, | 1468 | } }, |
| 1451 | }, | 1469 | }, |
| 1470 | [EM2882_BOARD_EVGA_INDTUBE] = { | ||
| 1471 | .name = "Evga inDtube", | ||
| 1472 | .tuner_type = TUNER_XC2028, | ||
| 1473 | .tuner_gpio = default_tuner_gpio, | ||
| 1474 | .decoder = EM28XX_TVP5150, | ||
| 1475 | .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */ | ||
| 1476 | .mts_firmware = 1, | ||
| 1477 | .has_dvb = 1, | ||
| 1478 | .dvb_gpio = evga_indtube_digital, | ||
| 1479 | .ir_codes = ir_codes_evga_indtube, | ||
| 1480 | .input = { { | ||
| 1481 | .type = EM28XX_VMUX_TELEVISION, | ||
| 1482 | .vmux = TVP5150_COMPOSITE0, | ||
| 1483 | .amux = EM28XX_AMUX_VIDEO, | ||
| 1484 | .gpio = evga_indtube_analog, | ||
| 1485 | }, { | ||
| 1486 | .type = EM28XX_VMUX_COMPOSITE1, | ||
| 1487 | .vmux = TVP5150_COMPOSITE1, | ||
| 1488 | .amux = EM28XX_AMUX_LINE_IN, | ||
| 1489 | .gpio = evga_indtube_analog, | ||
| 1490 | }, { | ||
| 1491 | .type = EM28XX_VMUX_SVIDEO, | ||
| 1492 | .vmux = TVP5150_SVIDEO, | ||
| 1493 | .amux = EM28XX_AMUX_LINE_IN, | ||
| 1494 | .gpio = evga_indtube_analog, | ||
| 1495 | } }, | ||
| 1496 | }, | ||
| 1452 | }; | 1497 | }; |
| 1453 | const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards); | 1498 | const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards); |
| 1454 | 1499 | ||
| @@ -1571,6 +1616,7 @@ static struct em28xx_hash_table em28xx_eeprom_hash[] = { | |||
| 1571 | {0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF}, | 1616 | {0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF}, |
| 1572 | {0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028}, | 1617 | {0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028}, |
| 1573 | {0x9567eb1a, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028}, | 1618 | {0x9567eb1a, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028}, |
| 1619 | {0xcee44a99, EM2882_BOARD_EVGA_INDTUBE, TUNER_XC2028}, | ||
| 1574 | }; | 1620 | }; |
| 1575 | 1621 | ||
| 1576 | /* I2C devicelist hash table for devices with generic USB IDs */ | 1622 | /* I2C devicelist hash table for devices with generic USB IDs */ |
| @@ -1834,6 +1880,10 @@ static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl) | |||
| 1834 | ctl->demod = XC3028_FE_CHINA; | 1880 | ctl->demod = XC3028_FE_CHINA; |
| 1835 | ctl->fname = XC2028_DEFAULT_FIRMWARE; | 1881 | ctl->fname = XC2028_DEFAULT_FIRMWARE; |
| 1836 | break; | 1882 | break; |
| 1883 | case EM2882_BOARD_EVGA_INDTUBE: | ||
| 1884 | ctl->demod = XC3028_FE_CHINA; | ||
| 1885 | ctl->fname = XC3028L_DEFAULT_FIRMWARE; | ||
| 1886 | break; | ||
| 1837 | default: | 1887 | default: |
| 1838 | ctl->demod = XC3028_FE_OREN538; | 1888 | ctl->demod = XC3028_FE_OREN538; |
| 1839 | } | 1889 | } |
| @@ -2101,6 +2151,12 @@ void em28xx_card_setup(struct em28xx *dev) | |||
| 2101 | case EM2880_BOARD_MSI_DIGIVOX_AD: | 2151 | case EM2880_BOARD_MSI_DIGIVOX_AD: |
| 2102 | if (!em28xx_hint_board(dev)) | 2152 | if (!em28xx_hint_board(dev)) |
| 2103 | em28xx_set_model(dev); | 2153 | em28xx_set_model(dev); |
| 2154 | |||
| 2155 | /* In cases where we had to use a board hint, the call to | ||
| 2156 | em28xx_set_mode() in em28xx_pre_card_setup() was a no-op, | ||
| 2157 | so make the call now so the analog GPIOs are set properly | ||
| 2158 | before probing the i2c bus. */ | ||
| 2159 | em28xx_set_mode(dev, EM28XX_ANALOG_MODE); | ||
| 2104 | break; | 2160 | break; |
| 2105 | } | 2161 | } |
| 2106 | 2162 | ||
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c index 563dd2b1c8e9..e7b47c8da8f3 100644 --- a/drivers/media/video/em28xx/em28xx-dvb.c +++ b/drivers/media/video/em28xx/em28xx-dvb.c | |||
| @@ -445,6 +445,7 @@ static int dvb_init(struct em28xx *dev) | |||
| 445 | } | 445 | } |
| 446 | break; | 446 | break; |
| 447 | case EM2883_BOARD_KWORLD_HYBRID_330U: | 447 | case EM2883_BOARD_KWORLD_HYBRID_330U: |
| 448 | case EM2882_BOARD_EVGA_INDTUBE: | ||
| 448 | dvb->frontend = dvb_attach(s5h1409_attach, | 449 | dvb->frontend = dvb_attach(s5h1409_attach, |
| 449 | &em28xx_s5h1409_with_xc3028, | 450 | &em28xx_s5h1409_with_xc3028, |
| 450 | &dev->i2c_adap); | 451 | &dev->i2c_adap); |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 882796e84dbc..8fe1beecfffa 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
| @@ -687,8 +687,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
| 687 | { | 687 | { |
| 688 | struct em28xx_fh *fh = priv; | 688 | struct em28xx_fh *fh = priv; |
| 689 | struct em28xx *dev = fh->dev; | 689 | struct em28xx *dev = fh->dev; |
| 690 | int width = f->fmt.pix.width; | 690 | unsigned int width = f->fmt.pix.width; |
| 691 | int height = f->fmt.pix.height; | 691 | unsigned int height = f->fmt.pix.height; |
| 692 | unsigned int maxw = norm_maxw(dev); | 692 | unsigned int maxw = norm_maxw(dev); |
| 693 | unsigned int maxh = norm_maxh(dev); | 693 | unsigned int maxh = norm_maxh(dev); |
| 694 | unsigned int hscale, vscale; | 694 | unsigned int hscale, vscale; |
| @@ -701,34 +701,20 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
| 701 | return -EINVAL; | 701 | return -EINVAL; |
| 702 | } | 702 | } |
| 703 | 703 | ||
| 704 | /* width must even because of the YUYV format | ||
| 705 | height must be even because of interlacing */ | ||
| 706 | height &= 0xfffe; | ||
| 707 | width &= 0xfffe; | ||
| 708 | |||
| 709 | if (unlikely(height < 32)) | ||
| 710 | height = 32; | ||
| 711 | if (unlikely(height > maxh)) | ||
| 712 | height = maxh; | ||
| 713 | if (unlikely(width < 48)) | ||
| 714 | width = 48; | ||
| 715 | if (unlikely(width > maxw)) | ||
| 716 | width = maxw; | ||
| 717 | |||
| 718 | if (dev->board.is_em2800) { | 704 | if (dev->board.is_em2800) { |
| 719 | /* the em2800 can only scale down to 50% */ | 705 | /* the em2800 can only scale down to 50% */ |
| 720 | if (height % (maxh / 2)) | 706 | height = height > (3 * maxh / 4) ? maxh : maxh / 2; |
| 721 | height = maxh; | 707 | width = width > (3 * maxw / 4) ? maxw : maxw / 2; |
| 722 | if (width % (maxw / 2)) | 708 | /* According to empiatech support the MaxPacketSize is too small |
| 723 | width = maxw; | 709 | * to support framesizes larger than 640x480 @ 30 fps or 640x576 |
| 724 | /* according to empiatech support */ | 710 | * @ 25 fps. As this would cut of a part of the image we prefer |
| 725 | /* the MaxPacketSize is to small to support */ | 711 | * 360x576 or 360x480 for now */ |
| 726 | /* framesizes larger than 640x480 @ 30 fps */ | ||
| 727 | /* or 640x576 @ 25 fps. As this would cut */ | ||
| 728 | /* of a part of the image we prefer */ | ||
| 729 | /* 360x576 or 360x480 for now */ | ||
| 730 | if (width == maxw && height == maxh) | 712 | if (width == maxw && height == maxh) |
| 731 | width /= 2; | 713 | width /= 2; |
| 714 | } else { | ||
| 715 | /* width must even because of the YUYV format | ||
| 716 | height must be even because of interlacing */ | ||
| 717 | v4l_bound_align_image(&width, 48, maxw, 1, &height, 32, maxh, 1, 0); | ||
| 732 | } | 718 | } |
| 733 | 719 | ||
| 734 | get_scale(dev, width, height, &hscale, &vscale); | 720 | get_scale(dev, width, height, &hscale, &vscale); |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 8bf81be1da61..813ce45c2f99 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
| @@ -106,6 +106,7 @@ | |||
| 106 | #define EM2860_BOARD_TERRATEC_GRABBY 67 | 106 | #define EM2860_BOARD_TERRATEC_GRABBY 67 |
| 107 | #define EM2860_BOARD_TERRATEC_AV350 68 | 107 | #define EM2860_BOARD_TERRATEC_AV350 68 |
| 108 | #define EM2882_BOARD_KWORLD_ATSC_315U 69 | 108 | #define EM2882_BOARD_KWORLD_ATSC_315U 69 |
| 109 | #define EM2882_BOARD_EVGA_INDTUBE 70 | ||
| 109 | 110 | ||
| 110 | /* Limits minimum and default number of buffers */ | 111 | /* Limits minimum and default number of buffers */ |
| 111 | #define EM28XX_MIN_BUF 4 | 112 | #define EM28XX_MIN_BUF 4 |
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index f7e0355ad644..1e89600986c8 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
| @@ -1042,13 +1042,11 @@ static int vidioc_queryctrl(struct file *file, void *priv, | |||
| 1042 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { | 1042 | for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) { |
| 1043 | if (gspca_dev->ctrl_dis & (1 << i)) | 1043 | if (gspca_dev->ctrl_dis & (1 << i)) |
| 1044 | continue; | 1044 | continue; |
| 1045 | if (ctrls->qctrl.id < id) | 1045 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id < id) |
| 1046 | continue; | 1046 | continue; |
| 1047 | if (ctrls != NULL) { | 1047 | if (ctrls && gspca_dev->sd_desc->ctrls[i].qctrl.id |
| 1048 | if (gspca_dev->sd_desc->ctrls[i].qctrl.id | ||
| 1049 | > ctrls->qctrl.id) | 1048 | > ctrls->qctrl.id) |
| 1050 | continue; | 1049 | continue; |
| 1051 | } | ||
| 1052 | ctrls = &gspca_dev->sd_desc->ctrls[i]; | 1050 | ctrls = &gspca_dev->sd_desc->ctrls[i]; |
| 1053 | } | 1051 | } |
| 1054 | } else { | 1052 | } else { |
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index 188866ac6cef..2f6e135d94bc 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c | |||
| @@ -50,12 +50,18 @@ static int i2c_detect_tries = 10; | |||
| 50 | struct sd { | 50 | struct sd { |
| 51 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 51 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
| 52 | 52 | ||
| 53 | __u8 packet_nr; | ||
| 54 | |||
| 53 | char bridge; | 55 | char bridge; |
| 54 | #define BRIDGE_OV511 0 | 56 | #define BRIDGE_OV511 0 |
| 55 | #define BRIDGE_OV511PLUS 1 | 57 | #define BRIDGE_OV511PLUS 1 |
| 56 | #define BRIDGE_OV518 2 | 58 | #define BRIDGE_OV518 2 |
| 57 | #define BRIDGE_OV518PLUS 3 | 59 | #define BRIDGE_OV518PLUS 3 |
| 58 | #define BRIDGE_OV519 4 | 60 | #define BRIDGE_OV519 4 |
| 61 | #define BRIDGE_MASK 7 | ||
| 62 | |||
| 63 | char invert_led; | ||
| 64 | #define BRIDGE_INVERT_LED 8 | ||
| 59 | 65 | ||
| 60 | /* Determined by sensor type */ | 66 | /* Determined by sensor type */ |
| 61 | __u8 sif; | 67 | __u8 sif; |
| @@ -65,22 +71,25 @@ struct sd { | |||
| 65 | __u8 colors; | 71 | __u8 colors; |
| 66 | __u8 hflip; | 72 | __u8 hflip; |
| 67 | __u8 vflip; | 73 | __u8 vflip; |
| 74 | __u8 autobrightness; | ||
| 75 | __u8 freq; | ||
| 68 | 76 | ||
| 69 | __u8 stopped; /* Streaming is temporarily paused */ | 77 | __u8 stopped; /* Streaming is temporarily paused */ |
| 70 | 78 | ||
| 71 | __u8 frame_rate; /* current Framerate (OV519 only) */ | 79 | __u8 frame_rate; /* current Framerate */ |
| 72 | __u8 clockdiv; /* clockdiv override for OV519 only */ | 80 | __u8 clockdiv; /* clockdiv override */ |
| 73 | 81 | ||
| 74 | char sensor; /* Type of image sensor chip (SEN_*) */ | 82 | char sensor; /* Type of image sensor chip (SEN_*) */ |
| 75 | #define SEN_UNKNOWN 0 | 83 | #define SEN_UNKNOWN 0 |
| 76 | #define SEN_OV6620 1 | 84 | #define SEN_OV6620 1 |
| 77 | #define SEN_OV6630 2 | 85 | #define SEN_OV6630 2 |
| 78 | #define SEN_OV7610 3 | 86 | #define SEN_OV66308AF 3 |
| 79 | #define SEN_OV7620 4 | 87 | #define SEN_OV7610 4 |
| 80 | #define SEN_OV7640 5 | 88 | #define SEN_OV7620 5 |
| 81 | #define SEN_OV7670 6 | 89 | #define SEN_OV7640 6 |
| 82 | #define SEN_OV76BE 7 | 90 | #define SEN_OV7670 7 |
| 83 | #define SEN_OV8610 8 | 91 | #define SEN_OV76BE 8 |
| 92 | #define SEN_OV8610 9 | ||
| 84 | }; | 93 | }; |
| 85 | 94 | ||
| 86 | /* V4L2 controls supported by the driver */ | 95 | /* V4L2 controls supported by the driver */ |
| @@ -94,11 +103,17 @@ static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); | |||
| 94 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val); | 103 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val); |
| 95 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); | 104 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); |
| 96 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); | 105 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); |
| 106 | static int sd_setautobrightness(struct gspca_dev *gspca_dev, __s32 val); | ||
| 107 | static int sd_getautobrightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
| 108 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | ||
| 109 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | ||
| 97 | static void setbrightness(struct gspca_dev *gspca_dev); | 110 | static void setbrightness(struct gspca_dev *gspca_dev); |
| 98 | static void setcontrast(struct gspca_dev *gspca_dev); | 111 | static void setcontrast(struct gspca_dev *gspca_dev); |
| 99 | static void setcolors(struct gspca_dev *gspca_dev); | 112 | static void setcolors(struct gspca_dev *gspca_dev); |
| 113 | static void setautobrightness(struct sd *sd); | ||
| 114 | static void setfreq(struct sd *sd); | ||
| 100 | 115 | ||
| 101 | static struct ctrl sd_ctrls[] = { | 116 | static const struct ctrl sd_ctrls[] = { |
| 102 | { | 117 | { |
| 103 | { | 118 | { |
| 104 | .id = V4L2_CID_BRIGHTNESS, | 119 | .id = V4L2_CID_BRIGHTNESS, |
| @@ -141,7 +156,7 @@ static struct ctrl sd_ctrls[] = { | |||
| 141 | .set = sd_setcolors, | 156 | .set = sd_setcolors, |
| 142 | .get = sd_getcolors, | 157 | .get = sd_getcolors, |
| 143 | }, | 158 | }, |
| 144 | /* next controls work with ov7670 only */ | 159 | /* The flip controls work with ov7670 only */ |
| 145 | #define HFLIP_IDX 3 | 160 | #define HFLIP_IDX 3 |
| 146 | { | 161 | { |
| 147 | { | 162 | { |
| @@ -172,6 +187,51 @@ static struct ctrl sd_ctrls[] = { | |||
| 172 | .set = sd_setvflip, | 187 | .set = sd_setvflip, |
| 173 | .get = sd_getvflip, | 188 | .get = sd_getvflip, |
| 174 | }, | 189 | }, |
| 190 | #define AUTOBRIGHT_IDX 5 | ||
| 191 | { | ||
| 192 | { | ||
| 193 | .id = V4L2_CID_AUTOBRIGHTNESS, | ||
| 194 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 195 | .name = "Auto Brightness", | ||
| 196 | .minimum = 0, | ||
| 197 | .maximum = 1, | ||
| 198 | .step = 1, | ||
| 199 | #define AUTOBRIGHT_DEF 1 | ||
| 200 | .default_value = AUTOBRIGHT_DEF, | ||
| 201 | }, | ||
| 202 | .set = sd_setautobrightness, | ||
| 203 | .get = sd_getautobrightness, | ||
| 204 | }, | ||
| 205 | #define FREQ_IDX 6 | ||
| 206 | { | ||
| 207 | { | ||
| 208 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | ||
| 209 | .type = V4L2_CTRL_TYPE_MENU, | ||
| 210 | .name = "Light frequency filter", | ||
| 211 | .minimum = 0, | ||
| 212 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ | ||
| 213 | .step = 1, | ||
| 214 | #define FREQ_DEF 0 | ||
| 215 | .default_value = FREQ_DEF, | ||
| 216 | }, | ||
| 217 | .set = sd_setfreq, | ||
| 218 | .get = sd_getfreq, | ||
| 219 | }, | ||
| 220 | #define OV7670_FREQ_IDX 7 | ||
| 221 | { | ||
| 222 | { | ||
| 223 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | ||
| 224 | .type = V4L2_CTRL_TYPE_MENU, | ||
| 225 | .name = "Light frequency filter", | ||
| 226 | .minimum = 0, | ||
| 227 | .maximum = 3, /* 0: 0, 1: 50Hz, 2:60Hz 3: Auto Hz */ | ||
| 228 | .step = 1, | ||
| 229 | #define OV7670_FREQ_DEF 3 | ||
| 230 | .default_value = OV7670_FREQ_DEF, | ||
| 231 | }, | ||
| 232 | .set = sd_setfreq, | ||
| 233 | .get = sd_getfreq, | ||
| 234 | }, | ||
| 175 | }; | 235 | }; |
| 176 | 236 | ||
| 177 | static const struct v4l2_pix_format ov519_vga_mode[] = { | 237 | static const struct v4l2_pix_format ov519_vga_mode[] = { |
| @@ -187,11 +247,21 @@ static const struct v4l2_pix_format ov519_vga_mode[] = { | |||
| 187 | .priv = 0}, | 247 | .priv = 0}, |
| 188 | }; | 248 | }; |
| 189 | static const struct v4l2_pix_format ov519_sif_mode[] = { | 249 | static const struct v4l2_pix_format ov519_sif_mode[] = { |
| 250 | {160, 120, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | ||
| 251 | .bytesperline = 160, | ||
| 252 | .sizeimage = 160 * 120 * 3 / 8 + 590, | ||
| 253 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 254 | .priv = 3}, | ||
| 190 | {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 255 | {176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 191 | .bytesperline = 176, | 256 | .bytesperline = 176, |
| 192 | .sizeimage = 176 * 144 * 3 / 8 + 590, | 257 | .sizeimage = 176 * 144 * 3 / 8 + 590, |
| 193 | .colorspace = V4L2_COLORSPACE_JPEG, | 258 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 194 | .priv = 1}, | 259 | .priv = 1}, |
| 260 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | ||
| 261 | .bytesperline = 320, | ||
| 262 | .sizeimage = 320 * 240 * 3 / 8 + 590, | ||
| 263 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 264 | .priv = 2}, | ||
| 195 | {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 265 | {352, 288, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 196 | .bytesperline = 352, | 266 | .bytesperline = 352, |
| 197 | .sizeimage = 352 * 288 * 3 / 8 + 590, | 267 | .sizeimage = 352 * 288 * 3 / 8 + 590, |
| @@ -199,42 +269,118 @@ static const struct v4l2_pix_format ov519_sif_mode[] = { | |||
| 199 | .priv = 0}, | 269 | .priv = 0}, |
| 200 | }; | 270 | }; |
| 201 | 271 | ||
| 272 | /* Note some of the sizeimage values for the ov511 / ov518 may seem | ||
| 273 | larger then necessary, however they need to be this big as the ov511 / | ||
| 274 | ov518 always fills the entire isoc frame, using 0 padding bytes when | ||
| 275 | it doesn't have any data. So with low framerates the amount of data | ||
| 276 | transfered can become quite large (libv4l will remove all the 0 padding | ||
| 277 | in userspace). */ | ||
| 202 | static const struct v4l2_pix_format ov518_vga_mode[] = { | 278 | static const struct v4l2_pix_format ov518_vga_mode[] = { |
| 203 | {320, 240, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, | 279 | {320, 240, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, |
| 204 | .bytesperline = 320, | 280 | .bytesperline = 320, |
| 205 | .sizeimage = 320 * 240 * 3 / 8 + 590, | 281 | .sizeimage = 320 * 240 * 3, |
| 206 | .colorspace = V4L2_COLORSPACE_JPEG, | 282 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 207 | .priv = 1}, | 283 | .priv = 1}, |
| 208 | {640, 480, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, | 284 | {640, 480, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, |
| 209 | .bytesperline = 640, | 285 | .bytesperline = 640, |
| 210 | .sizeimage = 640 * 480 * 3 / 8 + 590, | 286 | .sizeimage = 640 * 480 * 2, |
| 211 | .colorspace = V4L2_COLORSPACE_JPEG, | 287 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 212 | .priv = 0}, | 288 | .priv = 0}, |
| 213 | }; | 289 | }; |
| 214 | static const struct v4l2_pix_format ov518_sif_mode[] = { | 290 | static const struct v4l2_pix_format ov518_sif_mode[] = { |
| 291 | {160, 120, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, | ||
| 292 | .bytesperline = 160, | ||
| 293 | .sizeimage = 70000, | ||
| 294 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 295 | .priv = 3}, | ||
| 215 | {176, 144, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, | 296 | {176, 144, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, |
| 216 | .bytesperline = 176, | 297 | .bytesperline = 176, |
| 217 | .sizeimage = 40000, | 298 | .sizeimage = 70000, |
| 218 | .colorspace = V4L2_COLORSPACE_JPEG, | 299 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 219 | .priv = 1}, | 300 | .priv = 1}, |
| 301 | {320, 240, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, | ||
| 302 | .bytesperline = 320, | ||
| 303 | .sizeimage = 320 * 240 * 3, | ||
| 304 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 305 | .priv = 2}, | ||
| 220 | {352, 288, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, | 306 | {352, 288, V4L2_PIX_FMT_OV518, V4L2_FIELD_NONE, |
| 221 | .bytesperline = 352, | 307 | .bytesperline = 352, |
| 222 | .sizeimage = 352 * 288 * 3 / 8 + 590, | 308 | .sizeimage = 352 * 288 * 3, |
| 223 | .colorspace = V4L2_COLORSPACE_JPEG, | 309 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 224 | .priv = 0}, | 310 | .priv = 0}, |
| 225 | }; | 311 | }; |
| 226 | 312 | ||
| 313 | static const struct v4l2_pix_format ov511_vga_mode[] = { | ||
| 314 | {320, 240, V4L2_PIX_FMT_OV511, V4L2_FIELD_NONE, | ||
| 315 | .bytesperline = 320, | ||
| 316 | .sizeimage = 320 * 240 * 3, | ||
| 317 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 318 | .priv = 1}, | ||
| 319 | {640, 480, V4L2_PIX_FMT_OV511, V4L2_FIELD_NONE, | ||
| 320 | .bytesperline = 640, | ||
| 321 | .sizeimage = 640 * 480 * 2, | ||
| 322 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 323 | .priv = 0}, | ||
| 324 | }; | ||
| 325 | static const struct v4l2_pix_format ov511_sif_mode[] = { | ||
| 326 | {160, 120, V4L2_PIX_FMT_OV511, V4L2_FIELD_NONE, | ||
| 327 | .bytesperline = 160, | ||
| 328 | .sizeimage = 70000, | ||
| 329 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 330 | .priv = 3}, | ||
| 331 | {176, 144, V4L2_PIX_FMT_OV511, V4L2_FIELD_NONE, | ||
| 332 | .bytesperline = 176, | ||
| 333 | .sizeimage = 70000, | ||
| 334 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 335 | .priv = 1}, | ||
| 336 | {320, 240, V4L2_PIX_FMT_OV511, V4L2_FIELD_NONE, | ||
| 337 | .bytesperline = 320, | ||
| 338 | .sizeimage = 320 * 240 * 3, | ||
| 339 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 340 | .priv = 2}, | ||
| 341 | {352, 288, V4L2_PIX_FMT_OV511, V4L2_FIELD_NONE, | ||
| 342 | .bytesperline = 352, | ||
| 343 | .sizeimage = 352 * 288 * 3, | ||
| 344 | .colorspace = V4L2_COLORSPACE_JPEG, | ||
| 345 | .priv = 0}, | ||
| 346 | }; | ||
| 227 | 347 | ||
| 228 | /* Registers common to OV511 / OV518 */ | 348 | /* Registers common to OV511 / OV518 */ |
| 349 | #define R51x_FIFO_PSIZE 0x30 /* 2 bytes wide w/ OV518(+) */ | ||
| 229 | #define R51x_SYS_RESET 0x50 | 350 | #define R51x_SYS_RESET 0x50 |
| 351 | /* Reset type flags */ | ||
| 352 | #define OV511_RESET_OMNICE 0x08 | ||
| 230 | #define R51x_SYS_INIT 0x53 | 353 | #define R51x_SYS_INIT 0x53 |
| 231 | #define R51x_SYS_SNAP 0x52 | 354 | #define R51x_SYS_SNAP 0x52 |
| 232 | #define R51x_SYS_CUST_ID 0x5F | 355 | #define R51x_SYS_CUST_ID 0x5F |
| 233 | #define R51x_COMP_LUT_BEGIN 0x80 | 356 | #define R51x_COMP_LUT_BEGIN 0x80 |
| 234 | 357 | ||
| 235 | /* OV511 Camera interface register numbers */ | 358 | /* OV511 Camera interface register numbers */ |
| 359 | #define R511_CAM_DELAY 0x10 | ||
| 360 | #define R511_CAM_EDGE 0x11 | ||
| 361 | #define R511_CAM_PXCNT 0x12 | ||
| 362 | #define R511_CAM_LNCNT 0x13 | ||
| 363 | #define R511_CAM_PXDIV 0x14 | ||
| 364 | #define R511_CAM_LNDIV 0x15 | ||
| 365 | #define R511_CAM_UV_EN 0x16 | ||
| 366 | #define R511_CAM_LINE_MODE 0x17 | ||
| 367 | #define R511_CAM_OPTS 0x18 | ||
| 368 | |||
| 369 | #define R511_SNAP_FRAME 0x19 | ||
| 370 | #define R511_SNAP_PXCNT 0x1A | ||
| 371 | #define R511_SNAP_LNCNT 0x1B | ||
| 372 | #define R511_SNAP_PXDIV 0x1C | ||
| 373 | #define R511_SNAP_LNDIV 0x1D | ||
| 374 | #define R511_SNAP_UV_EN 0x1E | ||
| 375 | #define R511_SNAP_UV_EN 0x1E | ||
| 376 | #define R511_SNAP_OPTS 0x1F | ||
| 377 | |||
| 378 | #define R511_DRAM_FLOW_CTL 0x20 | ||
| 379 | #define R511_FIFO_OPTS 0x31 | ||
| 380 | #define R511_I2C_CTL 0x40 | ||
| 236 | #define R511_SYS_LED_CTL 0x55 /* OV511+ only */ | 381 | #define R511_SYS_LED_CTL 0x55 /* OV511+ only */ |
| 237 | #define OV511_RESET_NOREGS 0x3F /* All but OV511 & regs */ | 382 | #define R511_COMP_EN 0x78 |
| 383 | #define R511_COMP_LUT_EN 0x79 | ||
| 238 | 384 | ||
| 239 | /* OV518 Camera interface register numbers */ | 385 | /* OV518 Camera interface register numbers */ |
| 240 | #define R518_GPIO_OUT 0x56 /* OV518(+) only */ | 386 | #define R518_GPIO_OUT 0x56 /* OV518(+) only */ |
| @@ -383,7 +529,7 @@ static const struct ov_i2c_regvals norm_6x20[] = { | |||
| 383 | { 0x28, 0x05 }, | 529 | { 0x28, 0x05 }, |
| 384 | { 0x2a, 0x04 }, /* Disable framerate adjust */ | 530 | { 0x2a, 0x04 }, /* Disable framerate adjust */ |
| 385 | /* { 0x2b, 0xac }, * Framerate; Set 2a[7] first */ | 531 | /* { 0x2b, 0xac }, * Framerate; Set 2a[7] first */ |
| 386 | { 0x2d, 0x99 }, | 532 | { 0x2d, 0x85 }, |
| 387 | { 0x33, 0xa0 }, /* Color Processing Parameter */ | 533 | { 0x33, 0xa0 }, /* Color Processing Parameter */ |
| 388 | { 0x34, 0xd2 }, /* Max A/D range */ | 534 | { 0x34, 0xd2 }, /* Max A/D range */ |
| 389 | { 0x38, 0x8b }, | 535 | { 0x38, 0x8b }, |
| @@ -416,7 +562,7 @@ static const struct ov_i2c_regvals norm_6x30[] = { | |||
| 416 | { 0x07, 0x2d }, /* Sharpness */ | 562 | { 0x07, 0x2d }, /* Sharpness */ |
| 417 | { 0x0c, 0x20 }, | 563 | { 0x0c, 0x20 }, |
| 418 | { 0x0d, 0x20 }, | 564 | { 0x0d, 0x20 }, |
| 419 | { 0x0e, 0x20 }, | 565 | { 0x0e, 0xa0 }, /* Was 0x20, bit7 enables a 2x gain which we need */ |
| 420 | { 0x0f, 0x05 }, | 566 | { 0x0f, 0x05 }, |
| 421 | { 0x10, 0x9a }, | 567 | { 0x10, 0x9a }, |
| 422 | { 0x11, 0x00 }, /* Pixel clock = fastest */ | 568 | { 0x11, 0x00 }, /* Pixel clock = fastest */ |
| @@ -558,7 +704,7 @@ static const struct ov_i2c_regvals norm_7620[] = { | |||
| 558 | { 0x23, 0x00 }, | 704 | { 0x23, 0x00 }, |
| 559 | { 0x26, 0xa2 }, | 705 | { 0x26, 0xa2 }, |
| 560 | { 0x27, 0xea }, | 706 | { 0x27, 0xea }, |
| 561 | { 0x28, 0x20 }, | 707 | { 0x28, 0x22 }, /* Was 0x20, bit1 enables a 2x gain which we need */ |
| 562 | { 0x29, 0x00 }, | 708 | { 0x29, 0x00 }, |
| 563 | { 0x2a, 0x10 }, | 709 | { 0x2a, 0x10 }, |
| 564 | { 0x2b, 0x00 }, | 710 | { 0x2b, 0x00 }, |
| @@ -999,13 +1145,128 @@ static int ov518_reg_w32(struct sd *sd, __u16 index, u32 value, int n) | |||
| 999 | return ret; | 1145 | return ret; |
| 1000 | } | 1146 | } |
| 1001 | 1147 | ||
| 1148 | static int ov511_i2c_w(struct sd *sd, __u8 reg, __u8 value) | ||
| 1149 | { | ||
| 1150 | int rc, retries; | ||
| 1151 | |||
| 1152 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); | ||
| 1153 | |||
| 1154 | /* Three byte write cycle */ | ||
| 1155 | for (retries = 6; ; ) { | ||
| 1156 | /* Select camera register */ | ||
| 1157 | rc = reg_w(sd, R51x_I2C_SADDR_3, reg); | ||
| 1158 | if (rc < 0) | ||
| 1159 | return rc; | ||
| 1160 | |||
| 1161 | /* Write "value" to I2C data port of OV511 */ | ||
| 1162 | rc = reg_w(sd, R51x_I2C_DATA, value); | ||
| 1163 | if (rc < 0) | ||
| 1164 | return rc; | ||
| 1165 | |||
| 1166 | /* Initiate 3-byte write cycle */ | ||
| 1167 | rc = reg_w(sd, R511_I2C_CTL, 0x01); | ||
| 1168 | if (rc < 0) | ||
| 1169 | return rc; | ||
| 1170 | |||
| 1171 | do | ||
| 1172 | rc = reg_r(sd, R511_I2C_CTL); | ||
| 1173 | while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */ | ||
| 1174 | |||
| 1175 | if (rc < 0) | ||
| 1176 | return rc; | ||
| 1177 | |||
| 1178 | if ((rc & 2) == 0) /* Ack? */ | ||
| 1179 | break; | ||
| 1180 | if (--retries < 0) { | ||
| 1181 | PDEBUG(D_USBO, "i2c write retries exhausted"); | ||
| 1182 | return -1; | ||
| 1183 | } | ||
| 1184 | } | ||
| 1185 | |||
| 1186 | return 0; | ||
| 1187 | } | ||
| 1188 | |||
| 1189 | static int ov511_i2c_r(struct sd *sd, __u8 reg) | ||
| 1190 | { | ||
| 1191 | int rc, value, retries; | ||
| 1192 | |||
| 1193 | /* Two byte write cycle */ | ||
| 1194 | for (retries = 6; ; ) { | ||
| 1195 | /* Select camera register */ | ||
| 1196 | rc = reg_w(sd, R51x_I2C_SADDR_2, reg); | ||
| 1197 | if (rc < 0) | ||
| 1198 | return rc; | ||
| 1199 | |||
| 1200 | /* Initiate 2-byte write cycle */ | ||
| 1201 | rc = reg_w(sd, R511_I2C_CTL, 0x03); | ||
| 1202 | if (rc < 0) | ||
| 1203 | return rc; | ||
| 1204 | |||
| 1205 | do | ||
| 1206 | rc = reg_r(sd, R511_I2C_CTL); | ||
| 1207 | while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */ | ||
| 1208 | |||
| 1209 | if (rc < 0) | ||
| 1210 | return rc; | ||
| 1211 | |||
| 1212 | if ((rc & 2) == 0) /* Ack? */ | ||
| 1213 | break; | ||
| 1214 | |||
| 1215 | /* I2C abort */ | ||
| 1216 | reg_w(sd, R511_I2C_CTL, 0x10); | ||
| 1217 | |||
| 1218 | if (--retries < 0) { | ||
| 1219 | PDEBUG(D_USBI, "i2c write retries exhausted"); | ||
| 1220 | return -1; | ||
| 1221 | } | ||
| 1222 | } | ||
| 1223 | |||
| 1224 | /* Two byte read cycle */ | ||
| 1225 | for (retries = 6; ; ) { | ||
| 1226 | /* Initiate 2-byte read cycle */ | ||
| 1227 | rc = reg_w(sd, R511_I2C_CTL, 0x05); | ||
| 1228 | if (rc < 0) | ||
| 1229 | return rc; | ||
| 1230 | |||
| 1231 | do | ||
| 1232 | rc = reg_r(sd, R511_I2C_CTL); | ||
| 1233 | while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */ | ||
| 1234 | |||
| 1235 | if (rc < 0) | ||
| 1236 | return rc; | ||
| 1237 | |||
| 1238 | if ((rc & 2) == 0) /* Ack? */ | ||
| 1239 | break; | ||
| 1240 | |||
| 1241 | /* I2C abort */ | ||
| 1242 | rc = reg_w(sd, R511_I2C_CTL, 0x10); | ||
| 1243 | if (rc < 0) | ||
| 1244 | return rc; | ||
| 1245 | |||
| 1246 | if (--retries < 0) { | ||
| 1247 | PDEBUG(D_USBI, "i2c read retries exhausted"); | ||
| 1248 | return -1; | ||
| 1249 | } | ||
| 1250 | } | ||
| 1251 | |||
| 1252 | value = reg_r(sd, R51x_I2C_DATA); | ||
| 1253 | |||
| 1254 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); | ||
| 1255 | |||
| 1256 | /* This is needed to make i2c_w() work */ | ||
| 1257 | rc = reg_w(sd, R511_I2C_CTL, 0x05); | ||
| 1258 | if (rc < 0) | ||
| 1259 | return rc; | ||
| 1260 | |||
| 1261 | return value; | ||
| 1262 | } | ||
| 1002 | 1263 | ||
| 1003 | /* | 1264 | /* |
| 1004 | * The OV518 I2C I/O procedure is different, hence, this function. | 1265 | * The OV518 I2C I/O procedure is different, hence, this function. |
| 1005 | * This is normally only called from i2c_w(). Note that this function | 1266 | * This is normally only called from i2c_w(). Note that this function |
| 1006 | * always succeeds regardless of whether the sensor is present and working. | 1267 | * always succeeds regardless of whether the sensor is present and working. |
| 1007 | */ | 1268 | */ |
| 1008 | static int i2c_w(struct sd *sd, | 1269 | static int ov518_i2c_w(struct sd *sd, |
| 1009 | __u8 reg, | 1270 | __u8 reg, |
| 1010 | __u8 value) | 1271 | __u8 value) |
| 1011 | { | 1272 | { |
| @@ -1040,7 +1301,7 @@ static int i2c_w(struct sd *sd, | |||
| 1040 | * This is normally only called from i2c_r(). Note that this function | 1301 | * This is normally only called from i2c_r(). Note that this function |
| 1041 | * always succeeds regardless of whether the sensor is present and working. | 1302 | * always succeeds regardless of whether the sensor is present and working. |
| 1042 | */ | 1303 | */ |
| 1043 | static int i2c_r(struct sd *sd, __u8 reg) | 1304 | static int ov518_i2c_r(struct sd *sd, __u8 reg) |
| 1044 | { | 1305 | { |
| 1045 | int rc, value; | 1306 | int rc, value; |
| 1046 | 1307 | ||
| @@ -1063,6 +1324,34 @@ static int i2c_r(struct sd *sd, __u8 reg) | |||
| 1063 | return value; | 1324 | return value; |
| 1064 | } | 1325 | } |
| 1065 | 1326 | ||
| 1327 | static int i2c_w(struct sd *sd, __u8 reg, __u8 value) | ||
| 1328 | { | ||
| 1329 | switch (sd->bridge) { | ||
| 1330 | case BRIDGE_OV511: | ||
| 1331 | case BRIDGE_OV511PLUS: | ||
| 1332 | return ov511_i2c_w(sd, reg, value); | ||
| 1333 | case BRIDGE_OV518: | ||
| 1334 | case BRIDGE_OV518PLUS: | ||
| 1335 | case BRIDGE_OV519: | ||
| 1336 | return ov518_i2c_w(sd, reg, value); | ||
| 1337 | } | ||
| 1338 | return -1; /* Should never happen */ | ||
| 1339 | } | ||
| 1340 | |||
| 1341 | static int i2c_r(struct sd *sd, __u8 reg) | ||
| 1342 | { | ||
| 1343 | switch (sd->bridge) { | ||
| 1344 | case BRIDGE_OV511: | ||
| 1345 | case BRIDGE_OV511PLUS: | ||
| 1346 | return ov511_i2c_r(sd, reg); | ||
| 1347 | case BRIDGE_OV518: | ||
| 1348 | case BRIDGE_OV518PLUS: | ||
| 1349 | case BRIDGE_OV519: | ||
| 1350 | return ov518_i2c_r(sd, reg); | ||
| 1351 | } | ||
| 1352 | return -1; /* Should never happen */ | ||
| 1353 | } | ||
| 1354 | |||
| 1066 | /* Writes bits at positions specified by mask to an I2C reg. Bits that are in | 1355 | /* Writes bits at positions specified by mask to an I2C reg. Bits that are in |
| 1067 | * the same position as 1's in "mask" are cleared and set to "value". Bits | 1356 | * the same position as 1's in "mask" are cleared and set to "value". Bits |
| 1068 | * that are in the same position as 0's in "mask" are preserved, regardless | 1357 | * that are in the same position as 0's in "mask" are preserved, regardless |
| @@ -1242,7 +1531,6 @@ static int ov8xx0_configure(struct sd *sd) | |||
| 1242 | } | 1531 | } |
| 1243 | 1532 | ||
| 1244 | /* Set sensor-specific vars */ | 1533 | /* Set sensor-specific vars */ |
| 1245 | /* sd->sif = 0; already done */ | ||
| 1246 | return 0; | 1534 | return 0; |
| 1247 | } | 1535 | } |
| 1248 | 1536 | ||
| @@ -1279,15 +1567,13 @@ static int ov7xx0_configure(struct sd *sd) | |||
| 1279 | } | 1567 | } |
| 1280 | } else if ((rc & 3) == 1) { | 1568 | } else if ((rc & 3) == 1) { |
| 1281 | /* I don't know what's different about the 76BE yet. */ | 1569 | /* I don't know what's different about the 76BE yet. */ |
| 1282 | if (i2c_r(sd, 0x15) & 1) | 1570 | if (i2c_r(sd, 0x15) & 1) { |
| 1283 | PDEBUG(D_PROBE, "Sensor is an OV7620AE"); | 1571 | PDEBUG(D_PROBE, "Sensor is an OV7620AE"); |
| 1284 | else | 1572 | sd->sensor = SEN_OV7620; |
| 1573 | } else { | ||
| 1285 | PDEBUG(D_PROBE, "Sensor is an OV76BE"); | 1574 | PDEBUG(D_PROBE, "Sensor is an OV76BE"); |
| 1286 | 1575 | sd->sensor = SEN_OV76BE; | |
| 1287 | /* OV511+ will return all zero isoc data unless we | 1576 | } |
| 1288 | * configure the sensor as a 7620. Someone needs to | ||
| 1289 | * find the exact reg. setting that causes this. */ | ||
| 1290 | sd->sensor = SEN_OV76BE; | ||
| 1291 | } else if ((rc & 3) == 0) { | 1577 | } else if ((rc & 3) == 0) { |
| 1292 | /* try to read product id registers */ | 1578 | /* try to read product id registers */ |
| 1293 | high = i2c_r(sd, 0x0a); | 1579 | high = i2c_r(sd, 0x0a); |
| @@ -1333,7 +1619,6 @@ static int ov7xx0_configure(struct sd *sd) | |||
| 1333 | } | 1619 | } |
| 1334 | 1620 | ||
| 1335 | /* Set sensor-specific vars */ | 1621 | /* Set sensor-specific vars */ |
| 1336 | /* sd->sif = 0; already done */ | ||
| 1337 | return 0; | 1622 | return 0; |
| 1338 | } | 1623 | } |
| 1339 | 1624 | ||
| @@ -1362,13 +1647,14 @@ static int ov6xx0_configure(struct sd *sd) | |||
| 1362 | break; | 1647 | break; |
| 1363 | case 0x01: | 1648 | case 0x01: |
| 1364 | sd->sensor = SEN_OV6620; | 1649 | sd->sensor = SEN_OV6620; |
| 1650 | PDEBUG(D_PROBE, "Sensor is an OV6620"); | ||
| 1365 | break; | 1651 | break; |
| 1366 | case 0x02: | 1652 | case 0x02: |
| 1367 | sd->sensor = SEN_OV6630; | 1653 | sd->sensor = SEN_OV6630; |
| 1368 | PDEBUG(D_PROBE, "Sensor is an OV66308AE"); | 1654 | PDEBUG(D_PROBE, "Sensor is an OV66308AE"); |
| 1369 | break; | 1655 | break; |
| 1370 | case 0x03: | 1656 | case 0x03: |
| 1371 | sd->sensor = SEN_OV6630; | 1657 | sd->sensor = SEN_OV66308AF; |
| 1372 | PDEBUG(D_PROBE, "Sensor is an OV66308AF"); | 1658 | PDEBUG(D_PROBE, "Sensor is an OV66308AF"); |
| 1373 | break; | 1659 | break; |
| 1374 | case 0x90: | 1660 | case 0x90: |
| @@ -1391,6 +1677,9 @@ static int ov6xx0_configure(struct sd *sd) | |||
| 1391 | /* Turns on or off the LED. Only has an effect with OV511+/OV518(+)/OV519 */ | 1677 | /* Turns on or off the LED. Only has an effect with OV511+/OV518(+)/OV519 */ |
| 1392 | static void ov51x_led_control(struct sd *sd, int on) | 1678 | static void ov51x_led_control(struct sd *sd, int on) |
| 1393 | { | 1679 | { |
| 1680 | if (sd->invert_led) | ||
| 1681 | on = !on; | ||
| 1682 | |||
| 1394 | switch (sd->bridge) { | 1683 | switch (sd->bridge) { |
| 1395 | /* OV511 has no LED control */ | 1684 | /* OV511 has no LED control */ |
| 1396 | case BRIDGE_OV511PLUS: | 1685 | case BRIDGE_OV511PLUS: |
| @@ -1406,9 +1695,31 @@ static void ov51x_led_control(struct sd *sd, int on) | |||
| 1406 | } | 1695 | } |
| 1407 | } | 1696 | } |
| 1408 | 1697 | ||
| 1409 | /* OV518 quantization tables are 8x4 (instead of 8x8) */ | 1698 | static int ov51x_upload_quan_tables(struct sd *sd) |
| 1410 | static int ov518_upload_quan_tables(struct sd *sd) | ||
| 1411 | { | 1699 | { |
| 1700 | const unsigned char yQuanTable511[] = { | ||
| 1701 | 0, 1, 1, 2, 2, 3, 3, 4, | ||
| 1702 | 1, 1, 1, 2, 2, 3, 4, 4, | ||
| 1703 | 1, 1, 2, 2, 3, 4, 4, 4, | ||
| 1704 | 2, 2, 2, 3, 4, 4, 4, 4, | ||
| 1705 | 2, 2, 3, 4, 4, 5, 5, 5, | ||
| 1706 | 3, 3, 4, 4, 5, 5, 5, 5, | ||
| 1707 | 3, 4, 4, 4, 5, 5, 5, 5, | ||
| 1708 | 4, 4, 4, 4, 5, 5, 5, 5 | ||
| 1709 | }; | ||
| 1710 | |||
| 1711 | const unsigned char uvQuanTable511[] = { | ||
| 1712 | 0, 2, 2, 3, 4, 4, 4, 4, | ||
| 1713 | 2, 2, 2, 4, 4, 4, 4, 4, | ||
| 1714 | 2, 2, 3, 4, 4, 4, 4, 4, | ||
| 1715 | 3, 4, 4, 4, 4, 4, 4, 4, | ||
| 1716 | 4, 4, 4, 4, 4, 4, 4, 4, | ||
| 1717 | 4, 4, 4, 4, 4, 4, 4, 4, | ||
| 1718 | 4, 4, 4, 4, 4, 4, 4, 4, | ||
| 1719 | 4, 4, 4, 4, 4, 4, 4, 4 | ||
| 1720 | }; | ||
| 1721 | |||
| 1722 | /* OV518 quantization tables are 8x4 (instead of 8x8) */ | ||
| 1412 | const unsigned char yQuanTable518[] = { | 1723 | const unsigned char yQuanTable518[] = { |
| 1413 | 5, 4, 5, 6, 6, 7, 7, 7, | 1724 | 5, 4, 5, 6, 6, 7, 7, 7, |
| 1414 | 5, 5, 5, 5, 6, 7, 7, 7, | 1725 | 5, 5, 5, 5, 6, 7, 7, 7, |
| @@ -1423,14 +1734,23 @@ static int ov518_upload_quan_tables(struct sd *sd) | |||
| 1423 | 7, 7, 7, 7, 7, 7, 8, 8 | 1734 | 7, 7, 7, 7, 7, 7, 8, 8 |
| 1424 | }; | 1735 | }; |
| 1425 | 1736 | ||
| 1426 | const unsigned char *pYTable = yQuanTable518; | 1737 | const unsigned char *pYTable, *pUVTable; |
| 1427 | const unsigned char *pUVTable = uvQuanTable518; | ||
| 1428 | unsigned char val0, val1; | 1738 | unsigned char val0, val1; |
| 1429 | int i, rc, reg = R51x_COMP_LUT_BEGIN; | 1739 | int i, size, rc, reg = R51x_COMP_LUT_BEGIN; |
| 1430 | 1740 | ||
| 1431 | PDEBUG(D_PROBE, "Uploading quantization tables"); | 1741 | PDEBUG(D_PROBE, "Uploading quantization tables"); |
| 1432 | 1742 | ||
| 1433 | for (i = 0; i < 16; i++) { | 1743 | if (sd->bridge == BRIDGE_OV511 || sd->bridge == BRIDGE_OV511PLUS) { |
| 1744 | pYTable = yQuanTable511; | ||
| 1745 | pUVTable = uvQuanTable511; | ||
| 1746 | size = 32; | ||
| 1747 | } else { | ||
| 1748 | pYTable = yQuanTable518; | ||
| 1749 | pUVTable = uvQuanTable518; | ||
| 1750 | size = 16; | ||
| 1751 | } | ||
| 1752 | |||
| 1753 | for (i = 0; i < size; i++) { | ||
| 1434 | val0 = *pYTable++; | 1754 | val0 = *pYTable++; |
| 1435 | val1 = *pYTable++; | 1755 | val1 = *pYTable++; |
| 1436 | val0 &= 0x0f; | 1756 | val0 &= 0x0f; |
| @@ -1445,7 +1765,7 @@ static int ov518_upload_quan_tables(struct sd *sd) | |||
| 1445 | val0 &= 0x0f; | 1765 | val0 &= 0x0f; |
| 1446 | val1 &= 0x0f; | 1766 | val1 &= 0x0f; |
| 1447 | val0 |= val1 << 4; | 1767 | val0 |= val1 << 4; |
| 1448 | rc = reg_w(sd, reg + 16, val0); | 1768 | rc = reg_w(sd, reg + size, val0); |
| 1449 | if (rc < 0) | 1769 | if (rc < 0) |
| 1450 | return rc; | 1770 | return rc; |
| 1451 | 1771 | ||
| @@ -1455,6 +1775,87 @@ static int ov518_upload_quan_tables(struct sd *sd) | |||
| 1455 | return 0; | 1775 | return 0; |
| 1456 | } | 1776 | } |
| 1457 | 1777 | ||
| 1778 | /* This initializes the OV511/OV511+ and the sensor */ | ||
| 1779 | static int ov511_configure(struct gspca_dev *gspca_dev) | ||
| 1780 | { | ||
| 1781 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 1782 | int rc; | ||
| 1783 | |||
| 1784 | /* For 511 and 511+ */ | ||
| 1785 | const struct ov_regvals init_511[] = { | ||
| 1786 | { R51x_SYS_RESET, 0x7f }, | ||
| 1787 | { R51x_SYS_INIT, 0x01 }, | ||
| 1788 | { R51x_SYS_RESET, 0x7f }, | ||
| 1789 | { R51x_SYS_INIT, 0x01 }, | ||
| 1790 | { R51x_SYS_RESET, 0x3f }, | ||
| 1791 | { R51x_SYS_INIT, 0x01 }, | ||
| 1792 | { R51x_SYS_RESET, 0x3d }, | ||
| 1793 | }; | ||
| 1794 | |||
| 1795 | const struct ov_regvals norm_511[] = { | ||
| 1796 | { R511_DRAM_FLOW_CTL, 0x01 }, | ||
| 1797 | { R51x_SYS_SNAP, 0x00 }, | ||
| 1798 | { R51x_SYS_SNAP, 0x02 }, | ||
| 1799 | { R51x_SYS_SNAP, 0x00 }, | ||
| 1800 | { R511_FIFO_OPTS, 0x1f }, | ||
| 1801 | { R511_COMP_EN, 0x00 }, | ||
| 1802 | { R511_COMP_LUT_EN, 0x03 }, | ||
| 1803 | }; | ||
| 1804 | |||
| 1805 | const struct ov_regvals norm_511_p[] = { | ||
| 1806 | { R511_DRAM_FLOW_CTL, 0xff }, | ||
| 1807 | { R51x_SYS_SNAP, 0x00 }, | ||
| 1808 | { R51x_SYS_SNAP, 0x02 }, | ||
| 1809 | { R51x_SYS_SNAP, 0x00 }, | ||
| 1810 | { R511_FIFO_OPTS, 0xff }, | ||
| 1811 | { R511_COMP_EN, 0x00 }, | ||
| 1812 | { R511_COMP_LUT_EN, 0x03 }, | ||
| 1813 | }; | ||
| 1814 | |||
| 1815 | const struct ov_regvals compress_511[] = { | ||
| 1816 | { 0x70, 0x1f }, | ||
| 1817 | { 0x71, 0x05 }, | ||
| 1818 | { 0x72, 0x06 }, | ||
| 1819 | { 0x73, 0x06 }, | ||
| 1820 | { 0x74, 0x14 }, | ||
| 1821 | { 0x75, 0x03 }, | ||
| 1822 | { 0x76, 0x04 }, | ||
| 1823 | { 0x77, 0x04 }, | ||
| 1824 | }; | ||
| 1825 | |||
| 1826 | PDEBUG(D_PROBE, "Device custom id %x", reg_r(sd, R51x_SYS_CUST_ID)); | ||
| 1827 | |||
| 1828 | rc = write_regvals(sd, init_511, ARRAY_SIZE(init_511)); | ||
| 1829 | if (rc < 0) | ||
| 1830 | return rc; | ||
| 1831 | |||
| 1832 | switch (sd->bridge) { | ||
| 1833 | case BRIDGE_OV511: | ||
| 1834 | rc = write_regvals(sd, norm_511, ARRAY_SIZE(norm_511)); | ||
| 1835 | if (rc < 0) | ||
| 1836 | return rc; | ||
| 1837 | break; | ||
| 1838 | case BRIDGE_OV511PLUS: | ||
| 1839 | rc = write_regvals(sd, norm_511_p, ARRAY_SIZE(norm_511_p)); | ||
| 1840 | if (rc < 0) | ||
| 1841 | return rc; | ||
| 1842 | break; | ||
| 1843 | } | ||
| 1844 | |||
| 1845 | /* Init compression */ | ||
| 1846 | rc = write_regvals(sd, compress_511, ARRAY_SIZE(compress_511)); | ||
| 1847 | if (rc < 0) | ||
| 1848 | return rc; | ||
| 1849 | |||
| 1850 | rc = ov51x_upload_quan_tables(sd); | ||
| 1851 | if (rc < 0) { | ||
| 1852 | PDEBUG(D_ERR, "Error uploading quantization tables"); | ||
| 1853 | return rc; | ||
| 1854 | } | ||
| 1855 | |||
| 1856 | return 0; | ||
| 1857 | } | ||
| 1858 | |||
| 1458 | /* This initializes the OV518/OV518+ and the sensor */ | 1859 | /* This initializes the OV518/OV518+ and the sensor */ |
| 1459 | static int ov518_configure(struct gspca_dev *gspca_dev) | 1860 | static int ov518_configure(struct gspca_dev *gspca_dev) |
| 1460 | { | 1861 | { |
| @@ -1462,7 +1863,7 @@ static int ov518_configure(struct gspca_dev *gspca_dev) | |||
| 1462 | int rc; | 1863 | int rc; |
| 1463 | 1864 | ||
| 1464 | /* For 518 and 518+ */ | 1865 | /* For 518 and 518+ */ |
| 1465 | static struct ov_regvals init_518[] = { | 1866 | const struct ov_regvals init_518[] = { |
| 1466 | { R51x_SYS_RESET, 0x40 }, | 1867 | { R51x_SYS_RESET, 0x40 }, |
| 1467 | { R51x_SYS_INIT, 0xe1 }, | 1868 | { R51x_SYS_INIT, 0xe1 }, |
| 1468 | { R51x_SYS_RESET, 0x3e }, | 1869 | { R51x_SYS_RESET, 0x3e }, |
| @@ -1473,7 +1874,7 @@ static int ov518_configure(struct gspca_dev *gspca_dev) | |||
| 1473 | { 0x5d, 0x03 }, | 1874 | { 0x5d, 0x03 }, |
| 1474 | }; | 1875 | }; |
| 1475 | 1876 | ||
| 1476 | static struct ov_regvals norm_518[] = { | 1877 | const struct ov_regvals norm_518[] = { |
| 1477 | { R51x_SYS_SNAP, 0x02 }, /* Reset */ | 1878 | { R51x_SYS_SNAP, 0x02 }, /* Reset */ |
| 1478 | { R51x_SYS_SNAP, 0x01 }, /* Enable */ | 1879 | { R51x_SYS_SNAP, 0x01 }, /* Enable */ |
| 1479 | { 0x31, 0x0f }, | 1880 | { 0x31, 0x0f }, |
| @@ -1486,7 +1887,7 @@ static int ov518_configure(struct gspca_dev *gspca_dev) | |||
| 1486 | { 0x2f, 0x80 }, | 1887 | { 0x2f, 0x80 }, |
| 1487 | }; | 1888 | }; |
| 1488 | 1889 | ||
| 1489 | static struct ov_regvals norm_518_p[] = { | 1890 | const struct ov_regvals norm_518_p[] = { |
| 1490 | { R51x_SYS_SNAP, 0x02 }, /* Reset */ | 1891 | { R51x_SYS_SNAP, 0x02 }, /* Reset */ |
| 1491 | { R51x_SYS_SNAP, 0x01 }, /* Enable */ | 1892 | { R51x_SYS_SNAP, 0x01 }, /* Enable */ |
| 1492 | { 0x31, 0x0f }, | 1893 | { 0x31, 0x0f }, |
| @@ -1531,7 +1932,7 @@ static int ov518_configure(struct gspca_dev *gspca_dev) | |||
| 1531 | break; | 1932 | break; |
| 1532 | } | 1933 | } |
| 1533 | 1934 | ||
| 1534 | rc = ov518_upload_quan_tables(sd); | 1935 | rc = ov51x_upload_quan_tables(sd); |
| 1535 | if (rc < 0) { | 1936 | if (rc < 0) { |
| 1536 | PDEBUG(D_ERR, "Error uploading quantization tables"); | 1937 | PDEBUG(D_ERR, "Error uploading quantization tables"); |
| 1537 | return rc; | 1938 | return rc; |
| @@ -1573,9 +1974,14 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
| 1573 | struct cam *cam; | 1974 | struct cam *cam; |
| 1574 | int ret = 0; | 1975 | int ret = 0; |
| 1575 | 1976 | ||
| 1576 | sd->bridge = id->driver_info; | 1977 | sd->bridge = id->driver_info & BRIDGE_MASK; |
| 1978 | sd->invert_led = id->driver_info & BRIDGE_INVERT_LED; | ||
| 1577 | 1979 | ||
| 1578 | switch (sd->bridge) { | 1980 | switch (sd->bridge) { |
| 1981 | case BRIDGE_OV511: | ||
| 1982 | case BRIDGE_OV511PLUS: | ||
| 1983 | ret = ov511_configure(gspca_dev); | ||
| 1984 | break; | ||
| 1579 | case BRIDGE_OV518: | 1985 | case BRIDGE_OV518: |
| 1580 | case BRIDGE_OV518PLUS: | 1986 | case BRIDGE_OV518PLUS: |
| 1581 | ret = ov518_configure(gspca_dev); | 1987 | ret = ov518_configure(gspca_dev); |
| @@ -1634,6 +2040,16 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
| 1634 | 2040 | ||
| 1635 | cam = &gspca_dev->cam; | 2041 | cam = &gspca_dev->cam; |
| 1636 | switch (sd->bridge) { | 2042 | switch (sd->bridge) { |
| 2043 | case BRIDGE_OV511: | ||
| 2044 | case BRIDGE_OV511PLUS: | ||
| 2045 | if (!sd->sif) { | ||
| 2046 | cam->cam_mode = ov511_vga_mode; | ||
| 2047 | cam->nmodes = ARRAY_SIZE(ov511_vga_mode); | ||
| 2048 | } else { | ||
| 2049 | cam->cam_mode = ov511_sif_mode; | ||
| 2050 | cam->nmodes = ARRAY_SIZE(ov511_sif_mode); | ||
| 2051 | } | ||
| 2052 | break; | ||
| 1637 | case BRIDGE_OV518: | 2053 | case BRIDGE_OV518: |
| 1638 | case BRIDGE_OV518PLUS: | 2054 | case BRIDGE_OV518PLUS: |
| 1639 | if (!sd->sif) { | 2055 | if (!sd->sif) { |
| @@ -1655,13 +2071,28 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
| 1655 | break; | 2071 | break; |
| 1656 | } | 2072 | } |
| 1657 | sd->brightness = BRIGHTNESS_DEF; | 2073 | sd->brightness = BRIGHTNESS_DEF; |
| 1658 | sd->contrast = CONTRAST_DEF; | 2074 | if (sd->sensor == SEN_OV6630 || sd->sensor == SEN_OV66308AF) |
| 2075 | sd->contrast = 200; /* The default is too low for the ov6630 */ | ||
| 2076 | else | ||
| 2077 | sd->contrast = CONTRAST_DEF; | ||
| 1659 | sd->colors = COLOR_DEF; | 2078 | sd->colors = COLOR_DEF; |
| 1660 | sd->hflip = HFLIP_DEF; | 2079 | sd->hflip = HFLIP_DEF; |
| 1661 | sd->vflip = VFLIP_DEF; | 2080 | sd->vflip = VFLIP_DEF; |
| 1662 | if (sd->sensor != SEN_OV7670) | 2081 | sd->autobrightness = AUTOBRIGHT_DEF; |
| 1663 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | 2082 | if (sd->sensor == SEN_OV7670) { |
| 1664 | | (1 << VFLIP_IDX); | 2083 | sd->freq = OV7670_FREQ_DEF; |
| 2084 | gspca_dev->ctrl_dis = 1 << FREQ_IDX; | ||
| 2085 | } else { | ||
| 2086 | sd->freq = FREQ_DEF; | ||
| 2087 | gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | | ||
| 2088 | (1 << OV7670_FREQ_IDX); | ||
| 2089 | } | ||
| 2090 | if (sd->sensor == SEN_OV7640 || sd->sensor == SEN_OV7670) | ||
| 2091 | gspca_dev->ctrl_dis |= 1 << AUTOBRIGHT_IDX; | ||
| 2092 | /* OV8610 Frequency filter control should work but needs testing */ | ||
| 2093 | if (sd->sensor == SEN_OV8610) | ||
| 2094 | gspca_dev->ctrl_dis |= 1 << FREQ_IDX; | ||
| 2095 | |||
| 1665 | return 0; | 2096 | return 0; |
| 1666 | error: | 2097 | error: |
| 1667 | PDEBUG(D_ERR, "OV519 Config failed"); | 2098 | PDEBUG(D_ERR, "OV519 Config failed"); |
| @@ -1680,6 +2111,7 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
| 1680 | return -EIO; | 2111 | return -EIO; |
| 1681 | break; | 2112 | break; |
| 1682 | case SEN_OV6630: | 2113 | case SEN_OV6630: |
| 2114 | case SEN_OV66308AF: | ||
| 1683 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) | 2115 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) |
| 1684 | return -EIO; | 2116 | return -EIO; |
| 1685 | break; | 2117 | break; |
| @@ -1688,6 +2120,8 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
| 1688 | /* case SEN_OV76BE: */ | 2120 | /* case SEN_OV76BE: */ |
| 1689 | if (write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610))) | 2121 | if (write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610))) |
| 1690 | return -EIO; | 2122 | return -EIO; |
| 2123 | if (i2c_w_mask(sd, 0x0e, 0x00, 0x40)) | ||
| 2124 | return -EIO; | ||
| 1691 | break; | 2125 | break; |
| 1692 | case SEN_OV7620: | 2126 | case SEN_OV7620: |
| 1693 | if (write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620))) | 2127 | if (write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620))) |
| @@ -1709,6 +2143,126 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
| 1709 | return 0; | 2143 | return 0; |
| 1710 | } | 2144 | } |
| 1711 | 2145 | ||
| 2146 | /* Set up the OV511/OV511+ with the given image parameters. | ||
| 2147 | * | ||
| 2148 | * Do not put any sensor-specific code in here (including I2C I/O functions) | ||
| 2149 | */ | ||
| 2150 | static int ov511_mode_init_regs(struct sd *sd) | ||
| 2151 | { | ||
| 2152 | int hsegs, vsegs, packet_size, fps, needed; | ||
| 2153 | int interlaced = 0; | ||
| 2154 | struct usb_host_interface *alt; | ||
| 2155 | struct usb_interface *intf; | ||
| 2156 | |||
| 2157 | intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); | ||
| 2158 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); | ||
| 2159 | if (!alt) { | ||
| 2160 | PDEBUG(D_ERR, "Couldn't get altsetting"); | ||
| 2161 | return -EIO; | ||
| 2162 | } | ||
| 2163 | |||
| 2164 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | ||
| 2165 | reg_w(sd, R51x_FIFO_PSIZE, packet_size >> 5); | ||
| 2166 | |||
| 2167 | reg_w(sd, R511_CAM_UV_EN, 0x01); | ||
| 2168 | reg_w(sd, R511_SNAP_UV_EN, 0x01); | ||
| 2169 | reg_w(sd, R511_SNAP_OPTS, 0x03); | ||
| 2170 | |||
| 2171 | /* Here I'm assuming that snapshot size == image size. | ||
| 2172 | * I hope that's always true. --claudio | ||
| 2173 | */ | ||
| 2174 | hsegs = (sd->gspca_dev.width >> 3) - 1; | ||
| 2175 | vsegs = (sd->gspca_dev.height >> 3) - 1; | ||
| 2176 | |||
| 2177 | reg_w(sd, R511_CAM_PXCNT, hsegs); | ||
| 2178 | reg_w(sd, R511_CAM_LNCNT, vsegs); | ||
| 2179 | reg_w(sd, R511_CAM_PXDIV, 0x00); | ||
| 2180 | reg_w(sd, R511_CAM_LNDIV, 0x00); | ||
| 2181 | |||
| 2182 | /* YUV420, low pass filter on */ | ||
| 2183 | reg_w(sd, R511_CAM_OPTS, 0x03); | ||
| 2184 | |||
| 2185 | /* Snapshot additions */ | ||
| 2186 | reg_w(sd, R511_SNAP_PXCNT, hsegs); | ||
| 2187 | reg_w(sd, R511_SNAP_LNCNT, vsegs); | ||
| 2188 | reg_w(sd, R511_SNAP_PXDIV, 0x00); | ||
| 2189 | reg_w(sd, R511_SNAP_LNDIV, 0x00); | ||
| 2190 | |||
| 2191 | /******** Set the framerate ********/ | ||
| 2192 | if (frame_rate > 0) | ||
| 2193 | sd->frame_rate = frame_rate; | ||
| 2194 | |||
| 2195 | switch (sd->sensor) { | ||
| 2196 | case SEN_OV6620: | ||
| 2197 | /* No framerate control, doesn't like higher rates yet */ | ||
| 2198 | sd->clockdiv = 3; | ||
| 2199 | break; | ||
| 2200 | |||
| 2201 | /* Note once the FIXME's in mode_init_ov_sensor_regs() are fixed | ||
| 2202 | for more sensors we need to do this for them too */ | ||
| 2203 | case SEN_OV7620: | ||
| 2204 | case SEN_OV7640: | ||
| 2205 | case SEN_OV76BE: | ||
| 2206 | if (sd->gspca_dev.width == 320) | ||
| 2207 | interlaced = 1; | ||
| 2208 | /* Fall through */ | ||
| 2209 | case SEN_OV6630: | ||
| 2210 | case SEN_OV7610: | ||
| 2211 | case SEN_OV7670: | ||
| 2212 | switch (sd->frame_rate) { | ||
| 2213 | case 30: | ||
| 2214 | case 25: | ||
| 2215 | /* Not enough bandwidth to do 640x480 @ 30 fps */ | ||
| 2216 | if (sd->gspca_dev.width != 640) { | ||
| 2217 | sd->clockdiv = 0; | ||
| 2218 | break; | ||
| 2219 | } | ||
| 2220 | /* Fall through for 640x480 case */ | ||
| 2221 | default: | ||
| 2222 | /* case 20: */ | ||
| 2223 | /* case 15: */ | ||
| 2224 | sd->clockdiv = 1; | ||
| 2225 | break; | ||
| 2226 | case 10: | ||
| 2227 | sd->clockdiv = 2; | ||
| 2228 | break; | ||
| 2229 | case 5: | ||
| 2230 | sd->clockdiv = 5; | ||
| 2231 | break; | ||
| 2232 | } | ||
| 2233 | if (interlaced) { | ||
| 2234 | sd->clockdiv = (sd->clockdiv + 1) * 2 - 1; | ||
| 2235 | /* Higher then 10 does not work */ | ||
| 2236 | if (sd->clockdiv > 10) | ||
| 2237 | sd->clockdiv = 10; | ||
| 2238 | } | ||
| 2239 | break; | ||
| 2240 | |||
| 2241 | case SEN_OV8610: | ||
| 2242 | /* No framerate control ?? */ | ||
| 2243 | sd->clockdiv = 0; | ||
| 2244 | break; | ||
| 2245 | } | ||
| 2246 | |||
| 2247 | /* Check if we have enough bandwidth to disable compression */ | ||
| 2248 | fps = (interlaced ? 60 : 30) / (sd->clockdiv + 1) + 1; | ||
| 2249 | needed = fps * sd->gspca_dev.width * sd->gspca_dev.height * 3 / 2; | ||
| 2250 | /* 1400 is a conservative estimate of the max nr of isoc packets/sec */ | ||
| 2251 | if (needed > 1400 * packet_size) { | ||
| 2252 | /* Enable Y and UV quantization and compression */ | ||
| 2253 | reg_w(sd, R511_COMP_EN, 0x07); | ||
| 2254 | reg_w(sd, R511_COMP_LUT_EN, 0x03); | ||
| 2255 | } else { | ||
| 2256 | reg_w(sd, R511_COMP_EN, 0x06); | ||
| 2257 | reg_w(sd, R511_COMP_LUT_EN, 0x00); | ||
| 2258 | } | ||
| 2259 | |||
| 2260 | reg_w(sd, R51x_SYS_RESET, OV511_RESET_OMNICE); | ||
| 2261 | reg_w(sd, R51x_SYS_RESET, 0); | ||
| 2262 | |||
| 2263 | return 0; | ||
| 2264 | } | ||
| 2265 | |||
| 1712 | /* Sets up the OV518/OV518+ with the given image parameters | 2266 | /* Sets up the OV518/OV518+ with the given image parameters |
| 1713 | * | 2267 | * |
| 1714 | * OV518 needs a completely different approach, until we can figure out what | 2268 | * OV518 needs a completely different approach, until we can figure out what |
| @@ -1718,7 +2272,19 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
| 1718 | */ | 2272 | */ |
| 1719 | static int ov518_mode_init_regs(struct sd *sd) | 2273 | static int ov518_mode_init_regs(struct sd *sd) |
| 1720 | { | 2274 | { |
| 1721 | int hsegs, vsegs; | 2275 | int hsegs, vsegs, packet_size; |
| 2276 | struct usb_host_interface *alt; | ||
| 2277 | struct usb_interface *intf; | ||
| 2278 | |||
| 2279 | intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); | ||
| 2280 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); | ||
| 2281 | if (!alt) { | ||
| 2282 | PDEBUG(D_ERR, "Couldn't get altsetting"); | ||
| 2283 | return -EIO; | ||
| 2284 | } | ||
| 2285 | |||
| 2286 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | ||
| 2287 | ov518_reg_w32(sd, R51x_FIFO_PSIZE, packet_size & ~7, 2); | ||
| 1722 | 2288 | ||
| 1723 | /******** Set the mode ********/ | 2289 | /******** Set the mode ********/ |
| 1724 | 2290 | ||
| @@ -1755,20 +2321,30 @@ static int ov518_mode_init_regs(struct sd *sd) | |||
| 1755 | /* Windows driver does this here; who knows why */ | 2321 | /* Windows driver does this here; who knows why */ |
| 1756 | reg_w(sd, 0x2f, 0x80); | 2322 | reg_w(sd, 0x2f, 0x80); |
| 1757 | 2323 | ||
| 1758 | /******** Set the framerate (to 30 FPS) ********/ | 2324 | /******** Set the framerate ********/ |
| 1759 | if (sd->bridge == BRIDGE_OV518PLUS) | 2325 | sd->clockdiv = 1; |
| 1760 | sd->clockdiv = 1; | ||
| 1761 | else | ||
| 1762 | sd->clockdiv = 0; | ||
| 1763 | 2326 | ||
| 1764 | /* Mode independent, but framerate dependent, regs */ | 2327 | /* Mode independent, but framerate dependent, regs */ |
| 1765 | reg_w(sd, 0x51, 0x04); /* Clock divider; lower==faster */ | 2328 | /* 0x51: Clock divider; Only works on some cams which use 2 crystals */ |
| 2329 | reg_w(sd, 0x51, 0x04); | ||
| 1766 | reg_w(sd, 0x22, 0x18); | 2330 | reg_w(sd, 0x22, 0x18); |
| 1767 | reg_w(sd, 0x23, 0xff); | 2331 | reg_w(sd, 0x23, 0xff); |
| 1768 | 2332 | ||
| 1769 | if (sd->bridge == BRIDGE_OV518PLUS) | 2333 | if (sd->bridge == BRIDGE_OV518PLUS) { |
| 1770 | reg_w(sd, 0x21, 0x19); | 2334 | switch (sd->sensor) { |
| 1771 | else | 2335 | case SEN_OV7620: |
| 2336 | if (sd->gspca_dev.width == 320) { | ||
| 2337 | reg_w(sd, 0x20, 0x00); | ||
| 2338 | reg_w(sd, 0x21, 0x19); | ||
| 2339 | } else { | ||
| 2340 | reg_w(sd, 0x20, 0x60); | ||
| 2341 | reg_w(sd, 0x21, 0x1f); | ||
| 2342 | } | ||
| 2343 | break; | ||
| 2344 | default: | ||
| 2345 | reg_w(sd, 0x21, 0x19); | ||
| 2346 | } | ||
| 2347 | } else | ||
| 1772 | reg_w(sd, 0x71, 0x17); /* Compression-related? */ | 2348 | reg_w(sd, 0x71, 0x17); /* Compression-related? */ |
| 1773 | 2349 | ||
| 1774 | /* FIXME: Sensor-specific */ | 2350 | /* FIXME: Sensor-specific */ |
| @@ -1879,7 +2455,11 @@ static int ov519_mode_init_regs(struct sd *sd) | |||
| 1879 | 2455 | ||
| 1880 | reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.width >> 4); | 2456 | reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.width >> 4); |
| 1881 | reg_w(sd, OV519_R11_V_SIZE, sd->gspca_dev.height >> 3); | 2457 | reg_w(sd, OV519_R11_V_SIZE, sd->gspca_dev.height >> 3); |
| 1882 | reg_w(sd, OV519_R12_X_OFFSETL, 0x00); | 2458 | if (sd->sensor == SEN_OV7670 && |
| 2459 | sd->gspca_dev.cam.cam_mode[sd->gspca_dev.curr_mode].priv) | ||
| 2460 | reg_w(sd, OV519_R12_X_OFFSETL, 0x04); | ||
| 2461 | else | ||
| 2462 | reg_w(sd, OV519_R12_X_OFFSETL, 0x00); | ||
| 1883 | reg_w(sd, OV519_R13_X_OFFSETH, 0x00); | 2463 | reg_w(sd, OV519_R13_X_OFFSETH, 0x00); |
| 1884 | reg_w(sd, OV519_R14_Y_OFFSETL, 0x00); | 2464 | reg_w(sd, OV519_R14_Y_OFFSETL, 0x00); |
| 1885 | reg_w(sd, OV519_R15_Y_OFFSETH, 0x00); | 2465 | reg_w(sd, OV519_R15_Y_OFFSETH, 0x00); |
| @@ -1971,7 +2551,7 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
| 1971 | int qvga; | 2551 | int qvga; |
| 1972 | 2552 | ||
| 1973 | gspca_dev = &sd->gspca_dev; | 2553 | gspca_dev = &sd->gspca_dev; |
| 1974 | qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | 2554 | qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 1; |
| 1975 | 2555 | ||
| 1976 | /******** Mode (VGA/QVGA) and sensor specific regs ********/ | 2556 | /******** Mode (VGA/QVGA) and sensor specific regs ********/ |
| 1977 | switch (sd->sensor) { | 2557 | switch (sd->sensor) { |
| @@ -1983,21 +2563,16 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
| 1983 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); | 2563 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); |
| 1984 | break; | 2564 | break; |
| 1985 | case SEN_OV7620: | 2565 | case SEN_OV7620: |
| 1986 | /* i2c_w(sd, 0x2b, 0x00); */ | 2566 | case SEN_OV76BE: |
| 1987 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); | 2567 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); |
| 1988 | i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20); | 2568 | i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20); |
| 1989 | i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a); | 2569 | i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a); |
| 1990 | i2c_w(sd, 0x25, qvga ? 0x30 : 0x60); | 2570 | i2c_w(sd, 0x25, qvga ? 0x30 : 0x60); |
| 1991 | i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); | 2571 | i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); |
| 1992 | i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0); | 2572 | i2c_w_mask(sd, 0x67, qvga ? 0xb0 : 0x90, 0xf0); |
| 1993 | i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); | 2573 | i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); |
| 1994 | break; | 2574 | break; |
| 1995 | case SEN_OV76BE: | ||
| 1996 | /* i2c_w(sd, 0x2b, 0x00); */ | ||
| 1997 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); | ||
| 1998 | break; | ||
| 1999 | case SEN_OV7640: | 2575 | case SEN_OV7640: |
| 2000 | /* i2c_w(sd, 0x2b, 0x00); */ | ||
| 2001 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); | 2576 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); |
| 2002 | i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20); | 2577 | i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20); |
| 2003 | /* i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a); */ | 2578 | /* i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a); */ |
| @@ -2016,6 +2591,7 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
| 2016 | break; | 2591 | break; |
| 2017 | case SEN_OV6620: | 2592 | case SEN_OV6620: |
| 2018 | case SEN_OV6630: | 2593 | case SEN_OV6630: |
| 2594 | case SEN_OV66308AF: | ||
| 2019 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); | 2595 | i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); |
| 2020 | break; | 2596 | break; |
| 2021 | default: | 2597 | default: |
| @@ -2023,10 +2599,6 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
| 2023 | } | 2599 | } |
| 2024 | 2600 | ||
| 2025 | /******** Palette-specific regs ********/ | 2601 | /******** Palette-specific regs ********/ |
| 2026 | if (sd->sensor == SEN_OV7610 || sd->sensor == SEN_OV76BE) { | ||
| 2027 | /* not valid on the OV6620/OV7620/6630? */ | ||
| 2028 | i2c_w_mask(sd, 0x0e, 0x00, 0x40); | ||
| 2029 | } | ||
| 2030 | 2602 | ||
| 2031 | /* The OV518 needs special treatment. Although both the OV518 | 2603 | /* The OV518 needs special treatment. Although both the OV518 |
| 2032 | * and the OV6630 support a 16-bit video bus, only the 8 bit Y | 2604 | * and the OV6630 support a 16-bit video bus, only the 8 bit Y |
| @@ -2036,25 +2608,12 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
| 2036 | 2608 | ||
| 2037 | /* OV7640 is 8-bit only */ | 2609 | /* OV7640 is 8-bit only */ |
| 2038 | 2610 | ||
| 2039 | if (sd->sensor != SEN_OV6630 && sd->sensor != SEN_OV7640) | 2611 | if (sd->sensor != SEN_OV6630 && sd->sensor != SEN_OV66308AF && |
| 2612 | sd->sensor != SEN_OV7640) | ||
| 2040 | i2c_w_mask(sd, 0x13, 0x00, 0x20); | 2613 | i2c_w_mask(sd, 0x13, 0x00, 0x20); |
| 2041 | 2614 | ||
| 2042 | /******** Clock programming ********/ | 2615 | /******** Clock programming ********/ |
| 2043 | /* The OV6620 needs special handling. This prevents the | 2616 | i2c_w(sd, 0x11, sd->clockdiv); |
| 2044 | * severe banding that normally occurs */ | ||
| 2045 | if (sd->sensor == SEN_OV6620) { | ||
| 2046 | |||
| 2047 | /* Clock down */ | ||
| 2048 | i2c_w(sd, 0x2a, 0x04); | ||
| 2049 | i2c_w(sd, 0x11, sd->clockdiv); | ||
| 2050 | i2c_w(sd, 0x2a, 0x84); | ||
| 2051 | /* This next setting is critical. It seems to improve | ||
| 2052 | * the gain or the contrast. The "reserved" bits seem | ||
| 2053 | * to have some effect in this case. */ | ||
| 2054 | i2c_w(sd, 0x2d, 0x85); | ||
| 2055 | } else { | ||
| 2056 | i2c_w(sd, 0x11, sd->clockdiv); | ||
| 2057 | } | ||
| 2058 | 2617 | ||
| 2059 | /******** Special Features ********/ | 2618 | /******** Special Features ********/ |
| 2060 | /* no evidence this is possible with OV7670, either */ | 2619 | /* no evidence this is possible with OV7670, either */ |
| @@ -2098,13 +2657,14 @@ static void sethvflip(struct sd *sd) | |||
| 2098 | static int set_ov_sensor_window(struct sd *sd) | 2657 | static int set_ov_sensor_window(struct sd *sd) |
| 2099 | { | 2658 | { |
| 2100 | struct gspca_dev *gspca_dev; | 2659 | struct gspca_dev *gspca_dev; |
| 2101 | int qvga; | 2660 | int qvga, crop; |
| 2102 | int hwsbase, hwebase, vwsbase, vwebase, hwscale, vwscale; | 2661 | int hwsbase, hwebase, vwsbase, vwebase, hwscale, vwscale; |
| 2103 | int ret, hstart, hstop, vstop, vstart; | 2662 | int ret, hstart, hstop, vstop, vstart; |
| 2104 | __u8 v; | 2663 | __u8 v; |
| 2105 | 2664 | ||
| 2106 | gspca_dev = &sd->gspca_dev; | 2665 | gspca_dev = &sd->gspca_dev; |
| 2107 | qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | 2666 | qvga = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 1; |
| 2667 | crop = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv & 2; | ||
| 2108 | 2668 | ||
| 2109 | /* The different sensor ICs handle setting up of window differently. | 2669 | /* The different sensor ICs handle setting up of window differently. |
| 2110 | * IF YOU SET IT WRONG, YOU WILL GET ALL ZERO ISOC DATA FROM OV51x!! */ | 2670 | * IF YOU SET IT WRONG, YOU WILL GET ALL ZERO ISOC DATA FROM OV51x!! */ |
| @@ -2123,14 +2683,19 @@ static int set_ov_sensor_window(struct sd *sd) | |||
| 2123 | break; | 2683 | break; |
| 2124 | case SEN_OV6620: | 2684 | case SEN_OV6620: |
| 2125 | case SEN_OV6630: | 2685 | case SEN_OV6630: |
| 2686 | case SEN_OV66308AF: | ||
| 2126 | hwsbase = 0x38; | 2687 | hwsbase = 0x38; |
| 2127 | hwebase = 0x3a; | 2688 | hwebase = 0x3a; |
| 2128 | vwsbase = 0x05; | 2689 | vwsbase = 0x05; |
| 2129 | vwebase = 0x06; | 2690 | vwebase = 0x06; |
| 2130 | if (qvga) { | 2691 | if (sd->sensor == SEN_OV66308AF && qvga) |
| 2131 | /* HDG: this fixes U and V getting swapped */ | 2692 | /* HDG: this fixes U and V getting swapped */ |
| 2132 | hwsbase--; | 2693 | hwsbase++; |
| 2133 | vwsbase--; | 2694 | if (crop) { |
| 2695 | hwsbase += 8; | ||
| 2696 | hwebase += 8; | ||
| 2697 | vwsbase += 11; | ||
| 2698 | vwebase += 11; | ||
| 2134 | } | 2699 | } |
| 2135 | break; | 2700 | break; |
| 2136 | case SEN_OV7620: | 2701 | case SEN_OV7620: |
| @@ -2155,6 +2720,7 @@ static int set_ov_sensor_window(struct sd *sd) | |||
| 2155 | switch (sd->sensor) { | 2720 | switch (sd->sensor) { |
| 2156 | case SEN_OV6620: | 2721 | case SEN_OV6620: |
| 2157 | case SEN_OV6630: | 2722 | case SEN_OV6630: |
| 2723 | case SEN_OV66308AF: | ||
| 2158 | if (qvga) { /* QCIF */ | 2724 | if (qvga) { /* QCIF */ |
| 2159 | hwscale = 0; | 2725 | hwscale = 0; |
| 2160 | vwscale = 0; | 2726 | vwscale = 0; |
| @@ -2207,7 +2773,7 @@ static int set_ov_sensor_window(struct sd *sd) | |||
| 2207 | if (qvga) { /* QVGA from ov7670.c by | 2773 | if (qvga) { /* QVGA from ov7670.c by |
| 2208 | * Jonathan Corbet */ | 2774 | * Jonathan Corbet */ |
| 2209 | hstart = 164; | 2775 | hstart = 164; |
| 2210 | hstop = 20; | 2776 | hstop = 28; |
| 2211 | vstart = 14; | 2777 | vstart = 14; |
| 2212 | vstop = 494; | 2778 | vstop = 494; |
| 2213 | } else { /* VGA */ | 2779 | } else { /* VGA */ |
| @@ -2233,7 +2799,6 @@ static int set_ov_sensor_window(struct sd *sd) | |||
| 2233 | msleep(10); /* need to sleep between read and write to | 2799 | msleep(10); /* need to sleep between read and write to |
| 2234 | * same reg! */ | 2800 | * same reg! */ |
| 2235 | i2c_w(sd, OV7670_REG_VREF, v); | 2801 | i2c_w(sd, OV7670_REG_VREF, v); |
| 2236 | sethvflip(sd); | ||
| 2237 | } else { | 2802 | } else { |
| 2238 | i2c_w(sd, 0x17, hwsbase); | 2803 | i2c_w(sd, 0x17, hwsbase); |
| 2239 | i2c_w(sd, 0x18, hwebase + (sd->gspca_dev.width >> hwscale)); | 2804 | i2c_w(sd, 0x18, hwebase + (sd->gspca_dev.width >> hwscale)); |
| @@ -2250,6 +2815,10 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
| 2250 | int ret = 0; | 2815 | int ret = 0; |
| 2251 | 2816 | ||
| 2252 | switch (sd->bridge) { | 2817 | switch (sd->bridge) { |
| 2818 | case BRIDGE_OV511: | ||
| 2819 | case BRIDGE_OV511PLUS: | ||
| 2820 | ret = ov511_mode_init_regs(sd); | ||
| 2821 | break; | ||
| 2253 | case BRIDGE_OV518: | 2822 | case BRIDGE_OV518: |
| 2254 | case BRIDGE_OV518PLUS: | 2823 | case BRIDGE_OV518PLUS: |
| 2255 | ret = ov518_mode_init_regs(sd); | 2824 | ret = ov518_mode_init_regs(sd); |
| @@ -2268,6 +2837,9 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
| 2268 | setcontrast(gspca_dev); | 2837 | setcontrast(gspca_dev); |
| 2269 | setbrightness(gspca_dev); | 2838 | setbrightness(gspca_dev); |
| 2270 | setcolors(gspca_dev); | 2839 | setcolors(gspca_dev); |
| 2840 | sethvflip(sd); | ||
| 2841 | setautobrightness(sd); | ||
| 2842 | setfreq(sd); | ||
| 2271 | 2843 | ||
| 2272 | ret = ov51x_restart(sd); | 2844 | ret = ov51x_restart(sd); |
| 2273 | if (ret < 0) | 2845 | if (ret < 0) |
| @@ -2287,23 +2859,88 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
| 2287 | ov51x_led_control(sd, 0); | 2859 | ov51x_led_control(sd, 0); |
| 2288 | } | 2860 | } |
| 2289 | 2861 | ||
| 2290 | static void ov518_pkt_scan(struct gspca_dev *gspca_dev, | 2862 | static void ov511_pkt_scan(struct gspca_dev *gspca_dev, |
| 2291 | struct gspca_frame *frame, /* target */ | 2863 | struct gspca_frame *frame, /* target */ |
| 2292 | __u8 *data, /* isoc packet */ | 2864 | __u8 *in, /* isoc packet */ |
| 2293 | int len) /* iso packet length */ | 2865 | int len) /* iso packet length */ |
| 2294 | { | 2866 | { |
| 2295 | PDEBUG(D_STREAM, "ov518_pkt_scan: %d bytes", len); | 2867 | struct sd *sd = (struct sd *) gspca_dev; |
| 2296 | 2868 | ||
| 2297 | if (len & 7) { | 2869 | /* SOF/EOF packets have 1st to 8th bytes zeroed and the 9th |
| 2298 | len--; | 2870 | * byte non-zero. The EOF packet has image width/height in the |
| 2299 | PDEBUG(D_STREAM, "packet number: %d\n", (int)data[len]); | 2871 | * 10th and 11th bytes. The 9th byte is given as follows: |
| 2872 | * | ||
| 2873 | * bit 7: EOF | ||
| 2874 | * 6: compression enabled | ||
| 2875 | * 5: 422/420/400 modes | ||
| 2876 | * 4: 422/420/400 modes | ||
| 2877 | * 3: 1 | ||
| 2878 | * 2: snapshot button on | ||
| 2879 | * 1: snapshot frame | ||
| 2880 | * 0: even/odd field | ||
| 2881 | */ | ||
| 2882 | if (!(in[0] | in[1] | in[2] | in[3] | in[4] | in[5] | in[6] | in[7]) && | ||
| 2883 | (in[8] & 0x08)) { | ||
| 2884 | if (in[8] & 0x80) { | ||
| 2885 | /* Frame end */ | ||
| 2886 | if ((in[9] + 1) * 8 != gspca_dev->width || | ||
| 2887 | (in[10] + 1) * 8 != gspca_dev->height) { | ||
| 2888 | PDEBUG(D_ERR, "Invalid frame size, got: %dx%d," | ||
| 2889 | " requested: %dx%d\n", | ||
| 2890 | (in[9] + 1) * 8, (in[10] + 1) * 8, | ||
| 2891 | gspca_dev->width, gspca_dev->height); | ||
| 2892 | gspca_dev->last_packet_type = DISCARD_PACKET; | ||
| 2893 | return; | ||
| 2894 | } | ||
| 2895 | /* Add 11 byte footer to frame, might be usefull */ | ||
| 2896 | gspca_frame_add(gspca_dev, LAST_PACKET, frame, in, 11); | ||
| 2897 | return; | ||
| 2898 | } else { | ||
| 2899 | /* Frame start */ | ||
| 2900 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, in, 0); | ||
| 2901 | sd->packet_nr = 0; | ||
| 2902 | } | ||
| 2300 | } | 2903 | } |
| 2301 | 2904 | ||
| 2905 | /* Ignore the packet number */ | ||
| 2906 | len--; | ||
| 2907 | |||
| 2908 | /* intermediate packet */ | ||
| 2909 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, in, len); | ||
| 2910 | } | ||
| 2911 | |||
| 2912 | static void ov518_pkt_scan(struct gspca_dev *gspca_dev, | ||
| 2913 | struct gspca_frame *frame, /* target */ | ||
| 2914 | __u8 *data, /* isoc packet */ | ||
| 2915 | int len) /* iso packet length */ | ||
| 2916 | { | ||
| 2917 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 2918 | |||
| 2302 | /* A false positive here is likely, until OVT gives me | 2919 | /* A false positive here is likely, until OVT gives me |
| 2303 | * the definitive SOF/EOF format */ | 2920 | * the definitive SOF/EOF format */ |
| 2304 | if ((!(data[0] | data[1] | data[2] | data[3] | data[5])) && data[6]) { | 2921 | if ((!(data[0] | data[1] | data[2] | data[3] | data[5])) && data[6]) { |
| 2305 | gspca_frame_add(gspca_dev, LAST_PACKET, frame, data, 0); | 2922 | gspca_frame_add(gspca_dev, LAST_PACKET, frame, data, 0); |
| 2306 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, 0); | 2923 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, 0); |
| 2924 | sd->packet_nr = 0; | ||
| 2925 | } | ||
| 2926 | |||
| 2927 | if (gspca_dev->last_packet_type == DISCARD_PACKET) | ||
| 2928 | return; | ||
| 2929 | |||
| 2930 | /* Does this device use packet numbers ? */ | ||
| 2931 | if (len & 7) { | ||
| 2932 | len--; | ||
| 2933 | if (sd->packet_nr == data[len]) | ||
| 2934 | sd->packet_nr++; | ||
| 2935 | /* The last few packets of the frame (which are all 0's | ||
| 2936 | except that they may contain part of the footer), are | ||
| 2937 | numbered 0 */ | ||
| 2938 | else if (sd->packet_nr == 0 || data[len]) { | ||
| 2939 | PDEBUG(D_ERR, "Invalid packet nr: %d (expect: %d)", | ||
| 2940 | (int)data[len], (int)sd->packet_nr); | ||
| 2941 | gspca_dev->last_packet_type = DISCARD_PACKET; | ||
| 2942 | return; | ||
| 2943 | } | ||
| 2307 | } | 2944 | } |
| 2308 | 2945 | ||
| 2309 | /* intermediate packet */ | 2946 | /* intermediate packet */ |
| @@ -2364,6 +3001,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
| 2364 | switch (sd->bridge) { | 3001 | switch (sd->bridge) { |
| 2365 | case BRIDGE_OV511: | 3002 | case BRIDGE_OV511: |
| 2366 | case BRIDGE_OV511PLUS: | 3003 | case BRIDGE_OV511PLUS: |
| 3004 | ov511_pkt_scan(gspca_dev, frame, data, len); | ||
| 2367 | break; | 3005 | break; |
| 2368 | case BRIDGE_OV518: | 3006 | case BRIDGE_OV518: |
| 2369 | case BRIDGE_OV518PLUS: | 3007 | case BRIDGE_OV518PLUS: |
| @@ -2389,13 +3027,13 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
| 2389 | case SEN_OV76BE: | 3027 | case SEN_OV76BE: |
| 2390 | case SEN_OV6620: | 3028 | case SEN_OV6620: |
| 2391 | case SEN_OV6630: | 3029 | case SEN_OV6630: |
| 3030 | case SEN_OV66308AF: | ||
| 2392 | case SEN_OV7640: | 3031 | case SEN_OV7640: |
| 2393 | i2c_w(sd, OV7610_REG_BRT, val); | 3032 | i2c_w(sd, OV7610_REG_BRT, val); |
| 2394 | break; | 3033 | break; |
| 2395 | case SEN_OV7620: | 3034 | case SEN_OV7620: |
| 2396 | /* 7620 doesn't like manual changes when in auto mode */ | 3035 | /* 7620 doesn't like manual changes when in auto mode */ |
| 2397 | /*fixme | 3036 | if (!sd->autobrightness) |
| 2398 | * if (!sd->auto_brt) */ | ||
| 2399 | i2c_w(sd, OV7610_REG_BRT, val); | 3037 | i2c_w(sd, OV7610_REG_BRT, val); |
| 2400 | break; | 3038 | break; |
| 2401 | case SEN_OV7670: | 3039 | case SEN_OV7670: |
| @@ -2418,6 +3056,7 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
| 2418 | i2c_w(sd, OV7610_REG_CNT, val); | 3056 | i2c_w(sd, OV7610_REG_CNT, val); |
| 2419 | break; | 3057 | break; |
| 2420 | case SEN_OV6630: | 3058 | case SEN_OV6630: |
| 3059 | case SEN_OV66308AF: | ||
| 2421 | i2c_w_mask(sd, OV7610_REG_CNT, val >> 4, 0x0f); | 3060 | i2c_w_mask(sd, OV7610_REG_CNT, val >> 4, 0x0f); |
| 2422 | break; | 3061 | break; |
| 2423 | case SEN_OV8610: { | 3062 | case SEN_OV8610: { |
| @@ -2462,6 +3101,7 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
| 2462 | case SEN_OV76BE: | 3101 | case SEN_OV76BE: |
| 2463 | case SEN_OV6620: | 3102 | case SEN_OV6620: |
| 2464 | case SEN_OV6630: | 3103 | case SEN_OV6630: |
| 3104 | case SEN_OV66308AF: | ||
| 2465 | i2c_w(sd, OV7610_REG_SAT, val); | 3105 | i2c_w(sd, OV7610_REG_SAT, val); |
| 2466 | break; | 3106 | break; |
| 2467 | case SEN_OV7620: | 3107 | case SEN_OV7620: |
| @@ -2482,6 +3122,72 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
| 2482 | } | 3122 | } |
| 2483 | } | 3123 | } |
| 2484 | 3124 | ||
| 3125 | static void setautobrightness(struct sd *sd) | ||
| 3126 | { | ||
| 3127 | if (sd->sensor == SEN_OV7640 || sd->sensor == SEN_OV7670) | ||
| 3128 | return; | ||
| 3129 | |||
| 3130 | i2c_w_mask(sd, 0x2d, sd->autobrightness ? 0x10 : 0x00, 0x10); | ||
| 3131 | } | ||
| 3132 | |||
| 3133 | static void setfreq(struct sd *sd) | ||
| 3134 | { | ||
| 3135 | if (sd->sensor == SEN_OV7670) { | ||
| 3136 | switch (sd->freq) { | ||
| 3137 | case 0: /* Banding filter disabled */ | ||
| 3138 | i2c_w_mask(sd, OV7670_REG_COM8, 0, OV7670_COM8_BFILT); | ||
| 3139 | break; | ||
| 3140 | case 1: /* 50 hz */ | ||
| 3141 | i2c_w_mask(sd, OV7670_REG_COM8, OV7670_COM8_BFILT, | ||
| 3142 | OV7670_COM8_BFILT); | ||
| 3143 | i2c_w_mask(sd, OV7670_REG_COM11, 0x08, 0x18); | ||
| 3144 | break; | ||
| 3145 | case 2: /* 60 hz */ | ||
| 3146 | i2c_w_mask(sd, OV7670_REG_COM8, OV7670_COM8_BFILT, | ||
| 3147 | OV7670_COM8_BFILT); | ||
| 3148 | i2c_w_mask(sd, OV7670_REG_COM11, 0x00, 0x18); | ||
| 3149 | break; | ||
| 3150 | case 3: /* Auto hz */ | ||
| 3151 | i2c_w_mask(sd, OV7670_REG_COM8, OV7670_COM8_BFILT, | ||
| 3152 | OV7670_COM8_BFILT); | ||
| 3153 | i2c_w_mask(sd, OV7670_REG_COM11, OV7670_COM11_HZAUTO, | ||
| 3154 | 0x18); | ||
| 3155 | break; | ||
| 3156 | } | ||
| 3157 | } else { | ||
| 3158 | switch (sd->freq) { | ||
| 3159 | case 0: /* Banding filter disabled */ | ||
| 3160 | i2c_w_mask(sd, 0x2d, 0x00, 0x04); | ||
| 3161 | i2c_w_mask(sd, 0x2a, 0x00, 0x80); | ||
| 3162 | break; | ||
| 3163 | case 1: /* 50 hz (filter on and framerate adj) */ | ||
| 3164 | i2c_w_mask(sd, 0x2d, 0x04, 0x04); | ||
| 3165 | i2c_w_mask(sd, 0x2a, 0x80, 0x80); | ||
| 3166 | /* 20 fps -> 16.667 fps */ | ||
| 3167 | if (sd->sensor == SEN_OV6620 || | ||
| 3168 | sd->sensor == SEN_OV6630 || | ||
| 3169 | sd->sensor == SEN_OV66308AF) | ||
| 3170 | i2c_w(sd, 0x2b, 0x5e); | ||
| 3171 | else | ||
| 3172 | i2c_w(sd, 0x2b, 0xac); | ||
| 3173 | break; | ||
| 3174 | case 2: /* 60 hz (filter on, ...) */ | ||
| 3175 | i2c_w_mask(sd, 0x2d, 0x04, 0x04); | ||
| 3176 | if (sd->sensor == SEN_OV6620 || | ||
| 3177 | sd->sensor == SEN_OV6630 || | ||
| 3178 | sd->sensor == SEN_OV66308AF) { | ||
| 3179 | /* 20 fps -> 15 fps */ | ||
| 3180 | i2c_w_mask(sd, 0x2a, 0x80, 0x80); | ||
| 3181 | i2c_w(sd, 0x2b, 0xa8); | ||
| 3182 | } else { | ||
| 3183 | /* no framerate adj. */ | ||
| 3184 | i2c_w_mask(sd, 0x2a, 0x00, 0x80); | ||
| 3185 | } | ||
| 3186 | break; | ||
| 3187 | } | ||
| 3188 | } | ||
| 3189 | } | ||
| 3190 | |||
| 2485 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 3191 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
| 2486 | { | 3192 | { |
| 2487 | struct sd *sd = (struct sd *) gspca_dev; | 3193 | struct sd *sd = (struct sd *) gspca_dev; |
| @@ -2572,6 +3278,71 @@ static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
| 2572 | return 0; | 3278 | return 0; |
| 2573 | } | 3279 | } |
| 2574 | 3280 | ||
| 3281 | static int sd_setautobrightness(struct gspca_dev *gspca_dev, __s32 val) | ||
| 3282 | { | ||
| 3283 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 3284 | |||
| 3285 | sd->autobrightness = val; | ||
| 3286 | if (gspca_dev->streaming) | ||
| 3287 | setautobrightness(sd); | ||
| 3288 | return 0; | ||
| 3289 | } | ||
| 3290 | |||
| 3291 | static int sd_getautobrightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
| 3292 | { | ||
| 3293 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 3294 | |||
| 3295 | *val = sd->autobrightness; | ||
| 3296 | return 0; | ||
| 3297 | } | ||
| 3298 | |||
| 3299 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val) | ||
| 3300 | { | ||
| 3301 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 3302 | |||
| 3303 | sd->freq = val; | ||
| 3304 | if (gspca_dev->streaming) | ||
| 3305 | setfreq(sd); | ||
| 3306 | return 0; | ||
| 3307 | } | ||
| 3308 | |||
| 3309 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) | ||
| 3310 | { | ||
| 3311 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 3312 | |||
| 3313 | *val = sd->freq; | ||
| 3314 | return 0; | ||
| 3315 | } | ||
| 3316 | |||
| 3317 | static int sd_querymenu(struct gspca_dev *gspca_dev, | ||
| 3318 | struct v4l2_querymenu *menu) | ||
| 3319 | { | ||
| 3320 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 3321 | |||
| 3322 | switch (menu->id) { | ||
| 3323 | case V4L2_CID_POWER_LINE_FREQUENCY: | ||
| 3324 | switch (menu->index) { | ||
| 3325 | case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */ | ||
| 3326 | strcpy((char *) menu->name, "NoFliker"); | ||
| 3327 | return 0; | ||
| 3328 | case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */ | ||
| 3329 | strcpy((char *) menu->name, "50 Hz"); | ||
| 3330 | return 0; | ||
| 3331 | case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */ | ||
| 3332 | strcpy((char *) menu->name, "60 Hz"); | ||
| 3333 | return 0; | ||
| 3334 | case 3: | ||
| 3335 | if (sd->sensor != SEN_OV7670) | ||
| 3336 | return -EINVAL; | ||
| 3337 | |||
| 3338 | strcpy((char *) menu->name, "Automatic"); | ||
| 3339 | return 0; | ||
| 3340 | } | ||
| 3341 | break; | ||
| 3342 | } | ||
| 3343 | return -EINVAL; | ||
| 3344 | } | ||
| 3345 | |||
| 2575 | /* sub-driver description */ | 3346 | /* sub-driver description */ |
| 2576 | static const struct sd_desc sd_desc = { | 3347 | static const struct sd_desc sd_desc = { |
| 2577 | .name = MODULE_NAME, | 3348 | .name = MODULE_NAME, |
| @@ -2582,6 +3353,7 @@ static const struct sd_desc sd_desc = { | |||
| 2582 | .start = sd_start, | 3353 | .start = sd_start, |
| 2583 | .stopN = sd_stopN, | 3354 | .stopN = sd_stopN, |
| 2584 | .pkt_scan = sd_pkt_scan, | 3355 | .pkt_scan = sd_pkt_scan, |
| 3356 | .querymenu = sd_querymenu, | ||
| 2585 | }; | 3357 | }; |
| 2586 | 3358 | ||
| 2587 | /* -- module initialisation -- */ | 3359 | /* -- module initialisation -- */ |
| @@ -2590,17 +3362,22 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
| 2590 | {USB_DEVICE(0x041e, 0x405f), .driver_info = BRIDGE_OV519 }, | 3362 | {USB_DEVICE(0x041e, 0x405f), .driver_info = BRIDGE_OV519 }, |
| 2591 | {USB_DEVICE(0x041e, 0x4060), .driver_info = BRIDGE_OV519 }, | 3363 | {USB_DEVICE(0x041e, 0x4060), .driver_info = BRIDGE_OV519 }, |
| 2592 | {USB_DEVICE(0x041e, 0x4061), .driver_info = BRIDGE_OV519 }, | 3364 | {USB_DEVICE(0x041e, 0x4061), .driver_info = BRIDGE_OV519 }, |
| 2593 | {USB_DEVICE(0x041e, 0x4064), .driver_info = BRIDGE_OV519 }, | 3365 | {USB_DEVICE(0x041e, 0x4064), |
| 2594 | {USB_DEVICE(0x041e, 0x4068), .driver_info = BRIDGE_OV519 }, | 3366 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, |
| 3367 | {USB_DEVICE(0x041e, 0x4068), | ||
| 3368 | .driver_info = BRIDGE_OV519 | BRIDGE_INVERT_LED }, | ||
| 2595 | {USB_DEVICE(0x045e, 0x028c), .driver_info = BRIDGE_OV519 }, | 3369 | {USB_DEVICE(0x045e, 0x028c), .driver_info = BRIDGE_OV519 }, |
| 2596 | {USB_DEVICE(0x054c, 0x0154), .driver_info = BRIDGE_OV519 }, | 3370 | {USB_DEVICE(0x054c, 0x0154), .driver_info = BRIDGE_OV519 }, |
| 2597 | {USB_DEVICE(0x054c, 0x0155), .driver_info = BRIDGE_OV519 }, | 3371 | {USB_DEVICE(0x054c, 0x0155), .driver_info = BRIDGE_OV519 }, |
| 3372 | {USB_DEVICE(0x05a9, 0x0511), .driver_info = BRIDGE_OV511 }, | ||
| 2598 | {USB_DEVICE(0x05a9, 0x0518), .driver_info = BRIDGE_OV518 }, | 3373 | {USB_DEVICE(0x05a9, 0x0518), .driver_info = BRIDGE_OV518 }, |
| 2599 | {USB_DEVICE(0x05a9, 0x0519), .driver_info = BRIDGE_OV519 }, | 3374 | {USB_DEVICE(0x05a9, 0x0519), .driver_info = BRIDGE_OV519 }, |
| 2600 | {USB_DEVICE(0x05a9, 0x0530), .driver_info = BRIDGE_OV519 }, | 3375 | {USB_DEVICE(0x05a9, 0x0530), .driver_info = BRIDGE_OV519 }, |
| 2601 | {USB_DEVICE(0x05a9, 0x4519), .driver_info = BRIDGE_OV519 }, | 3376 | {USB_DEVICE(0x05a9, 0x4519), .driver_info = BRIDGE_OV519 }, |
| 2602 | {USB_DEVICE(0x05a9, 0x8519), .driver_info = BRIDGE_OV519 }, | 3377 | {USB_DEVICE(0x05a9, 0x8519), .driver_info = BRIDGE_OV519 }, |
| 3378 | {USB_DEVICE(0x05a9, 0xa511), .driver_info = BRIDGE_OV511PLUS }, | ||
| 2603 | {USB_DEVICE(0x05a9, 0xa518), .driver_info = BRIDGE_OV518PLUS }, | 3379 | {USB_DEVICE(0x05a9, 0xa518), .driver_info = BRIDGE_OV518PLUS }, |
| 3380 | {USB_DEVICE(0x0813, 0x0002), .driver_info = BRIDGE_OV511PLUS }, | ||
| 2604 | {} | 3381 | {} |
| 2605 | }; | 3382 | }; |
| 2606 | 3383 | ||
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index dc6a6f11354a..0d02f41fa7d0 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
| @@ -46,6 +46,7 @@ struct sd { | |||
| 46 | u8 gamma; | 46 | u8 gamma; |
| 47 | u8 vflip; /* ov7630/ov7648 only */ | 47 | u8 vflip; /* ov7630/ov7648 only */ |
| 48 | u8 infrared; /* mt9v111 only */ | 48 | u8 infrared; /* mt9v111 only */ |
| 49 | u8 freq; /* ov76xx only */ | ||
| 49 | u8 quality; /* image quality */ | 50 | u8 quality; /* image quality */ |
| 50 | #define QUALITY_MIN 60 | 51 | #define QUALITY_MIN 60 |
| 51 | #define QUALITY_MAX 95 | 52 | #define QUALITY_MAX 95 |
| @@ -96,8 +97,11 @@ static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); | |||
| 96 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); | 97 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val); |
| 97 | static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val); | 98 | static int sd_setinfrared(struct gspca_dev *gspca_dev, __s32 val); |
| 98 | static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val); | 99 | static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val); |
| 100 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val); | ||
| 101 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); | ||
| 99 | 102 | ||
| 100 | static struct ctrl sd_ctrls[] = { | 103 | static struct ctrl sd_ctrls[] = { |
| 104 | #define BRIGHTNESS_IDX 0 | ||
| 101 | { | 105 | { |
| 102 | { | 106 | { |
| 103 | .id = V4L2_CID_BRIGHTNESS, | 107 | .id = V4L2_CID_BRIGHTNESS, |
| @@ -113,6 +117,7 @@ static struct ctrl sd_ctrls[] = { | |||
| 113 | .set = sd_setbrightness, | 117 | .set = sd_setbrightness, |
| 114 | .get = sd_getbrightness, | 118 | .get = sd_getbrightness, |
| 115 | }, | 119 | }, |
| 120 | #define CONTRAST_IDX 1 | ||
| 116 | { | 121 | { |
| 117 | { | 122 | { |
| 118 | .id = V4L2_CID_CONTRAST, | 123 | .id = V4L2_CID_CONTRAST, |
| @@ -128,20 +133,22 @@ static struct ctrl sd_ctrls[] = { | |||
| 128 | .set = sd_setcontrast, | 133 | .set = sd_setcontrast, |
| 129 | .get = sd_getcontrast, | 134 | .get = sd_getcontrast, |
| 130 | }, | 135 | }, |
| 136 | #define COLOR_IDX 2 | ||
| 131 | { | 137 | { |
| 132 | { | 138 | { |
| 133 | .id = V4L2_CID_SATURATION, | 139 | .id = V4L2_CID_SATURATION, |
| 134 | .type = V4L2_CTRL_TYPE_INTEGER, | 140 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 135 | .name = "Color", | 141 | .name = "Saturation", |
| 136 | .minimum = 0, | 142 | .minimum = 0, |
| 137 | .maximum = 40, | 143 | .maximum = 40, |
| 138 | .step = 1, | 144 | .step = 1, |
| 139 | #define COLOR_DEF 32 | 145 | #define COLOR_DEF 25 |
| 140 | .default_value = COLOR_DEF, | 146 | .default_value = COLOR_DEF, |
| 141 | }, | 147 | }, |
| 142 | .set = sd_setcolors, | 148 | .set = sd_setcolors, |
| 143 | .get = sd_getcolors, | 149 | .get = sd_getcolors, |
| 144 | }, | 150 | }, |
| 151 | #define BLUE_BALANCE_IDX 3 | ||
| 145 | { | 152 | { |
| 146 | { | 153 | { |
| 147 | .id = V4L2_CID_BLUE_BALANCE, | 154 | .id = V4L2_CID_BLUE_BALANCE, |
| @@ -156,6 +163,7 @@ static struct ctrl sd_ctrls[] = { | |||
| 156 | .set = sd_setblue_balance, | 163 | .set = sd_setblue_balance, |
| 157 | .get = sd_getblue_balance, | 164 | .get = sd_getblue_balance, |
| 158 | }, | 165 | }, |
| 166 | #define RED_BALANCE_IDX 4 | ||
| 159 | { | 167 | { |
| 160 | { | 168 | { |
| 161 | .id = V4L2_CID_RED_BALANCE, | 169 | .id = V4L2_CID_RED_BALANCE, |
| @@ -170,6 +178,7 @@ static struct ctrl sd_ctrls[] = { | |||
| 170 | .set = sd_setred_balance, | 178 | .set = sd_setred_balance, |
| 171 | .get = sd_getred_balance, | 179 | .get = sd_getred_balance, |
| 172 | }, | 180 | }, |
| 181 | #define GAMMA_IDX 5 | ||
| 173 | { | 182 | { |
| 174 | { | 183 | { |
| 175 | .id = V4L2_CID_GAMMA, | 184 | .id = V4L2_CID_GAMMA, |
| @@ -184,7 +193,7 @@ static struct ctrl sd_ctrls[] = { | |||
| 184 | .set = sd_setgamma, | 193 | .set = sd_setgamma, |
| 185 | .get = sd_getgamma, | 194 | .get = sd_getgamma, |
| 186 | }, | 195 | }, |
| 187 | #define AUTOGAIN_IDX 5 | 196 | #define AUTOGAIN_IDX 6 |
| 188 | { | 197 | { |
| 189 | { | 198 | { |
| 190 | .id = V4L2_CID_AUTOGAIN, | 199 | .id = V4L2_CID_AUTOGAIN, |
| @@ -200,7 +209,7 @@ static struct ctrl sd_ctrls[] = { | |||
| 200 | .get = sd_getautogain, | 209 | .get = sd_getautogain, |
| 201 | }, | 210 | }, |
| 202 | /* ov7630/ov7648 only */ | 211 | /* ov7630/ov7648 only */ |
| 203 | #define VFLIP_IDX 6 | 212 | #define VFLIP_IDX 7 |
| 204 | { | 213 | { |
| 205 | { | 214 | { |
| 206 | .id = V4L2_CID_VFLIP, | 215 | .id = V4L2_CID_VFLIP, |
| @@ -209,14 +218,14 @@ static struct ctrl sd_ctrls[] = { | |||
| 209 | .minimum = 0, | 218 | .minimum = 0, |
| 210 | .maximum = 1, | 219 | .maximum = 1, |
| 211 | .step = 1, | 220 | .step = 1, |
| 212 | #define VFLIP_DEF 0 /* vflip def = 1 for ov7630 */ | 221 | #define VFLIP_DEF 0 |
| 213 | .default_value = VFLIP_DEF, | 222 | .default_value = VFLIP_DEF, |
| 214 | }, | 223 | }, |
| 215 | .set = sd_setvflip, | 224 | .set = sd_setvflip, |
| 216 | .get = sd_getvflip, | 225 | .get = sd_getvflip, |
| 217 | }, | 226 | }, |
| 218 | /* mt9v111 only */ | 227 | /* mt9v111 only */ |
| 219 | #define INFRARED_IDX 7 | 228 | #define INFRARED_IDX 8 |
| 220 | { | 229 | { |
| 221 | { | 230 | { |
| 222 | .id = V4L2_CID_INFRARED, | 231 | .id = V4L2_CID_INFRARED, |
| @@ -231,28 +240,44 @@ static struct ctrl sd_ctrls[] = { | |||
| 231 | .set = sd_setinfrared, | 240 | .set = sd_setinfrared, |
| 232 | .get = sd_getinfrared, | 241 | .get = sd_getinfrared, |
| 233 | }, | 242 | }, |
| 243 | /* ov7630/ov7648/ov7660 only */ | ||
| 244 | #define FREQ_IDX 9 | ||
| 245 | { | ||
| 246 | { | ||
| 247 | .id = V4L2_CID_POWER_LINE_FREQUENCY, | ||
| 248 | .type = V4L2_CTRL_TYPE_MENU, | ||
| 249 | .name = "Light frequency filter", | ||
| 250 | .minimum = 0, | ||
| 251 | .maximum = 2, /* 0: 0, 1: 50Hz, 2:60Hz */ | ||
| 252 | .step = 1, | ||
| 253 | #define FREQ_DEF 2 | ||
| 254 | .default_value = FREQ_DEF, | ||
| 255 | }, | ||
| 256 | .set = sd_setfreq, | ||
| 257 | .get = sd_getfreq, | ||
| 258 | }, | ||
| 234 | }; | 259 | }; |
| 235 | 260 | ||
| 236 | /* table of the disabled controls */ | 261 | /* table of the disabled controls */ |
| 237 | static __u32 ctrl_dis[] = { | 262 | static __u32 ctrl_dis[] = { |
| 238 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 263 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
| 239 | /* SENSOR_HV7131R 0 */ | 264 | /* SENSOR_HV7131R 0 */ |
| 240 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 265 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
| 241 | /* SENSOR_MI0360 1 */ | 266 | /* SENSOR_MI0360 1 */ |
| 242 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 267 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
| 243 | /* SENSOR_MO4000 2 */ | 268 | /* SENSOR_MO4000 2 */ |
| 244 | (1 << VFLIP_IDX), | 269 | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
| 245 | /* SENSOR_MT9V111 3 */ | 270 | /* SENSOR_MT9V111 3 */ |
| 246 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 271 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | (1 << FREQ_IDX), |
| 247 | /* SENSOR_OM6802 4 */ | 272 | /* SENSOR_OM6802 4 */ |
| 248 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX), | 273 | (1 << INFRARED_IDX), |
| 249 | /* SENSOR_OV7630 5 */ | 274 | /* SENSOR_OV7630 5 */ |
| 250 | (1 << INFRARED_IDX), | 275 | (1 << INFRARED_IDX), |
| 251 | /* SENSOR_OV7648 6 */ | 276 | /* SENSOR_OV7648 6 */ |
| 252 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 277 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), |
| 253 | /* SENSOR_OV7660 7 */ | 278 | /* SENSOR_OV7660 7 */ |
| 254 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 279 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX) | |
| 255 | /* SENSOR_SP80708 8 */ | 280 | (1 << FREQ_IDX), /* SENSOR_SP80708 8 */ |
| 256 | }; | 281 | }; |
| 257 | 282 | ||
| 258 | static const struct v4l2_pix_format vga_mode[] = { | 283 | static const struct v4l2_pix_format vga_mode[] = { |
| @@ -268,7 +293,8 @@ static const struct v4l2_pix_format vga_mode[] = { | |||
| 268 | .priv = 1}, | 293 | .priv = 1}, |
| 269 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 294 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
| 270 | .bytesperline = 640, | 295 | .bytesperline = 640, |
| 271 | .sizeimage = 640 * 480 * 3 / 8 + 590, | 296 | /* Note 3 / 8 is not large enough, not even 5 / 8 is ?! */ |
| 297 | .sizeimage = 640 * 480 * 3 / 4 + 590, | ||
| 272 | .colorspace = V4L2_COLORSPACE_JPEG, | 298 | .colorspace = V4L2_COLORSPACE_JPEG, |
| 273 | .priv = 0}, | 299 | .priv = 0}, |
| 274 | }; | 300 | }; |
| @@ -604,7 +630,9 @@ static const u8 ov7630_sensor_init[][8] = { | |||
| 604 | /* win: i2c_r from 00 to 80 */ | 630 | /* win: i2c_r from 00 to 80 */ |
| 605 | {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, | 631 | {0xd1, 0x21, 0x03, 0x80, 0x10, 0x20, 0x80, 0x10}, |
| 606 | {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10}, | 632 | {0xb1, 0x21, 0x0c, 0x20, 0x20, 0x00, 0x00, 0x10}, |
| 607 | {0xd1, 0x21, 0x11, 0x00, 0x48, 0xc0, 0x00, 0x10}, | 633 | /* HDG: 0x11 was 0x00 change to 0x01 for better exposure (15 fps instead of 30) |
| 634 | 0x13 was 0xc0 change to 0xc3 for auto gain and exposure */ | ||
| 635 | {0xd1, 0x21, 0x11, 0x01, 0x48, 0xc3, 0x00, 0x10}, | ||
| 608 | {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10}, | 636 | {0xb1, 0x21, 0x15, 0x80, 0x03, 0x00, 0x00, 0x10}, |
| 609 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, | 637 | {0xd1, 0x21, 0x17, 0x1b, 0xbd, 0x05, 0xf6, 0x10}, |
| 610 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, | 638 | {0xa1, 0x21, 0x1b, 0x04, 0x00, 0x00, 0x00, 0x10}, |
| @@ -638,9 +666,8 @@ static const u8 ov7630_sensor_init[][8] = { | |||
| 638 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | 666 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
| 639 | {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10}, | 667 | {0xb1, 0x21, 0x01, 0x80, 0x80, 0x00, 0x00, 0x10}, |
| 640 | /* */ | 668 | /* */ |
| 641 | {0xa1, 0x21, 0x11, 0x00, 0x00, 0x00, 0x00, 0x10}, | 669 | /* {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */ |
| 642 | {0xa1, 0x21, 0x2a, 0x88, 0x00, 0x00, 0x00, 0x10}, | 670 | /* {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, * set by setfreq */ |
| 643 | {0xa1, 0x21, 0x2b, 0x34, 0x00, 0x00, 0x00, 0x10}, | ||
| 644 | /* */ | 671 | /* */ |
| 645 | {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10}, | 672 | {0xa1, 0x21, 0x10, 0x83, 0x00, 0x00, 0x00, 0x10}, |
| 646 | /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */ | 673 | /* {0xb1, 0x21, 0x01, 0x88, 0x70, 0x00, 0x00, 0x10}, */ |
| @@ -673,7 +700,7 @@ static const u8 ov7648_sensor_init[][8] = { | |||
| 673 | {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10}, | 700 | {0xd1, 0x21, 0x21, 0x86, 0x00, 0xde, 0xa0, 0x10}, |
| 674 | /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */ | 701 | /* {0xd1, 0x21, 0x25, 0x80, 0x32, 0xfe, 0xa0, 0x10}, jfm done */ |
| 675 | /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */ | 702 | /* {0xd1, 0x21, 0x29, 0x00, 0x91, 0x00, 0x88, 0x10}, jfm done */ |
| 676 | {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, | 703 | /* {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, set by setfreq */ |
| 677 | /*...*/ | 704 | /*...*/ |
| 678 | /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */ | 705 | /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
| 679 | /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN | 706 | /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN |
| @@ -1294,11 +1321,9 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
| 1294 | sd->gamma = GAMMA_DEF; | 1321 | sd->gamma = GAMMA_DEF; |
| 1295 | sd->autogain = AUTOGAIN_DEF; | 1322 | sd->autogain = AUTOGAIN_DEF; |
| 1296 | sd->ag_cnt = -1; | 1323 | sd->ag_cnt = -1; |
| 1297 | if (sd->sensor != SENSOR_OV7630) | 1324 | sd->vflip = VFLIP_DEF; |
| 1298 | sd->vflip = 0; | ||
| 1299 | else | ||
| 1300 | sd->vflip = 1; | ||
| 1301 | sd->infrared = INFRARED_DEF; | 1325 | sd->infrared = INFRARED_DEF; |
| 1326 | sd->freq = FREQ_DEF; | ||
| 1302 | sd->quality = QUALITY_DEF; | 1327 | sd->quality = QUALITY_DEF; |
| 1303 | sd->jpegqual = 80; | 1328 | sd->jpegqual = 80; |
| 1304 | 1329 | ||
| @@ -1569,7 +1594,7 @@ static void setautogain(struct gspca_dev *gspca_dev) | |||
| 1569 | else | 1594 | else |
| 1570 | comb = 0xa0; | 1595 | comb = 0xa0; |
| 1571 | if (sd->autogain) | 1596 | if (sd->autogain) |
| 1572 | comb |= 0x02; | 1597 | comb |= 0x03; |
| 1573 | i2c_w1(&sd->gspca_dev, 0x13, comb); | 1598 | i2c_w1(&sd->gspca_dev, 0x13, comb); |
| 1574 | return; | 1599 | return; |
| 1575 | } | 1600 | } |
| @@ -1585,12 +1610,15 @@ static void setvflip(struct sd *sd) | |||
| 1585 | { | 1610 | { |
| 1586 | u8 comn; | 1611 | u8 comn; |
| 1587 | 1612 | ||
| 1588 | if (sd->sensor == SENSOR_OV7630) | 1613 | if (sd->sensor == SENSOR_OV7630) { |
| 1589 | comn = 0x02; | 1614 | comn = 0x02; |
| 1590 | else | 1615 | if (!sd->vflip) |
| 1616 | comn |= 0x80; | ||
| 1617 | } else { | ||
| 1591 | comn = 0x06; | 1618 | comn = 0x06; |
| 1592 | if (sd->vflip) | 1619 | if (sd->vflip) |
| 1593 | comn |= 0x80; | 1620 | comn |= 0x80; |
| 1621 | } | ||
| 1594 | i2c_w1(&sd->gspca_dev, 0x75, comn); | 1622 | i2c_w1(&sd->gspca_dev, 0x75, comn); |
| 1595 | } | 1623 | } |
| 1596 | 1624 | ||
| @@ -1602,6 +1630,58 @@ static void setinfrared(struct sd *sd) | |||
| 1602 | sd->infrared ? 0x66 : 0x64); | 1630 | sd->infrared ? 0x66 : 0x64); |
| 1603 | } | 1631 | } |
| 1604 | 1632 | ||
| 1633 | static void setfreq(struct gspca_dev *gspca_dev) | ||
| 1634 | { | ||
| 1635 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 1636 | |||
| 1637 | if (sd->sensor == SENSOR_OV7660) { | ||
| 1638 | switch (sd->freq) { | ||
| 1639 | case 0: /* Banding filter disabled */ | ||
| 1640 | i2c_w1(gspca_dev, 0x13, 0xdf); | ||
| 1641 | break; | ||
| 1642 | case 1: /* 50 hz */ | ||
| 1643 | i2c_w1(gspca_dev, 0x13, 0xff); | ||
| 1644 | i2c_w1(gspca_dev, 0x3b, 0x0a); | ||
| 1645 | break; | ||
| 1646 | case 2: /* 60 hz */ | ||
| 1647 | i2c_w1(gspca_dev, 0x13, 0xff); | ||
| 1648 | i2c_w1(gspca_dev, 0x3b, 0x02); | ||
| 1649 | break; | ||
| 1650 | } | ||
| 1651 | } else { | ||
| 1652 | u8 reg2a = 0, reg2b = 0, reg2d = 0; | ||
| 1653 | |||
| 1654 | /* Get reg2a / reg2d base values */ | ||
| 1655 | switch (sd->sensor) { | ||
| 1656 | case SENSOR_OV7630: | ||
| 1657 | reg2a = 0x08; | ||
| 1658 | reg2d = 0x01; | ||
| 1659 | break; | ||
| 1660 | case SENSOR_OV7648: | ||
| 1661 | reg2a = 0x11; | ||
| 1662 | reg2d = 0x81; | ||
| 1663 | break; | ||
| 1664 | } | ||
| 1665 | |||
| 1666 | switch (sd->freq) { | ||
| 1667 | case 0: /* Banding filter disabled */ | ||
| 1668 | break; | ||
| 1669 | case 1: /* 50 hz (filter on and framerate adj) */ | ||
| 1670 | reg2a |= 0x80; | ||
| 1671 | reg2b = 0xac; | ||
| 1672 | reg2d |= 0x04; | ||
| 1673 | break; | ||
| 1674 | case 2: /* 60 hz (filter on, no framerate adj) */ | ||
| 1675 | reg2a |= 0x80; | ||
| 1676 | reg2d |= 0x04; | ||
| 1677 | break; | ||
| 1678 | } | ||
| 1679 | i2c_w1(gspca_dev, 0x2a, reg2a); | ||
| 1680 | i2c_w1(gspca_dev, 0x2b, reg2b); | ||
| 1681 | i2c_w1(gspca_dev, 0x2d, reg2d); | ||
| 1682 | } | ||
| 1683 | } | ||
| 1684 | |||
| 1605 | static void setjpegqual(struct gspca_dev *gspca_dev) | 1685 | static void setjpegqual(struct gspca_dev *gspca_dev) |
| 1606 | { | 1686 | { |
| 1607 | struct sd *sd = (struct sd *) gspca_dev; | 1687 | struct sd *sd = (struct sd *) gspca_dev; |
| @@ -1828,6 +1908,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
| 1828 | setbrightness(gspca_dev); | 1908 | setbrightness(gspca_dev); |
| 1829 | setcontrast(gspca_dev); | 1909 | setcontrast(gspca_dev); |
| 1830 | setautogain(gspca_dev); | 1910 | setautogain(gspca_dev); |
| 1911 | setfreq(gspca_dev); | ||
| 1831 | return 0; | 1912 | return 0; |
| 1832 | } | 1913 | } |
| 1833 | 1914 | ||
| @@ -2131,6 +2212,24 @@ static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val) | |||
| 2131 | return 0; | 2212 | return 0; |
| 2132 | } | 2213 | } |
| 2133 | 2214 | ||
| 2215 | static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val) | ||
| 2216 | { | ||
| 2217 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 2218 | |||
| 2219 | sd->freq = val; | ||
| 2220 | if (gspca_dev->streaming) | ||
| 2221 | setfreq(gspca_dev); | ||
| 2222 | return 0; | ||
| 2223 | } | ||
| 2224 | |||
| 2225 | static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val) | ||
| 2226 | { | ||
| 2227 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 2228 | |||
| 2229 | *val = sd->freq; | ||
| 2230 | return 0; | ||
| 2231 | } | ||
| 2232 | |||
| 2134 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, | 2233 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, |
| 2135 | struct v4l2_jpegcompression *jcomp) | 2234 | struct v4l2_jpegcompression *jcomp) |
| 2136 | { | 2235 | { |
| @@ -2159,6 +2258,27 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev, | |||
| 2159 | return 0; | 2258 | return 0; |
| 2160 | } | 2259 | } |
| 2161 | 2260 | ||
| 2261 | static int sd_querymenu(struct gspca_dev *gspca_dev, | ||
| 2262 | struct v4l2_querymenu *menu) | ||
| 2263 | { | ||
| 2264 | switch (menu->id) { | ||
| 2265 | case V4L2_CID_POWER_LINE_FREQUENCY: | ||
| 2266 | switch (menu->index) { | ||
| 2267 | case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */ | ||
| 2268 | strcpy((char *) menu->name, "NoFliker"); | ||
| 2269 | return 0; | ||
| 2270 | case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */ | ||
| 2271 | strcpy((char *) menu->name, "50 Hz"); | ||
| 2272 | return 0; | ||
| 2273 | case 2: /* V4L2_CID_POWER_LINE_FREQUENCY_60HZ */ | ||
| 2274 | strcpy((char *) menu->name, "60 Hz"); | ||
| 2275 | return 0; | ||
| 2276 | } | ||
| 2277 | break; | ||
| 2278 | } | ||
| 2279 | return -EINVAL; | ||
| 2280 | } | ||
| 2281 | |||
| 2162 | /* sub-driver description */ | 2282 | /* sub-driver description */ |
| 2163 | static const struct sd_desc sd_desc = { | 2283 | static const struct sd_desc sd_desc = { |
| 2164 | .name = MODULE_NAME, | 2284 | .name = MODULE_NAME, |
| @@ -2173,6 +2293,7 @@ static const struct sd_desc sd_desc = { | |||
| 2173 | .dq_callback = do_autogain, | 2293 | .dq_callback = do_autogain, |
| 2174 | .get_jcomp = sd_get_jcomp, | 2294 | .get_jcomp = sd_get_jcomp, |
| 2175 | .set_jcomp = sd_set_jcomp, | 2295 | .set_jcomp = sd_set_jcomp, |
| 2296 | .querymenu = sd_querymenu, | ||
| 2176 | }; | 2297 | }; |
| 2177 | 2298 | ||
| 2178 | /* -- module initialisation -- */ | 2299 | /* -- module initialisation -- */ |
| @@ -2233,7 +2354,7 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
| 2233 | {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, | 2354 | {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, |
| 2234 | #endif | 2355 | #endif |
| 2235 | {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, | 2356 | {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, |
| 2236 | /* {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x??)}, */ | 2357 | {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x21)}, |
| 2237 | {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)}, | 2358 | {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)}, |
| 2238 | {} | 2359 | {} |
| 2239 | }; | 2360 | }; |
diff --git a/drivers/media/video/gspca/stv06xx/Makefile b/drivers/media/video/gspca/stv06xx/Makefile index feeaa94ab588..2f3c3a606ce4 100644 --- a/drivers/media/video/gspca/stv06xx/Makefile +++ b/drivers/media/video/gspca/stv06xx/Makefile | |||
| @@ -3,7 +3,8 @@ obj-$(CONFIG_USB_STV06XX) += gspca_stv06xx.o | |||
| 3 | gspca_stv06xx-objs := stv06xx.o \ | 3 | gspca_stv06xx-objs := stv06xx.o \ |
| 4 | stv06xx_vv6410.o \ | 4 | stv06xx_vv6410.o \ |
| 5 | stv06xx_hdcs.o \ | 5 | stv06xx_hdcs.o \ |
| 6 | stv06xx_pb0100.o | 6 | stv06xx_pb0100.o \ |
| 7 | stv06xx_st6422.o | ||
| 7 | 8 | ||
| 8 | EXTRA_CFLAGS += -Idrivers/media/video/gspca | 9 | EXTRA_CFLAGS += -Idrivers/media/video/gspca |
| 9 | 10 | ||
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.c b/drivers/media/video/gspca/stv06xx/stv06xx.c index e573c3406324..0da8e0de0456 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx.c +++ b/drivers/media/video/gspca/stv06xx/stv06xx.c | |||
| @@ -92,11 +92,10 @@ static int stv06xx_write_sensor_finish(struct sd *sd) | |||
| 92 | { | 92 | { |
| 93 | int err = 0; | 93 | int err = 0; |
| 94 | 94 | ||
| 95 | if (IS_850(sd)) { | 95 | if (sd->bridge == BRIDGE_STV610) { |
| 96 | struct usb_device *udev = sd->gspca_dev.dev; | 96 | struct usb_device *udev = sd->gspca_dev.dev; |
| 97 | __u8 *buf = sd->gspca_dev.usb_buf; | 97 | __u8 *buf = sd->gspca_dev.usb_buf; |
| 98 | 98 | ||
| 99 | /* Quickam Web needs an extra packet */ | ||
| 100 | buf[0] = 0; | 99 | buf[0] = 0; |
| 101 | err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 100 | err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
| 102 | 0x04, 0x40, 0x1704, 0, buf, 1, | 101 | 0x04, 0x40, 0x1704, 0, buf, 1, |
| @@ -253,7 +252,7 @@ static int stv06xx_init(struct gspca_dev *gspca_dev) | |||
| 253 | 252 | ||
| 254 | err = sd->sensor->init(sd); | 253 | err = sd->sensor->init(sd); |
| 255 | 254 | ||
| 256 | if (dump_sensor) | 255 | if (dump_sensor && sd->sensor->dump) |
| 257 | sd->sensor->dump(sd); | 256 | sd->sensor->dump(sd); |
| 258 | 257 | ||
| 259 | return (err < 0) ? err : 0; | 258 | return (err < 0) ? err : 0; |
| @@ -318,6 +317,8 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, | |||
| 318 | __u8 *data, /* isoc packet */ | 317 | __u8 *data, /* isoc packet */ |
| 319 | int len) /* iso packet length */ | 318 | int len) /* iso packet length */ |
| 320 | { | 319 | { |
| 320 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 321 | |||
| 321 | PDEBUG(D_PACK, "Packet of length %d arrived", len); | 322 | PDEBUG(D_PACK, "Packet of length %d arrived", len); |
| 322 | 323 | ||
| 323 | /* A packet may contain several frames | 324 | /* A packet may contain several frames |
| @@ -343,14 +344,29 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, | |||
| 343 | if (len < chunk_len) { | 344 | if (len < chunk_len) { |
| 344 | PDEBUG(D_ERR, "URB packet length is smaller" | 345 | PDEBUG(D_ERR, "URB packet length is smaller" |
| 345 | " than the specified chunk length"); | 346 | " than the specified chunk length"); |
| 347 | gspca_dev->last_packet_type = DISCARD_PACKET; | ||
| 346 | return; | 348 | return; |
| 347 | } | 349 | } |
| 348 | 350 | ||
| 351 | /* First byte seem to be 02=data 2nd byte is unknown??? */ | ||
| 352 | if (sd->bridge == BRIDGE_ST6422 && (id & 0xFF00) == 0x0200) | ||
| 353 | goto frame_data; | ||
| 354 | |||
| 349 | switch (id) { | 355 | switch (id) { |
| 350 | case 0x0200: | 356 | case 0x0200: |
| 351 | case 0x4200: | 357 | case 0x4200: |
| 358 | frame_data: | ||
| 352 | PDEBUG(D_PACK, "Frame data packet detected"); | 359 | PDEBUG(D_PACK, "Frame data packet detected"); |
| 353 | 360 | ||
| 361 | if (sd->to_skip) { | ||
| 362 | int skip = (sd->to_skip < chunk_len) ? | ||
| 363 | sd->to_skip : chunk_len; | ||
| 364 | data += skip; | ||
| 365 | len -= skip; | ||
| 366 | chunk_len -= skip; | ||
| 367 | sd->to_skip -= skip; | ||
| 368 | } | ||
| 369 | |||
| 354 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, | 370 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, |
| 355 | data, chunk_len); | 371 | data, chunk_len); |
| 356 | break; | 372 | break; |
| @@ -365,6 +381,9 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, | |||
| 365 | gspca_frame_add(gspca_dev, FIRST_PACKET, | 381 | gspca_frame_add(gspca_dev, FIRST_PACKET, |
| 366 | frame, data, 0); | 382 | frame, data, 0); |
| 367 | 383 | ||
| 384 | if (sd->bridge == BRIDGE_ST6422) | ||
| 385 | sd->to_skip = gspca_dev->width * 4; | ||
| 386 | |||
| 368 | if (chunk_len) | 387 | if (chunk_len) |
| 369 | PDEBUG(D_ERR, "Chunk length is " | 388 | PDEBUG(D_ERR, "Chunk length is " |
| 370 | "non-zero on a SOF"); | 389 | "non-zero on a SOF"); |
| @@ -395,8 +414,12 @@ static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, | |||
| 395 | /* Unknown chunk with 2 bytes of data, | 414 | /* Unknown chunk with 2 bytes of data, |
| 396 | occurs 2-3 times per USB interrupt */ | 415 | occurs 2-3 times per USB interrupt */ |
| 397 | break; | 416 | break; |
| 417 | case 0x42ff: | ||
| 418 | PDEBUG(D_PACK, "Chunk 0x42ff detected"); | ||
| 419 | /* Special chunk seen sometimes on the ST6422 */ | ||
| 420 | break; | ||
| 398 | default: | 421 | default: |
| 399 | PDEBUG(D_PACK, "Unknown chunk %d detected", id); | 422 | PDEBUG(D_PACK, "Unknown chunk 0x%04x detected", id); |
| 400 | /* Unknown chunk */ | 423 | /* Unknown chunk */ |
| 401 | } | 424 | } |
| 402 | data += chunk_len; | 425 | data += chunk_len; |
| @@ -428,11 +451,16 @@ static int stv06xx_config(struct gspca_dev *gspca_dev, | |||
| 428 | 451 | ||
| 429 | cam = &gspca_dev->cam; | 452 | cam = &gspca_dev->cam; |
| 430 | sd->desc = sd_desc; | 453 | sd->desc = sd_desc; |
| 454 | sd->bridge = id->driver_info; | ||
| 431 | gspca_dev->sd_desc = &sd->desc; | 455 | gspca_dev->sd_desc = &sd->desc; |
| 432 | 456 | ||
| 433 | if (dump_bridge) | 457 | if (dump_bridge) |
| 434 | stv06xx_dump_bridge(sd); | 458 | stv06xx_dump_bridge(sd); |
| 435 | 459 | ||
| 460 | sd->sensor = &stv06xx_sensor_st6422; | ||
| 461 | if (!sd->sensor->probe(sd)) | ||
| 462 | return 0; | ||
| 463 | |||
| 436 | sd->sensor = &stv06xx_sensor_vv6410; | 464 | sd->sensor = &stv06xx_sensor_vv6410; |
| 437 | if (!sd->sensor->probe(sd)) | 465 | if (!sd->sensor->probe(sd)) |
| 438 | return 0; | 466 | return 0; |
| @@ -457,9 +485,20 @@ static int stv06xx_config(struct gspca_dev *gspca_dev, | |||
| 457 | 485 | ||
| 458 | /* -- module initialisation -- */ | 486 | /* -- module initialisation -- */ |
| 459 | static const __devinitdata struct usb_device_id device_table[] = { | 487 | static const __devinitdata struct usb_device_id device_table[] = { |
| 460 | {USB_DEVICE(0x046d, 0x0840)}, /* QuickCam Express */ | 488 | /* QuickCam Express */ |
| 461 | {USB_DEVICE(0x046d, 0x0850)}, /* LEGO cam / QuickCam Web */ | 489 | {USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 }, |
| 462 | {USB_DEVICE(0x046d, 0x0870)}, /* Dexxa WebCam USB */ | 490 | /* LEGO cam / QuickCam Web */ |
| 491 | {USB_DEVICE(0x046d, 0x0850), .driver_info = BRIDGE_STV610 }, | ||
| 492 | /* Dexxa WebCam USB */ | ||
| 493 | {USB_DEVICE(0x046d, 0x0870), .driver_info = BRIDGE_STV602 }, | ||
| 494 | /* QuickCam Messenger */ | ||
| 495 | {USB_DEVICE(0x046D, 0x08F0), .driver_info = BRIDGE_ST6422 }, | ||
| 496 | /* QuickCam Communicate */ | ||
| 497 | {USB_DEVICE(0x046D, 0x08F5), .driver_info = BRIDGE_ST6422 }, | ||
| 498 | /* QuickCam Messenger (new) */ | ||
| 499 | {USB_DEVICE(0x046D, 0x08F6), .driver_info = BRIDGE_ST6422 }, | ||
| 500 | /* QuickCam Messenger (new) */ | ||
| 501 | {USB_DEVICE(0x046D, 0x08DA), .driver_info = BRIDGE_ST6422 }, | ||
| 463 | {} | 502 | {} |
| 464 | }; | 503 | }; |
| 465 | MODULE_DEVICE_TABLE(usb, device_table); | 504 | MODULE_DEVICE_TABLE(usb, device_table); |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.h b/drivers/media/video/gspca/stv06xx/stv06xx.h index 1207e7d17f14..9df7137fe67e 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx.h +++ b/drivers/media/video/gspca/stv06xx/stv06xx.h | |||
| @@ -93,6 +93,17 @@ struct sd { | |||
| 93 | 93 | ||
| 94 | /* Sensor private data */ | 94 | /* Sensor private data */ |
| 95 | void *sensor_priv; | 95 | void *sensor_priv; |
| 96 | |||
| 97 | /* The first 4 lines produced by the stv6422 are no good, this keeps | ||
| 98 | track of how many bytes we still need to skip during a frame */ | ||
| 99 | int to_skip; | ||
| 100 | |||
| 101 | /* Bridge / Camera type */ | ||
| 102 | u8 bridge; | ||
| 103 | #define BRIDGE_STV600 0 | ||
| 104 | #define BRIDGE_STV602 1 | ||
| 105 | #define BRIDGE_STV610 2 | ||
| 106 | #define BRIDGE_ST6422 3 /* With integrated sensor */ | ||
| 96 | }; | 107 | }; |
| 97 | 108 | ||
| 98 | int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data); | 109 | int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data); |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.c b/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.c index b16903814203..3039ec208f3a 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.c +++ b/drivers/media/video/gspca/stv06xx/stv06xx_hdcs.c | |||
| @@ -434,7 +434,7 @@ static int hdcs_probe_1x00(struct sd *sd) | |||
| 434 | hdcs->exp.er = 100; | 434 | hdcs->exp.er = 100; |
| 435 | 435 | ||
| 436 | /* | 436 | /* |
| 437 | * Frame rate on HDCS-1000 0x46D:0x840 depends on PSMP: | 437 | * Frame rate on HDCS-1000 with STV600 depends on PSMP: |
| 438 | * 4 = doesn't work at all | 438 | * 4 = doesn't work at all |
| 439 | * 5 = 7.8 fps, | 439 | * 5 = 7.8 fps, |
| 440 | * 6 = 6.9 fps, | 440 | * 6 = 6.9 fps, |
| @@ -443,7 +443,7 @@ static int hdcs_probe_1x00(struct sd *sd) | |||
| 443 | * 15 = 4.4 fps, | 443 | * 15 = 4.4 fps, |
| 444 | * 31 = 2.8 fps | 444 | * 31 = 2.8 fps |
| 445 | * | 445 | * |
| 446 | * Frame rate on HDCS-1000 0x46D:0x870 depends on PSMP: | 446 | * Frame rate on HDCS-1000 with STV602 depends on PSMP: |
| 447 | * 15 = doesn't work at all | 447 | * 15 = doesn't work at all |
| 448 | * 18 = doesn't work at all | 448 | * 18 = doesn't work at all |
| 449 | * 19 = 7.3 fps | 449 | * 19 = 7.3 fps |
| @@ -453,7 +453,7 @@ static int hdcs_probe_1x00(struct sd *sd) | |||
| 453 | * 24 = 6.3 fps | 453 | * 24 = 6.3 fps |
| 454 | * 30 = 5.4 fps | 454 | * 30 = 5.4 fps |
| 455 | */ | 455 | */ |
| 456 | hdcs->psmp = IS_870(sd) ? 20 : 5; | 456 | hdcs->psmp = (sd->bridge == BRIDGE_STV602) ? 20 : 5; |
| 457 | 457 | ||
| 458 | sd->sensor_priv = hdcs; | 458 | sd->sensor_priv = hdcs; |
| 459 | 459 | ||
| @@ -530,7 +530,7 @@ static int hdcs_init(struct sd *sd) | |||
| 530 | int i, err = 0; | 530 | int i, err = 0; |
| 531 | 531 | ||
| 532 | /* Set the STV0602AA in STV0600 emulation mode */ | 532 | /* Set the STV0602AA in STV0600 emulation mode */ |
| 533 | if (IS_870(sd)) | 533 | if (sd->bridge == BRIDGE_STV602) |
| 534 | stv06xx_write_bridge(sd, STV_STV0600_EMULATION, 1); | 534 | stv06xx_write_bridge(sd, STV_STV0600_EMULATION, 1); |
| 535 | 535 | ||
| 536 | /* Execute the bridge init */ | 536 | /* Execute the bridge init */ |
| @@ -558,7 +558,7 @@ static int hdcs_init(struct sd *sd) | |||
| 558 | return err; | 558 | return err; |
| 559 | 559 | ||
| 560 | /* Set PGA sample duration | 560 | /* Set PGA sample duration |
| 561 | (was 0x7E for IS_870, but caused slow framerate with HDCS-1020) */ | 561 | (was 0x7E for the STV602, but caused slow framerate with HDCS-1020) */ |
| 562 | if (IS_1020(sd)) | 562 | if (IS_1020(sd)) |
| 563 | err = stv06xx_write_sensor(sd, HDCS_TCTRL, | 563 | err = stv06xx_write_sensor(sd, HDCS_TCTRL, |
| 564 | (HDCS_ADC_START_SIG_DUR << 6) | hdcs->psmp); | 564 | (HDCS_ADC_START_SIG_DUR << 6) | hdcs->psmp); |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_sensor.h b/drivers/media/video/gspca/stv06xx/stv06xx_sensor.h index e88c42f7d2f8..934b9cebc1ab 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx_sensor.h +++ b/drivers/media/video/gspca/stv06xx/stv06xx_sensor.h | |||
| @@ -32,14 +32,13 @@ | |||
| 32 | 32 | ||
| 33 | #include "stv06xx.h" | 33 | #include "stv06xx.h" |
| 34 | 34 | ||
| 35 | #define IS_850(sd) ((sd)->gspca_dev.dev->descriptor.idProduct == 0x850) | ||
| 36 | #define IS_870(sd) ((sd)->gspca_dev.dev->descriptor.idProduct == 0x870) | ||
| 37 | #define IS_1020(sd) ((sd)->sensor == &stv06xx_sensor_hdcs1020) | 35 | #define IS_1020(sd) ((sd)->sensor == &stv06xx_sensor_hdcs1020) |
| 38 | 36 | ||
| 39 | extern const struct stv06xx_sensor stv06xx_sensor_vv6410; | 37 | extern const struct stv06xx_sensor stv06xx_sensor_vv6410; |
| 40 | extern const struct stv06xx_sensor stv06xx_sensor_hdcs1x00; | 38 | extern const struct stv06xx_sensor stv06xx_sensor_hdcs1x00; |
| 41 | extern const struct stv06xx_sensor stv06xx_sensor_hdcs1020; | 39 | extern const struct stv06xx_sensor stv06xx_sensor_hdcs1020; |
| 42 | extern const struct stv06xx_sensor stv06xx_sensor_pb0100; | 40 | extern const struct stv06xx_sensor stv06xx_sensor_pb0100; |
| 41 | extern const struct stv06xx_sensor stv06xx_sensor_st6422; | ||
| 43 | 42 | ||
| 44 | struct stv06xx_sensor { | 43 | struct stv06xx_sensor { |
| 45 | /* Defines the name of a sensor */ | 44 | /* Defines the name of a sensor */ |
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c new file mode 100644 index 000000000000..87cb5b9ddfa7 --- /dev/null +++ b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.c | |||
| @@ -0,0 +1,453 @@ | |||
| 1 | /* | ||
| 2 | * Support for the sensor part which is integrated (I think) into the | ||
| 3 | * st6422 stv06xx alike bridge, as its integrated there are no i2c writes | ||
| 4 | * but instead direct bridge writes. | ||
| 5 | * | ||
| 6 | * Copyright (c) 2009 Hans de Goede <hdegoede@redhat.com> | ||
| 7 | * | ||
| 8 | * Strongly based on qc-usb-messenger, which is: | ||
| 9 | * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher | ||
| 10 | * Mark Cave-Ayland, Carlo E Prelz, Dick Streefland | ||
| 11 | * Copyright (c) 2002, 2003 Tuukka Toivonen | ||
| 12 | * | ||
| 13 | * This program is free software; you can redistribute it and/or modify | ||
| 14 | * it under the terms of the GNU General Public License as published by | ||
| 15 | * the Free Software Foundation; either version 2 of the License, or | ||
| 16 | * (at your option) any later version. | ||
| 17 | * | ||
| 18 | * This program is distributed in the hope that it will be useful, | ||
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 21 | * GNU General Public License for more details. | ||
| 22 | * | ||
| 23 | * You should have received a copy of the GNU General Public License | ||
| 24 | * along with this program; if not, write to the Free Software | ||
| 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 26 | * | ||
| 27 | */ | ||
| 28 | |||
| 29 | #include "stv06xx_st6422.h" | ||
| 30 | |||
| 31 | static struct v4l2_pix_format st6422_mode[] = { | ||
| 32 | /* Note we actually get 124 lines of data, of which we skip the 4st | ||
| 33 | 4 as they are garbage */ | ||
| 34 | { | ||
| 35 | 162, | ||
| 36 | 120, | ||
| 37 | V4L2_PIX_FMT_SGRBG8, | ||
| 38 | V4L2_FIELD_NONE, | ||
| 39 | .sizeimage = 162 * 120, | ||
| 40 | .bytesperline = 162, | ||
| 41 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
| 42 | .priv = 1 | ||
| 43 | }, | ||
| 44 | /* Note we actually get 248 lines of data, of which we skip the 4st | ||
| 45 | 4 as they are garbage, and we tell the app it only gets the | ||
| 46 | first 240 of the 244 lines it actually gets, so that it ignores | ||
| 47 | the last 4. */ | ||
| 48 | { | ||
| 49 | 324, | ||
| 50 | 240, | ||
| 51 | V4L2_PIX_FMT_SGRBG8, | ||
| 52 | V4L2_FIELD_NONE, | ||
| 53 | .sizeimage = 324 * 244, | ||
| 54 | .bytesperline = 324, | ||
| 55 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
| 56 | .priv = 0 | ||
| 57 | }, | ||
| 58 | }; | ||
| 59 | |||
| 60 | static const struct ctrl st6422_ctrl[] = { | ||
| 61 | #define BRIGHTNESS_IDX 0 | ||
| 62 | { | ||
| 63 | { | ||
| 64 | .id = V4L2_CID_BRIGHTNESS, | ||
| 65 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 66 | .name = "Brightness", | ||
| 67 | .minimum = 0, | ||
| 68 | .maximum = 31, | ||
| 69 | .step = 1, | ||
| 70 | .default_value = 3 | ||
| 71 | }, | ||
| 72 | .set = st6422_set_brightness, | ||
| 73 | .get = st6422_get_brightness | ||
| 74 | }, | ||
| 75 | #define CONTRAST_IDX 1 | ||
| 76 | { | ||
| 77 | { | ||
| 78 | .id = V4L2_CID_CONTRAST, | ||
| 79 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 80 | .name = "Contrast", | ||
| 81 | .minimum = 0, | ||
| 82 | .maximum = 15, | ||
| 83 | .step = 1, | ||
| 84 | .default_value = 11 | ||
| 85 | }, | ||
| 86 | .set = st6422_set_contrast, | ||
| 87 | .get = st6422_get_contrast | ||
| 88 | }, | ||
| 89 | #define GAIN_IDX 2 | ||
| 90 | { | ||
| 91 | { | ||
| 92 | .id = V4L2_CID_GAIN, | ||
| 93 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 94 | .name = "Gain", | ||
| 95 | .minimum = 0, | ||
| 96 | .maximum = 255, | ||
| 97 | .step = 1, | ||
| 98 | .default_value = 64 | ||
| 99 | }, | ||
| 100 | .set = st6422_set_gain, | ||
| 101 | .get = st6422_get_gain | ||
| 102 | }, | ||
| 103 | #define EXPOSURE_IDX 3 | ||
| 104 | { | ||
| 105 | { | ||
| 106 | .id = V4L2_CID_EXPOSURE, | ||
| 107 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 108 | .name = "Exposure", | ||
| 109 | .minimum = 0, | ||
| 110 | .maximum = 1023, | ||
| 111 | .step = 1, | ||
| 112 | .default_value = 256 | ||
| 113 | }, | ||
| 114 | .set = st6422_set_exposure, | ||
| 115 | .get = st6422_get_exposure | ||
| 116 | }, | ||
| 117 | }; | ||
| 118 | |||
| 119 | static int st6422_probe(struct sd *sd) | ||
| 120 | { | ||
| 121 | int i; | ||
| 122 | s32 *sensor_settings; | ||
| 123 | |||
| 124 | if (sd->bridge != BRIDGE_ST6422) | ||
| 125 | return -ENODEV; | ||
| 126 | |||
| 127 | info("st6422 sensor detected"); | ||
| 128 | |||
| 129 | sensor_settings = kmalloc(ARRAY_SIZE(st6422_ctrl) * sizeof(s32), | ||
| 130 | GFP_KERNEL); | ||
| 131 | if (!sensor_settings) | ||
| 132 | return -ENOMEM; | ||
| 133 | |||
| 134 | sd->gspca_dev.cam.cam_mode = st6422_mode; | ||
| 135 | sd->gspca_dev.cam.nmodes = ARRAY_SIZE(st6422_mode); | ||
| 136 | sd->desc.ctrls = st6422_ctrl; | ||
| 137 | sd->desc.nctrls = ARRAY_SIZE(st6422_ctrl); | ||
| 138 | sd->sensor_priv = sensor_settings; | ||
| 139 | |||
| 140 | for (i = 0; i < sd->desc.nctrls; i++) | ||
| 141 | sensor_settings[i] = st6422_ctrl[i].qctrl.default_value; | ||
| 142 | |||
| 143 | return 0; | ||
| 144 | } | ||
| 145 | |||
| 146 | static int st6422_init(struct sd *sd) | ||
| 147 | { | ||
| 148 | int err = 0, i; | ||
| 149 | |||
| 150 | const u16 st6422_bridge_init[][2] = { | ||
| 151 | { STV_ISO_ENABLE, 0x00 }, /* disable capture */ | ||
| 152 | { 0x1436, 0x00 }, | ||
| 153 | { 0x1432, 0x03 }, /* 0x00-0x1F brightness */ | ||
| 154 | { 0x143a, 0xF9 }, /* 0x00-0x0F contrast */ | ||
| 155 | { 0x0509, 0x38 }, /* R */ | ||
| 156 | { 0x050a, 0x38 }, /* G */ | ||
| 157 | { 0x050b, 0x38 }, /* B */ | ||
| 158 | { 0x050c, 0x2A }, | ||
| 159 | { 0x050d, 0x01 }, | ||
| 160 | |||
| 161 | |||
| 162 | { 0x1431, 0x00 }, /* 0x00-0x07 ??? */ | ||
| 163 | { 0x1433, 0x34 }, /* 160x120, 0x00-0x01 night filter */ | ||
| 164 | { 0x1438, 0x18 }, /* 640x480 */ | ||
| 165 | /* 18 bayes */ | ||
| 166 | /* 10 compressed? */ | ||
| 167 | |||
| 168 | { 0x1439, 0x00 }, | ||
| 169 | /* antiflimmer?? 0xa2 ger perfekt bild mot monitor */ | ||
| 170 | |||
| 171 | { 0x143b, 0x05 }, | ||
| 172 | { 0x143c, 0x00 }, /* 0x00-0x01 - ??? */ | ||
| 173 | |||
| 174 | |||
| 175 | /* shutter time 0x0000-0x03FF */ | ||
| 176 | /* low value give good picures on moving objects (but requires much light) */ | ||
| 177 | /* high value gives good picures in darkness (but tends to be overexposed) */ | ||
| 178 | { 0x143e, 0x01 }, | ||
| 179 | { 0x143d, 0x00 }, | ||
| 180 | |||
| 181 | { 0x1442, 0xe2 }, | ||
| 182 | /* write: 1x1x xxxx */ | ||
| 183 | /* read: 1x1x xxxx */ | ||
| 184 | /* bit 5 == button pressed and hold if 0 */ | ||
| 185 | /* write 0xe2,0xea */ | ||
| 186 | |||
| 187 | /* 0x144a */ | ||
| 188 | /* 0x00 init */ | ||
| 189 | /* bit 7 == button has been pressed, but not handled */ | ||
| 190 | |||
| 191 | /* interrupt */ | ||
| 192 | /* if(urb->iso_frame_desc[i].status == 0x80) { */ | ||
| 193 | /* if(urb->iso_frame_desc[i].status == 0x88) { */ | ||
| 194 | |||
| 195 | { 0x1500, 0xd0 }, | ||
| 196 | { 0x1500, 0xd0 }, | ||
| 197 | { 0x1500, 0x50 }, /* 0x00 - 0xFF 0x80 == compr ? */ | ||
| 198 | |||
| 199 | { 0x1501, 0xaf }, | ||
| 200 | /* high val-> ljus area blir morkare. */ | ||
| 201 | /* low val -> ljus area blir ljusare. */ | ||
| 202 | { 0x1502, 0xc2 }, | ||
| 203 | /* high val-> ljus area blir morkare. */ | ||
| 204 | /* low val -> ljus area blir ljusare. */ | ||
| 205 | { 0x1503, 0x45 }, | ||
| 206 | /* high val-> ljus area blir morkare. */ | ||
| 207 | /* low val -> ljus area blir ljusare. */ | ||
| 208 | |||
| 209 | { 0x1505, 0x02 }, | ||
| 210 | /* 2 : 324x248 80352 bytes */ | ||
| 211 | /* 7 : 248x162 40176 bytes */ | ||
| 212 | /* c+f: 162*124 20088 bytes */ | ||
| 213 | |||
| 214 | { 0x150e, 0x8e }, | ||
| 215 | { 0x150f, 0x37 }, | ||
| 216 | { 0x15c0, 0x00 }, | ||
| 217 | { 0x15c1, 1023 }, /* 160x120, ISOC_PACKET_SIZE */ | ||
| 218 | { 0x15c3, 0x08 }, /* 0x04/0x14 ... test pictures ??? */ | ||
| 219 | |||
| 220 | |||
| 221 | { 0x143f, 0x01 }, /* commit settings */ | ||
| 222 | |||
| 223 | }; | ||
| 224 | |||
| 225 | for (i = 0; i < ARRAY_SIZE(st6422_bridge_init) && !err; i++) { | ||
| 226 | err = stv06xx_write_bridge(sd, st6422_bridge_init[i][0], | ||
| 227 | st6422_bridge_init[i][1]); | ||
| 228 | } | ||
| 229 | |||
| 230 | return err; | ||
| 231 | } | ||
| 232 | |||
| 233 | static void st6422_disconnect(struct sd *sd) | ||
| 234 | { | ||
| 235 | sd->sensor = NULL; | ||
| 236 | kfree(sd->sensor_priv); | ||
| 237 | } | ||
| 238 | |||
| 239 | static int st6422_start(struct sd *sd) | ||
| 240 | { | ||
| 241 | int err, packet_size; | ||
| 242 | struct cam *cam = &sd->gspca_dev.cam; | ||
| 243 | s32 *sensor_settings = sd->sensor_priv; | ||
| 244 | struct usb_host_interface *alt; | ||
| 245 | struct usb_interface *intf; | ||
| 246 | |||
| 247 | intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); | ||
| 248 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); | ||
| 249 | if (!alt) { | ||
| 250 | PDEBUG(D_ERR, "Couldn't get altsetting"); | ||
| 251 | return -EIO; | ||
| 252 | } | ||
| 253 | |||
| 254 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | ||
| 255 | err = stv06xx_write_bridge(sd, 0x15c1, packet_size); | ||
| 256 | if (err < 0) | ||
| 257 | return err; | ||
| 258 | |||
| 259 | if (cam->cam_mode[sd->gspca_dev.curr_mode].priv) | ||
| 260 | err = stv06xx_write_bridge(sd, 0x1505, 0x0f); | ||
| 261 | else | ||
| 262 | err = stv06xx_write_bridge(sd, 0x1505, 0x02); | ||
| 263 | if (err < 0) | ||
| 264 | return err; | ||
| 265 | |||
| 266 | err = st6422_set_brightness(&sd->gspca_dev, | ||
| 267 | sensor_settings[BRIGHTNESS_IDX]); | ||
| 268 | if (err < 0) | ||
| 269 | return err; | ||
| 270 | |||
| 271 | err = st6422_set_contrast(&sd->gspca_dev, | ||
| 272 | sensor_settings[CONTRAST_IDX]); | ||
| 273 | if (err < 0) | ||
| 274 | return err; | ||
| 275 | |||
| 276 | err = st6422_set_exposure(&sd->gspca_dev, | ||
| 277 | sensor_settings[EXPOSURE_IDX]); | ||
| 278 | if (err < 0) | ||
| 279 | return err; | ||
| 280 | |||
| 281 | err = st6422_set_gain(&sd->gspca_dev, | ||
| 282 | sensor_settings[GAIN_IDX]); | ||
| 283 | if (err < 0) | ||
| 284 | return err; | ||
| 285 | |||
| 286 | PDEBUG(D_STREAM, "Starting stream"); | ||
| 287 | |||
| 288 | return 0; | ||
| 289 | } | ||
| 290 | |||
| 291 | static int st6422_stop(struct sd *sd) | ||
| 292 | { | ||
| 293 | PDEBUG(D_STREAM, "Halting stream"); | ||
| 294 | |||
| 295 | return 0; | ||
| 296 | } | ||
| 297 | |||
| 298 | static int st6422_get_brightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
| 299 | { | ||
| 300 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 301 | s32 *sensor_settings = sd->sensor_priv; | ||
| 302 | |||
| 303 | *val = sensor_settings[BRIGHTNESS_IDX]; | ||
| 304 | |||
| 305 | PDEBUG(D_V4L2, "Read brightness %d", *val); | ||
| 306 | |||
| 307 | return 0; | ||
| 308 | } | ||
| 309 | |||
| 310 | static int st6422_set_brightness(struct gspca_dev *gspca_dev, __s32 val) | ||
| 311 | { | ||
| 312 | int err; | ||
| 313 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 314 | s32 *sensor_settings = sd->sensor_priv; | ||
| 315 | |||
| 316 | sensor_settings[BRIGHTNESS_IDX] = val; | ||
| 317 | |||
| 318 | if (!gspca_dev->streaming) | ||
| 319 | return 0; | ||
| 320 | |||
| 321 | /* val goes from 0 -> 31 */ | ||
| 322 | PDEBUG(D_V4L2, "Set brightness to %d", val); | ||
| 323 | err = stv06xx_write_bridge(sd, 0x1432, val); | ||
| 324 | if (err < 0) | ||
| 325 | return err; | ||
| 326 | |||
| 327 | /* commit settings */ | ||
| 328 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); | ||
| 329 | return (err < 0) ? err : 0; | ||
| 330 | } | ||
| 331 | |||
| 332 | static int st6422_get_contrast(struct gspca_dev *gspca_dev, __s32 *val) | ||
| 333 | { | ||
| 334 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 335 | s32 *sensor_settings = sd->sensor_priv; | ||
| 336 | |||
| 337 | *val = sensor_settings[CONTRAST_IDX]; | ||
| 338 | |||
| 339 | PDEBUG(D_V4L2, "Read contrast %d", *val); | ||
| 340 | |||
| 341 | return 0; | ||
| 342 | } | ||
| 343 | |||
| 344 | static int st6422_set_contrast(struct gspca_dev *gspca_dev, __s32 val) | ||
| 345 | { | ||
| 346 | int err; | ||
| 347 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 348 | s32 *sensor_settings = sd->sensor_priv; | ||
| 349 | |||
| 350 | sensor_settings[CONTRAST_IDX] = val; | ||
| 351 | |||
| 352 | if (!gspca_dev->streaming) | ||
| 353 | return 0; | ||
| 354 | |||
| 355 | /* Val goes from 0 -> 15 */ | ||
| 356 | PDEBUG(D_V4L2, "Set contrast to %d\n", val); | ||
| 357 | err = stv06xx_write_bridge(sd, 0x143a, 0xf0 | val); | ||
| 358 | if (err < 0) | ||
| 359 | return err; | ||
| 360 | |||
| 361 | /* commit settings */ | ||
| 362 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); | ||
| 363 | return (err < 0) ? err : 0; | ||
| 364 | } | ||
| 365 | |||
| 366 | static int st6422_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | ||
| 367 | { | ||
| 368 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 369 | s32 *sensor_settings = sd->sensor_priv; | ||
| 370 | |||
| 371 | *val = sensor_settings[GAIN_IDX]; | ||
| 372 | |||
| 373 | PDEBUG(D_V4L2, "Read gain %d", *val); | ||
| 374 | |||
| 375 | return 0; | ||
| 376 | } | ||
| 377 | |||
| 378 | static int st6422_set_gain(struct gspca_dev *gspca_dev, __s32 val) | ||
| 379 | { | ||
| 380 | int err; | ||
| 381 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 382 | s32 *sensor_settings = sd->sensor_priv; | ||
| 383 | |||
| 384 | sensor_settings[GAIN_IDX] = val; | ||
| 385 | |||
| 386 | if (!gspca_dev->streaming) | ||
| 387 | return 0; | ||
| 388 | |||
| 389 | PDEBUG(D_V4L2, "Set gain to %d", val); | ||
| 390 | |||
| 391 | /* Set red, green, blue, gain */ | ||
| 392 | err = stv06xx_write_bridge(sd, 0x0509, val); | ||
| 393 | if (err < 0) | ||
| 394 | return err; | ||
| 395 | |||
| 396 | err = stv06xx_write_bridge(sd, 0x050a, val); | ||
| 397 | if (err < 0) | ||
| 398 | return err; | ||
| 399 | |||
| 400 | err = stv06xx_write_bridge(sd, 0x050b, val); | ||
| 401 | if (err < 0) | ||
| 402 | return err; | ||
| 403 | |||
| 404 | /* 2 mystery writes */ | ||
| 405 | err = stv06xx_write_bridge(sd, 0x050c, 0x2a); | ||
| 406 | if (err < 0) | ||
| 407 | return err; | ||
| 408 | |||
| 409 | err = stv06xx_write_bridge(sd, 0x050d, 0x01); | ||
| 410 | if (err < 0) | ||
| 411 | return err; | ||
| 412 | |||
| 413 | /* commit settings */ | ||
| 414 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); | ||
| 415 | return (err < 0) ? err : 0; | ||
| 416 | } | ||
| 417 | |||
| 418 | static int st6422_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | ||
| 419 | { | ||
| 420 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 421 | s32 *sensor_settings = sd->sensor_priv; | ||
| 422 | |||
| 423 | *val = sensor_settings[EXPOSURE_IDX]; | ||
| 424 | |||
| 425 | PDEBUG(D_V4L2, "Read exposure %d", *val); | ||
| 426 | |||
| 427 | return 0; | ||
| 428 | } | ||
| 429 | |||
| 430 | static int st6422_set_exposure(struct gspca_dev *gspca_dev, __s32 val) | ||
| 431 | { | ||
| 432 | int err; | ||
| 433 | struct sd *sd = (struct sd *) gspca_dev; | ||
| 434 | s32 *sensor_settings = sd->sensor_priv; | ||
| 435 | |||
| 436 | sensor_settings[EXPOSURE_IDX] = val; | ||
| 437 | |||
| 438 | if (!gspca_dev->streaming) | ||
| 439 | return 0; | ||
| 440 | |||
| 441 | PDEBUG(D_V4L2, "Set exposure to %d\n", val); | ||
| 442 | err = stv06xx_write_bridge(sd, 0x143d, val & 0xff); | ||
| 443 | if (err < 0) | ||
| 444 | return err; | ||
| 445 | |||
| 446 | err = stv06xx_write_bridge(sd, 0x143e, val >> 8); | ||
| 447 | if (err < 0) | ||
| 448 | return err; | ||
| 449 | |||
| 450 | /* commit settings */ | ||
| 451 | err = stv06xx_write_bridge(sd, 0x143f, 0x01); | ||
| 452 | return (err < 0) ? err : 0; | ||
| 453 | } | ||
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_st6422.h b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.h new file mode 100644 index 000000000000..b2d45fe50522 --- /dev/null +++ b/drivers/media/video/gspca/stv06xx/stv06xx_st6422.h | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | /* | ||
| 2 | * Support for the sensor part which is integrated (I think) into the | ||
| 3 | * st6422 stv06xx alike bridge, as its integrated there are no i2c writes | ||
| 4 | * but instead direct bridge writes. | ||
| 5 | * | ||
| 6 | * Copyright (c) 2009 Hans de Goede <hdegoede@redhat.com> | ||
| 7 | * | ||
| 8 | * Strongly based on qc-usb-messenger, which is: | ||
| 9 | * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher | ||
| 10 | * Mark Cave-Ayland, Carlo E Prelz, Dick Streefland | ||
| 11 | * Copyright (c) 2002, 2003 Tuukka Toivonen | ||
| 12 | * | ||
| 13 | * This program is free software; you can redistribute it and/or modify | ||
| 14 | * it under the terms of the GNU General Public License as published by | ||
| 15 | * the Free Software Foundation; either version 2 of the License, or | ||
| 16 | * (at your option) any later version. | ||
| 17 | * | ||
| 18 | * This program is distributed in the hope that it will be useful, | ||
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 21 | * GNU General Public License for more details. | ||
| 22 | * | ||
| 23 | * You should have received a copy of the GNU General Public License | ||
| 24 | * along with this program; if not, write to the Free Software | ||
| 25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 26 | * | ||
| 27 | */ | ||
| 28 | |||
| 29 | #ifndef STV06XX_ST6422_H_ | ||
| 30 | #define STV06XX_ST6422_H_ | ||
| 31 | |||
| 32 | #include "stv06xx_sensor.h" | ||
| 33 | |||
| 34 | static int st6422_probe(struct sd *sd); | ||
| 35 | static int st6422_start(struct sd *sd); | ||
| 36 | static int st6422_init(struct sd *sd); | ||
| 37 | static int st6422_stop(struct sd *sd); | ||
| 38 | static void st6422_disconnect(struct sd *sd); | ||
| 39 | |||
| 40 | /* V4L2 controls supported by the driver */ | ||
| 41 | static int st6422_get_brightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
| 42 | static int st6422_set_brightness(struct gspca_dev *gspca_dev, __s32 val); | ||
| 43 | static int st6422_get_contrast(struct gspca_dev *gspca_dev, __s32 *val); | ||
| 44 | static int st6422_set_contrast(struct gspca_dev *gspca_dev, __s32 val); | ||
| 45 | static int st6422_get_gain(struct gspca_dev *gspca_dev, __s32 *val); | ||
| 46 | static int st6422_set_gain(struct gspca_dev *gspca_dev, __s32 val); | ||
| 47 | static int st6422_get_exposure(struct gspca_dev *gspca_dev, __s32 *val); | ||
| 48 | static int st6422_set_exposure(struct gspca_dev *gspca_dev, __s32 val); | ||
| 49 | |||
| 50 | const struct stv06xx_sensor stv06xx_sensor_st6422 = { | ||
| 51 | .name = "ST6422", | ||
| 52 | .init = st6422_init, | ||
| 53 | .probe = st6422_probe, | ||
| 54 | .start = st6422_start, | ||
| 55 | .stop = st6422_stop, | ||
| 56 | .disconnect = st6422_disconnect, | ||
| 57 | }; | ||
| 58 | |||
| 59 | #endif | ||
diff --git a/drivers/media/video/ivtv/ivtv-controls.c b/drivers/media/video/ivtv/ivtv-controls.c index 84995bcf4a75..a3b77ed3f089 100644 --- a/drivers/media/video/ivtv/ivtv-controls.c +++ b/drivers/media/video/ivtv/ivtv-controls.c | |||
| @@ -60,6 +60,8 @@ int ivtv_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qctrl) | |||
| 60 | 60 | ||
| 61 | switch (qctrl->id) { | 61 | switch (qctrl->id) { |
| 62 | /* Standard V4L2 controls */ | 62 | /* Standard V4L2 controls */ |
| 63 | case V4L2_CID_USER_CLASS: | ||
| 64 | return v4l2_ctrl_query_fill(qctrl, 0, 0, 0, 0); | ||
| 63 | case V4L2_CID_BRIGHTNESS: | 65 | case V4L2_CID_BRIGHTNESS: |
| 64 | case V4L2_CID_HUE: | 66 | case V4L2_CID_HUE: |
| 65 | case V4L2_CID_SATURATION: | 67 | case V4L2_CID_SATURATION: |
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c index 459c04cbf69d..4d794b42d6cd 100644 --- a/drivers/media/video/mt9m001.c +++ b/drivers/media/video/mt9m001.c | |||
| @@ -280,15 +280,9 @@ static int mt9m001_try_fmt(struct soc_camera_device *icd, | |||
| 280 | { | 280 | { |
| 281 | struct v4l2_pix_format *pix = &f->fmt.pix; | 281 | struct v4l2_pix_format *pix = &f->fmt.pix; |
| 282 | 282 | ||
| 283 | if (pix->height < 32 + icd->y_skip_top) | 283 | v4l_bound_align_image(&pix->width, 48, 1280, 1, |
| 284 | pix->height = 32 + icd->y_skip_top; | 284 | &pix->height, 32 + icd->y_skip_top, |
| 285 | if (pix->height > 1024 + icd->y_skip_top) | 285 | 1024 + icd->y_skip_top, 0, 0); |
| 286 | pix->height = 1024 + icd->y_skip_top; | ||
| 287 | if (pix->width < 48) | ||
| 288 | pix->width = 48; | ||
| 289 | if (pix->width > 1280) | ||
| 290 | pix->width = 1280; | ||
| 291 | pix->width &= ~0x01; /* has to be even, unsure why was ~3 */ | ||
| 292 | 286 | ||
| 293 | return 0; | 287 | return 0; |
| 294 | } | 288 | } |
diff --git a/drivers/media/video/mt9t031.c b/drivers/media/video/mt9t031.c index f72aeb7c4deb..4207fb342670 100644 --- a/drivers/media/video/mt9t031.c +++ b/drivers/media/video/mt9t031.c | |||
| @@ -385,17 +385,9 @@ static int mt9t031_try_fmt(struct soc_camera_device *icd, | |||
| 385 | { | 385 | { |
| 386 | struct v4l2_pix_format *pix = &f->fmt.pix; | 386 | struct v4l2_pix_format *pix = &f->fmt.pix; |
| 387 | 387 | ||
| 388 | if (pix->height < MT9T031_MIN_HEIGHT) | 388 | v4l_bound_align_image( |
| 389 | pix->height = MT9T031_MIN_HEIGHT; | 389 | &pix->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1, |
| 390 | if (pix->height > MT9T031_MAX_HEIGHT) | 390 | &pix->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0); |
| 391 | pix->height = MT9T031_MAX_HEIGHT; | ||
| 392 | if (pix->width < MT9T031_MIN_WIDTH) | ||
| 393 | pix->width = MT9T031_MIN_WIDTH; | ||
| 394 | if (pix->width > MT9T031_MAX_WIDTH) | ||
| 395 | pix->width = MT9T031_MAX_WIDTH; | ||
| 396 | |||
| 397 | pix->width &= ~0x01; /* has to be even */ | ||
| 398 | pix->height &= ~0x01; /* has to be even */ | ||
| 399 | 391 | ||
| 400 | return 0; | 392 | return 0; |
| 401 | } | 393 | } |
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c index be20d312b1dc..dbdcc86ae50d 100644 --- a/drivers/media/video/mt9v022.c +++ b/drivers/media/video/mt9v022.c | |||
| @@ -364,15 +364,9 @@ static int mt9v022_try_fmt(struct soc_camera_device *icd, | |||
| 364 | { | 364 | { |
| 365 | struct v4l2_pix_format *pix = &f->fmt.pix; | 365 | struct v4l2_pix_format *pix = &f->fmt.pix; |
| 366 | 366 | ||
| 367 | if (pix->height < 32 + icd->y_skip_top) | 367 | v4l_bound_align_image(&pix->width, 48, 752, 2 /* ? */, |
| 368 | pix->height = 32 + icd->y_skip_top; | 368 | &pix->height, 32 + icd->y_skip_top, |
| 369 | if (pix->height > 480 + icd->y_skip_top) | 369 | 480 + icd->y_skip_top, 0, 0); |
| 370 | pix->height = 480 + icd->y_skip_top; | ||
| 371 | if (pix->width < 48) | ||
| 372 | pix->width = 48; | ||
| 373 | if (pix->width > 752) | ||
| 374 | pix->width = 752; | ||
| 375 | pix->width &= ~0x03; /* ? */ | ||
| 376 | 370 | ||
| 377 | return 0; | 371 | return 0; |
| 378 | } | 372 | } |
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c index 08cfd3e4ae8a..0bc2cf573c76 100644 --- a/drivers/media/video/ov511.c +++ b/drivers/media/video/ov511.c | |||
| @@ -211,8 +211,6 @@ static const int i2c_detect_tries = 5; | |||
| 211 | static struct usb_device_id device_table [] = { | 211 | static struct usb_device_id device_table [] = { |
| 212 | { USB_DEVICE(VEND_OMNIVISION, PROD_OV511) }, | 212 | { USB_DEVICE(VEND_OMNIVISION, PROD_OV511) }, |
| 213 | { USB_DEVICE(VEND_OMNIVISION, PROD_OV511PLUS) }, | 213 | { USB_DEVICE(VEND_OMNIVISION, PROD_OV511PLUS) }, |
| 214 | { USB_DEVICE(VEND_OMNIVISION, PROD_OV518) }, | ||
| 215 | { USB_DEVICE(VEND_OMNIVISION, PROD_OV518PLUS) }, | ||
| 216 | { USB_DEVICE(VEND_MATTEL, PROD_ME2CAM) }, | 214 | { USB_DEVICE(VEND_MATTEL, PROD_ME2CAM) }, |
| 217 | { } /* Terminating entry */ | 215 | { } /* Terminating entry */ |
| 218 | }; | 216 | }; |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-audio.c b/drivers/media/video/pvrusb2/pvrusb2-audio.c index 10ef1a2c13ea..416933ca607d 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-audio.c +++ b/drivers/media/video/pvrusb2/pvrusb2-audio.c | |||
| @@ -48,11 +48,13 @@ static const int routing_scheme0[] = { | |||
| 48 | MSP_DSP_IN_SCART), | 48 | MSP_DSP_IN_SCART), |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | static const struct routing_scheme routing_schemes[] = { | 51 | static const struct routing_scheme routing_def0 = { |
| 52 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = { | 52 | .def = routing_scheme0, |
| 53 | .def = routing_scheme0, | 53 | .cnt = ARRAY_SIZE(routing_scheme0), |
| 54 | .cnt = ARRAY_SIZE(routing_scheme0), | 54 | }; |
| 55 | }, | 55 | |
| 56 | static const struct routing_scheme *routing_schemes[] = { | ||
| 57 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0, | ||
| 56 | }; | 58 | }; |
| 57 | 59 | ||
| 58 | void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | 60 | void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
| @@ -65,7 +67,7 @@ void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
| 65 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo"); | 67 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo"); |
| 66 | 68 | ||
| 67 | if ((sid < ARRAY_SIZE(routing_schemes)) && | 69 | if ((sid < ARRAY_SIZE(routing_schemes)) && |
| 68 | ((sp = routing_schemes + sid) != NULL) && | 70 | ((sp = routing_schemes[sid]) != NULL) && |
| 69 | (hdw->input_val >= 0) && | 71 | (hdw->input_val >= 0) && |
| 70 | (hdw->input_val < sp->cnt)) { | 72 | (hdw->input_val < sp->cnt)) { |
| 71 | input = sp->def[hdw->input_val]; | 73 | input = sp->def[hdw->input_val]; |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c b/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c index 9023adf3fdcc..68980e19409f 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c +++ b/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c | |||
| @@ -49,11 +49,13 @@ static const int routing_scheme1[] = { | |||
| 49 | [PVR2_CVAL_INPUT_SVIDEO] = 0, | 49 | [PVR2_CVAL_INPUT_SVIDEO] = 0, |
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| 52 | static const struct routing_scheme routing_schemes[] = { | 52 | static const struct routing_scheme routing_def1 = { |
| 53 | [PVR2_ROUTING_SCHEME_ONAIR] = { | 53 | .def = routing_scheme1, |
| 54 | .def = routing_scheme1, | 54 | .cnt = ARRAY_SIZE(routing_scheme1), |
| 55 | .cnt = ARRAY_SIZE(routing_scheme1), | 55 | }; |
| 56 | }, | 56 | |
| 57 | static const struct routing_scheme *routing_schemes[] = { | ||
| 58 | [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1, | ||
| 57 | }; | 59 | }; |
| 58 | 60 | ||
| 59 | 61 | ||
| @@ -65,12 +67,11 @@ void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
| 65 | u32 input; | 67 | u32 input; |
| 66 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", | 68 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", |
| 67 | hdw->input_val); | 69 | hdw->input_val); |
| 68 | if ((sid < ARRAY_SIZE(routing_schemes)) && | 70 | sp = (sid < ARRAY_SIZE(routing_schemes)) ? |
| 69 | ((sp = routing_schemes + sid) != NULL) && | 71 | routing_schemes[sid] : NULL; |
| 70 | (hdw->input_val >= 0) && | 72 | if ((sp == NULL) || |
| 71 | (hdw->input_val < sp->cnt)) { | 73 | (hdw->input_val < 0) || |
| 72 | input = sp->def[hdw->input_val]; | 74 | (hdw->input_val >= sp->cnt)) { |
| 73 | } else { | ||
| 74 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 75 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 75 | "*** WARNING *** subdev v4l2 set_input:" | 76 | "*** WARNING *** subdev v4l2 set_input:" |
| 76 | " Invalid routing scheme (%u)" | 77 | " Invalid routing scheme (%u)" |
| @@ -78,6 +79,7 @@ void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
| 78 | sid, hdw->input_val); | 79 | sid, hdw->input_val); |
| 79 | return; | 80 | return; |
| 80 | } | 81 | } |
| 82 | input = sp->def[hdw->input_val]; | ||
| 81 | sd->ops->audio->s_routing(sd, input, 0, 0); | 83 | sd->ops->audio->s_routing(sd, input, 0, 0); |
| 82 | } | 84 | } |
| 83 | } | 85 | } |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c index 05e52358ae49..82c135835753 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c +++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c | |||
| @@ -68,6 +68,11 @@ static const struct routing_scheme_item routing_scheme0[] = { | |||
| 68 | }, | 68 | }, |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | static const struct routing_scheme routing_def0 = { | ||
| 72 | .def = routing_scheme0, | ||
| 73 | .cnt = ARRAY_SIZE(routing_scheme0), | ||
| 74 | }; | ||
| 75 | |||
| 71 | /* Specific to gotview device */ | 76 | /* Specific to gotview device */ |
| 72 | static const struct routing_scheme_item routing_schemegv[] = { | 77 | static const struct routing_scheme_item routing_schemegv[] = { |
| 73 | [PVR2_CVAL_INPUT_TV] = { | 78 | [PVR2_CVAL_INPUT_TV] = { |
| @@ -90,15 +95,14 @@ static const struct routing_scheme_item routing_schemegv[] = { | |||
| 90 | }, | 95 | }, |
| 91 | }; | 96 | }; |
| 92 | 97 | ||
| 93 | static const struct routing_scheme routing_schemes[] = { | 98 | static const struct routing_scheme routing_defgv = { |
| 94 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = { | 99 | .def = routing_schemegv, |
| 95 | .def = routing_scheme0, | 100 | .cnt = ARRAY_SIZE(routing_schemegv), |
| 96 | .cnt = ARRAY_SIZE(routing_scheme0), | 101 | }; |
| 97 | }, | 102 | |
| 98 | [PVR2_ROUTING_SCHEME_GOTVIEW] = { | 103 | static const struct routing_scheme *routing_schemes[] = { |
| 99 | .def = routing_schemegv, | 104 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0, |
| 100 | .cnt = ARRAY_SIZE(routing_schemegv), | 105 | [PVR2_ROUTING_SCHEME_GOTVIEW] = &routing_defgv, |
| 101 | }, | ||
| 102 | }; | 106 | }; |
| 103 | 107 | ||
| 104 | void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | 108 | void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
| @@ -110,13 +114,11 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
| 110 | const struct routing_scheme *sp; | 114 | const struct routing_scheme *sp; |
| 111 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; | 115 | unsigned int sid = hdw->hdw_desc->signal_routing_scheme; |
| 112 | 116 | ||
| 113 | if ((sid < ARRAY_SIZE(routing_schemes)) && | 117 | sp = (sid < ARRAY_SIZE(routing_schemes)) ? |
| 114 | ((sp = routing_schemes + sid) != NULL) && | 118 | routing_schemes[sid] : NULL; |
| 115 | (hdw->input_val >= 0) && | 119 | if ((sp == NULL) || |
| 116 | (hdw->input_val < sp->cnt)) { | 120 | (hdw->input_val < 0) || |
| 117 | vid_input = sp->def[hdw->input_val].vid; | 121 | (hdw->input_val >= sp->cnt)) { |
| 118 | aud_input = sp->def[hdw->input_val].aud; | ||
| 119 | } else { | ||
| 120 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 122 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 121 | "*** WARNING *** subdev cx2584x set_input:" | 123 | "*** WARNING *** subdev cx2584x set_input:" |
| 122 | " Invalid routing scheme (%u)" | 124 | " Invalid routing scheme (%u)" |
| @@ -124,7 +126,8 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
| 124 | sid, hdw->input_val); | 126 | sid, hdw->input_val); |
| 125 | return; | 127 | return; |
| 126 | } | 128 | } |
| 127 | 129 | vid_input = sp->def[hdw->input_val].vid; | |
| 130 | aud_input = sp->def[hdw->input_val].aud; | ||
| 128 | pvr2_trace(PVR2_TRACE_CHIPS, | 131 | pvr2_trace(PVR2_TRACE_CHIPS, |
| 129 | "subdev cx2584x set_input vid=0x%x aud=0x%x", | 132 | "subdev cx2584x set_input vid=0x%x aud=0x%x", |
| 130 | vid_input, aud_input); | 133 | vid_input, aud_input); |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 0c745b142fb7..cbc388729d77 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
| @@ -85,8 +85,8 @@ MODULE_PARM_DESC(video_std,"specify initial video standard"); | |||
| 85 | module_param_array(tolerance, int, NULL, 0444); | 85 | module_param_array(tolerance, int, NULL, 0444); |
| 86 | MODULE_PARM_DESC(tolerance,"specify stream error tolerance"); | 86 | MODULE_PARM_DESC(tolerance,"specify stream error tolerance"); |
| 87 | 87 | ||
| 88 | /* US Broadcast channel 7 (175.25 MHz) */ | 88 | /* US Broadcast channel 3 (61.25 MHz), to help with testing */ |
| 89 | static int default_tv_freq = 175250000L; | 89 | static int default_tv_freq = 61250000L; |
| 90 | /* 104.3 MHz, a usable FM station for my area */ | 90 | /* 104.3 MHz, a usable FM station for my area */ |
| 91 | static int default_radio_freq = 104300000L; | 91 | static int default_radio_freq = 104300000L; |
| 92 | 92 | ||
| @@ -1987,6 +1987,34 @@ static unsigned int pvr2_copy_i2c_addr_list( | |||
| 1987 | } | 1987 | } |
| 1988 | 1988 | ||
| 1989 | 1989 | ||
| 1990 | static void pvr2_hdw_cx25840_vbi_hack(struct pvr2_hdw *hdw) | ||
| 1991 | { | ||
| 1992 | /* | ||
| 1993 | Mike Isely <isely@pobox.com> 19-Nov-2006 - This bit of nuttiness | ||
| 1994 | for cx25840 causes that module to correctly set up its video | ||
| 1995 | scaling. This is really a problem in the cx25840 module itself, | ||
| 1996 | but we work around it here. The problem has not been seen in | ||
| 1997 | ivtv because there VBI is supported and set up. We don't do VBI | ||
| 1998 | here (at least not yet) and thus we never attempted to even set | ||
| 1999 | it up. | ||
| 2000 | */ | ||
| 2001 | struct v4l2_format fmt; | ||
| 2002 | if (hdw->decoder_client_id != PVR2_CLIENT_ID_CX25840) { | ||
| 2003 | /* We're not using a cx25840 so don't enable the hack */ | ||
| 2004 | return; | ||
| 2005 | } | ||
| 2006 | |||
| 2007 | pvr2_trace(PVR2_TRACE_INIT, | ||
| 2008 | "Module ID %u:" | ||
| 2009 | " Executing cx25840 VBI hack", | ||
| 2010 | hdw->decoder_client_id); | ||
| 2011 | memset(&fmt, 0, sizeof(fmt)); | ||
| 2012 | fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; | ||
| 2013 | v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id, | ||
| 2014 | video, s_fmt, &fmt); | ||
| 2015 | } | ||
| 2016 | |||
| 2017 | |||
| 1990 | static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, | 2018 | static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, |
| 1991 | const struct pvr2_device_client_desc *cd) | 2019 | const struct pvr2_device_client_desc *cd) |
| 1992 | { | 2020 | { |
| @@ -2078,30 +2106,6 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, | |||
| 2078 | /* client-specific setup... */ | 2106 | /* client-specific setup... */ |
| 2079 | switch (mid) { | 2107 | switch (mid) { |
| 2080 | case PVR2_CLIENT_ID_CX25840: | 2108 | case PVR2_CLIENT_ID_CX25840: |
| 2081 | hdw->decoder_client_id = mid; | ||
| 2082 | { | ||
| 2083 | /* | ||
| 2084 | Mike Isely <isely@pobox.com> 19-Nov-2006 - This | ||
| 2085 | bit of nuttiness for cx25840 causes that module | ||
| 2086 | to correctly set up its video scaling. This is | ||
| 2087 | really a problem in the cx25840 module itself, | ||
| 2088 | but we work around it here. The problem has not | ||
| 2089 | been seen in ivtv because there VBI is supported | ||
| 2090 | and set up. We don't do VBI here (at least not | ||
| 2091 | yet) and thus we never attempted to even set it | ||
| 2092 | up. | ||
| 2093 | */ | ||
| 2094 | struct v4l2_format fmt; | ||
| 2095 | pvr2_trace(PVR2_TRACE_INIT, | ||
| 2096 | "Module ID %u:" | ||
| 2097 | " Executing cx25840 VBI hack", | ||
| 2098 | mid); | ||
| 2099 | memset(&fmt, 0, sizeof(fmt)); | ||
| 2100 | fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; | ||
| 2101 | v4l2_device_call_all(&hdw->v4l2_dev, mid, | ||
| 2102 | video, s_fmt, &fmt); | ||
| 2103 | } | ||
| 2104 | break; | ||
| 2105 | case PVR2_CLIENT_ID_SAA7115: | 2109 | case PVR2_CLIENT_ID_SAA7115: |
| 2106 | hdw->decoder_client_id = mid; | 2110 | hdw->decoder_client_id = mid; |
| 2107 | break; | 2111 | break; |
| @@ -2202,6 +2206,8 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw) | |||
| 2202 | cptr->info->set_value(cptr,~0,cptr->info->default_value); | 2206 | cptr->info->set_value(cptr,~0,cptr->info->default_value); |
| 2203 | } | 2207 | } |
| 2204 | 2208 | ||
| 2209 | pvr2_hdw_cx25840_vbi_hack(hdw); | ||
| 2210 | |||
| 2205 | /* Set up special default values for the television and radio | 2211 | /* Set up special default values for the television and radio |
| 2206 | frequencies here. It's not really important what these defaults | 2212 | frequencies here. It's not really important what these defaults |
| 2207 | are, but I set them to something usable in the Chicago area just | 2213 | are, but I set them to something usable in the Chicago area just |
| @@ -2954,6 +2960,7 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw) | |||
| 2954 | vs = hdw->std_mask_cur; | 2960 | vs = hdw->std_mask_cur; |
| 2955 | v4l2_device_call_all(&hdw->v4l2_dev, 0, | 2961 | v4l2_device_call_all(&hdw->v4l2_dev, 0, |
| 2956 | core, s_std, vs); | 2962 | core, s_std, vs); |
| 2963 | pvr2_hdw_cx25840_vbi_hack(hdw); | ||
| 2957 | } | 2964 | } |
| 2958 | hdw->tuner_signal_stale = !0; | 2965 | hdw->tuner_signal_stale = !0; |
| 2959 | hdw->cropcap_stale = !0; | 2966 | hdw->cropcap_stale = !0; |
| @@ -4076,6 +4083,7 @@ int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw) | |||
| 4076 | if (hdw->decoder_client_id) { | 4083 | if (hdw->decoder_client_id) { |
| 4077 | v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id, | 4084 | v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id, |
| 4078 | core, reset, 0); | 4085 | core, reset, 0); |
| 4086 | pvr2_hdw_cx25840_vbi_hack(hdw); | ||
| 4079 | return 0; | 4087 | return 0; |
| 4080 | } | 4088 | } |
| 4081 | pvr2_trace(PVR2_TRACE_INIT, | 4089 | pvr2_trace(PVR2_TRACE_INIT, |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c index d2fe7c8f2c3a..4c96cf48c796 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c +++ b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c | |||
| @@ -54,6 +54,11 @@ static const int routing_scheme0[] = { | |||
| 54 | [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2, | 54 | [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2, |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | static const struct routing_scheme routing_def0 = { | ||
| 58 | .def = routing_scheme0, | ||
| 59 | .cnt = ARRAY_SIZE(routing_scheme0), | ||
| 60 | }; | ||
| 61 | |||
| 57 | static const int routing_scheme1[] = { | 62 | static const int routing_scheme1[] = { |
| 58 | [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4, | 63 | [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4, |
| 59 | [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5, | 64 | [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5, |
| @@ -61,15 +66,14 @@ static const int routing_scheme1[] = { | |||
| 61 | [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2, /* or SVIDEO0, it seems */ | 66 | [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2, /* or SVIDEO0, it seems */ |
| 62 | }; | 67 | }; |
| 63 | 68 | ||
| 64 | static const struct routing_scheme routing_schemes[] = { | 69 | static const struct routing_scheme routing_def1 = { |
| 65 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = { | 70 | .def = routing_scheme1, |
| 66 | .def = routing_scheme0, | 71 | .cnt = ARRAY_SIZE(routing_scheme1), |
| 67 | .cnt = ARRAY_SIZE(routing_scheme0), | 72 | }; |
| 68 | }, | 73 | |
| 69 | [PVR2_ROUTING_SCHEME_ONAIR] = { | 74 | static const struct routing_scheme *routing_schemes[] = { |
| 70 | .def = routing_scheme1, | 75 | [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0, |
| 71 | .cnt = ARRAY_SIZE(routing_scheme1), | 76 | [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1, |
| 72 | }, | ||
| 73 | }; | 77 | }; |
| 74 | 78 | ||
| 75 | void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | 79 | void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) |
| @@ -81,12 +85,12 @@ void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
| 81 | 85 | ||
| 82 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", | 86 | pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", |
| 83 | hdw->input_val); | 87 | hdw->input_val); |
| 84 | if ((sid < ARRAY_SIZE(routing_schemes)) && | 88 | |
| 85 | ((sp = routing_schemes + sid) != NULL) && | 89 | sp = (sid < ARRAY_SIZE(routing_schemes)) ? |
| 86 | (hdw->input_val >= 0) && | 90 | routing_schemes[sid] : NULL; |
| 87 | (hdw->input_val < sp->cnt)) { | 91 | if ((sp == NULL) || |
| 88 | input = sp->def[hdw->input_val]; | 92 | (hdw->input_val < 0) || |
| 89 | } else { | 93 | (hdw->input_val >= sp->cnt)) { |
| 90 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 94 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 91 | "*** WARNING *** subdev v4l2 set_input:" | 95 | "*** WARNING *** subdev v4l2 set_input:" |
| 92 | " Invalid routing scheme (%u)" | 96 | " Invalid routing scheme (%u)" |
| @@ -94,6 +98,7 @@ void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) | |||
| 94 | sid, hdw->input_val); | 98 | sid, hdw->input_val); |
| 95 | return; | 99 | return; |
| 96 | } | 100 | } |
| 101 | input = sp->def[hdw->input_val]; | ||
| 97 | sd->ops->video->s_routing(sd, input, 0, 0); | 102 | sd->ops->video->s_routing(sd, input, 0, 0); |
| 98 | } | 103 | } |
| 99 | } | 104 | } |
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c index f60de40fd21f..46e0d8ad880f 100644 --- a/drivers/media/video/pxa_camera.c +++ b/drivers/media/video/pxa_camera.c | |||
| @@ -163,13 +163,6 @@ | |||
| 163 | CICR0_EOFM | CICR0_FOM) | 163 | CICR0_EOFM | CICR0_FOM) |
| 164 | 164 | ||
| 165 | /* | 165 | /* |
| 166 | * YUV422P picture size should be a multiple of 16, so the heuristic aligns | ||
| 167 | * height, width on 4 byte boundaries to reach the 16 multiple for the size. | ||
| 168 | */ | ||
| 169 | #define YUV422P_X_Y_ALIGN 4 | ||
| 170 | #define YUV422P_SIZE_ALIGN YUV422P_X_Y_ALIGN * YUV422P_X_Y_ALIGN | ||
| 171 | |||
| 172 | /* | ||
| 173 | * Structures | 166 | * Structures |
| 174 | */ | 167 | */ |
| 175 | enum pxa_camera_active_dma { | 168 | enum pxa_camera_active_dma { |
| @@ -1398,28 +1391,15 @@ static int pxa_camera_try_fmt(struct soc_camera_device *icd, | |||
| 1398 | return -EINVAL; | 1391 | return -EINVAL; |
| 1399 | } | 1392 | } |
| 1400 | 1393 | ||
| 1401 | /* limit to pxa hardware capabilities */ | ||
| 1402 | if (pix->height < 32) | ||
| 1403 | pix->height = 32; | ||
| 1404 | if (pix->height > 2048) | ||
| 1405 | pix->height = 2048; | ||
| 1406 | if (pix->width < 48) | ||
| 1407 | pix->width = 48; | ||
| 1408 | if (pix->width > 2048) | ||
| 1409 | pix->width = 2048; | ||
| 1410 | pix->width &= ~0x01; | ||
| 1411 | |||
| 1412 | /* | 1394 | /* |
| 1413 | * YUV422P planar format requires images size to be a 16 bytes | 1395 | * Limit to pxa hardware capabilities. YUV422P planar format requires |
| 1414 | * multiple. If not, zeros will be inserted between Y and U planes, and | 1396 | * images size to be a multiple of 16 bytes. If not, zeros will be |
| 1415 | * U and V planes, and YUV422P standard would be violated. | 1397 | * inserted between Y and U planes, and U and V planes, which violates |
| 1398 | * the YUV422P standard. | ||
| 1416 | */ | 1399 | */ |
| 1417 | if (xlate->host_fmt->fourcc == V4L2_PIX_FMT_YUV422P) { | 1400 | v4l_bound_align_image(&pix->width, 48, 2048, 1, |
| 1418 | if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN)) | 1401 | &pix->height, 32, 2048, 0, |
| 1419 | pix->height = ALIGN(pix->height, YUV422P_X_Y_ALIGN); | 1402 | xlate->host_fmt->fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0); |
| 1420 | if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN)) | ||
| 1421 | pix->width = ALIGN(pix->width, YUV422P_X_Y_ALIGN); | ||
| 1422 | } | ||
| 1423 | 1403 | ||
| 1424 | pix->bytesperline = pix->width * | 1404 | pix->bytesperline = pix->width * |
| 1425 | DIV_ROUND_UP(xlate->host_fmt->depth, 8); | 1405 | DIV_ROUND_UP(xlate->host_fmt->depth, 8); |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index e305c1674cee..ba87128542e0 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
| @@ -1640,15 +1640,8 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv, | |||
| 1640 | } | 1640 | } |
| 1641 | 1641 | ||
| 1642 | f->fmt.pix.field = field; | 1642 | f->fmt.pix.field = field; |
| 1643 | if (f->fmt.pix.width < 48) | 1643 | v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, |
| 1644 | f->fmt.pix.width = 48; | 1644 | &f->fmt.pix.height, 32, maxh, 0, 0); |
| 1645 | if (f->fmt.pix.height < 32) | ||
| 1646 | f->fmt.pix.height = 32; | ||
| 1647 | if (f->fmt.pix.width > maxw) | ||
| 1648 | f->fmt.pix.width = maxw; | ||
| 1649 | if (f->fmt.pix.height > maxh) | ||
| 1650 | f->fmt.pix.height = maxh; | ||
| 1651 | f->fmt.pix.width &= ~0x03; | ||
| 1652 | f->fmt.pix.bytesperline = | 1645 | f->fmt.pix.bytesperline = |
| 1653 | (f->fmt.pix.width * fmt->depth) >> 3; | 1646 | (f->fmt.pix.width * fmt->depth) >> 3; |
| 1654 | f->fmt.pix.sizeimage = | 1647 | f->fmt.pix.sizeimage = |
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index d369e8409ab8..0db88a53d92c 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c | |||
| @@ -689,16 +689,8 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd, | |||
| 689 | 689 | ||
| 690 | /* FIXME: calculate using depth and bus width */ | 690 | /* FIXME: calculate using depth and bus width */ |
| 691 | 691 | ||
| 692 | if (f->fmt.pix.height < 4) | 692 | v4l_bound_align_image(&f->fmt.pix.width, 2, 2560, 1, |
| 693 | f->fmt.pix.height = 4; | 693 | &f->fmt.pix.height, 4, 1920, 2, 0); |
| 694 | if (f->fmt.pix.height > 1920) | ||
| 695 | f->fmt.pix.height = 1920; | ||
| 696 | if (f->fmt.pix.width < 2) | ||
| 697 | f->fmt.pix.width = 2; | ||
| 698 | if (f->fmt.pix.width > 2560) | ||
| 699 | f->fmt.pix.width = 2560; | ||
| 700 | f->fmt.pix.width &= ~0x01; | ||
| 701 | f->fmt.pix.height &= ~0x03; | ||
| 702 | 694 | ||
| 703 | f->fmt.pix.bytesperline = f->fmt.pix.width * | 695 | f->fmt.pix.bytesperline = f->fmt.pix.width * |
| 704 | DIV_ROUND_UP(xlate->host_fmt->depth, 8); | 696 | DIV_ROUND_UP(xlate->host_fmt->depth, 8); |
diff --git a/drivers/media/video/tcm825x.c b/drivers/media/video/tcm825x.c index b30c49248217..b90e9da3167d 100644 --- a/drivers/media/video/tcm825x.c +++ b/drivers/media/video/tcm825x.c | |||
| @@ -878,7 +878,7 @@ static int tcm825x_probe(struct i2c_client *client, | |||
| 878 | return rval; | 878 | return rval; |
| 879 | } | 879 | } |
| 880 | 880 | ||
| 881 | static int __exit tcm825x_remove(struct i2c_client *client) | 881 | static int tcm825x_remove(struct i2c_client *client) |
| 882 | { | 882 | { |
| 883 | struct tcm825x_sensor *sensor = i2c_get_clientdata(client); | 883 | struct tcm825x_sensor *sensor = i2c_get_clientdata(client); |
| 884 | 884 | ||
| @@ -902,7 +902,7 @@ static struct i2c_driver tcm825x_i2c_driver = { | |||
| 902 | .name = TCM825X_NAME, | 902 | .name = TCM825X_NAME, |
| 903 | }, | 903 | }, |
| 904 | .probe = tcm825x_probe, | 904 | .probe = tcm825x_probe, |
| 905 | .remove = __exit_p(tcm825x_remove), | 905 | .remove = tcm825x_remove, |
| 906 | .id_table = tcm825x_id, | 906 | .id_table = tcm825x_id, |
| 907 | }; | 907 | }; |
| 908 | 908 | ||
diff --git a/drivers/media/video/usbvideo/Kconfig b/drivers/media/video/usbvideo/Kconfig index e4cb99c1f94b..adb1c044ad7d 100644 --- a/drivers/media/video/usbvideo/Kconfig +++ b/drivers/media/video/usbvideo/Kconfig | |||
| @@ -38,10 +38,13 @@ config USB_KONICAWC | |||
| 38 | module will be called konicawc. | 38 | module will be called konicawc. |
| 39 | 39 | ||
| 40 | config USB_QUICKCAM_MESSENGER | 40 | config USB_QUICKCAM_MESSENGER |
| 41 | tristate "USB Logitech Quickcam Messenger" | 41 | tristate "USB Logitech Quickcam Messenger (DEPRECATED)" |
| 42 | depends on VIDEO_V4L1 | 42 | depends on VIDEO_V4L1 |
| 43 | select VIDEO_USBVIDEO | 43 | select VIDEO_USBVIDEO |
| 44 | ---help--- | 44 | ---help--- |
| 45 | This driver is DEPRECATED please use the gspca stv06xx module | ||
| 46 | instead. | ||
| 47 | |||
| 45 | Say Y or M here to enable support for the USB Logitech Quickcam | 48 | Say Y or M here to enable support for the USB Logitech Quickcam |
| 46 | Messenger webcam. | 49 | Messenger webcam. |
| 47 | 50 | ||
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index f96475626da7..b91d66a767d7 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
| @@ -802,6 +802,17 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, | |||
| 802 | /* Decrease the module use count to match the first try_module_get. */ | 802 | /* Decrease the module use count to match the first try_module_get. */ |
| 803 | module_put(client->driver->driver.owner); | 803 | module_put(client->driver->driver.owner); |
| 804 | 804 | ||
| 805 | if (sd) { | ||
| 806 | /* We return errors from v4l2_subdev_call only if we have the | ||
| 807 | callback as the .s_config is not mandatory */ | ||
| 808 | int err = v4l2_subdev_call(sd, core, s_config, 0, NULL); | ||
| 809 | |||
| 810 | if (err && err != -ENOIOCTLCMD) { | ||
| 811 | v4l2_device_unregister_subdev(sd); | ||
| 812 | sd = NULL; | ||
| 813 | } | ||
| 814 | } | ||
| 815 | |||
| 805 | error: | 816 | error: |
| 806 | /* If we have a client but no subdev, then something went wrong and | 817 | /* If we have a client but no subdev, then something went wrong and |
| 807 | we must unregister the client. */ | 818 | we must unregister the client. */ |
| @@ -852,6 +863,17 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev, | |||
| 852 | /* Decrease the module use count to match the first try_module_get. */ | 863 | /* Decrease the module use count to match the first try_module_get. */ |
| 853 | module_put(client->driver->driver.owner); | 864 | module_put(client->driver->driver.owner); |
| 854 | 865 | ||
| 866 | if (sd) { | ||
| 867 | /* We return errors from v4l2_subdev_call only if we have the | ||
| 868 | callback as the .s_config is not mandatory */ | ||
| 869 | int err = v4l2_subdev_call(sd, core, s_config, 0, NULL); | ||
| 870 | |||
| 871 | if (err && err != -ENOIOCTLCMD) { | ||
| 872 | v4l2_device_unregister_subdev(sd); | ||
| 873 | sd = NULL; | ||
| 874 | } | ||
| 875 | } | ||
| 876 | |||
| 855 | error: | 877 | error: |
| 856 | /* If we have a client but no subdev, then something went wrong and | 878 | /* If we have a client but no subdev, then something went wrong and |
| 857 | we must unregister the client. */ | 879 | we must unregister the client. */ |
| @@ -872,6 +894,89 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev_addr(struct v4l2_device *v4l2_dev | |||
| 872 | } | 894 | } |
| 873 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev_addr); | 895 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev_addr); |
| 874 | 896 | ||
| 897 | /* Load an i2c sub-device. */ | ||
| 898 | struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, | ||
| 899 | struct i2c_adapter *adapter, const char *module_name, | ||
| 900 | struct i2c_board_info *info, const unsigned short *probe_addrs) | ||
| 901 | { | ||
| 902 | struct v4l2_subdev *sd = NULL; | ||
| 903 | struct i2c_client *client; | ||
| 904 | |||
| 905 | BUG_ON(!v4l2_dev); | ||
| 906 | |||
| 907 | if (module_name) | ||
| 908 | request_module(module_name); | ||
| 909 | |||
| 910 | /* Create the i2c client */ | ||
| 911 | if (info->addr == 0 && probe_addrs) | ||
| 912 | client = i2c_new_probed_device(adapter, info, probe_addrs); | ||
| 913 | else | ||
| 914 | client = i2c_new_device(adapter, info); | ||
| 915 | |||
| 916 | /* Note: by loading the module first we are certain that c->driver | ||
| 917 | will be set if the driver was found. If the module was not loaded | ||
| 918 | first, then the i2c core tries to delay-load the module for us, | ||
| 919 | and then c->driver is still NULL until the module is finally | ||
| 920 | loaded. This delay-load mechanism doesn't work if other drivers | ||
| 921 | want to use the i2c device, so explicitly loading the module | ||
| 922 | is the best alternative. */ | ||
| 923 | if (client == NULL || client->driver == NULL) | ||
| 924 | goto error; | ||
| 925 | |||
| 926 | /* Lock the module so we can safely get the v4l2_subdev pointer */ | ||
| 927 | if (!try_module_get(client->driver->driver.owner)) | ||
| 928 | goto error; | ||
| 929 | sd = i2c_get_clientdata(client); | ||
| 930 | |||
| 931 | /* Register with the v4l2_device which increases the module's | ||
| 932 | use count as well. */ | ||
| 933 | if (v4l2_device_register_subdev(v4l2_dev, sd)) | ||
| 934 | sd = NULL; | ||
| 935 | /* Decrease the module use count to match the first try_module_get. */ | ||
| 936 | module_put(client->driver->driver.owner); | ||
| 937 | |||
| 938 | if (sd) { | ||
| 939 | /* We return errors from v4l2_subdev_call only if we have the | ||
| 940 | callback as the .s_config is not mandatory */ | ||
| 941 | int err = v4l2_subdev_call(sd, core, s_config, | ||
| 942 | info->irq, info->platform_data); | ||
| 943 | |||
| 944 | if (err && err != -ENOIOCTLCMD) { | ||
| 945 | v4l2_device_unregister_subdev(sd); | ||
| 946 | sd = NULL; | ||
| 947 | } | ||
| 948 | } | ||
| 949 | |||
| 950 | error: | ||
| 951 | /* If we have a client but no subdev, then something went wrong and | ||
| 952 | we must unregister the client. */ | ||
| 953 | if (client && sd == NULL) | ||
| 954 | i2c_unregister_device(client); | ||
| 955 | return sd; | ||
| 956 | } | ||
| 957 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_board); | ||
| 958 | |||
| 959 | struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev, | ||
| 960 | struct i2c_adapter *adapter, | ||
| 961 | const char *module_name, const char *client_type, | ||
| 962 | int irq, void *platform_data, | ||
| 963 | u8 addr, const unsigned short *probe_addrs) | ||
| 964 | { | ||
| 965 | struct i2c_board_info info; | ||
| 966 | |||
| 967 | /* Setup the i2c board info with the device type and | ||
| 968 | the device address. */ | ||
| 969 | memset(&info, 0, sizeof(info)); | ||
| 970 | strlcpy(info.type, client_type, sizeof(info.type)); | ||
| 971 | info.addr = addr; | ||
| 972 | info.irq = irq; | ||
| 973 | info.platform_data = platform_data; | ||
| 974 | |||
| 975 | return v4l2_i2c_new_subdev_board(v4l2_dev, adapter, module_name, | ||
| 976 | &info, probe_addrs); | ||
| 977 | } | ||
| 978 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_cfg); | ||
| 979 | |||
| 875 | /* Return i2c client address of v4l2_subdev. */ | 980 | /* Return i2c client address of v4l2_subdev. */ |
| 876 | unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd) | 981 | unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd) |
| 877 | { | 982 | { |
| @@ -916,4 +1021,78 @@ const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type) | |||
| 916 | } | 1021 | } |
| 917 | EXPORT_SYMBOL_GPL(v4l2_i2c_tuner_addrs); | 1022 | EXPORT_SYMBOL_GPL(v4l2_i2c_tuner_addrs); |
| 918 | 1023 | ||
| 919 | #endif | 1024 | #endif /* defined(CONFIG_I2C) */ |
| 1025 | |||
| 1026 | /* Clamp x to be between min and max, aligned to a multiple of 2^align. min | ||
| 1027 | * and max don't have to be aligned, but there must be at least one valid | ||
| 1028 | * value. E.g., min=17,max=31,align=4 is not allowed as there are no multiples | ||
| 1029 | * of 16 between 17 and 31. */ | ||
| 1030 | static unsigned int clamp_align(unsigned int x, unsigned int min, | ||
| 1031 | unsigned int max, unsigned int align) | ||
| 1032 | { | ||
| 1033 | /* Bits that must be zero to be aligned */ | ||
| 1034 | unsigned int mask = ~((1 << align) - 1); | ||
| 1035 | |||
| 1036 | /* Round to nearest aligned value */ | ||
| 1037 | if (align) | ||
| 1038 | x = (x + (1 << (align - 1))) & mask; | ||
| 1039 | |||
| 1040 | /* Clamp to aligned value of min and max */ | ||
| 1041 | if (x < min) | ||
| 1042 | x = (min + ~mask) & mask; | ||
| 1043 | else if (x > max) | ||
| 1044 | x = max & mask; | ||
| 1045 | |||
| 1046 | return x; | ||
| 1047 | } | ||
| 1048 | |||
| 1049 | /* Bound an image to have a width between wmin and wmax, and height between | ||
| 1050 | * hmin and hmax, inclusive. Additionally, the width will be a multiple of | ||
| 1051 | * 2^walign, the height will be a multiple of 2^halign, and the overall size | ||
| 1052 | * (width*height) will be a multiple of 2^salign. The image may be shrunk | ||
| 1053 | * or enlarged to fit the alignment constraints. | ||
| 1054 | * | ||
| 1055 | * The width or height maximum must not be smaller than the corresponding | ||
| 1056 | * minimum. The alignments must not be so high there are no possible image | ||
| 1057 | * sizes within the allowed bounds. wmin and hmin must be at least 1 | ||
| 1058 | * (don't use 0). If you don't care about a certain alignment, specify 0, | ||
| 1059 | * as 2^0 is 1 and one byte alignment is equivalent to no alignment. If | ||
| 1060 | * you only want to adjust downward, specify a maximum that's the same as | ||
| 1061 | * the initial value. | ||
| 1062 | */ | ||
| 1063 | void v4l_bound_align_image(u32 *w, unsigned int wmin, unsigned int wmax, | ||
| 1064 | unsigned int walign, | ||
| 1065 | u32 *h, unsigned int hmin, unsigned int hmax, | ||
| 1066 | unsigned int halign, unsigned int salign) | ||
| 1067 | { | ||
| 1068 | *w = clamp_align(*w, wmin, wmax, walign); | ||
| 1069 | *h = clamp_align(*h, hmin, hmax, halign); | ||
| 1070 | |||
| 1071 | /* Usually we don't need to align the size and are done now. */ | ||
| 1072 | if (!salign) | ||
| 1073 | return; | ||
| 1074 | |||
| 1075 | /* How much alignment do we have? */ | ||
| 1076 | walign = __ffs(*w); | ||
| 1077 | halign = __ffs(*h); | ||
| 1078 | /* Enough to satisfy the image alignment? */ | ||
| 1079 | if (walign + halign < salign) { | ||
| 1080 | /* Max walign where there is still a valid width */ | ||
| 1081 | unsigned int wmaxa = __fls(wmax ^ (wmin - 1)); | ||
| 1082 | /* Max halign where there is still a valid height */ | ||
| 1083 | unsigned int hmaxa = __fls(hmax ^ (hmin - 1)); | ||
| 1084 | |||
| 1085 | /* up the smaller alignment until we have enough */ | ||
| 1086 | do { | ||
| 1087 | if (halign >= hmaxa || | ||
| 1088 | (walign <= halign && walign < wmaxa)) { | ||
| 1089 | *w = clamp_align(*w, wmin, wmax, walign + 1); | ||
| 1090 | walign = __ffs(*w); | ||
| 1091 | } else { | ||
| 1092 | *h = clamp_align(*h, hmin, hmax, halign + 1); | ||
| 1093 | halign = __ffs(*h); | ||
| 1094 | } | ||
| 1095 | } while (halign + walign < salign); | ||
| 1096 | } | ||
| 1097 | } | ||
| 1098 | EXPORT_SYMBOL_GPL(v4l_bound_align_image); | ||
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index fbfefae7886f..cd7266858462 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
| @@ -883,15 +883,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
| 883 | maxh = norm_maxh(); | 883 | maxh = norm_maxh(); |
| 884 | 884 | ||
| 885 | f->fmt.pix.field = field; | 885 | f->fmt.pix.field = field; |
| 886 | if (f->fmt.pix.height < 32) | 886 | v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, |
| 887 | f->fmt.pix.height = 32; | 887 | &f->fmt.pix.height, 32, maxh, 0, 0); |
| 888 | if (f->fmt.pix.height > maxh) | ||
| 889 | f->fmt.pix.height = maxh; | ||
| 890 | if (f->fmt.pix.width < 48) | ||
| 891 | f->fmt.pix.width = 48; | ||
| 892 | if (f->fmt.pix.width > maxw) | ||
| 893 | f->fmt.pix.width = maxw; | ||
| 894 | f->fmt.pix.width &= ~0x03; | ||
| 895 | f->fmt.pix.bytesperline = | 888 | f->fmt.pix.bytesperline = |
| 896 | (f->fmt.pix.width * fmt->depth) >> 3; | 889 | (f->fmt.pix.width * fmt->depth) >> 3; |
| 897 | f->fmt.pix.sizeimage = | 890 | f->fmt.pix.sizeimage = |
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c index f59b2bd07e89..6c3f23e31b5c 100644 --- a/drivers/media/video/w9968cf.c +++ b/drivers/media/video/w9968cf.c | |||
| @@ -460,7 +460,7 @@ static int w9968cf_set_picture(struct w9968cf_device*, struct video_picture); | |||
| 460 | static int w9968cf_set_window(struct w9968cf_device*, struct video_window); | 460 | static int w9968cf_set_window(struct w9968cf_device*, struct video_window); |
| 461 | static int w9968cf_postprocess_frame(struct w9968cf_device*, | 461 | static int w9968cf_postprocess_frame(struct w9968cf_device*, |
| 462 | struct w9968cf_frame_t*); | 462 | struct w9968cf_frame_t*); |
| 463 | static int w9968cf_adjust_window_size(struct w9968cf_device*, u16* w, u16* h); | 463 | static int w9968cf_adjust_window_size(struct w9968cf_device*, u32 *w, u32 *h); |
| 464 | static void w9968cf_init_framelist(struct w9968cf_device*); | 464 | static void w9968cf_init_framelist(struct w9968cf_device*); |
| 465 | static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num); | 465 | static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num); |
| 466 | static void w9968cf_pop_frame(struct w9968cf_device*,struct w9968cf_frame_t**); | 466 | static void w9968cf_pop_frame(struct w9968cf_device*,struct w9968cf_frame_t**); |
| @@ -1763,8 +1763,7 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win) | |||
| 1763 | #define UNSC(x) ((x) >> 10) | 1763 | #define UNSC(x) ((x) >> 10) |
| 1764 | 1764 | ||
| 1765 | /* Make sure we are using a supported resolution */ | 1765 | /* Make sure we are using a supported resolution */ |
| 1766 | if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width, | 1766 | if ((err = w9968cf_adjust_window_size(cam, &win.width, &win.height))) |
| 1767 | (u16*)&win.height))) | ||
| 1768 | goto error; | 1767 | goto error; |
| 1769 | 1768 | ||
| 1770 | /* Scaling factors */ | 1769 | /* Scaling factors */ |
| @@ -1914,12 +1913,9 @@ error: | |||
| 1914 | Return 0 on success, -1 otherwise. | 1913 | Return 0 on success, -1 otherwise. |
| 1915 | --------------------------------------------------------------------------*/ | 1914 | --------------------------------------------------------------------------*/ |
| 1916 | static int | 1915 | static int |
| 1917 | w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height) | 1916 | w9968cf_adjust_window_size(struct w9968cf_device *cam, u32 *width, u32 *height) |
| 1918 | { | 1917 | { |
| 1919 | u16 maxw, maxh; | 1918 | unsigned int maxw, maxh, align; |
| 1920 | |||
| 1921 | if ((*width < cam->minwidth) || (*height < cam->minheight)) | ||
| 1922 | return -ERANGE; | ||
| 1923 | 1919 | ||
| 1924 | maxw = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && | 1920 | maxw = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && |
| 1925 | w9968cf_vpp ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth) | 1921 | w9968cf_vpp ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth) |
| @@ -1927,16 +1923,10 @@ w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height) | |||
| 1927 | maxh = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && | 1923 | maxh = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) && |
| 1928 | w9968cf_vpp ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight) | 1924 | w9968cf_vpp ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight) |
| 1929 | : cam->maxheight; | 1925 | : cam->maxheight; |
| 1926 | align = (cam->vpp_flag & VPP_DECOMPRESSION) ? 4 : 0; | ||
| 1930 | 1927 | ||
| 1931 | if (*width > maxw) | 1928 | v4l_bound_align_image(width, cam->minwidth, maxw, align, |
| 1932 | *width = maxw; | 1929 | height, cam->minheight, maxh, align, 0); |
| 1933 | if (*height > maxh) | ||
| 1934 | *height = maxh; | ||
| 1935 | |||
| 1936 | if (cam->vpp_flag & VPP_DECOMPRESSION) { | ||
| 1937 | *width &= ~15L; /* multiple of 16 */ | ||
| 1938 | *height &= ~15L; | ||
| 1939 | } | ||
| 1940 | 1930 | ||
| 1941 | PDBGG("Window size adjusted w=%u, h=%u ", *width, *height) | 1931 | PDBGG("Window size adjusted w=%u, h=%u ", *width, *height) |
| 1942 | 1932 | ||
| @@ -3043,8 +3033,8 @@ static long w9968cf_v4l_ioctl(struct file *filp, | |||
| 3043 | if (win.clipcount != 0 || win.flags != 0) | 3033 | if (win.clipcount != 0 || win.flags != 0) |
| 3044 | return -EINVAL; | 3034 | return -EINVAL; |
| 3045 | 3035 | ||
| 3046 | if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width, | 3036 | if ((err = w9968cf_adjust_window_size(cam, &win.width, |
| 3047 | (u16*)&win.height))) { | 3037 | &win.height))) { |
| 3048 | DBG(4, "Resolution not supported (%ux%u). " | 3038 | DBG(4, "Resolution not supported (%ux%u). " |
| 3049 | "VIDIOCSWIN failed", win.width, win.height) | 3039 | "VIDIOCSWIN failed", win.width, win.height) |
| 3050 | return err; | 3040 | return err; |
| @@ -3116,6 +3106,7 @@ static long w9968cf_v4l_ioctl(struct file *filp, | |||
| 3116 | { | 3106 | { |
| 3117 | struct video_mmap mmap; | 3107 | struct video_mmap mmap; |
| 3118 | struct w9968cf_frame_t* fr; | 3108 | struct w9968cf_frame_t* fr; |
| 3109 | u32 w, h; | ||
| 3119 | int err = 0; | 3110 | int err = 0; |
| 3120 | 3111 | ||
| 3121 | if (copy_from_user(&mmap, arg, sizeof(mmap))) | 3112 | if (copy_from_user(&mmap, arg, sizeof(mmap))) |
| @@ -3164,8 +3155,10 @@ static long w9968cf_v4l_ioctl(struct file *filp, | |||
| 3164 | } | 3155 | } |
| 3165 | } | 3156 | } |
| 3166 | 3157 | ||
| 3167 | if ((err = w9968cf_adjust_window_size(cam, (u16*)&mmap.width, | 3158 | w = mmap.width; h = mmap.height; |
| 3168 | (u16*)&mmap.height))) { | 3159 | err = w9968cf_adjust_window_size(cam, &w, &h); |
| 3160 | mmap.width = w; mmap.height = h; | ||
| 3161 | if (err) { | ||
| 3169 | DBG(4, "Resolution not supported (%dx%d). " | 3162 | DBG(4, "Resolution not supported (%dx%d). " |
| 3170 | "VIDIOCMCAPTURE failed", | 3163 | "VIDIOCMCAPTURE failed", |
| 3171 | mmap.width, mmap.height) | 3164 | mmap.width, mmap.height) |
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c index 643cccaa1aab..3d7df32a3d87 100644 --- a/drivers/media/video/zoran/zoran_driver.c +++ b/drivers/media/video/zoran/zoran_driver.c | |||
| @@ -2088,16 +2088,10 @@ static int zoran_try_fmt_vid_cap(struct file *file, void *__fh, | |||
| 2088 | return -EINVAL; | 2088 | return -EINVAL; |
| 2089 | } | 2089 | } |
| 2090 | 2090 | ||
| 2091 | bpp = (zoran_formats[i].depth + 7) / 8; | 2091 | bpp = DIV_ROUND_UP(zoran_formats[i].depth, 8); |
| 2092 | fmt->fmt.pix.width &= ~((bpp == 2) ? 1 : 3); | 2092 | v4l_bound_align_image( |
| 2093 | if (fmt->fmt.pix.width > BUZ_MAX_WIDTH) | 2093 | &fmt->fmt.pix.width, BUZ_MIN_WIDTH, BUZ_MAX_WIDTH, bpp == 2 ? 1 : 2, |
| 2094 | fmt->fmt.pix.width = BUZ_MAX_WIDTH; | 2094 | &fmt->fmt.pix.height, BUZ_MIN_HEIGHT, BUZ_MAX_HEIGHT, 0, 0); |
| 2095 | if (fmt->fmt.pix.width < BUZ_MIN_WIDTH) | ||
| 2096 | fmt->fmt.pix.width = BUZ_MIN_WIDTH; | ||
| 2097 | if (fmt->fmt.pix.height > BUZ_MAX_HEIGHT) | ||
| 2098 | fmt->fmt.pix.height = BUZ_MAX_HEIGHT; | ||
| 2099 | if (fmt->fmt.pix.height < BUZ_MIN_HEIGHT) | ||
| 2100 | fmt->fmt.pix.height = BUZ_MIN_HEIGHT; | ||
| 2101 | mutex_unlock(&zr->resource_lock); | 2095 | mutex_unlock(&zr->resource_lock); |
| 2102 | 2096 | ||
| 2103 | return 0; | 2097 | return 0; |
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 20e0b447e8e8..55ff25244af4 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c | |||
| @@ -3518,7 +3518,7 @@ retry_page: | |||
| 3518 | } else | 3518 | } else |
| 3519 | mptsas_volume_delete(ioc, sas_info->fw.id); | 3519 | mptsas_volume_delete(ioc, sas_info->fw.id); |
| 3520 | } | 3520 | } |
| 3521 | mutex_lock(&ioc->sas_device_info_mutex); | 3521 | mutex_unlock(&ioc->sas_device_info_mutex); |
| 3522 | 3522 | ||
| 3523 | /* expanders */ | 3523 | /* expanders */ |
| 3524 | mutex_lock(&ioc->sas_topology_mutex); | 3524 | mutex_lock(&ioc->sas_topology_mutex); |
| @@ -3549,7 +3549,7 @@ retry_page: | |||
| 3549 | goto redo_expander_scan; | 3549 | goto redo_expander_scan; |
| 3550 | } | 3550 | } |
| 3551 | } | 3551 | } |
| 3552 | mutex_lock(&ioc->sas_topology_mutex); | 3552 | mutex_unlock(&ioc->sas_topology_mutex); |
| 3553 | } | 3553 | } |
| 3554 | 3554 | ||
| 3555 | /** | 3555 | /** |
diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c index cd1008c19cd7..ca54996ffd0e 100644 --- a/drivers/mfd/twl4030-core.c +++ b/drivers/mfd/twl4030-core.c | |||
| @@ -101,6 +101,12 @@ | |||
| 101 | #define twl_has_usb() false | 101 | #define twl_has_usb() false |
| 102 | #endif | 102 | #endif |
| 103 | 103 | ||
| 104 | #if defined(CONFIG_TWL4030_WATCHDOG) || \ | ||
| 105 | defined(CONFIG_TWL4030_WATCHDOG_MODULE) | ||
| 106 | #define twl_has_watchdog() true | ||
| 107 | #else | ||
| 108 | #define twl_has_watchdog() false | ||
| 109 | #endif | ||
| 104 | 110 | ||
| 105 | /* Triton Core internal information (BEGIN) */ | 111 | /* Triton Core internal information (BEGIN) */ |
| 106 | 112 | ||
| @@ -526,6 +532,12 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features) | |||
| 526 | usb_transceiver = child; | 532 | usb_transceiver = child; |
| 527 | } | 533 | } |
| 528 | 534 | ||
| 535 | if (twl_has_watchdog()) { | ||
| 536 | child = add_child(0, "twl4030_wdt", NULL, 0, false, 0, 0); | ||
| 537 | if (IS_ERR(child)) | ||
| 538 | return PTR_ERR(child); | ||
| 539 | } | ||
| 540 | |||
| 529 | if (twl_has_regulator()) { | 541 | if (twl_has_regulator()) { |
| 530 | /* | 542 | /* |
| 531 | child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1); | 543 | child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1); |
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index 44f77eb1180f..4d1515f45ba2 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c | |||
| @@ -25,8 +25,6 @@ | |||
| 25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
| 26 | #include <linux/ethtool.h> | 26 | #include <linux/ethtool.h> |
| 27 | #include <linux/if_vlan.h> | 27 | #include <linux/if_vlan.h> |
| 28 | #include <linux/module.h> | ||
| 29 | |||
| 30 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | 28 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) |
| 31 | #define BCM_VLAN 1 | 29 | #define BCM_VLAN 1 |
| 32 | #endif | 30 | #endif |
| @@ -2521,9 +2519,9 @@ static struct cnic_dev *init_bnx2_cnic(struct net_device *dev) | |||
| 2521 | struct cnic_dev *cdev; | 2519 | struct cnic_dev *cdev; |
| 2522 | struct cnic_local *cp; | 2520 | struct cnic_local *cp; |
| 2523 | struct cnic_eth_dev *ethdev = NULL; | 2521 | struct cnic_eth_dev *ethdev = NULL; |
| 2524 | struct cnic_eth_dev *(*probe)(void *) = NULL; | 2522 | struct cnic_eth_dev *(*probe)(struct net_device *) = NULL; |
| 2525 | 2523 | ||
| 2526 | probe = __symbol_get("bnx2_cnic_probe"); | 2524 | probe = symbol_get(bnx2_cnic_probe); |
| 2527 | if (probe) { | 2525 | if (probe) { |
| 2528 | ethdev = (*probe)(dev); | 2526 | ethdev = (*probe)(dev); |
| 2529 | symbol_put_addr(probe); | 2527 | symbol_put_addr(probe); |
diff --git a/drivers/net/cnic_if.h b/drivers/net/cnic_if.h index 06380963a34e..d1bce27ee99e 100644 --- a/drivers/net/cnic_if.h +++ b/drivers/net/cnic_if.h | |||
| @@ -296,4 +296,6 @@ extern int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops); | |||
| 296 | 296 | ||
| 297 | extern int cnic_unregister_driver(int ulp_type); | 297 | extern int cnic_unregister_driver(int ulp_type); |
| 298 | 298 | ||
| 299 | extern struct cnic_eth_dev *bnx2_cnic_probe(struct net_device *dev); | ||
| 300 | |||
| 299 | #endif | 301 | #endif |
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c index 5887e4764d22..f96948be0a44 100644 --- a/drivers/net/mlx4/mr.c +++ b/drivers/net/mlx4/mr.c | |||
| @@ -399,11 +399,14 @@ static int mlx4_write_mtt_chunk(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | |||
| 399 | if (!mtts) | 399 | if (!mtts) |
| 400 | return -ENOMEM; | 400 | return -ENOMEM; |
| 401 | 401 | ||
| 402 | dma_sync_single_for_cpu(&dev->pdev->dev, dma_handle, | ||
| 403 | npages * sizeof (u64), DMA_TO_DEVICE); | ||
| 404 | |||
| 402 | for (i = 0; i < npages; ++i) | 405 | for (i = 0; i < npages; ++i) |
| 403 | mtts[i] = cpu_to_be64(page_list[i] | MLX4_MTT_FLAG_PRESENT); | 406 | mtts[i] = cpu_to_be64(page_list[i] | MLX4_MTT_FLAG_PRESENT); |
| 404 | 407 | ||
| 405 | dma_sync_single_for_cpu(&dev->pdev->dev, dma_handle, | 408 | dma_sync_single_for_device(&dev->pdev->dev, dma_handle, |
| 406 | npages * sizeof (u64), DMA_TO_DEVICE); | 409 | npages * sizeof (u64), DMA_TO_DEVICE); |
| 407 | 410 | ||
| 408 | return 0; | 411 | return 0; |
| 409 | } | 412 | } |
| @@ -547,11 +550,14 @@ int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list | |||
| 547 | /* Make sure MPT status is visible before writing MTT entries */ | 550 | /* Make sure MPT status is visible before writing MTT entries */ |
| 548 | wmb(); | 551 | wmb(); |
| 549 | 552 | ||
| 553 | dma_sync_single_for_cpu(&dev->pdev->dev, fmr->dma_handle, | ||
| 554 | npages * sizeof(u64), DMA_TO_DEVICE); | ||
| 555 | |||
| 550 | for (i = 0; i < npages; ++i) | 556 | for (i = 0; i < npages; ++i) |
| 551 | fmr->mtts[i] = cpu_to_be64(page_list[i] | MLX4_MTT_FLAG_PRESENT); | 557 | fmr->mtts[i] = cpu_to_be64(page_list[i] | MLX4_MTT_FLAG_PRESENT); |
| 552 | 558 | ||
| 553 | dma_sync_single_for_cpu(&dev->pdev->dev, fmr->dma_handle, | 559 | dma_sync_single_for_device(&dev->pdev->dev, fmr->dma_handle, |
| 554 | npages * sizeof(u64), DMA_TO_DEVICE); | 560 | npages * sizeof(u64), DMA_TO_DEVICE); |
| 555 | 561 | ||
| 556 | fmr->mpt->key = cpu_to_be32(key); | 562 | fmr->mpt->key = cpu_to_be32(key); |
| 557 | fmr->mpt->lkey = cpu_to_be32(key); | 563 | fmr->mpt->lkey = cpu_to_be32(key); |
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 6a19ed9a1194..9c23122f755f 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
| @@ -258,10 +258,21 @@ config SCSI_SCAN_ASYNC | |||
| 258 | or async on the kernel's command line. | 258 | or async on the kernel's command line. |
| 259 | 259 | ||
| 260 | config SCSI_WAIT_SCAN | 260 | config SCSI_WAIT_SCAN |
| 261 | tristate | 261 | tristate # No prompt here, this is an invisible symbol. |
| 262 | default m | 262 | default m |
| 263 | depends on SCSI | 263 | depends on SCSI |
| 264 | depends on MODULES | 264 | depends on MODULES |
| 265 | # scsi_wait_scan is a loadable module which waits until all the async scans are | ||
| 266 | # complete. The idea is to use it in initrd/ initramfs scripts. You modprobe | ||
| 267 | # it after all the modprobes of the root SCSI drivers and it will wait until | ||
| 268 | # they have all finished scanning their buses before allowing the boot to | ||
| 269 | # proceed. (This method is not applicable if targets boot independently in | ||
| 270 | # parallel with the initiator, or with transports with non-deterministic target | ||
| 271 | # discovery schemes, or if a transport driver does not support scsi_wait_scan.) | ||
| 272 | # | ||
| 273 | # This symbol is not exposed as a prompt because little is to be gained by | ||
| 274 | # disabling it, whereas people who accidentally switch it off may wonder why | ||
| 275 | # their mkinitrd gets into trouble. | ||
| 265 | 276 | ||
| 266 | menu "SCSI Transports" | 277 | menu "SCSI Transports" |
| 267 | depends on SCSI | 278 | depends on SCSI |
diff --git a/drivers/scsi/bnx2i/Kconfig b/drivers/scsi/bnx2i/Kconfig index b62b482e55e7..1e9f7141102b 100644 --- a/drivers/scsi/bnx2i/Kconfig +++ b/drivers/scsi/bnx2i/Kconfig | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | config SCSI_BNX2_ISCSI | 1 | config SCSI_BNX2_ISCSI |
| 2 | tristate "Broadcom NetXtreme II iSCSI support" | 2 | tristate "Broadcom NetXtreme II iSCSI support" |
| 3 | select SCSI_ISCSI_ATTRS | 3 | select SCSI_ISCSI_ATTRS |
| 4 | select NETDEVICES | ||
| 5 | select NETDEV_1000 | ||
| 4 | select CNIC | 6 | select CNIC |
| 5 | depends on PCI | 7 | depends on PCI |
| 6 | ---help--- | 8 | ---help--- |
diff --git a/drivers/scsi/cxgb3i/cxgb3i_ddp.c b/drivers/scsi/cxgb3i/cxgb3i_ddp.c index 99c912547902..344fd53b9954 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_ddp.c +++ b/drivers/scsi/cxgb3i/cxgb3i_ddp.c | |||
| @@ -206,6 +206,31 @@ int cxgb3i_ddp_find_page_index(unsigned long pgsz) | |||
| 206 | return DDP_PGIDX_MAX; | 206 | return DDP_PGIDX_MAX; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | /** | ||
| 210 | * cxgb3i_ddp_adjust_page_table - adjust page table with PAGE_SIZE | ||
| 211 | * return the ddp page index, if no match is found return DDP_PGIDX_MAX. | ||
| 212 | */ | ||
| 213 | int cxgb3i_ddp_adjust_page_table(void) | ||
| 214 | { | ||
| 215 | int i; | ||
| 216 | unsigned int base_order, order; | ||
| 217 | |||
| 218 | if (PAGE_SIZE < (1UL << ddp_page_shift[0])) { | ||
| 219 | ddp_log_info("PAGE_SIZE 0x%lx too small, min. 0x%lx.\n", | ||
| 220 | PAGE_SIZE, 1UL << ddp_page_shift[0]); | ||
| 221 | return -EINVAL; | ||
| 222 | } | ||
| 223 | |||
| 224 | base_order = get_order(1UL << ddp_page_shift[0]); | ||
| 225 | order = get_order(1 << PAGE_SHIFT); | ||
| 226 | for (i = 0; i < DDP_PGIDX_MAX; i++) { | ||
| 227 | /* first is the kernel page size, then just doubling the size */ | ||
| 228 | ddp_page_order[i] = order - base_order + i; | ||
| 229 | ddp_page_shift[i] = PAGE_SHIFT + i; | ||
| 230 | } | ||
| 231 | return 0; | ||
| 232 | } | ||
| 233 | |||
| 209 | static inline void ddp_gl_unmap(struct pci_dev *pdev, | 234 | static inline void ddp_gl_unmap(struct pci_dev *pdev, |
| 210 | struct cxgb3i_gather_list *gl) | 235 | struct cxgb3i_gather_list *gl) |
| 211 | { | 236 | { |
| @@ -598,30 +623,40 @@ int cxgb3i_adapter_ddp_info(struct t3cdev *tdev, | |||
| 598 | * release all the resource held by the ddp pagepod manager for a given | 623 | * release all the resource held by the ddp pagepod manager for a given |
| 599 | * adapter if needed | 624 | * adapter if needed |
| 600 | */ | 625 | */ |
| 601 | void cxgb3i_ddp_cleanup(struct t3cdev *tdev) | 626 | |
| 627 | static void ddp_cleanup(struct kref *kref) | ||
| 602 | { | 628 | { |
| 629 | struct cxgb3i_ddp_info *ddp = container_of(kref, | ||
| 630 | struct cxgb3i_ddp_info, | ||
| 631 | refcnt); | ||
| 603 | int i = 0; | 632 | int i = 0; |
| 633 | |||
| 634 | ddp_log_info("kref release ddp 0x%p, t3dev 0x%p.\n", ddp, ddp->tdev); | ||
| 635 | |||
| 636 | ddp->tdev->ulp_iscsi = NULL; | ||
| 637 | while (i < ddp->nppods) { | ||
| 638 | struct cxgb3i_gather_list *gl = ddp->gl_map[i]; | ||
| 639 | if (gl) { | ||
| 640 | int npods = (gl->nelem + PPOD_PAGES_MAX - 1) | ||
| 641 | >> PPOD_PAGES_SHIFT; | ||
| 642 | ddp_log_info("t3dev 0x%p, ddp %d + %d.\n", | ||
| 643 | ddp->tdev, i, npods); | ||
| 644 | kfree(gl); | ||
| 645 | ddp_free_gl_skb(ddp, i, npods); | ||
| 646 | i += npods; | ||
| 647 | } else | ||
| 648 | i++; | ||
| 649 | } | ||
| 650 | cxgb3i_free_big_mem(ddp); | ||
| 651 | } | ||
| 652 | |||
| 653 | void cxgb3i_ddp_cleanup(struct t3cdev *tdev) | ||
| 654 | { | ||
| 604 | struct cxgb3i_ddp_info *ddp = (struct cxgb3i_ddp_info *)tdev->ulp_iscsi; | 655 | struct cxgb3i_ddp_info *ddp = (struct cxgb3i_ddp_info *)tdev->ulp_iscsi; |
| 605 | 656 | ||
| 606 | ddp_log_info("t3dev 0x%p, release ddp 0x%p.\n", tdev, ddp); | 657 | ddp_log_info("t3dev 0x%p, release ddp 0x%p.\n", tdev, ddp); |
| 607 | 658 | if (ddp) | |
| 608 | if (ddp) { | 659 | kref_put(&ddp->refcnt, ddp_cleanup); |
| 609 | tdev->ulp_iscsi = NULL; | ||
| 610 | while (i < ddp->nppods) { | ||
| 611 | struct cxgb3i_gather_list *gl = ddp->gl_map[i]; | ||
| 612 | if (gl) { | ||
| 613 | int npods = (gl->nelem + PPOD_PAGES_MAX - 1) | ||
| 614 | >> PPOD_PAGES_SHIFT; | ||
| 615 | ddp_log_info("t3dev 0x%p, ddp %d + %d.\n", | ||
| 616 | tdev, i, npods); | ||
| 617 | kfree(gl); | ||
| 618 | ddp_free_gl_skb(ddp, i, npods); | ||
| 619 | i += npods; | ||
| 620 | } else | ||
| 621 | i++; | ||
| 622 | } | ||
| 623 | cxgb3i_free_big_mem(ddp); | ||
| 624 | } | ||
| 625 | } | 660 | } |
| 626 | 661 | ||
| 627 | /** | 662 | /** |
| @@ -631,12 +666,13 @@ void cxgb3i_ddp_cleanup(struct t3cdev *tdev) | |||
| 631 | */ | 666 | */ |
| 632 | static void ddp_init(struct t3cdev *tdev) | 667 | static void ddp_init(struct t3cdev *tdev) |
| 633 | { | 668 | { |
| 634 | struct cxgb3i_ddp_info *ddp; | 669 | struct cxgb3i_ddp_info *ddp = tdev->ulp_iscsi; |
| 635 | struct ulp_iscsi_info uinfo; | 670 | struct ulp_iscsi_info uinfo; |
| 636 | unsigned int ppmax, bits; | 671 | unsigned int ppmax, bits; |
| 637 | int i, err; | 672 | int i, err; |
| 638 | 673 | ||
| 639 | if (tdev->ulp_iscsi) { | 674 | if (ddp) { |
| 675 | kref_get(&ddp->refcnt); | ||
| 640 | ddp_log_warn("t3dev 0x%p, ddp 0x%p already set up.\n", | 676 | ddp_log_warn("t3dev 0x%p, ddp 0x%p already set up.\n", |
| 641 | tdev, tdev->ulp_iscsi); | 677 | tdev, tdev->ulp_iscsi); |
| 642 | return; | 678 | return; |
| @@ -670,6 +706,7 @@ static void ddp_init(struct t3cdev *tdev) | |||
| 670 | ppmax * | 706 | ppmax * |
| 671 | sizeof(struct cxgb3i_gather_list *)); | 707 | sizeof(struct cxgb3i_gather_list *)); |
| 672 | spin_lock_init(&ddp->map_lock); | 708 | spin_lock_init(&ddp->map_lock); |
| 709 | kref_init(&ddp->refcnt); | ||
| 673 | 710 | ||
| 674 | ddp->tdev = tdev; | 711 | ddp->tdev = tdev; |
| 675 | ddp->pdev = uinfo.pdev; | 712 | ddp->pdev = uinfo.pdev; |
| @@ -715,6 +752,17 @@ void cxgb3i_ddp_init(struct t3cdev *tdev) | |||
| 715 | { | 752 | { |
| 716 | if (page_idx == DDP_PGIDX_MAX) { | 753 | if (page_idx == DDP_PGIDX_MAX) { |
| 717 | page_idx = cxgb3i_ddp_find_page_index(PAGE_SIZE); | 754 | page_idx = cxgb3i_ddp_find_page_index(PAGE_SIZE); |
| 755 | |||
| 756 | if (page_idx == DDP_PGIDX_MAX) { | ||
| 757 | ddp_log_info("system PAGE_SIZE %lu, update hw.\n", | ||
| 758 | PAGE_SIZE); | ||
| 759 | if (cxgb3i_ddp_adjust_page_table() < 0) { | ||
| 760 | ddp_log_info("PAGE_SIZE %lu, ddp disabled.\n", | ||
| 761 | PAGE_SIZE); | ||
| 762 | return; | ||
| 763 | } | ||
| 764 | page_idx = cxgb3i_ddp_find_page_index(PAGE_SIZE); | ||
| 765 | } | ||
| 718 | ddp_log_info("system PAGE_SIZE %lu, ddp idx %u.\n", | 766 | ddp_log_info("system PAGE_SIZE %lu, ddp idx %u.\n", |
| 719 | PAGE_SIZE, page_idx); | 767 | PAGE_SIZE, page_idx); |
| 720 | } | 768 | } |
diff --git a/drivers/scsi/cxgb3i/cxgb3i_ddp.h b/drivers/scsi/cxgb3i/cxgb3i_ddp.h index 0d296de7cf32..87dd56b422bf 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_ddp.h +++ b/drivers/scsi/cxgb3i/cxgb3i_ddp.h | |||
| @@ -54,6 +54,7 @@ struct cxgb3i_gather_list { | |||
| 54 | * struct cxgb3i_ddp_info - cxgb3i direct data placement for pdu payload | 54 | * struct cxgb3i_ddp_info - cxgb3i direct data placement for pdu payload |
| 55 | * | 55 | * |
| 56 | * @list: list head to link elements | 56 | * @list: list head to link elements |
| 57 | * @refcnt: ref. count | ||
| 57 | * @tdev: pointer to t3cdev used by cxgb3 driver | 58 | * @tdev: pointer to t3cdev used by cxgb3 driver |
| 58 | * @max_txsz: max tx packet size for ddp | 59 | * @max_txsz: max tx packet size for ddp |
| 59 | * @max_rxsz: max rx packet size for ddp | 60 | * @max_rxsz: max rx packet size for ddp |
| @@ -70,6 +71,7 @@ struct cxgb3i_gather_list { | |||
| 70 | */ | 71 | */ |
| 71 | struct cxgb3i_ddp_info { | 72 | struct cxgb3i_ddp_info { |
| 72 | struct list_head list; | 73 | struct list_head list; |
| 74 | struct kref refcnt; | ||
| 73 | struct t3cdev *tdev; | 75 | struct t3cdev *tdev; |
| 74 | struct pci_dev *pdev; | 76 | struct pci_dev *pdev; |
| 75 | unsigned int max_txsz; | 77 | unsigned int max_txsz; |
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index c15878e88157..0a5609bb5817 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c | |||
| @@ -45,8 +45,6 @@ | |||
| 45 | 45 | ||
| 46 | #include "fcoe.h" | 46 | #include "fcoe.h" |
| 47 | 47 | ||
| 48 | static int debug_fcoe; | ||
| 49 | |||
| 50 | MODULE_AUTHOR("Open-FCoE.org"); | 48 | MODULE_AUTHOR("Open-FCoE.org"); |
| 51 | MODULE_DESCRIPTION("FCoE"); | 49 | MODULE_DESCRIPTION("FCoE"); |
| 52 | MODULE_LICENSE("GPL v2"); | 50 | MODULE_LICENSE("GPL v2"); |
| @@ -305,23 +303,22 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) | |||
| 305 | #ifdef NETIF_F_FCOE_CRC | 303 | #ifdef NETIF_F_FCOE_CRC |
| 306 | if (netdev->features & NETIF_F_FCOE_CRC) { | 304 | if (netdev->features & NETIF_F_FCOE_CRC) { |
| 307 | lp->crc_offload = 1; | 305 | lp->crc_offload = 1; |
| 308 | printk(KERN_DEBUG "fcoe:%s supports FCCRC offload\n", | 306 | FCOE_NETDEV_DBG(netdev, "Supports FCCRC offload\n"); |
| 309 | netdev->name); | ||
| 310 | } | 307 | } |
| 311 | #endif | 308 | #endif |
| 312 | #ifdef NETIF_F_FSO | 309 | #ifdef NETIF_F_FSO |
| 313 | if (netdev->features & NETIF_F_FSO) { | 310 | if (netdev->features & NETIF_F_FSO) { |
| 314 | lp->seq_offload = 1; | 311 | lp->seq_offload = 1; |
| 315 | lp->lso_max = netdev->gso_max_size; | 312 | lp->lso_max = netdev->gso_max_size; |
| 316 | printk(KERN_DEBUG "fcoe:%s supports LSO for max len 0x%x\n", | 313 | FCOE_NETDEV_DBG(netdev, "Supports LSO for max len 0x%x\n", |
| 317 | netdev->name, lp->lso_max); | 314 | lp->lso_max); |
| 318 | } | 315 | } |
| 319 | #endif | 316 | #endif |
| 320 | if (netdev->fcoe_ddp_xid) { | 317 | if (netdev->fcoe_ddp_xid) { |
| 321 | lp->lro_enabled = 1; | 318 | lp->lro_enabled = 1; |
| 322 | lp->lro_xid = netdev->fcoe_ddp_xid; | 319 | lp->lro_xid = netdev->fcoe_ddp_xid; |
| 323 | printk(KERN_DEBUG "fcoe:%s supports LRO for max xid 0x%x\n", | 320 | FCOE_NETDEV_DBG(netdev, "Supports LRO for max xid 0x%x\n", |
| 324 | netdev->name, lp->lro_xid); | 321 | lp->lro_xid); |
| 325 | } | 322 | } |
| 326 | skb_queue_head_init(&fc->fcoe_pending_queue); | 323 | skb_queue_head_init(&fc->fcoe_pending_queue); |
| 327 | fc->fcoe_pending_queue_active = 0; | 324 | fc->fcoe_pending_queue_active = 0; |
| @@ -407,7 +404,8 @@ static int fcoe_shost_config(struct fc_lport *lp, struct Scsi_Host *shost, | |||
| 407 | /* add the new host to the SCSI-ml */ | 404 | /* add the new host to the SCSI-ml */ |
| 408 | rc = scsi_add_host(lp->host, dev); | 405 | rc = scsi_add_host(lp->host, dev); |
| 409 | if (rc) { | 406 | if (rc) { |
| 410 | FC_DBG("fcoe_shost_config:error on scsi_add_host\n"); | 407 | FCOE_NETDEV_DBG(fcoe_netdev(lp), "fcoe_shost_config: " |
| 408 | "error on scsi_add_host\n"); | ||
| 411 | return rc; | 409 | return rc; |
| 412 | } | 410 | } |
| 413 | sprintf(fc_host_symbolic_name(lp->host), "%s v%s over %s", | 411 | sprintf(fc_host_symbolic_name(lp->host), "%s v%s over %s", |
| @@ -448,8 +446,7 @@ static int fcoe_if_destroy(struct net_device *netdev) | |||
| 448 | 446 | ||
| 449 | BUG_ON(!netdev); | 447 | BUG_ON(!netdev); |
| 450 | 448 | ||
| 451 | printk(KERN_DEBUG "fcoe_if_destroy:interface on %s\n", | 449 | FCOE_NETDEV_DBG(netdev, "Destroying interface\n"); |
| 452 | netdev->name); | ||
| 453 | 450 | ||
| 454 | lp = fcoe_hostlist_lookup(netdev); | 451 | lp = fcoe_hostlist_lookup(netdev); |
| 455 | if (!lp) | 452 | if (!lp) |
| @@ -560,8 +557,7 @@ static int fcoe_if_create(struct net_device *netdev) | |||
| 560 | 557 | ||
| 561 | BUG_ON(!netdev); | 558 | BUG_ON(!netdev); |
| 562 | 559 | ||
| 563 | printk(KERN_DEBUG "fcoe_if_create:interface on %s\n", | 560 | FCOE_NETDEV_DBG(netdev, "Create Interface\n"); |
| 564 | netdev->name); | ||
| 565 | 561 | ||
| 566 | lp = fcoe_hostlist_lookup(netdev); | 562 | lp = fcoe_hostlist_lookup(netdev); |
| 567 | if (lp) | 563 | if (lp) |
| @@ -570,7 +566,7 @@ static int fcoe_if_create(struct net_device *netdev) | |||
| 570 | shost = libfc_host_alloc(&fcoe_shost_template, | 566 | shost = libfc_host_alloc(&fcoe_shost_template, |
| 571 | sizeof(struct fcoe_softc)); | 567 | sizeof(struct fcoe_softc)); |
| 572 | if (!shost) { | 568 | if (!shost) { |
| 573 | FC_DBG("Could not allocate host structure\n"); | 569 | FCOE_NETDEV_DBG(netdev, "Could not allocate host structure\n"); |
| 574 | return -ENOMEM; | 570 | return -ENOMEM; |
| 575 | } | 571 | } |
| 576 | lp = shost_priv(shost); | 572 | lp = shost_priv(shost); |
| @@ -579,7 +575,8 @@ static int fcoe_if_create(struct net_device *netdev) | |||
| 579 | /* configure fc_lport, e.g., em */ | 575 | /* configure fc_lport, e.g., em */ |
| 580 | rc = fcoe_lport_config(lp); | 576 | rc = fcoe_lport_config(lp); |
| 581 | if (rc) { | 577 | if (rc) { |
| 582 | FC_DBG("Could not configure lport\n"); | 578 | FCOE_NETDEV_DBG(netdev, "Could not configure lport for the " |
| 579 | "interface\n"); | ||
| 583 | goto out_host_put; | 580 | goto out_host_put; |
| 584 | } | 581 | } |
| 585 | 582 | ||
| @@ -593,28 +590,32 @@ static int fcoe_if_create(struct net_device *netdev) | |||
| 593 | /* configure lport network properties */ | 590 | /* configure lport network properties */ |
| 594 | rc = fcoe_netdev_config(lp, netdev); | 591 | rc = fcoe_netdev_config(lp, netdev); |
| 595 | if (rc) { | 592 | if (rc) { |
| 596 | FC_DBG("Could not configure netdev for the interface\n"); | 593 | FCOE_NETDEV_DBG(netdev, "Could not configure netdev for the " |
| 594 | "interface\n"); | ||
| 597 | goto out_netdev_cleanup; | 595 | goto out_netdev_cleanup; |
| 598 | } | 596 | } |
| 599 | 597 | ||
| 600 | /* configure lport scsi host properties */ | 598 | /* configure lport scsi host properties */ |
| 601 | rc = fcoe_shost_config(lp, shost, &netdev->dev); | 599 | rc = fcoe_shost_config(lp, shost, &netdev->dev); |
| 602 | if (rc) { | 600 | if (rc) { |
| 603 | FC_DBG("Could not configure shost for lport\n"); | 601 | FCOE_NETDEV_DBG(netdev, "Could not configure shost for the " |
| 602 | "interface\n"); | ||
| 604 | goto out_netdev_cleanup; | 603 | goto out_netdev_cleanup; |
| 605 | } | 604 | } |
| 606 | 605 | ||
| 607 | /* lport exch manager allocation */ | 606 | /* lport exch manager allocation */ |
| 608 | rc = fcoe_em_config(lp); | 607 | rc = fcoe_em_config(lp); |
| 609 | if (rc) { | 608 | if (rc) { |
| 610 | FC_DBG("Could not configure em for lport\n"); | 609 | FCOE_NETDEV_DBG(netdev, "Could not configure the EM for the " |
| 610 | "interface\n"); | ||
| 611 | goto out_netdev_cleanup; | 611 | goto out_netdev_cleanup; |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | /* Initialize the library */ | 614 | /* Initialize the library */ |
| 615 | rc = fcoe_libfc_config(lp, &fcoe_libfc_fcn_templ); | 615 | rc = fcoe_libfc_config(lp, &fcoe_libfc_fcn_templ); |
| 616 | if (rc) { | 616 | if (rc) { |
| 617 | FC_DBG("Could not configure libfc for lport!\n"); | 617 | FCOE_NETDEV_DBG(netdev, "Could not configure libfc for the " |
| 618 | "interface\n"); | ||
| 618 | goto out_lp_destroy; | 619 | goto out_lp_destroy; |
| 619 | } | 620 | } |
| 620 | 621 | ||
| @@ -653,7 +654,7 @@ static int __init fcoe_if_init(void) | |||
| 653 | fc_attach_transport(&fcoe_transport_function); | 654 | fc_attach_transport(&fcoe_transport_function); |
| 654 | 655 | ||
| 655 | if (!scsi_transport_fcoe_sw) { | 656 | if (!scsi_transport_fcoe_sw) { |
| 656 | printk(KERN_ERR "fcoe_init:fc_attach_transport() failed\n"); | 657 | printk(KERN_ERR "fcoe: Failed to attach to the FC transport\n"); |
| 657 | return -ENODEV; | 658 | return -ENODEV; |
| 658 | } | 659 | } |
| 659 | 660 | ||
| @@ -714,7 +715,7 @@ static void fcoe_percpu_thread_destroy(unsigned int cpu) | |||
| 714 | unsigned targ_cpu = smp_processor_id(); | 715 | unsigned targ_cpu = smp_processor_id(); |
| 715 | #endif /* CONFIG_SMP */ | 716 | #endif /* CONFIG_SMP */ |
| 716 | 717 | ||
| 717 | printk(KERN_DEBUG "fcoe: Destroying receive thread for CPU %d\n", cpu); | 718 | FCOE_DBG("Destroying receive thread for CPU %d\n", cpu); |
| 718 | 719 | ||
| 719 | /* Prevent any new skbs from being queued for this CPU. */ | 720 | /* Prevent any new skbs from being queued for this CPU. */ |
| 720 | p = &per_cpu(fcoe_percpu, cpu); | 721 | p = &per_cpu(fcoe_percpu, cpu); |
| @@ -736,8 +737,8 @@ static void fcoe_percpu_thread_destroy(unsigned int cpu) | |||
| 736 | p0 = &per_cpu(fcoe_percpu, targ_cpu); | 737 | p0 = &per_cpu(fcoe_percpu, targ_cpu); |
| 737 | spin_lock_bh(&p0->fcoe_rx_list.lock); | 738 | spin_lock_bh(&p0->fcoe_rx_list.lock); |
| 738 | if (p0->thread) { | 739 | if (p0->thread) { |
| 739 | FC_DBG("Moving frames from CPU %d to CPU %d\n", | 740 | FCOE_DBG("Moving frames from CPU %d to CPU %d\n", |
| 740 | cpu, targ_cpu); | 741 | cpu, targ_cpu); |
| 741 | 742 | ||
| 742 | while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL) | 743 | while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL) |
| 743 | __skb_queue_tail(&p0->fcoe_rx_list, skb); | 744 | __skb_queue_tail(&p0->fcoe_rx_list, skb); |
| @@ -803,12 +804,12 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, | |||
| 803 | switch (action) { | 804 | switch (action) { |
| 804 | case CPU_ONLINE: | 805 | case CPU_ONLINE: |
| 805 | case CPU_ONLINE_FROZEN: | 806 | case CPU_ONLINE_FROZEN: |
| 806 | FC_DBG("CPU %x online: Create Rx thread\n", cpu); | 807 | FCOE_DBG("CPU %x online: Create Rx thread\n", cpu); |
| 807 | fcoe_percpu_thread_create(cpu); | 808 | fcoe_percpu_thread_create(cpu); |
| 808 | break; | 809 | break; |
| 809 | case CPU_DEAD: | 810 | case CPU_DEAD: |
| 810 | case CPU_DEAD_FROZEN: | 811 | case CPU_DEAD_FROZEN: |
| 811 | FC_DBG("CPU %x offline: Remove Rx thread\n", cpu); | 812 | FCOE_DBG("CPU %x offline: Remove Rx thread\n", cpu); |
| 812 | fcoe_percpu_thread_destroy(cpu); | 813 | fcoe_percpu_thread_destroy(cpu); |
| 813 | break; | 814 | break; |
| 814 | default: | 815 | default: |
| @@ -846,24 +847,21 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 846 | fc = container_of(ptype, struct fcoe_softc, fcoe_packet_type); | 847 | fc = container_of(ptype, struct fcoe_softc, fcoe_packet_type); |
| 847 | lp = fc->ctlr.lp; | 848 | lp = fc->ctlr.lp; |
| 848 | if (unlikely(lp == NULL)) { | 849 | if (unlikely(lp == NULL)) { |
| 849 | FC_DBG("cannot find hba structure"); | 850 | FCOE_NETDEV_DBG(dev, "Cannot find hba structure"); |
| 850 | goto err2; | 851 | goto err2; |
| 851 | } | 852 | } |
| 852 | if (!lp->link_up) | 853 | if (!lp->link_up) |
| 853 | goto err2; | 854 | goto err2; |
| 854 | 855 | ||
| 855 | if (unlikely(debug_fcoe)) { | 856 | FCOE_NETDEV_DBG(dev, "skb_info: len:%d data_len:%d head:%p " |
| 856 | FC_DBG("skb_info: len:%d data_len:%d head:%p data:%p tail:%p " | 857 | "data:%p tail:%p end:%p sum:%d dev:%s", |
| 857 | "end:%p sum:%d dev:%s", skb->len, skb->data_len, | 858 | skb->len, skb->data_len, skb->head, skb->data, |
| 858 | skb->head, skb->data, skb_tail_pointer(skb), | 859 | skb_tail_pointer(skb), skb_end_pointer(skb), |
| 859 | skb_end_pointer(skb), skb->csum, | 860 | skb->csum, skb->dev ? skb->dev->name : "<NULL>"); |
| 860 | skb->dev ? skb->dev->name : "<NULL>"); | ||
| 861 | |||
| 862 | } | ||
| 863 | 861 | ||
| 864 | /* check for FCOE packet type */ | 862 | /* check for FCOE packet type */ |
| 865 | if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) { | 863 | if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) { |
| 866 | FC_DBG("wrong FC type frame"); | 864 | FCOE_NETDEV_DBG(dev, "Wrong FC type frame"); |
| 867 | goto err; | 865 | goto err; |
| 868 | } | 866 | } |
| 869 | 867 | ||
| @@ -901,8 +899,9 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 901 | * the first CPU now. For non-SMP systems this | 899 | * the first CPU now. For non-SMP systems this |
| 902 | * will check the same CPU twice. | 900 | * will check the same CPU twice. |
| 903 | */ | 901 | */ |
| 904 | FC_DBG("CPU is online, but no receive thread ready " | 902 | FCOE_NETDEV_DBG(dev, "CPU is online, but no receive thread " |
| 905 | "for incoming skb- using first online CPU.\n"); | 903 | "ready for incoming skb- using first online " |
| 904 | "CPU.\n"); | ||
| 906 | 905 | ||
| 907 | spin_unlock_bh(&fps->fcoe_rx_list.lock); | 906 | spin_unlock_bh(&fps->fcoe_rx_list.lock); |
| 908 | cpu = first_cpu(cpu_online_map); | 907 | cpu = first_cpu(cpu_online_map); |
| @@ -1201,19 +1200,17 @@ int fcoe_percpu_receive_thread(void *arg) | |||
| 1201 | fr = fcoe_dev_from_skb(skb); | 1200 | fr = fcoe_dev_from_skb(skb); |
| 1202 | lp = fr->fr_dev; | 1201 | lp = fr->fr_dev; |
| 1203 | if (unlikely(lp == NULL)) { | 1202 | if (unlikely(lp == NULL)) { |
| 1204 | FC_DBG("invalid HBA Structure"); | 1203 | FCOE_NETDEV_DBG(skb->dev, "Invalid HBA Structure"); |
| 1205 | kfree_skb(skb); | 1204 | kfree_skb(skb); |
| 1206 | continue; | 1205 | continue; |
| 1207 | } | 1206 | } |
| 1208 | 1207 | ||
| 1209 | if (unlikely(debug_fcoe)) { | 1208 | FCOE_NETDEV_DBG(skb->dev, "skb_info: len:%d data_len:%d " |
| 1210 | FC_DBG("skb_info: len:%d data_len:%d head:%p data:%p " | 1209 | "head:%p data:%p tail:%p end:%p sum:%d dev:%s", |
| 1211 | "tail:%p end:%p sum:%d dev:%s", | 1210 | skb->len, skb->data_len, |
| 1212 | skb->len, skb->data_len, | 1211 | skb->head, skb->data, skb_tail_pointer(skb), |
| 1213 | skb->head, skb->data, skb_tail_pointer(skb), | 1212 | skb_end_pointer(skb), skb->csum, |
| 1214 | skb_end_pointer(skb), skb->csum, | 1213 | skb->dev ? skb->dev->name : "<NULL>"); |
| 1215 | skb->dev ? skb->dev->name : "<NULL>"); | ||
| 1216 | } | ||
| 1217 | 1214 | ||
| 1218 | /* | 1215 | /* |
| 1219 | * Save source MAC address before discarding header. | 1216 | * Save source MAC address before discarding header. |
| @@ -1233,7 +1230,7 @@ int fcoe_percpu_receive_thread(void *arg) | |||
| 1233 | stats = fc_lport_get_stats(lp); | 1230 | stats = fc_lport_get_stats(lp); |
| 1234 | if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) { | 1231 | if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) { |
| 1235 | if (stats->ErrorFrames < 5) | 1232 | if (stats->ErrorFrames < 5) |
| 1236 | printk(KERN_WARNING "FCoE version " | 1233 | printk(KERN_WARNING "fcoe: FCoE version " |
| 1237 | "mismatch: The frame has " | 1234 | "mismatch: The frame has " |
| 1238 | "version %x, but the " | 1235 | "version %x, but the " |
| 1239 | "initiator supports version " | 1236 | "initiator supports version " |
| @@ -1286,7 +1283,7 @@ int fcoe_percpu_receive_thread(void *arg) | |||
| 1286 | if (fr_flags(fp) & FCPHF_CRC_UNCHECKED) { | 1283 | if (fr_flags(fp) & FCPHF_CRC_UNCHECKED) { |
| 1287 | if (le32_to_cpu(fr_crc(fp)) != | 1284 | if (le32_to_cpu(fr_crc(fp)) != |
| 1288 | ~crc32(~0, skb->data, fr_len)) { | 1285 | ~crc32(~0, skb->data, fr_len)) { |
| 1289 | if (debug_fcoe || stats->InvalidCRCCount < 5) | 1286 | if (stats->InvalidCRCCount < 5) |
| 1290 | printk(KERN_WARNING "fcoe: dropping " | 1287 | printk(KERN_WARNING "fcoe: dropping " |
| 1291 | "frame with CRC error\n"); | 1288 | "frame with CRC error\n"); |
| 1292 | stats->InvalidCRCCount++; | 1289 | stats->InvalidCRCCount++; |
| @@ -1432,7 +1429,8 @@ static int fcoe_device_notification(struct notifier_block *notifier, | |||
| 1432 | case NETDEV_REGISTER: | 1429 | case NETDEV_REGISTER: |
| 1433 | break; | 1430 | break; |
| 1434 | default: | 1431 | default: |
| 1435 | FC_DBG("Unknown event %ld from netdev netlink\n", event); | 1432 | FCOE_NETDEV_DBG(real_dev, "Unknown event %ld " |
| 1433 | "from netdev netlink\n", event); | ||
| 1436 | } | 1434 | } |
| 1437 | if (link_possible && !fcoe_link_ok(lp)) | 1435 | if (link_possible && !fcoe_link_ok(lp)) |
| 1438 | fcoe_ctlr_link_up(&fc->ctlr); | 1436 | fcoe_ctlr_link_up(&fc->ctlr); |
| @@ -1505,8 +1503,8 @@ static int fcoe_ethdrv_get(const struct net_device *netdev) | |||
| 1505 | 1503 | ||
| 1506 | owner = fcoe_netdev_to_module_owner(netdev); | 1504 | owner = fcoe_netdev_to_module_owner(netdev); |
| 1507 | if (owner) { | 1505 | if (owner) { |
| 1508 | printk(KERN_DEBUG "fcoe:hold driver module %s for %s\n", | 1506 | FCOE_NETDEV_DBG(netdev, "Hold driver module %s\n", |
| 1509 | module_name(owner), netdev->name); | 1507 | module_name(owner)); |
| 1510 | return try_module_get(owner); | 1508 | return try_module_get(owner); |
| 1511 | } | 1509 | } |
| 1512 | return -ENODEV; | 1510 | return -ENODEV; |
| @@ -1527,8 +1525,8 @@ static int fcoe_ethdrv_put(const struct net_device *netdev) | |||
| 1527 | 1525 | ||
| 1528 | owner = fcoe_netdev_to_module_owner(netdev); | 1526 | owner = fcoe_netdev_to_module_owner(netdev); |
| 1529 | if (owner) { | 1527 | if (owner) { |
| 1530 | printk(KERN_DEBUG "fcoe:release driver module %s for %s\n", | 1528 | FCOE_NETDEV_DBG(netdev, "Release driver module %s\n", |
| 1531 | module_name(owner), netdev->name); | 1529 | module_name(owner)); |
| 1532 | module_put(owner); | 1530 | module_put(owner); |
| 1533 | return 0; | 1531 | return 0; |
| 1534 | } | 1532 | } |
| @@ -1559,7 +1557,7 @@ static int fcoe_destroy(const char *buffer, struct kernel_param *kp) | |||
| 1559 | } | 1557 | } |
| 1560 | rc = fcoe_if_destroy(netdev); | 1558 | rc = fcoe_if_destroy(netdev); |
| 1561 | if (rc) { | 1559 | if (rc) { |
| 1562 | printk(KERN_ERR "fcoe: fcoe_if_destroy(%s) failed\n", | 1560 | printk(KERN_ERR "fcoe: Failed to destroy interface (%s)\n", |
| 1563 | netdev->name); | 1561 | netdev->name); |
| 1564 | rc = -EIO; | 1562 | rc = -EIO; |
| 1565 | goto out_putdev; | 1563 | goto out_putdev; |
| @@ -1598,7 +1596,7 @@ static int fcoe_create(const char *buffer, struct kernel_param *kp) | |||
| 1598 | 1596 | ||
| 1599 | rc = fcoe_if_create(netdev); | 1597 | rc = fcoe_if_create(netdev); |
| 1600 | if (rc) { | 1598 | if (rc) { |
| 1601 | printk(KERN_ERR "fcoe: fcoe_if_create(%s) failed\n", | 1599 | printk(KERN_ERR "fcoe: Failed to create interface (%s)\n", |
| 1602 | netdev->name); | 1600 | netdev->name); |
| 1603 | fcoe_ethdrv_put(netdev); | 1601 | fcoe_ethdrv_put(netdev); |
| 1604 | rc = -EIO; | 1602 | rc = -EIO; |
diff --git a/drivers/scsi/fcoe/fcoe.h b/drivers/scsi/fcoe/fcoe.h index a1eb8c1988b0..0d724fa0898f 100644 --- a/drivers/scsi/fcoe/fcoe.h +++ b/drivers/scsi/fcoe/fcoe.h | |||
| @@ -40,6 +40,30 @@ | |||
| 40 | #define FCOE_MIN_XID 0x0001 /* the min xid supported by fcoe_sw */ | 40 | #define FCOE_MIN_XID 0x0001 /* the min xid supported by fcoe_sw */ |
| 41 | #define FCOE_MAX_XID 0x07ef /* the max xid supported by fcoe_sw */ | 41 | #define FCOE_MAX_XID 0x07ef /* the max xid supported by fcoe_sw */ |
| 42 | 42 | ||
| 43 | unsigned int fcoe_debug_logging; | ||
| 44 | module_param_named(debug_logging, fcoe_debug_logging, int, S_IRUGO|S_IWUSR); | ||
| 45 | MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels"); | ||
| 46 | |||
| 47 | #define FCOE_LOGGING 0x01 /* General logging, not categorized */ | ||
| 48 | #define FCOE_NETDEV_LOGGING 0x02 /* Netdevice logging */ | ||
| 49 | |||
| 50 | #define FCOE_CHECK_LOGGING(LEVEL, CMD) \ | ||
| 51 | do { \ | ||
| 52 | if (unlikely(fcoe_debug_logging & LEVEL)) \ | ||
| 53 | do { \ | ||
| 54 | CMD; \ | ||
| 55 | } while (0); \ | ||
| 56 | } while (0); | ||
| 57 | |||
| 58 | #define FCOE_DBG(fmt, args...) \ | ||
| 59 | FCOE_CHECK_LOGGING(FCOE_LOGGING, \ | ||
| 60 | printk(KERN_INFO "fcoe: " fmt, ##args);) | ||
| 61 | |||
| 62 | #define FCOE_NETDEV_DBG(netdev, fmt, args...) \ | ||
| 63 | FCOE_CHECK_LOGGING(FCOE_NETDEV_LOGGING, \ | ||
| 64 | printk(KERN_INFO "fcoe: %s" fmt, \ | ||
| 65 | netdev->name, ##args);) | ||
| 66 | |||
| 43 | /* | 67 | /* |
| 44 | * this percpu struct for fcoe | 68 | * this percpu struct for fcoe |
| 45 | */ | 69 | */ |
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c index 2f5bc7fd3fa9..f544340d318b 100644 --- a/drivers/scsi/fcoe/libfcoe.c +++ b/drivers/scsi/fcoe/libfcoe.c | |||
| @@ -56,15 +56,28 @@ static void fcoe_ctlr_recv_work(struct work_struct *); | |||
| 56 | 56 | ||
| 57 | static u8 fcoe_all_fcfs[ETH_ALEN] = FIP_ALL_FCF_MACS; | 57 | static u8 fcoe_all_fcfs[ETH_ALEN] = FIP_ALL_FCF_MACS; |
| 58 | 58 | ||
| 59 | static u32 fcoe_ctlr_debug; /* 1 for basic, 2 for noisy debug */ | 59 | unsigned int libfcoe_debug_logging; |
| 60 | module_param_named(debug_logging, libfcoe_debug_logging, int, S_IRUGO|S_IWUSR); | ||
| 61 | MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels"); | ||
| 60 | 62 | ||
| 61 | #define FIP_DBG_LVL(level, fmt, args...) \ | 63 | #define LIBFCOE_LOGGING 0x01 /* General logging, not categorized */ |
| 64 | #define LIBFCOE_FIP_LOGGING 0x02 /* FIP logging */ | ||
| 65 | |||
| 66 | #define LIBFCOE_CHECK_LOGGING(LEVEL, CMD) \ | ||
| 67 | do { \ | ||
| 68 | if (unlikely(libfcoe_debug_logging & LEVEL)) \ | ||
| 62 | do { \ | 69 | do { \ |
| 63 | if (fcoe_ctlr_debug >= (level)) \ | 70 | CMD; \ |
| 64 | FC_DBG(fmt, ##args); \ | 71 | } while (0); \ |
| 65 | } while (0) | 72 | } while (0); |
| 73 | |||
| 74 | #define LIBFCOE_DBG(fmt, args...) \ | ||
| 75 | LIBFCOE_CHECK_LOGGING(LIBFCOE_LOGGING, \ | ||
| 76 | printk(KERN_INFO "libfcoe: " fmt, ##args);) | ||
| 66 | 77 | ||
| 67 | #define FIP_DBG(fmt, args...) FIP_DBG_LVL(1, fmt, ##args) | 78 | #define LIBFCOE_FIP_DBG(fmt, args...) \ |
| 79 | LIBFCOE_CHECK_LOGGING(LIBFCOE_FIP_LOGGING, \ | ||
| 80 | printk(KERN_INFO "fip: " fmt, ##args);) | ||
| 68 | 81 | ||
| 69 | /* | 82 | /* |
| 70 | * Return non-zero if FCF fcoe_size has been validated. | 83 | * Return non-zero if FCF fcoe_size has been validated. |
| @@ -243,7 +256,7 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip) | |||
| 243 | fip->last_link = 1; | 256 | fip->last_link = 1; |
| 244 | fip->link = 1; | 257 | fip->link = 1; |
| 245 | spin_unlock_bh(&fip->lock); | 258 | spin_unlock_bh(&fip->lock); |
| 246 | FIP_DBG("%s", "setting AUTO mode.\n"); | 259 | LIBFCOE_FIP_DBG("%s", "setting AUTO mode.\n"); |
| 247 | fc_linkup(fip->lp); | 260 | fc_linkup(fip->lp); |
| 248 | fcoe_ctlr_solicit(fip, NULL); | 261 | fcoe_ctlr_solicit(fip, NULL); |
| 249 | } else | 262 | } else |
| @@ -614,7 +627,8 @@ static int fcoe_ctlr_parse_adv(struct sk_buff *skb, struct fcoe_fcf *fcf) | |||
| 614 | ((struct fip_mac_desc *)desc)->fd_mac, | 627 | ((struct fip_mac_desc *)desc)->fd_mac, |
| 615 | ETH_ALEN); | 628 | ETH_ALEN); |
| 616 | if (!is_valid_ether_addr(fcf->fcf_mac)) { | 629 | if (!is_valid_ether_addr(fcf->fcf_mac)) { |
| 617 | FIP_DBG("invalid MAC addr in FIP adv\n"); | 630 | LIBFCOE_FIP_DBG("Invalid MAC address " |
| 631 | "in FIP adv\n"); | ||
| 618 | return -EINVAL; | 632 | return -EINVAL; |
| 619 | } | 633 | } |
| 620 | break; | 634 | break; |
| @@ -647,8 +661,8 @@ static int fcoe_ctlr_parse_adv(struct sk_buff *skb, struct fcoe_fcf *fcf) | |||
| 647 | case FIP_DT_LOGO: | 661 | case FIP_DT_LOGO: |
| 648 | case FIP_DT_ELP: | 662 | case FIP_DT_ELP: |
| 649 | default: | 663 | default: |
| 650 | FIP_DBG("unexpected descriptor type %x in FIP adv\n", | 664 | LIBFCOE_FIP_DBG("unexpected descriptor type %x " |
| 651 | desc->fip_dtype); | 665 | "in FIP adv\n", desc->fip_dtype); |
| 652 | /* standard says ignore unknown descriptors >= 128 */ | 666 | /* standard says ignore unknown descriptors >= 128 */ |
| 653 | if (desc->fip_dtype < FIP_DT_VENDOR_BASE) | 667 | if (desc->fip_dtype < FIP_DT_VENDOR_BASE) |
| 654 | return -EINVAL; | 668 | return -EINVAL; |
| @@ -664,8 +678,8 @@ static int fcoe_ctlr_parse_adv(struct sk_buff *skb, struct fcoe_fcf *fcf) | |||
| 664 | return 0; | 678 | return 0; |
| 665 | 679 | ||
| 666 | len_err: | 680 | len_err: |
| 667 | FIP_DBG("FIP length error in descriptor type %x len %zu\n", | 681 | LIBFCOE_FIP_DBG("FIP length error in descriptor type %x len %zu\n", |
| 668 | desc->fip_dtype, dlen); | 682 | desc->fip_dtype, dlen); |
| 669 | return -EINVAL; | 683 | return -EINVAL; |
| 670 | } | 684 | } |
| 671 | 685 | ||
| @@ -728,9 +742,10 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb) | |||
| 728 | } | 742 | } |
| 729 | mtu_valid = fcoe_ctlr_mtu_valid(fcf); | 743 | mtu_valid = fcoe_ctlr_mtu_valid(fcf); |
| 730 | fcf->time = jiffies; | 744 | fcf->time = jiffies; |
| 731 | FIP_DBG_LVL(found ? 2 : 1, "%s FCF for fab %llx map %x val %d\n", | 745 | if (!found) { |
| 732 | found ? "old" : "new", | 746 | LIBFCOE_FIP_DBG("New FCF for fab %llx map %x val %d\n", |
| 733 | fcf->fabric_name, fcf->fc_map, mtu_valid); | 747 | fcf->fabric_name, fcf->fc_map, mtu_valid); |
| 748 | } | ||
| 734 | 749 | ||
| 735 | /* | 750 | /* |
| 736 | * If this advertisement is not solicited and our max receive size | 751 | * If this advertisement is not solicited and our max receive size |
| @@ -807,7 +822,8 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb) | |||
| 807 | ((struct fip_mac_desc *)desc)->fd_mac, | 822 | ((struct fip_mac_desc *)desc)->fd_mac, |
| 808 | ETH_ALEN); | 823 | ETH_ALEN); |
| 809 | if (!is_valid_ether_addr(granted_mac)) { | 824 | if (!is_valid_ether_addr(granted_mac)) { |
| 810 | FIP_DBG("invalid MAC addrs in FIP ELS\n"); | 825 | LIBFCOE_FIP_DBG("Invalid MAC address " |
| 826 | "in FIP ELS\n"); | ||
| 811 | goto drop; | 827 | goto drop; |
| 812 | } | 828 | } |
| 813 | break; | 829 | break; |
| @@ -825,8 +841,8 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb) | |||
| 825 | els_dtype = desc->fip_dtype; | 841 | els_dtype = desc->fip_dtype; |
| 826 | break; | 842 | break; |
| 827 | default: | 843 | default: |
| 828 | FIP_DBG("unexpected descriptor type %x " | 844 | LIBFCOE_FIP_DBG("unexpected descriptor type %x " |
| 829 | "in FIP adv\n", desc->fip_dtype); | 845 | "in FIP adv\n", desc->fip_dtype); |
| 830 | /* standard says ignore unknown descriptors >= 128 */ | 846 | /* standard says ignore unknown descriptors >= 128 */ |
| 831 | if (desc->fip_dtype < FIP_DT_VENDOR_BASE) | 847 | if (desc->fip_dtype < FIP_DT_VENDOR_BASE) |
| 832 | goto drop; | 848 | goto drop; |
| @@ -867,8 +883,8 @@ static void fcoe_ctlr_recv_els(struct fcoe_ctlr *fip, struct sk_buff *skb) | |||
| 867 | return; | 883 | return; |
| 868 | 884 | ||
| 869 | len_err: | 885 | len_err: |
| 870 | FIP_DBG("FIP length error in descriptor type %x len %zu\n", | 886 | LIBFCOE_FIP_DBG("FIP length error in descriptor type %x len %zu\n", |
| 871 | desc->fip_dtype, dlen); | 887 | desc->fip_dtype, dlen); |
| 872 | drop: | 888 | drop: |
| 873 | kfree_skb(skb); | 889 | kfree_skb(skb); |
| 874 | } | 890 | } |
| @@ -894,7 +910,7 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, | |||
| 894 | struct fc_lport *lp = fip->lp; | 910 | struct fc_lport *lp = fip->lp; |
| 895 | u32 desc_mask; | 911 | u32 desc_mask; |
| 896 | 912 | ||
| 897 | FIP_DBG("Clear Virtual Link received\n"); | 913 | LIBFCOE_FIP_DBG("Clear Virtual Link received\n"); |
| 898 | if (!fcf) | 914 | if (!fcf) |
| 899 | return; | 915 | return; |
| 900 | if (!fcf || !fc_host_port_id(lp->host)) | 916 | if (!fcf || !fc_host_port_id(lp->host)) |
| @@ -952,9 +968,9 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, | |||
| 952 | * reset only if all required descriptors were present and valid. | 968 | * reset only if all required descriptors were present and valid. |
| 953 | */ | 969 | */ |
| 954 | if (desc_mask) { | 970 | if (desc_mask) { |
| 955 | FIP_DBG("missing descriptors mask %x\n", desc_mask); | 971 | LIBFCOE_FIP_DBG("missing descriptors mask %x\n", desc_mask); |
| 956 | } else { | 972 | } else { |
| 957 | FIP_DBG("performing Clear Virtual Link\n"); | 973 | LIBFCOE_FIP_DBG("performing Clear Virtual Link\n"); |
| 958 | fcoe_ctlr_reset(fip, FIP_ST_ENABLED); | 974 | fcoe_ctlr_reset(fip, FIP_ST_ENABLED); |
| 959 | } | 975 | } |
| 960 | } | 976 | } |
| @@ -1002,10 +1018,6 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, struct sk_buff *skb) | |||
| 1002 | op = ntohs(fiph->fip_op); | 1018 | op = ntohs(fiph->fip_op); |
| 1003 | sub = fiph->fip_subcode; | 1019 | sub = fiph->fip_subcode; |
| 1004 | 1020 | ||
| 1005 | FIP_DBG_LVL(2, "ver %x op %x/%x dl %x fl %x\n", | ||
| 1006 | FIP_VER_DECAPS(fiph->fip_ver), op, sub, | ||
| 1007 | ntohs(fiph->fip_dl_len), ntohs(fiph->fip_flags)); | ||
| 1008 | |||
| 1009 | if (FIP_VER_DECAPS(fiph->fip_ver) != FIP_VER) | 1021 | if (FIP_VER_DECAPS(fiph->fip_ver) != FIP_VER) |
| 1010 | goto drop; | 1022 | goto drop; |
| 1011 | if (ntohs(fiph->fip_dl_len) * FIP_BPW + sizeof(*fiph) > skb->len) | 1023 | if (ntohs(fiph->fip_dl_len) * FIP_BPW + sizeof(*fiph) > skb->len) |
| @@ -1017,7 +1029,7 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, struct sk_buff *skb) | |||
| 1017 | fip->map_dest = 0; | 1029 | fip->map_dest = 0; |
| 1018 | fip->state = FIP_ST_ENABLED; | 1030 | fip->state = FIP_ST_ENABLED; |
| 1019 | state = FIP_ST_ENABLED; | 1031 | state = FIP_ST_ENABLED; |
| 1020 | FIP_DBG("using FIP mode\n"); | 1032 | LIBFCOE_FIP_DBG("Using FIP mode\n"); |
| 1021 | } | 1033 | } |
| 1022 | spin_unlock_bh(&fip->lock); | 1034 | spin_unlock_bh(&fip->lock); |
| 1023 | if (state != FIP_ST_ENABLED) | 1035 | if (state != FIP_ST_ENABLED) |
| @@ -1052,14 +1064,15 @@ static void fcoe_ctlr_select(struct fcoe_ctlr *fip) | |||
| 1052 | struct fcoe_fcf *best = NULL; | 1064 | struct fcoe_fcf *best = NULL; |
| 1053 | 1065 | ||
| 1054 | list_for_each_entry(fcf, &fip->fcfs, list) { | 1066 | list_for_each_entry(fcf, &fip->fcfs, list) { |
| 1055 | FIP_DBG("consider FCF for fab %llx VFID %d map %x val %d\n", | 1067 | LIBFCOE_FIP_DBG("consider FCF for fab %llx VFID %d map %x " |
| 1056 | fcf->fabric_name, fcf->vfid, | 1068 | "val %d\n", fcf->fabric_name, fcf->vfid, |
| 1057 | fcf->fc_map, fcoe_ctlr_mtu_valid(fcf)); | 1069 | fcf->fc_map, fcoe_ctlr_mtu_valid(fcf)); |
| 1058 | if (!fcoe_ctlr_fcf_usable(fcf)) { | 1070 | if (!fcoe_ctlr_fcf_usable(fcf)) { |
| 1059 | FIP_DBG("FCF for fab %llx map %x %svalid %savailable\n", | 1071 | LIBFCOE_FIP_DBG("FCF for fab %llx map %x %svalid " |
| 1060 | fcf->fabric_name, fcf->fc_map, | 1072 | "%savailable\n", fcf->fabric_name, |
| 1061 | (fcf->flags & FIP_FL_SOL) ? "" : "in", | 1073 | fcf->fc_map, (fcf->flags & FIP_FL_SOL) |
| 1062 | (fcf->flags & FIP_FL_AVAIL) ? "" : "un"); | 1074 | ? "" : "in", (fcf->flags & FIP_FL_AVAIL) |
| 1075 | ? "" : "un"); | ||
| 1063 | continue; | 1076 | continue; |
| 1064 | } | 1077 | } |
| 1065 | if (!best) { | 1078 | if (!best) { |
| @@ -1069,7 +1082,8 @@ static void fcoe_ctlr_select(struct fcoe_ctlr *fip) | |||
| 1069 | if (fcf->fabric_name != best->fabric_name || | 1082 | if (fcf->fabric_name != best->fabric_name || |
| 1070 | fcf->vfid != best->vfid || | 1083 | fcf->vfid != best->vfid || |
| 1071 | fcf->fc_map != best->fc_map) { | 1084 | fcf->fc_map != best->fc_map) { |
| 1072 | FIP_DBG("conflicting fabric, VFID, or FC-MAP\n"); | 1085 | LIBFCOE_FIP_DBG("Conflicting fabric, VFID, " |
| 1086 | "or FC-MAP\n"); | ||
| 1073 | return; | 1087 | return; |
| 1074 | } | 1088 | } |
| 1075 | if (fcf->pri < best->pri) | 1089 | if (fcf->pri < best->pri) |
| @@ -1113,7 +1127,7 @@ static void fcoe_ctlr_timeout(unsigned long arg) | |||
| 1113 | if (sel != fcf) { | 1127 | if (sel != fcf) { |
| 1114 | fcf = sel; /* the old FCF may have been freed */ | 1128 | fcf = sel; /* the old FCF may have been freed */ |
| 1115 | if (sel) { | 1129 | if (sel) { |
| 1116 | printk(KERN_INFO "host%d: FIP selected " | 1130 | printk(KERN_INFO "libfcoe: host%d: FIP selected " |
| 1117 | "Fibre-Channel Forwarder MAC %s\n", | 1131 | "Fibre-Channel Forwarder MAC %s\n", |
| 1118 | fip->lp->host->host_no, | 1132 | fip->lp->host->host_no, |
| 1119 | print_mac(buf, sel->fcf_mac)); | 1133 | print_mac(buf, sel->fcf_mac)); |
| @@ -1123,7 +1137,7 @@ static void fcoe_ctlr_timeout(unsigned long arg) | |||
| 1123 | fip->ctlr_ka_time = jiffies + sel->fka_period; | 1137 | fip->ctlr_ka_time = jiffies + sel->fka_period; |
| 1124 | fip->link = 1; | 1138 | fip->link = 1; |
| 1125 | } else { | 1139 | } else { |
| 1126 | printk(KERN_NOTICE "host%d: " | 1140 | printk(KERN_NOTICE "libfcoe: host%d: " |
| 1127 | "FIP Fibre-Channel Forwarder timed out. " | 1141 | "FIP Fibre-Channel Forwarder timed out. " |
| 1128 | "Starting FCF discovery.\n", | 1142 | "Starting FCF discovery.\n", |
| 1129 | fip->lp->host->host_no); | 1143 | fip->lp->host->host_no); |
| @@ -1247,7 +1261,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_frame *fp, u8 *sa) | |||
| 1247 | return -EINVAL; | 1261 | return -EINVAL; |
| 1248 | } | 1262 | } |
| 1249 | fip->state = FIP_ST_NON_FIP; | 1263 | fip->state = FIP_ST_NON_FIP; |
| 1250 | FIP_DBG("received FLOGI LS_ACC using non-FIP mode\n"); | 1264 | LIBFCOE_FIP_DBG("received FLOGI LS_ACC using non-FIP mode\n"); |
| 1251 | 1265 | ||
| 1252 | /* | 1266 | /* |
| 1253 | * FLOGI accepted. | 1267 | * FLOGI accepted. |
| @@ -1276,7 +1290,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_frame *fp, u8 *sa) | |||
| 1276 | memcpy(fip->dest_addr, sa, ETH_ALEN); | 1290 | memcpy(fip->dest_addr, sa, ETH_ALEN); |
| 1277 | fip->map_dest = 0; | 1291 | fip->map_dest = 0; |
| 1278 | if (fip->state == FIP_ST_NON_FIP) | 1292 | if (fip->state == FIP_ST_NON_FIP) |
| 1279 | FIP_DBG("received FLOGI REQ, " | 1293 | LIBFCOE_FIP_DBG("received FLOGI REQ, " |
| 1280 | "using non-FIP mode\n"); | 1294 | "using non-FIP mode\n"); |
| 1281 | fip->state = FIP_ST_NON_FIP; | 1295 | fip->state = FIP_ST_NON_FIP; |
| 1282 | } | 1296 | } |
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 89d41a424b33..5fd2da494d08 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
| @@ -40,7 +40,7 @@ | |||
| 40 | #include "scsi_logging.h" | 40 | #include "scsi_logging.h" |
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | static int scsi_host_next_hn; /* host_no for next new host */ | 43 | static atomic_t scsi_host_next_hn; /* host_no for next new host */ |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | static void scsi_host_cls_release(struct device *dev) | 46 | static void scsi_host_cls_release(struct device *dev) |
| @@ -333,7 +333,11 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
| 333 | 333 | ||
| 334 | mutex_init(&shost->scan_mutex); | 334 | mutex_init(&shost->scan_mutex); |
| 335 | 335 | ||
| 336 | shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */ | 336 | /* |
| 337 | * subtract one because we increment first then return, but we need to | ||
| 338 | * know what the next host number was before increment | ||
| 339 | */ | ||
| 340 | shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1; | ||
| 337 | shost->dma_channel = 0xff; | 341 | shost->dma_channel = 0xff; |
| 338 | 342 | ||
| 339 | /* These three are default values which can be overridden */ | 343 | /* These three are default values which can be overridden */ |
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index b4b805e8d7db..166d96450a0e 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c | |||
| @@ -2254,10 +2254,13 @@ static void ibmvfc_handle_async(struct ibmvfc_async_crq *crq, | |||
| 2254 | continue; | 2254 | continue; |
| 2255 | if (crq->node_name && tgt->ids.node_name != crq->node_name) | 2255 | if (crq->node_name && tgt->ids.node_name != crq->node_name) |
| 2256 | continue; | 2256 | continue; |
| 2257 | ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); | 2257 | if (tgt->need_login && crq->event == IBMVFC_AE_ELS_LOGO) |
| 2258 | tgt->logo_rcvd = 1; | ||
| 2259 | if (!tgt->need_login || crq->event == IBMVFC_AE_ELS_PLOGI) { | ||
| 2260 | ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); | ||
| 2261 | ibmvfc_reinit_host(vhost); | ||
| 2262 | } | ||
| 2258 | } | 2263 | } |
| 2259 | |||
| 2260 | ibmvfc_reinit_host(vhost); | ||
| 2261 | break; | 2264 | break; |
| 2262 | case IBMVFC_AE_LINK_DOWN: | 2265 | case IBMVFC_AE_LINK_DOWN: |
| 2263 | case IBMVFC_AE_ADAPTER_FAILED: | 2266 | case IBMVFC_AE_ADAPTER_FAILED: |
| @@ -2783,27 +2786,27 @@ static void ibmvfc_tasklet(void *data) | |||
| 2783 | 2786 | ||
| 2784 | spin_lock_irqsave(vhost->host->host_lock, flags); | 2787 | spin_lock_irqsave(vhost->host->host_lock, flags); |
| 2785 | while (!done) { | 2788 | while (!done) { |
| 2786 | /* Pull all the valid messages off the CRQ */ | ||
| 2787 | while ((crq = ibmvfc_next_crq(vhost)) != NULL) { | ||
| 2788 | ibmvfc_handle_crq(crq, vhost); | ||
| 2789 | crq->valid = 0; | ||
| 2790 | } | ||
| 2791 | |||
| 2792 | /* Pull all the valid messages off the async CRQ */ | 2789 | /* Pull all the valid messages off the async CRQ */ |
| 2793 | while ((async = ibmvfc_next_async_crq(vhost)) != NULL) { | 2790 | while ((async = ibmvfc_next_async_crq(vhost)) != NULL) { |
| 2794 | ibmvfc_handle_async(async, vhost); | 2791 | ibmvfc_handle_async(async, vhost); |
| 2795 | async->valid = 0; | 2792 | async->valid = 0; |
| 2796 | } | 2793 | } |
| 2797 | 2794 | ||
| 2798 | vio_enable_interrupts(vdev); | 2795 | /* Pull all the valid messages off the CRQ */ |
| 2799 | if ((crq = ibmvfc_next_crq(vhost)) != NULL) { | 2796 | while ((crq = ibmvfc_next_crq(vhost)) != NULL) { |
| 2800 | vio_disable_interrupts(vdev); | ||
| 2801 | ibmvfc_handle_crq(crq, vhost); | 2797 | ibmvfc_handle_crq(crq, vhost); |
| 2802 | crq->valid = 0; | 2798 | crq->valid = 0; |
| 2803 | } else if ((async = ibmvfc_next_async_crq(vhost)) != NULL) { | 2799 | } |
| 2800 | |||
| 2801 | vio_enable_interrupts(vdev); | ||
| 2802 | if ((async = ibmvfc_next_async_crq(vhost)) != NULL) { | ||
| 2804 | vio_disable_interrupts(vdev); | 2803 | vio_disable_interrupts(vdev); |
| 2805 | ibmvfc_handle_async(async, vhost); | 2804 | ibmvfc_handle_async(async, vhost); |
| 2806 | async->valid = 0; | 2805 | async->valid = 0; |
| 2806 | } else if ((crq = ibmvfc_next_crq(vhost)) != NULL) { | ||
| 2807 | vio_disable_interrupts(vdev); | ||
| 2808 | ibmvfc_handle_crq(crq, vhost); | ||
| 2809 | crq->valid = 0; | ||
| 2807 | } else | 2810 | } else |
| 2808 | done = 1; | 2811 | done = 1; |
| 2809 | } | 2812 | } |
| @@ -2927,7 +2930,11 @@ static void ibmvfc_tgt_prli_done(struct ibmvfc_event *evt) | |||
| 2927 | break; | 2930 | break; |
| 2928 | case IBMVFC_MAD_FAILED: | 2931 | case IBMVFC_MAD_FAILED: |
| 2929 | default: | 2932 | default: |
| 2930 | if (ibmvfc_retry_cmd(rsp->status, rsp->error)) | 2933 | if ((rsp->status & IBMVFC_VIOS_FAILURE) && rsp->error == IBMVFC_PLOGI_REQUIRED) |
| 2934 | level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_plogi); | ||
| 2935 | else if (tgt->logo_rcvd) | ||
| 2936 | level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_plogi); | ||
| 2937 | else if (ibmvfc_retry_cmd(rsp->status, rsp->error)) | ||
| 2931 | level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_prli); | 2938 | level += ibmvfc_retry_tgt_init(tgt, ibmvfc_tgt_send_prli); |
| 2932 | else | 2939 | else |
| 2933 | ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); | 2940 | ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_DEL_RPORT); |
| @@ -3054,6 +3061,7 @@ static void ibmvfc_tgt_send_plogi(struct ibmvfc_target *tgt) | |||
| 3054 | return; | 3061 | return; |
| 3055 | 3062 | ||
| 3056 | kref_get(&tgt->kref); | 3063 | kref_get(&tgt->kref); |
| 3064 | tgt->logo_rcvd = 0; | ||
| 3057 | evt = ibmvfc_get_event(vhost); | 3065 | evt = ibmvfc_get_event(vhost); |
| 3058 | vhost->discovery_threads++; | 3066 | vhost->discovery_threads++; |
| 3059 | ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT_WAIT); | 3067 | ibmvfc_set_tgt_action(tgt, IBMVFC_TGT_ACTION_INIT_WAIT); |
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h index c2668d7d67f5..007fa1c9ef14 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.h +++ b/drivers/scsi/ibmvscsi/ibmvfc.h | |||
| @@ -605,6 +605,7 @@ struct ibmvfc_target { | |||
| 605 | int need_login; | 605 | int need_login; |
| 606 | int add_rport; | 606 | int add_rport; |
| 607 | int init_retries; | 607 | int init_retries; |
| 608 | int logo_rcvd; | ||
| 608 | u32 cancel_key; | 609 | u32 cancel_key; |
| 609 | struct ibmvfc_service_parms service_parms; | 610 | struct ibmvfc_service_parms service_parms; |
| 610 | struct ibmvfc_service_parms service_parms_change; | 611 | struct ibmvfc_service_parms service_parms_change; |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 0f8bc772b112..5f045505a1f4 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
| @@ -131,13 +131,13 @@ static const struct ipr_chip_cfg_t ipr_chip_cfg[] = { | |||
| 131 | }; | 131 | }; |
| 132 | 132 | ||
| 133 | static const struct ipr_chip_t ipr_chip[] = { | 133 | static const struct ipr_chip_t ipr_chip[] = { |
| 134 | { PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE, &ipr_chip_cfg[0] }, | 134 | { PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE, IPR_USE_LSI, &ipr_chip_cfg[0] }, |
| 135 | { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] }, | 135 | { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, IPR_USE_LSI, &ipr_chip_cfg[0] }, |
| 136 | { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, &ipr_chip_cfg[0] }, | 136 | { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, IPR_USE_LSI, &ipr_chip_cfg[0] }, |
| 137 | { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, &ipr_chip_cfg[0] }, | 137 | { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, IPR_USE_LSI, &ipr_chip_cfg[0] }, |
| 138 | { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, &ipr_chip_cfg[0] }, | 138 | { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, IPR_USE_MSI, &ipr_chip_cfg[0] }, |
| 139 | { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] }, | 139 | { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, IPR_USE_LSI, &ipr_chip_cfg[1] }, |
| 140 | { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] } | 140 | { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, IPR_USE_LSI, &ipr_chip_cfg[1] } |
| 141 | }; | 141 | }; |
| 142 | 142 | ||
| 143 | static int ipr_max_bus_speeds [] = { | 143 | static int ipr_max_bus_speeds [] = { |
| @@ -7367,6 +7367,7 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg, | |||
| 7367 | INIT_LIST_HEAD(&ioa_cfg->used_res_q); | 7367 | INIT_LIST_HEAD(&ioa_cfg->used_res_q); |
| 7368 | INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread); | 7368 | INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread); |
| 7369 | init_waitqueue_head(&ioa_cfg->reset_wait_q); | 7369 | init_waitqueue_head(&ioa_cfg->reset_wait_q); |
| 7370 | init_waitqueue_head(&ioa_cfg->msi_wait_q); | ||
| 7370 | ioa_cfg->sdt_state = INACTIVE; | 7371 | ioa_cfg->sdt_state = INACTIVE; |
| 7371 | if (ipr_enable_cache) | 7372 | if (ipr_enable_cache) |
| 7372 | ioa_cfg->cache_state = CACHE_ENABLED; | 7373 | ioa_cfg->cache_state = CACHE_ENABLED; |
| @@ -7398,25 +7399,108 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg, | |||
| 7398 | } | 7399 | } |
| 7399 | 7400 | ||
| 7400 | /** | 7401 | /** |
| 7401 | * ipr_get_chip_cfg - Find adapter chip configuration | 7402 | * ipr_get_chip_info - Find adapter chip information |
| 7402 | * @dev_id: PCI device id struct | 7403 | * @dev_id: PCI device id struct |
| 7403 | * | 7404 | * |
| 7404 | * Return value: | 7405 | * Return value: |
| 7405 | * ptr to chip config on success / NULL on failure | 7406 | * ptr to chip information on success / NULL on failure |
| 7406 | **/ | 7407 | **/ |
| 7407 | static const struct ipr_chip_cfg_t * __devinit | 7408 | static const struct ipr_chip_t * __devinit |
| 7408 | ipr_get_chip_cfg(const struct pci_device_id *dev_id) | 7409 | ipr_get_chip_info(const struct pci_device_id *dev_id) |
| 7409 | { | 7410 | { |
| 7410 | int i; | 7411 | int i; |
| 7411 | 7412 | ||
| 7412 | for (i = 0; i < ARRAY_SIZE(ipr_chip); i++) | 7413 | for (i = 0; i < ARRAY_SIZE(ipr_chip); i++) |
| 7413 | if (ipr_chip[i].vendor == dev_id->vendor && | 7414 | if (ipr_chip[i].vendor == dev_id->vendor && |
| 7414 | ipr_chip[i].device == dev_id->device) | 7415 | ipr_chip[i].device == dev_id->device) |
| 7415 | return ipr_chip[i].cfg; | 7416 | return &ipr_chip[i]; |
| 7416 | return NULL; | 7417 | return NULL; |
| 7417 | } | 7418 | } |
| 7418 | 7419 | ||
| 7419 | /** | 7420 | /** |
| 7421 | * ipr_test_intr - Handle the interrupt generated in ipr_test_msi(). | ||
| 7422 | * @pdev: PCI device struct | ||
| 7423 | * | ||
| 7424 | * Description: Simply set the msi_received flag to 1 indicating that | ||
| 7425 | * Message Signaled Interrupts are supported. | ||
| 7426 | * | ||
| 7427 | * Return value: | ||
| 7428 | * 0 on success / non-zero on failure | ||
| 7429 | **/ | ||
| 7430 | static irqreturn_t __devinit ipr_test_intr(int irq, void *devp) | ||
| 7431 | { | ||
| 7432 | struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)devp; | ||
| 7433 | unsigned long lock_flags = 0; | ||
| 7434 | irqreturn_t rc = IRQ_HANDLED; | ||
| 7435 | |||
| 7436 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); | ||
| 7437 | |||
| 7438 | ioa_cfg->msi_received = 1; | ||
| 7439 | wake_up(&ioa_cfg->msi_wait_q); | ||
| 7440 | |||
| 7441 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | ||
| 7442 | return rc; | ||
| 7443 | } | ||
| 7444 | |||
| 7445 | /** | ||
| 7446 | * ipr_test_msi - Test for Message Signaled Interrupt (MSI) support. | ||
| 7447 | * @pdev: PCI device struct | ||
| 7448 | * | ||
| 7449 | * Description: The return value from pci_enable_msi() can not always be | ||
| 7450 | * trusted. This routine sets up and initiates a test interrupt to determine | ||
| 7451 | * if the interrupt is received via the ipr_test_intr() service routine. | ||
| 7452 | * If the tests fails, the driver will fall back to LSI. | ||
| 7453 | * | ||
| 7454 | * Return value: | ||
| 7455 | * 0 on success / non-zero on failure | ||
| 7456 | **/ | ||
| 7457 | static int __devinit ipr_test_msi(struct ipr_ioa_cfg *ioa_cfg, | ||
| 7458 | struct pci_dev *pdev) | ||
| 7459 | { | ||
| 7460 | int rc; | ||
| 7461 | volatile u32 int_reg; | ||
| 7462 | unsigned long lock_flags = 0; | ||
| 7463 | |||
| 7464 | ENTER; | ||
| 7465 | |||
| 7466 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); | ||
| 7467 | init_waitqueue_head(&ioa_cfg->msi_wait_q); | ||
| 7468 | ioa_cfg->msi_received = 0; | ||
| 7469 | ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER); | ||
| 7470 | writel(IPR_PCII_IO_DEBUG_ACKNOWLEDGE, ioa_cfg->regs.clr_interrupt_mask_reg); | ||
| 7471 | int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); | ||
| 7472 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | ||
| 7473 | |||
| 7474 | rc = request_irq(pdev->irq, ipr_test_intr, 0, IPR_NAME, ioa_cfg); | ||
| 7475 | if (rc) { | ||
| 7476 | dev_err(&pdev->dev, "Can not assign irq %d\n", pdev->irq); | ||
| 7477 | return rc; | ||
| 7478 | } else if (ipr_debug) | ||
| 7479 | dev_info(&pdev->dev, "IRQ assigned: %d\n", pdev->irq); | ||
| 7480 | |||
| 7481 | writel(IPR_PCII_IO_DEBUG_ACKNOWLEDGE, ioa_cfg->regs.sense_interrupt_reg); | ||
| 7482 | int_reg = readl(ioa_cfg->regs.sense_interrupt_reg); | ||
| 7483 | wait_event_timeout(ioa_cfg->msi_wait_q, ioa_cfg->msi_received, HZ); | ||
| 7484 | ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER); | ||
| 7485 | |||
| 7486 | spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); | ||
| 7487 | if (!ioa_cfg->msi_received) { | ||
| 7488 | /* MSI test failed */ | ||
| 7489 | dev_info(&pdev->dev, "MSI test failed. Falling back to LSI.\n"); | ||
| 7490 | rc = -EOPNOTSUPP; | ||
| 7491 | } else if (ipr_debug) | ||
| 7492 | dev_info(&pdev->dev, "MSI test succeeded.\n"); | ||
| 7493 | |||
| 7494 | spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); | ||
| 7495 | |||
| 7496 | free_irq(pdev->irq, ioa_cfg); | ||
| 7497 | |||
| 7498 | LEAVE; | ||
| 7499 | |||
| 7500 | return rc; | ||
| 7501 | } | ||
| 7502 | |||
| 7503 | /** | ||
| 7420 | * ipr_probe_ioa - Allocates memory and does first stage of initialization | 7504 | * ipr_probe_ioa - Allocates memory and does first stage of initialization |
| 7421 | * @pdev: PCI device struct | 7505 | * @pdev: PCI device struct |
| 7422 | * @dev_id: PCI device id struct | 7506 | * @dev_id: PCI device id struct |
| @@ -7441,11 +7525,6 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, | |||
| 7441 | goto out; | 7525 | goto out; |
| 7442 | } | 7526 | } |
| 7443 | 7527 | ||
| 7444 | if (!(rc = pci_enable_msi(pdev))) | ||
| 7445 | dev_info(&pdev->dev, "MSI enabled\n"); | ||
| 7446 | else if (ipr_debug) | ||
| 7447 | dev_info(&pdev->dev, "Cannot enable MSI\n"); | ||
| 7448 | |||
| 7449 | dev_info(&pdev->dev, "Found IOA with IRQ: %d\n", pdev->irq); | 7528 | dev_info(&pdev->dev, "Found IOA with IRQ: %d\n", pdev->irq); |
| 7450 | 7529 | ||
| 7451 | host = scsi_host_alloc(&driver_template, sizeof(*ioa_cfg)); | 7530 | host = scsi_host_alloc(&driver_template, sizeof(*ioa_cfg)); |
| @@ -7461,14 +7540,16 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, | |||
| 7461 | ata_host_init(&ioa_cfg->ata_host, &pdev->dev, | 7540 | ata_host_init(&ioa_cfg->ata_host, &pdev->dev, |
| 7462 | sata_port_info.flags, &ipr_sata_ops); | 7541 | sata_port_info.flags, &ipr_sata_ops); |
| 7463 | 7542 | ||
| 7464 | ioa_cfg->chip_cfg = ipr_get_chip_cfg(dev_id); | 7543 | ioa_cfg->ipr_chip = ipr_get_chip_info(dev_id); |
| 7465 | 7544 | ||
| 7466 | if (!ioa_cfg->chip_cfg) { | 7545 | if (!ioa_cfg->ipr_chip) { |
| 7467 | dev_err(&pdev->dev, "Unknown adapter chipset 0x%04X 0x%04X\n", | 7546 | dev_err(&pdev->dev, "Unknown adapter chipset 0x%04X 0x%04X\n", |
| 7468 | dev_id->vendor, dev_id->device); | 7547 | dev_id->vendor, dev_id->device); |
| 7469 | goto out_scsi_host_put; | 7548 | goto out_scsi_host_put; |
| 7470 | } | 7549 | } |
| 7471 | 7550 | ||
| 7551 | ioa_cfg->chip_cfg = ioa_cfg->ipr_chip->cfg; | ||
| 7552 | |||
| 7472 | if (ipr_transop_timeout) | 7553 | if (ipr_transop_timeout) |
| 7473 | ioa_cfg->transop_timeout = ipr_transop_timeout; | 7554 | ioa_cfg->transop_timeout = ipr_transop_timeout; |
| 7474 | else if (dev_id->driver_data & IPR_USE_LONG_TRANSOP_TIMEOUT) | 7555 | else if (dev_id->driver_data & IPR_USE_LONG_TRANSOP_TIMEOUT) |
| @@ -7519,6 +7600,18 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, | |||
| 7519 | goto cleanup_nomem; | 7600 | goto cleanup_nomem; |
| 7520 | } | 7601 | } |
| 7521 | 7602 | ||
| 7603 | /* Enable MSI style interrupts if they are supported. */ | ||
| 7604 | if (ioa_cfg->ipr_chip->intr_type == IPR_USE_MSI && !pci_enable_msi(pdev)) { | ||
| 7605 | rc = ipr_test_msi(ioa_cfg, pdev); | ||
| 7606 | if (rc == -EOPNOTSUPP) | ||
| 7607 | pci_disable_msi(pdev); | ||
| 7608 | else if (rc) | ||
| 7609 | goto out_msi_disable; | ||
| 7610 | else | ||
| 7611 | dev_info(&pdev->dev, "MSI enabled with IRQ: %d\n", pdev->irq); | ||
| 7612 | } else if (ipr_debug) | ||
| 7613 | dev_info(&pdev->dev, "Cannot enable MSI.\n"); | ||
| 7614 | |||
| 7522 | /* Save away PCI config space for use following IOA reset */ | 7615 | /* Save away PCI config space for use following IOA reset */ |
| 7523 | rc = pci_save_state(pdev); | 7616 | rc = pci_save_state(pdev); |
| 7524 | 7617 | ||
| @@ -7556,7 +7649,9 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, | |||
| 7556 | ioa_cfg->ioa_unit_checked = 1; | 7649 | ioa_cfg->ioa_unit_checked = 1; |
| 7557 | 7650 | ||
| 7558 | ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER); | 7651 | ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER); |
| 7559 | rc = request_irq(pdev->irq, ipr_isr, IRQF_SHARED, IPR_NAME, ioa_cfg); | 7652 | rc = request_irq(pdev->irq, ipr_isr, |
| 7653 | ioa_cfg->msi_received ? 0 : IRQF_SHARED, | ||
| 7654 | IPR_NAME, ioa_cfg); | ||
| 7560 | 7655 | ||
| 7561 | if (rc) { | 7656 | if (rc) { |
| 7562 | dev_err(&pdev->dev, "Couldn't register IRQ %d! rc=%d\n", | 7657 | dev_err(&pdev->dev, "Couldn't register IRQ %d! rc=%d\n", |
| @@ -7583,12 +7678,13 @@ cleanup_nolog: | |||
| 7583 | ipr_free_mem(ioa_cfg); | 7678 | ipr_free_mem(ioa_cfg); |
| 7584 | cleanup_nomem: | 7679 | cleanup_nomem: |
| 7585 | iounmap(ipr_regs); | 7680 | iounmap(ipr_regs); |
| 7681 | out_msi_disable: | ||
| 7682 | pci_disable_msi(pdev); | ||
| 7586 | out_release_regions: | 7683 | out_release_regions: |
| 7587 | pci_release_regions(pdev); | 7684 | pci_release_regions(pdev); |
| 7588 | out_scsi_host_put: | 7685 | out_scsi_host_put: |
| 7589 | scsi_host_put(host); | 7686 | scsi_host_put(host); |
| 7590 | out_disable: | 7687 | out_disable: |
| 7591 | pci_disable_msi(pdev); | ||
| 7592 | pci_disable_device(pdev); | 7688 | pci_disable_device(pdev); |
| 7593 | goto out; | 7689 | goto out; |
| 7594 | } | 7690 | } |
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h index 79a3ae4fb2c7..4b63dd6b1c81 100644 --- a/drivers/scsi/ipr.h +++ b/drivers/scsi/ipr.h | |||
| @@ -37,8 +37,8 @@ | |||
| 37 | /* | 37 | /* |
| 38 | * Literals | 38 | * Literals |
| 39 | */ | 39 | */ |
| 40 | #define IPR_DRIVER_VERSION "2.4.2" | 40 | #define IPR_DRIVER_VERSION "2.4.3" |
| 41 | #define IPR_DRIVER_DATE "(January 21, 2009)" | 41 | #define IPR_DRIVER_DATE "(June 10, 2009)" |
| 42 | 42 | ||
| 43 | /* | 43 | /* |
| 44 | * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding | 44 | * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding |
| @@ -1025,6 +1025,9 @@ struct ipr_chip_cfg_t { | |||
| 1025 | struct ipr_chip_t { | 1025 | struct ipr_chip_t { |
| 1026 | u16 vendor; | 1026 | u16 vendor; |
| 1027 | u16 device; | 1027 | u16 device; |
| 1028 | u16 intr_type; | ||
| 1029 | #define IPR_USE_LSI 0x00 | ||
| 1030 | #define IPR_USE_MSI 0x01 | ||
| 1028 | const struct ipr_chip_cfg_t *cfg; | 1031 | const struct ipr_chip_cfg_t *cfg; |
| 1029 | }; | 1032 | }; |
| 1030 | 1033 | ||
| @@ -1094,6 +1097,7 @@ struct ipr_ioa_cfg { | |||
| 1094 | u8 needs_hard_reset:1; | 1097 | u8 needs_hard_reset:1; |
| 1095 | u8 dual_raid:1; | 1098 | u8 dual_raid:1; |
| 1096 | u8 needs_warm_reset:1; | 1099 | u8 needs_warm_reset:1; |
| 1100 | u8 msi_received:1; | ||
| 1097 | 1101 | ||
| 1098 | u8 revid; | 1102 | u8 revid; |
| 1099 | 1103 | ||
| @@ -1159,6 +1163,7 @@ struct ipr_ioa_cfg { | |||
| 1159 | 1163 | ||
| 1160 | unsigned int transop_timeout; | 1164 | unsigned int transop_timeout; |
| 1161 | const struct ipr_chip_cfg_t *chip_cfg; | 1165 | const struct ipr_chip_cfg_t *chip_cfg; |
| 1166 | const struct ipr_chip_t *ipr_chip; | ||
| 1162 | 1167 | ||
| 1163 | void __iomem *hdw_dma_regs; /* iomapped PCI memory space */ | 1168 | void __iomem *hdw_dma_regs; /* iomapped PCI memory space */ |
| 1164 | unsigned long hdw_dma_regs_pci; /* raw PCI memory space */ | 1169 | unsigned long hdw_dma_regs_pci; /* raw PCI memory space */ |
| @@ -1179,6 +1184,7 @@ struct ipr_ioa_cfg { | |||
| 1179 | struct work_struct work_q; | 1184 | struct work_struct work_q; |
| 1180 | 1185 | ||
| 1181 | wait_queue_head_t reset_wait_q; | 1186 | wait_queue_head_t reset_wait_q; |
| 1187 | wait_queue_head_t msi_wait_q; | ||
| 1182 | 1188 | ||
| 1183 | struct ipr_dump *dump; | 1189 | struct ipr_dump *dump; |
| 1184 | enum ipr_sdt_state sdt_state; | 1190 | enum ipr_sdt_state sdt_state; |
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index b7c092d63bbe..518dbd91df85 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
| @@ -253,8 +253,6 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn, | |||
| 253 | 253 | ||
| 254 | if (r < 0) { | 254 | if (r < 0) { |
| 255 | iscsi_tcp_segment_unmap(segment); | 255 | iscsi_tcp_segment_unmap(segment); |
| 256 | if (copied || r == -EAGAIN) | ||
| 257 | break; | ||
| 258 | return r; | 256 | return r; |
| 259 | } | 257 | } |
| 260 | copied += r; | 258 | copied += r; |
| @@ -275,11 +273,17 @@ static int iscsi_sw_tcp_xmit(struct iscsi_conn *conn) | |||
| 275 | 273 | ||
| 276 | while (1) { | 274 | while (1) { |
| 277 | rc = iscsi_sw_tcp_xmit_segment(tcp_conn, segment); | 275 | rc = iscsi_sw_tcp_xmit_segment(tcp_conn, segment); |
| 278 | if (rc < 0) { | 276 | /* |
| 277 | * We may not have been able to send data because the conn | ||
| 278 | * is getting stopped. libiscsi will know so propogate err | ||
| 279 | * for it to do the right thing. | ||
| 280 | */ | ||
| 281 | if (rc == -EAGAIN) | ||
| 282 | return rc; | ||
| 283 | else if (rc < 0) { | ||
| 279 | rc = ISCSI_ERR_XMIT_FAILED; | 284 | rc = ISCSI_ERR_XMIT_FAILED; |
| 280 | goto error; | 285 | goto error; |
| 281 | } | 286 | } else if (rc == 0) |
| 282 | if (rc == 0) | ||
| 283 | break; | 287 | break; |
| 284 | 288 | ||
| 285 | consumed += rc; | 289 | consumed += rc; |
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index 4c880656990b..6fabf66972b9 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c | |||
| @@ -45,14 +45,6 @@ | |||
| 45 | 45 | ||
| 46 | #define FC_DISC_DELAY 3 | 46 | #define FC_DISC_DELAY 3 |
| 47 | 47 | ||
| 48 | static int fc_disc_debug; | ||
| 49 | |||
| 50 | #define FC_DEBUG_DISC(fmt...) \ | ||
| 51 | do { \ | ||
| 52 | if (fc_disc_debug) \ | ||
| 53 | FC_DBG(fmt); \ | ||
| 54 | } while (0) | ||
| 55 | |||
| 56 | static void fc_disc_gpn_ft_req(struct fc_disc *); | 48 | static void fc_disc_gpn_ft_req(struct fc_disc *); |
| 57 | static void fc_disc_gpn_ft_resp(struct fc_seq *, struct fc_frame *, void *); | 49 | static void fc_disc_gpn_ft_resp(struct fc_seq *, struct fc_frame *, void *); |
| 58 | static int fc_disc_new_target(struct fc_disc *, struct fc_rport *, | 50 | static int fc_disc_new_target(struct fc_disc *, struct fc_rport *, |
| @@ -137,8 +129,8 @@ static void fc_disc_rport_callback(struct fc_lport *lport, | |||
| 137 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 129 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
| 138 | struct fc_disc *disc = &lport->disc; | 130 | struct fc_disc *disc = &lport->disc; |
| 139 | 131 | ||
| 140 | FC_DEBUG_DISC("Received a %d event for port (%6x)\n", event, | 132 | FC_DISC_DBG(disc, "Received a %d event for port (%6x)\n", event, |
| 141 | rport->port_id); | 133 | rport->port_id); |
| 142 | 134 | ||
| 143 | switch (event) { | 135 | switch (event) { |
| 144 | case RPORT_EV_CREATED: | 136 | case RPORT_EV_CREATED: |
| @@ -191,8 +183,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp, | |||
| 191 | 183 | ||
| 192 | lport = disc->lport; | 184 | lport = disc->lport; |
| 193 | 185 | ||
| 194 | FC_DEBUG_DISC("Received an RSCN event on port (%6x)\n", | 186 | FC_DISC_DBG(disc, "Received an RSCN event\n"); |
| 195 | fc_host_port_id(lport->host)); | ||
| 196 | 187 | ||
| 197 | /* make sure the frame contains an RSCN message */ | 188 | /* make sure the frame contains an RSCN message */ |
| 198 | rp = fc_frame_payload_get(fp, sizeof(*rp)); | 189 | rp = fc_frame_payload_get(fp, sizeof(*rp)); |
| @@ -225,8 +216,8 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp, | |||
| 225 | */ | 216 | */ |
| 226 | switch (fmt) { | 217 | switch (fmt) { |
| 227 | case ELS_ADDR_FMT_PORT: | 218 | case ELS_ADDR_FMT_PORT: |
| 228 | FC_DEBUG_DISC("Port address format for port (%6x)\n", | 219 | FC_DISC_DBG(disc, "Port address format for port " |
| 229 | ntoh24(pp->rscn_fid)); | 220 | "(%6x)\n", ntoh24(pp->rscn_fid)); |
| 230 | dp = kzalloc(sizeof(*dp), GFP_KERNEL); | 221 | dp = kzalloc(sizeof(*dp), GFP_KERNEL); |
| 231 | if (!dp) { | 222 | if (!dp) { |
| 232 | redisc = 1; | 223 | redisc = 1; |
| @@ -243,19 +234,19 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp, | |||
| 243 | case ELS_ADDR_FMT_DOM: | 234 | case ELS_ADDR_FMT_DOM: |
| 244 | case ELS_ADDR_FMT_FAB: | 235 | case ELS_ADDR_FMT_FAB: |
| 245 | default: | 236 | default: |
| 246 | FC_DEBUG_DISC("Address format is (%d)\n", fmt); | 237 | FC_DISC_DBG(disc, "Address format is (%d)\n", fmt); |
| 247 | redisc = 1; | 238 | redisc = 1; |
| 248 | break; | 239 | break; |
| 249 | } | 240 | } |
| 250 | } | 241 | } |
| 251 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); | 242 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); |
| 252 | if (redisc) { | 243 | if (redisc) { |
| 253 | FC_DEBUG_DISC("RSCN received: rediscovering\n"); | 244 | FC_DISC_DBG(disc, "RSCN received: rediscovering\n"); |
| 254 | fc_disc_restart(disc); | 245 | fc_disc_restart(disc); |
| 255 | } else { | 246 | } else { |
| 256 | FC_DEBUG_DISC("RSCN received: not rediscovering. " | 247 | FC_DISC_DBG(disc, "RSCN received: not rediscovering. " |
| 257 | "redisc %d state %d in_prog %d\n", | 248 | "redisc %d state %d in_prog %d\n", |
| 258 | redisc, lport->state, disc->pending); | 249 | redisc, lport->state, disc->pending); |
| 259 | list_for_each_entry_safe(dp, next, &disc_ports, peers) { | 250 | list_for_each_entry_safe(dp, next, &disc_ports, peers) { |
| 260 | list_del(&dp->peers); | 251 | list_del(&dp->peers); |
| 261 | rport = lport->tt.rport_lookup(lport, dp->ids.port_id); | 252 | rport = lport->tt.rport_lookup(lport, dp->ids.port_id); |
| @@ -270,7 +261,7 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp, | |||
| 270 | fc_frame_free(fp); | 261 | fc_frame_free(fp); |
| 271 | return; | 262 | return; |
| 272 | reject: | 263 | reject: |
| 273 | FC_DEBUG_DISC("Received a bad RSCN frame\n"); | 264 | FC_DISC_DBG(disc, "Received a bad RSCN frame\n"); |
| 274 | rjt_data.fp = NULL; | 265 | rjt_data.fp = NULL; |
| 275 | rjt_data.reason = ELS_RJT_LOGIC; | 266 | rjt_data.reason = ELS_RJT_LOGIC; |
| 276 | rjt_data.explan = ELS_EXPL_NONE; | 267 | rjt_data.explan = ELS_EXPL_NONE; |
| @@ -302,7 +293,8 @@ static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp, | |||
| 302 | mutex_unlock(&disc->disc_mutex); | 293 | mutex_unlock(&disc->disc_mutex); |
| 303 | break; | 294 | break; |
| 304 | default: | 295 | default: |
| 305 | FC_DBG("Received an unsupported request. opcode (%x)\n", op); | 296 | FC_DISC_DBG(disc, "Received an unsupported request, " |
| 297 | "the opcode is (%x)\n", op); | ||
| 306 | break; | 298 | break; |
| 307 | } | 299 | } |
| 308 | } | 300 | } |
| @@ -320,12 +312,10 @@ static void fc_disc_restart(struct fc_disc *disc) | |||
| 320 | struct fc_rport_libfc_priv *rdata, *next; | 312 | struct fc_rport_libfc_priv *rdata, *next; |
| 321 | struct fc_lport *lport = disc->lport; | 313 | struct fc_lport *lport = disc->lport; |
| 322 | 314 | ||
| 323 | FC_DEBUG_DISC("Restarting discovery for port (%6x)\n", | 315 | FC_DISC_DBG(disc, "Restarting discovery\n"); |
| 324 | fc_host_port_id(lport->host)); | ||
| 325 | 316 | ||
| 326 | list_for_each_entry_safe(rdata, next, &disc->rports, peers) { | 317 | list_for_each_entry_safe(rdata, next, &disc->rports, peers) { |
| 327 | rport = PRIV_TO_RPORT(rdata); | 318 | rport = PRIV_TO_RPORT(rdata); |
| 328 | FC_DEBUG_DISC("list_del(%6x)\n", rport->port_id); | ||
| 329 | list_del(&rdata->peers); | 319 | list_del(&rdata->peers); |
| 330 | lport->tt.rport_logoff(rport); | 320 | lport->tt.rport_logoff(rport); |
| 331 | } | 321 | } |
| @@ -485,8 +475,7 @@ static void fc_disc_done(struct fc_disc *disc) | |||
| 485 | struct fc_lport *lport = disc->lport; | 475 | struct fc_lport *lport = disc->lport; |
| 486 | enum fc_disc_event event; | 476 | enum fc_disc_event event; |
| 487 | 477 | ||
| 488 | FC_DEBUG_DISC("Discovery complete for port (%6x)\n", | 478 | FC_DISC_DBG(disc, "Discovery complete\n"); |
| 489 | fc_host_port_id(lport->host)); | ||
| 490 | 479 | ||
| 491 | event = disc->event; | 480 | event = disc->event; |
| 492 | disc->event = DISC_EV_NONE; | 481 | disc->event = DISC_EV_NONE; |
| @@ -510,10 +499,10 @@ static void fc_disc_error(struct fc_disc *disc, struct fc_frame *fp) | |||
| 510 | { | 499 | { |
| 511 | struct fc_lport *lport = disc->lport; | 500 | struct fc_lport *lport = disc->lport; |
| 512 | unsigned long delay = 0; | 501 | unsigned long delay = 0; |
| 513 | if (fc_disc_debug) | 502 | |
| 514 | FC_DBG("Error %ld, retries %d/%d\n", | 503 | FC_DISC_DBG(disc, "Error %ld, retries %d/%d\n", |
| 515 | PTR_ERR(fp), disc->retry_count, | 504 | PTR_ERR(fp), disc->retry_count, |
| 516 | FC_DISC_RETRY_LIMIT); | 505 | FC_DISC_RETRY_LIMIT); |
| 517 | 506 | ||
| 518 | if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) { | 507 | if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) { |
| 519 | /* | 508 | /* |
| @@ -649,9 +638,9 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) | |||
| 649 | &disc->rogue_rports); | 638 | &disc->rogue_rports); |
| 650 | lport->tt.rport_login(rport); | 639 | lport->tt.rport_login(rport); |
| 651 | } else | 640 | } else |
| 652 | FC_DBG("Failed to allocate memory for " | 641 | printk(KERN_WARNING "libfc: Failed to allocate " |
| 653 | "the newly discovered port (%6x)\n", | 642 | "memory for the newly discovered port " |
| 654 | dp.ids.port_id); | 643 | "(%6x)\n", dp.ids.port_id); |
| 655 | } | 644 | } |
| 656 | 645 | ||
| 657 | if (np->fp_flags & FC_NS_FID_LAST) { | 646 | if (np->fp_flags & FC_NS_FID_LAST) { |
| @@ -671,9 +660,8 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) | |||
| 671 | */ | 660 | */ |
| 672 | if (error == 0 && len > 0 && len < sizeof(*np)) { | 661 | if (error == 0 && len > 0 && len < sizeof(*np)) { |
| 673 | if (np != &disc->partial_buf) { | 662 | if (np != &disc->partial_buf) { |
| 674 | FC_DEBUG_DISC("Partial buffer remains " | 663 | FC_DISC_DBG(disc, "Partial buffer remains " |
| 675 | "for discovery by (%6x)\n", | 664 | "for discovery\n"); |
| 676 | fc_host_port_id(lport->host)); | ||
| 677 | memcpy(&disc->partial_buf, np, len); | 665 | memcpy(&disc->partial_buf, np, len); |
| 678 | } | 666 | } |
| 679 | disc->buf_len = (unsigned char) len; | 667 | disc->buf_len = (unsigned char) len; |
| @@ -721,8 +709,7 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 721 | int error; | 709 | int error; |
| 722 | 710 | ||
| 723 | mutex_lock(&disc->disc_mutex); | 711 | mutex_lock(&disc->disc_mutex); |
| 724 | FC_DEBUG_DISC("Received a GPN_FT response on port (%6x)\n", | 712 | FC_DISC_DBG(disc, "Received a GPN_FT response\n"); |
| 725 | fc_host_port_id(disc->lport->host)); | ||
| 726 | 713 | ||
| 727 | if (IS_ERR(fp)) { | 714 | if (IS_ERR(fp)) { |
| 728 | fc_disc_error(disc, fp); | 715 | fc_disc_error(disc, fp); |
| @@ -738,30 +725,30 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 738 | disc->seq_count == 0) { | 725 | disc->seq_count == 0) { |
| 739 | cp = fc_frame_payload_get(fp, sizeof(*cp)); | 726 | cp = fc_frame_payload_get(fp, sizeof(*cp)); |
| 740 | if (!cp) { | 727 | if (!cp) { |
| 741 | FC_DBG("GPN_FT response too short, len %d\n", | 728 | FC_DISC_DBG(disc, "GPN_FT response too short, len %d\n", |
| 742 | fr_len(fp)); | 729 | fr_len(fp)); |
| 743 | } else if (ntohs(cp->ct_cmd) == FC_FS_ACC) { | 730 | } else if (ntohs(cp->ct_cmd) == FC_FS_ACC) { |
| 744 | 731 | ||
| 745 | /* Accepted, parse the response. */ | 732 | /* Accepted, parse the response. */ |
| 746 | buf = cp + 1; | 733 | buf = cp + 1; |
| 747 | len -= sizeof(*cp); | 734 | len -= sizeof(*cp); |
| 748 | } else if (ntohs(cp->ct_cmd) == FC_FS_RJT) { | 735 | } else if (ntohs(cp->ct_cmd) == FC_FS_RJT) { |
| 749 | FC_DBG("GPN_FT rejected reason %x exp %x " | 736 | FC_DISC_DBG(disc, "GPN_FT rejected reason %x exp %x " |
| 750 | "(check zoning)\n", cp->ct_reason, | 737 | "(check zoning)\n", cp->ct_reason, |
| 751 | cp->ct_explan); | 738 | cp->ct_explan); |
| 752 | disc->event = DISC_EV_FAILED; | 739 | disc->event = DISC_EV_FAILED; |
| 753 | fc_disc_done(disc); | 740 | fc_disc_done(disc); |
| 754 | } else { | 741 | } else { |
| 755 | FC_DBG("GPN_FT unexpected response code %x\n", | 742 | FC_DISC_DBG(disc, "GPN_FT unexpected response code " |
| 756 | ntohs(cp->ct_cmd)); | 743 | "%x\n", ntohs(cp->ct_cmd)); |
| 757 | } | 744 | } |
| 758 | } else if (fr_sof(fp) == FC_SOF_N3 && | 745 | } else if (fr_sof(fp) == FC_SOF_N3 && |
| 759 | seq_cnt == disc->seq_count) { | 746 | seq_cnt == disc->seq_count) { |
| 760 | buf = fh + 1; | 747 | buf = fh + 1; |
| 761 | } else { | 748 | } else { |
| 762 | FC_DBG("GPN_FT unexpected frame - out of sequence? " | 749 | FC_DISC_DBG(disc, "GPN_FT unexpected frame - out of sequence? " |
| 763 | "seq_cnt %x expected %x sof %x eof %x\n", | 750 | "seq_cnt %x expected %x sof %x eof %x\n", |
| 764 | seq_cnt, disc->seq_count, fr_sof(fp), fr_eof(fp)); | 751 | seq_cnt, disc->seq_count, fr_sof(fp), fr_eof(fp)); |
| 765 | } | 752 | } |
| 766 | if (buf) { | 753 | if (buf) { |
| 767 | error = fc_disc_gpn_ft_parse(disc, buf, len); | 754 | error = fc_disc_gpn_ft_parse(disc, buf, len); |
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index 7af9bceb8aa9..2bc22be5f849 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c | |||
| @@ -32,18 +32,7 @@ | |||
| 32 | #include <scsi/libfc.h> | 32 | #include <scsi/libfc.h> |
| 33 | #include <scsi/fc_encode.h> | 33 | #include <scsi/fc_encode.h> |
| 34 | 34 | ||
| 35 | /* | 35 | static struct kmem_cache *fc_em_cachep; /* cache for exchanges */ |
| 36 | * fc_exch_debug can be set in debugger or at compile time to get more logs. | ||
| 37 | */ | ||
| 38 | static int fc_exch_debug; | ||
| 39 | |||
| 40 | #define FC_DEBUG_EXCH(fmt...) \ | ||
| 41 | do { \ | ||
| 42 | if (fc_exch_debug) \ | ||
| 43 | FC_DBG(fmt); \ | ||
| 44 | } while (0) | ||
| 45 | |||
| 46 | static struct kmem_cache *fc_em_cachep; /* cache for exchanges */ | ||
| 47 | 36 | ||
| 48 | /* | 37 | /* |
| 49 | * Structure and function definitions for managing Fibre Channel Exchanges | 38 | * Structure and function definitions for managing Fibre Channel Exchanges |
| @@ -333,8 +322,8 @@ static inline void fc_exch_timer_set_locked(struct fc_exch *ep, | |||
| 333 | if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) | 322 | if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) |
| 334 | return; | 323 | return; |
| 335 | 324 | ||
| 336 | FC_DEBUG_EXCH("Exchange (%4x) timed out, notifying the upper layer\n", | 325 | FC_EXCH_DBG(ep, "Exchange timed out, notifying the upper layer\n"); |
| 337 | ep->xid); | 326 | |
| 338 | if (schedule_delayed_work(&ep->timeout_work, | 327 | if (schedule_delayed_work(&ep->timeout_work, |
| 339 | msecs_to_jiffies(timer_msec))) | 328 | msecs_to_jiffies(timer_msec))) |
| 340 | fc_exch_hold(ep); /* hold for timer */ | 329 | fc_exch_hold(ep); /* hold for timer */ |
| @@ -545,7 +534,7 @@ struct fc_exch *fc_exch_alloc(struct fc_exch_mgr *mp, | |||
| 545 | /* alloc a new xid */ | 534 | /* alloc a new xid */ |
| 546 | xid = fc_em_alloc_xid(mp, fp); | 535 | xid = fc_em_alloc_xid(mp, fp); |
| 547 | if (!xid) { | 536 | if (!xid) { |
| 548 | printk(KERN_ERR "fc_em_alloc_xid() failed\n"); | 537 | printk(KERN_WARNING "libfc: Failed to allocate an exhange\n"); |
| 549 | goto err; | 538 | goto err; |
| 550 | } | 539 | } |
| 551 | } | 540 | } |
| @@ -820,8 +809,8 @@ static struct fc_seq *fc_seq_start_next_locked(struct fc_seq *sp) | |||
| 820 | struct fc_exch *ep = fc_seq_exch(sp); | 809 | struct fc_exch *ep = fc_seq_exch(sp); |
| 821 | 810 | ||
| 822 | sp = fc_seq_alloc(ep, ep->seq_id++); | 811 | sp = fc_seq_alloc(ep, ep->seq_id++); |
| 823 | FC_DEBUG_EXCH("exch %4x f_ctl %6x seq %2x\n", | 812 | FC_EXCH_DBG(ep, "f_ctl %6x seq %2x\n", |
| 824 | ep->xid, ep->f_ctl, sp->id); | 813 | ep->f_ctl, sp->id); |
| 825 | return sp; | 814 | return sp; |
| 826 | } | 815 | } |
| 827 | /* | 816 | /* |
| @@ -901,7 +890,7 @@ void fc_seq_els_rsp_send(struct fc_seq *sp, enum fc_els_cmd els_cmd, | |||
| 901 | fc_exch_els_rec(sp, els_data->fp); | 890 | fc_exch_els_rec(sp, els_data->fp); |
| 902 | break; | 891 | break; |
| 903 | default: | 892 | default: |
| 904 | FC_DBG("Invalid ELS CMD:%x\n", els_cmd); | 893 | FC_EXCH_DBG(fc_seq_exch(sp), "Invalid ELS CMD:%x\n", els_cmd); |
| 905 | } | 894 | } |
| 906 | } | 895 | } |
| 907 | EXPORT_SYMBOL(fc_seq_els_rsp_send); | 896 | EXPORT_SYMBOL(fc_seq_els_rsp_send); |
| @@ -1134,7 +1123,7 @@ static void fc_exch_recv_req(struct fc_lport *lp, struct fc_exch_mgr *mp, | |||
| 1134 | lp->tt.lport_recv(lp, sp, fp); | 1123 | lp->tt.lport_recv(lp, sp, fp); |
| 1135 | fc_exch_release(ep); /* release from lookup */ | 1124 | fc_exch_release(ep); /* release from lookup */ |
| 1136 | } else { | 1125 | } else { |
| 1137 | FC_DEBUG_EXCH("exch/seq lookup failed: reject %x\n", reject); | 1126 | FC_EM_DBG(mp, "exch/seq lookup failed: reject %x\n", reject); |
| 1138 | fc_frame_free(fp); | 1127 | fc_frame_free(fp); |
| 1139 | } | 1128 | } |
| 1140 | } | 1129 | } |
| @@ -1242,10 +1231,10 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp) | |||
| 1242 | sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */ | 1231 | sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */ |
| 1243 | if (!sp) { | 1232 | if (!sp) { |
| 1244 | atomic_inc(&mp->stats.xid_not_found); | 1233 | atomic_inc(&mp->stats.xid_not_found); |
| 1245 | FC_DEBUG_EXCH("seq lookup failed\n"); | 1234 | FC_EM_DBG(mp, "seq lookup failed\n"); |
| 1246 | } else { | 1235 | } else { |
| 1247 | atomic_inc(&mp->stats.non_bls_resp); | 1236 | atomic_inc(&mp->stats.non_bls_resp); |
| 1248 | FC_DEBUG_EXCH("non-BLS response to sequence"); | 1237 | FC_EM_DBG(mp, "non-BLS response to sequence"); |
| 1249 | } | 1238 | } |
| 1250 | fc_frame_free(fp); | 1239 | fc_frame_free(fp); |
| 1251 | } | 1240 | } |
| @@ -1266,8 +1255,8 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp) | |||
| 1266 | int rc = 1, has_rec = 0; | 1255 | int rc = 1, has_rec = 0; |
| 1267 | 1256 | ||
| 1268 | fh = fc_frame_header_get(fp); | 1257 | fh = fc_frame_header_get(fp); |
| 1269 | FC_DEBUG_EXCH("exch: BLS rctl %x - %s\n", | 1258 | FC_EXCH_DBG(ep, "exch: BLS rctl %x - %s\n", fh->fh_r_ctl, |
| 1270 | fh->fh_r_ctl, fc_exch_rctl_name(fh->fh_r_ctl)); | 1259 | fc_exch_rctl_name(fh->fh_r_ctl)); |
| 1271 | 1260 | ||
| 1272 | if (cancel_delayed_work_sync(&ep->timeout_work)) | 1261 | if (cancel_delayed_work_sync(&ep->timeout_work)) |
| 1273 | fc_exch_release(ep); /* release from pending timer hold */ | 1262 | fc_exch_release(ep); /* release from pending timer hold */ |
| @@ -1359,9 +1348,9 @@ static void fc_exch_recv_bls(struct fc_exch_mgr *mp, struct fc_frame *fp) | |||
| 1359 | case FC_RCTL_ACK_0: | 1348 | case FC_RCTL_ACK_0: |
| 1360 | break; | 1349 | break; |
| 1361 | default: | 1350 | default: |
| 1362 | FC_DEBUG_EXCH("BLS rctl %x - %s received", | 1351 | FC_EXCH_DBG(ep, "BLS rctl %x - %s received", |
| 1363 | fh->fh_r_ctl, | 1352 | fh->fh_r_ctl, |
| 1364 | fc_exch_rctl_name(fh->fh_r_ctl)); | 1353 | fc_exch_rctl_name(fh->fh_r_ctl)); |
| 1365 | break; | 1354 | break; |
| 1366 | } | 1355 | } |
| 1367 | fc_frame_free(fp); | 1356 | fc_frame_free(fp); |
| @@ -1599,7 +1588,8 @@ static void fc_exch_rrq_resp(struct fc_seq *sp, struct fc_frame *fp, void *arg) | |||
| 1599 | 1588 | ||
| 1600 | if (err == -FC_EX_CLOSED || err == -FC_EX_TIMEOUT) | 1589 | if (err == -FC_EX_CLOSED || err == -FC_EX_TIMEOUT) |
| 1601 | goto cleanup; | 1590 | goto cleanup; |
| 1602 | FC_DBG("Cannot process RRQ, because of frame error %d\n", err); | 1591 | FC_EXCH_DBG(aborted_ep, "Cannot process RRQ, " |
| 1592 | "frame error %d\n", err); | ||
| 1603 | return; | 1593 | return; |
| 1604 | } | 1594 | } |
| 1605 | 1595 | ||
| @@ -1608,12 +1598,13 @@ static void fc_exch_rrq_resp(struct fc_seq *sp, struct fc_frame *fp, void *arg) | |||
| 1608 | 1598 | ||
| 1609 | switch (op) { | 1599 | switch (op) { |
| 1610 | case ELS_LS_RJT: | 1600 | case ELS_LS_RJT: |
| 1611 | FC_DBG("LS_RJT for RRQ"); | 1601 | FC_EXCH_DBG(aborted_ep, "LS_RJT for RRQ"); |
| 1612 | /* fall through */ | 1602 | /* fall through */ |
| 1613 | case ELS_LS_ACC: | 1603 | case ELS_LS_ACC: |
| 1614 | goto cleanup; | 1604 | goto cleanup; |
| 1615 | default: | 1605 | default: |
| 1616 | FC_DBG("unexpected response op %x for RRQ", op); | 1606 | FC_EXCH_DBG(aborted_ep, "unexpected response op %x " |
| 1607 | "for RRQ", op); | ||
| 1617 | return; | 1608 | return; |
| 1618 | } | 1609 | } |
| 1619 | 1610 | ||
| @@ -1740,8 +1731,8 @@ struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp, | |||
| 1740 | size_t len; | 1731 | size_t len; |
| 1741 | 1732 | ||
| 1742 | if (max_xid <= min_xid || min_xid == 0 || max_xid == FC_XID_UNKNOWN) { | 1733 | if (max_xid <= min_xid || min_xid == 0 || max_xid == FC_XID_UNKNOWN) { |
| 1743 | FC_DBG("Invalid min_xid 0x:%x and max_xid 0x:%x\n", | 1734 | FC_LPORT_DBG(lp, "Invalid min_xid 0x:%x and max_xid 0x:%x\n", |
| 1744 | min_xid, max_xid); | 1735 | min_xid, max_xid); |
| 1745 | return NULL; | 1736 | return NULL; |
| 1746 | } | 1737 | } |
| 1747 | 1738 | ||
| @@ -1878,7 +1869,8 @@ void fc_exch_recv(struct fc_lport *lp, struct fc_exch_mgr *mp, | |||
| 1878 | 1869 | ||
| 1879 | /* lport lock ? */ | 1870 | /* lport lock ? */ |
| 1880 | if (!lp || !mp || (lp->state == LPORT_ST_NONE)) { | 1871 | if (!lp || !mp || (lp->state == LPORT_ST_NONE)) { |
| 1881 | FC_DBG("fc_lport or EM is not allocated and configured"); | 1872 | FC_LPORT_DBG(lp, "Receiving frames for an lport that " |
| 1873 | "has not been initialized correctly\n"); | ||
| 1882 | fc_frame_free(fp); | 1874 | fc_frame_free(fp); |
| 1883 | return; | 1875 | return; |
| 1884 | } | 1876 | } |
| @@ -1904,7 +1896,7 @@ void fc_exch_recv(struct fc_lport *lp, struct fc_exch_mgr *mp, | |||
| 1904 | fc_exch_recv_req(lp, mp, fp); | 1896 | fc_exch_recv_req(lp, mp, fp); |
| 1905 | break; | 1897 | break; |
| 1906 | default: | 1898 | default: |
| 1907 | FC_DBG("dropping invalid frame (eof %x)", fr_eof(fp)); | 1899 | FC_EM_DBG(mp, "dropping invalid frame (eof %x)", fr_eof(fp)); |
| 1908 | fc_frame_free(fp); | 1900 | fc_frame_free(fp); |
| 1909 | break; | 1901 | break; |
| 1910 | } | 1902 | } |
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c index ad8b747837b0..e303e0d12c4b 100644 --- a/drivers/scsi/libfc/fc_fcp.c +++ b/drivers/scsi/libfc/fc_fcp.c | |||
| @@ -43,13 +43,9 @@ MODULE_AUTHOR("Open-FCoE.org"); | |||
| 43 | MODULE_DESCRIPTION("libfc"); | 43 | MODULE_DESCRIPTION("libfc"); |
| 44 | MODULE_LICENSE("GPL v2"); | 44 | MODULE_LICENSE("GPL v2"); |
| 45 | 45 | ||
| 46 | static int fc_fcp_debug; | 46 | unsigned int fc_debug_logging; |
| 47 | 47 | module_param_named(debug_logging, fc_debug_logging, int, S_IRUGO|S_IWUSR); | |
| 48 | #define FC_DEBUG_FCP(fmt...) \ | 48 | MODULE_PARM_DESC(debug_logging, "a bit mask of logging levels"); |
| 49 | do { \ | ||
| 50 | if (fc_fcp_debug) \ | ||
| 51 | FC_DBG(fmt); \ | ||
| 52 | } while (0) | ||
| 53 | 49 | ||
| 54 | static struct kmem_cache *scsi_pkt_cachep; | 50 | static struct kmem_cache *scsi_pkt_cachep; |
| 55 | 51 | ||
| @@ -347,8 +343,8 @@ static void fc_fcp_recv_data(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
| 347 | if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) && | 343 | if ((fr_flags(fp) & FCPHF_CRC_UNCHECKED) && |
| 348 | fc_frame_crc_check(fp)) | 344 | fc_frame_crc_check(fp)) |
| 349 | goto crc_err; | 345 | goto crc_err; |
| 350 | FC_DEBUG_FCP("data received past end. len %zx offset %zx " | 346 | FC_FCP_DBG(fsp, "data received past end. len %zx offset %zx " |
| 351 | "data_len %x\n", len, offset, fsp->data_len); | 347 | "data_len %x\n", len, offset, fsp->data_len); |
| 352 | fc_fcp_retry_cmd(fsp); | 348 | fc_fcp_retry_cmd(fsp); |
| 353 | return; | 349 | return; |
| 354 | } | 350 | } |
| @@ -411,7 +407,8 @@ crc_err: | |||
| 411 | stats->ErrorFrames++; | 407 | stats->ErrorFrames++; |
| 412 | /* FIXME - per cpu count, not total count! */ | 408 | /* FIXME - per cpu count, not total count! */ |
| 413 | if (stats->InvalidCRCCount++ < 5) | 409 | if (stats->InvalidCRCCount++ < 5) |
| 414 | printk(KERN_WARNING "CRC error on data frame for port (%6x)\n", | 410 | printk(KERN_WARNING "libfc: CRC error on data " |
| 411 | "frame for port (%6x)\n", | ||
| 415 | fc_host_port_id(lp->host)); | 412 | fc_host_port_id(lp->host)); |
| 416 | /* | 413 | /* |
| 417 | * Assume the frame is total garbage. | 414 | * Assume the frame is total garbage. |
| @@ -475,14 +472,14 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
| 475 | WARN_ON(seq_blen <= 0); | 472 | WARN_ON(seq_blen <= 0); |
| 476 | if (unlikely(offset + seq_blen > fsp->data_len)) { | 473 | if (unlikely(offset + seq_blen > fsp->data_len)) { |
| 477 | /* this should never happen */ | 474 | /* this should never happen */ |
| 478 | FC_DEBUG_FCP("xfer-ready past end. seq_blen %zx offset %zx\n", | 475 | FC_FCP_DBG(fsp, "xfer-ready past end. seq_blen %zx " |
| 479 | seq_blen, offset); | 476 | "offset %zx\n", seq_blen, offset); |
| 480 | fc_fcp_send_abort(fsp); | 477 | fc_fcp_send_abort(fsp); |
| 481 | return 0; | 478 | return 0; |
| 482 | } else if (offset != fsp->xfer_len) { | 479 | } else if (offset != fsp->xfer_len) { |
| 483 | /* Out of Order Data Request - no problem, but unexpected. */ | 480 | /* Out of Order Data Request - no problem, but unexpected. */ |
| 484 | FC_DEBUG_FCP("xfer-ready non-contiguous. " | 481 | FC_FCP_DBG(fsp, "xfer-ready non-contiguous. " |
| 485 | "seq_blen %zx offset %zx\n", seq_blen, offset); | 482 | "seq_blen %zx offset %zx\n", seq_blen, offset); |
| 486 | } | 483 | } |
| 487 | 484 | ||
| 488 | /* | 485 | /* |
| @@ -493,7 +490,7 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq, | |||
| 493 | t_blen = fsp->max_payload; | 490 | t_blen = fsp->max_payload; |
| 494 | if (lp->seq_offload) { | 491 | if (lp->seq_offload) { |
| 495 | t_blen = min(seq_blen, (size_t)lp->lso_max); | 492 | t_blen = min(seq_blen, (size_t)lp->lso_max); |
| 496 | FC_DEBUG_FCP("fsp=%p:lso:blen=%zx lso_max=0x%x t_blen=%zx\n", | 493 | FC_FCP_DBG(fsp, "fsp=%p:lso:blen=%zx lso_max=0x%x t_blen=%zx\n", |
| 497 | fsp, seq_blen, lp->lso_max, t_blen); | 494 | fsp, seq_blen, lp->lso_max, t_blen); |
| 498 | } | 495 | } |
| 499 | 496 | ||
| @@ -694,7 +691,7 @@ static void fc_fcp_reduce_can_queue(struct fc_lport *lp) | |||
| 694 | if (!can_queue) | 691 | if (!can_queue) |
| 695 | can_queue = 1; | 692 | can_queue = 1; |
| 696 | lp->host->can_queue = can_queue; | 693 | lp->host->can_queue = can_queue; |
| 697 | shost_printk(KERN_ERR, lp->host, "Could not allocate frame.\n" | 694 | shost_printk(KERN_ERR, lp->host, "libfc: Could not allocate frame.\n" |
| 698 | "Reducing can_queue to %d.\n", can_queue); | 695 | "Reducing can_queue to %d.\n", can_queue); |
| 699 | done: | 696 | done: |
| 700 | spin_unlock_irqrestore(lp->host->host_lock, flags); | 697 | spin_unlock_irqrestore(lp->host->host_lock, flags); |
| @@ -768,7 +765,7 @@ static void fc_fcp_recv(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
| 768 | 765 | ||
| 769 | fc_fcp_resp(fsp, fp); | 766 | fc_fcp_resp(fsp, fp); |
| 770 | } else { | 767 | } else { |
| 771 | FC_DBG("unexpected frame. r_ctl %x\n", r_ctl); | 768 | FC_FCP_DBG(fsp, "unexpected frame. r_ctl %x\n", r_ctl); |
| 772 | } | 769 | } |
| 773 | unlock: | 770 | unlock: |
| 774 | fc_fcp_unlock_pkt(fsp); | 771 | fc_fcp_unlock_pkt(fsp); |
| @@ -877,17 +874,17 @@ static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
| 877 | return; | 874 | return; |
| 878 | } | 875 | } |
| 879 | fsp->status_code = FC_DATA_OVRRUN; | 876 | fsp->status_code = FC_DATA_OVRRUN; |
| 880 | FC_DBG("tgt %6x xfer len %zx greater than expected len %x. " | 877 | FC_FCP_DBG(fsp, "tgt %6x xfer len %zx greater than expected, " |
| 881 | "data len %x\n", | 878 | "len %x, data len %x\n", |
| 882 | fsp->rport->port_id, | 879 | fsp->rport->port_id, |
| 883 | fsp->xfer_len, expected_len, fsp->data_len); | 880 | fsp->xfer_len, expected_len, fsp->data_len); |
| 884 | } | 881 | } |
| 885 | fc_fcp_complete_locked(fsp); | 882 | fc_fcp_complete_locked(fsp); |
| 886 | return; | 883 | return; |
| 887 | 884 | ||
| 888 | len_err: | 885 | len_err: |
| 889 | FC_DBG("short FCP response. flags 0x%x len %u respl %u snsl %u\n", | 886 | FC_FCP_DBG(fsp, "short FCP response. flags 0x%x len %u respl %u " |
| 890 | flags, fr_len(fp), respl, snsl); | 887 | "snsl %u\n", flags, fr_len(fp), respl, snsl); |
| 891 | err: | 888 | err: |
| 892 | fsp->status_code = FC_ERROR; | 889 | fsp->status_code = FC_ERROR; |
| 893 | fc_fcp_complete_locked(fsp); | 890 | fc_fcp_complete_locked(fsp); |
| @@ -1107,13 +1104,11 @@ static void fc_fcp_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
| 1107 | if (fc_fcp_lock_pkt(fsp)) | 1104 | if (fc_fcp_lock_pkt(fsp)) |
| 1108 | return; | 1105 | return; |
| 1109 | 1106 | ||
| 1110 | switch (error) { | 1107 | if (error == -FC_EX_CLOSED) { |
| 1111 | case -FC_EX_CLOSED: | ||
| 1112 | fc_fcp_retry_cmd(fsp); | 1108 | fc_fcp_retry_cmd(fsp); |
| 1113 | goto unlock; | 1109 | goto unlock; |
| 1114 | default: | ||
| 1115 | FC_DBG("unknown error %ld\n", PTR_ERR(fp)); | ||
| 1116 | } | 1110 | } |
| 1111 | |||
| 1117 | /* | 1112 | /* |
| 1118 | * clear abort pending, because the lower layer | 1113 | * clear abort pending, because the lower layer |
| 1119 | * decided to force completion. | 1114 | * decided to force completion. |
| @@ -1145,10 +1140,10 @@ static int fc_fcp_pkt_abort(struct fc_lport *lp, struct fc_fcp_pkt *fsp) | |||
| 1145 | fsp->wait_for_comp = 0; | 1140 | fsp->wait_for_comp = 0; |
| 1146 | 1141 | ||
| 1147 | if (!rc) { | 1142 | if (!rc) { |
| 1148 | FC_DBG("target abort cmd failed\n"); | 1143 | FC_FCP_DBG(fsp, "target abort cmd failed\n"); |
| 1149 | rc = FAILED; | 1144 | rc = FAILED; |
| 1150 | } else if (fsp->state & FC_SRB_ABORTED) { | 1145 | } else if (fsp->state & FC_SRB_ABORTED) { |
| 1151 | FC_DBG("target abort cmd passed\n"); | 1146 | FC_FCP_DBG(fsp, "target abort cmd passed\n"); |
| 1152 | rc = SUCCESS; | 1147 | rc = SUCCESS; |
| 1153 | fc_fcp_complete_locked(fsp); | 1148 | fc_fcp_complete_locked(fsp); |
| 1154 | } | 1149 | } |
| @@ -1213,7 +1208,7 @@ static int fc_lun_reset(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | |||
| 1213 | spin_unlock_bh(&fsp->scsi_pkt_lock); | 1208 | spin_unlock_bh(&fsp->scsi_pkt_lock); |
| 1214 | 1209 | ||
| 1215 | if (!rc) { | 1210 | if (!rc) { |
| 1216 | FC_DBG("lun reset failed\n"); | 1211 | FC_SCSI_DBG(lp, "lun reset failed\n"); |
| 1217 | return FAILED; | 1212 | return FAILED; |
| 1218 | } | 1213 | } |
| 1219 | 1214 | ||
| @@ -1221,7 +1216,7 @@ static int fc_lun_reset(struct fc_lport *lp, struct fc_fcp_pkt *fsp, | |||
| 1221 | if (fsp->cdb_status != FCP_TMF_CMPL) | 1216 | if (fsp->cdb_status != FCP_TMF_CMPL) |
| 1222 | return FAILED; | 1217 | return FAILED; |
| 1223 | 1218 | ||
| 1224 | FC_DBG("lun reset to lun %u completed\n", lun); | 1219 | FC_SCSI_DBG(lp, "lun reset to lun %u completed\n", lun); |
| 1225 | fc_fcp_cleanup_each_cmd(lp, id, lun, FC_CMD_ABORTED); | 1220 | fc_fcp_cleanup_each_cmd(lp, id, lun, FC_CMD_ABORTED); |
| 1226 | return SUCCESS; | 1221 | return SUCCESS; |
| 1227 | } | 1222 | } |
| @@ -1388,13 +1383,13 @@ static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg) | |||
| 1388 | rjt = fc_frame_payload_get(fp, sizeof(*rjt)); | 1383 | rjt = fc_frame_payload_get(fp, sizeof(*rjt)); |
| 1389 | switch (rjt->er_reason) { | 1384 | switch (rjt->er_reason) { |
| 1390 | default: | 1385 | default: |
| 1391 | FC_DEBUG_FCP("device %x unexpected REC reject " | 1386 | FC_FCP_DBG(fsp, "device %x unexpected REC reject " |
| 1392 | "reason %d expl %d\n", | 1387 | "reason %d expl %d\n", |
| 1393 | fsp->rport->port_id, rjt->er_reason, | 1388 | fsp->rport->port_id, rjt->er_reason, |
| 1394 | rjt->er_explan); | 1389 | rjt->er_explan); |
| 1395 | /* fall through */ | 1390 | /* fall through */ |
| 1396 | case ELS_RJT_UNSUP: | 1391 | case ELS_RJT_UNSUP: |
| 1397 | FC_DEBUG_FCP("device does not support REC\n"); | 1392 | FC_FCP_DBG(fsp, "device does not support REC\n"); |
| 1398 | rp = fsp->rport->dd_data; | 1393 | rp = fsp->rport->dd_data; |
| 1399 | /* | 1394 | /* |
| 1400 | * if we do not spport RECs or got some bogus | 1395 | * if we do not spport RECs or got some bogus |
| @@ -1514,8 +1509,8 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
| 1514 | break; | 1509 | break; |
| 1515 | 1510 | ||
| 1516 | default: | 1511 | default: |
| 1517 | FC_DBG("REC %p fid %x error unexpected error %d\n", | 1512 | FC_FCP_DBG(fsp, "REC %p fid %x error unexpected error %d\n", |
| 1518 | fsp, fsp->rport->port_id, error); | 1513 | fsp, fsp->rport->port_id, error); |
| 1519 | fsp->status_code = FC_CMD_PLOGO; | 1514 | fsp->status_code = FC_CMD_PLOGO; |
| 1520 | /* fall through */ | 1515 | /* fall through */ |
| 1521 | 1516 | ||
| @@ -1524,9 +1519,9 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp) | |||
| 1524 | * Assume REC or LS_ACC was lost. | 1519 | * Assume REC or LS_ACC was lost. |
| 1525 | * The exchange manager will have aborted REC, so retry. | 1520 | * The exchange manager will have aborted REC, so retry. |
| 1526 | */ | 1521 | */ |
| 1527 | FC_DBG("REC fid %x error error %d retry %d/%d\n", | 1522 | FC_FCP_DBG(fsp, "REC fid %x error error %d retry %d/%d\n", |
| 1528 | fsp->rport->port_id, error, fsp->recov_retry, | 1523 | fsp->rport->port_id, error, fsp->recov_retry, |
| 1529 | FC_MAX_RECOV_RETRY); | 1524 | FC_MAX_RECOV_RETRY); |
| 1530 | if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY) | 1525 | if (fsp->recov_retry++ < FC_MAX_RECOV_RETRY) |
| 1531 | fc_fcp_rec(fsp); | 1526 | fc_fcp_rec(fsp); |
| 1532 | else | 1527 | else |
| @@ -2011,9 +2006,11 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd) | |||
| 2011 | if (lp->state != LPORT_ST_READY) | 2006 | if (lp->state != LPORT_ST_READY) |
| 2012 | return rc; | 2007 | return rc; |
| 2013 | 2008 | ||
| 2009 | FC_SCSI_DBG(lp, "Resetting rport (%6x)\n", rport->port_id); | ||
| 2010 | |||
| 2014 | fsp = fc_fcp_pkt_alloc(lp, GFP_NOIO); | 2011 | fsp = fc_fcp_pkt_alloc(lp, GFP_NOIO); |
| 2015 | if (fsp == NULL) { | 2012 | if (fsp == NULL) { |
| 2016 | FC_DBG("could not allocate scsi_pkt\n"); | 2013 | printk(KERN_WARNING "libfc: could not allocate scsi_pkt\n"); |
| 2017 | sc_cmd->result = DID_NO_CONNECT << 16; | 2014 | sc_cmd->result = DID_NO_CONNECT << 16; |
| 2018 | goto out; | 2015 | goto out; |
| 2019 | } | 2016 | } |
| @@ -2048,17 +2045,21 @@ int fc_eh_host_reset(struct scsi_cmnd *sc_cmd) | |||
| 2048 | struct fc_lport *lp = shost_priv(shost); | 2045 | struct fc_lport *lp = shost_priv(shost); |
| 2049 | unsigned long wait_tmo; | 2046 | unsigned long wait_tmo; |
| 2050 | 2047 | ||
| 2048 | FC_SCSI_DBG(lp, "Resetting host\n"); | ||
| 2049 | |||
| 2051 | lp->tt.lport_reset(lp); | 2050 | lp->tt.lport_reset(lp); |
| 2052 | wait_tmo = jiffies + FC_HOST_RESET_TIMEOUT; | 2051 | wait_tmo = jiffies + FC_HOST_RESET_TIMEOUT; |
| 2053 | while (!fc_fcp_lport_queue_ready(lp) && time_before(jiffies, wait_tmo)) | 2052 | while (!fc_fcp_lport_queue_ready(lp) && time_before(jiffies, wait_tmo)) |
| 2054 | msleep(1000); | 2053 | msleep(1000); |
| 2055 | 2054 | ||
| 2056 | if (fc_fcp_lport_queue_ready(lp)) { | 2055 | if (fc_fcp_lport_queue_ready(lp)) { |
| 2057 | shost_printk(KERN_INFO, shost, "Host reset succeeded.\n"); | 2056 | shost_printk(KERN_INFO, shost, "libfc: Host reset succeeded " |
| 2057 | "on port (%6x)\n", fc_host_port_id(lp->host)); | ||
| 2058 | return SUCCESS; | 2058 | return SUCCESS; |
| 2059 | } else { | 2059 | } else { |
| 2060 | shost_printk(KERN_INFO, shost, "Host reset failed. " | 2060 | shost_printk(KERN_INFO, shost, "libfc: Host reset failed, " |
| 2061 | "lport not ready.\n"); | 2061 | "port (%6x) is not ready.\n", |
| 2062 | fc_host_port_id(lp->host)); | ||
| 2062 | return FAILED; | 2063 | return FAILED; |
| 2063 | } | 2064 | } |
| 2064 | } | 2065 | } |
| @@ -2117,7 +2118,8 @@ void fc_fcp_destroy(struct fc_lport *lp) | |||
| 2117 | struct fc_fcp_internal *si = fc_get_scsi_internal(lp); | 2118 | struct fc_fcp_internal *si = fc_get_scsi_internal(lp); |
| 2118 | 2119 | ||
| 2119 | if (!list_empty(&si->scsi_pkt_queue)) | 2120 | if (!list_empty(&si->scsi_pkt_queue)) |
| 2120 | printk(KERN_ERR "Leaked scsi packets.\n"); | 2121 | printk(KERN_ERR "libfc: Leaked SCSI packets when destroying " |
| 2122 | "port (%6x)\n", fc_host_port_id(lp->host)); | ||
| 2121 | 2123 | ||
| 2122 | mempool_destroy(si->scsi_pkt_pool); | 2124 | mempool_destroy(si->scsi_pkt_pool); |
| 2123 | kfree(si); | 2125 | kfree(si); |
| @@ -2166,7 +2168,8 @@ static int __init libfc_init(void) | |||
| 2166 | sizeof(struct fc_fcp_pkt), | 2168 | sizeof(struct fc_fcp_pkt), |
| 2167 | 0, SLAB_HWCACHE_ALIGN, NULL); | 2169 | 0, SLAB_HWCACHE_ALIGN, NULL); |
| 2168 | if (scsi_pkt_cachep == NULL) { | 2170 | if (scsi_pkt_cachep == NULL) { |
| 2169 | FC_DBG("Unable to allocate SRB cache...module load failed!"); | 2171 | printk(KERN_ERR "libfc: Unable to allocate SRB cache, " |
| 2172 | "module load failed!"); | ||
| 2170 | return -ENOMEM; | 2173 | return -ENOMEM; |
| 2171 | } | 2174 | } |
| 2172 | 2175 | ||
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index e0c247724d2b..745fa5555d6a 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c | |||
| @@ -101,14 +101,6 @@ | |||
| 101 | 101 | ||
| 102 | #define DNS_DELAY 3 /* Discovery delay after RSCN (in seconds)*/ | 102 | #define DNS_DELAY 3 /* Discovery delay after RSCN (in seconds)*/ |
| 103 | 103 | ||
| 104 | static int fc_lport_debug; | ||
| 105 | |||
| 106 | #define FC_DEBUG_LPORT(fmt...) \ | ||
| 107 | do { \ | ||
| 108 | if (fc_lport_debug) \ | ||
| 109 | FC_DBG(fmt); \ | ||
| 110 | } while (0) | ||
| 111 | |||
| 112 | static void fc_lport_error(struct fc_lport *, struct fc_frame *); | 104 | static void fc_lport_error(struct fc_lport *, struct fc_frame *); |
| 113 | 105 | ||
| 114 | static void fc_lport_enter_reset(struct fc_lport *); | 106 | static void fc_lport_enter_reset(struct fc_lport *); |
| @@ -151,8 +143,8 @@ static void fc_lport_rport_callback(struct fc_lport *lport, | |||
| 151 | struct fc_rport *rport, | 143 | struct fc_rport *rport, |
| 152 | enum fc_rport_event event) | 144 | enum fc_rport_event event) |
| 153 | { | 145 | { |
| 154 | FC_DEBUG_LPORT("Received a %d event for port (%6x)\n", event, | 146 | FC_LPORT_DBG(lport, "Received a %d event for port (%6x)\n", event, |
| 155 | rport->port_id); | 147 | rport->port_id); |
| 156 | 148 | ||
| 157 | switch (event) { | 149 | switch (event) { |
| 158 | case RPORT_EV_CREATED: | 150 | case RPORT_EV_CREATED: |
| @@ -162,19 +154,19 @@ static void fc_lport_rport_callback(struct fc_lport *lport, | |||
| 162 | lport->dns_rp = rport; | 154 | lport->dns_rp = rport; |
| 163 | fc_lport_enter_rpn_id(lport); | 155 | fc_lport_enter_rpn_id(lport); |
| 164 | } else { | 156 | } else { |
| 165 | FC_DEBUG_LPORT("Received an CREATED event on " | 157 | FC_LPORT_DBG(lport, "Received an CREATED event " |
| 166 | "port (%6x) for the directory " | 158 | "on port (%6x) for the directory " |
| 167 | "server, but the lport is not " | 159 | "server, but the lport is not " |
| 168 | "in the DNS state, it's in the " | 160 | "in the DNS state, it's in the " |
| 169 | "%d state", rport->port_id, | 161 | "%d state", rport->port_id, |
| 170 | lport->state); | 162 | lport->state); |
| 171 | lport->tt.rport_logoff(rport); | 163 | lport->tt.rport_logoff(rport); |
| 172 | } | 164 | } |
| 173 | mutex_unlock(&lport->lp_mutex); | 165 | mutex_unlock(&lport->lp_mutex); |
| 174 | } else | 166 | } else |
| 175 | FC_DEBUG_LPORT("Received an event for port (%6x) " | 167 | FC_LPORT_DBG(lport, "Received an event for port (%6x) " |
| 176 | "which is not the directory server\n", | 168 | "which is not the directory server\n", |
| 177 | rport->port_id); | 169 | rport->port_id); |
| 178 | break; | 170 | break; |
| 179 | case RPORT_EV_LOGO: | 171 | case RPORT_EV_LOGO: |
| 180 | case RPORT_EV_FAILED: | 172 | case RPORT_EV_FAILED: |
| @@ -185,9 +177,9 @@ static void fc_lport_rport_callback(struct fc_lport *lport, | |||
| 185 | mutex_unlock(&lport->lp_mutex); | 177 | mutex_unlock(&lport->lp_mutex); |
| 186 | 178 | ||
| 187 | } else | 179 | } else |
| 188 | FC_DEBUG_LPORT("Received an event for port (%6x) " | 180 | FC_LPORT_DBG(lport, "Received an event for port (%6x) " |
| 189 | "which is not the directory server\n", | 181 | "which is not the directory server\n", |
| 190 | rport->port_id); | 182 | rport->port_id); |
| 191 | break; | 183 | break; |
| 192 | case RPORT_EV_NONE: | 184 | case RPORT_EV_NONE: |
| 193 | break; | 185 | break; |
| @@ -363,8 +355,8 @@ static void fc_lport_add_fc4_type(struct fc_lport *lport, enum fc_fh_type type) | |||
| 363 | static void fc_lport_recv_rlir_req(struct fc_seq *sp, struct fc_frame *fp, | 355 | static void fc_lport_recv_rlir_req(struct fc_seq *sp, struct fc_frame *fp, |
| 364 | struct fc_lport *lport) | 356 | struct fc_lport *lport) |
| 365 | { | 357 | { |
| 366 | FC_DEBUG_LPORT("Received RLIR request while in state %s\n", | 358 | FC_LPORT_DBG(lport, "Received RLIR request while in state %s\n", |
| 367 | fc_lport_state(lport)); | 359 | fc_lport_state(lport)); |
| 368 | 360 | ||
| 369 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); | 361 | lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL); |
| 370 | fc_frame_free(fp); | 362 | fc_frame_free(fp); |
| @@ -389,8 +381,8 @@ static void fc_lport_recv_echo_req(struct fc_seq *sp, struct fc_frame *in_fp, | |||
| 389 | void *dp; | 381 | void *dp; |
| 390 | u32 f_ctl; | 382 | u32 f_ctl; |
| 391 | 383 | ||
| 392 | FC_DEBUG_LPORT("Received RLIR request while in state %s\n", | 384 | FC_LPORT_DBG(lport, "Received RLIR request while in state %s\n", |
| 393 | fc_lport_state(lport)); | 385 | fc_lport_state(lport)); |
| 394 | 386 | ||
| 395 | len = fr_len(in_fp) - sizeof(struct fc_frame_header); | 387 | len = fr_len(in_fp) - sizeof(struct fc_frame_header); |
| 396 | pp = fc_frame_payload_get(in_fp, len); | 388 | pp = fc_frame_payload_get(in_fp, len); |
| @@ -437,8 +429,8 @@ static void fc_lport_recv_rnid_req(struct fc_seq *sp, struct fc_frame *in_fp, | |||
| 437 | size_t len; | 429 | size_t len; |
| 438 | u32 f_ctl; | 430 | u32 f_ctl; |
| 439 | 431 | ||
| 440 | FC_DEBUG_LPORT("Received RNID request while in state %s\n", | 432 | FC_LPORT_DBG(lport, "Received RNID request while in state %s\n", |
| 441 | fc_lport_state(lport)); | 433 | fc_lport_state(lport)); |
| 442 | 434 | ||
| 443 | req = fc_frame_payload_get(in_fp, sizeof(*req)); | 435 | req = fc_frame_payload_get(in_fp, sizeof(*req)); |
| 444 | if (!req) { | 436 | if (!req) { |
| @@ -498,8 +490,8 @@ static void fc_lport_recv_adisc_req(struct fc_seq *sp, struct fc_frame *in_fp, | |||
| 498 | size_t len; | 490 | size_t len; |
| 499 | u32 f_ctl; | 491 | u32 f_ctl; |
| 500 | 492 | ||
| 501 | FC_DEBUG_LPORT("Received ADISC request while in state %s\n", | 493 | FC_LPORT_DBG(lport, "Received ADISC request while in state %s\n", |
| 502 | fc_lport_state(lport)); | 494 | fc_lport_state(lport)); |
| 503 | 495 | ||
| 504 | req = fc_frame_payload_get(in_fp, sizeof(*req)); | 496 | req = fc_frame_payload_get(in_fp, sizeof(*req)); |
| 505 | if (!req) { | 497 | if (!req) { |
| @@ -574,8 +566,8 @@ EXPORT_SYMBOL(fc_fabric_login); | |||
| 574 | */ | 566 | */ |
| 575 | void fc_linkup(struct fc_lport *lport) | 567 | void fc_linkup(struct fc_lport *lport) |
| 576 | { | 568 | { |
| 577 | FC_DEBUG_LPORT("Link is up for port (%6x)\n", | 569 | printk(KERN_INFO "libfc: Link up on port (%6x)\n", |
| 578 | fc_host_port_id(lport->host)); | 570 | fc_host_port_id(lport->host)); |
| 579 | 571 | ||
| 580 | mutex_lock(&lport->lp_mutex); | 572 | mutex_lock(&lport->lp_mutex); |
| 581 | if (!lport->link_up) { | 573 | if (!lport->link_up) { |
| @@ -595,8 +587,8 @@ EXPORT_SYMBOL(fc_linkup); | |||
| 595 | void fc_linkdown(struct fc_lport *lport) | 587 | void fc_linkdown(struct fc_lport *lport) |
| 596 | { | 588 | { |
| 597 | mutex_lock(&lport->lp_mutex); | 589 | mutex_lock(&lport->lp_mutex); |
| 598 | FC_DEBUG_LPORT("Link is down for port (%6x)\n", | 590 | printk(KERN_INFO "libfc: Link down on port (%6x)\n", |
| 599 | fc_host_port_id(lport->host)); | 591 | fc_host_port_id(lport->host)); |
| 600 | 592 | ||
| 601 | if (lport->link_up) { | 593 | if (lport->link_up) { |
| 602 | lport->link_up = 0; | 594 | lport->link_up = 0; |
| @@ -701,12 +693,11 @@ void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event) | |||
| 701 | { | 693 | { |
| 702 | switch (event) { | 694 | switch (event) { |
| 703 | case DISC_EV_SUCCESS: | 695 | case DISC_EV_SUCCESS: |
| 704 | FC_DEBUG_LPORT("Got a SUCCESS event for port (%6x)\n", | 696 | FC_LPORT_DBG(lport, "Discovery succeeded\n"); |
| 705 | fc_host_port_id(lport->host)); | ||
| 706 | break; | 697 | break; |
| 707 | case DISC_EV_FAILED: | 698 | case DISC_EV_FAILED: |
| 708 | FC_DEBUG_LPORT("Got a FAILED event for port (%6x)\n", | 699 | printk(KERN_ERR "libfc: Discovery failed for port (%6x)\n", |
| 709 | fc_host_port_id(lport->host)); | 700 | fc_host_port_id(lport->host)); |
| 710 | mutex_lock(&lport->lp_mutex); | 701 | mutex_lock(&lport->lp_mutex); |
| 711 | fc_lport_enter_reset(lport); | 702 | fc_lport_enter_reset(lport); |
| 712 | mutex_unlock(&lport->lp_mutex); | 703 | mutex_unlock(&lport->lp_mutex); |
| @@ -726,8 +717,8 @@ void fc_lport_disc_callback(struct fc_lport *lport, enum fc_disc_event event) | |||
| 726 | */ | 717 | */ |
| 727 | static void fc_lport_enter_ready(struct fc_lport *lport) | 718 | static void fc_lport_enter_ready(struct fc_lport *lport) |
| 728 | { | 719 | { |
| 729 | FC_DEBUG_LPORT("Port (%6x) entered Ready from state %s\n", | 720 | FC_LPORT_DBG(lport, "Entered READY from state %s\n", |
| 730 | fc_host_port_id(lport->host), fc_lport_state(lport)); | 721 | fc_lport_state(lport)); |
| 731 | 722 | ||
| 732 | fc_lport_state_enter(lport, LPORT_ST_READY); | 723 | fc_lport_state_enter(lport, LPORT_ST_READY); |
| 733 | 724 | ||
| @@ -762,8 +753,8 @@ static void fc_lport_recv_flogi_req(struct fc_seq *sp_in, | |||
| 762 | u32 local_fid; | 753 | u32 local_fid; |
| 763 | u32 f_ctl; | 754 | u32 f_ctl; |
| 764 | 755 | ||
| 765 | FC_DEBUG_LPORT("Received FLOGI request while in state %s\n", | 756 | FC_LPORT_DBG(lport, "Received FLOGI request while in state %s\n", |
| 766 | fc_lport_state(lport)); | 757 | fc_lport_state(lport)); |
| 767 | 758 | ||
| 768 | fh = fc_frame_header_get(rx_fp); | 759 | fh = fc_frame_header_get(rx_fp); |
| 769 | remote_fid = ntoh24(fh->fh_s_id); | 760 | remote_fid = ntoh24(fh->fh_s_id); |
| @@ -772,12 +763,11 @@ static void fc_lport_recv_flogi_req(struct fc_seq *sp_in, | |||
| 772 | goto out; | 763 | goto out; |
| 773 | remote_wwpn = get_unaligned_be64(&flp->fl_wwpn); | 764 | remote_wwpn = get_unaligned_be64(&flp->fl_wwpn); |
| 774 | if (remote_wwpn == lport->wwpn) { | 765 | if (remote_wwpn == lport->wwpn) { |
| 775 | FC_DBG("FLOGI from port with same WWPN %llx " | 766 | printk(KERN_WARNING "libfc: Received FLOGI from port " |
| 776 | "possible configuration error\n", | 767 | "with same WWPN %llx\n", remote_wwpn); |
| 777 | (unsigned long long)remote_wwpn); | ||
| 778 | goto out; | 768 | goto out; |
| 779 | } | 769 | } |
| 780 | FC_DBG("FLOGI from port WWPN %llx\n", (unsigned long long)remote_wwpn); | 770 | FC_LPORT_DBG(lport, "FLOGI from port WWPN %llx\n", remote_wwpn); |
| 781 | 771 | ||
| 782 | /* | 772 | /* |
| 783 | * XXX what is the right thing to do for FIDs? | 773 | * XXX what is the right thing to do for FIDs? |
| @@ -909,7 +899,8 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp, | |||
| 909 | } | 899 | } |
| 910 | } | 900 | } |
| 911 | } else { | 901 | } else { |
| 912 | FC_DBG("dropping invalid frame (eof %x)\n", fr_eof(fp)); | 902 | FC_LPORT_DBG(lport, "dropping invalid frame (eof %x)\n", |
| 903 | fr_eof(fp)); | ||
| 913 | fc_frame_free(fp); | 904 | fc_frame_free(fp); |
| 914 | } | 905 | } |
| 915 | mutex_unlock(&lport->lp_mutex); | 906 | mutex_unlock(&lport->lp_mutex); |
| @@ -947,8 +938,8 @@ EXPORT_SYMBOL(fc_lport_reset); | |||
| 947 | */ | 938 | */ |
| 948 | static void fc_lport_enter_reset(struct fc_lport *lport) | 939 | static void fc_lport_enter_reset(struct fc_lport *lport) |
| 949 | { | 940 | { |
| 950 | FC_DEBUG_LPORT("Port (%6x) entered RESET state from %s state\n", | 941 | FC_LPORT_DBG(lport, "Entered RESET state from %s state\n", |
| 951 | fc_host_port_id(lport->host), fc_lport_state(lport)); | 942 | fc_lport_state(lport)); |
| 952 | 943 | ||
| 953 | fc_lport_state_enter(lport, LPORT_ST_RESET); | 944 | fc_lport_state_enter(lport, LPORT_ST_RESET); |
| 954 | 945 | ||
| @@ -982,9 +973,9 @@ static void fc_lport_enter_reset(struct fc_lport *lport) | |||
| 982 | static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp) | 973 | static void fc_lport_error(struct fc_lport *lport, struct fc_frame *fp) |
| 983 | { | 974 | { |
| 984 | unsigned long delay = 0; | 975 | unsigned long delay = 0; |
| 985 | FC_DEBUG_LPORT("Error %ld in state %s, retries %d\n", | 976 | FC_LPORT_DBG(lport, "Error %ld in state %s, retries %d\n", |
| 986 | PTR_ERR(fp), fc_lport_state(lport), | 977 | PTR_ERR(fp), fc_lport_state(lport), |
| 987 | lport->retry_count); | 978 | lport->retry_count); |
| 988 | 979 | ||
| 989 | if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) { | 980 | if (!fp || PTR_ERR(fp) == -FC_EX_TIMEOUT) { |
| 990 | /* | 981 | /* |
| @@ -1040,11 +1031,11 @@ static void fc_lport_rft_id_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 1040 | 1031 | ||
| 1041 | mutex_lock(&lport->lp_mutex); | 1032 | mutex_lock(&lport->lp_mutex); |
| 1042 | 1033 | ||
| 1043 | FC_DEBUG_LPORT("Received a RFT_ID response\n"); | 1034 | FC_LPORT_DBG(lport, "Received a RFT_ID response\n"); |
| 1044 | 1035 | ||
| 1045 | if (lport->state != LPORT_ST_RFT_ID) { | 1036 | if (lport->state != LPORT_ST_RFT_ID) { |
| 1046 | FC_DBG("Received a RFT_ID response, but in state %s\n", | 1037 | FC_LPORT_DBG(lport, "Received a RFT_ID response, but in state " |
| 1047 | fc_lport_state(lport)); | 1038 | "%s\n", fc_lport_state(lport)); |
| 1048 | if (IS_ERR(fp)) | 1039 | if (IS_ERR(fp)) |
| 1049 | goto err; | 1040 | goto err; |
| 1050 | goto out; | 1041 | goto out; |
| @@ -1094,11 +1085,11 @@ static void fc_lport_rpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 1094 | 1085 | ||
| 1095 | mutex_lock(&lport->lp_mutex); | 1086 | mutex_lock(&lport->lp_mutex); |
| 1096 | 1087 | ||
| 1097 | FC_DEBUG_LPORT("Received a RPN_ID response\n"); | 1088 | FC_LPORT_DBG(lport, "Received a RPN_ID response\n"); |
| 1098 | 1089 | ||
| 1099 | if (lport->state != LPORT_ST_RPN_ID) { | 1090 | if (lport->state != LPORT_ST_RPN_ID) { |
| 1100 | FC_DBG("Received a RPN_ID response, but in state %s\n", | 1091 | FC_LPORT_DBG(lport, "Received a RPN_ID response, but in state " |
| 1101 | fc_lport_state(lport)); | 1092 | "%s\n", fc_lport_state(lport)); |
| 1102 | if (IS_ERR(fp)) | 1093 | if (IS_ERR(fp)) |
| 1103 | goto err; | 1094 | goto err; |
| 1104 | goto out; | 1095 | goto out; |
| @@ -1146,11 +1137,11 @@ static void fc_lport_scr_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 1146 | 1137 | ||
| 1147 | mutex_lock(&lport->lp_mutex); | 1138 | mutex_lock(&lport->lp_mutex); |
| 1148 | 1139 | ||
| 1149 | FC_DEBUG_LPORT("Received a SCR response\n"); | 1140 | FC_LPORT_DBG(lport, "Received a SCR response\n"); |
| 1150 | 1141 | ||
| 1151 | if (lport->state != LPORT_ST_SCR) { | 1142 | if (lport->state != LPORT_ST_SCR) { |
| 1152 | FC_DBG("Received a SCR response, but in state %s\n", | 1143 | FC_LPORT_DBG(lport, "Received a SCR response, but in state " |
| 1153 | fc_lport_state(lport)); | 1144 | "%s\n", fc_lport_state(lport)); |
| 1154 | if (IS_ERR(fp)) | 1145 | if (IS_ERR(fp)) |
| 1155 | goto err; | 1146 | goto err; |
| 1156 | goto out; | 1147 | goto out; |
| @@ -1184,8 +1175,8 @@ static void fc_lport_enter_scr(struct fc_lport *lport) | |||
| 1184 | { | 1175 | { |
| 1185 | struct fc_frame *fp; | 1176 | struct fc_frame *fp; |
| 1186 | 1177 | ||
| 1187 | FC_DEBUG_LPORT("Port (%6x) entered SCR state from %s state\n", | 1178 | FC_LPORT_DBG(lport, "Entered SCR state from %s state\n", |
| 1188 | fc_host_port_id(lport->host), fc_lport_state(lport)); | 1179 | fc_lport_state(lport)); |
| 1189 | 1180 | ||
| 1190 | fc_lport_state_enter(lport, LPORT_ST_SCR); | 1181 | fc_lport_state_enter(lport, LPORT_ST_SCR); |
| 1191 | 1182 | ||
| @@ -1213,8 +1204,8 @@ static void fc_lport_enter_rft_id(struct fc_lport *lport) | |||
| 1213 | struct fc_ns_fts *lps; | 1204 | struct fc_ns_fts *lps; |
| 1214 | int i; | 1205 | int i; |
| 1215 | 1206 | ||
| 1216 | FC_DEBUG_LPORT("Port (%6x) entered RFT_ID state from %s state\n", | 1207 | FC_LPORT_DBG(lport, "Entered RFT_ID state from %s state\n", |
| 1217 | fc_host_port_id(lport->host), fc_lport_state(lport)); | 1208 | fc_lport_state(lport)); |
| 1218 | 1209 | ||
| 1219 | fc_lport_state_enter(lport, LPORT_ST_RFT_ID); | 1210 | fc_lport_state_enter(lport, LPORT_ST_RFT_ID); |
| 1220 | 1211 | ||
| @@ -1253,8 +1244,8 @@ static void fc_lport_enter_rpn_id(struct fc_lport *lport) | |||
| 1253 | { | 1244 | { |
| 1254 | struct fc_frame *fp; | 1245 | struct fc_frame *fp; |
| 1255 | 1246 | ||
| 1256 | FC_DEBUG_LPORT("Port (%6x) entered RPN_ID state from %s state\n", | 1247 | FC_LPORT_DBG(lport, "Entered RPN_ID state from %s state\n", |
| 1257 | fc_host_port_id(lport->host), fc_lport_state(lport)); | 1248 | fc_lport_state(lport)); |
| 1258 | 1249 | ||
| 1259 | fc_lport_state_enter(lport, LPORT_ST_RPN_ID); | 1250 | fc_lport_state_enter(lport, LPORT_ST_RPN_ID); |
| 1260 | 1251 | ||
| @@ -1294,8 +1285,8 @@ static void fc_lport_enter_dns(struct fc_lport *lport) | |||
| 1294 | dp.ids.roles = FC_RPORT_ROLE_UNKNOWN; | 1285 | dp.ids.roles = FC_RPORT_ROLE_UNKNOWN; |
| 1295 | dp.lp = lport; | 1286 | dp.lp = lport; |
| 1296 | 1287 | ||
| 1297 | FC_DEBUG_LPORT("Port (%6x) entered DNS state from %s state\n", | 1288 | FC_LPORT_DBG(lport, "Entered DNS state from %s state\n", |
| 1298 | fc_host_port_id(lport->host), fc_lport_state(lport)); | 1289 | fc_lport_state(lport)); |
| 1299 | 1290 | ||
| 1300 | fc_lport_state_enter(lport, LPORT_ST_DNS); | 1291 | fc_lport_state_enter(lport, LPORT_ST_DNS); |
| 1301 | 1292 | ||
| @@ -1374,11 +1365,11 @@ static void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 1374 | 1365 | ||
| 1375 | mutex_lock(&lport->lp_mutex); | 1366 | mutex_lock(&lport->lp_mutex); |
| 1376 | 1367 | ||
| 1377 | FC_DEBUG_LPORT("Received a LOGO response\n"); | 1368 | FC_LPORT_DBG(lport, "Received a LOGO response\n"); |
| 1378 | 1369 | ||
| 1379 | if (lport->state != LPORT_ST_LOGO) { | 1370 | if (lport->state != LPORT_ST_LOGO) { |
| 1380 | FC_DBG("Received a LOGO response, but in state %s\n", | 1371 | FC_LPORT_DBG(lport, "Received a LOGO response, but in state " |
| 1381 | fc_lport_state(lport)); | 1372 | "%s\n", fc_lport_state(lport)); |
| 1382 | if (IS_ERR(fp)) | 1373 | if (IS_ERR(fp)) |
| 1383 | goto err; | 1374 | goto err; |
| 1384 | goto out; | 1375 | goto out; |
| @@ -1413,8 +1404,8 @@ static void fc_lport_enter_logo(struct fc_lport *lport) | |||
| 1413 | struct fc_frame *fp; | 1404 | struct fc_frame *fp; |
| 1414 | struct fc_els_logo *logo; | 1405 | struct fc_els_logo *logo; |
| 1415 | 1406 | ||
| 1416 | FC_DEBUG_LPORT("Port (%6x) entered LOGO state from %s state\n", | 1407 | FC_LPORT_DBG(lport, "Entered LOGO state from %s state\n", |
| 1417 | fc_host_port_id(lport->host), fc_lport_state(lport)); | 1408 | fc_lport_state(lport)); |
| 1418 | 1409 | ||
| 1419 | fc_lport_state_enter(lport, LPORT_ST_LOGO); | 1410 | fc_lport_state_enter(lport, LPORT_ST_LOGO); |
| 1420 | 1411 | ||
| @@ -1456,11 +1447,11 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 1456 | 1447 | ||
| 1457 | mutex_lock(&lport->lp_mutex); | 1448 | mutex_lock(&lport->lp_mutex); |
| 1458 | 1449 | ||
| 1459 | FC_DEBUG_LPORT("Received a FLOGI response\n"); | 1450 | FC_LPORT_DBG(lport, "Received a FLOGI response\n"); |
| 1460 | 1451 | ||
| 1461 | if (lport->state != LPORT_ST_FLOGI) { | 1452 | if (lport->state != LPORT_ST_FLOGI) { |
| 1462 | FC_DBG("Received a FLOGI response, but in state %s\n", | 1453 | FC_LPORT_DBG(lport, "Received a FLOGI response, but in state " |
| 1463 | fc_lport_state(lport)); | 1454 | "%s\n", fc_lport_state(lport)); |
| 1464 | if (IS_ERR(fp)) | 1455 | if (IS_ERR(fp)) |
| 1465 | goto err; | 1456 | goto err; |
| 1466 | goto out; | 1457 | goto out; |
| @@ -1475,7 +1466,8 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 1475 | did = ntoh24(fh->fh_d_id); | 1466 | did = ntoh24(fh->fh_d_id); |
| 1476 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { | 1467 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { |
| 1477 | 1468 | ||
| 1478 | FC_DEBUG_LPORT("Assigned fid %x\n", did); | 1469 | printk(KERN_INFO "libfc: Assigned FID (%6x) in FLOGI response\n", |
| 1470 | did); | ||
| 1479 | fc_host_port_id(lport->host) = did; | 1471 | fc_host_port_id(lport->host) = did; |
| 1480 | 1472 | ||
| 1481 | flp = fc_frame_payload_get(fp, sizeof(*flp)); | 1473 | flp = fc_frame_payload_get(fp, sizeof(*flp)); |
| @@ -1494,7 +1486,8 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 1494 | if (e_d_tov > lport->e_d_tov) | 1486 | if (e_d_tov > lport->e_d_tov) |
| 1495 | lport->e_d_tov = e_d_tov; | 1487 | lport->e_d_tov = e_d_tov; |
| 1496 | lport->r_a_tov = 2 * e_d_tov; | 1488 | lport->r_a_tov = 2 * e_d_tov; |
| 1497 | FC_DBG("Point-to-Point mode\n"); | 1489 | printk(KERN_INFO "libfc: Port (%6x) entered " |
| 1490 | "point to point mode\n", did); | ||
| 1498 | fc_lport_ptp_setup(lport, ntoh24(fh->fh_s_id), | 1491 | fc_lport_ptp_setup(lport, ntoh24(fh->fh_s_id), |
| 1499 | get_unaligned_be64( | 1492 | get_unaligned_be64( |
| 1500 | &flp->fl_wwpn), | 1493 | &flp->fl_wwpn), |
| @@ -1517,7 +1510,7 @@ static void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 1517 | } | 1510 | } |
| 1518 | } | 1511 | } |
| 1519 | } else { | 1512 | } else { |
| 1520 | FC_DBG("bad FLOGI response\n"); | 1513 | FC_LPORT_DBG(lport, "Bad FLOGI response\n"); |
| 1521 | } | 1514 | } |
| 1522 | 1515 | ||
| 1523 | out: | 1516 | out: |
| @@ -1537,7 +1530,8 @@ void fc_lport_enter_flogi(struct fc_lport *lport) | |||
| 1537 | { | 1530 | { |
| 1538 | struct fc_frame *fp; | 1531 | struct fc_frame *fp; |
| 1539 | 1532 | ||
| 1540 | FC_DEBUG_LPORT("Processing FLOGI state\n"); | 1533 | FC_LPORT_DBG(lport, "Entered FLOGI state from %s state\n", |
| 1534 | fc_lport_state(lport)); | ||
| 1541 | 1535 | ||
| 1542 | fc_lport_state_enter(lport, LPORT_ST_FLOGI); | 1536 | fc_lport_state_enter(lport, LPORT_ST_FLOGI); |
| 1543 | 1537 | ||
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 7bfbff7e0efb..7162385f52eb 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c | |||
| @@ -55,14 +55,6 @@ | |||
| 55 | #include <scsi/libfc.h> | 55 | #include <scsi/libfc.h> |
| 56 | #include <scsi/fc_encode.h> | 56 | #include <scsi/fc_encode.h> |
| 57 | 57 | ||
| 58 | static int fc_rport_debug; | ||
| 59 | |||
| 60 | #define FC_DEBUG_RPORT(fmt...) \ | ||
| 61 | do { \ | ||
| 62 | if (fc_rport_debug) \ | ||
| 63 | FC_DBG(fmt); \ | ||
| 64 | } while (0) | ||
| 65 | |||
| 66 | struct workqueue_struct *rport_event_queue; | 58 | struct workqueue_struct *rport_event_queue; |
| 67 | 59 | ||
| 68 | static void fc_rport_enter_plogi(struct fc_rport *); | 60 | static void fc_rport_enter_plogi(struct fc_rport *); |
| @@ -97,7 +89,7 @@ static const char *fc_rport_state_names[] = { | |||
| 97 | static void fc_rport_rogue_destroy(struct device *dev) | 89 | static void fc_rport_rogue_destroy(struct device *dev) |
| 98 | { | 90 | { |
| 99 | struct fc_rport *rport = dev_to_rport(dev); | 91 | struct fc_rport *rport = dev_to_rport(dev); |
| 100 | FC_DEBUG_RPORT("Destroying rogue rport (%6x)\n", rport->port_id); | 92 | FC_RPORT_DBG(rport, "Destroying rogue rport\n"); |
| 101 | kfree(rport); | 93 | kfree(rport); |
| 102 | } | 94 | } |
| 103 | 95 | ||
| @@ -263,8 +255,8 @@ static void fc_rport_work(struct work_struct *work) | |||
| 263 | 255 | ||
| 264 | fc_rport_state_enter(new_rport, RPORT_ST_READY); | 256 | fc_rport_state_enter(new_rport, RPORT_ST_READY); |
| 265 | } else { | 257 | } else { |
| 266 | FC_DBG("Failed to create the rport for port " | 258 | printk(KERN_WARNING "libfc: Failed to allocate " |
| 267 | "(%6x).\n", ids.port_id); | 259 | " memory for rport (%6x)\n", ids.port_id); |
| 268 | event = RPORT_EV_FAILED; | 260 | event = RPORT_EV_FAILED; |
| 269 | } | 261 | } |
| 270 | if (rport->port_id != FC_FID_DIR_SERV) | 262 | if (rport->port_id != FC_FID_DIR_SERV) |
| @@ -309,7 +301,7 @@ int fc_rport_login(struct fc_rport *rport) | |||
| 309 | 301 | ||
| 310 | mutex_lock(&rdata->rp_mutex); | 302 | mutex_lock(&rdata->rp_mutex); |
| 311 | 303 | ||
| 312 | FC_DEBUG_RPORT("Login to port (%6x)\n", rport->port_id); | 304 | FC_RPORT_DBG(rport, "Login to port\n"); |
| 313 | 305 | ||
| 314 | fc_rport_enter_plogi(rport); | 306 | fc_rport_enter_plogi(rport); |
| 315 | 307 | ||
| @@ -329,16 +321,13 @@ int fc_rport_login(struct fc_rport *rport) | |||
| 329 | int fc_rport_logoff(struct fc_rport *rport) | 321 | int fc_rport_logoff(struct fc_rport *rport) |
| 330 | { | 322 | { |
| 331 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 323 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
| 332 | struct fc_lport *lport = rdata->local_port; | ||
| 333 | 324 | ||
| 334 | mutex_lock(&rdata->rp_mutex); | 325 | mutex_lock(&rdata->rp_mutex); |
| 335 | 326 | ||
| 336 | FC_DEBUG_RPORT("Remove port (%6x)\n", rport->port_id); | 327 | FC_RPORT_DBG(rport, "Remove port\n"); |
| 337 | 328 | ||
| 338 | if (rdata->rp_state == RPORT_ST_NONE) { | 329 | if (rdata->rp_state == RPORT_ST_NONE) { |
| 339 | FC_DEBUG_RPORT("(%6x): Port (%6x) in NONE state," | 330 | FC_RPORT_DBG(rport, "Port in NONE state, not removing\n"); |
| 340 | " not removing", fc_host_port_id(lport->host), | ||
| 341 | rport->port_id); | ||
| 342 | mutex_unlock(&rdata->rp_mutex); | 331 | mutex_unlock(&rdata->rp_mutex); |
| 343 | goto out; | 332 | goto out; |
| 344 | } | 333 | } |
| @@ -379,7 +368,7 @@ static void fc_rport_enter_ready(struct fc_rport *rport) | |||
| 379 | 368 | ||
| 380 | fc_rport_state_enter(rport, RPORT_ST_READY); | 369 | fc_rport_state_enter(rport, RPORT_ST_READY); |
| 381 | 370 | ||
| 382 | FC_DEBUG_RPORT("Port (%6x) is Ready\n", rport->port_id); | 371 | FC_RPORT_DBG(rport, "Port is Ready\n"); |
| 383 | 372 | ||
| 384 | rdata->event = RPORT_EV_CREATED; | 373 | rdata->event = RPORT_EV_CREATED; |
| 385 | queue_work(rport_event_queue, &rdata->event_work); | 374 | queue_work(rport_event_queue, &rdata->event_work); |
| @@ -436,8 +425,8 @@ static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp) | |||
| 436 | { | 425 | { |
| 437 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 426 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
| 438 | 427 | ||
| 439 | FC_DEBUG_RPORT("Error %ld in state %s, retries %d\n", | 428 | FC_RPORT_DBG(rport, "Error %ld in state %s, retries %d\n", |
| 440 | PTR_ERR(fp), fc_rport_state(rport), rdata->retries); | 429 | PTR_ERR(fp), fc_rport_state(rport), rdata->retries); |
| 441 | 430 | ||
| 442 | switch (rdata->rp_state) { | 431 | switch (rdata->rp_state) { |
| 443 | case RPORT_ST_PLOGI: | 432 | case RPORT_ST_PLOGI: |
| @@ -479,8 +468,8 @@ static void fc_rport_error_retry(struct fc_rport *rport, struct fc_frame *fp) | |||
| 479 | return fc_rport_error(rport, fp); | 468 | return fc_rport_error(rport, fp); |
| 480 | 469 | ||
| 481 | if (rdata->retries < rdata->local_port->max_rport_retry_count) { | 470 | if (rdata->retries < rdata->local_port->max_rport_retry_count) { |
| 482 | FC_DEBUG_RPORT("Error %ld in state %s, retrying\n", | 471 | FC_RPORT_DBG(rport, "Error %ld in state %s, retrying\n", |
| 483 | PTR_ERR(fp), fc_rport_state(rport)); | 472 | PTR_ERR(fp), fc_rport_state(rport)); |
| 484 | rdata->retries++; | 473 | rdata->retries++; |
| 485 | /* no additional delay on exchange timeouts */ | 474 | /* no additional delay on exchange timeouts */ |
| 486 | if (PTR_ERR(fp) == -FC_EX_TIMEOUT) | 475 | if (PTR_ERR(fp) == -FC_EX_TIMEOUT) |
| @@ -517,12 +506,11 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 517 | 506 | ||
| 518 | mutex_lock(&rdata->rp_mutex); | 507 | mutex_lock(&rdata->rp_mutex); |
| 519 | 508 | ||
| 520 | FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n", | 509 | FC_RPORT_DBG(rport, "Received a PLOGI response\n"); |
| 521 | rport->port_id); | ||
| 522 | 510 | ||
| 523 | if (rdata->rp_state != RPORT_ST_PLOGI) { | 511 | if (rdata->rp_state != RPORT_ST_PLOGI) { |
| 524 | FC_DBG("Received a PLOGI response, but in state %s\n", | 512 | FC_RPORT_DBG(rport, "Received a PLOGI response, but in state " |
| 525 | fc_rport_state(rport)); | 513 | "%s\n", fc_rport_state(rport)); |
| 526 | if (IS_ERR(fp)) | 514 | if (IS_ERR(fp)) |
| 527 | goto err; | 515 | goto err; |
| 528 | goto out; | 516 | goto out; |
| @@ -583,8 +571,8 @@ static void fc_rport_enter_plogi(struct fc_rport *rport) | |||
| 583 | struct fc_lport *lport = rdata->local_port; | 571 | struct fc_lport *lport = rdata->local_port; |
| 584 | struct fc_frame *fp; | 572 | struct fc_frame *fp; |
| 585 | 573 | ||
| 586 | FC_DEBUG_RPORT("Port (%6x) entered PLOGI state from %s state\n", | 574 | FC_RPORT_DBG(rport, "Port entered PLOGI state from %s state\n", |
| 587 | rport->port_id, fc_rport_state(rport)); | 575 | fc_rport_state(rport)); |
| 588 | 576 | ||
| 589 | fc_rport_state_enter(rport, RPORT_ST_PLOGI); | 577 | fc_rport_state_enter(rport, RPORT_ST_PLOGI); |
| 590 | 578 | ||
| @@ -628,12 +616,11 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 628 | 616 | ||
| 629 | mutex_lock(&rdata->rp_mutex); | 617 | mutex_lock(&rdata->rp_mutex); |
| 630 | 618 | ||
| 631 | FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n", | 619 | FC_RPORT_DBG(rport, "Received a PRLI response\n"); |
| 632 | rport->port_id); | ||
| 633 | 620 | ||
| 634 | if (rdata->rp_state != RPORT_ST_PRLI) { | 621 | if (rdata->rp_state != RPORT_ST_PRLI) { |
| 635 | FC_DBG("Received a PRLI response, but in state %s\n", | 622 | FC_RPORT_DBG(rport, "Received a PRLI response, but in state " |
| 636 | fc_rport_state(rport)); | 623 | "%s\n", fc_rport_state(rport)); |
| 637 | if (IS_ERR(fp)) | 624 | if (IS_ERR(fp)) |
| 638 | goto err; | 625 | goto err; |
| 639 | goto out; | 626 | goto out; |
| @@ -663,7 +650,7 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 663 | fc_rport_enter_rtv(rport); | 650 | fc_rport_enter_rtv(rport); |
| 664 | 651 | ||
| 665 | } else { | 652 | } else { |
| 666 | FC_DBG("Bad ELS response\n"); | 653 | FC_RPORT_DBG(rport, "Bad ELS response for PRLI command\n"); |
| 667 | rdata->event = RPORT_EV_FAILED; | 654 | rdata->event = RPORT_EV_FAILED; |
| 668 | fc_rport_state_enter(rport, RPORT_ST_NONE); | 655 | fc_rport_state_enter(rport, RPORT_ST_NONE); |
| 669 | queue_work(rport_event_queue, &rdata->event_work); | 656 | queue_work(rport_event_queue, &rdata->event_work); |
| @@ -695,12 +682,11 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 695 | 682 | ||
| 696 | mutex_lock(&rdata->rp_mutex); | 683 | mutex_lock(&rdata->rp_mutex); |
| 697 | 684 | ||
| 698 | FC_DEBUG_RPORT("Received a LOGO response from port (%6x)\n", | 685 | FC_RPORT_DBG(rport, "Received a LOGO response\n"); |
| 699 | rport->port_id); | ||
| 700 | 686 | ||
| 701 | if (rdata->rp_state != RPORT_ST_LOGO) { | 687 | if (rdata->rp_state != RPORT_ST_LOGO) { |
| 702 | FC_DEBUG_RPORT("Received a LOGO response, but in state %s\n", | 688 | FC_RPORT_DBG(rport, "Received a LOGO response, but in state " |
| 703 | fc_rport_state(rport)); | 689 | "%s\n", fc_rport_state(rport)); |
| 704 | if (IS_ERR(fp)) | 690 | if (IS_ERR(fp)) |
| 705 | goto err; | 691 | goto err; |
| 706 | goto out; | 692 | goto out; |
| @@ -715,7 +701,7 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 715 | if (op == ELS_LS_ACC) { | 701 | if (op == ELS_LS_ACC) { |
| 716 | fc_rport_enter_rtv(rport); | 702 | fc_rport_enter_rtv(rport); |
| 717 | } else { | 703 | } else { |
| 718 | FC_DBG("Bad ELS response\n"); | 704 | FC_RPORT_DBG(rport, "Bad ELS response for LOGO command\n"); |
| 719 | rdata->event = RPORT_EV_LOGO; | 705 | rdata->event = RPORT_EV_LOGO; |
| 720 | fc_rport_state_enter(rport, RPORT_ST_NONE); | 706 | fc_rport_state_enter(rport, RPORT_ST_NONE); |
| 721 | queue_work(rport_event_queue, &rdata->event_work); | 707 | queue_work(rport_event_queue, &rdata->event_work); |
| @@ -745,8 +731,8 @@ static void fc_rport_enter_prli(struct fc_rport *rport) | |||
| 745 | } *pp; | 731 | } *pp; |
| 746 | struct fc_frame *fp; | 732 | struct fc_frame *fp; |
| 747 | 733 | ||
| 748 | FC_DEBUG_RPORT("Port (%6x) entered PRLI state from %s state\n", | 734 | FC_RPORT_DBG(rport, "Port entered PRLI state from %s state\n", |
| 749 | rport->port_id, fc_rport_state(rport)); | 735 | fc_rport_state(rport)); |
| 750 | 736 | ||
| 751 | fc_rport_state_enter(rport, RPORT_ST_PRLI); | 737 | fc_rport_state_enter(rport, RPORT_ST_PRLI); |
| 752 | 738 | ||
| @@ -784,12 +770,11 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 784 | 770 | ||
| 785 | mutex_lock(&rdata->rp_mutex); | 771 | mutex_lock(&rdata->rp_mutex); |
| 786 | 772 | ||
| 787 | FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n", | 773 | FC_RPORT_DBG(rport, "Received a RTV response\n"); |
| 788 | rport->port_id); | ||
| 789 | 774 | ||
| 790 | if (rdata->rp_state != RPORT_ST_RTV) { | 775 | if (rdata->rp_state != RPORT_ST_RTV) { |
| 791 | FC_DBG("Received a RTV response, but in state %s\n", | 776 | FC_RPORT_DBG(rport, "Received a RTV response, but in state " |
| 792 | fc_rport_state(rport)); | 777 | "%s\n", fc_rport_state(rport)); |
| 793 | if (IS_ERR(fp)) | 778 | if (IS_ERR(fp)) |
| 794 | goto err; | 779 | goto err; |
| 795 | goto out; | 780 | goto out; |
| @@ -844,8 +829,8 @@ static void fc_rport_enter_rtv(struct fc_rport *rport) | |||
| 844 | struct fc_rport_libfc_priv *rdata = rport->dd_data; | 829 | struct fc_rport_libfc_priv *rdata = rport->dd_data; |
| 845 | struct fc_lport *lport = rdata->local_port; | 830 | struct fc_lport *lport = rdata->local_port; |
| 846 | 831 | ||
| 847 | FC_DEBUG_RPORT("Port (%6x) entered RTV state from %s state\n", | 832 | FC_RPORT_DBG(rport, "Port entered RTV state from %s state\n", |
| 848 | rport->port_id, fc_rport_state(rport)); | 833 | fc_rport_state(rport)); |
| 849 | 834 | ||
| 850 | fc_rport_state_enter(rport, RPORT_ST_RTV); | 835 | fc_rport_state_enter(rport, RPORT_ST_RTV); |
| 851 | 836 | ||
| @@ -875,8 +860,8 @@ static void fc_rport_enter_logo(struct fc_rport *rport) | |||
| 875 | struct fc_lport *lport = rdata->local_port; | 860 | struct fc_lport *lport = rdata->local_port; |
| 876 | struct fc_frame *fp; | 861 | struct fc_frame *fp; |
| 877 | 862 | ||
| 878 | FC_DEBUG_RPORT("Port (%6x) entered LOGO state from %s state\n", | 863 | FC_RPORT_DBG(rport, "Port entered LOGO state from %s state\n", |
| 879 | rport->port_id, fc_rport_state(rport)); | 864 | fc_rport_state(rport)); |
| 880 | 865 | ||
| 881 | fc_rport_state_enter(rport, RPORT_ST_LOGO); | 866 | fc_rport_state_enter(rport, RPORT_ST_LOGO); |
| 882 | 867 | ||
| @@ -983,14 +968,13 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport, | |||
| 983 | 968 | ||
| 984 | fh = fc_frame_header_get(fp); | 969 | fh = fc_frame_header_get(fp); |
| 985 | 970 | ||
| 986 | FC_DEBUG_RPORT("Received PLOGI request from port (%6x) " | 971 | FC_RPORT_DBG(rport, "Received PLOGI request while in state %s\n", |
| 987 | "while in state %s\n", ntoh24(fh->fh_s_id), | 972 | fc_rport_state(rport)); |
| 988 | fc_rport_state(rport)); | ||
| 989 | 973 | ||
| 990 | sid = ntoh24(fh->fh_s_id); | 974 | sid = ntoh24(fh->fh_s_id); |
| 991 | pl = fc_frame_payload_get(fp, sizeof(*pl)); | 975 | pl = fc_frame_payload_get(fp, sizeof(*pl)); |
| 992 | if (!pl) { | 976 | if (!pl) { |
| 993 | FC_DBG("incoming PLOGI from %x too short\n", sid); | 977 | FC_RPORT_DBG(rport, "Received PLOGI too short\n"); |
| 994 | WARN_ON(1); | 978 | WARN_ON(1); |
| 995 | /* XXX TBD: send reject? */ | 979 | /* XXX TBD: send reject? */ |
| 996 | fc_frame_free(fp); | 980 | fc_frame_free(fp); |
| @@ -1012,26 +996,26 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport, | |||
| 1012 | */ | 996 | */ |
| 1013 | switch (rdata->rp_state) { | 997 | switch (rdata->rp_state) { |
| 1014 | case RPORT_ST_INIT: | 998 | case RPORT_ST_INIT: |
| 1015 | FC_DEBUG_RPORT("incoming PLOGI from %6x wwpn %llx state INIT " | 999 | FC_RPORT_DBG(rport, "Received PLOGI, wwpn %llx state INIT " |
| 1016 | "- reject\n", sid, (unsigned long long)wwpn); | 1000 | "- reject\n", (unsigned long long)wwpn); |
| 1017 | reject = ELS_RJT_UNSUP; | 1001 | reject = ELS_RJT_UNSUP; |
| 1018 | break; | 1002 | break; |
| 1019 | case RPORT_ST_PLOGI: | 1003 | case RPORT_ST_PLOGI: |
| 1020 | FC_DEBUG_RPORT("incoming PLOGI from %x in PLOGI state %d\n", | 1004 | FC_RPORT_DBG(rport, "Received PLOGI in PLOGI state %d\n", |
| 1021 | sid, rdata->rp_state); | 1005 | rdata->rp_state); |
| 1022 | if (wwpn < lport->wwpn) | 1006 | if (wwpn < lport->wwpn) |
| 1023 | reject = ELS_RJT_INPROG; | 1007 | reject = ELS_RJT_INPROG; |
| 1024 | break; | 1008 | break; |
| 1025 | case RPORT_ST_PRLI: | 1009 | case RPORT_ST_PRLI: |
| 1026 | case RPORT_ST_READY: | 1010 | case RPORT_ST_READY: |
| 1027 | FC_DEBUG_RPORT("incoming PLOGI from %x in logged-in state %d " | 1011 | FC_RPORT_DBG(rport, "Received PLOGI in logged-in state %d " |
| 1028 | "- ignored for now\n", sid, rdata->rp_state); | 1012 | "- ignored for now\n", rdata->rp_state); |
| 1029 | /* XXX TBD - should reset */ | 1013 | /* XXX TBD - should reset */ |
| 1030 | break; | 1014 | break; |
| 1031 | case RPORT_ST_NONE: | 1015 | case RPORT_ST_NONE: |
| 1032 | default: | 1016 | default: |
| 1033 | FC_DEBUG_RPORT("incoming PLOGI from %x in unexpected " | 1017 | FC_RPORT_DBG(rport, "Received PLOGI in unexpected " |
| 1034 | "state %d\n", sid, rdata->rp_state); | 1018 | "state %d\n", rdata->rp_state); |
| 1035 | fc_frame_free(fp); | 1019 | fc_frame_free(fp); |
| 1036 | return; | 1020 | return; |
| 1037 | break; | 1021 | break; |
| @@ -1115,9 +1099,8 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport, | |||
| 1115 | 1099 | ||
| 1116 | fh = fc_frame_header_get(rx_fp); | 1100 | fh = fc_frame_header_get(rx_fp); |
| 1117 | 1101 | ||
| 1118 | FC_DEBUG_RPORT("Received PRLI request from port (%6x) " | 1102 | FC_RPORT_DBG(rport, "Received PRLI request while in state %s\n", |
| 1119 | "while in state %s\n", ntoh24(fh->fh_s_id), | 1103 | fc_rport_state(rport)); |
| 1120 | fc_rport_state(rport)); | ||
| 1121 | 1104 | ||
| 1122 | switch (rdata->rp_state) { | 1105 | switch (rdata->rp_state) { |
| 1123 | case RPORT_ST_PRLI: | 1106 | case RPORT_ST_PRLI: |
| @@ -1252,9 +1235,8 @@ static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp, | |||
| 1252 | 1235 | ||
| 1253 | fh = fc_frame_header_get(fp); | 1236 | fh = fc_frame_header_get(fp); |
| 1254 | 1237 | ||
| 1255 | FC_DEBUG_RPORT("Received PRLO request from port (%6x) " | 1238 | FC_RPORT_DBG(rport, "Received PRLO request while in state %s\n", |
| 1256 | "while in state %s\n", ntoh24(fh->fh_s_id), | 1239 | fc_rport_state(rport)); |
| 1257 | fc_rport_state(rport)); | ||
| 1258 | 1240 | ||
| 1259 | if (rdata->rp_state == RPORT_ST_NONE) { | 1241 | if (rdata->rp_state == RPORT_ST_NONE) { |
| 1260 | fc_frame_free(fp); | 1242 | fc_frame_free(fp); |
| @@ -1286,9 +1268,8 @@ static void fc_rport_recv_logo_req(struct fc_rport *rport, struct fc_seq *sp, | |||
| 1286 | 1268 | ||
| 1287 | fh = fc_frame_header_get(fp); | 1269 | fh = fc_frame_header_get(fp); |
| 1288 | 1270 | ||
| 1289 | FC_DEBUG_RPORT("Received LOGO request from port (%6x) " | 1271 | FC_RPORT_DBG(rport, "Received LOGO request while in state %s\n", |
| 1290 | "while in state %s\n", ntoh24(fh->fh_s_id), | 1272 | fc_rport_state(rport)); |
| 1291 | fc_rport_state(rport)); | ||
| 1292 | 1273 | ||
| 1293 | if (rdata->rp_state == RPORT_ST_NONE) { | 1274 | if (rdata->rp_state == RPORT_ST_NONE) { |
| 1294 | fc_frame_free(fp); | 1275 | fc_frame_free(fp); |
| @@ -1308,7 +1289,6 @@ static void fc_rport_flush_queue(void) | |||
| 1308 | flush_workqueue(rport_event_queue); | 1289 | flush_workqueue(rport_event_queue); |
| 1309 | } | 1290 | } |
| 1310 | 1291 | ||
| 1311 | |||
| 1312 | int fc_rport_init(struct fc_lport *lport) | 1292 | int fc_rport_init(struct fc_lport *lport) |
| 1313 | { | 1293 | { |
| 1314 | if (!lport->tt.rport_create) | 1294 | if (!lport->tt.rport_create) |
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 59908aead531..716cc344c5df 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
| @@ -38,15 +38,30 @@ | |||
| 38 | #include <scsi/scsi_transport_iscsi.h> | 38 | #include <scsi/scsi_transport_iscsi.h> |
| 39 | #include <scsi/libiscsi.h> | 39 | #include <scsi/libiscsi.h> |
| 40 | 40 | ||
| 41 | static int iscsi_dbg_lib; | 41 | static int iscsi_dbg_lib_conn; |
| 42 | module_param_named(debug_libiscsi, iscsi_dbg_lib, int, S_IRUGO | S_IWUSR); | 42 | module_param_named(debug_libiscsi_conn, iscsi_dbg_lib_conn, int, |
| 43 | MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. " | 43 | S_IRUGO | S_IWUSR); |
| 44 | "Set to 1 to turn on, and zero to turn off. Default " | 44 | MODULE_PARM_DESC(debug_libiscsi_conn, |
| 45 | "is off."); | 45 | "Turn on debugging for connections in libiscsi module. " |
| 46 | "Set to 1 to turn on, and zero to turn off. Default is off."); | ||
| 47 | |||
| 48 | static int iscsi_dbg_lib_session; | ||
| 49 | module_param_named(debug_libiscsi_session, iscsi_dbg_lib_session, int, | ||
| 50 | S_IRUGO | S_IWUSR); | ||
| 51 | MODULE_PARM_DESC(debug_libiscsi_session, | ||
| 52 | "Turn on debugging for sessions in libiscsi module. " | ||
| 53 | "Set to 1 to turn on, and zero to turn off. Default is off."); | ||
| 54 | |||
| 55 | static int iscsi_dbg_lib_eh; | ||
| 56 | module_param_named(debug_libiscsi_eh, iscsi_dbg_lib_eh, int, | ||
| 57 | S_IRUGO | S_IWUSR); | ||
| 58 | MODULE_PARM_DESC(debug_libiscsi_eh, | ||
| 59 | "Turn on debugging for error handling in libiscsi module. " | ||
| 60 | "Set to 1 to turn on, and zero to turn off. Default is off."); | ||
| 46 | 61 | ||
| 47 | #define ISCSI_DBG_CONN(_conn, dbg_fmt, arg...) \ | 62 | #define ISCSI_DBG_CONN(_conn, dbg_fmt, arg...) \ |
| 48 | do { \ | 63 | do { \ |
| 49 | if (iscsi_dbg_lib) \ | 64 | if (iscsi_dbg_lib_conn) \ |
| 50 | iscsi_conn_printk(KERN_INFO, _conn, \ | 65 | iscsi_conn_printk(KERN_INFO, _conn, \ |
| 51 | "%s " dbg_fmt, \ | 66 | "%s " dbg_fmt, \ |
| 52 | __func__, ##arg); \ | 67 | __func__, ##arg); \ |
| @@ -54,7 +69,15 @@ MODULE_PARM_DESC(debug_libiscsi, "Turn on debugging for libiscsi module. " | |||
| 54 | 69 | ||
| 55 | #define ISCSI_DBG_SESSION(_session, dbg_fmt, arg...) \ | 70 | #define ISCSI_DBG_SESSION(_session, dbg_fmt, arg...) \ |
| 56 | do { \ | 71 | do { \ |
| 57 | if (iscsi_dbg_lib) \ | 72 | if (iscsi_dbg_lib_session) \ |
| 73 | iscsi_session_printk(KERN_INFO, _session, \ | ||
| 74 | "%s " dbg_fmt, \ | ||
| 75 | __func__, ##arg); \ | ||
| 76 | } while (0); | ||
| 77 | |||
| 78 | #define ISCSI_DBG_EH(_session, dbg_fmt, arg...) \ | ||
| 79 | do { \ | ||
| 80 | if (iscsi_dbg_lib_eh) \ | ||
| 58 | iscsi_session_printk(KERN_INFO, _session, \ | 81 | iscsi_session_printk(KERN_INFO, _session, \ |
| 59 | "%s " dbg_fmt, \ | 82 | "%s " dbg_fmt, \ |
| 60 | __func__, ##arg); \ | 83 | __func__, ##arg); \ |
| @@ -954,6 +977,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
| 954 | task = iscsi_itt_to_ctask(conn, hdr->itt); | 977 | task = iscsi_itt_to_ctask(conn, hdr->itt); |
| 955 | if (!task) | 978 | if (!task) |
| 956 | return ISCSI_ERR_BAD_ITT; | 979 | return ISCSI_ERR_BAD_ITT; |
| 980 | task->last_xfer = jiffies; | ||
| 957 | break; | 981 | break; |
| 958 | case ISCSI_OP_R2T: | 982 | case ISCSI_OP_R2T: |
| 959 | /* | 983 | /* |
| @@ -1192,10 +1216,12 @@ static int iscsi_xmit_task(struct iscsi_conn *conn) | |||
| 1192 | spin_unlock_bh(&conn->session->lock); | 1216 | spin_unlock_bh(&conn->session->lock); |
| 1193 | rc = conn->session->tt->xmit_task(task); | 1217 | rc = conn->session->tt->xmit_task(task); |
| 1194 | spin_lock_bh(&conn->session->lock); | 1218 | spin_lock_bh(&conn->session->lock); |
| 1195 | __iscsi_put_task(task); | 1219 | if (!rc) { |
| 1196 | if (!rc) | ||
| 1197 | /* done with this task */ | 1220 | /* done with this task */ |
| 1221 | task->last_xfer = jiffies; | ||
| 1198 | conn->task = NULL; | 1222 | conn->task = NULL; |
| 1223 | } | ||
| 1224 | __iscsi_put_task(task); | ||
| 1199 | return rc; | 1225 | return rc; |
| 1200 | } | 1226 | } |
| 1201 | 1227 | ||
| @@ -1361,6 +1387,9 @@ static inline struct iscsi_task *iscsi_alloc_task(struct iscsi_conn *conn, | |||
| 1361 | task->state = ISCSI_TASK_PENDING; | 1387 | task->state = ISCSI_TASK_PENDING; |
| 1362 | task->conn = conn; | 1388 | task->conn = conn; |
| 1363 | task->sc = sc; | 1389 | task->sc = sc; |
| 1390 | task->have_checked_conn = false; | ||
| 1391 | task->last_timeout = jiffies; | ||
| 1392 | task->last_xfer = jiffies; | ||
| 1364 | INIT_LIST_HEAD(&task->running); | 1393 | INIT_LIST_HEAD(&task->running); |
| 1365 | return task; | 1394 | return task; |
| 1366 | } | 1395 | } |
| @@ -1555,10 +1584,10 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc) | |||
| 1555 | spin_lock_bh(&session->lock); | 1584 | spin_lock_bh(&session->lock); |
| 1556 | if (session->state == ISCSI_STATE_TERMINATE) { | 1585 | if (session->state == ISCSI_STATE_TERMINATE) { |
| 1557 | failed: | 1586 | failed: |
| 1558 | iscsi_session_printk(KERN_INFO, session, | 1587 | ISCSI_DBG_EH(session, |
| 1559 | "failing target reset: Could not log " | 1588 | "failing target reset: Could not log back into " |
| 1560 | "back into target [age %d]\n", | 1589 | "target [age %d]\n", |
| 1561 | session->age); | 1590 | session->age); |
| 1562 | spin_unlock_bh(&session->lock); | 1591 | spin_unlock_bh(&session->lock); |
| 1563 | mutex_unlock(&session->eh_mutex); | 1592 | mutex_unlock(&session->eh_mutex); |
| 1564 | return FAILED; | 1593 | return FAILED; |
| @@ -1572,7 +1601,7 @@ failed: | |||
| 1572 | */ | 1601 | */ |
| 1573 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); | 1602 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); |
| 1574 | 1603 | ||
| 1575 | ISCSI_DBG_SESSION(session, "wait for relogin\n"); | 1604 | ISCSI_DBG_EH(session, "wait for relogin\n"); |
| 1576 | wait_event_interruptible(conn->ehwait, | 1605 | wait_event_interruptible(conn->ehwait, |
| 1577 | session->state == ISCSI_STATE_TERMINATE || | 1606 | session->state == ISCSI_STATE_TERMINATE || |
| 1578 | session->state == ISCSI_STATE_LOGGED_IN || | 1607 | session->state == ISCSI_STATE_LOGGED_IN || |
| @@ -1582,10 +1611,10 @@ failed: | |||
| 1582 | 1611 | ||
| 1583 | mutex_lock(&session->eh_mutex); | 1612 | mutex_lock(&session->eh_mutex); |
| 1584 | spin_lock_bh(&session->lock); | 1613 | spin_lock_bh(&session->lock); |
| 1585 | if (session->state == ISCSI_STATE_LOGGED_IN) | 1614 | if (session->state == ISCSI_STATE_LOGGED_IN) { |
| 1586 | iscsi_session_printk(KERN_INFO, session, | 1615 | ISCSI_DBG_EH(session, |
| 1587 | "target reset succeeded\n"); | 1616 | "target reset succeeded\n"); |
| 1588 | else | 1617 | } else |
| 1589 | goto failed; | 1618 | goto failed; |
| 1590 | spin_unlock_bh(&session->lock); | 1619 | spin_unlock_bh(&session->lock); |
| 1591 | mutex_unlock(&session->eh_mutex); | 1620 | mutex_unlock(&session->eh_mutex); |
| @@ -1601,7 +1630,7 @@ static void iscsi_tmf_timedout(unsigned long data) | |||
| 1601 | spin_lock(&session->lock); | 1630 | spin_lock(&session->lock); |
| 1602 | if (conn->tmf_state == TMF_QUEUED) { | 1631 | if (conn->tmf_state == TMF_QUEUED) { |
| 1603 | conn->tmf_state = TMF_TIMEDOUT; | 1632 | conn->tmf_state = TMF_TIMEDOUT; |
| 1604 | ISCSI_DBG_SESSION(session, "tmf timedout\n"); | 1633 | ISCSI_DBG_EH(session, "tmf timedout\n"); |
| 1605 | /* unblock eh_abort() */ | 1634 | /* unblock eh_abort() */ |
| 1606 | wake_up(&conn->ehwait); | 1635 | wake_up(&conn->ehwait); |
| 1607 | } | 1636 | } |
| @@ -1621,7 +1650,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, | |||
| 1621 | spin_unlock_bh(&session->lock); | 1650 | spin_unlock_bh(&session->lock); |
| 1622 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); | 1651 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); |
| 1623 | spin_lock_bh(&session->lock); | 1652 | spin_lock_bh(&session->lock); |
| 1624 | ISCSI_DBG_SESSION(session, "tmf exec failure\n"); | 1653 | ISCSI_DBG_EH(session, "tmf exec failure\n"); |
| 1625 | return -EPERM; | 1654 | return -EPERM; |
| 1626 | } | 1655 | } |
| 1627 | conn->tmfcmd_pdus_cnt++; | 1656 | conn->tmfcmd_pdus_cnt++; |
| @@ -1629,7 +1658,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, | |||
| 1629 | conn->tmf_timer.function = iscsi_tmf_timedout; | 1658 | conn->tmf_timer.function = iscsi_tmf_timedout; |
| 1630 | conn->tmf_timer.data = (unsigned long)conn; | 1659 | conn->tmf_timer.data = (unsigned long)conn; |
| 1631 | add_timer(&conn->tmf_timer); | 1660 | add_timer(&conn->tmf_timer); |
| 1632 | ISCSI_DBG_SESSION(session, "tmf set timeout\n"); | 1661 | ISCSI_DBG_EH(session, "tmf set timeout\n"); |
| 1633 | 1662 | ||
| 1634 | spin_unlock_bh(&session->lock); | 1663 | spin_unlock_bh(&session->lock); |
| 1635 | mutex_unlock(&session->eh_mutex); | 1664 | mutex_unlock(&session->eh_mutex); |
| @@ -1716,17 +1745,18 @@ static int iscsi_has_ping_timed_out(struct iscsi_conn *conn) | |||
| 1716 | return 0; | 1745 | return 0; |
| 1717 | } | 1746 | } |
| 1718 | 1747 | ||
| 1719 | static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) | 1748 | static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) |
| 1720 | { | 1749 | { |
| 1750 | enum blk_eh_timer_return rc = BLK_EH_NOT_HANDLED; | ||
| 1751 | struct iscsi_task *task = NULL; | ||
| 1721 | struct iscsi_cls_session *cls_session; | 1752 | struct iscsi_cls_session *cls_session; |
| 1722 | struct iscsi_session *session; | 1753 | struct iscsi_session *session; |
| 1723 | struct iscsi_conn *conn; | 1754 | struct iscsi_conn *conn; |
| 1724 | enum blk_eh_timer_return rc = BLK_EH_NOT_HANDLED; | ||
| 1725 | 1755 | ||
| 1726 | cls_session = starget_to_session(scsi_target(scmd->device)); | 1756 | cls_session = starget_to_session(scsi_target(sc->device)); |
| 1727 | session = cls_session->dd_data; | 1757 | session = cls_session->dd_data; |
| 1728 | 1758 | ||
| 1729 | ISCSI_DBG_SESSION(session, "scsi cmd %p timedout\n", scmd); | 1759 | ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc); |
| 1730 | 1760 | ||
| 1731 | spin_lock(&session->lock); | 1761 | spin_lock(&session->lock); |
| 1732 | if (session->state != ISCSI_STATE_LOGGED_IN) { | 1762 | if (session->state != ISCSI_STATE_LOGGED_IN) { |
| @@ -1745,6 +1775,26 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) | |||
| 1745 | goto done; | 1775 | goto done; |
| 1746 | } | 1776 | } |
| 1747 | 1777 | ||
| 1778 | task = (struct iscsi_task *)sc->SCp.ptr; | ||
| 1779 | if (!task) | ||
| 1780 | goto done; | ||
| 1781 | /* | ||
| 1782 | * If we have sent (at least queued to the network layer) a pdu or | ||
| 1783 | * recvd one for the task since the last timeout ask for | ||
| 1784 | * more time. If on the next timeout we have not made progress | ||
| 1785 | * we can check if it is the task or connection when we send the | ||
| 1786 | * nop as a ping. | ||
| 1787 | */ | ||
| 1788 | if (time_after_eq(task->last_xfer, task->last_timeout)) { | ||
| 1789 | ISCSI_DBG_EH(session, "Command making progress. Asking " | ||
| 1790 | "scsi-ml for more time to complete. " | ||
| 1791 | "Last data recv at %lu. Last timeout was at " | ||
| 1792 | "%lu\n.", task->last_xfer, task->last_timeout); | ||
| 1793 | task->have_checked_conn = false; | ||
| 1794 | rc = BLK_EH_RESET_TIMER; | ||
| 1795 | goto done; | ||
| 1796 | } | ||
| 1797 | |||
| 1748 | if (!conn->recv_timeout && !conn->ping_timeout) | 1798 | if (!conn->recv_timeout && !conn->ping_timeout) |
| 1749 | goto done; | 1799 | goto done; |
| 1750 | /* | 1800 | /* |
| @@ -1755,23 +1805,32 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) | |||
| 1755 | rc = BLK_EH_RESET_TIMER; | 1805 | rc = BLK_EH_RESET_TIMER; |
| 1756 | goto done; | 1806 | goto done; |
| 1757 | } | 1807 | } |
| 1808 | |||
| 1809 | /* Assumes nop timeout is shorter than scsi cmd timeout */ | ||
| 1810 | if (task->have_checked_conn) | ||
| 1811 | goto done; | ||
| 1812 | |||
| 1758 | /* | 1813 | /* |
| 1759 | * if we are about to check the transport then give the command | 1814 | * Checking the transport already or nop from a cmd timeout still |
| 1760 | * more time | 1815 | * running |
| 1761 | */ | 1816 | */ |
| 1762 | if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ), | 1817 | if (conn->ping_task) { |
| 1763 | jiffies)) { | 1818 | task->have_checked_conn = true; |
| 1764 | rc = BLK_EH_RESET_TIMER; | 1819 | rc = BLK_EH_RESET_TIMER; |
| 1765 | goto done; | 1820 | goto done; |
| 1766 | } | 1821 | } |
| 1767 | 1822 | ||
| 1768 | /* if in the middle of checking the transport then give us more time */ | 1823 | /* Make sure there is a transport check done */ |
| 1769 | if (conn->ping_task) | 1824 | iscsi_send_nopout(conn, NULL); |
| 1770 | rc = BLK_EH_RESET_TIMER; | 1825 | task->have_checked_conn = true; |
| 1826 | rc = BLK_EH_RESET_TIMER; | ||
| 1827 | |||
| 1771 | done: | 1828 | done: |
| 1829 | if (task) | ||
| 1830 | task->last_timeout = jiffies; | ||
| 1772 | spin_unlock(&session->lock); | 1831 | spin_unlock(&session->lock); |
| 1773 | ISCSI_DBG_SESSION(session, "return %s\n", rc == BLK_EH_RESET_TIMER ? | 1832 | ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ? |
| 1774 | "timer reset" : "nh"); | 1833 | "timer reset" : "nh"); |
| 1775 | return rc; | 1834 | return rc; |
| 1776 | } | 1835 | } |
| 1777 | 1836 | ||
| @@ -1841,7 +1900,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
| 1841 | cls_session = starget_to_session(scsi_target(sc->device)); | 1900 | cls_session = starget_to_session(scsi_target(sc->device)); |
| 1842 | session = cls_session->dd_data; | 1901 | session = cls_session->dd_data; |
| 1843 | 1902 | ||
| 1844 | ISCSI_DBG_SESSION(session, "aborting sc %p\n", sc); | 1903 | ISCSI_DBG_EH(session, "aborting sc %p\n", sc); |
| 1845 | 1904 | ||
| 1846 | mutex_lock(&session->eh_mutex); | 1905 | mutex_lock(&session->eh_mutex); |
| 1847 | spin_lock_bh(&session->lock); | 1906 | spin_lock_bh(&session->lock); |
| @@ -1850,8 +1909,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
| 1850 | * got the command. | 1909 | * got the command. |
| 1851 | */ | 1910 | */ |
| 1852 | if (!sc->SCp.ptr) { | 1911 | if (!sc->SCp.ptr) { |
| 1853 | ISCSI_DBG_SESSION(session, "sc never reached iscsi layer or " | 1912 | ISCSI_DBG_EH(session, "sc never reached iscsi layer or " |
| 1854 | "it completed.\n"); | 1913 | "it completed.\n"); |
| 1855 | spin_unlock_bh(&session->lock); | 1914 | spin_unlock_bh(&session->lock); |
| 1856 | mutex_unlock(&session->eh_mutex); | 1915 | mutex_unlock(&session->eh_mutex); |
| 1857 | return SUCCESS; | 1916 | return SUCCESS; |
| @@ -1865,7 +1924,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
| 1865 | sc->SCp.phase != session->age) { | 1924 | sc->SCp.phase != session->age) { |
| 1866 | spin_unlock_bh(&session->lock); | 1925 | spin_unlock_bh(&session->lock); |
| 1867 | mutex_unlock(&session->eh_mutex); | 1926 | mutex_unlock(&session->eh_mutex); |
| 1868 | ISCSI_DBG_SESSION(session, "failing abort due to dropped " | 1927 | ISCSI_DBG_EH(session, "failing abort due to dropped " |
| 1869 | "session.\n"); | 1928 | "session.\n"); |
| 1870 | return FAILED; | 1929 | return FAILED; |
| 1871 | } | 1930 | } |
| @@ -1875,13 +1934,12 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
| 1875 | age = session->age; | 1934 | age = session->age; |
| 1876 | 1935 | ||
| 1877 | task = (struct iscsi_task *)sc->SCp.ptr; | 1936 | task = (struct iscsi_task *)sc->SCp.ptr; |
| 1878 | ISCSI_DBG_SESSION(session, "aborting [sc %p itt 0x%x]\n", | 1937 | ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", |
| 1879 | sc, task->itt); | 1938 | sc, task->itt); |
| 1880 | 1939 | ||
| 1881 | /* task completed before time out */ | 1940 | /* task completed before time out */ |
| 1882 | if (!task->sc) { | 1941 | if (!task->sc) { |
| 1883 | ISCSI_DBG_SESSION(session, "sc completed while abort in " | 1942 | ISCSI_DBG_EH(session, "sc completed while abort in progress\n"); |
| 1884 | "progress\n"); | ||
| 1885 | goto success; | 1943 | goto success; |
| 1886 | } | 1944 | } |
| 1887 | 1945 | ||
| @@ -1930,8 +1988,8 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
| 1930 | if (!sc->SCp.ptr) { | 1988 | if (!sc->SCp.ptr) { |
| 1931 | conn->tmf_state = TMF_INITIAL; | 1989 | conn->tmf_state = TMF_INITIAL; |
| 1932 | /* task completed before tmf abort response */ | 1990 | /* task completed before tmf abort response */ |
| 1933 | ISCSI_DBG_SESSION(session, "sc completed while abort " | 1991 | ISCSI_DBG_EH(session, "sc completed while abort in " |
| 1934 | "in progress\n"); | 1992 | "progress\n"); |
| 1935 | goto success; | 1993 | goto success; |
| 1936 | } | 1994 | } |
| 1937 | /* fall through */ | 1995 | /* fall through */ |
| @@ -1943,16 +2001,16 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
| 1943 | success: | 2001 | success: |
| 1944 | spin_unlock_bh(&session->lock); | 2002 | spin_unlock_bh(&session->lock); |
| 1945 | success_unlocked: | 2003 | success_unlocked: |
| 1946 | ISCSI_DBG_SESSION(session, "abort success [sc %p itt 0x%x]\n", | 2004 | ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n", |
| 1947 | sc, task->itt); | 2005 | sc, task->itt); |
| 1948 | mutex_unlock(&session->eh_mutex); | 2006 | mutex_unlock(&session->eh_mutex); |
| 1949 | return SUCCESS; | 2007 | return SUCCESS; |
| 1950 | 2008 | ||
| 1951 | failed: | 2009 | failed: |
| 1952 | spin_unlock_bh(&session->lock); | 2010 | spin_unlock_bh(&session->lock); |
| 1953 | failed_unlocked: | 2011 | failed_unlocked: |
| 1954 | ISCSI_DBG_SESSION(session, "abort failed [sc %p itt 0x%x]\n", sc, | 2012 | ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc, |
| 1955 | task ? task->itt : 0); | 2013 | task ? task->itt : 0); |
| 1956 | mutex_unlock(&session->eh_mutex); | 2014 | mutex_unlock(&session->eh_mutex); |
| 1957 | return FAILED; | 2015 | return FAILED; |
| 1958 | } | 2016 | } |
| @@ -1979,8 +2037,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) | |||
| 1979 | cls_session = starget_to_session(scsi_target(sc->device)); | 2037 | cls_session = starget_to_session(scsi_target(sc->device)); |
| 1980 | session = cls_session->dd_data; | 2038 | session = cls_session->dd_data; |
| 1981 | 2039 | ||
| 1982 | ISCSI_DBG_SESSION(session, "LU Reset [sc %p lun %u]\n", | 2040 | ISCSI_DBG_EH(session, "LU Reset [sc %p lun %u]\n", sc, sc->device->lun); |
| 1983 | sc, sc->device->lun); | ||
| 1984 | 2041 | ||
| 1985 | mutex_lock(&session->eh_mutex); | 2042 | mutex_lock(&session->eh_mutex); |
| 1986 | spin_lock_bh(&session->lock); | 2043 | spin_lock_bh(&session->lock); |
| @@ -2034,8 +2091,8 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) | |||
| 2034 | unlock: | 2091 | unlock: |
| 2035 | spin_unlock_bh(&session->lock); | 2092 | spin_unlock_bh(&session->lock); |
| 2036 | done: | 2093 | done: |
| 2037 | ISCSI_DBG_SESSION(session, "dev reset result = %s\n", | 2094 | ISCSI_DBG_EH(session, "dev reset result = %s\n", |
| 2038 | rc == SUCCESS ? "SUCCESS" : "FAILED"); | 2095 | rc == SUCCESS ? "SUCCESS" : "FAILED"); |
| 2039 | mutex_unlock(&session->eh_mutex); | 2096 | mutex_unlock(&session->eh_mutex); |
| 2040 | return rc; | 2097 | return rc; |
| 2041 | } | 2098 | } |
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index 2bc07090321d..2e0746d70303 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c | |||
| @@ -686,6 +686,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) | |||
| 686 | "offset=%d, datalen=%d)\n", | 686 | "offset=%d, datalen=%d)\n", |
| 687 | tcp_task->data_offset, | 687 | tcp_task->data_offset, |
| 688 | tcp_conn->in.datalen); | 688 | tcp_conn->in.datalen); |
| 689 | task->last_xfer = jiffies; | ||
| 689 | rc = iscsi_segment_seek_sg(&tcp_conn->in.segment, | 690 | rc = iscsi_segment_seek_sg(&tcp_conn->in.segment, |
| 690 | sdb->table.sgl, | 691 | sdb->table.sgl, |
| 691 | sdb->table.nents, | 692 | sdb->table.nents, |
| @@ -713,9 +714,10 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) | |||
| 713 | rc = ISCSI_ERR_BAD_ITT; | 714 | rc = ISCSI_ERR_BAD_ITT; |
| 714 | else if (ahslen) | 715 | else if (ahslen) |
| 715 | rc = ISCSI_ERR_AHSLEN; | 716 | rc = ISCSI_ERR_AHSLEN; |
| 716 | else if (task->sc->sc_data_direction == DMA_TO_DEVICE) | 717 | else if (task->sc->sc_data_direction == DMA_TO_DEVICE) { |
| 718 | task->last_xfer = jiffies; | ||
| 717 | rc = iscsi_tcp_r2t_rsp(conn, task); | 719 | rc = iscsi_tcp_r2t_rsp(conn, task); |
| 718 | else | 720 | } else |
| 719 | rc = ISCSI_ERR_PROTO; | 721 | rc = ISCSI_ERR_PROTO; |
| 720 | spin_unlock(&conn->session->lock); | 722 | spin_unlock(&conn->session->lock); |
| 721 | break; | 723 | break; |
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 4a990f4da4ea..cca8e4ab0372 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c | |||
| @@ -216,7 +216,7 @@ qla24xx_soft_reset(struct qla_hw_data *ha) | |||
| 216 | 216 | ||
| 217 | static int | 217 | static int |
| 218 | qla2xxx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint16_t *ram, | 218 | qla2xxx_dump_ram(struct qla_hw_data *ha, uint32_t addr, uint16_t *ram, |
| 219 | uint16_t ram_words, void **nxt) | 219 | uint32_t ram_words, void **nxt) |
| 220 | { | 220 | { |
| 221 | int rval; | 221 | int rval; |
| 222 | uint32_t cnt, stat, timer, words, idx; | 222 | uint32_t cnt, stat, timer, words, idx; |
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 262026129325..f2ce8e3cc91b 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c | |||
| @@ -2301,7 +2301,7 @@ qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) | |||
| 2301 | static char *link_speeds[] = { "1", "2", "?", "4", "8", "10" }; | 2301 | static char *link_speeds[] = { "1", "2", "?", "4", "8", "10" }; |
| 2302 | char *link_speed; | 2302 | char *link_speed; |
| 2303 | int rval; | 2303 | int rval; |
| 2304 | uint16_t mb[6]; | 2304 | uint16_t mb[4]; |
| 2305 | struct qla_hw_data *ha = vha->hw; | 2305 | struct qla_hw_data *ha = vha->hw; |
| 2306 | 2306 | ||
| 2307 | if (!IS_IIDMA_CAPABLE(ha)) | 2307 | if (!IS_IIDMA_CAPABLE(ha)) |
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 451ece0760b0..fe69f3057671 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c | |||
| @@ -1267,17 +1267,22 @@ qla2x00_get_firmware_state(scsi_qla_host_t *vha, uint16_t *states) | |||
| 1267 | 1267 | ||
| 1268 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; | 1268 | mcp->mb[0] = MBC_GET_FIRMWARE_STATE; |
| 1269 | mcp->out_mb = MBX_0; | 1269 | mcp->out_mb = MBX_0; |
| 1270 | mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; | 1270 | if (IS_FWI2_CAPABLE(vha->hw)) |
| 1271 | mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; | ||
| 1272 | else | ||
| 1273 | mcp->in_mb = MBX_1|MBX_0; | ||
| 1271 | mcp->tov = MBX_TOV_SECONDS; | 1274 | mcp->tov = MBX_TOV_SECONDS; |
| 1272 | mcp->flags = 0; | 1275 | mcp->flags = 0; |
| 1273 | rval = qla2x00_mailbox_command(vha, mcp); | 1276 | rval = qla2x00_mailbox_command(vha, mcp); |
| 1274 | 1277 | ||
| 1275 | /* Return firmware states. */ | 1278 | /* Return firmware states. */ |
| 1276 | states[0] = mcp->mb[1]; | 1279 | states[0] = mcp->mb[1]; |
| 1277 | states[1] = mcp->mb[2]; | 1280 | if (IS_FWI2_CAPABLE(vha->hw)) { |
| 1278 | states[2] = mcp->mb[3]; | 1281 | states[1] = mcp->mb[2]; |
| 1279 | states[3] = mcp->mb[4]; | 1282 | states[2] = mcp->mb[3]; |
| 1280 | states[4] = mcp->mb[5]; | 1283 | states[3] = mcp->mb[4]; |
| 1284 | states[4] = mcp->mb[5]; | ||
| 1285 | } | ||
| 1281 | 1286 | ||
| 1282 | if (rval != QLA_SUCCESS) { | 1287 | if (rval != QLA_SUCCESS) { |
| 1283 | /*EMPTY*/ | 1288 | /*EMPTY*/ |
| @@ -2697,10 +2702,13 @@ qla2x00_set_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, | |||
| 2697 | mcp->mb[0] = MBC_PORT_PARAMS; | 2702 | mcp->mb[0] = MBC_PORT_PARAMS; |
| 2698 | mcp->mb[1] = loop_id; | 2703 | mcp->mb[1] = loop_id; |
| 2699 | mcp->mb[2] = BIT_0; | 2704 | mcp->mb[2] = BIT_0; |
| 2700 | mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); | 2705 | if (IS_QLA81XX(vha->hw)) |
| 2701 | mcp->mb[4] = mcp->mb[5] = 0; | 2706 | mcp->mb[3] = port_speed & (BIT_5|BIT_4|BIT_3|BIT_2|BIT_1|BIT_0); |
| 2702 | mcp->out_mb = MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; | 2707 | else |
| 2703 | mcp->in_mb = MBX_5|MBX_4|MBX_3|MBX_1|MBX_0; | 2708 | mcp->mb[3] = port_speed & (BIT_2|BIT_1|BIT_0); |
| 2709 | mcp->mb[9] = vha->vp_idx; | ||
| 2710 | mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; | ||
| 2711 | mcp->in_mb = MBX_3|MBX_1|MBX_0; | ||
| 2704 | mcp->tov = MBX_TOV_SECONDS; | 2712 | mcp->tov = MBX_TOV_SECONDS; |
| 2705 | mcp->flags = 0; | 2713 | mcp->flags = 0; |
| 2706 | rval = qla2x00_mailbox_command(vha, mcp); | 2714 | rval = qla2x00_mailbox_command(vha, mcp); |
| @@ -2710,8 +2718,6 @@ qla2x00_set_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id, | |||
| 2710 | mb[0] = mcp->mb[0]; | 2718 | mb[0] = mcp->mb[0]; |
| 2711 | mb[1] = mcp->mb[1]; | 2719 | mb[1] = mcp->mb[1]; |
| 2712 | mb[3] = mcp->mb[3]; | 2720 | mb[3] = mcp->mb[3]; |
| 2713 | mb[4] = mcp->mb[4]; | ||
| 2714 | mb[5] = mcp->mb[5]; | ||
| 2715 | } | 2721 | } |
| 2716 | 2722 | ||
| 2717 | if (rval != QLA_SUCCESS) { | 2723 | if (rval != QLA_SUCCESS) { |
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index dcf011679c8b..f0396e79b6fa 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
| @@ -1663,7 +1663,7 @@ skip_pio: | |||
| 1663 | /* queue 0 uses two msix vectors */ | 1663 | /* queue 0 uses two msix vectors */ |
| 1664 | if (ql2xmultique_tag) { | 1664 | if (ql2xmultique_tag) { |
| 1665 | cpus = num_online_cpus(); | 1665 | cpus = num_online_cpus(); |
| 1666 | ha->max_rsp_queues = (ha->msix_count - 1 - cpus) ? | 1666 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1667 | (cpus + 1) : (ha->msix_count - 1); | 1667 | (cpus + 1) : (ha->msix_count - 1); |
| 1668 | ha->max_req_queues = 2; | 1668 | ha->max_req_queues = 2; |
| 1669 | } else if (ql2xmaxqueues > 1) { | 1669 | } else if (ql2xmaxqueues > 1) { |
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h index b63feaf43126..84369705a9ad 100644 --- a/drivers/scsi/qla2xxx/qla_version.h +++ b/drivers/scsi/qla2xxx/qla_version.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | /* | 7 | /* |
| 8 | * Driver version | 8 | * Driver version |
| 9 | */ | 9 | */ |
| 10 | #define QLA2XXX_VERSION "8.03.01-k3" | 10 | #define QLA2XXX_VERSION "8.03.01-k4" |
| 11 | 11 | ||
| 12 | #define QLA_DRIVER_MAJOR_VER 8 | 12 | #define QLA_DRIVER_MAJOR_VER 8 |
| 13 | #define QLA_DRIVER_MINOR_VER 3 | 13 | #define QLA_DRIVER_MINOR_VER 3 |
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 41a21772df12..fb9af207d61d 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
| @@ -101,6 +101,8 @@ static const char * scsi_debug_version_date = "20070104"; | |||
| 101 | #define DEF_DIF 0 | 101 | #define DEF_DIF 0 |
| 102 | #define DEF_GUARD 0 | 102 | #define DEF_GUARD 0 |
| 103 | #define DEF_ATO 1 | 103 | #define DEF_ATO 1 |
| 104 | #define DEF_PHYSBLK_EXP 0 | ||
| 105 | #define DEF_LOWEST_ALIGNED 0 | ||
| 104 | 106 | ||
| 105 | /* bit mask values for scsi_debug_opts */ | 107 | /* bit mask values for scsi_debug_opts */ |
| 106 | #define SCSI_DEBUG_OPT_NOISE 1 | 108 | #define SCSI_DEBUG_OPT_NOISE 1 |
| @@ -156,6 +158,8 @@ static int scsi_debug_dix = DEF_DIX; | |||
| 156 | static int scsi_debug_dif = DEF_DIF; | 158 | static int scsi_debug_dif = DEF_DIF; |
| 157 | static int scsi_debug_guard = DEF_GUARD; | 159 | static int scsi_debug_guard = DEF_GUARD; |
| 158 | static int scsi_debug_ato = DEF_ATO; | 160 | static int scsi_debug_ato = DEF_ATO; |
| 161 | static int scsi_debug_physblk_exp = DEF_PHYSBLK_EXP; | ||
| 162 | static int scsi_debug_lowest_aligned = DEF_LOWEST_ALIGNED; | ||
| 159 | 163 | ||
| 160 | static int scsi_debug_cmnd_count = 0; | 164 | static int scsi_debug_cmnd_count = 0; |
| 161 | 165 | ||
| @@ -657,7 +661,12 @@ static unsigned char vpdb0_data[] = { | |||
| 657 | 661 | ||
| 658 | static int inquiry_evpd_b0(unsigned char * arr) | 662 | static int inquiry_evpd_b0(unsigned char * arr) |
| 659 | { | 663 | { |
| 664 | unsigned int gran; | ||
| 665 | |||
| 660 | memcpy(arr, vpdb0_data, sizeof(vpdb0_data)); | 666 | memcpy(arr, vpdb0_data, sizeof(vpdb0_data)); |
| 667 | gran = 1 << scsi_debug_physblk_exp; | ||
| 668 | arr[2] = (gran >> 8) & 0xff; | ||
| 669 | arr[3] = gran & 0xff; | ||
| 661 | if (sdebug_store_sectors > 0x400) { | 670 | if (sdebug_store_sectors > 0x400) { |
| 662 | arr[4] = (sdebug_store_sectors >> 24) & 0xff; | 671 | arr[4] = (sdebug_store_sectors >> 24) & 0xff; |
| 663 | arr[5] = (sdebug_store_sectors >> 16) & 0xff; | 672 | arr[5] = (sdebug_store_sectors >> 16) & 0xff; |
| @@ -945,6 +954,9 @@ static int resp_readcap16(struct scsi_cmnd * scp, | |||
| 945 | arr[9] = (scsi_debug_sector_size >> 16) & 0xff; | 954 | arr[9] = (scsi_debug_sector_size >> 16) & 0xff; |
| 946 | arr[10] = (scsi_debug_sector_size >> 8) & 0xff; | 955 | arr[10] = (scsi_debug_sector_size >> 8) & 0xff; |
| 947 | arr[11] = scsi_debug_sector_size & 0xff; | 956 | arr[11] = scsi_debug_sector_size & 0xff; |
| 957 | arr[13] = scsi_debug_physblk_exp & 0xf; | ||
| 958 | arr[14] = (scsi_debug_lowest_aligned >> 8) & 0x3f; | ||
| 959 | arr[15] = scsi_debug_lowest_aligned & 0xff; | ||
| 948 | 960 | ||
| 949 | if (scsi_debug_dif) { | 961 | if (scsi_debug_dif) { |
| 950 | arr[12] = (scsi_debug_dif - 1) << 1; /* P_TYPE */ | 962 | arr[12] = (scsi_debug_dif - 1) << 1; /* P_TYPE */ |
| @@ -2380,6 +2392,8 @@ module_param_named(dix, scsi_debug_dix, int, S_IRUGO); | |||
| 2380 | module_param_named(dif, scsi_debug_dif, int, S_IRUGO); | 2392 | module_param_named(dif, scsi_debug_dif, int, S_IRUGO); |
| 2381 | module_param_named(guard, scsi_debug_guard, int, S_IRUGO); | 2393 | module_param_named(guard, scsi_debug_guard, int, S_IRUGO); |
| 2382 | module_param_named(ato, scsi_debug_ato, int, S_IRUGO); | 2394 | module_param_named(ato, scsi_debug_ato, int, S_IRUGO); |
| 2395 | module_param_named(physblk_exp, scsi_debug_physblk_exp, int, S_IRUGO); | ||
| 2396 | module_param_named(lowest_aligned, scsi_debug_lowest_aligned, int, S_IRUGO); | ||
| 2383 | 2397 | ||
| 2384 | MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); | 2398 | MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert"); |
| 2385 | MODULE_DESCRIPTION("SCSI debug adapter driver"); | 2399 | MODULE_DESCRIPTION("SCSI debug adapter driver"); |
| @@ -2401,7 +2415,9 @@ MODULE_PARM_DESC(ptype, "SCSI peripheral type(def=0[disk])"); | |||
| 2401 | MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=5[SPC-3])"); | 2415 | MODULE_PARM_DESC(scsi_level, "SCSI level to simulate(def=5[SPC-3])"); |
| 2402 | MODULE_PARM_DESC(virtual_gb, "virtual gigabyte size (def=0 -> use dev_size_mb)"); | 2416 | MODULE_PARM_DESC(virtual_gb, "virtual gigabyte size (def=0 -> use dev_size_mb)"); |
| 2403 | MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique dev ids)"); | 2417 | MODULE_PARM_DESC(vpd_use_hostno, "0 -> dev ids ignore hostno (def=1 -> unique dev ids)"); |
| 2404 | MODULE_PARM_DESC(sector_size, "hardware sector size in bytes (def=512)"); | 2418 | MODULE_PARM_DESC(sector_size, "logical block size in bytes (def=512)"); |
| 2419 | MODULE_PARM_DESC(physblk_exp, "physical block exponent (def=0)"); | ||
| 2420 | MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)"); | ||
| 2405 | MODULE_PARM_DESC(dix, "data integrity extensions mask (def=0)"); | 2421 | MODULE_PARM_DESC(dix, "data integrity extensions mask (def=0)"); |
| 2406 | MODULE_PARM_DESC(dif, "data integrity field type: 0-3 (def=0)"); | 2422 | MODULE_PARM_DESC(dif, "data integrity field type: 0-3 (def=0)"); |
| 2407 | MODULE_PARM_DESC(guard, "protection checksum: 0=crc, 1=ip (def=0)"); | 2423 | MODULE_PARM_DESC(guard, "protection checksum: 0=crc, 1=ip (def=0)"); |
| @@ -2874,6 +2890,18 @@ static int __init scsi_debug_init(void) | |||
| 2874 | return -EINVAL; | 2890 | return -EINVAL; |
| 2875 | } | 2891 | } |
| 2876 | 2892 | ||
| 2893 | if (scsi_debug_physblk_exp > 15) { | ||
| 2894 | printk(KERN_ERR "scsi_debug_init: invalid physblk_exp %u\n", | ||
| 2895 | scsi_debug_physblk_exp); | ||
| 2896 | return -EINVAL; | ||
| 2897 | } | ||
| 2898 | |||
| 2899 | if (scsi_debug_lowest_aligned > 0x3fff) { | ||
| 2900 | printk(KERN_ERR "scsi_debug_init: lowest_aligned too big: %u\n", | ||
| 2901 | scsi_debug_lowest_aligned); | ||
| 2902 | return -EINVAL; | ||
| 2903 | } | ||
| 2904 | |||
| 2877 | if (scsi_debug_dev_size_mb < 1) | 2905 | if (scsi_debug_dev_size_mb < 1) |
| 2878 | scsi_debug_dev_size_mb = 1; /* force minimum 1 MB ramdisk */ | 2906 | scsi_debug_dev_size_mb = 1; /* force minimum 1 MB ramdisk */ |
| 2879 | sz = (unsigned long)scsi_debug_dev_size_mb * 1048576; | 2907 | sz = (unsigned long)scsi_debug_dev_size_mb * 1048576; |
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index 8821df9a277b..93c2622cb969 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c | |||
| @@ -24,6 +24,13 @@ struct scsi_dev_info_list { | |||
| 24 | unsigned compatible; /* for use with scsi_static_device_list entries */ | 24 | unsigned compatible; /* for use with scsi_static_device_list entries */ |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | struct scsi_dev_info_list_table { | ||
| 28 | struct list_head node; /* our node for being on the master list */ | ||
| 29 | struct list_head scsi_dev_info_list; /* head of dev info list */ | ||
| 30 | const char *name; /* name of list for /proc (NULL for global) */ | ||
| 31 | int key; /* unique numeric identifier */ | ||
| 32 | }; | ||
| 33 | |||
| 27 | 34 | ||
| 28 | static const char spaces[] = " "; /* 16 of them */ | 35 | static const char spaces[] = " "; /* 16 of them */ |
| 29 | static unsigned scsi_default_dev_flags; | 36 | static unsigned scsi_default_dev_flags; |
| @@ -247,6 +254,22 @@ static struct { | |||
| 247 | { NULL, NULL, NULL, 0 }, | 254 | { NULL, NULL, NULL, 0 }, |
| 248 | }; | 255 | }; |
| 249 | 256 | ||
| 257 | static struct scsi_dev_info_list_table *scsi_devinfo_lookup_by_key(int key) | ||
| 258 | { | ||
| 259 | struct scsi_dev_info_list_table *devinfo_table; | ||
| 260 | int found = 0; | ||
| 261 | |||
| 262 | list_for_each_entry(devinfo_table, &scsi_dev_info_list, node) | ||
| 263 | if (devinfo_table->key == key) { | ||
| 264 | found = 1; | ||
| 265 | break; | ||
| 266 | } | ||
| 267 | if (!found) | ||
| 268 | return ERR_PTR(-EINVAL); | ||
| 269 | |||
| 270 | return devinfo_table; | ||
| 271 | } | ||
| 272 | |||
| 250 | /* | 273 | /* |
| 251 | * scsi_strcpy_devinfo: called from scsi_dev_info_list_add to copy into | 274 | * scsi_strcpy_devinfo: called from scsi_dev_info_list_add to copy into |
| 252 | * devinfo vendor and model strings. | 275 | * devinfo vendor and model strings. |
| @@ -296,7 +319,38 @@ static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length, | |||
| 296 | static int scsi_dev_info_list_add(int compatible, char *vendor, char *model, | 319 | static int scsi_dev_info_list_add(int compatible, char *vendor, char *model, |
| 297 | char *strflags, int flags) | 320 | char *strflags, int flags) |
| 298 | { | 321 | { |
| 322 | return scsi_dev_info_list_add_keyed(compatible, vendor, model, | ||
| 323 | strflags, flags, | ||
| 324 | SCSI_DEVINFO_GLOBAL); | ||
| 325 | } | ||
| 326 | |||
| 327 | /** | ||
| 328 | * scsi_dev_info_list_add_keyed - add one dev_info list entry. | ||
| 329 | * @compatible: if true, null terminate short strings. Otherwise space pad. | ||
| 330 | * @vendor: vendor string | ||
| 331 | * @model: model (product) string | ||
| 332 | * @strflags: integer string | ||
| 333 | * @flags: if strflags NULL, use this flag value | ||
| 334 | * @key: specify list to use | ||
| 335 | * | ||
| 336 | * Description: | ||
| 337 | * Create and add one dev_info entry for @vendor, @model, | ||
| 338 | * @strflags or @flag in list specified by @key. If @compatible, | ||
| 339 | * add to the tail of the list, do not space pad, and set | ||
| 340 | * devinfo->compatible. The scsi_static_device_list entries are | ||
| 341 | * added with @compatible 1 and @clfags NULL. | ||
| 342 | * | ||
| 343 | * Returns: 0 OK, -error on failure. | ||
| 344 | **/ | ||
| 345 | int scsi_dev_info_list_add_keyed(int compatible, char *vendor, char *model, | ||
| 346 | char *strflags, int flags, int key) | ||
| 347 | { | ||
| 299 | struct scsi_dev_info_list *devinfo; | 348 | struct scsi_dev_info_list *devinfo; |
| 349 | struct scsi_dev_info_list_table *devinfo_table = | ||
| 350 | scsi_devinfo_lookup_by_key(key); | ||
| 351 | |||
| 352 | if (IS_ERR(devinfo_table)) | ||
| 353 | return PTR_ERR(devinfo_table); | ||
| 300 | 354 | ||
| 301 | devinfo = kmalloc(sizeof(*devinfo), GFP_KERNEL); | 355 | devinfo = kmalloc(sizeof(*devinfo), GFP_KERNEL); |
| 302 | if (!devinfo) { | 356 | if (!devinfo) { |
| @@ -317,12 +371,15 @@ static int scsi_dev_info_list_add(int compatible, char *vendor, char *model, | |||
| 317 | devinfo->compatible = compatible; | 371 | devinfo->compatible = compatible; |
| 318 | 372 | ||
| 319 | if (compatible) | 373 | if (compatible) |
| 320 | list_add_tail(&devinfo->dev_info_list, &scsi_dev_info_list); | 374 | list_add_tail(&devinfo->dev_info_list, |
| 375 | &devinfo_table->scsi_dev_info_list); | ||
| 321 | else | 376 | else |
| 322 | list_add(&devinfo->dev_info_list, &scsi_dev_info_list); | 377 | list_add(&devinfo->dev_info_list, |
| 378 | &devinfo_table->scsi_dev_info_list); | ||
| 323 | 379 | ||
| 324 | return 0; | 380 | return 0; |
| 325 | } | 381 | } |
| 382 | EXPORT_SYMBOL(scsi_dev_info_list_add_keyed); | ||
| 326 | 383 | ||
| 327 | /** | 384 | /** |
| 328 | * scsi_dev_info_list_add_str - parse dev_list and add to the scsi_dev_info_list. | 385 | * scsi_dev_info_list_add_str - parse dev_list and add to the scsi_dev_info_list. |
| @@ -382,22 +439,48 @@ static int scsi_dev_info_list_add_str(char *dev_list) | |||
| 382 | * @model: model name | 439 | * @model: model name |
| 383 | * | 440 | * |
| 384 | * Description: | 441 | * Description: |
| 385 | * Search the scsi_dev_info_list for an entry matching @vendor and | 442 | * Search the global scsi_dev_info_list (specified by list zero) |
| 386 | * @model, if found, return the matching flags value, else return | 443 | * for an entry matching @vendor and @model, if found, return the |
| 387 | * the host or global default settings. Called during scan time. | 444 | * matching flags value, else return the host or global default |
| 445 | * settings. Called during scan time. | ||
| 388 | **/ | 446 | **/ |
| 389 | int scsi_get_device_flags(struct scsi_device *sdev, | 447 | int scsi_get_device_flags(struct scsi_device *sdev, |
| 390 | const unsigned char *vendor, | 448 | const unsigned char *vendor, |
| 391 | const unsigned char *model) | 449 | const unsigned char *model) |
| 392 | { | 450 | { |
| 451 | return scsi_get_device_flags_keyed(sdev, vendor, model, | ||
| 452 | SCSI_DEVINFO_GLOBAL); | ||
| 453 | } | ||
| 454 | |||
| 455 | |||
| 456 | /** | ||
| 457 | * get_device_flags_keyed - get device specific flags from the dynamic device list. | ||
| 458 | * @sdev: &scsi_device to get flags for | ||
| 459 | * @vendor: vendor name | ||
| 460 | * @model: model name | ||
| 461 | * @key: list to look up | ||
| 462 | * | ||
| 463 | * Description: | ||
| 464 | * Search the scsi_dev_info_list specified by @key for an entry | ||
| 465 | * matching @vendor and @model, if found, return the matching | ||
| 466 | * flags value, else return the host or global default settings. | ||
| 467 | * Called during scan time. | ||
| 468 | **/ | ||
| 469 | int scsi_get_device_flags_keyed(struct scsi_device *sdev, | ||
| 470 | const unsigned char *vendor, | ||
| 471 | const unsigned char *model, | ||
| 472 | int key) | ||
| 473 | { | ||
| 393 | struct scsi_dev_info_list *devinfo; | 474 | struct scsi_dev_info_list *devinfo; |
| 394 | unsigned int bflags; | 475 | struct scsi_dev_info_list_table *devinfo_table; |
| 476 | |||
| 477 | devinfo_table = scsi_devinfo_lookup_by_key(key); | ||
| 395 | 478 | ||
| 396 | bflags = sdev->sdev_bflags; | 479 | if (IS_ERR(devinfo_table)) |
| 397 | if (!bflags) | 480 | return PTR_ERR(devinfo_table); |
| 398 | bflags = scsi_default_dev_flags; | ||
| 399 | 481 | ||
| 400 | list_for_each_entry(devinfo, &scsi_dev_info_list, dev_info_list) { | 482 | list_for_each_entry(devinfo, &devinfo_table->scsi_dev_info_list, |
| 483 | dev_info_list) { | ||
| 401 | if (devinfo->compatible) { | 484 | if (devinfo->compatible) { |
| 402 | /* | 485 | /* |
| 403 | * Behave like the older version of get_device_flags. | 486 | * Behave like the older version of get_device_flags. |
| @@ -447,32 +530,89 @@ int scsi_get_device_flags(struct scsi_device *sdev, | |||
| 447 | return devinfo->flags; | 530 | return devinfo->flags; |
| 448 | } | 531 | } |
| 449 | } | 532 | } |
| 450 | return bflags; | 533 | /* nothing found, return nothing */ |
| 534 | if (key != SCSI_DEVINFO_GLOBAL) | ||
| 535 | return 0; | ||
| 536 | |||
| 537 | /* except for the global list, where we have an exception */ | ||
| 538 | if (sdev->sdev_bflags) | ||
| 539 | return sdev->sdev_bflags; | ||
| 540 | |||
| 541 | return scsi_default_dev_flags; | ||
| 451 | } | 542 | } |
| 543 | EXPORT_SYMBOL(scsi_get_device_flags_keyed); | ||
| 452 | 544 | ||
| 453 | #ifdef CONFIG_SCSI_PROC_FS | 545 | #ifdef CONFIG_SCSI_PROC_FS |
| 546 | struct double_list { | ||
| 547 | struct list_head *top; | ||
| 548 | struct list_head *bottom; | ||
| 549 | }; | ||
| 550 | |||
| 454 | static int devinfo_seq_show(struct seq_file *m, void *v) | 551 | static int devinfo_seq_show(struct seq_file *m, void *v) |
| 455 | { | 552 | { |
| 553 | struct double_list *dl = v; | ||
| 554 | struct scsi_dev_info_list_table *devinfo_table = | ||
| 555 | list_entry(dl->top, struct scsi_dev_info_list_table, node); | ||
| 456 | struct scsi_dev_info_list *devinfo = | 556 | struct scsi_dev_info_list *devinfo = |
| 457 | list_entry(v, struct scsi_dev_info_list, dev_info_list); | 557 | list_entry(dl->bottom, struct scsi_dev_info_list, |
| 558 | dev_info_list); | ||
| 559 | |||
| 560 | if (devinfo_table->scsi_dev_info_list.next == dl->bottom && | ||
| 561 | devinfo_table->name) | ||
| 562 | seq_printf(m, "[%s]:\n", devinfo_table->name); | ||
| 458 | 563 | ||
| 459 | seq_printf(m, "'%.8s' '%.16s' 0x%x\n", | 564 | seq_printf(m, "'%.8s' '%.16s' 0x%x\n", |
| 460 | devinfo->vendor, devinfo->model, devinfo->flags); | 565 | devinfo->vendor, devinfo->model, devinfo->flags); |
| 461 | return 0; | 566 | return 0; |
| 462 | } | 567 | } |
| 463 | 568 | ||
| 464 | static void * devinfo_seq_start(struct seq_file *m, loff_t *pos) | 569 | static void *devinfo_seq_start(struct seq_file *m, loff_t *ppos) |
| 465 | { | 570 | { |
| 466 | return seq_list_start(&scsi_dev_info_list, *pos); | 571 | struct double_list *dl = kmalloc(sizeof(*dl), GFP_KERNEL); |
| 572 | loff_t pos = *ppos; | ||
| 573 | |||
| 574 | if (!dl) | ||
| 575 | return NULL; | ||
| 576 | |||
| 577 | list_for_each(dl->top, &scsi_dev_info_list) { | ||
| 578 | struct scsi_dev_info_list_table *devinfo_table = | ||
| 579 | list_entry(dl->top, struct scsi_dev_info_list_table, | ||
| 580 | node); | ||
| 581 | list_for_each(dl->bottom, &devinfo_table->scsi_dev_info_list) | ||
| 582 | if (pos-- == 0) | ||
| 583 | return dl; | ||
| 584 | } | ||
| 585 | |||
| 586 | kfree(dl); | ||
| 587 | return NULL; | ||
| 467 | } | 588 | } |
| 468 | 589 | ||
| 469 | static void * devinfo_seq_next(struct seq_file *m, void *v, loff_t *pos) | 590 | static void *devinfo_seq_next(struct seq_file *m, void *v, loff_t *ppos) |
| 470 | { | 591 | { |
| 471 | return seq_list_next(v, &scsi_dev_info_list, pos); | 592 | struct double_list *dl = v; |
| 593 | struct scsi_dev_info_list_table *devinfo_table = | ||
| 594 | list_entry(dl->top, struct scsi_dev_info_list_table, node); | ||
| 595 | |||
| 596 | ++*ppos; | ||
| 597 | dl->bottom = dl->bottom->next; | ||
| 598 | while (&devinfo_table->scsi_dev_info_list == dl->bottom) { | ||
| 599 | dl->top = dl->top->next; | ||
| 600 | if (dl->top == &scsi_dev_info_list) { | ||
| 601 | kfree(dl); | ||
| 602 | return NULL; | ||
| 603 | } | ||
| 604 | devinfo_table = list_entry(dl->top, | ||
| 605 | struct scsi_dev_info_list_table, | ||
| 606 | node); | ||
| 607 | dl->bottom = devinfo_table->scsi_dev_info_list.next; | ||
| 608 | } | ||
| 609 | |||
| 610 | return dl; | ||
| 472 | } | 611 | } |
| 473 | 612 | ||
| 474 | static void devinfo_seq_stop(struct seq_file *m, void *v) | 613 | static void devinfo_seq_stop(struct seq_file *m, void *v) |
| 475 | { | 614 | { |
| 615 | kfree(v); | ||
| 476 | } | 616 | } |
| 477 | 617 | ||
| 478 | static const struct seq_operations scsi_devinfo_seq_ops = { | 618 | static const struct seq_operations scsi_devinfo_seq_ops = { |
| @@ -549,19 +689,78 @@ MODULE_PARM_DESC(default_dev_flags, | |||
| 549 | **/ | 689 | **/ |
| 550 | void scsi_exit_devinfo(void) | 690 | void scsi_exit_devinfo(void) |
| 551 | { | 691 | { |
| 552 | struct list_head *lh, *lh_next; | ||
| 553 | struct scsi_dev_info_list *devinfo; | ||
| 554 | |||
| 555 | #ifdef CONFIG_SCSI_PROC_FS | 692 | #ifdef CONFIG_SCSI_PROC_FS |
| 556 | remove_proc_entry("scsi/device_info", NULL); | 693 | remove_proc_entry("scsi/device_info", NULL); |
| 557 | #endif | 694 | #endif |
| 558 | 695 | ||
| 559 | list_for_each_safe(lh, lh_next, &scsi_dev_info_list) { | 696 | scsi_dev_info_remove_list(SCSI_DEVINFO_GLOBAL); |
| 697 | } | ||
| 698 | |||
| 699 | /** | ||
| 700 | * scsi_dev_info_add_list - add a new devinfo list | ||
| 701 | * @key: key of the list to add | ||
| 702 | * @name: Name of the list to add (for /proc/scsi/device_info) | ||
| 703 | * | ||
| 704 | * Adds the requested list, returns zero on success, -EEXIST if the | ||
| 705 | * key is already registered to a list, or other error on failure. | ||
| 706 | */ | ||
| 707 | int scsi_dev_info_add_list(int key, const char *name) | ||
| 708 | { | ||
| 709 | struct scsi_dev_info_list_table *devinfo_table = | ||
| 710 | scsi_devinfo_lookup_by_key(key); | ||
| 711 | |||
| 712 | if (!IS_ERR(devinfo_table)) | ||
| 713 | /* list already exists */ | ||
| 714 | return -EEXIST; | ||
| 715 | |||
| 716 | devinfo_table = kmalloc(sizeof(*devinfo_table), GFP_KERNEL); | ||
| 717 | |||
| 718 | if (!devinfo_table) | ||
| 719 | return -ENOMEM; | ||
| 720 | |||
| 721 | INIT_LIST_HEAD(&devinfo_table->node); | ||
| 722 | INIT_LIST_HEAD(&devinfo_table->scsi_dev_info_list); | ||
| 723 | devinfo_table->name = name; | ||
| 724 | devinfo_table->key = key; | ||
| 725 | list_add_tail(&devinfo_table->node, &scsi_dev_info_list); | ||
| 726 | |||
| 727 | return 0; | ||
| 728 | } | ||
| 729 | EXPORT_SYMBOL(scsi_dev_info_add_list); | ||
| 730 | |||
| 731 | /** | ||
| 732 | * scsi_dev_info_remove_list - destroy an added devinfo list | ||
| 733 | * @key: key of the list to destroy | ||
| 734 | * | ||
| 735 | * Iterates over the entire list first, freeing all the values, then | ||
| 736 | * frees the list itself. Returns 0 on success or -EINVAL if the key | ||
| 737 | * can't be found. | ||
| 738 | */ | ||
| 739 | int scsi_dev_info_remove_list(int key) | ||
| 740 | { | ||
| 741 | struct list_head *lh, *lh_next; | ||
| 742 | struct scsi_dev_info_list_table *devinfo_table = | ||
| 743 | scsi_devinfo_lookup_by_key(key); | ||
| 744 | |||
| 745 | if (IS_ERR(devinfo_table)) | ||
| 746 | /* no such list */ | ||
| 747 | return -EINVAL; | ||
| 748 | |||
| 749 | /* remove from the master list */ | ||
| 750 | list_del(&devinfo_table->node); | ||
| 751 | |||
| 752 | list_for_each_safe(lh, lh_next, &devinfo_table->scsi_dev_info_list) { | ||
| 753 | struct scsi_dev_info_list *devinfo; | ||
| 754 | |||
| 560 | devinfo = list_entry(lh, struct scsi_dev_info_list, | 755 | devinfo = list_entry(lh, struct scsi_dev_info_list, |
| 561 | dev_info_list); | 756 | dev_info_list); |
| 562 | kfree(devinfo); | 757 | kfree(devinfo); |
| 563 | } | 758 | } |
| 759 | kfree(devinfo_table); | ||
| 760 | |||
| 761 | return 0; | ||
| 564 | } | 762 | } |
| 763 | EXPORT_SYMBOL(scsi_dev_info_remove_list); | ||
| 565 | 764 | ||
| 566 | /** | 765 | /** |
| 567 | * scsi_init_devinfo - set up the dynamic device list. | 766 | * scsi_init_devinfo - set up the dynamic device list. |
| @@ -577,10 +776,14 @@ int __init scsi_init_devinfo(void) | |||
| 577 | #endif | 776 | #endif |
| 578 | int error, i; | 777 | int error, i; |
| 579 | 778 | ||
| 580 | error = scsi_dev_info_list_add_str(scsi_dev_flags); | 779 | error = scsi_dev_info_add_list(SCSI_DEVINFO_GLOBAL, NULL); |
| 581 | if (error) | 780 | if (error) |
| 582 | return error; | 781 | return error; |
| 583 | 782 | ||
| 783 | error = scsi_dev_info_list_add_str(scsi_dev_flags); | ||
| 784 | if (error) | ||
| 785 | goto out; | ||
| 786 | |||
| 584 | for (i = 0; scsi_static_device_list[i].vendor; i++) { | 787 | for (i = 0; scsi_static_device_list[i].vendor; i++) { |
| 585 | error = scsi_dev_info_list_add(1 /* compatibile */, | 788 | error = scsi_dev_info_list_add(1 /* compatibile */, |
| 586 | scsi_static_device_list[i].vendor, | 789 | scsi_static_device_list[i].vendor, |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 30f3275e119e..f3c40898fc7d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
| @@ -1207,6 +1207,7 @@ int scsi_prep_fn(struct request_queue *q, struct request *req) | |||
| 1207 | ret = scsi_setup_blk_pc_cmnd(sdev, req); | 1207 | ret = scsi_setup_blk_pc_cmnd(sdev, req); |
| 1208 | return scsi_prep_return(q, req, ret); | 1208 | return scsi_prep_return(q, req, ret); |
| 1209 | } | 1209 | } |
| 1210 | EXPORT_SYMBOL(scsi_prep_fn); | ||
| 1210 | 1211 | ||
| 1211 | /* | 1212 | /* |
| 1212 | * scsi_dev_queue_ready: if we can send requests to sdev, return 1 else | 1213 | * scsi_dev_queue_ready: if we can send requests to sdev, return 1 else |
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index fbc83bebdd8e..021e503c8c44 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h | |||
| @@ -39,9 +39,25 @@ static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) | |||
| 39 | #endif | 39 | #endif |
| 40 | 40 | ||
| 41 | /* scsi_devinfo.c */ | 41 | /* scsi_devinfo.c */ |
| 42 | |||
| 43 | /* list of keys for the lists */ | ||
| 44 | enum { | ||
| 45 | SCSI_DEVINFO_GLOBAL = 0, | ||
| 46 | SCSI_DEVINFO_SPI, | ||
| 47 | }; | ||
| 48 | |||
| 42 | extern int scsi_get_device_flags(struct scsi_device *sdev, | 49 | extern int scsi_get_device_flags(struct scsi_device *sdev, |
| 43 | const unsigned char *vendor, | 50 | const unsigned char *vendor, |
| 44 | const unsigned char *model); | 51 | const unsigned char *model); |
| 52 | extern int scsi_get_device_flags_keyed(struct scsi_device *sdev, | ||
| 53 | const unsigned char *vendor, | ||
| 54 | const unsigned char *model, int key); | ||
| 55 | extern int scsi_dev_info_list_add_keyed(int compatible, char *vendor, | ||
| 56 | char *model, char *strflags, | ||
| 57 | int flags, int key); | ||
| 58 | extern int scsi_dev_info_add_list(int key, const char *name); | ||
| 59 | extern int scsi_dev_info_remove_list(int key); | ||
| 60 | |||
| 45 | extern int __init scsi_init_devinfo(void); | 61 | extern int __init scsi_init_devinfo(void); |
| 46 | extern void scsi_exit_devinfo(void); | 62 | extern void scsi_exit_devinfo(void); |
| 47 | 63 | ||
| @@ -71,7 +87,6 @@ extern int scsi_init_queue(void); | |||
| 71 | extern void scsi_exit_queue(void); | 87 | extern void scsi_exit_queue(void); |
| 72 | struct request_queue; | 88 | struct request_queue; |
| 73 | struct request; | 89 | struct request; |
| 74 | extern int scsi_prep_fn(struct request_queue *, struct request *); | ||
| 75 | extern struct kmem_cache *scsi_sdb_cache; | 90 | extern struct kmem_cache *scsi_sdb_cache; |
| 76 | 91 | ||
| 77 | /* scsi_proc.c */ | 92 | /* scsi_proc.c */ |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index fa4711d12744..91482f2dcc50 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
| @@ -420,29 +420,12 @@ static int scsi_bus_resume(struct device * dev) | |||
| 420 | return err; | 420 | return err; |
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | static int scsi_bus_remove(struct device *dev) | ||
| 424 | { | ||
| 425 | struct device_driver *drv = dev->driver; | ||
| 426 | struct scsi_device *sdev = to_scsi_device(dev); | ||
| 427 | int err = 0; | ||
| 428 | |||
| 429 | /* reset the prep_fn back to the default since the | ||
| 430 | * driver may have altered it and it's being removed */ | ||
| 431 | blk_queue_prep_rq(sdev->request_queue, scsi_prep_fn); | ||
| 432 | |||
| 433 | if (drv && drv->remove) | ||
| 434 | err = drv->remove(dev); | ||
| 435 | |||
| 436 | return 0; | ||
| 437 | } | ||
| 438 | |||
| 439 | struct bus_type scsi_bus_type = { | 423 | struct bus_type scsi_bus_type = { |
| 440 | .name = "scsi", | 424 | .name = "scsi", |
| 441 | .match = scsi_bus_match, | 425 | .match = scsi_bus_match, |
| 442 | .uevent = scsi_bus_uevent, | 426 | .uevent = scsi_bus_uevent, |
| 443 | .suspend = scsi_bus_suspend, | 427 | .suspend = scsi_bus_suspend, |
| 444 | .resume = scsi_bus_resume, | 428 | .resume = scsi_bus_resume, |
| 445 | .remove = scsi_bus_remove, | ||
| 446 | }; | 429 | }; |
| 447 | EXPORT_SYMBOL_GPL(scsi_bus_type); | 430 | EXPORT_SYMBOL_GPL(scsi_bus_type); |
| 448 | 431 | ||
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 3f64d93b6c8b..2eee9e6e4fe8 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c | |||
| @@ -3397,7 +3397,6 @@ fc_destroy_bsgjob(struct fc_bsg_job *job) | |||
| 3397 | kfree(job); | 3397 | kfree(job); |
| 3398 | } | 3398 | } |
| 3399 | 3399 | ||
| 3400 | |||
| 3401 | /** | 3400 | /** |
| 3402 | * fc_bsg_jobdone - completion routine for bsg requests that the LLD has | 3401 | * fc_bsg_jobdone - completion routine for bsg requests that the LLD has |
| 3403 | * completed | 3402 | * completed |
| @@ -3408,15 +3407,10 @@ fc_bsg_jobdone(struct fc_bsg_job *job) | |||
| 3408 | { | 3407 | { |
| 3409 | struct request *req = job->req; | 3408 | struct request *req = job->req; |
| 3410 | struct request *rsp = req->next_rq; | 3409 | struct request *rsp = req->next_rq; |
| 3411 | unsigned long flags; | ||
| 3412 | int err; | 3410 | int err; |
| 3413 | 3411 | ||
| 3414 | spin_lock_irqsave(&job->job_lock, flags); | ||
| 3415 | job->state_flags |= FC_RQST_STATE_DONE; | ||
| 3416 | job->ref_cnt--; | ||
| 3417 | spin_unlock_irqrestore(&job->job_lock, flags); | ||
| 3418 | |||
| 3419 | err = job->req->errors = job->reply->result; | 3412 | err = job->req->errors = job->reply->result; |
| 3413 | |||
| 3420 | if (err < 0) | 3414 | if (err < 0) |
| 3421 | /* we're only returning the result field in the reply */ | 3415 | /* we're only returning the result field in the reply */ |
| 3422 | job->req->sense_len = sizeof(uint32_t); | 3416 | job->req->sense_len = sizeof(uint32_t); |
| @@ -3433,13 +3427,27 @@ fc_bsg_jobdone(struct fc_bsg_job *job) | |||
| 3433 | rsp->resid_len -= min(job->reply->reply_payload_rcv_len, | 3427 | rsp->resid_len -= min(job->reply->reply_payload_rcv_len, |
| 3434 | rsp->resid_len); | 3428 | rsp->resid_len); |
| 3435 | } | 3429 | } |
| 3430 | blk_complete_request(req); | ||
| 3431 | } | ||
| 3436 | 3432 | ||
| 3437 | blk_end_request_all(req, err); | 3433 | /** |
| 3434 | * fc_bsg_softirq_done - softirq done routine for destroying the bsg requests | ||
| 3435 | * @req: BSG request that holds the job to be destroyed | ||
| 3436 | */ | ||
| 3437 | static void fc_bsg_softirq_done(struct request *rq) | ||
| 3438 | { | ||
| 3439 | struct fc_bsg_job *job = rq->special; | ||
| 3440 | unsigned long flags; | ||
| 3438 | 3441 | ||
| 3442 | spin_lock_irqsave(&job->job_lock, flags); | ||
| 3443 | job->state_flags |= FC_RQST_STATE_DONE; | ||
| 3444 | job->ref_cnt--; | ||
| 3445 | spin_unlock_irqrestore(&job->job_lock, flags); | ||
| 3446 | |||
| 3447 | blk_end_request_all(rq, rq->errors); | ||
| 3439 | fc_destroy_bsgjob(job); | 3448 | fc_destroy_bsgjob(job); |
| 3440 | } | 3449 | } |
| 3441 | 3450 | ||
| 3442 | |||
| 3443 | /** | 3451 | /** |
| 3444 | * fc_bsg_job_timeout - handler for when a bsg request timesout | 3452 | * fc_bsg_job_timeout - handler for when a bsg request timesout |
| 3445 | * @req: request that timed out | 3453 | * @req: request that timed out |
| @@ -3471,19 +3479,13 @@ fc_bsg_job_timeout(struct request *req) | |||
| 3471 | "abort failed with status %d\n", err); | 3479 | "abort failed with status %d\n", err); |
| 3472 | } | 3480 | } |
| 3473 | 3481 | ||
| 3474 | if (!done) { | ||
| 3475 | spin_lock_irqsave(&job->job_lock, flags); | ||
| 3476 | job->ref_cnt--; | ||
| 3477 | spin_unlock_irqrestore(&job->job_lock, flags); | ||
| 3478 | fc_destroy_bsgjob(job); | ||
| 3479 | } | ||
| 3480 | |||
| 3481 | /* the blk_end_sync_io() doesn't check the error */ | 3482 | /* the blk_end_sync_io() doesn't check the error */ |
| 3482 | return BLK_EH_HANDLED; | 3483 | if (done) |
| 3484 | return BLK_EH_NOT_HANDLED; | ||
| 3485 | else | ||
| 3486 | return BLK_EH_HANDLED; | ||
| 3483 | } | 3487 | } |
| 3484 | 3488 | ||
| 3485 | |||
| 3486 | |||
| 3487 | static int | 3489 | static int |
| 3488 | fc_bsg_map_buffer(struct fc_bsg_buffer *buf, struct request *req) | 3490 | fc_bsg_map_buffer(struct fc_bsg_buffer *buf, struct request *req) |
| 3489 | { | 3491 | { |
| @@ -3859,7 +3861,7 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host) | |||
| 3859 | struct fc_internal *i = to_fc_internal(shost->transportt); | 3861 | struct fc_internal *i = to_fc_internal(shost->transportt); |
| 3860 | struct request_queue *q; | 3862 | struct request_queue *q; |
| 3861 | int err; | 3863 | int err; |
| 3862 | char bsg_name[BUS_ID_SIZE]; /*20*/ | 3864 | char bsg_name[20]; |
| 3863 | 3865 | ||
| 3864 | fc_host->rqst_q = NULL; | 3866 | fc_host->rqst_q = NULL; |
| 3865 | 3867 | ||
| @@ -3879,6 +3881,7 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host) | |||
| 3879 | 3881 | ||
| 3880 | q->queuedata = shost; | 3882 | q->queuedata = shost; |
| 3881 | queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q); | 3883 | queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q); |
| 3884 | blk_queue_softirq_done(q, fc_bsg_softirq_done); | ||
| 3882 | blk_queue_rq_timed_out(q, fc_bsg_job_timeout); | 3885 | blk_queue_rq_timed_out(q, fc_bsg_job_timeout); |
| 3883 | blk_queue_rq_timeout(q, FC_DEFAULT_BSG_TIMEOUT); | 3886 | blk_queue_rq_timeout(q, FC_DEFAULT_BSG_TIMEOUT); |
| 3884 | 3887 | ||
| @@ -3924,6 +3927,7 @@ fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport) | |||
| 3924 | 3927 | ||
| 3925 | q->queuedata = rport; | 3928 | q->queuedata = rport; |
| 3926 | queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q); | 3929 | queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q); |
| 3930 | blk_queue_softirq_done(q, fc_bsg_softirq_done); | ||
| 3927 | blk_queue_rq_timed_out(q, fc_bsg_job_timeout); | 3931 | blk_queue_rq_timed_out(q, fc_bsg_job_timeout); |
| 3928 | blk_queue_rq_timeout(q, BLK_DEFAULT_SG_TIMEOUT); | 3932 | blk_queue_rq_timeout(q, BLK_DEFAULT_SG_TIMEOUT); |
| 3929 | 3933 | ||
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c index f3e664628d7a..783e33c65eb7 100644 --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c | |||
| @@ -692,6 +692,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id) | |||
| 692 | "Too many iscsi targets. Max " | 692 | "Too many iscsi targets. Max " |
| 693 | "number of targets is %d.\n", | 693 | "number of targets is %d.\n", |
| 694 | ISCSI_MAX_TARGET - 1); | 694 | ISCSI_MAX_TARGET - 1); |
| 695 | err = -EOVERFLOW; | ||
| 695 | goto release_host; | 696 | goto release_host; |
| 696 | } | 697 | } |
| 697 | } | 698 | } |
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index d606452297cf..0895d3c71b03 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c | |||
| @@ -173,9 +173,9 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost, | |||
| 173 | ret = handler(shost, rphy, req); | 173 | ret = handler(shost, rphy, req); |
| 174 | req->errors = ret; | 174 | req->errors = ret; |
| 175 | 175 | ||
| 176 | spin_lock_irq(q->queue_lock); | 176 | blk_end_request_all(req, ret); |
| 177 | 177 | ||
| 178 | req->end_io(req, ret); | 178 | spin_lock_irq(q->queue_lock); |
| 179 | } | 179 | } |
| 180 | } | 180 | } |
| 181 | 181 | ||
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 654a34fb04cb..c25bd9a34e02 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c | |||
| @@ -46,6 +46,22 @@ | |||
| 46 | #define DV_RETRIES 3 /* should only need at most | 46 | #define DV_RETRIES 3 /* should only need at most |
| 47 | * two cc/ua clears */ | 47 | * two cc/ua clears */ |
| 48 | 48 | ||
| 49 | /* Our blacklist flags */ | ||
| 50 | enum { | ||
| 51 | SPI_BLIST_NOIUS = 0x1, | ||
| 52 | }; | ||
| 53 | |||
| 54 | /* blacklist table, modelled on scsi_devinfo.c */ | ||
| 55 | static struct { | ||
| 56 | char *vendor; | ||
| 57 | char *model; | ||
| 58 | unsigned flags; | ||
| 59 | } spi_static_device_list[] __initdata = { | ||
| 60 | {"HP", "Ultrium 3-SCSI", SPI_BLIST_NOIUS }, | ||
| 61 | {"IBM", "ULTRIUM-TD3", SPI_BLIST_NOIUS }, | ||
| 62 | {NULL, NULL, 0} | ||
| 63 | }; | ||
| 64 | |||
| 49 | /* Private data accessors (keep these out of the header file) */ | 65 | /* Private data accessors (keep these out of the header file) */ |
| 50 | #define spi_dv_in_progress(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_in_progress) | 66 | #define spi_dv_in_progress(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_in_progress) |
| 51 | #define spi_dv_mutex(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_mutex) | 67 | #define spi_dv_mutex(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_mutex) |
| @@ -207,6 +223,9 @@ static int spi_device_configure(struct transport_container *tc, | |||
| 207 | { | 223 | { |
| 208 | struct scsi_device *sdev = to_scsi_device(dev); | 224 | struct scsi_device *sdev = to_scsi_device(dev); |
| 209 | struct scsi_target *starget = sdev->sdev_target; | 225 | struct scsi_target *starget = sdev->sdev_target; |
| 226 | unsigned bflags = scsi_get_device_flags_keyed(sdev, &sdev->inquiry[8], | ||
| 227 | &sdev->inquiry[16], | ||
| 228 | SCSI_DEVINFO_SPI); | ||
| 210 | 229 | ||
| 211 | /* Populate the target capability fields with the values | 230 | /* Populate the target capability fields with the values |
| 212 | * gleaned from the device inquiry */ | 231 | * gleaned from the device inquiry */ |
| @@ -216,6 +235,10 @@ static int spi_device_configure(struct transport_container *tc, | |||
| 216 | spi_support_dt(starget) = scsi_device_dt(sdev); | 235 | spi_support_dt(starget) = scsi_device_dt(sdev); |
| 217 | spi_support_dt_only(starget) = scsi_device_dt_only(sdev); | 236 | spi_support_dt_only(starget) = scsi_device_dt_only(sdev); |
| 218 | spi_support_ius(starget) = scsi_device_ius(sdev); | 237 | spi_support_ius(starget) = scsi_device_ius(sdev); |
| 238 | if (bflags & SPI_BLIST_NOIUS) { | ||
| 239 | dev_info(dev, "Information Units disabled by blacklist\n"); | ||
| 240 | spi_support_ius(starget) = 0; | ||
| 241 | } | ||
| 219 | spi_support_qas(starget) = scsi_device_qas(sdev); | 242 | spi_support_qas(starget) = scsi_device_qas(sdev); |
| 220 | 243 | ||
| 221 | return 0; | 244 | return 0; |
| @@ -833,7 +856,7 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) | |||
| 833 | return; | 856 | return; |
| 834 | } | 857 | } |
| 835 | 858 | ||
| 836 | if (!scsi_device_wide(sdev)) { | 859 | if (!spi_support_wide(starget)) { |
| 837 | spi_max_width(starget) = 0; | 860 | spi_max_width(starget) = 0; |
| 838 | max_width = 0; | 861 | max_width = 0; |
| 839 | } | 862 | } |
| @@ -860,7 +883,7 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) | |||
| 860 | return; | 883 | return; |
| 861 | 884 | ||
| 862 | /* device can't handle synchronous */ | 885 | /* device can't handle synchronous */ |
| 863 | if (!scsi_device_sync(sdev) && !scsi_device_dt(sdev)) | 886 | if (!spi_support_sync(starget) && !spi_support_dt(starget)) |
| 864 | return; | 887 | return; |
| 865 | 888 | ||
| 866 | /* len == -1 is the signal that we need to ascertain the | 889 | /* len == -1 is the signal that we need to ascertain the |
| @@ -876,13 +899,14 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) | |||
| 876 | 899 | ||
| 877 | /* try QAS requests; this should be harmless to set if the | 900 | /* try QAS requests; this should be harmless to set if the |
| 878 | * target supports it */ | 901 | * target supports it */ |
| 879 | if (scsi_device_qas(sdev) && spi_max_qas(starget)) { | 902 | if (spi_support_qas(starget) && spi_max_qas(starget)) { |
| 880 | DV_SET(qas, 1); | 903 | DV_SET(qas, 1); |
| 881 | } else { | 904 | } else { |
| 882 | DV_SET(qas, 0); | 905 | DV_SET(qas, 0); |
| 883 | } | 906 | } |
| 884 | 907 | ||
| 885 | if (scsi_device_ius(sdev) && spi_max_iu(starget) && min_period < 9) { | 908 | if (spi_support_ius(starget) && spi_max_iu(starget) && |
| 909 | min_period < 9) { | ||
| 886 | /* This u320 (or u640). Set IU transfers */ | 910 | /* This u320 (or u640). Set IU transfers */ |
| 887 | DV_SET(iu, 1); | 911 | DV_SET(iu, 1); |
| 888 | /* Then set the optional parameters */ | 912 | /* Then set the optional parameters */ |
| @@ -902,7 +926,7 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) | |||
| 902 | i->f->get_signalling(shost); | 926 | i->f->get_signalling(shost); |
| 903 | if (spi_signalling(shost) == SPI_SIGNAL_SE || | 927 | if (spi_signalling(shost) == SPI_SIGNAL_SE || |
| 904 | spi_signalling(shost) == SPI_SIGNAL_HVD || | 928 | spi_signalling(shost) == SPI_SIGNAL_HVD || |
| 905 | !scsi_device_dt(sdev)) { | 929 | !spi_support_dt(starget)) { |
| 906 | DV_SET(dt, 0); | 930 | DV_SET(dt, 0); |
| 907 | } else { | 931 | } else { |
| 908 | DV_SET(dt, 1); | 932 | DV_SET(dt, 1); |
| @@ -1523,7 +1547,21 @@ EXPORT_SYMBOL(spi_release_transport); | |||
| 1523 | 1547 | ||
| 1524 | static __init int spi_transport_init(void) | 1548 | static __init int spi_transport_init(void) |
| 1525 | { | 1549 | { |
| 1526 | int error = transport_class_register(&spi_transport_class); | 1550 | int error = scsi_dev_info_add_list(SCSI_DEVINFO_SPI, |
| 1551 | "SCSI Parallel Transport Class"); | ||
| 1552 | if (!error) { | ||
| 1553 | int i; | ||
| 1554 | |||
| 1555 | for (i = 0; spi_static_device_list[i].vendor; i++) | ||
| 1556 | scsi_dev_info_list_add_keyed(1, /* compatible */ | ||
| 1557 | spi_static_device_list[i].vendor, | ||
| 1558 | spi_static_device_list[i].model, | ||
| 1559 | NULL, | ||
| 1560 | spi_static_device_list[i].flags, | ||
| 1561 | SCSI_DEVINFO_SPI); | ||
| 1562 | } | ||
| 1563 | |||
| 1564 | error = transport_class_register(&spi_transport_class); | ||
| 1527 | if (error) | 1565 | if (error) |
| 1528 | return error; | 1566 | return error; |
| 1529 | error = anon_transport_class_register(&spi_device_class); | 1567 | error = anon_transport_class_register(&spi_device_class); |
| @@ -1535,6 +1573,7 @@ static void __exit spi_transport_exit(void) | |||
| 1535 | transport_class_unregister(&spi_transport_class); | 1573 | transport_class_unregister(&spi_transport_class); |
| 1536 | anon_transport_class_unregister(&spi_device_class); | 1574 | anon_transport_class_unregister(&spi_device_class); |
| 1537 | transport_class_unregister(&spi_host_class); | 1575 | transport_class_unregister(&spi_host_class); |
| 1576 | scsi_dev_info_remove_list(SCSI_DEVINFO_SPI); | ||
| 1538 | } | 1577 | } |
| 1539 | 1578 | ||
| 1540 | MODULE_AUTHOR("Martin Hicks"); | 1579 | MODULE_AUTHOR("Martin Hicks"); |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 878b17a9af30..5616cd780ff3 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
| @@ -1307,6 +1307,7 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, | |||
| 1307 | int sense_valid = 0; | 1307 | int sense_valid = 0; |
| 1308 | int the_result; | 1308 | int the_result; |
| 1309 | int retries = 3; | 1309 | int retries = 3; |
| 1310 | unsigned int alignment; | ||
| 1310 | unsigned long long lba; | 1311 | unsigned long long lba; |
| 1311 | unsigned sector_size; | 1312 | unsigned sector_size; |
| 1312 | 1313 | ||
| @@ -1358,6 +1359,16 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, | |||
| 1358 | return -EOVERFLOW; | 1359 | return -EOVERFLOW; |
| 1359 | } | 1360 | } |
| 1360 | 1361 | ||
| 1362 | /* Logical blocks per physical block exponent */ | ||
| 1363 | sdkp->hw_sector_size = (1 << (buffer[13] & 0xf)) * sector_size; | ||
| 1364 | |||
| 1365 | /* Lowest aligned logical block */ | ||
| 1366 | alignment = ((buffer[14] & 0x3f) << 8 | buffer[15]) * sector_size; | ||
| 1367 | blk_queue_alignment_offset(sdp->request_queue, alignment); | ||
| 1368 | if (alignment && sdkp->first_scan) | ||
| 1369 | sd_printk(KERN_NOTICE, sdkp, | ||
| 1370 | "physical block alignment offset: %u\n", alignment); | ||
| 1371 | |||
| 1361 | sdkp->capacity = lba + 1; | 1372 | sdkp->capacity = lba + 1; |
| 1362 | return sector_size; | 1373 | return sector_size; |
| 1363 | } | 1374 | } |
| @@ -1409,6 +1420,7 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, | |||
| 1409 | } | 1420 | } |
| 1410 | 1421 | ||
| 1411 | sdkp->capacity = lba + 1; | 1422 | sdkp->capacity = lba + 1; |
| 1423 | sdkp->hw_sector_size = sector_size; | ||
| 1412 | return sector_size; | 1424 | return sector_size; |
| 1413 | } | 1425 | } |
| 1414 | 1426 | ||
| @@ -1521,11 +1533,17 @@ got_data: | |||
| 1521 | string_get_size(sz, STRING_UNITS_10, cap_str_10, | 1533 | string_get_size(sz, STRING_UNITS_10, cap_str_10, |
| 1522 | sizeof(cap_str_10)); | 1534 | sizeof(cap_str_10)); |
| 1523 | 1535 | ||
| 1524 | if (sdkp->first_scan || old_capacity != sdkp->capacity) | 1536 | if (sdkp->first_scan || old_capacity != sdkp->capacity) { |
| 1525 | sd_printk(KERN_NOTICE, sdkp, | 1537 | sd_printk(KERN_NOTICE, sdkp, |
| 1526 | "%llu %d-byte hardware sectors: (%s/%s)\n", | 1538 | "%llu %d-byte logical blocks: (%s/%s)\n", |
| 1527 | (unsigned long long)sdkp->capacity, | 1539 | (unsigned long long)sdkp->capacity, |
| 1528 | sector_size, cap_str_10, cap_str_2); | 1540 | sector_size, cap_str_10, cap_str_2); |
| 1541 | |||
| 1542 | if (sdkp->hw_sector_size != sector_size) | ||
| 1543 | sd_printk(KERN_NOTICE, sdkp, | ||
| 1544 | "%u-byte physical blocks\n", | ||
| 1545 | sdkp->hw_sector_size); | ||
| 1546 | } | ||
| 1529 | } | 1547 | } |
| 1530 | 1548 | ||
| 1531 | /* Rescale capacity to 512-byte units */ | 1549 | /* Rescale capacity to 512-byte units */ |
| @@ -1538,6 +1556,7 @@ got_data: | |||
| 1538 | else if (sector_size == 256) | 1556 | else if (sector_size == 256) |
| 1539 | sdkp->capacity >>= 1; | 1557 | sdkp->capacity >>= 1; |
| 1540 | 1558 | ||
| 1559 | blk_queue_physical_block_size(sdp->request_queue, sdkp->hw_sector_size); | ||
| 1541 | sdkp->device->sector_size = sector_size; | 1560 | sdkp->device->sector_size = sector_size; |
| 1542 | } | 1561 | } |
| 1543 | 1562 | ||
| @@ -1776,6 +1795,52 @@ void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) | |||
| 1776 | } | 1795 | } |
| 1777 | 1796 | ||
| 1778 | /** | 1797 | /** |
| 1798 | * sd_read_block_limits - Query disk device for preferred I/O sizes. | ||
| 1799 | * @disk: disk to query | ||
| 1800 | */ | ||
| 1801 | static void sd_read_block_limits(struct scsi_disk *sdkp) | ||
| 1802 | { | ||
| 1803 | unsigned int sector_sz = sdkp->device->sector_size; | ||
| 1804 | char *buffer; | ||
| 1805 | |||
| 1806 | /* Block Limits VPD */ | ||
| 1807 | buffer = scsi_get_vpd_page(sdkp->device, 0xb0); | ||
| 1808 | |||
| 1809 | if (buffer == NULL) | ||
| 1810 | return; | ||
| 1811 | |||
| 1812 | blk_queue_io_min(sdkp->disk->queue, | ||
| 1813 | get_unaligned_be16(&buffer[6]) * sector_sz); | ||
| 1814 | blk_queue_io_opt(sdkp->disk->queue, | ||
| 1815 | get_unaligned_be32(&buffer[12]) * sector_sz); | ||
| 1816 | |||
| 1817 | kfree(buffer); | ||
| 1818 | } | ||
| 1819 | |||
| 1820 | /** | ||
| 1821 | * sd_read_block_characteristics - Query block dev. characteristics | ||
| 1822 | * @disk: disk to query | ||
| 1823 | */ | ||
| 1824 | static void sd_read_block_characteristics(struct scsi_disk *sdkp) | ||
| 1825 | { | ||
| 1826 | char *buffer; | ||
| 1827 | u16 rot; | ||
| 1828 | |||
| 1829 | /* Block Device Characteristics VPD */ | ||
| 1830 | buffer = scsi_get_vpd_page(sdkp->device, 0xb1); | ||
| 1831 | |||
| 1832 | if (buffer == NULL) | ||
| 1833 | return; | ||
| 1834 | |||
| 1835 | rot = get_unaligned_be16(&buffer[4]); | ||
| 1836 | |||
| 1837 | if (rot == 1) | ||
| 1838 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, sdkp->disk->queue); | ||
| 1839 | |||
| 1840 | kfree(buffer); | ||
| 1841 | } | ||
| 1842 | |||
| 1843 | /** | ||
| 1779 | * sd_revalidate_disk - called the first time a new disk is seen, | 1844 | * sd_revalidate_disk - called the first time a new disk is seen, |
| 1780 | * performs disk spin up, read_capacity, etc. | 1845 | * performs disk spin up, read_capacity, etc. |
| 1781 | * @disk: struct gendisk we care about | 1846 | * @disk: struct gendisk we care about |
| @@ -1812,6 +1877,8 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
| 1812 | */ | 1877 | */ |
| 1813 | if (sdkp->media_present) { | 1878 | if (sdkp->media_present) { |
| 1814 | sd_read_capacity(sdkp, buffer); | 1879 | sd_read_capacity(sdkp, buffer); |
| 1880 | sd_read_block_limits(sdkp); | ||
| 1881 | sd_read_block_characteristics(sdkp); | ||
| 1815 | sd_read_write_protect_flag(sdkp, buffer); | 1882 | sd_read_write_protect_flag(sdkp, buffer); |
| 1816 | sd_read_cache_type(sdkp, buffer); | 1883 | sd_read_cache_type(sdkp, buffer); |
| 1817 | sd_read_app_tag_own(sdkp, buffer); | 1884 | sd_read_app_tag_own(sdkp, buffer); |
| @@ -1934,6 +2001,8 @@ static void sd_probe_async(void *data, async_cookie_t cookie) | |||
| 1934 | add_disk(gd); | 2001 | add_disk(gd); |
| 1935 | sd_dif_config_host(sdkp); | 2002 | sd_dif_config_host(sdkp); |
| 1936 | 2003 | ||
| 2004 | sd_revalidate_disk(gd); | ||
| 2005 | |||
| 1937 | sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", | 2006 | sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", |
| 1938 | sdp->removable ? "removable " : ""); | 2007 | sdp->removable ? "removable " : ""); |
| 1939 | } | 2008 | } |
| @@ -2054,6 +2123,7 @@ static int sd_remove(struct device *dev) | |||
| 2054 | 2123 | ||
| 2055 | async_synchronize_full(); | 2124 | async_synchronize_full(); |
| 2056 | sdkp = dev_get_drvdata(dev); | 2125 | sdkp = dev_get_drvdata(dev); |
| 2126 | blk_queue_prep_rq(sdkp->device->request_queue, scsi_prep_fn); | ||
| 2057 | device_del(&sdkp->dev); | 2127 | device_del(&sdkp->dev); |
| 2058 | del_gendisk(sdkp->disk); | 2128 | del_gendisk(sdkp->disk); |
| 2059 | sd_shutdown(dev); | 2129 | sd_shutdown(dev); |
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 708778cf5f06..8474b5bad3fe 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h | |||
| @@ -45,6 +45,7 @@ struct scsi_disk { | |||
| 45 | unsigned int openers; /* protected by BKL for now, yuck */ | 45 | unsigned int openers; /* protected by BKL for now, yuck */ |
| 46 | sector_t capacity; /* size in 512-byte sectors */ | 46 | sector_t capacity; /* size in 512-byte sectors */ |
| 47 | u32 index; | 47 | u32 index; |
| 48 | unsigned short hw_sector_size; | ||
| 48 | u8 media_present; | 49 | u8 media_present; |
| 49 | u8 write_prot; | 50 | u8 write_prot; |
| 50 | u8 protection_type;/* Data Integrity Field */ | 51 | u8 protection_type;/* Data Integrity Field */ |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index cd350dfc1216..cce0fe4c8a3b 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
| @@ -881,6 +881,7 @@ static int sr_remove(struct device *dev) | |||
| 881 | { | 881 | { |
| 882 | struct scsi_cd *cd = dev_get_drvdata(dev); | 882 | struct scsi_cd *cd = dev_get_drvdata(dev); |
| 883 | 883 | ||
| 884 | blk_queue_prep_rq(cd->device->request_queue, scsi_prep_fn); | ||
| 884 | del_gendisk(cd->disk); | 885 | del_gendisk(cd->disk); |
| 885 | 886 | ||
| 886 | mutex_lock(&sr_ref_mutex); | 887 | mutex_lock(&sr_ref_mutex); |
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 69ad4945c936..297deb817a5d 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c | |||
| @@ -2321,8 +2321,9 @@ static void sym_int_par (struct sym_hcb *np, u_short sist) | |||
| 2321 | int phase = cmd & 7; | 2321 | int phase = cmd & 7; |
| 2322 | struct sym_ccb *cp = sym_ccb_from_dsa(np, dsa); | 2322 | struct sym_ccb *cp = sym_ccb_from_dsa(np, dsa); |
| 2323 | 2323 | ||
| 2324 | printf("%s: SCSI parity error detected: SCR1=%d DBC=%x SBCL=%x\n", | 2324 | if (printk_ratelimit()) |
| 2325 | sym_name(np), hsts, dbc, sbcl); | 2325 | printf("%s: SCSI parity error detected: SCR1=%d DBC=%x SBCL=%x\n", |
| 2326 | sym_name(np), hsts, dbc, sbcl); | ||
| 2326 | 2327 | ||
| 2327 | /* | 2328 | /* |
| 2328 | * Check that the chip is connected to the SCSI BUS. | 2329 | * Check that the chip is connected to the SCSI BUS. |
diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c index 135ae18bfce8..eef2bb298d9f 100644 --- a/drivers/video/nvidia/nv_setup.c +++ b/drivers/video/nvidia/nv_setup.c | |||
| @@ -543,8 +543,7 @@ int NVCommonSetup(struct fb_info *info) | |||
| 543 | } else if (analog_on_B) { | 543 | } else if (analog_on_B) { |
| 544 | CRTCnumber = outputBfromCRTC; | 544 | CRTCnumber = outputBfromCRTC; |
| 545 | FlatPanel = 0; | 545 | FlatPanel = 0; |
| 546 | printk("nvidiafb: CRTC %i" | 546 | printk("nvidiafb: CRTC %i appears to have a " |
| 547 | "appears to have a " | ||
| 548 | "CRT attached\n", CRTCnumber); | 547 | "CRT attached\n", CRTCnumber); |
| 549 | } else if (slaved_on_A) { | 548 | } else if (slaved_on_A) { |
| 550 | CRTCnumber = 0; | 549 | CRTCnumber = 0; |
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index b166f2852a64..b1ccc04f3c9a 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
| @@ -240,6 +240,32 @@ config ORION_WATCHDOG | |||
| 240 | To compile this driver as a module, choose M here: the | 240 | To compile this driver as a module, choose M here: the |
| 241 | module will be called orion_wdt. | 241 | module will be called orion_wdt. |
| 242 | 242 | ||
| 243 | config COH901327_WATCHDOG | ||
| 244 | bool "ST-Ericsson COH 901 327 watchdog" | ||
| 245 | depends on ARCH_U300 | ||
| 246 | default y if MACH_U300 | ||
| 247 | help | ||
| 248 | Say Y here to include Watchdog timer support for the | ||
| 249 | watchdog embedded into the ST-Ericsson U300 series platforms. | ||
| 250 | This watchdog is used to reset the system and thus cannot be | ||
| 251 | compiled as a module. | ||
| 252 | |||
| 253 | config TWL4030_WATCHDOG | ||
| 254 | tristate "TWL4030 Watchdog" | ||
| 255 | depends on TWL4030_CORE | ||
| 256 | help | ||
| 257 | Support for TI TWL4030 watchdog. Say 'Y' here to enable the | ||
| 258 | watchdog timer support for TWL4030 chips. | ||
| 259 | |||
| 260 | config STMP3XXX_WATCHDOG | ||
| 261 | tristate "Freescale STMP3XXX watchdog" | ||
| 262 | depends on ARCH_STMP3XXX | ||
| 263 | help | ||
| 264 | Say Y here if to include support for the watchdog timer | ||
| 265 | for the Sigmatel STMP37XX/378X SoC. | ||
| 266 | To compile this driver as a module, choose M here: the | ||
| 267 | module will be called stmp3xxx_wdt. | ||
| 268 | |||
| 243 | # AVR32 Architecture | 269 | # AVR32 Architecture |
| 244 | 270 | ||
| 245 | config AT32AP700X_WDT | 271 | config AT32AP700X_WDT |
| @@ -703,6 +729,12 @@ config SBC_EPX_C3_WATCHDOG | |||
| 703 | 729 | ||
| 704 | # MIPS Architecture | 730 | # MIPS Architecture |
| 705 | 731 | ||
| 732 | config BCM47XX_WDT | ||
| 733 | tristate "Broadcom BCM47xx Watchdog Timer" | ||
| 734 | depends on BCM47XX | ||
| 735 | help | ||
| 736 | Hardware driver for the Broadcom BCM47xx Watchog Timer. | ||
| 737 | |||
| 706 | config RC32434_WDT | 738 | config RC32434_WDT |
| 707 | tristate "IDT RC32434 SoC Watchdog Timer" | 739 | tristate "IDT RC32434 SoC Watchdog Timer" |
| 708 | depends on MIKROTIK_RB532 | 740 | depends on MIKROTIK_RB532 |
| @@ -729,6 +761,15 @@ config WDT_MTX1 | |||
| 729 | Hardware driver for the MTX-1 boards. This is a watchdog timer that | 761 | Hardware driver for the MTX-1 boards. This is a watchdog timer that |
| 730 | will reboot the machine after a 100 seconds timer expired. | 762 | will reboot the machine after a 100 seconds timer expired. |
| 731 | 763 | ||
| 764 | config PNX833X_WDT | ||
| 765 | tristate "PNX833x Hardware Watchdog" | ||
| 766 | depends on SOC_PNX8335 | ||
| 767 | help | ||
| 768 | Hardware driver for the PNX833x's watchdog. This is a | ||
| 769 | watchdog timer that will reboot the machine after a programable | ||
| 770 | timer has expired and no process has written to /dev/watchdog during | ||
| 771 | that time. | ||
| 772 | |||
| 732 | config WDT_RM9K_GPI | 773 | config WDT_RM9K_GPI |
| 733 | tristate "RM9000/GPI hardware watchdog" | 774 | tristate "RM9000/GPI hardware watchdog" |
| 734 | depends on CPU_RM9000 | 775 | depends on CPU_RM9000 |
| @@ -966,24 +1007,16 @@ config WDTPCI | |||
| 966 | ---help--- | 1007 | ---help--- |
| 967 | If you have a PCI-WDT500/501 watchdog board, say Y here, otherwise N. | 1008 | If you have a PCI-WDT500/501 watchdog board, say Y here, otherwise N. |
| 968 | 1009 | ||
| 969 | To compile this driver as a module, choose M here: the | 1010 | If you have a PCI-WDT501 watchdog board then you can enable the |
| 970 | module will be called wdt_pci. | 1011 | temperature sensor by setting the type parameter to 501. |
| 971 | |||
| 972 | config WDT_501_PCI | ||
| 973 | bool "PCI-WDT501 features" | ||
| 974 | depends on WDTPCI | ||
| 975 | help | ||
| 976 | Saying Y here and creating a character special file /dev/temperature | ||
| 977 | with major number 10 and minor number 131 ("man mknod") will give | ||
| 978 | you a thermometer inside your computer: reading from | ||
| 979 | /dev/temperature yields one byte, the temperature in degrees | ||
| 980 | Fahrenheit. This works only if you have a PCI-WDT501 watchdog board | ||
| 981 | installed. | ||
| 982 | 1012 | ||
| 983 | If you want to enable the Fan Tachometer on the PCI-WDT501, then you | 1013 | If you want to enable the Fan Tachometer on the PCI-WDT501, then you |
| 984 | can do this via the tachometer parameter. Only do this if you have a | 1014 | can do this via the tachometer parameter. Only do this if you have a |
| 985 | fan tachometer actually set up. | 1015 | fan tachometer actually set up. |
| 986 | 1016 | ||
| 1017 | To compile this driver as a module, choose M here: the | ||
| 1018 | module will be called wdt_pci. | ||
| 1019 | |||
| 987 | # | 1020 | # |
| 988 | # USB-based Watchdog Cards | 1021 | # USB-based Watchdog Cards |
| 989 | # | 1022 | # |
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index c3afa14d5be1..3d774294a2b7 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile | |||
| @@ -28,6 +28,7 @@ obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o | |||
| 28 | obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o | 28 | obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o |
| 29 | obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o | 29 | obj-$(CONFIG_AT91SAM9X_WATCHDOG) += at91sam9_wdt.o |
| 30 | obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o | 30 | obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o |
| 31 | obj-$(CONFIG_TWL4030_WATCHDOG) += twl4030_wdt.o | ||
| 31 | obj-$(CONFIG_21285_WATCHDOG) += wdt285.o | 32 | obj-$(CONFIG_21285_WATCHDOG) += wdt285.o |
| 32 | obj-$(CONFIG_977_WATCHDOG) += wdt977.o | 33 | obj-$(CONFIG_977_WATCHDOG) += wdt977.o |
| 33 | obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o | 34 | obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o |
| @@ -41,6 +42,8 @@ obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o | |||
| 41 | obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o | 42 | obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o |
| 42 | obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o | 43 | obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o |
| 43 | obj-$(CONFIG_ORION_WATCHDOG) += orion_wdt.o | 44 | obj-$(CONFIG_ORION_WATCHDOG) += orion_wdt.o |
| 45 | obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o | ||
| 46 | obj-$(CONFIG_STMP3XXX_WATCHDOG) += stmp3xxx_wdt.o | ||
| 44 | 47 | ||
| 45 | # AVR32 Architecture | 48 | # AVR32 Architecture |
| 46 | obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o | 49 | obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o |
| @@ -98,9 +101,11 @@ obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o | |||
| 98 | # M68KNOMMU Architecture | 101 | # M68KNOMMU Architecture |
| 99 | 102 | ||
| 100 | # MIPS Architecture | 103 | # MIPS Architecture |
| 104 | obj-$(CONFIG_BCM47XX_WDT) += bcm47xx_wdt.o | ||
| 101 | obj-$(CONFIG_RC32434_WDT) += rc32434_wdt.o | 105 | obj-$(CONFIG_RC32434_WDT) += rc32434_wdt.o |
| 102 | obj-$(CONFIG_INDYDOG) += indydog.o | 106 | obj-$(CONFIG_INDYDOG) += indydog.o |
| 103 | obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o | 107 | obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o |
| 108 | obj-$(CONFIG_PNX833X_WDT) += pnx833x_wdt.o | ||
| 104 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o | 109 | obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o |
| 105 | obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o | 110 | obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o |
| 106 | obj-$(CONFIG_AR7_WDT) += ar7_wdt.o | 111 | obj-$(CONFIG_AR7_WDT) += ar7_wdt.o |
diff --git a/drivers/watchdog/bcm47xx_wdt.c b/drivers/watchdog/bcm47xx_wdt.c new file mode 100644 index 000000000000..5c7011cda6a6 --- /dev/null +++ b/drivers/watchdog/bcm47xx_wdt.c | |||
| @@ -0,0 +1,286 @@ | |||
| 1 | /* | ||
| 2 | * Watchdog driver for Broadcom BCM47XX | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008 Aleksandar Radovanovic <biblbroks@sezampro.rs> | ||
| 5 | * Copyright (C) 2009 Matthieu CASTET <castet.matthieu@free.fr> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU General Public License | ||
| 9 | * as published by the Free Software Foundation; either version | ||
| 10 | * 2 of the License, or (at your option) any later version. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/bitops.h> | ||
| 14 | #include <linux/errno.h> | ||
| 15 | #include <linux/fs.h> | ||
| 16 | #include <linux/init.h> | ||
| 17 | #include <linux/kernel.h> | ||
| 18 | #include <linux/miscdevice.h> | ||
| 19 | #include <linux/module.h> | ||
| 20 | #include <linux/moduleparam.h> | ||
| 21 | #include <linux/reboot.h> | ||
| 22 | #include <linux/types.h> | ||
| 23 | #include <linux/uaccess.h> | ||
| 24 | #include <linux/watchdog.h> | ||
| 25 | #include <linux/timer.h> | ||
| 26 | #include <linux/jiffies.h> | ||
| 27 | #include <linux/ssb/ssb_embedded.h> | ||
| 28 | #include <asm/mach-bcm47xx/bcm47xx.h> | ||
| 29 | |||
| 30 | #define DRV_NAME "bcm47xx_wdt" | ||
| 31 | |||
| 32 | #define WDT_DEFAULT_TIME 30 /* seconds */ | ||
| 33 | #define WDT_MAX_TIME 255 /* seconds */ | ||
| 34 | |||
| 35 | static int wdt_time = WDT_DEFAULT_TIME; | ||
| 36 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
| 37 | |||
| 38 | module_param(wdt_time, int, 0); | ||
| 39 | MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default=" | ||
| 40 | __MODULE_STRING(WDT_DEFAULT_TIME) ")"); | ||
| 41 | |||
| 42 | #ifdef CONFIG_WATCHDOG_NOWAYOUT | ||
| 43 | module_param(nowayout, int, 0); | ||
| 44 | MODULE_PARM_DESC(nowayout, | ||
| 45 | "Watchdog cannot be stopped once started (default=" | ||
| 46 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
| 47 | #endif | ||
| 48 | |||
| 49 | static unsigned long bcm47xx_wdt_busy; | ||
| 50 | static char expect_release; | ||
| 51 | static struct timer_list wdt_timer; | ||
| 52 | static atomic_t ticks; | ||
| 53 | |||
| 54 | static inline void bcm47xx_wdt_hw_start(void) | ||
| 55 | { | ||
| 56 | /* this is 2,5s on 100Mhz clock and 2s on 133 Mhz */ | ||
| 57 | ssb_watchdog_timer_set(&ssb_bcm47xx, 0xfffffff); | ||
| 58 | } | ||
| 59 | |||
| 60 | static inline int bcm47xx_wdt_hw_stop(void) | ||
| 61 | { | ||
| 62 | return ssb_watchdog_timer_set(&ssb_bcm47xx, 0); | ||
| 63 | } | ||
| 64 | |||
| 65 | static void bcm47xx_timer_tick(unsigned long unused) | ||
| 66 | { | ||
| 67 | if (!atomic_dec_and_test(&ticks)) { | ||
| 68 | bcm47xx_wdt_hw_start(); | ||
| 69 | mod_timer(&wdt_timer, jiffies + HZ); | ||
| 70 | } else { | ||
| 71 | printk(KERN_CRIT DRV_NAME "Watchdog will fire soon!!!\n"); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | static inline void bcm47xx_wdt_pet(void) | ||
| 76 | { | ||
| 77 | atomic_set(&ticks, wdt_time); | ||
| 78 | } | ||
| 79 | |||
| 80 | static void bcm47xx_wdt_start(void) | ||
| 81 | { | ||
| 82 | bcm47xx_wdt_pet(); | ||
| 83 | bcm47xx_timer_tick(0); | ||
| 84 | } | ||
| 85 | |||
| 86 | static void bcm47xx_wdt_pause(void) | ||
| 87 | { | ||
| 88 | del_timer_sync(&wdt_timer); | ||
| 89 | bcm47xx_wdt_hw_stop(); | ||
| 90 | } | ||
| 91 | |||
| 92 | static void bcm47xx_wdt_stop(void) | ||
| 93 | { | ||
| 94 | bcm47xx_wdt_pause(); | ||
| 95 | } | ||
| 96 | |||
| 97 | static int bcm47xx_wdt_settimeout(int new_time) | ||
| 98 | { | ||
| 99 | if ((new_time <= 0) || (new_time > WDT_MAX_TIME)) | ||
| 100 | return -EINVAL; | ||
| 101 | |||
| 102 | wdt_time = new_time; | ||
| 103 | return 0; | ||
| 104 | } | ||
| 105 | |||
| 106 | static int bcm47xx_wdt_open(struct inode *inode, struct file *file) | ||
| 107 | { | ||
| 108 | if (test_and_set_bit(0, &bcm47xx_wdt_busy)) | ||
| 109 | return -EBUSY; | ||
| 110 | |||
| 111 | bcm47xx_wdt_start(); | ||
| 112 | return nonseekable_open(inode, file); | ||
| 113 | } | ||
| 114 | |||
| 115 | static int bcm47xx_wdt_release(struct inode *inode, struct file *file) | ||
| 116 | { | ||
| 117 | if (expect_release == 42) { | ||
| 118 | bcm47xx_wdt_stop(); | ||
| 119 | } else { | ||
| 120 | printk(KERN_CRIT DRV_NAME | ||
| 121 | ": Unexpected close, not stopping watchdog!\n"); | ||
| 122 | bcm47xx_wdt_start(); | ||
| 123 | } | ||
| 124 | |||
| 125 | clear_bit(0, &bcm47xx_wdt_busy); | ||
| 126 | expect_release = 0; | ||
| 127 | return 0; | ||
| 128 | } | ||
| 129 | |||
| 130 | static ssize_t bcm47xx_wdt_write(struct file *file, const char __user *data, | ||
| 131 | size_t len, loff_t *ppos) | ||
| 132 | { | ||
| 133 | if (len) { | ||
| 134 | if (!nowayout) { | ||
| 135 | size_t i; | ||
| 136 | |||
| 137 | expect_release = 0; | ||
| 138 | |||
| 139 | for (i = 0; i != len; i++) { | ||
| 140 | char c; | ||
| 141 | if (get_user(c, data + i)) | ||
| 142 | return -EFAULT; | ||
| 143 | if (c == 'V') | ||
| 144 | expect_release = 42; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | bcm47xx_wdt_pet(); | ||
| 148 | } | ||
| 149 | return len; | ||
| 150 | } | ||
| 151 | |||
| 152 | static struct watchdog_info bcm47xx_wdt_info = { | ||
| 153 | .identity = DRV_NAME, | ||
| 154 | .options = WDIOF_SETTIMEOUT | | ||
| 155 | WDIOF_KEEPALIVEPING | | ||
| 156 | WDIOF_MAGICCLOSE, | ||
| 157 | }; | ||
| 158 | |||
| 159 | static long bcm47xx_wdt_ioctl(struct file *file, | ||
| 160 | unsigned int cmd, unsigned long arg) | ||
| 161 | { | ||
| 162 | void __user *argp = (void __user *)arg; | ||
| 163 | int __user *p = argp; | ||
| 164 | int new_value, retval = -EINVAL;; | ||
| 165 | |||
| 166 | switch (cmd) { | ||
| 167 | case WDIOC_GETSUPPORT: | ||
| 168 | return copy_to_user(argp, &bcm47xx_wdt_info, | ||
| 169 | sizeof(bcm47xx_wdt_info)) ? -EFAULT : 0; | ||
| 170 | |||
| 171 | case WDIOC_GETSTATUS: | ||
| 172 | case WDIOC_GETBOOTSTATUS: | ||
| 173 | return put_user(0, p); | ||
| 174 | |||
| 175 | case WDIOC_SETOPTIONS: | ||
| 176 | if (get_user(new_value, p)) | ||
| 177 | return -EFAULT; | ||
| 178 | |||
| 179 | if (new_value & WDIOS_DISABLECARD) { | ||
| 180 | bcm47xx_wdt_stop(); | ||
| 181 | retval = 0; | ||
| 182 | } | ||
| 183 | |||
| 184 | if (new_value & WDIOS_ENABLECARD) { | ||
| 185 | bcm47xx_wdt_start(); | ||
| 186 | retval = 0; | ||
| 187 | } | ||
| 188 | |||
| 189 | return retval; | ||
| 190 | |||
| 191 | case WDIOC_KEEPALIVE: | ||
| 192 | bcm47xx_wdt_pet(); | ||
| 193 | return 0; | ||
| 194 | |||
| 195 | case WDIOC_SETTIMEOUT: | ||
| 196 | if (get_user(new_value, p)) | ||
| 197 | return -EFAULT; | ||
| 198 | |||
| 199 | if (bcm47xx_wdt_settimeout(new_value)) | ||
| 200 | return -EINVAL; | ||
| 201 | |||
| 202 | bcm47xx_wdt_pet(); | ||
| 203 | |||
| 204 | case WDIOC_GETTIMEOUT: | ||
| 205 | return put_user(wdt_time, p); | ||
| 206 | |||
| 207 | default: | ||
| 208 | return -ENOTTY; | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 212 | static int bcm47xx_wdt_notify_sys(struct notifier_block *this, | ||
| 213 | unsigned long code, void *unused) | ||
| 214 | { | ||
| 215 | if (code == SYS_DOWN || code == SYS_HALT) | ||
| 216 | bcm47xx_wdt_stop(); | ||
| 217 | return NOTIFY_DONE; | ||
| 218 | } | ||
| 219 | |||
| 220 | static const struct file_operations bcm47xx_wdt_fops = { | ||
| 221 | .owner = THIS_MODULE, | ||
| 222 | .llseek = no_llseek, | ||
| 223 | .unlocked_ioctl = bcm47xx_wdt_ioctl, | ||
| 224 | .open = bcm47xx_wdt_open, | ||
| 225 | .release = bcm47xx_wdt_release, | ||
| 226 | .write = bcm47xx_wdt_write, | ||
| 227 | }; | ||
| 228 | |||
| 229 | static struct miscdevice bcm47xx_wdt_miscdev = { | ||
| 230 | .minor = WATCHDOG_MINOR, | ||
| 231 | .name = "watchdog", | ||
| 232 | .fops = &bcm47xx_wdt_fops, | ||
| 233 | }; | ||
| 234 | |||
| 235 | static struct notifier_block bcm47xx_wdt_notifier = { | ||
| 236 | .notifier_call = bcm47xx_wdt_notify_sys, | ||
| 237 | }; | ||
| 238 | |||
| 239 | static int __init bcm47xx_wdt_init(void) | ||
| 240 | { | ||
| 241 | int ret; | ||
| 242 | |||
| 243 | if (bcm47xx_wdt_hw_stop() < 0) | ||
| 244 | return -ENODEV; | ||
| 245 | |||
| 246 | setup_timer(&wdt_timer, bcm47xx_timer_tick, 0L); | ||
| 247 | |||
| 248 | if (bcm47xx_wdt_settimeout(wdt_time)) { | ||
| 249 | bcm47xx_wdt_settimeout(WDT_DEFAULT_TIME); | ||
| 250 | printk(KERN_INFO DRV_NAME ": " | ||
| 251 | "wdt_time value must be 0 < wdt_time < %d, using %d\n", | ||
| 252 | (WDT_MAX_TIME + 1), wdt_time); | ||
| 253 | } | ||
| 254 | |||
| 255 | ret = register_reboot_notifier(&bcm47xx_wdt_notifier); | ||
| 256 | if (ret) | ||
| 257 | return ret; | ||
| 258 | |||
| 259 | ret = misc_register(&bcm47xx_wdt_miscdev); | ||
| 260 | if (ret) { | ||
| 261 | unregister_reboot_notifier(&bcm47xx_wdt_notifier); | ||
| 262 | return ret; | ||
| 263 | } | ||
| 264 | |||
| 265 | printk(KERN_INFO "BCM47xx Watchdog Timer enabled (%d seconds%s)\n", | ||
| 266 | wdt_time, nowayout ? ", nowayout" : ""); | ||
| 267 | return 0; | ||
| 268 | } | ||
| 269 | |||
| 270 | static void __exit bcm47xx_wdt_exit(void) | ||
| 271 | { | ||
| 272 | if (!nowayout) | ||
| 273 | bcm47xx_wdt_stop(); | ||
| 274 | |||
| 275 | misc_deregister(&bcm47xx_wdt_miscdev); | ||
| 276 | |||
| 277 | unregister_reboot_notifier(&bcm47xx_wdt_notifier); | ||
| 278 | } | ||
| 279 | |||
| 280 | module_init(bcm47xx_wdt_init); | ||
| 281 | module_exit(bcm47xx_wdt_exit); | ||
| 282 | |||
| 283 | MODULE_AUTHOR("Aleksandar Radovanovic"); | ||
| 284 | MODULE_DESCRIPTION("Watchdog driver for Broadcom BCM47xx"); | ||
| 285 | MODULE_LICENSE("GPL"); | ||
| 286 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c new file mode 100644 index 000000000000..fecb307d28e9 --- /dev/null +++ b/drivers/watchdog/coh901327_wdt.c | |||
| @@ -0,0 +1,537 @@ | |||
| 1 | /* | ||
| 2 | * coh901327_wdt.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008-2009 ST-Ericsson AB | ||
| 5 | * License terms: GNU General Public License (GPL) version 2 | ||
| 6 | * Watchdog driver for the ST-Ericsson AB COH 901 327 IP core | ||
| 7 | * Author: Linus Walleij <linus.walleij@stericsson.com> | ||
| 8 | */ | ||
| 9 | #include <linux/module.h> | ||
| 10 | #include <linux/types.h> | ||
| 11 | #include <linux/fs.h> | ||
| 12 | #include <linux/miscdevice.h> | ||
| 13 | #include <linux/watchdog.h> | ||
| 14 | #include <linux/interrupt.h> | ||
| 15 | #include <linux/pm.h> | ||
| 16 | #include <linux/platform_device.h> | ||
| 17 | #include <linux/io.h> | ||
| 18 | #include <linux/bitops.h> | ||
| 19 | #include <linux/uaccess.h> | ||
| 20 | #include <linux/clk.h> | ||
| 21 | |||
| 22 | #define DRV_NAME "WDOG COH 901 327" | ||
| 23 | |||
| 24 | /* | ||
| 25 | * COH 901 327 register definitions | ||
| 26 | */ | ||
| 27 | |||
| 28 | /* WDOG_FEED Register 32bit (-/W) */ | ||
| 29 | #define U300_WDOG_FR 0x00 | ||
| 30 | #define U300_WDOG_FR_FEED_RESTART_TIMER 0xFEEDU | ||
| 31 | /* WDOG_TIMEOUT Register 32bit (R/W) */ | ||
| 32 | #define U300_WDOG_TR 0x04 | ||
| 33 | #define U300_WDOG_TR_TIMEOUT_MASK 0x7FFFU | ||
| 34 | /* WDOG_DISABLE1 Register 32bit (-/W) */ | ||
| 35 | #define U300_WDOG_D1R 0x08 | ||
| 36 | #define U300_WDOG_D1R_DISABLE1_DISABLE_TIMER 0x2BADU | ||
| 37 | /* WDOG_DISABLE2 Register 32bit (R/W) */ | ||
| 38 | #define U300_WDOG_D2R 0x0C | ||
| 39 | #define U300_WDOG_D2R_DISABLE2_DISABLE_TIMER 0xCAFEU | ||
| 40 | #define U300_WDOG_D2R_DISABLE_STATUS_DISABLED 0xDABEU | ||
| 41 | #define U300_WDOG_D2R_DISABLE_STATUS_ENABLED 0x0000U | ||
| 42 | /* WDOG_STATUS Register 32bit (R/W) */ | ||
| 43 | #define U300_WDOG_SR 0x10 | ||
| 44 | #define U300_WDOG_SR_STATUS_TIMED_OUT 0xCFE8U | ||
| 45 | #define U300_WDOG_SR_STATUS_NORMAL 0x0000U | ||
| 46 | #define U300_WDOG_SR_RESET_STATUS_RESET 0xE8B4U | ||
| 47 | /* WDOG_COUNT Register 32bit (R/-) */ | ||
| 48 | #define U300_WDOG_CR 0x14 | ||
| 49 | #define U300_WDOG_CR_VALID_IND 0x8000U | ||
| 50 | #define U300_WDOG_CR_VALID_STABLE 0x0000U | ||
| 51 | #define U300_WDOG_CR_COUNT_VALUE_MASK 0x7FFFU | ||
| 52 | /* WDOG_JTAGOVR Register 32bit (R/W) */ | ||
| 53 | #define U300_WDOG_JOR 0x18 | ||
| 54 | #define U300_WDOG_JOR_JTAG_MODE_IND 0x0002U | ||
| 55 | #define U300_WDOG_JOR_JTAG_WATCHDOG_ENABLE 0x0001U | ||
| 56 | /* WDOG_RESTART Register 32bit (-/W) */ | ||
| 57 | #define U300_WDOG_RR 0x1C | ||
| 58 | #define U300_WDOG_RR_RESTART_VALUE_RESUME 0xACEDU | ||
| 59 | /* WDOG_IRQ_EVENT Register 32bit (R/W) */ | ||
| 60 | #define U300_WDOG_IER 0x20 | ||
| 61 | #define U300_WDOG_IER_WILL_BARK_IRQ_EVENT_IND 0x0001U | ||
| 62 | #define U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE 0x0001U | ||
| 63 | /* WDOG_IRQ_MASK Register 32bit (R/W) */ | ||
| 64 | #define U300_WDOG_IMR 0x24 | ||
| 65 | #define U300_WDOG_IMR_WILL_BARK_IRQ_ENABLE 0x0001U | ||
| 66 | /* WDOG_IRQ_FORCE Register 32bit (R/W) */ | ||
| 67 | #define U300_WDOG_IFR 0x28 | ||
| 68 | #define U300_WDOG_IFR_WILL_BARK_IRQ_FORCE_ENABLE 0x0001U | ||
| 69 | |||
| 70 | /* Default timeout in seconds = 1 minute */ | ||
| 71 | static int margin = 60; | ||
| 72 | static resource_size_t phybase; | ||
| 73 | static resource_size_t physize; | ||
| 74 | static int irq; | ||
| 75 | static void __iomem *virtbase; | ||
| 76 | static unsigned long coh901327_users; | ||
| 77 | static unsigned long boot_status; | ||
| 78 | static u16 wdogenablestore; | ||
| 79 | static u16 irqmaskstore; | ||
| 80 | static struct device *parent; | ||
| 81 | |||
| 82 | /* | ||
| 83 | * The watchdog block is of course always clocked, the | ||
| 84 | * clk_enable()/clk_disable() calls are mainly for performing reference | ||
| 85 | * counting higher up in the clock hierarchy. | ||
| 86 | */ | ||
| 87 | static struct clk *clk; | ||
| 88 | |||
| 89 | /* | ||
| 90 | * Enabling and disabling functions. | ||
| 91 | */ | ||
| 92 | static void coh901327_enable(u16 timeout) | ||
| 93 | { | ||
| 94 | u16 val; | ||
| 95 | |||
| 96 | clk_enable(clk); | ||
| 97 | /* Restart timer if it is disabled */ | ||
| 98 | val = readw(virtbase + U300_WDOG_D2R); | ||
| 99 | if (val == U300_WDOG_D2R_DISABLE_STATUS_DISABLED) | ||
| 100 | writew(U300_WDOG_RR_RESTART_VALUE_RESUME, | ||
| 101 | virtbase + U300_WDOG_RR); | ||
| 102 | /* Acknowledge any pending interrupt so it doesn't just fire off */ | ||
| 103 | writew(U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE, | ||
| 104 | virtbase + U300_WDOG_IER); | ||
| 105 | /* Enable the watchdog interrupt */ | ||
| 106 | writew(U300_WDOG_IMR_WILL_BARK_IRQ_ENABLE, virtbase + U300_WDOG_IMR); | ||
| 107 | /* Activate the watchdog timer */ | ||
| 108 | writew(timeout, virtbase + U300_WDOG_TR); | ||
| 109 | /* Start the watchdog timer */ | ||
| 110 | writew(U300_WDOG_FR_FEED_RESTART_TIMER, virtbase + U300_WDOG_FR); | ||
| 111 | /* | ||
| 112 | * Extra read so that this change propagate in the watchdog. | ||
| 113 | */ | ||
| 114 | (void) readw(virtbase + U300_WDOG_CR); | ||
| 115 | val = readw(virtbase + U300_WDOG_D2R); | ||
| 116 | clk_disable(clk); | ||
| 117 | if (val != U300_WDOG_D2R_DISABLE_STATUS_ENABLED) | ||
| 118 | dev_err(parent, | ||
| 119 | "%s(): watchdog not enabled! D2R value %04x\n", | ||
| 120 | __func__, val); | ||
| 121 | } | ||
| 122 | |||
| 123 | static void coh901327_disable(void) | ||
| 124 | { | ||
| 125 | u16 val; | ||
| 126 | |||
| 127 | clk_enable(clk); | ||
| 128 | /* Disable the watchdog interrupt if it is active */ | ||
| 129 | writew(0x0000U, virtbase + U300_WDOG_IMR); | ||
| 130 | /* If the watchdog is currently enabled, attempt to disable it */ | ||
| 131 | val = readw(virtbase + U300_WDOG_D2R); | ||
| 132 | if (val != U300_WDOG_D2R_DISABLE_STATUS_DISABLED) { | ||
| 133 | writew(U300_WDOG_D1R_DISABLE1_DISABLE_TIMER, | ||
| 134 | virtbase + U300_WDOG_D1R); | ||
| 135 | writew(U300_WDOG_D2R_DISABLE2_DISABLE_TIMER, | ||
| 136 | virtbase + U300_WDOG_D2R); | ||
| 137 | /* Write this twice (else problems occur) */ | ||
| 138 | writew(U300_WDOG_D2R_DISABLE2_DISABLE_TIMER, | ||
| 139 | virtbase + U300_WDOG_D2R); | ||
| 140 | } | ||
| 141 | val = readw(virtbase + U300_WDOG_D2R); | ||
| 142 | clk_disable(clk); | ||
| 143 | if (val != U300_WDOG_D2R_DISABLE_STATUS_DISABLED) | ||
| 144 | dev_err(parent, | ||
| 145 | "%s(): watchdog not disabled! D2R value %04x\n", | ||
| 146 | __func__, val); | ||
| 147 | } | ||
| 148 | |||
| 149 | static void coh901327_start(void) | ||
| 150 | { | ||
| 151 | coh901327_enable(margin * 100); | ||
| 152 | } | ||
| 153 | |||
| 154 | static void coh901327_keepalive(void) | ||
| 155 | { | ||
| 156 | clk_enable(clk); | ||
| 157 | /* Feed the watchdog */ | ||
| 158 | writew(U300_WDOG_FR_FEED_RESTART_TIMER, | ||
| 159 | virtbase + U300_WDOG_FR); | ||
| 160 | clk_disable(clk); | ||
| 161 | } | ||
| 162 | |||
| 163 | static int coh901327_settimeout(int time) | ||
| 164 | { | ||
| 165 | /* | ||
| 166 | * Max margin is 327 since the 10ms | ||
| 167 | * timeout register is max | ||
| 168 | * 0x7FFF = 327670ms ~= 327s. | ||
| 169 | */ | ||
| 170 | if (time <= 0 || time > 327) | ||
| 171 | return -EINVAL; | ||
| 172 | |||
| 173 | margin = time; | ||
| 174 | clk_enable(clk); | ||
| 175 | /* Set new timeout value */ | ||
| 176 | writew(margin * 100, virtbase + U300_WDOG_TR); | ||
| 177 | /* Feed the dog */ | ||
| 178 | writew(U300_WDOG_FR_FEED_RESTART_TIMER, | ||
| 179 | virtbase + U300_WDOG_FR); | ||
| 180 | clk_disable(clk); | ||
| 181 | return 0; | ||
| 182 | } | ||
| 183 | |||
| 184 | /* | ||
| 185 | * This interrupt occurs 10 ms before the watchdog WILL bark. | ||
| 186 | */ | ||
| 187 | static irqreturn_t coh901327_interrupt(int irq, void *data) | ||
| 188 | { | ||
| 189 | u16 val; | ||
| 190 | |||
| 191 | /* | ||
| 192 | * Ack IRQ? If this occurs we're FUBAR anyway, so | ||
| 193 | * just acknowledge, disable the interrupt and await the imminent end. | ||
| 194 | * If you at some point need a host of callbacks to be called | ||
| 195 | * when the system is about to watchdog-reset, add them here! | ||
| 196 | * | ||
| 197 | * NOTE: on future versions of this IP-block, it will be possible | ||
| 198 | * to prevent a watchdog reset by feeding the watchdog at this | ||
| 199 | * point. | ||
| 200 | */ | ||
| 201 | clk_enable(clk); | ||
| 202 | val = readw(virtbase + U300_WDOG_IER); | ||
| 203 | if (val == U300_WDOG_IER_WILL_BARK_IRQ_EVENT_IND) | ||
| 204 | writew(U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE, | ||
| 205 | virtbase + U300_WDOG_IER); | ||
| 206 | writew(0x0000U, virtbase + U300_WDOG_IMR); | ||
| 207 | clk_disable(clk); | ||
| 208 | dev_crit(parent, "watchdog is barking!\n"); | ||
| 209 | return IRQ_HANDLED; | ||
| 210 | } | ||
| 211 | |||
| 212 | /* | ||
| 213 | * Allow only one user (daemon) to open the watchdog | ||
| 214 | */ | ||
| 215 | static int coh901327_open(struct inode *inode, struct file *file) | ||
| 216 | { | ||
| 217 | if (test_and_set_bit(1, &coh901327_users)) | ||
| 218 | return -EBUSY; | ||
| 219 | coh901327_start(); | ||
| 220 | return nonseekable_open(inode, file); | ||
| 221 | } | ||
| 222 | |||
| 223 | static int coh901327_release(struct inode *inode, struct file *file) | ||
| 224 | { | ||
| 225 | clear_bit(1, &coh901327_users); | ||
| 226 | coh901327_disable(); | ||
| 227 | return 0; | ||
| 228 | } | ||
| 229 | |||
| 230 | static ssize_t coh901327_write(struct file *file, const char __user *data, | ||
| 231 | size_t len, loff_t *ppos) | ||
| 232 | { | ||
| 233 | if (len) | ||
| 234 | coh901327_keepalive(); | ||
| 235 | return len; | ||
| 236 | } | ||
| 237 | |||
| 238 | static long coh901327_ioctl(struct file *file, unsigned int cmd, | ||
| 239 | unsigned long arg) | ||
| 240 | { | ||
| 241 | int ret = -ENOTTY; | ||
| 242 | u16 val; | ||
| 243 | int time; | ||
| 244 | int new_options; | ||
| 245 | union { | ||
| 246 | struct watchdog_info __user *ident; | ||
| 247 | int __user *i; | ||
| 248 | } uarg; | ||
| 249 | static struct watchdog_info ident = { | ||
| 250 | .options = WDIOF_CARDRESET | | ||
| 251 | WDIOF_SETTIMEOUT | | ||
| 252 | WDIOF_KEEPALIVEPING, | ||
| 253 | .identity = "COH 901 327 Watchdog", | ||
| 254 | .firmware_version = 1, | ||
| 255 | }; | ||
| 256 | uarg.i = (int __user *)arg; | ||
| 257 | |||
| 258 | switch (cmd) { | ||
| 259 | case WDIOC_GETSUPPORT: | ||
| 260 | ret = copy_to_user(uarg.ident, &ident, | ||
| 261 | sizeof(ident)) ? -EFAULT : 0; | ||
| 262 | break; | ||
| 263 | |||
| 264 | case WDIOC_GETSTATUS: | ||
| 265 | ret = put_user(0, uarg.i); | ||
| 266 | break; | ||
| 267 | |||
| 268 | case WDIOC_GETBOOTSTATUS: | ||
| 269 | ret = put_user(boot_status, uarg.i); | ||
| 270 | break; | ||
| 271 | |||
| 272 | case WDIOC_SETOPTIONS: | ||
| 273 | ret = get_user(new_options, uarg.i); | ||
| 274 | if (ret) | ||
| 275 | break; | ||
| 276 | if (new_options & WDIOS_DISABLECARD) | ||
| 277 | coh901327_disable(); | ||
| 278 | if (new_options & WDIOS_ENABLECARD) | ||
| 279 | coh901327_start(); | ||
| 280 | ret = 0; | ||
| 281 | break; | ||
| 282 | |||
| 283 | case WDIOC_KEEPALIVE: | ||
| 284 | coh901327_keepalive(); | ||
| 285 | ret = 0; | ||
| 286 | break; | ||
| 287 | |||
| 288 | case WDIOC_SETTIMEOUT: | ||
| 289 | ret = get_user(time, uarg.i); | ||
| 290 | if (ret) | ||
| 291 | break; | ||
| 292 | |||
| 293 | ret = coh901327_settimeout(time); | ||
| 294 | if (ret) | ||
| 295 | break; | ||
| 296 | /* Then fall through to return set value */ | ||
| 297 | |||
| 298 | case WDIOC_GETTIMEOUT: | ||
| 299 | ret = put_user(margin, uarg.i); | ||
| 300 | break; | ||
| 301 | |||
| 302 | case WDIOC_GETTIMELEFT: | ||
| 303 | clk_enable(clk); | ||
| 304 | /* Read repeatedly until the value is stable! */ | ||
| 305 | val = readw(virtbase + U300_WDOG_CR); | ||
| 306 | while (val & U300_WDOG_CR_VALID_IND) | ||
| 307 | val = readw(virtbase + U300_WDOG_CR); | ||
| 308 | val &= U300_WDOG_CR_COUNT_VALUE_MASK; | ||
| 309 | clk_disable(clk); | ||
| 310 | if (val != 0) | ||
| 311 | val /= 100; | ||
| 312 | ret = put_user(val, uarg.i); | ||
| 313 | break; | ||
| 314 | } | ||
| 315 | return ret; | ||
| 316 | } | ||
| 317 | |||
| 318 | static const struct file_operations coh901327_fops = { | ||
| 319 | .owner = THIS_MODULE, | ||
| 320 | .llseek = no_llseek, | ||
| 321 | .write = coh901327_write, | ||
| 322 | .unlocked_ioctl = coh901327_ioctl, | ||
| 323 | .open = coh901327_open, | ||
| 324 | .release = coh901327_release, | ||
| 325 | }; | ||
| 326 | |||
| 327 | static struct miscdevice coh901327_miscdev = { | ||
| 328 | .minor = WATCHDOG_MINOR, | ||
| 329 | .name = "watchdog", | ||
| 330 | .fops = &coh901327_fops, | ||
| 331 | }; | ||
| 332 | |||
| 333 | static int __exit coh901327_remove(struct platform_device *pdev) | ||
| 334 | { | ||
| 335 | misc_deregister(&coh901327_miscdev); | ||
| 336 | coh901327_disable(); | ||
| 337 | free_irq(irq, pdev); | ||
| 338 | clk_put(clk); | ||
| 339 | iounmap(virtbase); | ||
| 340 | release_mem_region(phybase, physize); | ||
| 341 | return 0; | ||
| 342 | } | ||
| 343 | |||
| 344 | |||
| 345 | static int __init coh901327_probe(struct platform_device *pdev) | ||
| 346 | { | ||
| 347 | int ret; | ||
| 348 | u16 val; | ||
| 349 | struct resource *res; | ||
| 350 | |||
| 351 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 352 | if (!res) | ||
| 353 | return -ENOENT; | ||
| 354 | |||
| 355 | parent = &pdev->dev; | ||
| 356 | physize = resource_size(res); | ||
| 357 | phybase = res->start; | ||
| 358 | |||
| 359 | if (request_mem_region(phybase, physize, DRV_NAME) == NULL) { | ||
| 360 | ret = -EBUSY; | ||
| 361 | goto out; | ||
| 362 | } | ||
| 363 | |||
| 364 | virtbase = ioremap(phybase, physize); | ||
| 365 | if (!virtbase) { | ||
| 366 | ret = -ENOMEM; | ||
| 367 | goto out_no_remap; | ||
| 368 | } | ||
| 369 | |||
| 370 | clk = clk_get(&pdev->dev, NULL); | ||
| 371 | if (IS_ERR(clk)) { | ||
| 372 | ret = PTR_ERR(clk); | ||
| 373 | dev_err(&pdev->dev, "could not get clock\n"); | ||
| 374 | goto out_no_clk; | ||
| 375 | } | ||
| 376 | ret = clk_enable(clk); | ||
| 377 | if (ret) { | ||
| 378 | dev_err(&pdev->dev, "could not enable clock\n"); | ||
| 379 | goto out_no_clk_enable; | ||
| 380 | } | ||
| 381 | |||
| 382 | val = readw(virtbase + U300_WDOG_SR); | ||
| 383 | switch (val) { | ||
| 384 | case U300_WDOG_SR_STATUS_TIMED_OUT: | ||
| 385 | dev_info(&pdev->dev, | ||
| 386 | "watchdog timed out since last chip reset!\n"); | ||
| 387 | boot_status = WDIOF_CARDRESET; | ||
| 388 | /* Status will be cleared below */ | ||
| 389 | break; | ||
| 390 | case U300_WDOG_SR_STATUS_NORMAL: | ||
| 391 | dev_info(&pdev->dev, | ||
| 392 | "in normal status, no timeouts have occurred.\n"); | ||
| 393 | break; | ||
| 394 | default: | ||
| 395 | dev_info(&pdev->dev, | ||
| 396 | "contains an illegal status code (%08x)\n", val); | ||
| 397 | break; | ||
| 398 | } | ||
| 399 | |||
| 400 | val = readw(virtbase + U300_WDOG_D2R); | ||
| 401 | switch (val) { | ||
| 402 | case U300_WDOG_D2R_DISABLE_STATUS_DISABLED: | ||
| 403 | dev_info(&pdev->dev, "currently disabled.\n"); | ||
| 404 | break; | ||
| 405 | case U300_WDOG_D2R_DISABLE_STATUS_ENABLED: | ||
| 406 | dev_info(&pdev->dev, | ||
| 407 | "currently enabled! (disabling it now)\n"); | ||
| 408 | coh901327_disable(); | ||
| 409 | break; | ||
| 410 | default: | ||
| 411 | dev_err(&pdev->dev, | ||
| 412 | "contains an illegal enable/disable code (%08x)\n", | ||
| 413 | val); | ||
| 414 | break; | ||
| 415 | } | ||
| 416 | |||
| 417 | /* Reset the watchdog */ | ||
| 418 | writew(U300_WDOG_SR_RESET_STATUS_RESET, virtbase + U300_WDOG_SR); | ||
| 419 | |||
| 420 | irq = platform_get_irq(pdev, 0); | ||
| 421 | if (request_irq(irq, coh901327_interrupt, IRQF_DISABLED, | ||
| 422 | DRV_NAME " Bark", pdev)) { | ||
| 423 | ret = -EIO; | ||
| 424 | goto out_no_irq; | ||
| 425 | } | ||
| 426 | |||
| 427 | clk_disable(clk); | ||
| 428 | |||
| 429 | ret = misc_register(&coh901327_miscdev); | ||
| 430 | if (ret == 0) | ||
| 431 | dev_info(&pdev->dev, | ||
| 432 | "initialized. timer margin=%d sec\n", margin); | ||
| 433 | else | ||
| 434 | goto out_no_wdog; | ||
| 435 | |||
| 436 | return 0; | ||
| 437 | |||
| 438 | out_no_wdog: | ||
| 439 | free_irq(irq, pdev); | ||
| 440 | out_no_irq: | ||
| 441 | clk_disable(clk); | ||
| 442 | out_no_clk_enable: | ||
| 443 | clk_put(clk); | ||
| 444 | out_no_clk: | ||
| 445 | iounmap(virtbase); | ||
| 446 | out_no_remap: | ||
| 447 | release_mem_region(phybase, SZ_4K); | ||
| 448 | out: | ||
| 449 | return ret; | ||
| 450 | } | ||
| 451 | |||
| 452 | #ifdef CONFIG_PM | ||
| 453 | static int coh901327_suspend(struct platform_device *pdev, pm_message_t state) | ||
| 454 | { | ||
| 455 | irqmaskstore = readw(virtbase + U300_WDOG_IMR) & 0x0001U; | ||
| 456 | wdogenablestore = readw(virtbase + U300_WDOG_D2R); | ||
| 457 | /* If watchdog is on, disable it here and now */ | ||
| 458 | if (wdogenablestore == U300_WDOG_D2R_DISABLE_STATUS_ENABLED) | ||
| 459 | coh901327_disable(); | ||
| 460 | return 0; | ||
| 461 | } | ||
| 462 | |||
| 463 | static int coh901327_resume(struct platform_device *pdev) | ||
| 464 | { | ||
| 465 | /* Restore the watchdog interrupt */ | ||
| 466 | writew(irqmaskstore, virtbase + U300_WDOG_IMR); | ||
| 467 | if (wdogenablestore == U300_WDOG_D2R_DISABLE_STATUS_ENABLED) { | ||
| 468 | /* Restart the watchdog timer */ | ||
| 469 | writew(U300_WDOG_RR_RESTART_VALUE_RESUME, | ||
| 470 | virtbase + U300_WDOG_RR); | ||
| 471 | writew(U300_WDOG_FR_FEED_RESTART_TIMER, | ||
| 472 | virtbase + U300_WDOG_FR); | ||
| 473 | } | ||
| 474 | return 0; | ||
| 475 | } | ||
| 476 | #else | ||
| 477 | #define coh901327_suspend NULL | ||
| 478 | #define coh901327_resume NULL | ||
| 479 | #endif | ||
| 480 | |||
| 481 | /* | ||
| 482 | * Mistreating the watchdog is the only way to perform a software reset of the | ||
| 483 | * system on EMP platforms. So we implement this and export a symbol for it. | ||
| 484 | */ | ||
| 485 | void coh901327_watchdog_reset(void) | ||
| 486 | { | ||
| 487 | /* Enable even if on JTAG too */ | ||
| 488 | writew(U300_WDOG_JOR_JTAG_WATCHDOG_ENABLE, | ||
| 489 | virtbase + U300_WDOG_JOR); | ||
| 490 | /* | ||
| 491 | * Timeout = 5s, we have to wait for the watchdog reset to | ||
| 492 | * actually take place: the watchdog will be reloaded with the | ||
| 493 | * default value immediately, so we HAVE to reboot and get back | ||
| 494 | * into the kernel in 30s, or the device will reboot again! | ||
| 495 | * The boot loader will typically deactivate the watchdog, so we | ||
| 496 | * need time enough for the boot loader to get to the point of | ||
| 497 | * deactivating the watchdog before it is shut down by it. | ||
| 498 | * | ||
| 499 | * NOTE: on future versions of the watchdog, this restriction is | ||
| 500 | * gone: the watchdog will be reloaded with a defaul value (1 min) | ||
| 501 | * instead of last value, and you can conveniently set the watchdog | ||
| 502 | * timeout to 10ms (value = 1) without any problems. | ||
| 503 | */ | ||
| 504 | coh901327_enable(500); | ||
| 505 | /* Return and await doom */ | ||
| 506 | } | ||
| 507 | |||
| 508 | static struct platform_driver coh901327_driver = { | ||
| 509 | .driver = { | ||
| 510 | .owner = THIS_MODULE, | ||
| 511 | .name = "coh901327_wdog", | ||
| 512 | }, | ||
| 513 | .remove = __exit_p(coh901327_remove), | ||
| 514 | .suspend = coh901327_suspend, | ||
| 515 | .resume = coh901327_resume, | ||
| 516 | }; | ||
| 517 | |||
| 518 | static int __init coh901327_init(void) | ||
| 519 | { | ||
| 520 | return platform_driver_probe(&coh901327_driver, coh901327_probe); | ||
| 521 | } | ||
| 522 | module_init(coh901327_init); | ||
| 523 | |||
| 524 | static void __exit coh901327_exit(void) | ||
| 525 | { | ||
| 526 | platform_driver_unregister(&coh901327_driver); | ||
| 527 | } | ||
| 528 | module_exit(coh901327_exit); | ||
| 529 | |||
| 530 | MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>"); | ||
| 531 | MODULE_DESCRIPTION("COH 901 327 Watchdog"); | ||
| 532 | |||
| 533 | module_param(margin, int, 0); | ||
| 534 | MODULE_PARM_DESC(margin, "Watchdog margin in seconds (default 60s)"); | ||
| 535 | |||
| 536 | MODULE_LICENSE("GPL"); | ||
| 537 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index c0b9169ba5d5..a6c5674c78e6 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c | |||
| @@ -120,7 +120,8 @@ static int nowayout = WATCHDOG_NOWAYOUT; | |||
| 120 | static char expect_release; | 120 | static char expect_release; |
| 121 | static unsigned long hpwdt_is_open; | 121 | static unsigned long hpwdt_is_open; |
| 122 | static unsigned int allow_kdump; | 122 | static unsigned int allow_kdump; |
| 123 | static int hpwdt_nmi_sourcing; | 123 | static unsigned int hpwdt_nmi_sourcing; |
| 124 | static unsigned int priority; /* hpwdt at end of die_notify list */ | ||
| 124 | 125 | ||
| 125 | static void __iomem *pci_mem_addr; /* the PCI-memory address */ | 126 | static void __iomem *pci_mem_addr; /* the PCI-memory address */ |
| 126 | static unsigned long __iomem *hpwdt_timer_reg; | 127 | static unsigned long __iomem *hpwdt_timer_reg; |
| @@ -623,7 +624,7 @@ static struct miscdevice hpwdt_miscdev = { | |||
| 623 | 624 | ||
| 624 | static struct notifier_block die_notifier = { | 625 | static struct notifier_block die_notifier = { |
| 625 | .notifier_call = hpwdt_pretimeout, | 626 | .notifier_call = hpwdt_pretimeout, |
| 626 | .priority = 0x7FFFFFFF, | 627 | .priority = 0, |
| 627 | }; | 628 | }; |
| 628 | 629 | ||
| 629 | /* | 630 | /* |
| @@ -641,7 +642,8 @@ static void __devinit hpwdt_check_nmi_sourcing(struct pci_dev *dev) | |||
| 641 | hpwdt_nmi_sourcing = 1; | 642 | hpwdt_nmi_sourcing = 1; |
| 642 | else | 643 | else |
| 643 | dev_warn(&dev->dev, "NMI sourcing is disabled. To enable this " | 644 | dev_warn(&dev->dev, "NMI sourcing is disabled. To enable this " |
| 644 | "functionality you must reboot with nmi_watchdog=0.\n"); | 645 | "functionality you must reboot with nmi_watchdog=0 " |
| 646 | "and load the hpwdt driver with priority=1.\n"); | ||
| 645 | } | 647 | } |
| 646 | #else | 648 | #else |
| 647 | static void __devinit hpwdt_check_nmi_sourcing(struct pci_dev *dev) | 649 | static void __devinit hpwdt_check_nmi_sourcing(struct pci_dev *dev) |
| @@ -714,6 +716,14 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev, | |||
| 714 | cmn_regs.u1.rah = 0x0D; | 716 | cmn_regs.u1.rah = 0x0D; |
| 715 | cmn_regs.u1.ral = 0x02; | 717 | cmn_regs.u1.ral = 0x02; |
| 716 | 718 | ||
| 719 | /* | ||
| 720 | * If the priority is set to 1, then we will be put first on the | ||
| 721 | * die notify list to handle a critical NMI. The default is to | ||
| 722 | * be last so other users of the NMI signal can function. | ||
| 723 | */ | ||
| 724 | if (priority) | ||
| 725 | die_notifier.priority = 0x7FFFFFFF; | ||
| 726 | |||
| 717 | retval = register_die_notifier(&die_notifier); | 727 | retval = register_die_notifier(&die_notifier); |
| 718 | if (retval != 0) { | 728 | if (retval != 0) { |
| 719 | dev_warn(&dev->dev, | 729 | dev_warn(&dev->dev, |
| @@ -733,9 +743,11 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev, | |||
| 733 | printk(KERN_INFO | 743 | printk(KERN_INFO |
| 734 | "hp Watchdog Timer Driver: %s" | 744 | "hp Watchdog Timer Driver: %s" |
| 735 | ", timer margin: %d seconds (nowayout=%d)" | 745 | ", timer margin: %d seconds (nowayout=%d)" |
| 736 | ", allow kernel dump: %s (default = 0/OFF).\n", | 746 | ", allow kernel dump: %s (default = 0/OFF)" |
| 747 | ", priority: %s (default = 0/LAST).\n", | ||
| 737 | HPWDT_VERSION, soft_margin, nowayout, | 748 | HPWDT_VERSION, soft_margin, nowayout, |
| 738 | (allow_kdump == 0) ? "OFF" : "ON"); | 749 | (allow_kdump == 0) ? "OFF" : "ON", |
| 750 | (priority == 0) ? "LAST" : "FIRST"); | ||
| 739 | 751 | ||
| 740 | return 0; | 752 | return 0; |
| 741 | 753 | ||
| @@ -798,5 +810,9 @@ module_param(nowayout, int, 0); | |||
| 798 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | 810 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" |
| 799 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 811 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
| 800 | 812 | ||
| 813 | module_param(priority, int, 0); | ||
| 814 | MODULE_PARM_DESC(priority, "The hpwdt driver handles NMIs first or last" | ||
| 815 | " (default = 0/Last)\n"); | ||
| 816 | |||
| 801 | module_init(hpwdt_init); | 817 | module_init(hpwdt_init); |
| 802 | module_exit(hpwdt_cleanup); | 818 | module_exit(hpwdt_cleanup); |
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index f2713851aaab..3ed571a2ab18 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c | |||
| @@ -159,6 +159,7 @@ static int omap_wdt_open(struct inode *inode, struct file *file) | |||
| 159 | file->private_data = (void *) wdev; | 159 | file->private_data = (void *) wdev; |
| 160 | 160 | ||
| 161 | omap_wdt_set_timeout(wdev); | 161 | omap_wdt_set_timeout(wdev); |
| 162 | omap_wdt_ping(wdev); /* trigger loading of new timeout value */ | ||
| 162 | omap_wdt_enable(wdev); | 163 | omap_wdt_enable(wdev); |
| 163 | 164 | ||
| 164 | return nonseekable_open(inode, file); | 165 | return nonseekable_open(inode, file); |
| @@ -313,6 +314,9 @@ static int __devinit omap_wdt_probe(struct platform_device *pdev) | |||
| 313 | 314 | ||
| 314 | platform_set_drvdata(pdev, wdev); | 315 | platform_set_drvdata(pdev, wdev); |
| 315 | 316 | ||
| 317 | clk_enable(wdev->ick); | ||
| 318 | clk_enable(wdev->fck); | ||
| 319 | |||
| 316 | omap_wdt_disable(wdev); | 320 | omap_wdt_disable(wdev); |
| 317 | omap_wdt_adjust_timeout(timer_margin); | 321 | omap_wdt_adjust_timeout(timer_margin); |
| 318 | 322 | ||
| @@ -332,6 +336,9 @@ static int __devinit omap_wdt_probe(struct platform_device *pdev) | |||
| 332 | /* autogate OCP interface clock */ | 336 | /* autogate OCP interface clock */ |
| 333 | __raw_writel(0x01, wdev->base + OMAP_WATCHDOG_SYS_CONFIG); | 337 | __raw_writel(0x01, wdev->base + OMAP_WATCHDOG_SYS_CONFIG); |
| 334 | 338 | ||
| 339 | clk_disable(wdev->ick); | ||
| 340 | clk_disable(wdev->fck); | ||
| 341 | |||
| 335 | omap_wdt_dev = pdev; | 342 | omap_wdt_dev = pdev; |
| 336 | 343 | ||
| 337 | return 0; | 344 | return 0; |
diff --git a/drivers/watchdog/pnx833x_wdt.c b/drivers/watchdog/pnx833x_wdt.c new file mode 100644 index 000000000000..538ec2c05197 --- /dev/null +++ b/drivers/watchdog/pnx833x_wdt.c | |||
| @@ -0,0 +1,282 @@ | |||
| 1 | /* | ||
| 2 | * PNX833x Hardware Watchdog Driver | ||
| 3 | * Copyright 2008 NXP Semiconductors | ||
| 4 | * Daniel Laird <daniel.j.laird@nxp.com> | ||
| 5 | * Andre McCurdy <andre.mccurdy@nxp.com> | ||
| 6 | * | ||
| 7 | * Heavily based upon - IndyDog 0.3 | ||
| 8 | * A Hardware Watchdog Device for SGI IP22 | ||
| 9 | * | ||
| 10 | * (c) Copyright 2002 Guido Guenther <agx@sigxcpu.org>, All Rights Reserved. | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or | ||
| 13 | * modify it under the terms of the GNU General Public License | ||
| 14 | * as published by the Free Software Foundation; either version | ||
| 15 | * 2 of the License, or (at your option) any later version. | ||
| 16 | * | ||
| 17 | * based on softdog.c by Alan Cox <alan@redhat.com> | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <linux/module.h> | ||
| 21 | #include <linux/moduleparam.h> | ||
| 22 | #include <linux/types.h> | ||
| 23 | #include <linux/kernel.h> | ||
| 24 | #include <linux/fs.h> | ||
| 25 | #include <linux/mm.h> | ||
| 26 | #include <linux/miscdevice.h> | ||
| 27 | #include <linux/watchdog.h> | ||
| 28 | #include <linux/notifier.h> | ||
| 29 | #include <linux/reboot.h> | ||
| 30 | #include <linux/init.h> | ||
| 31 | #include <asm/mach-pnx833x/pnx833x.h> | ||
| 32 | |||
| 33 | #define PFX "pnx833x: " | ||
| 34 | #define WATCHDOG_TIMEOUT 30 /* 30 sec Maximum timeout */ | ||
| 35 | #define WATCHDOG_COUNT_FREQUENCY 68000000U /* Watchdog counts at 68MHZ. */ | ||
| 36 | |||
| 37 | /** CONFIG block */ | ||
| 38 | #define PNX833X_CONFIG (0x07000U) | ||
| 39 | #define PNX833X_CONFIG_CPU_WATCHDOG (0x54) | ||
| 40 | #define PNX833X_CONFIG_CPU_WATCHDOG_COMPARE (0x58) | ||
| 41 | #define PNX833X_CONFIG_CPU_COUNTERS_CONTROL (0x1c) | ||
| 42 | |||
| 43 | /** RESET block */ | ||
| 44 | #define PNX833X_RESET (0x08000U) | ||
| 45 | #define PNX833X_RESET_CONFIG (0x08) | ||
| 46 | |||
| 47 | static int pnx833x_wdt_alive; | ||
| 48 | |||
| 49 | /* Set default timeout in MHZ.*/ | ||
| 50 | static int pnx833x_wdt_timeout = (WATCHDOG_TIMEOUT * WATCHDOG_COUNT_FREQUENCY); | ||
| 51 | module_param(pnx833x_wdt_timeout, int, 0); | ||
| 52 | MODULE_PARM_DESC(timeout, "Watchdog timeout in Mhz. (68Mhz clock), default=" | ||
| 53 | __MODULE_STRING(pnx833x_wdt_timeout) "(30 seconds)."); | ||
| 54 | |||
| 55 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
| 56 | module_param(nowayout, int, 0); | ||
| 57 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" | ||
| 58 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
| 59 | |||
| 60 | static int start_enabled = 1; | ||
| 61 | module_param(start_enabled, int, 0); | ||
| 62 | MODULE_PARM_DESC(start_enabled, "Watchdog is started on module insertion " | ||
| 63 | "(default=" __MODULE_STRING(start_enabled) ")"); | ||
| 64 | |||
| 65 | static void pnx833x_wdt_start(void) | ||
| 66 | { | ||
| 67 | /* Enable watchdog causing reset. */ | ||
| 68 | PNX833X_REG(PNX833X_RESET + PNX833X_RESET_CONFIG) |= 0x1; | ||
| 69 | /* Set timeout.*/ | ||
| 70 | PNX833X_REG(PNX833X_CONFIG + | ||
| 71 | PNX833X_CONFIG_CPU_WATCHDOG_COMPARE) = pnx833x_wdt_timeout; | ||
| 72 | /* Enable watchdog. */ | ||
| 73 | PNX833X_REG(PNX833X_CONFIG + | ||
| 74 | PNX833X_CONFIG_CPU_COUNTERS_CONTROL) |= 0x1; | ||
| 75 | |||
| 76 | printk(KERN_INFO PFX "Started watchdog timer.\n"); | ||
| 77 | } | ||
| 78 | |||
| 79 | static void pnx833x_wdt_stop(void) | ||
| 80 | { | ||
| 81 | /* Disable watchdog causing reset. */ | ||
| 82 | PNX833X_REG(PNX833X_RESET + PNX833X_CONFIG) &= 0xFFFFFFFE; | ||
| 83 | /* Disable watchdog.*/ | ||
| 84 | PNX833X_REG(PNX833X_CONFIG + | ||
| 85 | PNX833X_CONFIG_CPU_COUNTERS_CONTROL) &= 0xFFFFFFFE; | ||
| 86 | |||
| 87 | printk(KERN_INFO PFX "Stopped watchdog timer.\n"); | ||
| 88 | } | ||
| 89 | |||
| 90 | static void pnx833x_wdt_ping(void) | ||
| 91 | { | ||
| 92 | PNX833X_REG(PNX833X_CONFIG + | ||
| 93 | PNX833X_CONFIG_CPU_WATCHDOG_COMPARE) = pnx833x_wdt_timeout; | ||
| 94 | } | ||
| 95 | |||
| 96 | /* | ||
| 97 | * Allow only one person to hold it open | ||
| 98 | */ | ||
| 99 | static int pnx833x_wdt_open(struct inode *inode, struct file *file) | ||
| 100 | { | ||
| 101 | if (test_and_set_bit(0, &pnx833x_wdt_alive)) | ||
| 102 | return -EBUSY; | ||
| 103 | |||
| 104 | if (nowayout) | ||
| 105 | __module_get(THIS_MODULE); | ||
| 106 | |||
| 107 | /* Activate timer */ | ||
| 108 | if (!start_enabled) | ||
| 109 | pnx833x_wdt_start(); | ||
| 110 | |||
| 111 | pnx833x_wdt_ping(); | ||
| 112 | |||
| 113 | printk(KERN_INFO "Started watchdog timer.\n"); | ||
| 114 | |||
| 115 | return nonseekable_open(inode, file); | ||
| 116 | } | ||
| 117 | |||
| 118 | static int pnx833x_wdt_release(struct inode *inode, struct file *file) | ||
| 119 | { | ||
| 120 | /* Shut off the timer. | ||
| 121 | * Lock it in if it's a module and we defined ...NOWAYOUT */ | ||
| 122 | if (!nowayout) | ||
| 123 | pnx833x_wdt_stop(); /* Turn the WDT off */ | ||
| 124 | |||
| 125 | clear_bit(0, &pnx833x_wdt_alive); | ||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | |||
| 129 | static ssize_t pnx833x_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos) | ||
| 130 | { | ||
| 131 | /* Refresh the timer. */ | ||
| 132 | if (len) | ||
| 133 | pnx833x_wdt_ping(); | ||
| 134 | |||
| 135 | return len; | ||
| 136 | } | ||
| 137 | |||
| 138 | static long pnx833x_wdt_ioctl(struct file *file, unsigned int cmd, | ||
| 139 | unsigned long arg) | ||
| 140 | { | ||
| 141 | int options, new_timeout = 0; | ||
| 142 | uint32_t timeout, timeout_left = 0; | ||
| 143 | |||
| 144 | static struct watchdog_info ident = { | ||
| 145 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, | ||
| 146 | .firmware_version = 0, | ||
| 147 | .identity = "Hardware Watchdog for PNX833x", | ||
| 148 | }; | ||
| 149 | |||
| 150 | switch (cmd) { | ||
| 151 | default: | ||
| 152 | return -ENOTTY; | ||
| 153 | |||
| 154 | case WDIOC_GETSUPPORT: | ||
| 155 | if (copy_to_user((struct watchdog_info *)arg, | ||
| 156 | &ident, sizeof(ident))) | ||
| 157 | return -EFAULT; | ||
| 158 | return 0; | ||
| 159 | |||
| 160 | case WDIOC_GETSTATUS: | ||
| 161 | case WDIOC_GETBOOTSTATUS: | ||
| 162 | return put_user(0, (int *)arg); | ||
| 163 | |||
| 164 | case WDIOC_SETOPTIONS: | ||
| 165 | if (get_user(options, (int *)arg)) | ||
| 166 | return -EFAULT; | ||
| 167 | |||
| 168 | if (options & WDIOS_DISABLECARD) | ||
| 169 | pnx833x_wdt_stop(); | ||
| 170 | |||
| 171 | if (options & WDIOS_ENABLECARD) | ||
| 172 | pnx833x_wdt_start(); | ||
| 173 | |||
| 174 | return 0; | ||
| 175 | |||
| 176 | case WDIOC_KEEPALIVE: | ||
| 177 | pnx833x_wdt_ping(); | ||
| 178 | return 0; | ||
| 179 | |||
| 180 | case WDIOC_SETTIMEOUT: | ||
| 181 | { | ||
| 182 | if (get_user(new_timeout, (int *)arg)) | ||
| 183 | return -EFAULT; | ||
| 184 | |||
| 185 | pnx833x_wdt_timeout = new_timeout; | ||
| 186 | PNX833X_REG(PNX833X_CONFIG + | ||
| 187 | PNX833X_CONFIG_CPU_WATCHDOG_COMPARE) = new_timeout; | ||
| 188 | return put_user(new_timeout, (int *)arg); | ||
| 189 | } | ||
| 190 | |||
| 191 | case WDIOC_GETTIMEOUT: | ||
| 192 | timeout = PNX833X_REG(PNX833X_CONFIG + | ||
| 193 | PNX833X_CONFIG_CPU_WATCHDOG_COMPARE); | ||
| 194 | return put_user(timeout, (int *)arg); | ||
| 195 | |||
| 196 | case WDIOC_GETTIMELEFT: | ||
| 197 | timeout_left = PNX833X_REG(PNX833X_CONFIG + | ||
| 198 | PNX833X_CONFIG_CPU_WATCHDOG); | ||
| 199 | return put_user(timeout_left, (int *)arg); | ||
| 200 | |||
| 201 | } | ||
| 202 | } | ||
| 203 | |||
| 204 | static int pnx833x_wdt_notify_sys(struct notifier_block *this, | ||
| 205 | unsigned long code, void *unused) | ||
| 206 | { | ||
| 207 | if (code == SYS_DOWN || code == SYS_HALT) | ||
| 208 | pnx833x_wdt_stop(); /* Turn the WDT off */ | ||
| 209 | |||
| 210 | return NOTIFY_DONE; | ||
| 211 | } | ||
| 212 | |||
| 213 | static const struct file_operations pnx833x_wdt_fops = { | ||
| 214 | .owner = THIS_MODULE, | ||
| 215 | .llseek = no_llseek, | ||
| 216 | .write = pnx833x_wdt_write, | ||
| 217 | .unlocked_ioctl = pnx833x_wdt_ioctl, | ||
| 218 | .open = pnx833x_wdt_open, | ||
| 219 | .release = pnx833x_wdt_release, | ||
| 220 | }; | ||
| 221 | |||
| 222 | static struct miscdevice pnx833x_wdt_miscdev = { | ||
| 223 | .minor = WATCHDOG_MINOR, | ||
| 224 | .name = "watchdog", | ||
| 225 | .fops = &pnx833x_wdt_fops, | ||
| 226 | }; | ||
| 227 | |||
| 228 | static struct notifier_block pnx833x_wdt_notifier = { | ||
| 229 | .notifier_call = pnx833x_wdt_notify_sys, | ||
| 230 | }; | ||
| 231 | |||
| 232 | static char banner[] __initdata = | ||
| 233 | KERN_INFO PFX "Hardware Watchdog Timer for PNX833x: Version 0.1\n"; | ||
| 234 | |||
| 235 | static int __init watchdog_init(void) | ||
| 236 | { | ||
| 237 | int ret, cause; | ||
| 238 | |||
| 239 | /* Lets check the reason for the reset.*/ | ||
| 240 | cause = PNX833X_REG(PNX833X_RESET); | ||
| 241 | /*If bit 31 is set then watchdog was cause of reset.*/ | ||
| 242 | if (cause & 0x80000000) { | ||
| 243 | printk(KERN_INFO PFX "The system was previously reset due to " | ||
| 244 | "the watchdog firing - please investigate...\n"); | ||
| 245 | } | ||
| 246 | |||
| 247 | ret = register_reboot_notifier(&pnx833x_wdt_notifier); | ||
| 248 | if (ret) { | ||
| 249 | printk(KERN_ERR PFX | ||
| 250 | "cannot register reboot notifier (err=%d)\n", ret); | ||
| 251 | return ret; | ||
| 252 | } | ||
| 253 | |||
| 254 | ret = misc_register(&pnx833x_wdt_miscdev); | ||
| 255 | if (ret) { | ||
| 256 | printk(KERN_ERR PFX | ||
| 257 | "cannot register miscdev on minor=%d (err=%d)\n", | ||
| 258 | WATCHDOG_MINOR, ret); | ||
| 259 | unregister_reboot_notifier(&pnx833x_wdt_notifier); | ||
| 260 | return ret; | ||
| 261 | } | ||
| 262 | |||
| 263 | printk(banner); | ||
| 264 | if (start_enabled) | ||
| 265 | pnx833x_wdt_start(); | ||
| 266 | |||
| 267 | return 0; | ||
| 268 | } | ||
| 269 | |||
| 270 | static void __exit watchdog_exit(void) | ||
| 271 | { | ||
| 272 | misc_deregister(&pnx833x_wdt_miscdev); | ||
| 273 | unregister_reboot_notifier(&pnx833x_wdt_notifier); | ||
| 274 | } | ||
| 275 | |||
| 276 | module_init(watchdog_init); | ||
| 277 | module_exit(watchdog_exit); | ||
| 278 | |||
| 279 | MODULE_AUTHOR("Daniel Laird/Andre McCurdy"); | ||
| 280 | MODULE_DESCRIPTION("Hardware Watchdog Device for PNX833x"); | ||
| 281 | MODULE_LICENSE("GPL"); | ||
| 282 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/stmp3xxx_wdt.c b/drivers/watchdog/stmp3xxx_wdt.c new file mode 100644 index 000000000000..5dd952681f32 --- /dev/null +++ b/drivers/watchdog/stmp3xxx_wdt.c | |||
| @@ -0,0 +1,296 @@ | |||
| 1 | /* | ||
| 2 | * Watchdog driver for Freescale STMP37XX/STMP378X | ||
| 3 | * | ||
| 4 | * Author: Vitaly Wool <vital@embeddedalley.com> | ||
| 5 | * | ||
| 6 | * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. | ||
| 7 | * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. | ||
| 8 | */ | ||
| 9 | #include <linux/init.h> | ||
| 10 | #include <linux/kernel.h> | ||
| 11 | #include <linux/fs.h> | ||
| 12 | #include <linux/miscdevice.h> | ||
| 13 | #include <linux/watchdog.h> | ||
| 14 | #include <linux/platform_device.h> | ||
| 15 | #include <linux/spinlock.h> | ||
| 16 | #include <linux/uaccess.h> | ||
| 17 | |||
| 18 | #include <mach/platform.h> | ||
| 19 | #include <mach/regs-rtc.h> | ||
| 20 | |||
| 21 | #define DEFAULT_HEARTBEAT 19 | ||
| 22 | #define MAX_HEARTBEAT (0x10000000 >> 6) | ||
| 23 | |||
| 24 | /* missing bitmask in headers */ | ||
| 25 | #define BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER 0x80000000 | ||
| 26 | |||
| 27 | #define WDT_IN_USE 0 | ||
| 28 | #define WDT_OK_TO_CLOSE 1 | ||
| 29 | |||
| 30 | #define WDOG_COUNTER_RATE 1000 /* 1 kHz clock */ | ||
| 31 | |||
| 32 | static DEFINE_SPINLOCK(stmp3xxx_wdt_io_lock); | ||
| 33 | static unsigned long wdt_status; | ||
| 34 | static const int nowayout = WATCHDOG_NOWAYOUT; | ||
| 35 | static int heartbeat = DEFAULT_HEARTBEAT; | ||
| 36 | static unsigned long boot_status; | ||
| 37 | |||
| 38 | static void wdt_enable(u32 value) | ||
| 39 | { | ||
| 40 | spin_lock(&stmp3xxx_wdt_io_lock); | ||
| 41 | __raw_writel(value, REGS_RTC_BASE + HW_RTC_WATCHDOG); | ||
| 42 | stmp3xxx_setl(BM_RTC_CTRL_WATCHDOGEN, REGS_RTC_BASE + HW_RTC_CTRL); | ||
| 43 | stmp3xxx_setl(BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER, | ||
| 44 | REGS_RTC_BASE + HW_RTC_PERSISTENT1); | ||
| 45 | spin_unlock(&stmp3xxx_wdt_io_lock); | ||
| 46 | } | ||
| 47 | |||
| 48 | static void wdt_disable(void) | ||
| 49 | { | ||
| 50 | spin_lock(&stmp3xxx_wdt_io_lock); | ||
| 51 | stmp3xxx_clearl(BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER, | ||
| 52 | REGS_RTC_BASE + HW_RTC_PERSISTENT1); | ||
| 53 | stmp3xxx_clearl(BM_RTC_CTRL_WATCHDOGEN, REGS_RTC_BASE + HW_RTC_CTRL); | ||
| 54 | spin_unlock(&stmp3xxx_wdt_io_lock); | ||
| 55 | } | ||
| 56 | |||
| 57 | static void wdt_ping(void) | ||
| 58 | { | ||
| 59 | wdt_enable(heartbeat * WDOG_COUNTER_RATE); | ||
| 60 | } | ||
| 61 | |||
| 62 | static int stmp3xxx_wdt_open(struct inode *inode, struct file *file) | ||
| 63 | { | ||
| 64 | if (test_and_set_bit(WDT_IN_USE, &wdt_status)) | ||
| 65 | return -EBUSY; | ||
| 66 | |||
| 67 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); | ||
| 68 | wdt_ping(); | ||
| 69 | |||
| 70 | return nonseekable_open(inode, file); | ||
| 71 | } | ||
| 72 | |||
| 73 | static ssize_t stmp3xxx_wdt_write(struct file *file, const char __user *data, | ||
| 74 | size_t len, loff_t *ppos) | ||
| 75 | { | ||
| 76 | if (len) { | ||
| 77 | if (!nowayout) { | ||
| 78 | size_t i; | ||
| 79 | |||
| 80 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); | ||
| 81 | |||
| 82 | for (i = 0; i != len; i++) { | ||
| 83 | char c; | ||
| 84 | |||
| 85 | if (get_user(c, data + i)) | ||
| 86 | return -EFAULT; | ||
| 87 | if (c == 'V') | ||
| 88 | set_bit(WDT_OK_TO_CLOSE, &wdt_status); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | wdt_ping(); | ||
| 92 | } | ||
| 93 | |||
| 94 | return len; | ||
| 95 | } | ||
| 96 | |||
| 97 | static struct watchdog_info ident = { | ||
| 98 | .options = WDIOF_CARDRESET | | ||
| 99 | WDIOF_MAGICCLOSE | | ||
| 100 | WDIOF_SETTIMEOUT | | ||
| 101 | WDIOF_KEEPALIVEPING, | ||
| 102 | .identity = "STMP3XXX Watchdog", | ||
| 103 | }; | ||
| 104 | |||
| 105 | static long stmp3xxx_wdt_ioctl(struct file *file, unsigned int cmd, | ||
| 106 | unsigned long arg) | ||
| 107 | { | ||
| 108 | void __user *argp = (void __user *)arg; | ||
| 109 | int __user *p = argp; | ||
| 110 | int new_heartbeat, opts; | ||
| 111 | int ret = -ENOTTY; | ||
| 112 | |||
| 113 | switch (cmd) { | ||
| 114 | case WDIOC_GETSUPPORT: | ||
| 115 | ret = copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0; | ||
| 116 | break; | ||
| 117 | |||
| 118 | case WDIOC_GETSTATUS: | ||
| 119 | ret = put_user(0, p); | ||
| 120 | break; | ||
| 121 | |||
| 122 | case WDIOC_GETBOOTSTATUS: | ||
| 123 | ret = put_user(boot_status, p); | ||
| 124 | break; | ||
| 125 | |||
| 126 | case WDIOC_SETOPTIONS: | ||
| 127 | if (get_user(opts, p)) { | ||
| 128 | ret = -EFAULT; | ||
| 129 | break; | ||
| 130 | } | ||
| 131 | if (opts & WDIOS_DISABLECARD) | ||
| 132 | wdt_disable(); | ||
| 133 | else if (opts & WDIOS_ENABLECARD) | ||
| 134 | wdt_ping(); | ||
| 135 | else { | ||
| 136 | pr_debug("%s: unknown option 0x%x\n", __func__, opts); | ||
| 137 | ret = -EINVAL; | ||
| 138 | break; | ||
| 139 | } | ||
| 140 | ret = 0; | ||
| 141 | break; | ||
| 142 | |||
| 143 | case WDIOC_KEEPALIVE: | ||
| 144 | wdt_ping(); | ||
| 145 | ret = 0; | ||
| 146 | break; | ||
| 147 | |||
| 148 | case WDIOC_SETTIMEOUT: | ||
| 149 | if (get_user(new_heartbeat, p)) { | ||
| 150 | ret = -EFAULT; | ||
| 151 | break; | ||
| 152 | } | ||
| 153 | if (new_heartbeat <= 0 || new_heartbeat > MAX_HEARTBEAT) { | ||
| 154 | ret = -EINVAL; | ||
| 155 | break; | ||
| 156 | } | ||
| 157 | |||
| 158 | heartbeat = new_heartbeat; | ||
| 159 | wdt_ping(); | ||
| 160 | /* Fall through */ | ||
| 161 | |||
| 162 | case WDIOC_GETTIMEOUT: | ||
| 163 | ret = put_user(heartbeat, p); | ||
| 164 | break; | ||
| 165 | } | ||
| 166 | return ret; | ||
| 167 | } | ||
| 168 | |||
| 169 | static int stmp3xxx_wdt_release(struct inode *inode, struct file *file) | ||
| 170 | { | ||
| 171 | int ret = 0; | ||
| 172 | |||
| 173 | if (!nowayout) { | ||
| 174 | if (!test_bit(WDT_OK_TO_CLOSE, &wdt_status)) { | ||
| 175 | wdt_ping(); | ||
| 176 | pr_debug("%s: Device closed unexpectdly\n", __func__); | ||
| 177 | ret = -EINVAL; | ||
| 178 | } else { | ||
| 179 | wdt_disable(); | ||
| 180 | clear_bit(WDT_OK_TO_CLOSE, &wdt_status); | ||
| 181 | } | ||
| 182 | } | ||
| 183 | clear_bit(WDT_IN_USE, &wdt_status); | ||
| 184 | |||
| 185 | return ret; | ||
| 186 | } | ||
| 187 | |||
| 188 | static const struct file_operations stmp3xxx_wdt_fops = { | ||
| 189 | .owner = THIS_MODULE, | ||
| 190 | .llseek = no_llseek, | ||
| 191 | .write = stmp3xxx_wdt_write, | ||
| 192 | .unlocked_ioctl = stmp3xxx_wdt_ioctl, | ||
| 193 | .open = stmp3xxx_wdt_open, | ||
| 194 | .release = stmp3xxx_wdt_release, | ||
| 195 | }; | ||
| 196 | |||
| 197 | static struct miscdevice stmp3xxx_wdt_miscdev = { | ||
| 198 | .minor = WATCHDOG_MINOR, | ||
| 199 | .name = "watchdog", | ||
| 200 | .fops = &stmp3xxx_wdt_fops, | ||
| 201 | }; | ||
| 202 | |||
| 203 | static int __devinit stmp3xxx_wdt_probe(struct platform_device *pdev) | ||
| 204 | { | ||
| 205 | int ret = 0; | ||
| 206 | |||
| 207 | if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) | ||
| 208 | heartbeat = DEFAULT_HEARTBEAT; | ||
| 209 | |||
| 210 | boot_status = __raw_readl(REGS_RTC_BASE + HW_RTC_PERSISTENT1) & | ||
| 211 | BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER; | ||
| 212 | boot_status = !!boot_status; | ||
| 213 | stmp3xxx_clearl(BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER, | ||
| 214 | REGS_RTC_BASE + HW_RTC_PERSISTENT1); | ||
| 215 | wdt_disable(); /* disable for now */ | ||
| 216 | |||
| 217 | ret = misc_register(&stmp3xxx_wdt_miscdev); | ||
| 218 | if (ret < 0) { | ||
| 219 | dev_err(&pdev->dev, "cannot register misc device\n"); | ||
| 220 | return ret; | ||
| 221 | } | ||
| 222 | |||
| 223 | printk(KERN_INFO "stmp3xxx watchdog: initialized, heartbeat %d sec\n", | ||
| 224 | heartbeat); | ||
| 225 | |||
| 226 | return ret; | ||
| 227 | } | ||
| 228 | |||
| 229 | static int __devexit stmp3xxx_wdt_remove(struct platform_device *pdev) | ||
| 230 | { | ||
| 231 | misc_deregister(&stmp3xxx_wdt_miscdev); | ||
| 232 | return 0; | ||
| 233 | } | ||
| 234 | |||
| 235 | #ifdef CONFIG_PM | ||
| 236 | static int wdt_suspended; | ||
| 237 | static u32 wdt_saved_time; | ||
| 238 | |||
| 239 | static int stmp3xxx_wdt_suspend(struct platform_device *pdev, | ||
| 240 | pm_message_t state) | ||
| 241 | { | ||
| 242 | if (__raw_readl(REGS_RTC_BASE + HW_RTC_CTRL) & | ||
| 243 | BM_RTC_CTRL_WATCHDOGEN) { | ||
| 244 | wdt_suspended = 1; | ||
| 245 | wdt_saved_time = __raw_readl(REGS_RTC_BASE + HW_RTC_WATCHDOG); | ||
| 246 | wdt_disable(); | ||
| 247 | } | ||
| 248 | return 0; | ||
| 249 | } | ||
| 250 | |||
| 251 | static int stmp3xxx_wdt_resume(struct platform_device *pdev) | ||
| 252 | { | ||
| 253 | if (wdt_suspended) { | ||
| 254 | wdt_enable(wdt_saved_time); | ||
| 255 | wdt_suspended = 0; | ||
| 256 | } | ||
| 257 | return 0; | ||
| 258 | } | ||
| 259 | #else | ||
| 260 | #define stmp3xxx_wdt_suspend NULL | ||
| 261 | #define stmp3xxx_wdt_resume NULL | ||
| 262 | #endif | ||
| 263 | |||
| 264 | static struct platform_driver platform_wdt_driver = { | ||
| 265 | .driver = { | ||
| 266 | .name = "stmp3xxx_wdt", | ||
| 267 | }, | ||
| 268 | .probe = stmp3xxx_wdt_probe, | ||
| 269 | .remove = __devexit_p(stmp3xxx_wdt_remove), | ||
| 270 | .suspend = stmp3xxx_wdt_suspend, | ||
| 271 | .resume = stmp3xxx_wdt_resume, | ||
| 272 | }; | ||
| 273 | |||
| 274 | static int __init stmp3xxx_wdt_init(void) | ||
| 275 | { | ||
| 276 | return platform_driver_register(&platform_wdt_driver); | ||
| 277 | } | ||
| 278 | |||
| 279 | static void __exit stmp3xxx_wdt_exit(void) | ||
| 280 | { | ||
| 281 | return platform_driver_unregister(&platform_wdt_driver); | ||
| 282 | } | ||
| 283 | |||
| 284 | module_init(stmp3xxx_wdt_init); | ||
| 285 | module_exit(stmp3xxx_wdt_exit); | ||
| 286 | |||
| 287 | MODULE_DESCRIPTION("STMP3XXX Watchdog Driver"); | ||
| 288 | MODULE_LICENSE("GPL"); | ||
| 289 | |||
| 290 | module_param(heartbeat, int, 0); | ||
| 291 | MODULE_PARM_DESC(heartbeat, | ||
| 292 | "Watchdog heartbeat period in seconds from 1 to " | ||
| 293 | __MODULE_STRING(MAX_HEARTBEAT) ", default " | ||
| 294 | __MODULE_STRING(DEFAULT_HEARTBEAT)); | ||
| 295 | |||
| 296 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c new file mode 100644 index 000000000000..cb46556f2973 --- /dev/null +++ b/drivers/watchdog/twl4030_wdt.c | |||
| @@ -0,0 +1,272 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) Nokia Corporation | ||
| 3 | * | ||
| 4 | * Written by Timo Kokkonen <timo.t.kokkonen at nokia.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <linux/module.h> | ||
| 22 | #include <linux/types.h> | ||
| 23 | #include <linux/kernel.h> | ||
| 24 | #include <linux/fs.h> | ||
| 25 | #include <linux/watchdog.h> | ||
| 26 | #include <linux/platform_device.h> | ||
| 27 | #include <linux/miscdevice.h> | ||
| 28 | #include <linux/uaccess.h> | ||
| 29 | #include <linux/i2c/twl4030.h> | ||
| 30 | |||
| 31 | #define TWL4030_WATCHDOG_CFG_REG_OFFS 0x3 | ||
| 32 | |||
| 33 | #define TWL4030_WDT_STATE_OPEN 0x1 | ||
| 34 | #define TWL4030_WDT_STATE_ACTIVE 0x8 | ||
| 35 | |||
| 36 | static struct platform_device *twl4030_wdt_dev; | ||
| 37 | |||
| 38 | struct twl4030_wdt { | ||
| 39 | struct miscdevice miscdev; | ||
| 40 | int timer_margin; | ||
| 41 | unsigned long state; | ||
| 42 | }; | ||
| 43 | |||
| 44 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
| 45 | module_param(nowayout, int, 0); | ||
| 46 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " | ||
| 47 | "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
| 48 | |||
| 49 | static int twl4030_wdt_write(unsigned char val) | ||
| 50 | { | ||
| 51 | return twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, val, | ||
| 52 | TWL4030_WATCHDOG_CFG_REG_OFFS); | ||
| 53 | } | ||
| 54 | |||
| 55 | static int twl4030_wdt_enable(struct twl4030_wdt *wdt) | ||
| 56 | { | ||
| 57 | return twl4030_wdt_write(wdt->timer_margin + 1); | ||
| 58 | } | ||
| 59 | |||
| 60 | static int twl4030_wdt_disable(struct twl4030_wdt *wdt) | ||
| 61 | { | ||
| 62 | return twl4030_wdt_write(0); | ||
| 63 | } | ||
| 64 | |||
| 65 | static int twl4030_wdt_set_timeout(struct twl4030_wdt *wdt, int timeout) | ||
| 66 | { | ||
| 67 | if (timeout < 0 || timeout > 30) { | ||
| 68 | dev_warn(wdt->miscdev.parent, | ||
| 69 | "Timeout can only be in the range [0-30] seconds"); | ||
| 70 | return -EINVAL; | ||
| 71 | } | ||
| 72 | wdt->timer_margin = timeout; | ||
| 73 | return twl4030_wdt_enable(wdt); | ||
| 74 | } | ||
| 75 | |||
| 76 | static ssize_t twl4030_wdt_write_fop(struct file *file, | ||
| 77 | const char __user *data, size_t len, loff_t *ppos) | ||
| 78 | { | ||
| 79 | struct twl4030_wdt *wdt = file->private_data; | ||
| 80 | |||
| 81 | if (len) | ||
| 82 | twl4030_wdt_enable(wdt); | ||
| 83 | |||
| 84 | return len; | ||
| 85 | } | ||
| 86 | |||
| 87 | static long twl4030_wdt_ioctl(struct file *file, | ||
| 88 | unsigned int cmd, unsigned long arg) | ||
| 89 | { | ||
| 90 | void __user *argp = (void __user *)arg; | ||
| 91 | int __user *p = argp; | ||
| 92 | int new_margin; | ||
| 93 | struct twl4030_wdt *wdt = file->private_data; | ||
| 94 | |||
| 95 | static const struct watchdog_info twl4030_wd_ident = { | ||
| 96 | .identity = "TWL4030 Watchdog", | ||
| 97 | .options = WDIOF_SETTIMEOUT, | ||
| 98 | .firmware_version = 0, | ||
| 99 | }; | ||
| 100 | |||
| 101 | switch (cmd) { | ||
| 102 | case WDIOC_GETSUPPORT: | ||
| 103 | return copy_to_user(argp, &twl4030_wd_ident, | ||
| 104 | sizeof(twl4030_wd_ident)) ? -EFAULT : 0; | ||
| 105 | |||
| 106 | case WDIOC_GETSTATUS: | ||
| 107 | case WDIOC_GETBOOTSTATUS: | ||
| 108 | return put_user(0, p); | ||
| 109 | |||
| 110 | case WDIOC_KEEPALIVE: | ||
| 111 | twl4030_wdt_enable(wdt); | ||
| 112 | break; | ||
| 113 | |||
| 114 | case WDIOC_SETTIMEOUT: | ||
| 115 | if (get_user(new_margin, p)) | ||
| 116 | return -EFAULT; | ||
| 117 | if (twl4030_wdt_set_timeout(wdt, new_margin)) | ||
| 118 | return -EINVAL; | ||
| 119 | return put_user(wdt->timer_margin, p); | ||
| 120 | |||
| 121 | case WDIOC_GETTIMEOUT: | ||
| 122 | return put_user(wdt->timer_margin, p); | ||
| 123 | |||
| 124 | default: | ||
| 125 | return -ENOTTY; | ||
| 126 | } | ||
| 127 | |||
| 128 | return 0; | ||
| 129 | } | ||
| 130 | |||
| 131 | static int twl4030_wdt_open(struct inode *inode, struct file *file) | ||
| 132 | { | ||
| 133 | struct twl4030_wdt *wdt = platform_get_drvdata(twl4030_wdt_dev); | ||
| 134 | |||
| 135 | /* /dev/watchdog can only be opened once */ | ||
| 136 | if (test_and_set_bit(0, &wdt->state)) | ||
| 137 | return -EBUSY; | ||
| 138 | |||
| 139 | wdt->state |= TWL4030_WDT_STATE_ACTIVE; | ||
| 140 | file->private_data = (void *) wdt; | ||
| 141 | |||
| 142 | twl4030_wdt_enable(wdt); | ||
| 143 | return nonseekable_open(inode, file); | ||
| 144 | } | ||
| 145 | |||
| 146 | static int twl4030_wdt_release(struct inode *inode, struct file *file) | ||
| 147 | { | ||
| 148 | struct twl4030_wdt *wdt = file->private_data; | ||
| 149 | if (nowayout) { | ||
| 150 | dev_alert(wdt->miscdev.parent, | ||
| 151 | "Unexpected close, watchdog still running!\n"); | ||
| 152 | twl4030_wdt_enable(wdt); | ||
| 153 | } else { | ||
| 154 | if (twl4030_wdt_disable(wdt)) | ||
| 155 | return -EFAULT; | ||
| 156 | wdt->state &= ~TWL4030_WDT_STATE_ACTIVE; | ||
| 157 | } | ||
| 158 | |||
| 159 | clear_bit(0, &wdt->state); | ||
| 160 | return 0; | ||
| 161 | } | ||
| 162 | |||
| 163 | static const struct file_operations twl4030_wdt_fops = { | ||
| 164 | .owner = THIS_MODULE, | ||
| 165 | .llseek = no_llseek, | ||
| 166 | .open = twl4030_wdt_open, | ||
| 167 | .release = twl4030_wdt_release, | ||
| 168 | .unlocked_ioctl = twl4030_wdt_ioctl, | ||
| 169 | .write = twl4030_wdt_write_fop, | ||
| 170 | }; | ||
| 171 | |||
| 172 | static int __devinit twl4030_wdt_probe(struct platform_device *pdev) | ||
| 173 | { | ||
| 174 | int ret = 0; | ||
| 175 | struct twl4030_wdt *wdt; | ||
| 176 | |||
| 177 | wdt = kzalloc(sizeof(struct twl4030_wdt), GFP_KERNEL); | ||
| 178 | if (!wdt) | ||
| 179 | return -ENOMEM; | ||
| 180 | |||
| 181 | wdt->state = 0; | ||
| 182 | wdt->timer_margin = 30; | ||
| 183 | wdt->miscdev.parent = &pdev->dev; | ||
| 184 | wdt->miscdev.fops = &twl4030_wdt_fops; | ||
| 185 | wdt->miscdev.minor = WATCHDOG_MINOR; | ||
| 186 | wdt->miscdev.name = "watchdog"; | ||
| 187 | |||
| 188 | platform_set_drvdata(pdev, wdt); | ||
| 189 | |||
| 190 | twl4030_wdt_dev = pdev; | ||
| 191 | |||
| 192 | ret = misc_register(&wdt->miscdev); | ||
| 193 | if (ret) { | ||
| 194 | dev_err(wdt->miscdev.parent, | ||
| 195 | "Failed to register misc device\n"); | ||
| 196 | platform_set_drvdata(pdev, NULL); | ||
| 197 | kfree(wdt); | ||
| 198 | twl4030_wdt_dev = NULL; | ||
| 199 | return ret; | ||
| 200 | } | ||
| 201 | return 0; | ||
| 202 | } | ||
| 203 | |||
| 204 | static int __devexit twl4030_wdt_remove(struct platform_device *pdev) | ||
| 205 | { | ||
| 206 | struct twl4030_wdt *wdt = platform_get_drvdata(pdev); | ||
| 207 | |||
| 208 | if (wdt->state & TWL4030_WDT_STATE_ACTIVE) | ||
| 209 | if (twl4030_wdt_disable(wdt)) | ||
| 210 | return -EFAULT; | ||
| 211 | |||
| 212 | wdt->state &= ~TWL4030_WDT_STATE_ACTIVE; | ||
| 213 | misc_deregister(&wdt->miscdev); | ||
| 214 | |||
| 215 | platform_set_drvdata(pdev, NULL); | ||
| 216 | kfree(wdt); | ||
| 217 | twl4030_wdt_dev = NULL; | ||
| 218 | |||
| 219 | return 0; | ||
| 220 | } | ||
| 221 | |||
| 222 | #ifdef CONFIG_PM | ||
| 223 | static int twl4030_wdt_suspend(struct platform_device *pdev, pm_message_t state) | ||
| 224 | { | ||
| 225 | struct twl4030_wdt *wdt = platform_get_drvdata(pdev); | ||
| 226 | if (wdt->state & TWL4030_WDT_STATE_ACTIVE) | ||
| 227 | return twl4030_wdt_disable(wdt); | ||
| 228 | |||
| 229 | return 0; | ||
| 230 | } | ||
| 231 | |||
| 232 | static int twl4030_wdt_resume(struct platform_device *pdev) | ||
| 233 | { | ||
| 234 | struct twl4030_wdt *wdt = platform_get_drvdata(pdev); | ||
| 235 | if (wdt->state & TWL4030_WDT_STATE_ACTIVE) | ||
| 236 | return twl4030_wdt_enable(wdt); | ||
| 237 | |||
| 238 | return 0; | ||
| 239 | } | ||
| 240 | #else | ||
| 241 | #define twl4030_wdt_suspend NULL | ||
| 242 | #define twl4030_wdt_resume NULL | ||
| 243 | #endif | ||
| 244 | |||
| 245 | static struct platform_driver twl4030_wdt_driver = { | ||
| 246 | .probe = twl4030_wdt_probe, | ||
| 247 | .remove = __devexit_p(twl4030_wdt_remove), | ||
| 248 | .suspend = twl4030_wdt_suspend, | ||
| 249 | .resume = twl4030_wdt_resume, | ||
| 250 | .driver = { | ||
| 251 | .owner = THIS_MODULE, | ||
| 252 | .name = "twl4030_wdt", | ||
| 253 | }, | ||
| 254 | }; | ||
| 255 | |||
| 256 | static int __devinit twl4030_wdt_init(void) | ||
| 257 | { | ||
| 258 | return platform_driver_register(&twl4030_wdt_driver); | ||
| 259 | } | ||
| 260 | module_init(twl4030_wdt_init); | ||
| 261 | |||
| 262 | static void __devexit twl4030_wdt_exit(void) | ||
| 263 | { | ||
| 264 | platform_driver_unregister(&twl4030_wdt_driver); | ||
| 265 | } | ||
| 266 | module_exit(twl4030_wdt_exit); | ||
| 267 | |||
| 268 | MODULE_AUTHOR("Nokia Corporation"); | ||
| 269 | MODULE_LICENSE("GPL"); | ||
| 270 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
| 271 | MODULE_ALIAS("platform:twl4030_wdt"); | ||
| 272 | |||
diff --git a/drivers/watchdog/wdt_pci.c b/drivers/watchdog/wdt_pci.c index c45839a4a34d..7a1bdc7c95a9 100644 --- a/drivers/watchdog/wdt_pci.c +++ b/drivers/watchdog/wdt_pci.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Industrial Computer Source PCI-WDT500/501 driver | 2 | * Industrial Computer Source PCI-WDT500/501 driver |
| 3 | * | 3 | * |
| 4 | * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>, | 4 | * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>, |
| 5 | * All Rights Reserved. | 5 | * All Rights Reserved. |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
| @@ -99,14 +99,16 @@ MODULE_PARM_DESC(nowayout, | |||
| 99 | "Watchdog cannot be stopped once started (default=" | 99 | "Watchdog cannot be stopped once started (default=" |
| 100 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 100 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
| 101 | 101 | ||
| 102 | #ifdef CONFIG_WDT_501_PCI | ||
| 103 | /* Support for the Fan Tachometer on the PCI-WDT501 */ | 102 | /* Support for the Fan Tachometer on the PCI-WDT501 */ |
| 104 | static int tachometer; | 103 | static int tachometer; |
| 105 | |||
| 106 | module_param(tachometer, int, 0); | 104 | module_param(tachometer, int, 0); |
| 107 | MODULE_PARM_DESC(tachometer, | 105 | MODULE_PARM_DESC(tachometer, |
| 108 | "PCI-WDT501 Fan Tachometer support (0=disable, default=0)"); | 106 | "PCI-WDT501 Fan Tachometer support (0=disable, default=0)"); |
| 109 | #endif /* CONFIG_WDT_501_PCI */ | 107 | |
| 108 | static int type = 500; | ||
| 109 | module_param(type, int, 0); | ||
| 110 | MODULE_PARM_DESC(type, | ||
| 111 | "PCI-WDT501 Card type (500 or 501 , default=500)"); | ||
| 110 | 112 | ||
| 111 | /* | 113 | /* |
| 112 | * Programming support | 114 | * Programming support |
| @@ -266,22 +268,21 @@ static int wdtpci_get_status(int *status) | |||
| 266 | *status |= WDIOF_EXTERN1; | 268 | *status |= WDIOF_EXTERN1; |
| 267 | if (new_status & WDC_SR_ISII1) | 269 | if (new_status & WDC_SR_ISII1) |
| 268 | *status |= WDIOF_EXTERN2; | 270 | *status |= WDIOF_EXTERN2; |
| 269 | #ifdef CONFIG_WDT_501_PCI | 271 | if (type == 501) { |
| 270 | if (!(new_status & WDC_SR_TGOOD)) | 272 | if (!(new_status & WDC_SR_TGOOD)) |
| 271 | *status |= WDIOF_OVERHEAT; | 273 | *status |= WDIOF_OVERHEAT; |
| 272 | if (!(new_status & WDC_SR_PSUOVER)) | 274 | if (!(new_status & WDC_SR_PSUOVER)) |
| 273 | *status |= WDIOF_POWEROVER; | 275 | *status |= WDIOF_POWEROVER; |
| 274 | if (!(new_status & WDC_SR_PSUUNDR)) | 276 | if (!(new_status & WDC_SR_PSUUNDR)) |
| 275 | *status |= WDIOF_POWERUNDER; | 277 | *status |= WDIOF_POWERUNDER; |
| 276 | if (tachometer) { | 278 | if (tachometer) { |
| 277 | if (!(new_status & WDC_SR_FANGOOD)) | 279 | if (!(new_status & WDC_SR_FANGOOD)) |
| 278 | *status |= WDIOF_FANFAULT; | 280 | *status |= WDIOF_FANFAULT; |
| 281 | } | ||
| 279 | } | 282 | } |
| 280 | #endif /* CONFIG_WDT_501_PCI */ | ||
| 281 | return 0; | 283 | return 0; |
| 282 | } | 284 | } |
| 283 | 285 | ||
| 284 | #ifdef CONFIG_WDT_501_PCI | ||
| 285 | /** | 286 | /** |
| 286 | * wdtpci_get_temperature: | 287 | * wdtpci_get_temperature: |
| 287 | * | 288 | * |
| @@ -300,7 +301,6 @@ static int wdtpci_get_temperature(int *temperature) | |||
| 300 | *temperature = (c * 11 / 15) + 7; | 301 | *temperature = (c * 11 / 15) + 7; |
| 301 | return 0; | 302 | return 0; |
| 302 | } | 303 | } |
| 303 | #endif /* CONFIG_WDT_501_PCI */ | ||
| 304 | 304 | ||
| 305 | /** | 305 | /** |
| 306 | * wdtpci_interrupt: | 306 | * wdtpci_interrupt: |
| @@ -327,22 +327,22 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id) | |||
| 327 | 327 | ||
| 328 | printk(KERN_CRIT PFX "status %d\n", status); | 328 | printk(KERN_CRIT PFX "status %d\n", status); |
| 329 | 329 | ||
| 330 | #ifdef CONFIG_WDT_501_PCI | 330 | if (type == 501) { |
| 331 | if (!(status & WDC_SR_TGOOD)) { | 331 | if (!(status & WDC_SR_TGOOD)) { |
| 332 | u8 alarm = inb(WDT_RT); | 332 | printk(KERN_CRIT PFX "Overheat alarm.(%d)\n", |
| 333 | printk(KERN_CRIT PFX "Overheat alarm.(%d)\n", alarm); | 333 | inb(WDT_RT)); |
| 334 | udelay(8); | 334 | udelay(8); |
| 335 | } | 335 | } |
| 336 | if (!(status & WDC_SR_PSUOVER)) | 336 | if (!(status & WDC_SR_PSUOVER)) |
| 337 | printk(KERN_CRIT PFX "PSU over voltage.\n"); | 337 | printk(KERN_CRIT PFX "PSU over voltage.\n"); |
| 338 | if (!(status & WDC_SR_PSUUNDR)) | 338 | if (!(status & WDC_SR_PSUUNDR)) |
| 339 | printk(KERN_CRIT PFX "PSU under voltage.\n"); | 339 | printk(KERN_CRIT PFX "PSU under voltage.\n"); |
| 340 | if (tachometer) { | 340 | if (tachometer) { |
| 341 | if (!(status & WDC_SR_FANGOOD)) | 341 | if (!(status & WDC_SR_FANGOOD)) |
| 342 | printk(KERN_CRIT PFX "Possible fan fault.\n"); | 342 | printk(KERN_CRIT PFX "Possible fan fault.\n"); |
| 343 | } | ||
| 343 | } | 344 | } |
| 344 | #endif /* CONFIG_WDT_501_PCI */ | 345 | if (!(status & WDC_SR_WCCR)) { |
| 345 | if (!(status&WDC_SR_WCCR)) { | ||
| 346 | #ifdef SOFTWARE_REBOOT | 346 | #ifdef SOFTWARE_REBOOT |
| 347 | #ifdef ONLY_TESTING | 347 | #ifdef ONLY_TESTING |
| 348 | printk(KERN_CRIT PFX "Would Reboot.\n"); | 348 | printk(KERN_CRIT PFX "Would Reboot.\n"); |
| @@ -371,12 +371,13 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id) | |||
| 371 | */ | 371 | */ |
| 372 | 372 | ||
| 373 | static ssize_t wdtpci_write(struct file *file, const char __user *buf, | 373 | static ssize_t wdtpci_write(struct file *file, const char __user *buf, |
| 374 | size_t count, loff_t *ppos) | 374 | size_t count, loff_t *ppos) |
| 375 | { | 375 | { |
| 376 | if (count) { | 376 | if (count) { |
| 377 | if (!nowayout) { | 377 | if (!nowayout) { |
| 378 | size_t i; | 378 | size_t i; |
| 379 | 379 | ||
| 380 | /* In case it was set long ago */ | ||
| 380 | expect_close = 0; | 381 | expect_close = 0; |
| 381 | 382 | ||
| 382 | for (i = 0; i != count; i++) { | 383 | for (i = 0; i != count; i++) { |
| @@ -406,10 +407,10 @@ static ssize_t wdtpci_write(struct file *file, const char __user *buf, | |||
| 406 | static long wdtpci_ioctl(struct file *file, unsigned int cmd, | 407 | static long wdtpci_ioctl(struct file *file, unsigned int cmd, |
| 407 | unsigned long arg) | 408 | unsigned long arg) |
| 408 | { | 409 | { |
| 409 | int new_heartbeat; | ||
| 410 | int status; | ||
| 411 | void __user *argp = (void __user *)arg; | 410 | void __user *argp = (void __user *)arg; |
| 412 | int __user *p = argp; | 411 | int __user *p = argp; |
| 412 | int new_heartbeat; | ||
| 413 | int status; | ||
| 413 | 414 | ||
| 414 | static struct watchdog_info ident = { | 415 | static struct watchdog_info ident = { |
| 415 | .options = WDIOF_SETTIMEOUT| | 416 | .options = WDIOF_SETTIMEOUT| |
| @@ -421,11 +422,12 @@ static long wdtpci_ioctl(struct file *file, unsigned int cmd, | |||
| 421 | 422 | ||
| 422 | /* Add options according to the card we have */ | 423 | /* Add options according to the card we have */ |
| 423 | ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2); | 424 | ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2); |
| 424 | #ifdef CONFIG_WDT_501_PCI | 425 | if (type == 501) { |
| 425 | ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER); | 426 | ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER| |
| 426 | if (tachometer) | 427 | WDIOF_POWEROVER); |
| 427 | ident.options |= WDIOF_FANFAULT; | 428 | if (tachometer) |
| 428 | #endif /* CONFIG_WDT_501_PCI */ | 429 | ident.options |= WDIOF_FANFAULT; |
| 430 | } | ||
| 429 | 431 | ||
| 430 | switch (cmd) { | 432 | switch (cmd) { |
| 431 | case WDIOC_GETSUPPORT: | 433 | case WDIOC_GETSUPPORT: |
| @@ -503,7 +505,6 @@ static int wdtpci_release(struct inode *inode, struct file *file) | |||
| 503 | return 0; | 505 | return 0; |
| 504 | } | 506 | } |
| 505 | 507 | ||
| 506 | #ifdef CONFIG_WDT_501_PCI | ||
| 507 | /** | 508 | /** |
| 508 | * wdtpci_temp_read: | 509 | * wdtpci_temp_read: |
| 509 | * @file: file handle to the watchdog board | 510 | * @file: file handle to the watchdog board |
| @@ -554,7 +555,6 @@ static int wdtpci_temp_release(struct inode *inode, struct file *file) | |||
| 554 | { | 555 | { |
| 555 | return 0; | 556 | return 0; |
| 556 | } | 557 | } |
| 557 | #endif /* CONFIG_WDT_501_PCI */ | ||
| 558 | 558 | ||
| 559 | /** | 559 | /** |
| 560 | * notify_sys: | 560 | * notify_sys: |
| @@ -596,7 +596,6 @@ static struct miscdevice wdtpci_miscdev = { | |||
| 596 | .fops = &wdtpci_fops, | 596 | .fops = &wdtpci_fops, |
| 597 | }; | 597 | }; |
| 598 | 598 | ||
| 599 | #ifdef CONFIG_WDT_501_PCI | ||
| 600 | static const struct file_operations wdtpci_temp_fops = { | 599 | static const struct file_operations wdtpci_temp_fops = { |
| 601 | .owner = THIS_MODULE, | 600 | .owner = THIS_MODULE, |
| 602 | .llseek = no_llseek, | 601 | .llseek = no_llseek, |
| @@ -610,7 +609,6 @@ static struct miscdevice temp_miscdev = { | |||
| 610 | .name = "temperature", | 609 | .name = "temperature", |
| 611 | .fops = &wdtpci_temp_fops, | 610 | .fops = &wdtpci_temp_fops, |
| 612 | }; | 611 | }; |
| 613 | #endif /* CONFIG_WDT_501_PCI */ | ||
| 614 | 612 | ||
| 615 | /* | 613 | /* |
| 616 | * The WDT card needs to learn about soft shutdowns in order to | 614 | * The WDT card needs to learn about soft shutdowns in order to |
| @@ -633,6 +631,11 @@ static int __devinit wdtpci_init_one(struct pci_dev *dev, | |||
| 633 | return -ENODEV; | 631 | return -ENODEV; |
| 634 | } | 632 | } |
| 635 | 633 | ||
| 634 | if (type != 500 && type != 501) { | ||
| 635 | printk(KERN_ERR PFX "unknown card type '%d'.\n", type); | ||
| 636 | return -ENODEV; | ||
| 637 | } | ||
| 638 | |||
| 636 | if (pci_enable_device(dev)) { | 639 | if (pci_enable_device(dev)) { |
| 637 | printk(KERN_ERR PFX "Not possible to enable PCI Device\n"); | 640 | printk(KERN_ERR PFX "Not possible to enable PCI Device\n"); |
| 638 | return -ENODEV; | 641 | return -ENODEV; |
| @@ -678,15 +681,15 @@ static int __devinit wdtpci_init_one(struct pci_dev *dev, | |||
| 678 | goto out_irq; | 681 | goto out_irq; |
| 679 | } | 682 | } |
| 680 | 683 | ||
| 681 | #ifdef CONFIG_WDT_501_PCI | 684 | if (type == 501) { |
| 682 | ret = misc_register(&temp_miscdev); | 685 | ret = misc_register(&temp_miscdev); |
| 683 | if (ret) { | 686 | if (ret) { |
| 684 | printk(KERN_ERR PFX | 687 | printk(KERN_ERR PFX |
| 685 | "cannot register miscdev on minor=%d (err=%d)\n", | 688 | "cannot register miscdev on minor=%d (err=%d)\n", |
| 686 | TEMP_MINOR, ret); | 689 | TEMP_MINOR, ret); |
| 687 | goto out_rbt; | 690 | goto out_rbt; |
| 691 | } | ||
| 688 | } | 692 | } |
| 689 | #endif /* CONFIG_WDT_501_PCI */ | ||
| 690 | 693 | ||
| 691 | ret = misc_register(&wdtpci_miscdev); | 694 | ret = misc_register(&wdtpci_miscdev); |
| 692 | if (ret) { | 695 | if (ret) { |
| @@ -698,20 +701,18 @@ static int __devinit wdtpci_init_one(struct pci_dev *dev, | |||
| 698 | 701 | ||
| 699 | printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", | 702 | printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n", |
| 700 | heartbeat, nowayout); | 703 | heartbeat, nowayout); |
| 701 | #ifdef CONFIG_WDT_501_PCI | 704 | if (type == 501) |
| 702 | printk(KERN_INFO "wdt: Fan Tachometer is %s\n", | 705 | printk(KERN_INFO "wdt: Fan Tachometer is %s\n", |
| 703 | (tachometer ? "Enabled" : "Disabled")); | 706 | (tachometer ? "Enabled" : "Disabled")); |
| 704 | #endif /* CONFIG_WDT_501_PCI */ | ||
| 705 | 707 | ||
| 706 | ret = 0; | 708 | ret = 0; |
| 707 | out: | 709 | out: |
| 708 | return ret; | 710 | return ret; |
| 709 | 711 | ||
| 710 | out_misc: | 712 | out_misc: |
| 711 | #ifdef CONFIG_WDT_501_PCI | 713 | if (type == 501) |
| 712 | misc_deregister(&temp_miscdev); | 714 | misc_deregister(&temp_miscdev); |
| 713 | out_rbt: | 715 | out_rbt: |
| 714 | #endif /* CONFIG_WDT_501_PCI */ | ||
| 715 | unregister_reboot_notifier(&wdtpci_notifier); | 716 | unregister_reboot_notifier(&wdtpci_notifier); |
| 716 | out_irq: | 717 | out_irq: |
| 717 | free_irq(irq, &wdtpci_miscdev); | 718 | free_irq(irq, &wdtpci_miscdev); |
| @@ -728,9 +729,8 @@ static void __devexit wdtpci_remove_one(struct pci_dev *pdev) | |||
| 728 | /* here we assume only one device will ever have | 729 | /* here we assume only one device will ever have |
| 729 | * been picked up and registered by probe function */ | 730 | * been picked up and registered by probe function */ |
| 730 | misc_deregister(&wdtpci_miscdev); | 731 | misc_deregister(&wdtpci_miscdev); |
| 731 | #ifdef CONFIG_WDT_501_PCI | 732 | if (type == 501) |
| 732 | misc_deregister(&temp_miscdev); | 733 | misc_deregister(&temp_miscdev); |
| 733 | #endif /* CONFIG_WDT_501_PCI */ | ||
| 734 | unregister_reboot_notifier(&wdtpci_notifier); | 734 | unregister_reboot_notifier(&wdtpci_notifier); |
| 735 | free_irq(irq, &wdtpci_miscdev); | 735 | free_irq(irq, &wdtpci_miscdev); |
| 736 | release_region(io, 16); | 736 | release_region(io, 16); |
diff --git a/include/asm-generic/hardirq.h b/include/asm-generic/hardirq.h index 3d5d2c906ab3..23bb4dad4962 100644 --- a/include/asm-generic/hardirq.h +++ b/include/asm-generic/hardirq.h | |||
| @@ -11,19 +11,6 @@ typedef struct { | |||
| 11 | 11 | ||
| 12 | #include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ | 12 | #include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ |
| 13 | 13 | ||
| 14 | #ifndef HARDIRQ_BITS | ||
| 15 | #define HARDIRQ_BITS 8 | ||
| 16 | #endif | ||
| 17 | |||
| 18 | /* | ||
| 19 | * The hardirq mask has to be large enough to have | ||
| 20 | * space for potentially all IRQ sources in the system | ||
| 21 | * nesting on a single CPU: | ||
| 22 | */ | ||
| 23 | #if (1 << HARDIRQ_BITS) < NR_IRQS | ||
| 24 | # error HARDIRQ_BITS is too low! | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #ifndef ack_bad_irq | 14 | #ifndef ack_bad_irq |
| 28 | static inline void ack_bad_irq(unsigned int irq) | 15 | static inline void ack_bad_irq(unsigned int irq) |
| 29 | { | 16 | { |
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index e410f602cab1..e2bd73e8f9c0 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h | |||
| @@ -129,6 +129,10 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres | |||
| 129 | #define move_pte(pte, prot, old_addr, new_addr) (pte) | 129 | #define move_pte(pte, prot, old_addr, new_addr) (pte) |
| 130 | #endif | 130 | #endif |
| 131 | 131 | ||
| 132 | #ifndef pgprot_noncached | ||
| 133 | #define pgprot_noncached(prot) (prot) | ||
| 134 | #endif | ||
| 135 | |||
| 132 | #ifndef pgprot_writecombine | 136 | #ifndef pgprot_writecombine |
| 133 | #define pgprot_writecombine pgprot_noncached | 137 | #define pgprot_writecombine pgprot_noncached |
| 134 | #endif | 138 | #endif |
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index 6d8cab22e294..b218b8513d04 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h | |||
| @@ -163,7 +163,7 @@ static inline __must_check long __copy_to_user(void __user *to, | |||
| 163 | #define put_user(x, ptr) \ | 163 | #define put_user(x, ptr) \ |
| 164 | ({ \ | 164 | ({ \ |
| 165 | might_sleep(); \ | 165 | might_sleep(); \ |
| 166 | __access_ok(ptr, sizeof (*ptr)) ? \ | 166 | access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \ |
| 167 | __put_user(x, ptr) : \ | 167 | __put_user(x, ptr) : \ |
| 168 | -EFAULT; \ | 168 | -EFAULT; \ |
| 169 | }) | 169 | }) |
| @@ -219,7 +219,7 @@ extern int __put_user_bad(void) __attribute__((noreturn)); | |||
| 219 | #define get_user(x, ptr) \ | 219 | #define get_user(x, ptr) \ |
| 220 | ({ \ | 220 | ({ \ |
| 221 | might_sleep(); \ | 221 | might_sleep(); \ |
| 222 | __access_ok(ptr, sizeof (*ptr)) ? \ | 222 | access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \ |
| 223 | __get_user(x, ptr) : \ | 223 | __get_user(x, ptr) : \ |
| 224 | -EFAULT; \ | 224 | -EFAULT; \ |
| 225 | }) | 225 | }) |
| @@ -244,7 +244,7 @@ static inline long copy_from_user(void *to, | |||
| 244 | const void __user * from, unsigned long n) | 244 | const void __user * from, unsigned long n) |
| 245 | { | 245 | { |
| 246 | might_sleep(); | 246 | might_sleep(); |
| 247 | if (__access_ok(from, n)) | 247 | if (access_ok(VERIFY_READ, from, n)) |
| 248 | return __copy_from_user(to, from, n); | 248 | return __copy_from_user(to, from, n); |
| 249 | else | 249 | else |
| 250 | return n; | 250 | return n; |
| @@ -254,7 +254,7 @@ static inline long copy_to_user(void __user *to, | |||
| 254 | const void *from, unsigned long n) | 254 | const void *from, unsigned long n) |
| 255 | { | 255 | { |
| 256 | might_sleep(); | 256 | might_sleep(); |
| 257 | if (__access_ok(to, n)) | 257 | if (access_ok(VERIFY_WRITE, to, n)) |
| 258 | return __copy_to_user(to, from, n); | 258 | return __copy_to_user(to, from, n); |
| 259 | else | 259 | else |
| 260 | return n; | 260 | return n; |
| @@ -278,7 +278,7 @@ __strncpy_from_user(char *dst, const char __user *src, long count) | |||
| 278 | static inline long | 278 | static inline long |
| 279 | strncpy_from_user(char *dst, const char __user *src, long count) | 279 | strncpy_from_user(char *dst, const char __user *src, long count) |
| 280 | { | 280 | { |
| 281 | if (!__access_ok(src, 1)) | 281 | if (!access_ok(VERIFY_READ, src, 1)) |
| 282 | return -EFAULT; | 282 | return -EFAULT; |
| 283 | return __strncpy_from_user(dst, src, count); | 283 | return __strncpy_from_user(dst, src, count); |
| 284 | } | 284 | } |
| @@ -291,6 +291,8 @@ strncpy_from_user(char *dst, const char __user *src, long count) | |||
| 291 | #ifndef strnlen_user | 291 | #ifndef strnlen_user |
| 292 | static inline long strnlen_user(const char __user *src, long n) | 292 | static inline long strnlen_user(const char __user *src, long n) |
| 293 | { | 293 | { |
| 294 | if (!access_ok(VERIFY_READ, src, 1)) | ||
| 295 | return 0; | ||
| 294 | return strlen((void * __force)src) + 1; | 296 | return strlen((void * __force)src) + 1; |
| 295 | } | 297 | } |
| 296 | #endif | 298 | #endif |
| @@ -316,7 +318,7 @@ static inline __must_check unsigned long | |||
| 316 | clear_user(void __user *to, unsigned long n) | 318 | clear_user(void __user *to, unsigned long n) |
| 317 | { | 319 | { |
| 318 | might_sleep(); | 320 | might_sleep(); |
| 319 | if (!__access_ok(to, n)) | 321 | if (!access_ok(VERIFY_WRITE, to, n)) |
| 320 | return n; | 322 | return n; |
| 321 | 323 | ||
| 322 | return __clear_user(to, n); | 324 | return __clear_user(to, n); |
diff --git a/include/asm-generic/unistd.h b/include/asm-generic/unistd.h index 5b34b6233d6d..1125e5a1ee5d 100644 --- a/include/asm-generic/unistd.h +++ b/include/asm-generic/unistd.h | |||
| @@ -618,8 +618,13 @@ __SYSCALL(__NR_migrate_pages, sys_migrate_pages) | |||
| 618 | __SYSCALL(__NR_move_pages, sys_move_pages) | 618 | __SYSCALL(__NR_move_pages, sys_move_pages) |
| 619 | #endif | 619 | #endif |
| 620 | 620 | ||
| 621 | #define __NR_rt_tgsigqueueinfo 240 | ||
| 622 | __SYSCALL(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo) | ||
| 623 | #define __NR_perf_counter_open 241 | ||
| 624 | __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open) | ||
| 625 | |||
| 621 | #undef __NR_syscalls | 626 | #undef __NR_syscalls |
| 622 | #define __NR_syscalls 240 | 627 | #define __NR_syscalls 242 |
| 623 | 628 | ||
| 624 | /* | 629 | /* |
| 625 | * All syscalls below here should go away really, | 630 | * All syscalls below here should go away really, |
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index a05a5ef33391..2723513a5651 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h | |||
| @@ -33,7 +33,7 @@ void hugetlb_report_meminfo(struct seq_file *); | |||
| 33 | int hugetlb_report_node_meminfo(int, char *); | 33 | int hugetlb_report_node_meminfo(int, char *); |
| 34 | unsigned long hugetlb_total_pages(void); | 34 | unsigned long hugetlb_total_pages(void); |
| 35 | int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | 35 | int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, |
| 36 | unsigned long address, int write_access); | 36 | unsigned long address, unsigned int flags); |
| 37 | int hugetlb_reserve_pages(struct inode *inode, long from, long to, | 37 | int hugetlb_reserve_pages(struct inode *inode, long from, long to, |
| 38 | struct vm_area_struct *vma, | 38 | struct vm_area_struct *vma, |
| 39 | int acctflags); | 39 | int acctflags); |
| @@ -98,7 +98,7 @@ static inline void hugetlb_report_meminfo(struct seq_file *m) | |||
| 98 | #define pud_huge(x) 0 | 98 | #define pud_huge(x) 0 |
| 99 | #define is_hugepage_only_range(mm, addr, len) 0 | 99 | #define is_hugepage_only_range(mm, addr, len) 0 |
| 100 | #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) | 100 | #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) ({BUG(); 0; }) |
| 101 | #define hugetlb_fault(mm, vma, addr, write) ({ BUG(); 0; }) | 101 | #define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; }) |
| 102 | 102 | ||
| 103 | #define hugetlb_change_protection(vma, address, end, newprot) | 103 | #define hugetlb_change_protection(vma, address, end, newprot) |
| 104 | 104 | ||
diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 216d024f830d..bf116d0dbf23 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h | |||
| @@ -118,7 +118,14 @@ int try_to_munlock(struct page *); | |||
| 118 | #define anon_vma_prepare(vma) (0) | 118 | #define anon_vma_prepare(vma) (0) |
| 119 | #define anon_vma_link(vma) do {} while (0) | 119 | #define anon_vma_link(vma) do {} while (0) |
| 120 | 120 | ||
| 121 | #define page_referenced(page, locked, cnt, flags) TestClearPageReferenced(page) | 121 | static inline int page_referenced(struct page *page, int is_locked, |
| 122 | struct mem_cgroup *cnt, | ||
| 123 | unsigned long *vm_flags) | ||
| 124 | { | ||
| 125 | *vm_flags = 0; | ||
| 126 | return TestClearPageReferenced(page); | ||
| 127 | } | ||
| 128 | |||
| 122 | #define try_to_unmap(page, refs) SWAP_FAIL | 129 | #define try_to_unmap(page, refs) SWAP_FAIL |
| 123 | 130 | ||
| 124 | static inline int page_mkclean(struct page *page) | 131 | static inline int page_mkclean(struct page *page) |
diff --git a/include/linux/swap.h b/include/linux/swap.h index c88b36665f79..7c15334f3ff2 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
| @@ -298,8 +298,8 @@ extern int try_to_free_swap(struct page *); | |||
| 298 | struct backing_dev_info; | 298 | struct backing_dev_info; |
| 299 | 299 | ||
| 300 | /* linux/mm/thrash.c */ | 300 | /* linux/mm/thrash.c */ |
| 301 | extern struct mm_struct * swap_token_mm; | 301 | extern struct mm_struct *swap_token_mm; |
| 302 | extern void grab_swap_token(void); | 302 | extern void grab_swap_token(struct mm_struct *); |
| 303 | extern void __put_swap_token(struct mm_struct *); | 303 | extern void __put_swap_token(struct mm_struct *); |
| 304 | 304 | ||
| 305 | static inline int has_swap_token(struct mm_struct *mm) | 305 | static inline int has_swap_token(struct mm_struct *mm) |
| @@ -419,10 +419,10 @@ static inline swp_entry_t get_swap_page(void) | |||
| 419 | } | 419 | } |
| 420 | 420 | ||
| 421 | /* linux/mm/thrash.c */ | 421 | /* linux/mm/thrash.c */ |
| 422 | #define put_swap_token(x) do { } while(0) | 422 | #define put_swap_token(mm) do { } while (0) |
| 423 | #define grab_swap_token() do { } while(0) | 423 | #define grab_swap_token(mm) do { } while (0) |
| 424 | #define has_swap_token(x) 0 | 424 | #define has_swap_token(mm) 0 |
| 425 | #define disable_swap_token() do { } while(0) | 425 | #define disable_swap_token() do { } while (0) |
| 426 | 426 | ||
| 427 | static inline void | 427 | static inline void |
| 428 | mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent) | 428 | mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent) |
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index f24eceecc5a6..8a025d510904 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h | |||
| @@ -348,6 +348,7 @@ struct v4l2_pix_format { | |||
| 348 | #define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer */ | 348 | #define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer */ |
| 349 | #define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */ | 349 | #define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */ |
| 350 | #define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */ | 350 | #define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */ |
| 351 | #define V4L2_PIX_FMT_OV511 v4l2_fourcc('O', '5', '1', '1') /* ov511 JPEG */ | ||
| 351 | #define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */ | 352 | #define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */ |
| 352 | 353 | ||
| 353 | /* | 354 | /* |
| @@ -894,9 +895,10 @@ enum v4l2_colorfx { | |||
| 894 | V4L2_COLORFX_BW = 1, | 895 | V4L2_COLORFX_BW = 1, |
| 895 | V4L2_COLORFX_SEPIA = 2, | 896 | V4L2_COLORFX_SEPIA = 2, |
| 896 | }; | 897 | }; |
| 898 | #define V4L2_CID_AUTOBRIGHTNESS (V4L2_CID_BASE+32) | ||
| 897 | 899 | ||
| 898 | /* last CID + 1 */ | 900 | /* last CID + 1 */ |
| 899 | #define V4L2_CID_LASTP1 (V4L2_CID_BASE+32) | 901 | #define V4L2_CID_LASTP1 (V4L2_CID_BASE+33) |
| 900 | 902 | ||
| 901 | /* MPEG-class control IDs defined by V4L2 */ | 903 | /* MPEG-class control IDs defined by V4L2 */ |
| 902 | #define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) | 904 | #define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) |
diff --git a/include/media/ir-common.h b/include/media/ir-common.h index 7b5b91f60425..9dcb632f6083 100644 --- a/include/media/ir-common.h +++ b/include/media/ir-common.h | |||
| @@ -162,6 +162,8 @@ extern IR_KEYTAB_TYPE ir_codes_ati_tv_wonder_hd_600[IR_KEYTAB_SIZE]; | |||
| 162 | extern IR_KEYTAB_TYPE ir_codes_kworld_plus_tv_analog[IR_KEYTAB_SIZE]; | 162 | extern IR_KEYTAB_TYPE ir_codes_kworld_plus_tv_analog[IR_KEYTAB_SIZE]; |
| 163 | extern IR_KEYTAB_TYPE ir_codes_kaiomy[IR_KEYTAB_SIZE]; | 163 | extern IR_KEYTAB_TYPE ir_codes_kaiomy[IR_KEYTAB_SIZE]; |
| 164 | extern IR_KEYTAB_TYPE ir_codes_dm1105_nec[IR_KEYTAB_SIZE]; | 164 | extern IR_KEYTAB_TYPE ir_codes_dm1105_nec[IR_KEYTAB_SIZE]; |
| 165 | extern IR_KEYTAB_TYPE ir_codes_evga_indtube[IR_KEYTAB_SIZE]; | ||
| 166 | |||
| 165 | #endif | 167 | #endif |
| 166 | 168 | ||
| 167 | /* | 169 | /* |
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index c48c24e4d0fa..33a18426ab9b 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h | |||
| @@ -153,6 +153,22 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev, | |||
| 153 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev_addr(struct v4l2_device *v4l2_dev, | 153 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev_addr(struct v4l2_device *v4l2_dev, |
| 154 | struct i2c_adapter *adapter, | 154 | struct i2c_adapter *adapter, |
| 155 | const char *module_name, const char *client_type, u8 addr); | 155 | const char *module_name, const char *client_type, u8 addr); |
| 156 | |||
| 157 | /* Load an i2c module and return an initialized v4l2_subdev struct. | ||
| 158 | Only call request_module if module_name != NULL. | ||
| 159 | The client_type argument is the name of the chip that's on the adapter. */ | ||
| 160 | struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev, | ||
| 161 | struct i2c_adapter *adapter, | ||
| 162 | const char *module_name, const char *client_type, | ||
| 163 | int irq, void *platform_data, | ||
| 164 | u8 addr, const unsigned short *probe_addrs); | ||
| 165 | |||
| 166 | struct i2c_board_info; | ||
| 167 | |||
| 168 | struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, | ||
| 169 | struct i2c_adapter *adapter, const char *module_name, | ||
| 170 | struct i2c_board_info *info, const unsigned short *probe_addrs); | ||
| 171 | |||
| 156 | /* Initialize an v4l2_subdev with data from an i2c_client struct */ | 172 | /* Initialize an v4l2_subdev with data from an i2c_client struct */ |
| 157 | void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, | 173 | void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, |
| 158 | const struct v4l2_subdev_ops *ops); | 174 | const struct v4l2_subdev_ops *ops); |
| @@ -193,4 +209,14 @@ struct v4l2_routing { | |||
| 193 | u32 output; | 209 | u32 output; |
| 194 | }; | 210 | }; |
| 195 | 211 | ||
| 212 | /* ------------------------------------------------------------------------- */ | ||
| 213 | |||
| 214 | /* Miscellaneous helper functions */ | ||
| 215 | |||
| 216 | void v4l_bound_align_image(unsigned int *w, unsigned int wmin, | ||
| 217 | unsigned int wmax, unsigned int walign, | ||
| 218 | unsigned int *h, unsigned int hmin, | ||
| 219 | unsigned int hmax, unsigned int halign, | ||
| 220 | unsigned int salign); | ||
| 221 | |||
| 196 | #endif /* V4L2_COMMON_H_ */ | 222 | #endif /* V4L2_COMMON_H_ */ |
diff --git a/include/media/v4l2-i2c-drv.h b/include/media/v4l2-i2c-drv.h index 10a2882c3cbf..74bf741d1a9b 100644 --- a/include/media/v4l2-i2c-drv.h +++ b/include/media/v4l2-i2c-drv.h | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | /* NOTE: the full version of this header is in the v4l-dvb repository | 24 | /* NOTE: the full version of this header is in the v4l-dvb repository |
| 25 | * and allows v4l i2c drivers to be compiled on older kernels as well. | 25 | * and allows v4l i2c drivers to be compiled on pre-2.6.26 kernels. |
| 26 | * The version of this header as it appears in the kernel is a stripped | 26 | * The version of this header as it appears in the kernel is a stripped |
| 27 | * version (without all the backwards compatibility stuff) and so it | 27 | * version (without all the backwards compatibility stuff) and so it |
| 28 | * looks a bit odd. | 28 | * looks a bit odd. |
| @@ -30,6 +30,9 @@ | |||
| 30 | * If you look at the full version then you will understand the reason | 30 | * If you look at the full version then you will understand the reason |
| 31 | * for introducing this header since you really don't want to have all | 31 | * for introducing this header since you really don't want to have all |
| 32 | * the tricky backwards compatibility code in each and every i2c driver. | 32 | * the tricky backwards compatibility code in each and every i2c driver. |
| 33 | * | ||
| 34 | * If the i2c driver will never be compiled for pre-2.6.26 kernels, then | ||
| 35 | * DO NOT USE this header! Just write it as a regular i2c driver. | ||
| 33 | */ | 36 | */ |
| 34 | 37 | ||
| 35 | #ifndef __V4L2_I2C_DRV_H__ | 38 | #ifndef __V4L2_I2C_DRV_H__ |
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index a503e1cee78b..5dcb36785529 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h | |||
| @@ -79,7 +79,11 @@ struct v4l2_decode_vbi_line { | |||
| 79 | not yet implemented) since ops provide proper type-checking. | 79 | not yet implemented) since ops provide proper type-checking. |
| 80 | */ | 80 | */ |
| 81 | 81 | ||
| 82 | /* init: initialize the sensor registors to some sort of reasonable default | 82 | /* s_config: if set, then it is always called by the v4l2_i2c_new_subdev* |
| 83 | functions after the v4l2_subdev was registered. It is used to pass | ||
| 84 | platform data to the subdev which can be used during initialization. | ||
| 85 | |||
| 86 | init: initialize the sensor registors to some sort of reasonable default | ||
| 83 | values. Do not use for new drivers and should be removed in existing | 87 | values. Do not use for new drivers and should be removed in existing |
| 84 | drivers. | 88 | drivers. |
| 85 | 89 | ||
| @@ -96,6 +100,7 @@ struct v4l2_decode_vbi_line { | |||
| 96 | struct v4l2_subdev_core_ops { | 100 | struct v4l2_subdev_core_ops { |
| 97 | int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); | 101 | int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip); |
| 98 | int (*log_status)(struct v4l2_subdev *sd); | 102 | int (*log_status)(struct v4l2_subdev *sd); |
| 103 | int (*s_config)(struct v4l2_subdev *sd, int irq, void *platform_data); | ||
| 99 | int (*init)(struct v4l2_subdev *sd, u32 val); | 104 | int (*init)(struct v4l2_subdev *sd, u32 val); |
| 100 | int (*load_fw)(struct v4l2_subdev *sd); | 105 | int (*load_fw)(struct v4l2_subdev *sd); |
| 101 | int (*reset)(struct v4l2_subdev *sd, u32 val); | 106 | int (*reset)(struct v4l2_subdev *sd, u32 val); |
diff --git a/include/scsi/fc_encode.h b/include/scsi/fc_encode.h index 6300f556bce5..a0ff61c3e935 100644 --- a/include/scsi/fc_encode.h +++ b/include/scsi/fc_encode.h | |||
| @@ -107,7 +107,6 @@ static inline int fc_ct_fill(struct fc_lport *lport, struct fc_frame *fp, | |||
| 107 | break; | 107 | break; |
| 108 | 108 | ||
| 109 | default: | 109 | default: |
| 110 | FC_DBG("Invalid op code %x \n", op); | ||
| 111 | return -EINVAL; | 110 | return -EINVAL; |
| 112 | } | 111 | } |
| 113 | *r_ctl = FC_RCTL_DD_UNSOL_CTL; | 112 | *r_ctl = FC_RCTL_DD_UNSOL_CTL; |
| @@ -298,7 +297,6 @@ static inline int fc_els_fill(struct fc_lport *lport, struct fc_rport *rport, | |||
| 298 | break; | 297 | break; |
| 299 | 298 | ||
| 300 | default: | 299 | default: |
| 301 | FC_DBG("Invalid op code %x \n", op); | ||
| 302 | return -EINVAL; | 300 | return -EINVAL; |
| 303 | } | 301 | } |
| 304 | 302 | ||
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index ebdd9f4cf070..b92584a8843a 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
| @@ -34,17 +34,72 @@ | |||
| 34 | 34 | ||
| 35 | #include <scsi/fc_frame.h> | 35 | #include <scsi/fc_frame.h> |
| 36 | 36 | ||
| 37 | #define LIBFC_DEBUG | 37 | #define FC_LIBFC_LOGGING 0x01 /* General logging, not categorized */ |
| 38 | 38 | #define FC_LPORT_LOGGING 0x02 /* lport layer logging */ | |
| 39 | #ifdef LIBFC_DEBUG | 39 | #define FC_DISC_LOGGING 0x04 /* discovery layer logging */ |
| 40 | /* Log messages */ | 40 | #define FC_RPORT_LOGGING 0x08 /* rport layer logging */ |
| 41 | #define FC_DBG(fmt, args...) \ | 41 | #define FC_FCP_LOGGING 0x10 /* I/O path logging */ |
| 42 | do { \ | 42 | #define FC_EM_LOGGING 0x20 /* Exchange Manager logging */ |
| 43 | printk(KERN_INFO "%s " fmt, __func__, ##args); \ | 43 | #define FC_EXCH_LOGGING 0x40 /* Exchange/Sequence logging */ |
| 44 | } while (0) | 44 | #define FC_SCSI_LOGGING 0x80 /* SCSI logging (mostly error handling) */ |
| 45 | #else | 45 | |
| 46 | #define FC_DBG(fmt, args...) | 46 | extern unsigned int fc_debug_logging; |
| 47 | #endif | 47 | |
| 48 | #define FC_CHECK_LOGGING(LEVEL, CMD) \ | ||
| 49 | do { \ | ||
| 50 | if (unlikely(fc_debug_logging & LEVEL)) \ | ||
| 51 | do { \ | ||
| 52 | CMD; \ | ||
| 53 | } while (0); \ | ||
| 54 | } while (0); | ||
| 55 | |||
| 56 | #define FC_LIBFC_DBG(fmt, args...) \ | ||
| 57 | FC_CHECK_LOGGING(FC_LIBFC_LOGGING, \ | ||
| 58 | printk(KERN_INFO "libfc: " fmt, ##args);) | ||
| 59 | |||
| 60 | #define FC_LPORT_DBG(lport, fmt, args...) \ | ||
| 61 | FC_CHECK_LOGGING(FC_LPORT_LOGGING, \ | ||
| 62 | printk(KERN_INFO "lport: %6x: " fmt, \ | ||
| 63 | fc_host_port_id(lport->host), ##args);) | ||
| 64 | |||
| 65 | #define FC_DISC_DBG(disc, fmt, args...) \ | ||
| 66 | FC_CHECK_LOGGING(FC_DISC_LOGGING, \ | ||
| 67 | printk(KERN_INFO "disc: %6x: " fmt, \ | ||
| 68 | fc_host_port_id(disc->lport->host), \ | ||
| 69 | ##args);) | ||
| 70 | |||
| 71 | #define FC_RPORT_DBG(rport, fmt, args...) \ | ||
| 72 | do { \ | ||
| 73 | struct fc_rport_libfc_priv *rdata = rport->dd_data; \ | ||
| 74 | struct fc_lport *lport = rdata->local_port; \ | ||
| 75 | FC_CHECK_LOGGING(FC_RPORT_LOGGING, \ | ||
| 76 | printk(KERN_INFO "rport: %6x: %6x: " fmt, \ | ||
| 77 | fc_host_port_id(lport->host), \ | ||
| 78 | rport->port_id, ##args);) \ | ||
| 79 | } while (0); | ||
| 80 | |||
| 81 | #define FC_FCP_DBG(pkt, fmt, args...) \ | ||
| 82 | FC_CHECK_LOGGING(FC_FCP_LOGGING, \ | ||
| 83 | printk(KERN_INFO "fcp: %6x: %6x: " fmt, \ | ||
| 84 | fc_host_port_id(pkt->lp->host), \ | ||
| 85 | pkt->rport->port_id, ##args);) | ||
| 86 | |||
| 87 | #define FC_EM_DBG(em, fmt, args...) \ | ||
| 88 | FC_CHECK_LOGGING(FC_EM_LOGGING, \ | ||
| 89 | printk(KERN_INFO "em: %6x: " fmt, \ | ||
| 90 | fc_host_port_id(em->lp->host), \ | ||
| 91 | ##args);) | ||
| 92 | |||
| 93 | #define FC_EXCH_DBG(exch, fmt, args...) \ | ||
| 94 | FC_CHECK_LOGGING(FC_EXCH_LOGGING, \ | ||
| 95 | printk(KERN_INFO "exch: %6x: %4x: " fmt, \ | ||
| 96 | fc_host_port_id(exch->lp->host), \ | ||
| 97 | exch->xid, ##args);) | ||
| 98 | |||
| 99 | #define FC_SCSI_DBG(lport, fmt, args...) \ | ||
| 100 | FC_CHECK_LOGGING(FC_SCSI_LOGGING, \ | ||
| 101 | printk(KERN_INFO "scsi: %6x: " fmt, \ | ||
| 102 | fc_host_port_id(lport->host), ##args);) | ||
| 48 | 103 | ||
| 49 | /* | 104 | /* |
| 50 | * libfc error codes | 105 | * libfc error codes |
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index 196525cd402f..61afeb59a836 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h | |||
| @@ -125,6 +125,10 @@ struct iscsi_task { | |||
| 125 | struct scsi_cmnd *sc; /* associated SCSI cmd*/ | 125 | struct scsi_cmnd *sc; /* associated SCSI cmd*/ |
| 126 | struct iscsi_conn *conn; /* used connection */ | 126 | struct iscsi_conn *conn; /* used connection */ |
| 127 | 127 | ||
| 128 | /* data processing tracking */ | ||
| 129 | unsigned long last_xfer; | ||
| 130 | unsigned long last_timeout; | ||
| 131 | bool have_checked_conn; | ||
| 128 | /* state set/tested under session->lock */ | 132 | /* state set/tested under session->lock */ |
| 129 | int state; | 133 | int state; |
| 130 | atomic_t refcount; | 134 | atomic_t refcount; |
diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h index 1f5ca7f62116..9fd6702f02e2 100644 --- a/include/scsi/scsi_driver.h +++ b/include/scsi/scsi_driver.h | |||
| @@ -32,5 +32,6 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req); | |||
| 32 | int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req); | 32 | int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req); |
| 33 | int scsi_prep_state_check(struct scsi_device *sdev, struct request *req); | 33 | int scsi_prep_state_check(struct scsi_device *sdev, struct request *req); |
| 34 | int scsi_prep_return(struct request_queue *q, struct request *req, int ret); | 34 | int scsi_prep_return(struct request_queue *q, struct request *req, int ret); |
| 35 | int scsi_prep_fn(struct request_queue *, struct request *); | ||
| 35 | 36 | ||
| 36 | #endif /* _SCSI_SCSI_DRIVER_H */ | 37 | #endif /* _SCSI_SCSI_DRIVER_H */ |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 23067ab1a73c..4c32b1a1a06e 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -340,8 +340,6 @@ config DEBUG_KMEMLEAK | |||
| 340 | bool "Kernel memory leak detector" | 340 | bool "Kernel memory leak detector" |
| 341 | depends on DEBUG_KERNEL && EXPERIMENTAL && (X86 || ARM) && \ | 341 | depends on DEBUG_KERNEL && EXPERIMENTAL && (X86 || ARM) && \ |
| 342 | !MEMORY_HOTPLUG | 342 | !MEMORY_HOTPLUG |
| 343 | select DEBUG_SLAB if SLAB | ||
| 344 | select SLUB_DEBUG if SLUB | ||
| 345 | select DEBUG_FS if SYSFS | 343 | select DEBUG_FS if SYSFS |
| 346 | select STACKTRACE if STACKTRACE_SUPPORT | 344 | select STACKTRACE if STACKTRACE_SUPPORT |
| 347 | select KALLSYMS | 345 | select KALLSYMS |
| @@ -355,6 +353,9 @@ config DEBUG_KMEMLEAK | |||
| 355 | allocations. See Documentation/kmemleak.txt for more | 353 | allocations. See Documentation/kmemleak.txt for more |
| 356 | details. | 354 | details. |
| 357 | 355 | ||
| 356 | Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances | ||
| 357 | of finding leaks due to the slab objects poisoning. | ||
| 358 | |||
| 358 | In order to access the kmemleak file, debugfs needs to be | 359 | In order to access the kmemleak file, debugfs needs to be |
| 359 | mounted (usually at /sys/kernel/debug). | 360 | mounted (usually at /sys/kernel/debug). |
| 360 | 361 | ||
diff --git a/lib/checksum.c b/lib/checksum.c index 12e5a1c91cda..b2e2fd468461 100644 --- a/lib/checksum.c +++ b/lib/checksum.c | |||
| @@ -55,7 +55,11 @@ static unsigned int do_csum(const unsigned char *buff, int len) | |||
| 55 | goto out; | 55 | goto out; |
| 56 | odd = 1 & (unsigned long) buff; | 56 | odd = 1 & (unsigned long) buff; |
| 57 | if (odd) { | 57 | if (odd) { |
| 58 | #ifdef __LITTLE_ENDIAN | ||
| 58 | result = *buff; | 59 | result = *buff; |
| 60 | #else | ||
| 61 | result += (*buff << 8); | ||
| 62 | #endif | ||
| 59 | len--; | 63 | len--; |
| 60 | buff++; | 64 | buff++; |
| 61 | } | 65 | } |
| @@ -71,7 +75,7 @@ static unsigned int do_csum(const unsigned char *buff, int len) | |||
| 71 | if (count) { | 75 | if (count) { |
| 72 | unsigned long carry = 0; | 76 | unsigned long carry = 0; |
| 73 | do { | 77 | do { |
| 74 | unsigned long w = *(unsigned long *) buff; | 78 | unsigned long w = *(unsigned int *) buff; |
| 75 | count--; | 79 | count--; |
| 76 | buff += 4; | 80 | buff += 4; |
| 77 | result += carry; | 81 | result += carry; |
| @@ -87,7 +91,11 @@ static unsigned int do_csum(const unsigned char *buff, int len) | |||
| 87 | } | 91 | } |
| 88 | } | 92 | } |
| 89 | if (len & 1) | 93 | if (len & 1) |
| 94 | #ifdef __LITTLE_ENDIAN | ||
| 95 | result += *buff; | ||
| 96 | #else | ||
| 90 | result += (*buff << 8); | 97 | result += (*buff << 8); |
| 98 | #endif | ||
| 91 | result = from32to16(result); | 99 | result = from32to16(result); |
| 92 | if (odd) | 100 | if (odd) |
| 93 | result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); | 101 | result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a56e6f3ce979..d0351e31f474 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
| @@ -1985,7 +1985,7 @@ static struct page *hugetlbfs_pagecache_page(struct hstate *h, | |||
| 1985 | } | 1985 | } |
| 1986 | 1986 | ||
| 1987 | static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, | 1987 | static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, |
| 1988 | unsigned long address, pte_t *ptep, int write_access) | 1988 | unsigned long address, pte_t *ptep, unsigned int flags) |
| 1989 | { | 1989 | { |
| 1990 | struct hstate *h = hstate_vma(vma); | 1990 | struct hstate *h = hstate_vma(vma); |
| 1991 | int ret = VM_FAULT_SIGBUS; | 1991 | int ret = VM_FAULT_SIGBUS; |
| @@ -2053,7 +2053,7 @@ retry: | |||
| 2053 | * any allocations necessary to record that reservation occur outside | 2053 | * any allocations necessary to record that reservation occur outside |
| 2054 | * the spinlock. | 2054 | * the spinlock. |
| 2055 | */ | 2055 | */ |
| 2056 | if (write_access && !(vma->vm_flags & VM_SHARED)) | 2056 | if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) |
| 2057 | if (vma_needs_reservation(h, vma, address) < 0) { | 2057 | if (vma_needs_reservation(h, vma, address) < 0) { |
| 2058 | ret = VM_FAULT_OOM; | 2058 | ret = VM_FAULT_OOM; |
| 2059 | goto backout_unlocked; | 2059 | goto backout_unlocked; |
| @@ -2072,7 +2072,7 @@ retry: | |||
| 2072 | && (vma->vm_flags & VM_SHARED))); | 2072 | && (vma->vm_flags & VM_SHARED))); |
| 2073 | set_huge_pte_at(mm, address, ptep, new_pte); | 2073 | set_huge_pte_at(mm, address, ptep, new_pte); |
| 2074 | 2074 | ||
| 2075 | if (write_access && !(vma->vm_flags & VM_SHARED)) { | 2075 | if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) { |
| 2076 | /* Optimization, do the COW without a second fault */ | 2076 | /* Optimization, do the COW without a second fault */ |
| 2077 | ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page); | 2077 | ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page); |
| 2078 | } | 2078 | } |
| @@ -2091,7 +2091,7 @@ backout_unlocked: | |||
| 2091 | } | 2091 | } |
| 2092 | 2092 | ||
| 2093 | int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | 2093 | int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, |
| 2094 | unsigned long address, int write_access) | 2094 | unsigned long address, unsigned int flags) |
| 2095 | { | 2095 | { |
| 2096 | pte_t *ptep; | 2096 | pte_t *ptep; |
| 2097 | pte_t entry; | 2097 | pte_t entry; |
| @@ -2112,7 +2112,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 2112 | mutex_lock(&hugetlb_instantiation_mutex); | 2112 | mutex_lock(&hugetlb_instantiation_mutex); |
| 2113 | entry = huge_ptep_get(ptep); | 2113 | entry = huge_ptep_get(ptep); |
| 2114 | if (huge_pte_none(entry)) { | 2114 | if (huge_pte_none(entry)) { |
| 2115 | ret = hugetlb_no_page(mm, vma, address, ptep, write_access); | 2115 | ret = hugetlb_no_page(mm, vma, address, ptep, flags); |
| 2116 | goto out_mutex; | 2116 | goto out_mutex; |
| 2117 | } | 2117 | } |
| 2118 | 2118 | ||
| @@ -2126,7 +2126,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 2126 | * page now as it is used to determine if a reservation has been | 2126 | * page now as it is used to determine if a reservation has been |
| 2127 | * consumed. | 2127 | * consumed. |
| 2128 | */ | 2128 | */ |
| 2129 | if (write_access && !pte_write(entry)) { | 2129 | if ((flags & FAULT_FLAG_WRITE) && !pte_write(entry)) { |
| 2130 | if (vma_needs_reservation(h, vma, address) < 0) { | 2130 | if (vma_needs_reservation(h, vma, address) < 0) { |
| 2131 | ret = VM_FAULT_OOM; | 2131 | ret = VM_FAULT_OOM; |
| 2132 | goto out_mutex; | 2132 | goto out_mutex; |
| @@ -2143,7 +2143,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 2143 | goto out_page_table_lock; | 2143 | goto out_page_table_lock; |
| 2144 | 2144 | ||
| 2145 | 2145 | ||
| 2146 | if (write_access) { | 2146 | if (flags & FAULT_FLAG_WRITE) { |
| 2147 | if (!pte_write(entry)) { | 2147 | if (!pte_write(entry)) { |
| 2148 | ret = hugetlb_cow(mm, vma, address, ptep, entry, | 2148 | ret = hugetlb_cow(mm, vma, address, ptep, entry, |
| 2149 | pagecache_page); | 2149 | pagecache_page); |
| @@ -2152,7 +2152,8 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 2152 | entry = pte_mkdirty(entry); | 2152 | entry = pte_mkdirty(entry); |
| 2153 | } | 2153 | } |
| 2154 | entry = pte_mkyoung(entry); | 2154 | entry = pte_mkyoung(entry); |
| 2155 | if (huge_ptep_set_access_flags(vma, address, ptep, entry, write_access)) | 2155 | if (huge_ptep_set_access_flags(vma, address, ptep, entry, |
| 2156 | flags & FAULT_FLAG_WRITE)) | ||
| 2156 | update_mmu_cache(vma, address, entry); | 2157 | update_mmu_cache(vma, address, entry); |
| 2157 | 2158 | ||
| 2158 | out_page_table_lock: | 2159 | out_page_table_lock: |
diff --git a/mm/kmemleak.c b/mm/kmemleak.c index ec759b60077a..c96f2c8700aa 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c | |||
| @@ -61,6 +61,8 @@ | |||
| 61 | * structure. | 61 | * structure. |
| 62 | */ | 62 | */ |
| 63 | 63 | ||
| 64 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
| 65 | |||
| 64 | #include <linux/init.h> | 66 | #include <linux/init.h> |
| 65 | #include <linux/kernel.h> | 67 | #include <linux/kernel.h> |
| 66 | #include <linux/list.h> | 68 | #include <linux/list.h> |
| @@ -311,7 +313,7 @@ static int unreferenced_object(struct kmemleak_object *object) | |||
| 311 | 313 | ||
| 312 | static void print_referenced(struct kmemleak_object *object) | 314 | static void print_referenced(struct kmemleak_object *object) |
| 313 | { | 315 | { |
| 314 | pr_info("kmemleak: referenced object 0x%08lx (size %zu)\n", | 316 | pr_info("referenced object 0x%08lx (size %zu)\n", |
| 315 | object->pointer, object->size); | 317 | object->pointer, object->size); |
| 316 | } | 318 | } |
| 317 | 319 | ||
| @@ -320,7 +322,7 @@ static void print_unreferenced(struct seq_file *seq, | |||
| 320 | { | 322 | { |
| 321 | int i; | 323 | int i; |
| 322 | 324 | ||
| 323 | print_helper(seq, "kmemleak: unreferenced object 0x%08lx (size %zu):\n", | 325 | print_helper(seq, "unreferenced object 0x%08lx (size %zu):\n", |
| 324 | object->pointer, object->size); | 326 | object->pointer, object->size); |
| 325 | print_helper(seq, " comm \"%s\", pid %d, jiffies %lu\n", | 327 | print_helper(seq, " comm \"%s\", pid %d, jiffies %lu\n", |
| 326 | object->comm, object->pid, object->jiffies); | 328 | object->comm, object->pid, object->jiffies); |
| @@ -344,7 +346,7 @@ static void dump_object_info(struct kmemleak_object *object) | |||
| 344 | trace.nr_entries = object->trace_len; | 346 | trace.nr_entries = object->trace_len; |
| 345 | trace.entries = object->trace; | 347 | trace.entries = object->trace; |
| 346 | 348 | ||
| 347 | pr_notice("kmemleak: Object 0x%08lx (size %zu):\n", | 349 | pr_notice("Object 0x%08lx (size %zu):\n", |
| 348 | object->tree_node.start, object->size); | 350 | object->tree_node.start, object->size); |
| 349 | pr_notice(" comm \"%s\", pid %d, jiffies %lu\n", | 351 | pr_notice(" comm \"%s\", pid %d, jiffies %lu\n", |
| 350 | object->comm, object->pid, object->jiffies); | 352 | object->comm, object->pid, object->jiffies); |
| @@ -372,7 +374,7 @@ static struct kmemleak_object *lookup_object(unsigned long ptr, int alias) | |||
| 372 | object = prio_tree_entry(node, struct kmemleak_object, | 374 | object = prio_tree_entry(node, struct kmemleak_object, |
| 373 | tree_node); | 375 | tree_node); |
| 374 | if (!alias && object->pointer != ptr) { | 376 | if (!alias && object->pointer != ptr) { |
| 375 | kmemleak_warn("kmemleak: Found object by alias"); | 377 | kmemleak_warn("Found object by alias"); |
| 376 | object = NULL; | 378 | object = NULL; |
| 377 | } | 379 | } |
| 378 | } else | 380 | } else |
| @@ -467,8 +469,7 @@ static void create_object(unsigned long ptr, size_t size, int min_count, | |||
| 467 | 469 | ||
| 468 | object = kmem_cache_alloc(object_cache, gfp & GFP_KMEMLEAK_MASK); | 470 | object = kmem_cache_alloc(object_cache, gfp & GFP_KMEMLEAK_MASK); |
| 469 | if (!object) { | 471 | if (!object) { |
| 470 | kmemleak_stop("kmemleak: Cannot allocate a kmemleak_object " | 472 | kmemleak_stop("Cannot allocate a kmemleak_object structure\n"); |
| 471 | "structure\n"); | ||
| 472 | return; | 473 | return; |
| 473 | } | 474 | } |
| 474 | 475 | ||
| @@ -527,8 +528,8 @@ static void create_object(unsigned long ptr, size_t size, int min_count, | |||
| 527 | if (node != &object->tree_node) { | 528 | if (node != &object->tree_node) { |
| 528 | unsigned long flags; | 529 | unsigned long flags; |
| 529 | 530 | ||
| 530 | kmemleak_stop("kmemleak: Cannot insert 0x%lx into the object " | 531 | kmemleak_stop("Cannot insert 0x%lx into the object search tree " |
| 531 | "search tree (already existing)\n", ptr); | 532 | "(already existing)\n", ptr); |
| 532 | object = lookup_object(ptr, 1); | 533 | object = lookup_object(ptr, 1); |
| 533 | spin_lock_irqsave(&object->lock, flags); | 534 | spin_lock_irqsave(&object->lock, flags); |
| 534 | dump_object_info(object); | 535 | dump_object_info(object); |
| @@ -553,7 +554,7 @@ static void delete_object(unsigned long ptr) | |||
| 553 | write_lock_irqsave(&kmemleak_lock, flags); | 554 | write_lock_irqsave(&kmemleak_lock, flags); |
| 554 | object = lookup_object(ptr, 0); | 555 | object = lookup_object(ptr, 0); |
| 555 | if (!object) { | 556 | if (!object) { |
| 556 | kmemleak_warn("kmemleak: Freeing unknown object at 0x%08lx\n", | 557 | kmemleak_warn("Freeing unknown object at 0x%08lx\n", |
| 557 | ptr); | 558 | ptr); |
| 558 | write_unlock_irqrestore(&kmemleak_lock, flags); | 559 | write_unlock_irqrestore(&kmemleak_lock, flags); |
| 559 | return; | 560 | return; |
| @@ -588,8 +589,7 @@ static void make_gray_object(unsigned long ptr) | |||
| 588 | 589 | ||
| 589 | object = find_and_get_object(ptr, 0); | 590 | object = find_and_get_object(ptr, 0); |
| 590 | if (!object) { | 591 | if (!object) { |
| 591 | kmemleak_warn("kmemleak: Graying unknown object at 0x%08lx\n", | 592 | kmemleak_warn("Graying unknown object at 0x%08lx\n", ptr); |
| 592 | ptr); | ||
| 593 | return; | 593 | return; |
| 594 | } | 594 | } |
| 595 | 595 | ||
| @@ -610,8 +610,7 @@ static void make_black_object(unsigned long ptr) | |||
| 610 | 610 | ||
| 611 | object = find_and_get_object(ptr, 0); | 611 | object = find_and_get_object(ptr, 0); |
| 612 | if (!object) { | 612 | if (!object) { |
| 613 | kmemleak_warn("kmemleak: Blacking unknown object at 0x%08lx\n", | 613 | kmemleak_warn("Blacking unknown object at 0x%08lx\n", ptr); |
| 614 | ptr); | ||
| 615 | return; | 614 | return; |
| 616 | } | 615 | } |
| 617 | 616 | ||
| @@ -634,21 +633,20 @@ static void add_scan_area(unsigned long ptr, unsigned long offset, | |||
| 634 | 633 | ||
| 635 | object = find_and_get_object(ptr, 0); | 634 | object = find_and_get_object(ptr, 0); |
| 636 | if (!object) { | 635 | if (!object) { |
| 637 | kmemleak_warn("kmemleak: Adding scan area to unknown " | 636 | kmemleak_warn("Adding scan area to unknown object at 0x%08lx\n", |
| 638 | "object at 0x%08lx\n", ptr); | 637 | ptr); |
| 639 | return; | 638 | return; |
| 640 | } | 639 | } |
| 641 | 640 | ||
| 642 | area = kmem_cache_alloc(scan_area_cache, gfp & GFP_KMEMLEAK_MASK); | 641 | area = kmem_cache_alloc(scan_area_cache, gfp & GFP_KMEMLEAK_MASK); |
| 643 | if (!area) { | 642 | if (!area) { |
| 644 | kmemleak_warn("kmemleak: Cannot allocate a scan area\n"); | 643 | kmemleak_warn("Cannot allocate a scan area\n"); |
| 645 | goto out; | 644 | goto out; |
| 646 | } | 645 | } |
| 647 | 646 | ||
| 648 | spin_lock_irqsave(&object->lock, flags); | 647 | spin_lock_irqsave(&object->lock, flags); |
| 649 | if (offset + length > object->size) { | 648 | if (offset + length > object->size) { |
| 650 | kmemleak_warn("kmemleak: Scan area larger than object " | 649 | kmemleak_warn("Scan area larger than object 0x%08lx\n", ptr); |
| 651 | "0x%08lx\n", ptr); | ||
| 652 | dump_object_info(object); | 650 | dump_object_info(object); |
| 653 | kmem_cache_free(scan_area_cache, area); | 651 | kmem_cache_free(scan_area_cache, area); |
| 654 | goto out_unlock; | 652 | goto out_unlock; |
| @@ -677,8 +675,7 @@ static void object_no_scan(unsigned long ptr) | |||
| 677 | 675 | ||
| 678 | object = find_and_get_object(ptr, 0); | 676 | object = find_and_get_object(ptr, 0); |
| 679 | if (!object) { | 677 | if (!object) { |
| 680 | kmemleak_warn("kmemleak: Not scanning unknown object at " | 678 | kmemleak_warn("Not scanning unknown object at 0x%08lx\n", ptr); |
| 681 | "0x%08lx\n", ptr); | ||
| 682 | return; | 679 | return; |
| 683 | } | 680 | } |
| 684 | 681 | ||
| @@ -699,7 +696,7 @@ static void log_early(int op_type, const void *ptr, size_t size, | |||
| 699 | struct early_log *log; | 696 | struct early_log *log; |
| 700 | 697 | ||
| 701 | if (crt_early_log >= ARRAY_SIZE(early_log)) { | 698 | if (crt_early_log >= ARRAY_SIZE(early_log)) { |
| 702 | kmemleak_stop("kmemleak: Early log buffer exceeded\n"); | 699 | kmemleak_stop("Early log buffer exceeded\n"); |
| 703 | return; | 700 | return; |
| 704 | } | 701 | } |
| 705 | 702 | ||
| @@ -966,7 +963,7 @@ static void kmemleak_scan(void) | |||
| 966 | * 1 reference to any object at this point. | 963 | * 1 reference to any object at this point. |
| 967 | */ | 964 | */ |
| 968 | if (atomic_read(&object->use_count) > 1) { | 965 | if (atomic_read(&object->use_count) > 1) { |
| 969 | pr_debug("kmemleak: object->use_count = %d\n", | 966 | pr_debug("object->use_count = %d\n", |
| 970 | atomic_read(&object->use_count)); | 967 | atomic_read(&object->use_count)); |
| 971 | dump_object_info(object); | 968 | dump_object_info(object); |
| 972 | } | 969 | } |
| @@ -1062,7 +1059,7 @@ static int kmemleak_scan_thread(void *arg) | |||
| 1062 | { | 1059 | { |
| 1063 | static int first_run = 1; | 1060 | static int first_run = 1; |
| 1064 | 1061 | ||
| 1065 | pr_info("kmemleak: Automatic memory scanning thread started\n"); | 1062 | pr_info("Automatic memory scanning thread started\n"); |
| 1066 | 1063 | ||
| 1067 | /* | 1064 | /* |
| 1068 | * Wait before the first scan to allow the system to fully initialize. | 1065 | * Wait before the first scan to allow the system to fully initialize. |
| @@ -1108,7 +1105,7 @@ static int kmemleak_scan_thread(void *arg) | |||
| 1108 | timeout = schedule_timeout_interruptible(timeout); | 1105 | timeout = schedule_timeout_interruptible(timeout); |
| 1109 | } | 1106 | } |
| 1110 | 1107 | ||
| 1111 | pr_info("kmemleak: Automatic memory scanning thread ended\n"); | 1108 | pr_info("Automatic memory scanning thread ended\n"); |
| 1112 | 1109 | ||
| 1113 | return 0; | 1110 | return 0; |
| 1114 | } | 1111 | } |
| @@ -1123,7 +1120,7 @@ void start_scan_thread(void) | |||
| 1123 | return; | 1120 | return; |
| 1124 | scan_thread = kthread_run(kmemleak_scan_thread, NULL, "kmemleak"); | 1121 | scan_thread = kthread_run(kmemleak_scan_thread, NULL, "kmemleak"); |
| 1125 | if (IS_ERR(scan_thread)) { | 1122 | if (IS_ERR(scan_thread)) { |
| 1126 | pr_warning("kmemleak: Failed to create the scan thread\n"); | 1123 | pr_warning("Failed to create the scan thread\n"); |
| 1127 | scan_thread = NULL; | 1124 | scan_thread = NULL; |
| 1128 | } | 1125 | } |
| 1129 | } | 1126 | } |
| @@ -1367,7 +1364,7 @@ static void kmemleak_cleanup(void) | |||
| 1367 | cleanup_thread = kthread_run(kmemleak_cleanup_thread, NULL, | 1364 | cleanup_thread = kthread_run(kmemleak_cleanup_thread, NULL, |
| 1368 | "kmemleak-clean"); | 1365 | "kmemleak-clean"); |
| 1369 | if (IS_ERR(cleanup_thread)) | 1366 | if (IS_ERR(cleanup_thread)) |
| 1370 | pr_warning("kmemleak: Failed to create the clean-up thread\n"); | 1367 | pr_warning("Failed to create the clean-up thread\n"); |
| 1371 | } | 1368 | } |
| 1372 | 1369 | ||
| 1373 | /* | 1370 | /* |
| @@ -1488,8 +1485,7 @@ static int __init kmemleak_late_init(void) | |||
| 1488 | dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL, | 1485 | dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL, |
| 1489 | &kmemleak_fops); | 1486 | &kmemleak_fops); |
| 1490 | if (!dentry) | 1487 | if (!dentry) |
| 1491 | pr_warning("kmemleak: Failed to create the debugfs kmemleak " | 1488 | pr_warning("Failed to create the debugfs kmemleak file\n"); |
| 1492 | "file\n"); | ||
| 1493 | mutex_lock(&kmemleak_mutex); | 1489 | mutex_lock(&kmemleak_mutex); |
| 1494 | start_scan_thread(); | 1490 | start_scan_thread(); |
| 1495 | mutex_unlock(&kmemleak_mutex); | 1491 | mutex_unlock(&kmemleak_mutex); |
diff --git a/mm/memory.c b/mm/memory.c index 98bcb90d5957..f46ac18ba231 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
| @@ -1311,8 +1311,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, | |||
| 1311 | while (!(page = follow_page(vma, start, foll_flags))) { | 1311 | while (!(page = follow_page(vma, start, foll_flags))) { |
| 1312 | int ret; | 1312 | int ret; |
| 1313 | 1313 | ||
| 1314 | /* FOLL_WRITE matches FAULT_FLAG_WRITE! */ | 1314 | ret = handle_mm_fault(mm, vma, start, |
| 1315 | ret = handle_mm_fault(mm, vma, start, foll_flags & FOLL_WRITE); | 1315 | (foll_flags & FOLL_WRITE) ? |
| 1316 | FAULT_FLAG_WRITE : 0); | ||
| 1317 | |||
| 1316 | if (ret & VM_FAULT_ERROR) { | 1318 | if (ret & VM_FAULT_ERROR) { |
| 1317 | if (ret & VM_FAULT_OOM) | 1319 | if (ret & VM_FAULT_OOM) |
| 1318 | return i ? i : -ENOMEM; | 1320 | return i ? i : -ENOMEM; |
| @@ -2517,7 +2519,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 2517 | delayacct_set_flag(DELAYACCT_PF_SWAPIN); | 2519 | delayacct_set_flag(DELAYACCT_PF_SWAPIN); |
| 2518 | page = lookup_swap_cache(entry); | 2520 | page = lookup_swap_cache(entry); |
| 2519 | if (!page) { | 2521 | if (!page) { |
| 2520 | grab_swap_token(); /* Contend for token _before_ read-in */ | 2522 | grab_swap_token(mm); /* Contend for token _before_ read-in */ |
| 2521 | page = swapin_readahead(entry, | 2523 | page = swapin_readahead(entry, |
| 2522 | GFP_HIGHUSER_MOVABLE, vma, address); | 2524 | GFP_HIGHUSER_MOVABLE, vma, address); |
| 2523 | if (!page) { | 2525 | if (!page) { |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 30d5093a099d..aecc9cdfdfce 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
| @@ -3026,7 +3026,7 @@ bad: | |||
| 3026 | if (dzone == zone) | 3026 | if (dzone == zone) |
| 3027 | break; | 3027 | break; |
| 3028 | kfree(zone_pcp(dzone, cpu)); | 3028 | kfree(zone_pcp(dzone, cpu)); |
| 3029 | zone_pcp(dzone, cpu) = NULL; | 3029 | zone_pcp(dzone, cpu) = &boot_pageset[cpu]; |
| 3030 | } | 3030 | } |
| 3031 | return -ENOMEM; | 3031 | return -ENOMEM; |
| 3032 | } | 3032 | } |
| @@ -3041,7 +3041,7 @@ static inline void free_zone_pagesets(int cpu) | |||
| 3041 | /* Free per_cpu_pageset if it is slab allocated */ | 3041 | /* Free per_cpu_pageset if it is slab allocated */ |
| 3042 | if (pset != &boot_pageset[cpu]) | 3042 | if (pset != &boot_pageset[cpu]) |
| 3043 | kfree(pset); | 3043 | kfree(pset); |
| 3044 | zone_pcp(zone, cpu) = NULL; | 3044 | zone_pcp(zone, cpu) = &boot_pageset[cpu]; |
| 3045 | } | 3045 | } |
| 3046 | } | 3046 | } |
| 3047 | 3047 | ||
| @@ -4659,7 +4659,7 @@ int percpu_pagelist_fraction_sysctl_handler(ctl_table *table, int write, | |||
| 4659 | ret = proc_dointvec_minmax(table, write, file, buffer, length, ppos); | 4659 | ret = proc_dointvec_minmax(table, write, file, buffer, length, ppos); |
| 4660 | if (!write || (ret == -EINVAL)) | 4660 | if (!write || (ret == -EINVAL)) |
| 4661 | return ret; | 4661 | return ret; |
| 4662 | for_each_zone(zone) { | 4662 | for_each_populated_zone(zone) { |
| 4663 | for_each_online_cpu(cpu) { | 4663 | for_each_online_cpu(cpu) { |
| 4664 | unsigned long high; | 4664 | unsigned long high; |
| 4665 | high = zone->present_pages / percpu_pagelist_fraction; | 4665 | high = zone->present_pages / percpu_pagelist_fraction; |
diff --git a/mm/thrash.c b/mm/thrash.c index c4c5205a9c35..2372d4ed5dd8 100644 --- a/mm/thrash.c +++ b/mm/thrash.c | |||
| @@ -26,47 +26,45 @@ static DEFINE_SPINLOCK(swap_token_lock); | |||
| 26 | struct mm_struct *swap_token_mm; | 26 | struct mm_struct *swap_token_mm; |
| 27 | static unsigned int global_faults; | 27 | static unsigned int global_faults; |
| 28 | 28 | ||
| 29 | void grab_swap_token(void) | 29 | void grab_swap_token(struct mm_struct *mm) |
| 30 | { | 30 | { |
| 31 | int current_interval; | 31 | int current_interval; |
| 32 | 32 | ||
| 33 | global_faults++; | 33 | global_faults++; |
| 34 | 34 | ||
| 35 | current_interval = global_faults - current->mm->faultstamp; | 35 | current_interval = global_faults - mm->faultstamp; |
| 36 | 36 | ||
| 37 | if (!spin_trylock(&swap_token_lock)) | 37 | if (!spin_trylock(&swap_token_lock)) |
| 38 | return; | 38 | return; |
| 39 | 39 | ||
| 40 | /* First come first served */ | 40 | /* First come first served */ |
| 41 | if (swap_token_mm == NULL) { | 41 | if (swap_token_mm == NULL) { |
| 42 | current->mm->token_priority = current->mm->token_priority + 2; | 42 | mm->token_priority = mm->token_priority + 2; |
| 43 | swap_token_mm = current->mm; | 43 | swap_token_mm = mm; |
| 44 | goto out; | 44 | goto out; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | if (current->mm != swap_token_mm) { | 47 | if (mm != swap_token_mm) { |
| 48 | if (current_interval < current->mm->last_interval) | 48 | if (current_interval < mm->last_interval) |
| 49 | current->mm->token_priority++; | 49 | mm->token_priority++; |
| 50 | else { | 50 | else { |
| 51 | if (likely(current->mm->token_priority > 0)) | 51 | if (likely(mm->token_priority > 0)) |
| 52 | current->mm->token_priority--; | 52 | mm->token_priority--; |
| 53 | } | 53 | } |
| 54 | /* Check if we deserve the token */ | 54 | /* Check if we deserve the token */ |
| 55 | if (current->mm->token_priority > | 55 | if (mm->token_priority > swap_token_mm->token_priority) { |
| 56 | swap_token_mm->token_priority) { | 56 | mm->token_priority += 2; |
| 57 | current->mm->token_priority += 2; | 57 | swap_token_mm = mm; |
| 58 | swap_token_mm = current->mm; | ||
| 59 | } | 58 | } |
| 60 | } else { | 59 | } else { |
| 61 | /* Token holder came in again! */ | 60 | /* Token holder came in again! */ |
| 62 | current->mm->token_priority += 2; | 61 | mm->token_priority += 2; |
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | out: | 64 | out: |
| 66 | current->mm->faultstamp = global_faults; | 65 | mm->faultstamp = global_faults; |
| 67 | current->mm->last_interval = current_interval; | 66 | mm->last_interval = current_interval; |
| 68 | spin_unlock(&swap_token_lock); | 67 | spin_unlock(&swap_token_lock); |
| 69 | return; | ||
| 70 | } | 68 | } |
| 71 | 69 | ||
| 72 | /* Called on process exit. */ | 70 | /* Called on process exit. */ |
diff --git a/mm/vmscan.c b/mm/vmscan.c index e8fa2d9eb212..54155268dfca 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
| @@ -932,7 +932,7 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan, | |||
| 932 | continue; | 932 | continue; |
| 933 | if (__isolate_lru_page(cursor_page, mode, file) == 0) { | 933 | if (__isolate_lru_page(cursor_page, mode, file) == 0) { |
| 934 | list_move(&cursor_page->lru, dst); | 934 | list_move(&cursor_page->lru, dst); |
| 935 | mem_cgroup_del_lru(page); | 935 | mem_cgroup_del_lru(cursor_page); |
| 936 | nr_taken++; | 936 | nr_taken++; |
| 937 | scan++; | 937 | scan++; |
| 938 | } | 938 | } |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 84da3ba17c86..ac2150e0670d 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
| @@ -320,7 +320,7 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream, | |||
| 320 | snd_mask_max(¶ms->masks[SNDRV_PCM_HW_PARAM_CHANNELS])) { | 320 | snd_mask_max(¶ms->masks[SNDRV_PCM_HW_PARAM_CHANNELS])) { |
| 321 | changed = substream->ops->ioctl(substream, | 321 | changed = substream->ops->ioctl(substream, |
| 322 | SNDRV_PCM_IOCTL1_FIFO_SIZE, params); | 322 | SNDRV_PCM_IOCTL1_FIFO_SIZE, params); |
| 323 | if (params < 0) | 323 | if (changed < 0) |
| 324 | return changed; | 324 | return changed; |
| 325 | } | 325 | } |
| 326 | } | 326 | } |
diff --git a/sound/core/seq/seq_midi_event.c b/sound/core/seq/seq_midi_event.c index 8284f176a342..b5d6ea4904c0 100644 --- a/sound/core/seq/seq_midi_event.c +++ b/sound/core/seq/seq_midi_event.c | |||
| @@ -504,10 +504,10 @@ static int extra_decode_xrpn(struct snd_midi_event *dev, unsigned char *buf, | |||
| 504 | if (dev->nostat && count < 12) | 504 | if (dev->nostat && count < 12) |
| 505 | return -ENOMEM; | 505 | return -ENOMEM; |
| 506 | cmd = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f); | 506 | cmd = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f); |
| 507 | bytes[0] = ev->data.control.param & 0x007f; | 507 | bytes[0] = (ev->data.control.param & 0x3f80) >> 7; |
| 508 | bytes[1] = (ev->data.control.param & 0x3f80) >> 7; | 508 | bytes[1] = ev->data.control.param & 0x007f; |
| 509 | bytes[2] = ev->data.control.value & 0x007f; | 509 | bytes[2] = (ev->data.control.value & 0x3f80) >> 7; |
| 510 | bytes[3] = (ev->data.control.value & 0x3f80) >> 7; | 510 | bytes[3] = ev->data.control.value & 0x007f; |
| 511 | if (cmd != dev->lastcmd && !dev->nostat) { | 511 | if (cmd != dev->lastcmd && !dev->nostat) { |
| 512 | if (count < 9) | 512 | if (count < 9) |
| 513 | return -ENOMEM; | 513 | return -ENOMEM; |
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index b0adc8094009..a49c76647307 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c | |||
| @@ -46,8 +46,6 @@ static struct snd_pci_quirk __devinitdata subsys_20k1_list[] = { | |||
| 46 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, 0x0031, "SB073x", CTSB073X), | 46 | SND_PCI_QUIRK(PCI_VENDOR_ID_CREATIVE, 0x0031, "SB073x", CTSB073X), |
| 47 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_CREATIVE, 0xf000, 0x6000, | 47 | SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_CREATIVE, 0xf000, 0x6000, |
| 48 | "UAA", CTUAA), | 48 | "UAA", CTUAA), |
| 49 | SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_CREATIVE, | ||
| 50 | "Unknown", CT20K1_UNKNOWN), | ||
| 51 | { } /* terminator */ | 49 | { } /* terminator */ |
| 52 | }; | 50 | }; |
| 53 | 51 | ||
| @@ -67,13 +65,16 @@ static struct snd_pci_quirk __devinitdata subsys_20k2_list[] = { | |||
| 67 | }; | 65 | }; |
| 68 | 66 | ||
| 69 | static const char *ct_subsys_name[NUM_CTCARDS] = { | 67 | static const char *ct_subsys_name[NUM_CTCARDS] = { |
| 68 | /* 20k1 models */ | ||
| 70 | [CTSB055X] = "SB055x", | 69 | [CTSB055X] = "SB055x", |
| 71 | [CTSB073X] = "SB073x", | 70 | [CTSB073X] = "SB073x", |
| 72 | [CTSB0760] = "SB076x", | ||
| 73 | [CTUAA] = "UAA", | 71 | [CTUAA] = "UAA", |
| 74 | [CT20K1_UNKNOWN] = "Unknown", | 72 | [CT20K1_UNKNOWN] = "Unknown", |
| 73 | /* 20k2 models */ | ||
| 74 | [CTSB0760] = "SB076x", | ||
| 75 | [CTHENDRIX] = "Hendrix", | 75 | [CTHENDRIX] = "Hendrix", |
| 76 | [CTSB0880] = "SB0880", | 76 | [CTSB0880] = "SB0880", |
| 77 | [CT20K2_UNKNOWN] = "Unknown", | ||
| 77 | }; | 78 | }; |
| 78 | 79 | ||
| 79 | static struct { | 80 | static struct { |
| @@ -260,13 +261,8 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
| 260 | int device = apcm->substream->pcm->device; | 261 | int device = apcm->substream->pcm->device; |
| 261 | unsigned int pitch; | 262 | unsigned int pitch; |
| 262 | 263 | ||
| 263 | if (NULL != apcm->src) { | ||
| 264 | /* Prepared pcm playback */ | ||
| 265 | return 0; | ||
| 266 | } | ||
| 267 | |||
| 268 | /* first release old resources */ | 264 | /* first release old resources */ |
| 269 | atc->pcm_release_resources(atc, apcm); | 265 | atc_pcm_release_resources(atc, apcm); |
| 270 | 266 | ||
| 271 | /* Get SRC resource */ | 267 | /* Get SRC resource */ |
| 272 | desc.multi = apcm->substream->runtime->channels; | 268 | desc.multi = apcm->substream->runtime->channels; |
| @@ -660,10 +656,7 @@ static int atc_pcm_capture_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
| 660 | unsigned int pitch; | 656 | unsigned int pitch; |
| 661 | int mix_base = 0, imp_base = 0; | 657 | int mix_base = 0, imp_base = 0; |
| 662 | 658 | ||
| 663 | if (NULL != apcm->src) { | 659 | atc_pcm_release_resources(atc, apcm); |
| 664 | /* Prepared pcm capture */ | ||
| 665 | return 0; | ||
| 666 | } | ||
| 667 | 660 | ||
| 668 | /* Get needed resources. */ | 661 | /* Get needed resources. */ |
| 669 | err = atc_pcm_capture_get_resources(atc, apcm); | 662 | err = atc_pcm_capture_get_resources(atc, apcm); |
| @@ -866,7 +859,7 @@ spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
| 866 | struct dao *dao = container_of(atc->daios[SPDIFOO], struct dao, daio); | 859 | struct dao *dao = container_of(atc->daios[SPDIFOO], struct dao, daio); |
| 867 | unsigned int rate = apcm->substream->runtime->rate; | 860 | unsigned int rate = apcm->substream->runtime->rate; |
| 868 | unsigned int status; | 861 | unsigned int status; |
| 869 | int err; | 862 | int err = 0; |
| 870 | unsigned char iec958_con_fs; | 863 | unsigned char iec958_con_fs; |
| 871 | 864 | ||
| 872 | switch (rate) { | 865 | switch (rate) { |
| @@ -907,8 +900,7 @@ spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
| 907 | int err; | 900 | int err; |
| 908 | int i; | 901 | int i; |
| 909 | 902 | ||
| 910 | if (NULL != apcm->src) | 903 | atc_pcm_release_resources(atc, apcm); |
| 911 | return 0; | ||
| 912 | 904 | ||
| 913 | /* Configure SPDIFOO and PLL to passthrough mode; | 905 | /* Configure SPDIFOO and PLL to passthrough mode; |
| 914 | * determine pll_rate. */ | 906 | * determine pll_rate. */ |
| @@ -1115,32 +1107,20 @@ static int atc_spdif_out_passthru(struct ct_atc *atc, unsigned char state) | |||
| 1115 | return err; | 1107 | return err; |
| 1116 | } | 1108 | } |
| 1117 | 1109 | ||
| 1118 | static int ct_atc_destroy(struct ct_atc *atc) | 1110 | static int atc_release_resources(struct ct_atc *atc) |
| 1119 | { | 1111 | { |
| 1120 | struct daio_mgr *daio_mgr; | 1112 | int i; |
| 1121 | struct dao *dao; | 1113 | struct daio_mgr *daio_mgr = NULL; |
| 1122 | struct dai *dai; | 1114 | struct dao *dao = NULL; |
| 1123 | struct daio *daio; | 1115 | struct dai *dai = NULL; |
| 1124 | struct sum_mgr *sum_mgr; | 1116 | struct daio *daio = NULL; |
| 1125 | struct src_mgr *src_mgr; | 1117 | struct sum_mgr *sum_mgr = NULL; |
| 1126 | struct srcimp_mgr *srcimp_mgr; | 1118 | struct src_mgr *src_mgr = NULL; |
| 1127 | struct srcimp *srcimp; | 1119 | struct srcimp_mgr *srcimp_mgr = NULL; |
| 1128 | struct ct_mixer *mixer; | 1120 | struct srcimp *srcimp = NULL; |
| 1129 | int i = 0; | 1121 | struct ct_mixer *mixer = NULL; |
| 1130 | 1122 | ||
| 1131 | if (NULL == atc) | 1123 | /* disconnect internal mixer objects */ |
| 1132 | return 0; | ||
| 1133 | |||
| 1134 | if (atc->timer) { | ||
| 1135 | ct_timer_free(atc->timer); | ||
| 1136 | atc->timer = NULL; | ||
| 1137 | } | ||
| 1138 | |||
| 1139 | /* Stop hardware and disable all interrupts */ | ||
| 1140 | if (NULL != atc->hw) | ||
| 1141 | ((struct hw *)atc->hw)->card_stop(atc->hw); | ||
| 1142 | |||
| 1143 | /* Destroy internal mixer objects */ | ||
| 1144 | if (NULL != atc->mixer) { | 1124 | if (NULL != atc->mixer) { |
| 1145 | mixer = atc->mixer; | 1125 | mixer = atc->mixer; |
| 1146 | mixer->set_input_left(mixer, MIX_LINE_IN, NULL); | 1126 | mixer->set_input_left(mixer, MIX_LINE_IN, NULL); |
| @@ -1149,7 +1129,6 @@ static int ct_atc_destroy(struct ct_atc *atc) | |||
| 1149 | mixer->set_input_right(mixer, MIX_MIC_IN, NULL); | 1129 | mixer->set_input_right(mixer, MIX_MIC_IN, NULL); |
| 1150 | mixer->set_input_left(mixer, MIX_SPDIF_IN, NULL); | 1130 | mixer->set_input_left(mixer, MIX_SPDIF_IN, NULL); |
| 1151 | mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); | 1131 | mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); |
| 1152 | ct_mixer_destroy(atc->mixer); | ||
| 1153 | } | 1132 | } |
| 1154 | 1133 | ||
| 1155 | if (NULL != atc->daios) { | 1134 | if (NULL != atc->daios) { |
| @@ -1167,6 +1146,7 @@ static int ct_atc_destroy(struct ct_atc *atc) | |||
| 1167 | daio_mgr->put_daio(daio_mgr, daio); | 1146 | daio_mgr->put_daio(daio_mgr, daio); |
| 1168 | } | 1147 | } |
| 1169 | kfree(atc->daios); | 1148 | kfree(atc->daios); |
| 1149 | atc->daios = NULL; | ||
| 1170 | } | 1150 | } |
| 1171 | 1151 | ||
| 1172 | if (NULL != atc->pcm) { | 1152 | if (NULL != atc->pcm) { |
| @@ -1175,6 +1155,7 @@ static int ct_atc_destroy(struct ct_atc *atc) | |||
| 1175 | sum_mgr->put_sum(sum_mgr, atc->pcm[i]); | 1155 | sum_mgr->put_sum(sum_mgr, atc->pcm[i]); |
| 1176 | 1156 | ||
| 1177 | kfree(atc->pcm); | 1157 | kfree(atc->pcm); |
| 1158 | atc->pcm = NULL; | ||
| 1178 | } | 1159 | } |
| 1179 | 1160 | ||
| 1180 | if (NULL != atc->srcs) { | 1161 | if (NULL != atc->srcs) { |
| @@ -1183,6 +1164,7 @@ static int ct_atc_destroy(struct ct_atc *atc) | |||
| 1183 | src_mgr->put_src(src_mgr, atc->srcs[i]); | 1164 | src_mgr->put_src(src_mgr, atc->srcs[i]); |
| 1184 | 1165 | ||
| 1185 | kfree(atc->srcs); | 1166 | kfree(atc->srcs); |
| 1167 | atc->srcs = NULL; | ||
| 1186 | } | 1168 | } |
| 1187 | 1169 | ||
| 1188 | if (NULL != atc->srcimps) { | 1170 | if (NULL != atc->srcimps) { |
| @@ -1193,8 +1175,30 @@ static int ct_atc_destroy(struct ct_atc *atc) | |||
| 1193 | srcimp_mgr->put_srcimp(srcimp_mgr, atc->srcimps[i]); | 1175 | srcimp_mgr->put_srcimp(srcimp_mgr, atc->srcimps[i]); |
| 1194 | } | 1176 | } |
| 1195 | kfree(atc->srcimps); | 1177 | kfree(atc->srcimps); |
| 1178 | atc->srcimps = NULL; | ||
| 1179 | } | ||
| 1180 | |||
| 1181 | return 0; | ||
| 1182 | } | ||
| 1183 | |||
| 1184 | static int ct_atc_destroy(struct ct_atc *atc) | ||
| 1185 | { | ||
| 1186 | int i = 0; | ||
| 1187 | |||
| 1188 | if (NULL == atc) | ||
| 1189 | return 0; | ||
| 1190 | |||
| 1191 | if (atc->timer) { | ||
| 1192 | ct_timer_free(atc->timer); | ||
| 1193 | atc->timer = NULL; | ||
| 1196 | } | 1194 | } |
| 1197 | 1195 | ||
| 1196 | atc_release_resources(atc); | ||
| 1197 | |||
| 1198 | /* Destroy internal mixer objects */ | ||
| 1199 | if (NULL != atc->mixer) | ||
| 1200 | ct_mixer_destroy(atc->mixer); | ||
| 1201 | |||
| 1198 | for (i = 0; i < NUM_RSCTYP; i++) { | 1202 | for (i = 0; i < NUM_RSCTYP; i++) { |
| 1199 | if ((NULL != rsc_mgr_funcs[i].destroy) && | 1203 | if ((NULL != rsc_mgr_funcs[i].destroy) && |
| 1200 | (NULL != atc->rsc_mgrs[i])) | 1204 | (NULL != atc->rsc_mgrs[i])) |
| @@ -1240,9 +1244,21 @@ static int __devinit atc_identify_card(struct ct_atc *atc) | |||
| 1240 | return -ENOENT; | 1244 | return -ENOENT; |
| 1241 | } | 1245 | } |
| 1242 | p = snd_pci_quirk_lookup(atc->pci, list); | 1246 | p = snd_pci_quirk_lookup(atc->pci, list); |
| 1243 | if (!p) | 1247 | if (p) { |
| 1244 | return -ENOENT; | 1248 | if (p->value < 0) { |
| 1245 | atc->model = p->value; | 1249 | printk(KERN_ERR "ctxfi: " |
| 1250 | "Device %04x:%04x is black-listed\n", | ||
| 1251 | atc->pci->subsystem_vendor, | ||
| 1252 | atc->pci->subsystem_device); | ||
| 1253 | return -ENOENT; | ||
| 1254 | } | ||
| 1255 | atc->model = p->value; | ||
| 1256 | } else { | ||
| 1257 | if (atc->chip_type == ATC20K1) | ||
| 1258 | atc->model = CT20K1_UNKNOWN; | ||
| 1259 | else | ||
| 1260 | atc->model = CT20K2_UNKNOWN; | ||
| 1261 | } | ||
| 1246 | atc->model_name = ct_subsys_name[atc->model]; | 1262 | atc->model_name = ct_subsys_name[atc->model]; |
| 1247 | snd_printd("ctxfi: chip %s model %s (%04x:%04x) is found\n", | 1263 | snd_printd("ctxfi: chip %s model %s (%04x:%04x) is found\n", |
| 1248 | atc->chip_name, atc->model_name, | 1264 | atc->chip_name, atc->model_name, |
| @@ -1310,7 +1326,7 @@ static int __devinit atc_create_hw_devs(struct ct_atc *atc) | |||
| 1310 | return 0; | 1326 | return 0; |
| 1311 | } | 1327 | } |
| 1312 | 1328 | ||
| 1313 | static int __devinit atc_get_resources(struct ct_atc *atc) | 1329 | static int atc_get_resources(struct ct_atc *atc) |
| 1314 | { | 1330 | { |
| 1315 | struct daio_desc da_desc = {0}; | 1331 | struct daio_desc da_desc = {0}; |
| 1316 | struct daio_mgr *daio_mgr; | 1332 | struct daio_mgr *daio_mgr; |
| @@ -1407,16 +1423,10 @@ static int __devinit atc_get_resources(struct ct_atc *atc) | |||
| 1407 | atc->n_pcm++; | 1423 | atc->n_pcm++; |
| 1408 | } | 1424 | } |
| 1409 | 1425 | ||
| 1410 | err = ct_mixer_create(atc, (struct ct_mixer **)&atc->mixer); | ||
| 1411 | if (err) { | ||
| 1412 | printk(KERN_ERR "ctxfi: Failed to create mixer obj!!!\n"); | ||
| 1413 | return err; | ||
| 1414 | } | ||
| 1415 | |||
| 1416 | return 0; | 1426 | return 0; |
| 1417 | } | 1427 | } |
| 1418 | 1428 | ||
| 1419 | static void __devinit | 1429 | static void |
| 1420 | atc_connect_dai(struct src_mgr *src_mgr, struct dai *dai, | 1430 | atc_connect_dai(struct src_mgr *src_mgr, struct dai *dai, |
| 1421 | struct src **srcs, struct srcimp **srcimps) | 1431 | struct src **srcs, struct srcimp **srcimps) |
| 1422 | { | 1432 | { |
| @@ -1455,7 +1465,7 @@ atc_connect_dai(struct src_mgr *src_mgr, struct dai *dai, | |||
| 1455 | src_mgr->commit_write(src_mgr); /* Synchronously enable SRCs */ | 1465 | src_mgr->commit_write(src_mgr); /* Synchronously enable SRCs */ |
| 1456 | } | 1466 | } |
| 1457 | 1467 | ||
| 1458 | static void __devinit atc_connect_resources(struct ct_atc *atc) | 1468 | static void atc_connect_resources(struct ct_atc *atc) |
| 1459 | { | 1469 | { |
| 1460 | struct dai *dai; | 1470 | struct dai *dai; |
| 1461 | struct dao *dao; | 1471 | struct dao *dao; |
| @@ -1501,6 +1511,84 @@ static void __devinit atc_connect_resources(struct ct_atc *atc) | |||
| 1501 | } | 1511 | } |
| 1502 | } | 1512 | } |
| 1503 | 1513 | ||
| 1514 | #ifdef CONFIG_PM | ||
| 1515 | static int atc_suspend(struct ct_atc *atc, pm_message_t state) | ||
| 1516 | { | ||
| 1517 | int i; | ||
| 1518 | struct hw *hw = atc->hw; | ||
| 1519 | |||
| 1520 | snd_power_change_state(atc->card, SNDRV_CTL_POWER_D3hot); | ||
| 1521 | |||
| 1522 | for (i = FRONT; i < NUM_PCMS; i++) { | ||
| 1523 | if (!atc->pcms[i]) | ||
| 1524 | continue; | ||
| 1525 | |||
| 1526 | snd_pcm_suspend_all(atc->pcms[i]); | ||
| 1527 | } | ||
| 1528 | |||
| 1529 | atc_release_resources(atc); | ||
| 1530 | |||
| 1531 | hw->suspend(hw, state); | ||
| 1532 | |||
| 1533 | return 0; | ||
| 1534 | } | ||
| 1535 | |||
| 1536 | static int atc_hw_resume(struct ct_atc *atc) | ||
| 1537 | { | ||
| 1538 | struct hw *hw = atc->hw; | ||
| 1539 | struct card_conf info = {0}; | ||
| 1540 | |||
| 1541 | /* Re-initialize card hardware. */ | ||
| 1542 | info.rsr = atc->rsr; | ||
| 1543 | info.msr = atc->msr; | ||
| 1544 | info.vm_pgt_phys = atc_get_ptp_phys(atc, 0); | ||
| 1545 | return hw->resume(hw, &info); | ||
| 1546 | } | ||
| 1547 | |||
| 1548 | static int atc_resources_resume(struct ct_atc *atc) | ||
| 1549 | { | ||
| 1550 | struct ct_mixer *mixer; | ||
| 1551 | int err = 0; | ||
| 1552 | |||
| 1553 | /* Get resources */ | ||
| 1554 | err = atc_get_resources(atc); | ||
| 1555 | if (err < 0) { | ||
| 1556 | atc_release_resources(atc); | ||
| 1557 | return err; | ||
| 1558 | } | ||
| 1559 | |||
| 1560 | /* Build topology */ | ||
| 1561 | atc_connect_resources(atc); | ||
| 1562 | |||
| 1563 | mixer = atc->mixer; | ||
| 1564 | mixer->resume(mixer); | ||
| 1565 | |||
| 1566 | return 0; | ||
| 1567 | } | ||
| 1568 | |||
| 1569 | static int atc_resume(struct ct_atc *atc) | ||
| 1570 | { | ||
| 1571 | int err = 0; | ||
| 1572 | |||
| 1573 | /* Do hardware resume. */ | ||
| 1574 | err = atc_hw_resume(atc); | ||
| 1575 | if (err < 0) { | ||
| 1576 | printk(KERN_ERR "ctxfi: pci_enable_device failed, " | ||
| 1577 | "disabling device\n"); | ||
| 1578 | snd_card_disconnect(atc->card); | ||
| 1579 | return err; | ||
| 1580 | } | ||
| 1581 | |||
| 1582 | err = atc_resources_resume(atc); | ||
| 1583 | if (err < 0) | ||
| 1584 | return err; | ||
| 1585 | |||
| 1586 | snd_power_change_state(atc->card, SNDRV_CTL_POWER_D0); | ||
| 1587 | |||
| 1588 | return 0; | ||
| 1589 | } | ||
| 1590 | #endif | ||
| 1591 | |||
| 1504 | static struct ct_atc atc_preset __devinitdata = { | 1592 | static struct ct_atc atc_preset __devinitdata = { |
| 1505 | .map_audio_buffer = ct_map_audio_buffer, | 1593 | .map_audio_buffer = ct_map_audio_buffer, |
| 1506 | .unmap_audio_buffer = ct_unmap_audio_buffer, | 1594 | .unmap_audio_buffer = ct_unmap_audio_buffer, |
| @@ -1529,6 +1617,10 @@ static struct ct_atc atc_preset __devinitdata = { | |||
| 1529 | .spdif_out_set_status = atc_spdif_out_set_status, | 1617 | .spdif_out_set_status = atc_spdif_out_set_status, |
| 1530 | .spdif_out_passthru = atc_spdif_out_passthru, | 1618 | .spdif_out_passthru = atc_spdif_out_passthru, |
| 1531 | .have_digit_io_switch = atc_have_digit_io_switch, | 1619 | .have_digit_io_switch = atc_have_digit_io_switch, |
| 1620 | #ifdef CONFIG_PM | ||
| 1621 | .suspend = atc_suspend, | ||
| 1622 | .resume = atc_resume, | ||
| 1623 | #endif | ||
| 1532 | }; | 1624 | }; |
| 1533 | 1625 | ||
| 1534 | /** | 1626 | /** |
| @@ -1587,6 +1679,12 @@ int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | |||
| 1587 | if (err < 0) | 1679 | if (err < 0) |
| 1588 | goto error1; | 1680 | goto error1; |
| 1589 | 1681 | ||
| 1682 | err = ct_mixer_create(atc, (struct ct_mixer **)&atc->mixer); | ||
| 1683 | if (err) { | ||
| 1684 | printk(KERN_ERR "ctxfi: Failed to create mixer obj!!!\n"); | ||
| 1685 | goto error1; | ||
| 1686 | } | ||
| 1687 | |||
| 1590 | /* Get resources */ | 1688 | /* Get resources */ |
| 1591 | err = atc_get_resources(atc); | 1689 | err = atc_get_resources(atc); |
| 1592 | if (err < 0) | 1690 | if (err < 0) |
diff --git a/sound/pci/ctxfi/ctatc.h b/sound/pci/ctxfi/ctatc.h index 9fe620ea5f3f..9fd8a5708943 100644 --- a/sound/pci/ctxfi/ctatc.h +++ b/sound/pci/ctxfi/ctatc.h | |||
| @@ -136,6 +136,13 @@ struct ct_atc { | |||
| 136 | unsigned char n_pcm; | 136 | unsigned char n_pcm; |
| 137 | 137 | ||
| 138 | struct ct_timer *timer; | 138 | struct ct_timer *timer; |
| 139 | |||
| 140 | #ifdef CONFIG_PM | ||
| 141 | int (*suspend)(struct ct_atc *atc, pm_message_t state); | ||
| 142 | int (*resume)(struct ct_atc *atc); | ||
| 143 | #define NUM_PCMS (NUM_CTALSADEVS - 1) | ||
| 144 | struct snd_pcm *pcms[NUM_PCMS]; | ||
| 145 | #endif | ||
| 139 | }; | 146 | }; |
| 140 | 147 | ||
| 141 | 148 | ||
diff --git a/sound/pci/ctxfi/cthardware.h b/sound/pci/ctxfi/cthardware.h index 4a8e04f090a4..af55405f5dec 100644 --- a/sound/pci/ctxfi/cthardware.h +++ b/sound/pci/ctxfi/cthardware.h | |||
| @@ -30,13 +30,16 @@ enum CHIPTYP { | |||
| 30 | enum CTCARDS { | 30 | enum CTCARDS { |
| 31 | /* 20k1 models */ | 31 | /* 20k1 models */ |
| 32 | CTSB055X, | 32 | CTSB055X, |
| 33 | CT20K1_MODEL_FIRST = CTSB055X, | ||
| 33 | CTSB073X, | 34 | CTSB073X, |
| 34 | CTUAA, | 35 | CTUAA, |
| 35 | CT20K1_UNKNOWN, | 36 | CT20K1_UNKNOWN, |
| 36 | /* 20k2 models */ | 37 | /* 20k2 models */ |
| 37 | CTSB0760, | 38 | CTSB0760, |
| 39 | CT20K2_MODEL_FIRST = CTSB0760, | ||
| 38 | CTHENDRIX, | 40 | CTHENDRIX, |
| 39 | CTSB0880, | 41 | CTSB0880, |
| 42 | CT20K2_UNKNOWN, | ||
| 40 | NUM_CTCARDS /* This should always be the last */ | 43 | NUM_CTCARDS /* This should always be the last */ |
| 41 | }; | 44 | }; |
| 42 | 45 | ||
| @@ -61,6 +64,10 @@ struct hw { | |||
| 61 | int (*card_init)(struct hw *hw, struct card_conf *info); | 64 | int (*card_init)(struct hw *hw, struct card_conf *info); |
| 62 | int (*card_stop)(struct hw *hw); | 65 | int (*card_stop)(struct hw *hw); |
| 63 | int (*pll_init)(struct hw *hw, unsigned int rsr); | 66 | int (*pll_init)(struct hw *hw, unsigned int rsr); |
| 67 | #ifdef CONFIG_PM | ||
| 68 | int (*suspend)(struct hw *hw, pm_message_t state); | ||
| 69 | int (*resume)(struct hw *hw, struct card_conf *info); | ||
| 70 | #endif | ||
| 64 | int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source); | 71 | int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source); |
| 65 | int (*select_adc_source)(struct hw *hw, enum ADCSRC source); | 72 | int (*select_adc_source)(struct hw *hw, enum ADCSRC source); |
| 66 | int (*have_digit_io_switch)(struct hw *hw); | 73 | int (*have_digit_io_switch)(struct hw *hw); |
diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c index cb69d9ddfbe3..ad3e1d144464 100644 --- a/sound/pci/ctxfi/cthw20k1.c +++ b/sound/pci/ctxfi/cthw20k1.c | |||
| @@ -1911,9 +1911,17 @@ static int hw_card_start(struct hw *hw) | |||
| 1911 | goto error1; | 1911 | goto error1; |
| 1912 | } | 1912 | } |
| 1913 | 1913 | ||
| 1914 | err = pci_request_regions(pci, "XFi"); | 1914 | if (!hw->io_base) { |
| 1915 | if (err < 0) | 1915 | err = pci_request_regions(pci, "XFi"); |
| 1916 | goto error1; | 1916 | if (err < 0) |
| 1917 | goto error1; | ||
| 1918 | |||
| 1919 | if (hw->model == CTUAA) | ||
| 1920 | hw->io_base = pci_resource_start(pci, 5); | ||
| 1921 | else | ||
| 1922 | hw->io_base = pci_resource_start(pci, 0); | ||
| 1923 | |||
| 1924 | } | ||
| 1917 | 1925 | ||
| 1918 | /* Switch to X-Fi mode from UAA mode if neeeded */ | 1926 | /* Switch to X-Fi mode from UAA mode if neeeded */ |
| 1919 | if (hw->model == CTUAA) { | 1927 | if (hw->model == CTUAA) { |
| @@ -1921,18 +1929,17 @@ static int hw_card_start(struct hw *hw) | |||
| 1921 | if (err) | 1929 | if (err) |
| 1922 | goto error2; | 1930 | goto error2; |
| 1923 | 1931 | ||
| 1924 | hw->io_base = pci_resource_start(pci, 5); | ||
| 1925 | } else { | ||
| 1926 | hw->io_base = pci_resource_start(pci, 0); | ||
| 1927 | } | 1932 | } |
| 1928 | 1933 | ||
| 1929 | err = request_irq(pci->irq, ct_20k1_interrupt, IRQF_SHARED, | 1934 | if (hw->irq < 0) { |
| 1930 | "ctxfi", hw); | 1935 | err = request_irq(pci->irq, ct_20k1_interrupt, IRQF_SHARED, |
| 1931 | if (err < 0) { | 1936 | "ctxfi", hw); |
| 1932 | printk(KERN_ERR "XFi: Cannot get irq %d\n", pci->irq); | 1937 | if (err < 0) { |
| 1933 | goto error2; | 1938 | printk(KERN_ERR "XFi: Cannot get irq %d\n", pci->irq); |
| 1939 | goto error2; | ||
| 1940 | } | ||
| 1941 | hw->irq = pci->irq; | ||
| 1934 | } | 1942 | } |
| 1935 | hw->irq = pci->irq; | ||
| 1936 | 1943 | ||
| 1937 | pci_set_master(pci); | 1944 | pci_set_master(pci); |
| 1938 | 1945 | ||
| @@ -1948,6 +1955,15 @@ error1: | |||
| 1948 | 1955 | ||
| 1949 | static int hw_card_stop(struct hw *hw) | 1956 | static int hw_card_stop(struct hw *hw) |
| 1950 | { | 1957 | { |
| 1958 | unsigned int data; | ||
| 1959 | |||
| 1960 | /* disable transport bus master and queueing of request */ | ||
| 1961 | hw_write_20kx(hw, TRNCTL, 0x00); | ||
| 1962 | |||
| 1963 | /* disable pll */ | ||
| 1964 | data = hw_read_20kx(hw, PLLCTL); | ||
| 1965 | hw_write_20kx(hw, PLLCTL, (data & (~(0x0F<<12)))); | ||
| 1966 | |||
| 1951 | /* TODO: Disable interrupt and so on... */ | 1967 | /* TODO: Disable interrupt and so on... */ |
| 1952 | if (hw->irq >= 0) | 1968 | if (hw->irq >= 0) |
| 1953 | synchronize_irq(hw->irq); | 1969 | synchronize_irq(hw->irq); |
| @@ -1987,11 +2003,9 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) | |||
| 1987 | struct trn_conf trn_info = {0}; | 2003 | struct trn_conf trn_info = {0}; |
| 1988 | 2004 | ||
| 1989 | /* Get PCI io port base address and do Hendrix switch if needed. */ | 2005 | /* Get PCI io port base address and do Hendrix switch if needed. */ |
| 1990 | if (!hw->io_base) { | 2006 | err = hw_card_start(hw); |
| 1991 | err = hw_card_start(hw); | 2007 | if (err) |
| 1992 | if (err) | 2008 | return err; |
| 1993 | return err; | ||
| 1994 | } | ||
| 1995 | 2009 | ||
| 1996 | /* PLL init */ | 2010 | /* PLL init */ |
| 1997 | err = hw_pll_init(hw, info->rsr); | 2011 | err = hw_pll_init(hw, info->rsr); |
| @@ -2064,6 +2078,37 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) | |||
| 2064 | return 0; | 2078 | return 0; |
| 2065 | } | 2079 | } |
| 2066 | 2080 | ||
| 2081 | #ifdef CONFIG_PM | ||
| 2082 | static int hw_suspend(struct hw *hw, pm_message_t state) | ||
| 2083 | { | ||
| 2084 | struct pci_dev *pci = hw->pci; | ||
| 2085 | |||
| 2086 | hw_card_stop(hw); | ||
| 2087 | |||
| 2088 | if (hw->model == CTUAA) { | ||
| 2089 | /* Switch to UAA config space. */ | ||
| 2090 | pci_write_config_dword(pci, UAA_CFG_SPACE_FLAG, 0x0); | ||
| 2091 | } | ||
| 2092 | |||
| 2093 | pci_disable_device(pci); | ||
| 2094 | pci_save_state(pci); | ||
| 2095 | pci_set_power_state(pci, pci_choose_state(pci, state)); | ||
| 2096 | |||
| 2097 | return 0; | ||
| 2098 | } | ||
| 2099 | |||
| 2100 | static int hw_resume(struct hw *hw, struct card_conf *info) | ||
| 2101 | { | ||
| 2102 | struct pci_dev *pci = hw->pci; | ||
| 2103 | |||
| 2104 | pci_set_power_state(pci, PCI_D0); | ||
| 2105 | pci_restore_state(pci); | ||
| 2106 | |||
| 2107 | /* Re-initialize card hardware. */ | ||
| 2108 | return hw_card_init(hw, info); | ||
| 2109 | } | ||
| 2110 | #endif | ||
| 2111 | |||
| 2067 | static u32 hw_read_20kx(struct hw *hw, u32 reg) | 2112 | static u32 hw_read_20kx(struct hw *hw, u32 reg) |
| 2068 | { | 2113 | { |
| 2069 | u32 value; | 2114 | u32 value; |
| @@ -2128,6 +2173,10 @@ static struct hw ct20k1_preset __devinitdata = { | |||
| 2128 | .is_adc_source_selected = hw_is_adc_input_selected, | 2173 | .is_adc_source_selected = hw_is_adc_input_selected, |
| 2129 | .select_adc_source = hw_adc_input_select, | 2174 | .select_adc_source = hw_adc_input_select, |
| 2130 | .have_digit_io_switch = hw_have_digit_io_switch, | 2175 | .have_digit_io_switch = hw_have_digit_io_switch, |
| 2176 | #ifdef CONFIG_PM | ||
| 2177 | .suspend = hw_suspend, | ||
| 2178 | .resume = hw_resume, | ||
| 2179 | #endif | ||
| 2131 | 2180 | ||
| 2132 | .src_rsc_get_ctrl_blk = src_get_rsc_ctrl_blk, | 2181 | .src_rsc_get_ctrl_blk = src_get_rsc_ctrl_blk, |
| 2133 | .src_rsc_put_ctrl_blk = src_put_rsc_ctrl_blk, | 2182 | .src_rsc_put_ctrl_blk = src_put_rsc_ctrl_blk, |
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c index 4493a51c6b01..dec46d04b041 100644 --- a/sound/pci/ctxfi/cthw20k2.c +++ b/sound/pci/ctxfi/cthw20k2.c | |||
| @@ -1860,16 +1860,18 @@ static int hw_card_start(struct hw *hw) | |||
| 1860 | goto error1; | 1860 | goto error1; |
| 1861 | } | 1861 | } |
| 1862 | 1862 | ||
| 1863 | err = pci_request_regions(pci, "XFi"); | 1863 | if (!hw->io_base) { |
| 1864 | if (err < 0) | 1864 | err = pci_request_regions(pci, "XFi"); |
| 1865 | goto error1; | 1865 | if (err < 0) |
| 1866 | goto error1; | ||
| 1866 | 1867 | ||
| 1867 | hw->io_base = pci_resource_start(hw->pci, 2); | 1868 | hw->io_base = pci_resource_start(hw->pci, 2); |
| 1868 | hw->mem_base = (unsigned long)ioremap(hw->io_base, | 1869 | hw->mem_base = (unsigned long)ioremap(hw->io_base, |
| 1869 | pci_resource_len(hw->pci, 2)); | 1870 | pci_resource_len(hw->pci, 2)); |
| 1870 | if (NULL == (void *)hw->mem_base) { | 1871 | if (NULL == (void *)hw->mem_base) { |
| 1871 | err = -ENOENT; | 1872 | err = -ENOENT; |
| 1872 | goto error2; | 1873 | goto error2; |
| 1874 | } | ||
| 1873 | } | 1875 | } |
| 1874 | 1876 | ||
| 1875 | /* Switch to 20k2 mode from UAA mode. */ | 1877 | /* Switch to 20k2 mode from UAA mode. */ |
| @@ -1901,6 +1903,15 @@ error1: | |||
| 1901 | 1903 | ||
| 1902 | static int hw_card_stop(struct hw *hw) | 1904 | static int hw_card_stop(struct hw *hw) |
| 1903 | { | 1905 | { |
| 1906 | unsigned int data; | ||
| 1907 | |||
| 1908 | /* disable transport bus master and queueing of request */ | ||
| 1909 | hw_write_20kx(hw, TRANSPORT_CTL, 0x00); | ||
| 1910 | |||
| 1911 | /* disable pll */ | ||
| 1912 | data = hw_read_20kx(hw, PLL_ENB); | ||
| 1913 | hw_write_20kx(hw, PLL_ENB, (data & (~0x07))); | ||
| 1914 | |||
| 1904 | /* TODO: Disable interrupt and so on... */ | 1915 | /* TODO: Disable interrupt and so on... */ |
| 1905 | return 0; | 1916 | return 0; |
| 1906 | } | 1917 | } |
| @@ -1939,11 +1950,9 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) | |||
| 1939 | 1950 | ||
| 1940 | /* Get PCI io port/memory base address and | 1951 | /* Get PCI io port/memory base address and |
| 1941 | * do 20kx core switch if needed. */ | 1952 | * do 20kx core switch if needed. */ |
| 1942 | if (!hw->io_base) { | 1953 | err = hw_card_start(hw); |
| 1943 | err = hw_card_start(hw); | 1954 | if (err) |
| 1944 | if (err) | 1955 | return err; |
| 1945 | return err; | ||
| 1946 | } | ||
| 1947 | 1956 | ||
| 1948 | /* PLL init */ | 1957 | /* PLL init */ |
| 1949 | err = hw_pll_init(hw, info->rsr); | 1958 | err = hw_pll_init(hw, info->rsr); |
| @@ -2006,6 +2015,32 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) | |||
| 2006 | return 0; | 2015 | return 0; |
| 2007 | } | 2016 | } |
| 2008 | 2017 | ||
| 2018 | #ifdef CONFIG_PM | ||
| 2019 | static int hw_suspend(struct hw *hw, pm_message_t state) | ||
| 2020 | { | ||
| 2021 | struct pci_dev *pci = hw->pci; | ||
| 2022 | |||
| 2023 | hw_card_stop(hw); | ||
| 2024 | |||
| 2025 | pci_disable_device(pci); | ||
| 2026 | pci_save_state(pci); | ||
| 2027 | pci_set_power_state(pci, pci_choose_state(pci, state)); | ||
| 2028 | |||
| 2029 | return 0; | ||
| 2030 | } | ||
| 2031 | |||
| 2032 | static int hw_resume(struct hw *hw, struct card_conf *info) | ||
| 2033 | { | ||
| 2034 | struct pci_dev *pci = hw->pci; | ||
| 2035 | |||
| 2036 | pci_set_power_state(pci, PCI_D0); | ||
| 2037 | pci_restore_state(pci); | ||
| 2038 | |||
| 2039 | /* Re-initialize card hardware. */ | ||
| 2040 | return hw_card_init(hw, info); | ||
| 2041 | } | ||
| 2042 | #endif | ||
| 2043 | |||
| 2009 | static u32 hw_read_20kx(struct hw *hw, u32 reg) | 2044 | static u32 hw_read_20kx(struct hw *hw, u32 reg) |
| 2010 | { | 2045 | { |
| 2011 | return readl((void *)(hw->mem_base + reg)); | 2046 | return readl((void *)(hw->mem_base + reg)); |
| @@ -2025,6 +2060,10 @@ static struct hw ct20k2_preset __devinitdata = { | |||
| 2025 | .is_adc_source_selected = hw_is_adc_input_selected, | 2060 | .is_adc_source_selected = hw_is_adc_input_selected, |
| 2026 | .select_adc_source = hw_adc_input_select, | 2061 | .select_adc_source = hw_adc_input_select, |
| 2027 | .have_digit_io_switch = hw_have_digit_io_switch, | 2062 | .have_digit_io_switch = hw_have_digit_io_switch, |
| 2063 | #ifdef CONFIG_PM | ||
| 2064 | .suspend = hw_suspend, | ||
| 2065 | .resume = hw_resume, | ||
| 2066 | #endif | ||
| 2028 | 2067 | ||
| 2029 | .src_rsc_get_ctrl_blk = src_get_rsc_ctrl_blk, | 2068 | .src_rsc_get_ctrl_blk = src_get_rsc_ctrl_blk, |
| 2030 | .src_rsc_put_ctrl_blk = src_put_rsc_ctrl_blk, | 2069 | .src_rsc_put_ctrl_blk = src_put_rsc_ctrl_blk, |
diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c index 666722d9de41..f26d7cd9db9f 100644 --- a/sound/pci/ctxfi/ctmixer.c +++ b/sound/pci/ctxfi/ctmixer.c | |||
| @@ -462,6 +462,43 @@ do_digit_io_switch(struct ct_atc *atc, int state) | |||
| 462 | return; | 462 | return; |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | static void do_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type, int state) | ||
| 466 | { | ||
| 467 | struct ct_mixer *mixer = atc->mixer; | ||
| 468 | |||
| 469 | /* Do changes in mixer. */ | ||
| 470 | if ((SWH_CAPTURE_START <= type) && (SWH_CAPTURE_END >= type)) { | ||
| 471 | if (state) { | ||
| 472 | ct_mixer_recording_select(mixer, | ||
| 473 | get_amixer_index(type)); | ||
| 474 | } else { | ||
| 475 | ct_mixer_recording_unselect(mixer, | ||
| 476 | get_amixer_index(type)); | ||
| 477 | } | ||
| 478 | } | ||
| 479 | /* Do changes out of mixer. */ | ||
| 480 | if (state && (MIXER_LINEIN_C_S == type || MIXER_MIC_C_S == type)) | ||
| 481 | do_line_mic_switch(atc, type); | ||
| 482 | else if (MIXER_WAVEF_P_S == type) | ||
| 483 | atc->line_front_unmute(atc, state); | ||
| 484 | else if (MIXER_WAVES_P_S == type) | ||
| 485 | atc->line_surround_unmute(atc, state); | ||
| 486 | else if (MIXER_WAVEC_P_S == type) | ||
| 487 | atc->line_clfe_unmute(atc, state); | ||
| 488 | else if (MIXER_WAVER_P_S == type) | ||
| 489 | atc->line_rear_unmute(atc, state); | ||
| 490 | else if (MIXER_LINEIN_P_S == type) | ||
| 491 | atc->line_in_unmute(atc, state); | ||
| 492 | else if (MIXER_SPDIFO_P_S == type) | ||
| 493 | atc->spdif_out_unmute(atc, state); | ||
| 494 | else if (MIXER_SPDIFI_P_S == type) | ||
| 495 | atc->spdif_in_unmute(atc, state); | ||
| 496 | else if (MIXER_DIGITAL_IO_S == type) | ||
| 497 | do_digit_io_switch(atc, state); | ||
| 498 | |||
| 499 | return; | ||
| 500 | } | ||
| 501 | |||
| 465 | static int ct_alsa_mix_switch_info(struct snd_kcontrol *kcontrol, | 502 | static int ct_alsa_mix_switch_info(struct snd_kcontrol *kcontrol, |
| 466 | struct snd_ctl_elem_info *uinfo) | 503 | struct snd_ctl_elem_info *uinfo) |
| 467 | { | 504 | { |
| @@ -498,35 +535,7 @@ static int ct_alsa_mix_switch_put(struct snd_kcontrol *kcontrol, | |||
| 498 | return 0; | 535 | return 0; |
| 499 | 536 | ||
| 500 | set_switch_state(mixer, type, state); | 537 | set_switch_state(mixer, type, state); |
| 501 | /* Do changes in mixer. */ | 538 | do_switch(atc, type, state); |
| 502 | if ((SWH_CAPTURE_START <= type) && (SWH_CAPTURE_END >= type)) { | ||
| 503 | if (state) { | ||
| 504 | ct_mixer_recording_select(mixer, | ||
| 505 | get_amixer_index(type)); | ||
| 506 | } else { | ||
| 507 | ct_mixer_recording_unselect(mixer, | ||
| 508 | get_amixer_index(type)); | ||
| 509 | } | ||
| 510 | } | ||
| 511 | /* Do changes out of mixer. */ | ||
| 512 | if (state && (MIXER_LINEIN_C_S == type || MIXER_MIC_C_S == type)) | ||
| 513 | do_line_mic_switch(atc, type); | ||
| 514 | else if (MIXER_WAVEF_P_S == type) | ||
| 515 | atc->line_front_unmute(atc, state); | ||
| 516 | else if (MIXER_WAVES_P_S == type) | ||
| 517 | atc->line_surround_unmute(atc, state); | ||
| 518 | else if (MIXER_WAVEC_P_S == type) | ||
| 519 | atc->line_clfe_unmute(atc, state); | ||
| 520 | else if (MIXER_WAVER_P_S == type) | ||
| 521 | atc->line_rear_unmute(atc, state); | ||
| 522 | else if (MIXER_LINEIN_P_S == type) | ||
| 523 | atc->line_in_unmute(atc, state); | ||
| 524 | else if (MIXER_SPDIFO_P_S == type) | ||
| 525 | atc->spdif_out_unmute(atc, state); | ||
| 526 | else if (MIXER_SPDIFI_P_S == type) | ||
| 527 | atc->spdif_in_unmute(atc, state); | ||
| 528 | else if (MIXER_DIGITAL_IO_S == type) | ||
| 529 | do_digit_io_switch(atc, state); | ||
| 530 | 539 | ||
| 531 | return 1; | 540 | return 1; |
| 532 | } | 541 | } |
| @@ -1039,6 +1048,28 @@ mixer_set_input_right(struct ct_mixer *mixer, | |||
| 1039 | return 0; | 1048 | return 0; |
| 1040 | } | 1049 | } |
| 1041 | 1050 | ||
| 1051 | #ifdef CONFIG_PM | ||
| 1052 | static int mixer_resume(struct ct_mixer *mixer) | ||
| 1053 | { | ||
| 1054 | int i, state; | ||
| 1055 | struct amixer *amixer; | ||
| 1056 | |||
| 1057 | /* resume topology and volume gain. */ | ||
| 1058 | for (i = 0; i < NUM_CT_AMIXERS*CHN_NUM; i++) { | ||
| 1059 | amixer = mixer->amixers[i]; | ||
| 1060 | amixer->ops->commit_write(amixer); | ||
| 1061 | } | ||
| 1062 | |||
| 1063 | /* resume switch state. */ | ||
| 1064 | for (i = SWH_MIXER_START; i <= SWH_MIXER_END; i++) { | ||
| 1065 | state = get_switch_state(mixer, i); | ||
| 1066 | do_switch(mixer->atc, i, state); | ||
| 1067 | } | ||
| 1068 | |||
| 1069 | return 0; | ||
| 1070 | } | ||
| 1071 | #endif | ||
| 1072 | |||
| 1042 | int ct_mixer_destroy(struct ct_mixer *mixer) | 1073 | int ct_mixer_destroy(struct ct_mixer *mixer) |
| 1043 | { | 1074 | { |
| 1044 | struct sum_mgr *sum_mgr = (struct sum_mgr *)mixer->atc->rsc_mgrs[SUM]; | 1075 | struct sum_mgr *sum_mgr = (struct sum_mgr *)mixer->atc->rsc_mgrs[SUM]; |
| @@ -1087,6 +1118,9 @@ int ct_mixer_create(struct ct_atc *atc, struct ct_mixer **rmixer) | |||
| 1087 | mixer->get_output_ports = mixer_get_output_ports; | 1118 | mixer->get_output_ports = mixer_get_output_ports; |
| 1088 | mixer->set_input_left = mixer_set_input_left; | 1119 | mixer->set_input_left = mixer_set_input_left; |
| 1089 | mixer->set_input_right = mixer_set_input_right; | 1120 | mixer->set_input_right = mixer_set_input_right; |
| 1121 | #ifdef CONFIG_PM | ||
| 1122 | mixer->resume = mixer_resume; | ||
| 1123 | #endif | ||
| 1090 | 1124 | ||
| 1091 | /* Allocate chip resources for mixer obj */ | 1125 | /* Allocate chip resources for mixer obj */ |
| 1092 | err = ct_mixer_get_resources(mixer); | 1126 | err = ct_mixer_get_resources(mixer); |
diff --git a/sound/pci/ctxfi/ctmixer.h b/sound/pci/ctxfi/ctmixer.h index e2d96ebde746..b009e989e77d 100644 --- a/sound/pci/ctxfi/ctmixer.h +++ b/sound/pci/ctxfi/ctmixer.h | |||
| @@ -56,6 +56,9 @@ struct ct_mixer { | |||
| 56 | enum MIXER_PORT_T type, struct rsc *rsc); | 56 | enum MIXER_PORT_T type, struct rsc *rsc); |
| 57 | int (*set_input_right)(struct ct_mixer *mixer, | 57 | int (*set_input_right)(struct ct_mixer *mixer, |
| 58 | enum MIXER_PORT_T type, struct rsc *rsc); | 58 | enum MIXER_PORT_T type, struct rsc *rsc); |
| 59 | #ifdef CONFIG_PM | ||
| 60 | int (*resume)(struct ct_mixer *mixer); | ||
| 61 | #endif | ||
| 59 | }; | 62 | }; |
| 60 | 63 | ||
| 61 | int ct_alsa_mix_create(struct ct_atc *atc, | 64 | int ct_alsa_mix_create(struct ct_atc *atc, |
diff --git a/sound/pci/ctxfi/ctpcm.c b/sound/pci/ctxfi/ctpcm.c index 9e5c0c4da726..60ea23180acb 100644 --- a/sound/pci/ctxfi/ctpcm.c +++ b/sound/pci/ctxfi/ctpcm.c | |||
| @@ -422,5 +422,9 @@ int ct_alsa_pcm_create(struct ct_atc *atc, | |||
| 422 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, | 422 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, |
| 423 | snd_dma_pci_data(atc->pci), 128*1024, 128*1024); | 423 | snd_dma_pci_data(atc->pci), 128*1024, 128*1024); |
| 424 | 424 | ||
| 425 | #ifdef CONFIG_PM | ||
| 426 | atc->pcms[device] = pcm; | ||
| 427 | #endif | ||
| 428 | |||
| 425 | return 0; | 429 | return 0; |
| 426 | } | 430 | } |
diff --git a/sound/pci/ctxfi/xfi.c b/sound/pci/ctxfi/xfi.c index 2d3dd89af151..76541748e7bc 100644 --- a/sound/pci/ctxfi/xfi.c +++ b/sound/pci/ctxfi/xfi.c | |||
| @@ -121,11 +121,33 @@ static void __devexit ct_card_remove(struct pci_dev *pci) | |||
| 121 | pci_set_drvdata(pci, NULL); | 121 | pci_set_drvdata(pci, NULL); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #ifdef CONFIG_PM | ||
| 125 | static int ct_card_suspend(struct pci_dev *pci, pm_message_t state) | ||
| 126 | { | ||
| 127 | struct snd_card *card = pci_get_drvdata(pci); | ||
| 128 | struct ct_atc *atc = card->private_data; | ||
| 129 | |||
| 130 | return atc->suspend(atc, state); | ||
| 131 | } | ||
| 132 | |||
| 133 | static int ct_card_resume(struct pci_dev *pci) | ||
| 134 | { | ||
| 135 | struct snd_card *card = pci_get_drvdata(pci); | ||
| 136 | struct ct_atc *atc = card->private_data; | ||
| 137 | |||
| 138 | return atc->resume(atc); | ||
| 139 | } | ||
| 140 | #endif | ||
| 141 | |||
| 124 | static struct pci_driver ct_driver = { | 142 | static struct pci_driver ct_driver = { |
| 125 | .name = "SB-XFi", | 143 | .name = "SB-XFi", |
| 126 | .id_table = ct_pci_dev_ids, | 144 | .id_table = ct_pci_dev_ids, |
| 127 | .probe = ct_card_probe, | 145 | .probe = ct_card_probe, |
| 128 | .remove = __devexit_p(ct_card_remove), | 146 | .remove = __devexit_p(ct_card_remove), |
| 147 | #ifdef CONFIG_PM | ||
| 148 | .suspend = ct_card_suspend, | ||
| 149 | .resume = ct_card_resume, | ||
| 150 | #endif | ||
| 129 | }; | 151 | }; |
| 130 | 152 | ||
| 131 | static int __init ct_card_init(void) | 153 | static int __init ct_card_init(void) |
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index c710150d5065..04438f1d682d 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig | |||
| @@ -2,7 +2,6 @@ menuconfig SND_HDA_INTEL | |||
| 2 | tristate "Intel HD Audio" | 2 | tristate "Intel HD Audio" |
| 3 | select SND_PCM | 3 | select SND_PCM |
| 4 | select SND_VMASTER | 4 | select SND_VMASTER |
| 5 | select SND_JACK if INPUT=y || INPUT=SND | ||
| 6 | help | 5 | help |
| 7 | Say Y here to include support for Intel "High Definition | 6 | Say Y here to include support for Intel "High Definition |
| 8 | Audio" (Azalia) and its compatible devices. | 7 | Audio" (Azalia) and its compatible devices. |
| @@ -39,6 +38,14 @@ config SND_HDA_INPUT_BEEP | |||
| 39 | Say Y here to build a digital beep interface for HD-audio | 38 | Say Y here to build a digital beep interface for HD-audio |
| 40 | driver. This interface is used to generate digital beeps. | 39 | driver. This interface is used to generate digital beeps. |
| 41 | 40 | ||
| 41 | config SND_HDA_INPUT_JACK | ||
| 42 | bool "Support jack plugging notification via input layer" | ||
| 43 | depends on INPUT=y || INPUT=SND_HDA_INTEL | ||
| 44 | select SND_JACK | ||
| 45 | help | ||
| 46 | Say Y here to enable the jack plugging notification via | ||
| 47 | input layer. | ||
| 48 | |||
| 42 | config SND_HDA_CODEC_REALTEK | 49 | config SND_HDA_CODEC_REALTEK |
| 43 | bool "Build Realtek HD-audio codec support" | 50 | bool "Build Realtek HD-audio codec support" |
| 44 | default y | 51 | default y |
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 4fcbe21829ab..ac868c59f9e3 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
| @@ -349,7 +349,7 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
| 349 | &spec->cur_mux[adc_idx]); | 349 | &spec->cur_mux[adc_idx]); |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | #ifdef CONFIG_SND_JACK | 352 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
| 353 | static void conexant_free_jack_priv(struct snd_jack *jack) | 353 | static void conexant_free_jack_priv(struct snd_jack *jack) |
| 354 | { | 354 | { |
| 355 | struct conexant_jack *jacks = jack->private_data; | 355 | struct conexant_jack *jacks = jack->private_data; |
| @@ -463,7 +463,7 @@ static int conexant_init(struct hda_codec *codec) | |||
| 463 | 463 | ||
| 464 | static void conexant_free(struct hda_codec *codec) | 464 | static void conexant_free(struct hda_codec *codec) |
| 465 | { | 465 | { |
| 466 | #ifdef CONFIG_SND_JACK | 466 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
| 467 | struct conexant_spec *spec = codec->spec; | 467 | struct conexant_spec *spec = codec->spec; |
| 468 | if (spec->jacks.list) { | 468 | if (spec->jacks.list) { |
| 469 | struct conexant_jack *jacks = spec->jacks.list; | 469 | struct conexant_jack *jacks = spec->jacks.list; |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index bf4b78a74a8f..334533197425 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
| @@ -250,13 +250,6 @@ enum { | |||
| 250 | ALC883_MODEL_LAST, | 250 | ALC883_MODEL_LAST, |
| 251 | }; | 251 | }; |
| 252 | 252 | ||
| 253 | /* styles of capture selection */ | ||
| 254 | enum { | ||
| 255 | CAPT_MUX = 0, /* only mux based */ | ||
| 256 | CAPT_MIX, /* only mixer based */ | ||
| 257 | CAPT_1MUX_MIX, /* first mux and other mixers */ | ||
| 258 | }; | ||
| 259 | |||
| 260 | /* for GPIO Poll */ | 253 | /* for GPIO Poll */ |
| 261 | #define GPIO_MASK 0x03 | 254 | #define GPIO_MASK 0x03 |
| 262 | 255 | ||
| @@ -306,7 +299,6 @@ struct alc_spec { | |||
| 306 | hda_nid_t *adc_nids; | 299 | hda_nid_t *adc_nids; |
| 307 | hda_nid_t *capsrc_nids; | 300 | hda_nid_t *capsrc_nids; |
| 308 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ | 301 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
| 309 | int capture_style; /* capture style (CAPT_*) */ | ||
| 310 | 302 | ||
| 311 | /* capture source */ | 303 | /* capture source */ |
| 312 | unsigned int num_mux_defs; | 304 | unsigned int num_mux_defs; |
| @@ -420,12 +412,13 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
| 420 | unsigned int mux_idx; | 412 | unsigned int mux_idx; |
| 421 | hda_nid_t nid = spec->capsrc_nids ? | 413 | hda_nid_t nid = spec->capsrc_nids ? |
| 422 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; | 414 | spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx]; |
| 415 | unsigned int type; | ||
| 423 | 416 | ||
| 424 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; | 417 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 425 | imux = &spec->input_mux[mux_idx]; | 418 | imux = &spec->input_mux[mux_idx]; |
| 426 | 419 | ||
| 427 | if (spec->capture_style && | 420 | type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
| 428 | !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) { | 421 | if (type == AC_WID_AUD_MIX) { |
| 429 | /* Matrix-mixer style (e.g. ALC882) */ | 422 | /* Matrix-mixer style (e.g. ALC882) */ |
| 430 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; | 423 | unsigned int *cur_val = &spec->cur_mux[adc_idx]; |
| 431 | unsigned int i, idx; | 424 | unsigned int i, idx; |
| @@ -7557,7 +7550,6 @@ static int patch_alc882(struct hda_codec *codec) | |||
| 7557 | spec->stream_digital_playback = &alc882_pcm_digital_playback; | 7550 | spec->stream_digital_playback = &alc882_pcm_digital_playback; |
| 7558 | spec->stream_digital_capture = &alc882_pcm_digital_capture; | 7551 | spec->stream_digital_capture = &alc882_pcm_digital_capture; |
| 7559 | 7552 | ||
| 7560 | spec->capture_style = CAPT_MIX; /* matrix-style capture */ | ||
| 7561 | if (!spec->adc_nids && spec->input_mux) { | 7553 | if (!spec->adc_nids && spec->input_mux) { |
| 7562 | /* check whether NID 0x07 is valid */ | 7554 | /* check whether NID 0x07 is valid */ |
| 7563 | unsigned int wcap = get_wcaps(codec, 0x07); | 7555 | unsigned int wcap = get_wcaps(codec, 0x07); |
| @@ -9781,7 +9773,6 @@ static int patch_alc883(struct hda_codec *codec) | |||
| 9781 | } | 9773 | } |
| 9782 | if (!spec->capsrc_nids) | 9774 | if (!spec->capsrc_nids) |
| 9783 | spec->capsrc_nids = alc883_capsrc_nids; | 9775 | spec->capsrc_nids = alc883_capsrc_nids; |
| 9784 | spec->capture_style = CAPT_MIX; /* matrix-style capture */ | ||
| 9785 | spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ | 9776 | spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */ |
| 9786 | break; | 9777 | break; |
| 9787 | case 0x10ec0889: | 9778 | case 0x10ec0889: |
| @@ -9791,8 +9782,6 @@ static int patch_alc883(struct hda_codec *codec) | |||
| 9791 | } | 9782 | } |
| 9792 | if (!spec->capsrc_nids) | 9783 | if (!spec->capsrc_nids) |
| 9793 | spec->capsrc_nids = alc889_capsrc_nids; | 9784 | spec->capsrc_nids = alc889_capsrc_nids; |
| 9794 | spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style | ||
| 9795 | capture */ | ||
| 9796 | break; | 9785 | break; |
| 9797 | default: | 9786 | default: |
| 9798 | if (!spec->num_adc_nids) { | 9787 | if (!spec->num_adc_nids) { |
| @@ -9801,7 +9790,6 @@ static int patch_alc883(struct hda_codec *codec) | |||
| 9801 | } | 9790 | } |
| 9802 | if (!spec->capsrc_nids) | 9791 | if (!spec->capsrc_nids) |
| 9803 | spec->capsrc_nids = alc883_capsrc_nids; | 9792 | spec->capsrc_nids = alc883_capsrc_nids; |
| 9804 | spec->capture_style = CAPT_MIX; /* matrix-style capture */ | ||
| 9805 | break; | 9793 | break; |
| 9806 | } | 9794 | } |
| 9807 | 9795 | ||
| @@ -10913,9 +10901,27 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
| 10913 | return 0; | 10901 | return 0; |
| 10914 | } | 10902 | } |
| 10915 | 10903 | ||
| 10916 | /* identical with ALC880 */ | 10904 | static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec, |
| 10917 | #define alc262_auto_create_analog_input_ctls \ | 10905 | const struct auto_pin_cfg *cfg) |
| 10918 | alc880_auto_create_analog_input_ctls | 10906 | { |
| 10907 | int err; | ||
| 10908 | |||
| 10909 | err = alc880_auto_create_analog_input_ctls(spec, cfg); | ||
| 10910 | if (err < 0) | ||
| 10911 | return err; | ||
| 10912 | /* digital-mic input pin is excluded in alc880_auto_create..() | ||
| 10913 | * because it's under 0x18 | ||
| 10914 | */ | ||
| 10915 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | ||
| 10916 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | ||
| 10917 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
| 10918 | imux->items[imux->num_items].label = "Int Mic"; | ||
| 10919 | imux->items[imux->num_items].index = 0x09; | ||
| 10920 | imux->num_items++; | ||
| 10921 | } | ||
| 10922 | return 0; | ||
| 10923 | } | ||
| 10924 | |||
| 10919 | 10925 | ||
| 10920 | /* | 10926 | /* |
| 10921 | * generic initialization of ADC, input mixers and output mixers | 10927 | * generic initialization of ADC, input mixers and output mixers |
| @@ -11332,6 +11338,7 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = { | |||
| 11332 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), | 11338 | SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), |
| 11333 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), | 11339 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
| 11334 | SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */ | 11340 | SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */ |
| 11341 | SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06), | ||
| 11335 | SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO", | 11342 | SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO", |
| 11336 | ALC262_SONY_ASSAMD), | 11343 | ALC262_SONY_ASSAMD), |
| 11337 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", | 11344 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
| @@ -11539,6 +11546,7 @@ static struct alc_config_preset alc262_presets[] = { | |||
| 11539 | .capsrc_nids = alc262_dmic_capsrc_nids, | 11546 | .capsrc_nids = alc262_dmic_capsrc_nids, |
| 11540 | .dac_nids = alc262_dac_nids, | 11547 | .dac_nids = alc262_dac_nids, |
| 11541 | .adc_nids = alc262_dmic_adc_nids, /* ADC0 */ | 11548 | .adc_nids = alc262_dmic_adc_nids, /* ADC0 */ |
| 11549 | .num_adc_nids = 1, /* single ADC */ | ||
| 11542 | .dig_out_nid = ALC262_DIGOUT_NID, | 11550 | .dig_out_nid = ALC262_DIGOUT_NID, |
| 11543 | .num_channel_mode = ARRAY_SIZE(alc262_modes), | 11551 | .num_channel_mode = ARRAY_SIZE(alc262_modes), |
| 11544 | .channel_mode = alc262_modes, | 11552 | .channel_mode = alc262_modes, |
| @@ -11640,21 +11648,36 @@ static int patch_alc262(struct hda_codec *codec) | |||
| 11640 | spec->stream_digital_playback = &alc262_pcm_digital_playback; | 11648 | spec->stream_digital_playback = &alc262_pcm_digital_playback; |
| 11641 | spec->stream_digital_capture = &alc262_pcm_digital_capture; | 11649 | spec->stream_digital_capture = &alc262_pcm_digital_capture; |
| 11642 | 11650 | ||
| 11643 | spec->capture_style = CAPT_MIX; | ||
| 11644 | if (!spec->adc_nids && spec->input_mux) { | 11651 | if (!spec->adc_nids && spec->input_mux) { |
| 11645 | /* check whether NID 0x07 is valid */ | 11652 | int i; |
| 11646 | unsigned int wcap = get_wcaps(codec, 0x07); | 11653 | /* check whether the digital-mic has to be supported */ |
| 11647 | 11654 | for (i = 0; i < spec->input_mux->num_items; i++) { | |
| 11648 | /* get type */ | 11655 | if (spec->input_mux->items[i].index >= 9) |
| 11649 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | 11656 | break; |
| 11650 | if (wcap != AC_WID_AUD_IN) { | 11657 | } |
| 11651 | spec->adc_nids = alc262_adc_nids_alt; | 11658 | if (i < spec->input_mux->num_items) { |
| 11652 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); | 11659 | /* use only ADC0 */ |
| 11653 | spec->capsrc_nids = alc262_capsrc_nids_alt; | 11660 | spec->adc_nids = alc262_dmic_adc_nids; |
| 11661 | spec->num_adc_nids = 1; | ||
| 11662 | spec->capsrc_nids = alc262_dmic_capsrc_nids; | ||
| 11654 | } else { | 11663 | } else { |
| 11655 | spec->adc_nids = alc262_adc_nids; | 11664 | /* all analog inputs */ |
| 11656 | spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); | 11665 | /* check whether NID 0x07 is valid */ |
| 11657 | spec->capsrc_nids = alc262_capsrc_nids; | 11666 | unsigned int wcap = get_wcaps(codec, 0x07); |
| 11667 | |||
| 11668 | /* get type */ | ||
| 11669 | wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
| 11670 | if (wcap != AC_WID_AUD_IN) { | ||
| 11671 | spec->adc_nids = alc262_adc_nids_alt; | ||
| 11672 | spec->num_adc_nids = | ||
| 11673 | ARRAY_SIZE(alc262_adc_nids_alt); | ||
| 11674 | spec->capsrc_nids = alc262_capsrc_nids_alt; | ||
| 11675 | } else { | ||
| 11676 | spec->adc_nids = alc262_adc_nids; | ||
| 11677 | spec->num_adc_nids = | ||
| 11678 | ARRAY_SIZE(alc262_adc_nids); | ||
| 11679 | spec->capsrc_nids = alc262_capsrc_nids; | ||
| 11680 | } | ||
| 11658 | } | 11681 | } |
| 11659 | } | 11682 | } |
| 11660 | if (!spec->cap_mixer && !spec->no_analog) | 11683 | if (!spec->cap_mixer && !spec->no_analog) |
| @@ -13244,26 +13267,8 @@ static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec, | |||
| 13244 | return 0; | 13267 | return 0; |
| 13245 | } | 13268 | } |
| 13246 | 13269 | ||
| 13247 | static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec, | 13270 | #define alc269_auto_create_analog_input_ctls \ |
| 13248 | const struct auto_pin_cfg *cfg) | 13271 | alc262_auto_create_analog_input_ctls |
| 13249 | { | ||
| 13250 | int err; | ||
| 13251 | |||
| 13252 | err = alc880_auto_create_analog_input_ctls(spec, cfg); | ||
| 13253 | if (err < 0) | ||
| 13254 | return err; | ||
| 13255 | /* digital-mic input pin is excluded in alc880_auto_create..() | ||
| 13256 | * because it's under 0x18 | ||
| 13257 | */ | ||
| 13258 | if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || | ||
| 13259 | cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { | ||
| 13260 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
| 13261 | imux->items[imux->num_items].label = "Int Mic"; | ||
| 13262 | imux->items[imux->num_items].index = 0x05; | ||
| 13263 | imux->num_items++; | ||
| 13264 | } | ||
| 13265 | return 0; | ||
| 13266 | } | ||
| 13267 | 13272 | ||
| 13268 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 13273 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 13269 | #define alc269_loopbacks alc880_loopbacks | 13274 | #define alc269_loopbacks alc880_loopbacks |
| @@ -15554,7 +15559,6 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
| 15554 | spec->adc_nids = alc861vd_adc_nids; | 15559 | spec->adc_nids = alc861vd_adc_nids; |
| 15555 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); | 15560 | spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); |
| 15556 | spec->capsrc_nids = alc861vd_capsrc_nids; | 15561 | spec->capsrc_nids = alc861vd_capsrc_nids; |
| 15557 | spec->capture_style = CAPT_MIX; | ||
| 15558 | 15562 | ||
| 15559 | set_capture_mixer(spec); | 15563 | set_capture_mixer(spec); |
| 15560 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); | 15564 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| @@ -17474,7 +17478,6 @@ static int patch_alc662(struct hda_codec *codec) | |||
| 17474 | spec->adc_nids = alc662_adc_nids; | 17478 | spec->adc_nids = alc662_adc_nids; |
| 17475 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); | 17479 | spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); |
| 17476 | spec->capsrc_nids = alc662_capsrc_nids; | 17480 | spec->capsrc_nids = alc662_capsrc_nids; |
| 17477 | spec->capture_style = CAPT_MIX; | ||
| 17478 | 17481 | ||
| 17479 | if (!spec->cap_mixer) | 17482 | if (!spec->cap_mixer) |
| 17480 | set_capture_mixer(spec); | 17483 | set_capture_mixer(spec); |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 93e47c96a38b..14f3c3e0f62d 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
| @@ -639,7 +639,7 @@ static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, | |||
| 639 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, | 639 | static unsigned int stac92xx_vref_set(struct hda_codec *codec, |
| 640 | hda_nid_t nid, unsigned int new_vref) | 640 | hda_nid_t nid, unsigned int new_vref) |
| 641 | { | 641 | { |
| 642 | unsigned int error; | 642 | int error; |
| 643 | unsigned int pincfg; | 643 | unsigned int pincfg; |
| 644 | pincfg = snd_hda_codec_read(codec, nid, 0, | 644 | pincfg = snd_hda_codec_read(codec, nid, 0, |
| 645 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 645 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| @@ -2703,7 +2703,7 @@ static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol, | |||
| 2703 | { | 2703 | { |
| 2704 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | 2704 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2705 | unsigned int new_vref = 0; | 2705 | unsigned int new_vref = 0; |
| 2706 | unsigned int error; | 2706 | int error; |
| 2707 | hda_nid_t nid = kcontrol->private_value; | 2707 | hda_nid_t nid = kcontrol->private_value; |
| 2708 | 2708 | ||
| 2709 | if (ucontrol->value.enumerated.item[0] == 0) | 2709 | if (ucontrol->value.enumerated.item[0] == 0) |
| @@ -4035,7 +4035,7 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, | |||
| 4035 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ | 4035 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
| 4036 | } | 4036 | } |
| 4037 | 4037 | ||
| 4038 | #ifdef CONFIG_SND_JACK | 4038 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
| 4039 | static void stac92xx_free_jack_priv(struct snd_jack *jack) | 4039 | static void stac92xx_free_jack_priv(struct snd_jack *jack) |
| 4040 | { | 4040 | { |
| 4041 | struct sigmatel_jack *jacks = jack->private_data; | 4041 | struct sigmatel_jack *jacks = jack->private_data; |
| @@ -4047,7 +4047,7 @@ static void stac92xx_free_jack_priv(struct snd_jack *jack) | |||
| 4047 | static int stac92xx_add_jack(struct hda_codec *codec, | 4047 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 4048 | hda_nid_t nid, int type) | 4048 | hda_nid_t nid, int type) |
| 4049 | { | 4049 | { |
| 4050 | #ifdef CONFIG_SND_JACK | 4050 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
| 4051 | struct sigmatel_spec *spec = codec->spec; | 4051 | struct sigmatel_spec *spec = codec->spec; |
| 4052 | struct sigmatel_jack *jack; | 4052 | struct sigmatel_jack *jack; |
| 4053 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); | 4053 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
| @@ -4336,7 +4336,7 @@ static int stac92xx_init(struct hda_codec *codec) | |||
| 4336 | 4336 | ||
| 4337 | static void stac92xx_free_jacks(struct hda_codec *codec) | 4337 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4338 | { | 4338 | { |
| 4339 | #ifdef CONFIG_SND_JACK | 4339 | #ifdef CONFIG_SND_HDA_INPUT_JACK |
| 4340 | /* free jack instances manually when clearing/reconfiguring */ | 4340 | /* free jack instances manually when clearing/reconfiguring */ |
| 4341 | struct sigmatel_spec *spec = codec->spec; | 4341 | struct sigmatel_spec *spec = codec->spec; |
| 4342 | if (!codec->bus->shutdown && spec->jacks.list) { | 4342 | if (!codec->bus->shutdown && spec->jacks.list) { |
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 1ef58c51c213..949fcaf6b70e 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c | |||
| @@ -85,6 +85,7 @@ static int joystick; | |||
| 85 | static int ac97_clock = 48000; | 85 | static int ac97_clock = 48000; |
| 86 | static char *ac97_quirk; | 86 | static char *ac97_quirk; |
| 87 | static int dxs_support; | 87 | static int dxs_support; |
| 88 | static int nodelay; | ||
| 88 | 89 | ||
| 89 | module_param(index, int, 0444); | 90 | module_param(index, int, 0444); |
| 90 | MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); | 91 | MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); |
| @@ -102,6 +103,8 @@ module_param(ac97_quirk, charp, 0444); | |||
| 102 | MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); | 103 | MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); |
| 103 | module_param(dxs_support, int, 0444); | 104 | module_param(dxs_support, int, 0444); |
| 104 | MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); | 105 | MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); |
| 106 | module_param(nodelay, int, 0444); | ||
| 107 | MODULE_PARM_DESC(nodelay, "Disable 500ms init delay"); | ||
| 105 | 108 | ||
| 106 | /* just for backward compatibility */ | 109 | /* just for backward compatibility */ |
| 107 | static int enable; | 110 | static int enable; |
| @@ -549,7 +552,8 @@ static void snd_via82xx_codec_wait(struct snd_ac97 *ac97) | |||
| 549 | int err; | 552 | int err; |
| 550 | err = snd_via82xx_codec_ready(chip, ac97->num); | 553 | err = snd_via82xx_codec_ready(chip, ac97->num); |
| 551 | /* here we need to wait fairly for long time.. */ | 554 | /* here we need to wait fairly for long time.. */ |
| 552 | msleep(500); | 555 | if (!nodelay) |
| 556 | msleep(500); | ||
| 553 | } | 557 | } |
| 554 | 558 | ||
| 555 | static void snd_via82xx_codec_write(struct snd_ac97 *ac97, | 559 | static void snd_via82xx_codec_write(struct snd_ac97 *ac97, |
diff --git a/sound/soc/blackfin/bf5xx-i2s.c b/sound/soc/blackfin/bf5xx-i2s.c index 964824419678..af06904bab0f 100644 --- a/sound/soc/blackfin/bf5xx-i2s.c +++ b/sound/soc/blackfin/bf5xx-i2s.c | |||
| @@ -50,6 +50,7 @@ struct bf5xx_i2s_port { | |||
| 50 | u16 tcr2; | 50 | u16 tcr2; |
| 51 | u16 rcr2; | 51 | u16 rcr2; |
| 52 | int counter; | 52 | int counter; |
| 53 | int configured; | ||
| 53 | }; | 54 | }; |
| 54 | 55 | ||
| 55 | static struct bf5xx_i2s_port bf5xx_i2s; | 56 | static struct bf5xx_i2s_port bf5xx_i2s; |
| @@ -168,7 +169,7 @@ static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 168 | break; | 169 | break; |
| 169 | } | 170 | } |
| 170 | 171 | ||
| 171 | if (bf5xx_i2s.counter == 1) { | 172 | if (!bf5xx_i2s.configured) { |
| 172 | /* | 173 | /* |
| 173 | * TX and RX are not independent,they are enabled at the | 174 | * TX and RX are not independent,they are enabled at the |
| 174 | * same time, even if only one side is running. So, we | 175 | * same time, even if only one side is running. So, we |
| @@ -177,6 +178,7 @@ static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 177 | * | 178 | * |
| 178 | * CPU DAI:slave mode. | 179 | * CPU DAI:slave mode. |
| 179 | */ | 180 | */ |
| 181 | bf5xx_i2s.configured = 1; | ||
| 180 | ret = sport_config_rx(sport_handle, bf5xx_i2s.rcr1, | 182 | ret = sport_config_rx(sport_handle, bf5xx_i2s.rcr1, |
| 181 | bf5xx_i2s.rcr2, 0, 0); | 183 | bf5xx_i2s.rcr2, 0, 0); |
| 182 | if (ret) { | 184 | if (ret) { |
| @@ -200,6 +202,9 @@ static void bf5xx_i2s_shutdown(struct snd_pcm_substream *substream, | |||
| 200 | { | 202 | { |
| 201 | pr_debug("%s enter\n", __func__); | 203 | pr_debug("%s enter\n", __func__); |
| 202 | bf5xx_i2s.counter--; | 204 | bf5xx_i2s.counter--; |
| 205 | /* No active stream, SPORT is allowed to be configured again. */ | ||
| 206 | if (!bf5xx_i2s.counter) | ||
| 207 | bf5xx_i2s.configured = 0; | ||
| 203 | } | 208 | } |
| 204 | 209 | ||
| 205 | static int bf5xx_i2s_probe(struct platform_device *pdev, | 210 | static int bf5xx_i2s_probe(struct platform_device *pdev, |
| @@ -244,8 +249,7 @@ static int bf5xx_i2s_suspend(struct snd_soc_dai *dai) | |||
| 244 | return 0; | 249 | return 0; |
| 245 | } | 250 | } |
| 246 | 251 | ||
| 247 | static int bf5xx_i2s_resume(struct platform_device *pdev, | 252 | static int bf5xx_i2s_resume(struct snd_soc_dai *dai) |
| 248 | struct snd_soc_dai *dai) | ||
| 249 | { | 253 | { |
| 250 | int ret; | 254 | int ret; |
| 251 | struct sport_device *sport = | 255 | struct sport_device *sport = |
