diff options
Diffstat (limited to 'drivers/char')
41 files changed, 350 insertions, 1429 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index d0ac944e1696..caff85149b9d 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -8,7 +8,7 @@ config VT | |||
8 | bool "Virtual terminal" if EMBEDDED | 8 | bool "Virtual terminal" if EMBEDDED |
9 | depends on !S390 | 9 | depends on !S390 |
10 | select INPUT | 10 | select INPUT |
11 | default y if !VIOCONS | 11 | default y |
12 | ---help--- | 12 | ---help--- |
13 | If you say Y here, you will get support for terminal devices with | 13 | If you say Y here, you will get support for terminal devices with |
14 | display and keyboard devices. These are called "virtual" because you | 14 | display and keyboard devices. These are called "virtual" because you |
diff --git a/drivers/char/Makefile b/drivers/char/Makefile index 8a161c30e1dc..6850f6da7576 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile | |||
@@ -55,7 +55,6 @@ obj-$(CONFIG_RAW_DRIVER) += raw.o | |||
55 | obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o | 55 | obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o |
56 | obj-$(CONFIG_MSPEC) += mspec.o | 56 | obj-$(CONFIG_MSPEC) += mspec.o |
57 | obj-$(CONFIG_MMTIMER) += mmtimer.o | 57 | obj-$(CONFIG_MMTIMER) += mmtimer.o |
58 | obj-$(CONFIG_VIOCONS) += viocons.o | ||
59 | obj-$(CONFIG_VIOTAPE) += viotape.o | 58 | obj-$(CONFIG_VIOTAPE) += viotape.o |
60 | obj-$(CONFIG_HVCS) += hvcs.o | 59 | obj-$(CONFIG_HVCS) += hvcs.o |
61 | obj-$(CONFIG_IBM_BSR) += bsr.o | 60 | obj-$(CONFIG_IBM_BSR) += bsr.o |
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h index 81e14bea54bd..4bada0e8b812 100644 --- a/drivers/char/agp/agp.h +++ b/drivers/char/agp/agp.h | |||
@@ -148,6 +148,9 @@ struct agp_bridge_data { | |||
148 | char minor_version; | 148 | char minor_version; |
149 | struct list_head list; | 149 | struct list_head list; |
150 | u32 apbase_config; | 150 | u32 apbase_config; |
151 | /* list of agp_memory mapped to the aperture */ | ||
152 | struct list_head mapped_list; | ||
153 | spinlock_t mapped_lock; | ||
151 | }; | 154 | }; |
152 | 155 | ||
153 | #define KB(x) ((x) * 1024) | 156 | #define KB(x) ((x) * 1024) |
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c index 1ffb381130c3..31dcd9142d54 100644 --- a/drivers/char/agp/ali-agp.c +++ b/drivers/char/agp/ali-agp.c | |||
@@ -110,7 +110,8 @@ static int ali_configure(void) | |||
110 | 110 | ||
111 | nlvm_addr+= agp_bridge->gart_bus_addr; | 111 | nlvm_addr+= agp_bridge->gart_bus_addr; |
112 | nlvm_addr|=(agp_bridge->gart_bus_addr>>12); | 112 | nlvm_addr|=(agp_bridge->gart_bus_addr>>12); |
113 | printk(KERN_INFO PFX "nlvm top &base = %8x\n",nlvm_addr); | 113 | dev_info(&agp_bridge->dev->dev, "nlvm top &base = %8x\n", |
114 | nlvm_addr); | ||
114 | } | 115 | } |
115 | #endif | 116 | #endif |
116 | 117 | ||
@@ -315,8 +316,8 @@ static int __devinit agp_ali_probe(struct pci_dev *pdev, | |||
315 | goto found; | 316 | goto found; |
316 | } | 317 | } |
317 | 318 | ||
318 | printk(KERN_ERR PFX "Unsupported ALi chipset (device id: %04x)\n", | 319 | dev_err(&pdev->dev, "unsupported ALi chipset [%04x/%04x])\n", |
319 | pdev->device); | 320 | pdev->vendor, pdev->device); |
320 | return -ENODEV; | 321 | return -ENODEV; |
321 | 322 | ||
322 | 323 | ||
@@ -361,8 +362,7 @@ found: | |||
361 | bridge->driver = &ali_generic_bridge; | 362 | bridge->driver = &ali_generic_bridge; |
362 | } | 363 | } |
363 | 364 | ||
364 | printk(KERN_INFO PFX "Detected ALi %s chipset\n", | 365 | dev_info(&pdev->dev, "ALi %s chipset\n", devs[j].chipset_name); |
365 | devs[j].chipset_name); | ||
366 | 366 | ||
367 | /* Fill in the mode register */ | 367 | /* Fill in the mode register */ |
368 | pci_read_config_dword(pdev, | 368 | pci_read_config_dword(pdev, |
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c index 39a0718bc616..e280531843be 100644 --- a/drivers/char/agp/amd-k7-agp.c +++ b/drivers/char/agp/amd-k7-agp.c | |||
@@ -419,8 +419,8 @@ static int __devinit agp_amdk7_probe(struct pci_dev *pdev, | |||
419 | return -ENODEV; | 419 | return -ENODEV; |
420 | 420 | ||
421 | j = ent - agp_amdk7_pci_table; | 421 | j = ent - agp_amdk7_pci_table; |
422 | printk(KERN_INFO PFX "Detected AMD %s chipset\n", | 422 | dev_info(&pdev->dev, "AMD %s chipset\n", |
423 | amd_agp_device_ids[j].chipset_name); | 423 | amd_agp_device_ids[j].chipset_name); |
424 | 424 | ||
425 | bridge = agp_alloc_bridge(); | 425 | bridge = agp_alloc_bridge(); |
426 | if (!bridge) | 426 | if (!bridge) |
@@ -442,7 +442,7 @@ static int __devinit agp_amdk7_probe(struct pci_dev *pdev, | |||
442 | while (!cap_ptr) { | 442 | while (!cap_ptr) { |
443 | gfxcard = pci_get_class(PCI_CLASS_DISPLAY_VGA<<8, gfxcard); | 443 | gfxcard = pci_get_class(PCI_CLASS_DISPLAY_VGA<<8, gfxcard); |
444 | if (!gfxcard) { | 444 | if (!gfxcard) { |
445 | printk (KERN_INFO PFX "Couldn't find an AGP VGA controller.\n"); | 445 | dev_info(&pdev->dev, "no AGP VGA controller\n"); |
446 | return -ENODEV; | 446 | return -ENODEV; |
447 | } | 447 | } |
448 | cap_ptr = pci_find_capability(gfxcard, PCI_CAP_ID_AGP); | 448 | cap_ptr = pci_find_capability(gfxcard, PCI_CAP_ID_AGP); |
@@ -453,7 +453,7 @@ static int __devinit agp_amdk7_probe(struct pci_dev *pdev, | |||
453 | (if necessary at all). */ | 453 | (if necessary at all). */ |
454 | if (gfxcard->vendor == PCI_VENDOR_ID_NVIDIA) { | 454 | if (gfxcard->vendor == PCI_VENDOR_ID_NVIDIA) { |
455 | agp_bridge->flags |= AGP_ERRATA_1X; | 455 | agp_bridge->flags |= AGP_ERRATA_1X; |
456 | printk (KERN_INFO PFX "AMD 751 chipset with NVidia GeForce detected. Forcing to 1X due to errata.\n"); | 456 | dev_info(&pdev->dev, "AMD 751 chipset with NVidia GeForce; forcing 1X due to errata\n"); |
457 | } | 457 | } |
458 | pci_dev_put(gfxcard); | 458 | pci_dev_put(gfxcard); |
459 | } | 459 | } |
@@ -469,7 +469,7 @@ static int __devinit agp_amdk7_probe(struct pci_dev *pdev, | |||
469 | agp_bridge->flags = AGP_ERRATA_FASTWRITES; | 469 | agp_bridge->flags = AGP_ERRATA_FASTWRITES; |
470 | agp_bridge->flags |= AGP_ERRATA_SBA; | 470 | agp_bridge->flags |= AGP_ERRATA_SBA; |
471 | agp_bridge->flags |= AGP_ERRATA_1X; | 471 | agp_bridge->flags |= AGP_ERRATA_1X; |
472 | printk (KERN_INFO PFX "AMD 761 chipset with errata detected - disabling AGP fast writes & SBA and forcing to 1X.\n"); | 472 | dev_info(&pdev->dev, "AMD 761 chipset with errata; disabling AGP fast writes & SBA and forcing to 1X\n"); |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 481ffe87c716..7495c522d8e4 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | static struct resource *aperture_resource; | 35 | static struct resource *aperture_resource; |
36 | static int __initdata agp_try_unsupported = 1; | 36 | static int __initdata agp_try_unsupported = 1; |
37 | static int agp_bridges_found; | ||
37 | 38 | ||
38 | static void amd64_tlbflush(struct agp_memory *temp) | 39 | static void amd64_tlbflush(struct agp_memory *temp) |
39 | { | 40 | { |
@@ -293,12 +294,13 @@ static __devinit int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, | |||
293 | * so let double check that order, and lets trust the AMD NB settings | 294 | * so let double check that order, and lets trust the AMD NB settings |
294 | */ | 295 | */ |
295 | if (order >=0 && aper + (32ULL<<(20 + order)) > 0x100000000ULL) { | 296 | if (order >=0 && aper + (32ULL<<(20 + order)) > 0x100000000ULL) { |
296 | printk(KERN_INFO "Aperture size %u MB is not right, using settings from NB\n", | 297 | dev_info(&agp->dev, "aperture size %u MB is not right, using settings from NB\n", |
297 | 32 << order); | 298 | 32 << order); |
298 | order = nb_order; | 299 | order = nb_order; |
299 | } | 300 | } |
300 | 301 | ||
301 | printk(KERN_INFO PFX "Aperture from AGP @ %Lx size %u MB\n", aper, 32 << order); | 302 | dev_info(&agp->dev, "aperture from AGP @ %Lx size %u MB\n", |
303 | aper, 32 << order); | ||
302 | if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order)) | 304 | if (order < 0 || !agp_aperture_valid(aper, (32*1024*1024)<<order)) |
303 | return -1; | 305 | return -1; |
304 | 306 | ||
@@ -319,10 +321,10 @@ static __devinit int cache_nbs (struct pci_dev *pdev, u32 cap_ptr) | |||
319 | for (i = 0; i < num_k8_northbridges; i++) { | 321 | for (i = 0; i < num_k8_northbridges; i++) { |
320 | struct pci_dev *dev = k8_northbridges[i]; | 322 | struct pci_dev *dev = k8_northbridges[i]; |
321 | if (fix_northbridge(dev, pdev, cap_ptr) < 0) { | 323 | if (fix_northbridge(dev, pdev, cap_ptr) < 0) { |
322 | printk(KERN_ERR PFX "No usable aperture found.\n"); | 324 | dev_err(&dev->dev, "no usable aperture found\n"); |
323 | #ifdef __x86_64__ | 325 | #ifdef __x86_64__ |
324 | /* should port this to i386 */ | 326 | /* should port this to i386 */ |
325 | printk(KERN_ERR PFX "Consider rebooting with iommu=memaper=2 to get a good aperture.\n"); | 327 | dev_err(&dev->dev, "consider rebooting with iommu=memaper=2 to get a good aperture\n"); |
326 | #endif | 328 | #endif |
327 | return -1; | 329 | return -1; |
328 | } | 330 | } |
@@ -345,14 +347,14 @@ static void __devinit amd8151_init(struct pci_dev *pdev, struct agp_bridge_data | |||
345 | default: revstring="??"; break; | 347 | default: revstring="??"; break; |
346 | } | 348 | } |
347 | 349 | ||
348 | printk (KERN_INFO PFX "Detected AMD 8151 AGP Bridge rev %s\n", revstring); | 350 | dev_info(&pdev->dev, "AMD 8151 AGP Bridge rev %s\n", revstring); |
349 | 351 | ||
350 | /* | 352 | /* |
351 | * Work around errata. | 353 | * Work around errata. |
352 | * Chips before B2 stepping incorrectly reporting v3.5 | 354 | * Chips before B2 stepping incorrectly reporting v3.5 |
353 | */ | 355 | */ |
354 | if (pdev->revision < 0x13) { | 356 | if (pdev->revision < 0x13) { |
355 | printk (KERN_INFO PFX "Correcting AGP revision (reports 3.5, is really 3.0)\n"); | 357 | dev_info(&pdev->dev, "correcting AGP revision (reports 3.5, is really 3.0)\n"); |
356 | bridge->major_version = 3; | 358 | bridge->major_version = 3; |
357 | bridge->minor_version = 0; | 359 | bridge->minor_version = 0; |
358 | } | 360 | } |
@@ -375,11 +377,11 @@ static int __devinit uli_agp_init(struct pci_dev *pdev) | |||
375 | struct pci_dev *dev1; | 377 | struct pci_dev *dev1; |
376 | int i; | 378 | int i; |
377 | unsigned size = amd64_fetch_size(); | 379 | unsigned size = amd64_fetch_size(); |
378 | printk(KERN_INFO "Setting up ULi AGP.\n"); | 380 | |
381 | dev_info(&pdev->dev, "setting up ULi AGP\n"); | ||
379 | dev1 = pci_get_slot (pdev->bus,PCI_DEVFN(0,0)); | 382 | dev1 = pci_get_slot (pdev->bus,PCI_DEVFN(0,0)); |
380 | if (dev1 == NULL) { | 383 | if (dev1 == NULL) { |
381 | printk(KERN_INFO PFX "Detected a ULi chipset, " | 384 | dev_info(&pdev->dev, "can't find ULi secondary device\n"); |
382 | "but could not fine the secondary device.\n"); | ||
383 | return -ENODEV; | 385 | return -ENODEV; |
384 | } | 386 | } |
385 | 387 | ||
@@ -388,7 +390,7 @@ static int __devinit uli_agp_init(struct pci_dev *pdev) | |||
388 | break; | 390 | break; |
389 | 391 | ||
390 | if (i == ARRAY_SIZE(uli_sizes)) { | 392 | if (i == ARRAY_SIZE(uli_sizes)) { |
391 | printk(KERN_INFO PFX "No ULi size found for %d\n", size); | 393 | dev_info(&pdev->dev, "no ULi size found for %d\n", size); |
392 | return -ENODEV; | 394 | return -ENODEV; |
393 | } | 395 | } |
394 | 396 | ||
@@ -433,13 +435,11 @@ static int nforce3_agp_init(struct pci_dev *pdev) | |||
433 | int i; | 435 | int i; |
434 | unsigned size = amd64_fetch_size(); | 436 | unsigned size = amd64_fetch_size(); |
435 | 437 | ||
436 | printk(KERN_INFO PFX "Setting up Nforce3 AGP.\n"); | 438 | dev_info(&pdev->dev, "setting up Nforce3 AGP\n"); |
437 | 439 | ||
438 | dev1 = pci_get_slot(pdev->bus, PCI_DEVFN(11, 0)); | 440 | dev1 = pci_get_slot(pdev->bus, PCI_DEVFN(11, 0)); |
439 | if (dev1 == NULL) { | 441 | if (dev1 == NULL) { |
440 | printk(KERN_INFO PFX "agpgart: Detected an NVIDIA " | 442 | dev_info(&pdev->dev, "can't find Nforce3 secondary device\n"); |
441 | "nForce3 chipset, but could not find " | ||
442 | "the secondary device.\n"); | ||
443 | return -ENODEV; | 443 | return -ENODEV; |
444 | } | 444 | } |
445 | 445 | ||
@@ -448,7 +448,7 @@ static int nforce3_agp_init(struct pci_dev *pdev) | |||
448 | break; | 448 | break; |
449 | 449 | ||
450 | if (i == ARRAY_SIZE(nforce3_sizes)) { | 450 | if (i == ARRAY_SIZE(nforce3_sizes)) { |
451 | printk(KERN_INFO PFX "No NForce3 size found for %d\n", size); | 451 | dev_info(&pdev->dev, "no NForce3 size found for %d\n", size); |
452 | return -ENODEV; | 452 | return -ENODEV; |
453 | } | 453 | } |
454 | 454 | ||
@@ -462,7 +462,7 @@ static int nforce3_agp_init(struct pci_dev *pdev) | |||
462 | 462 | ||
463 | /* if x86-64 aperture base is beyond 4G, exit here */ | 463 | /* if x86-64 aperture base is beyond 4G, exit here */ |
464 | if ( (apbase & 0x7fff) >> (32 - 25) ) { | 464 | if ( (apbase & 0x7fff) >> (32 - 25) ) { |
465 | printk(KERN_INFO PFX "aperture base > 4G\n"); | 465 | dev_info(&pdev->dev, "aperture base > 4G\n"); |
466 | return -ENODEV; | 466 | return -ENODEV; |
467 | } | 467 | } |
468 | 468 | ||
@@ -489,6 +489,7 @@ static int __devinit agp_amd64_probe(struct pci_dev *pdev, | |||
489 | { | 489 | { |
490 | struct agp_bridge_data *bridge; | 490 | struct agp_bridge_data *bridge; |
491 | u8 cap_ptr; | 491 | u8 cap_ptr; |
492 | int err; | ||
492 | 493 | ||
493 | cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); | 494 | cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); |
494 | if (!cap_ptr) | 495 | if (!cap_ptr) |
@@ -504,7 +505,8 @@ static int __devinit agp_amd64_probe(struct pci_dev *pdev, | |||
504 | pdev->device == PCI_DEVICE_ID_AMD_8151_0) { | 505 | pdev->device == PCI_DEVICE_ID_AMD_8151_0) { |
505 | amd8151_init(pdev, bridge); | 506 | amd8151_init(pdev, bridge); |
506 | } else { | 507 | } else { |
507 | printk(KERN_INFO PFX "Detected AGP bridge %x\n", pdev->devfn); | 508 | dev_info(&pdev->dev, "AGP bridge [%04x/%04x]\n", |
509 | pdev->vendor, pdev->device); | ||
508 | } | 510 | } |
509 | 511 | ||
510 | bridge->driver = &amd_8151_driver; | 512 | bridge->driver = &amd_8151_driver; |
@@ -536,7 +538,12 @@ static int __devinit agp_amd64_probe(struct pci_dev *pdev, | |||
536 | } | 538 | } |
537 | 539 | ||
538 | pci_set_drvdata(pdev, bridge); | 540 | pci_set_drvdata(pdev, bridge); |
539 | return agp_add_bridge(bridge); | 541 | err = agp_add_bridge(bridge); |
542 | if (err < 0) | ||
543 | return err; | ||
544 | |||
545 | agp_bridges_found++; | ||
546 | return 0; | ||
540 | } | 547 | } |
541 | 548 | ||
542 | static void __devexit agp_amd64_remove(struct pci_dev *pdev) | 549 | static void __devexit agp_amd64_remove(struct pci_dev *pdev) |
@@ -713,7 +720,11 @@ int __init agp_amd64_init(void) | |||
713 | 720 | ||
714 | if (agp_off) | 721 | if (agp_off) |
715 | return -EINVAL; | 722 | return -EINVAL; |
716 | if (pci_register_driver(&agp_amd64_pci_driver) < 0) { | 723 | err = pci_register_driver(&agp_amd64_pci_driver); |
724 | if (err < 0) | ||
725 | return err; | ||
726 | |||
727 | if (agp_bridges_found == 0) { | ||
717 | struct pci_dev *dev; | 728 | struct pci_dev *dev; |
718 | if (!agp_try_unsupported && !agp_try_unsupported_boot) { | 729 | if (!agp_try_unsupported && !agp_try_unsupported_boot) { |
719 | printk(KERN_INFO PFX "No supported AGP bridge found.\n"); | 730 | printk(KERN_INFO PFX "No supported AGP bridge found.\n"); |
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c index 3a4566c0d84f..6ecbcafb34b1 100644 --- a/drivers/char/agp/ati-agp.c +++ b/drivers/char/agp/ati-agp.c | |||
@@ -486,8 +486,8 @@ static int __devinit agp_ati_probe(struct pci_dev *pdev, | |||
486 | goto found; | 486 | goto found; |
487 | } | 487 | } |
488 | 488 | ||
489 | printk(KERN_ERR PFX | 489 | dev_err(&pdev->dev, "unsupported Ati chipset [%04x/%04x])\n", |
490 | "Unsupported Ati chipset (device id: %04x)\n", pdev->device); | 490 | pdev->vendor, pdev->device); |
491 | return -ENODEV; | 491 | return -ENODEV; |
492 | 492 | ||
493 | found: | 493 | found: |
@@ -500,8 +500,7 @@ found: | |||
500 | 500 | ||
501 | bridge->driver = &ati_generic_bridge; | 501 | bridge->driver = &ati_generic_bridge; |
502 | 502 | ||
503 | printk(KERN_INFO PFX "Detected Ati %s chipset\n", | 503 | dev_info(&pdev->dev, "Ati %s chipset\n", devs[j].chipset_name); |
504 | devs[j].chipset_name); | ||
505 | 504 | ||
506 | /* Fill in the mode register */ | 505 | /* Fill in the mode register */ |
507 | pci_read_config_dword(pdev, | 506 | pci_read_config_dword(pdev, |
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c index 1ec87104e68c..3a3cc03d401c 100644 --- a/drivers/char/agp/backend.c +++ b/drivers/char/agp/backend.c | |||
@@ -144,7 +144,8 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge) | |||
144 | void *addr = bridge->driver->agp_alloc_page(bridge); | 144 | void *addr = bridge->driver->agp_alloc_page(bridge); |
145 | 145 | ||
146 | if (!addr) { | 146 | if (!addr) { |
147 | printk(KERN_ERR PFX "unable to get memory for scratch page.\n"); | 147 | dev_err(&bridge->dev->dev, |
148 | "can't get memory for scratch page\n"); | ||
148 | return -ENOMEM; | 149 | return -ENOMEM; |
149 | } | 150 | } |
150 | 151 | ||
@@ -155,13 +156,13 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge) | |||
155 | 156 | ||
156 | size_value = bridge->driver->fetch_size(); | 157 | size_value = bridge->driver->fetch_size(); |
157 | if (size_value == 0) { | 158 | if (size_value == 0) { |
158 | printk(KERN_ERR PFX "unable to determine aperture size.\n"); | 159 | dev_err(&bridge->dev->dev, "can't determine aperture size\n"); |
159 | rc = -EINVAL; | 160 | rc = -EINVAL; |
160 | goto err_out; | 161 | goto err_out; |
161 | } | 162 | } |
162 | if (bridge->driver->create_gatt_table(bridge)) { | 163 | if (bridge->driver->create_gatt_table(bridge)) { |
163 | printk(KERN_ERR PFX | 164 | dev_err(&bridge->dev->dev, |
164 | "unable to get memory for graphics translation table.\n"); | 165 | "can't get memory for graphics translation table\n"); |
165 | rc = -ENOMEM; | 166 | rc = -ENOMEM; |
166 | goto err_out; | 167 | goto err_out; |
167 | } | 168 | } |
@@ -169,7 +170,8 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge) | |||
169 | 170 | ||
170 | bridge->key_list = vmalloc(PAGE_SIZE * 4); | 171 | bridge->key_list = vmalloc(PAGE_SIZE * 4); |
171 | if (bridge->key_list == NULL) { | 172 | if (bridge->key_list == NULL) { |
172 | printk(KERN_ERR PFX "error allocating memory for key lists.\n"); | 173 | dev_err(&bridge->dev->dev, |
174 | "can't allocate memory for key lists\n"); | ||
173 | rc = -ENOMEM; | 175 | rc = -ENOMEM; |
174 | goto err_out; | 176 | goto err_out; |
175 | } | 177 | } |
@@ -179,10 +181,12 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge) | |||
179 | memset(bridge->key_list, 0, PAGE_SIZE * 4); | 181 | memset(bridge->key_list, 0, PAGE_SIZE * 4); |
180 | 182 | ||
181 | if (bridge->driver->configure()) { | 183 | if (bridge->driver->configure()) { |
182 | printk(KERN_ERR PFX "error configuring host chipset.\n"); | 184 | dev_err(&bridge->dev->dev, "error configuring host chipset\n"); |
183 | rc = -EINVAL; | 185 | rc = -EINVAL; |
184 | goto err_out; | 186 | goto err_out; |
185 | } | 187 | } |
188 | INIT_LIST_HEAD(&bridge->mapped_list); | ||
189 | spin_lock_init(&bridge->mapped_lock); | ||
186 | 190 | ||
187 | return 0; | 191 | return 0; |
188 | 192 | ||
@@ -269,25 +273,27 @@ int agp_add_bridge(struct agp_bridge_data *bridge) | |||
269 | 273 | ||
270 | /* Grab reference on the chipset driver. */ | 274 | /* Grab reference on the chipset driver. */ |
271 | if (!try_module_get(bridge->driver->owner)) { | 275 | if (!try_module_get(bridge->driver->owner)) { |
272 | printk (KERN_INFO PFX "Couldn't lock chipset driver.\n"); | 276 | dev_info(&bridge->dev->dev, "can't lock chipset driver\n"); |
273 | return -EINVAL; | 277 | return -EINVAL; |
274 | } | 278 | } |
275 | 279 | ||
276 | error = agp_backend_initialize(bridge); | 280 | error = agp_backend_initialize(bridge); |
277 | if (error) { | 281 | if (error) { |
278 | printk (KERN_INFO PFX "agp_backend_initialize() failed.\n"); | 282 | dev_info(&bridge->dev->dev, |
283 | "agp_backend_initialize() failed\n"); | ||
279 | goto err_out; | 284 | goto err_out; |
280 | } | 285 | } |
281 | 286 | ||
282 | if (list_empty(&agp_bridges)) { | 287 | if (list_empty(&agp_bridges)) { |
283 | error = agp_frontend_initialize(); | 288 | error = agp_frontend_initialize(); |
284 | if (error) { | 289 | if (error) { |
285 | printk (KERN_INFO PFX "agp_frontend_initialize() failed.\n"); | 290 | dev_info(&bridge->dev->dev, |
291 | "agp_frontend_initialize() failed\n"); | ||
286 | goto frontend_err; | 292 | goto frontend_err; |
287 | } | 293 | } |
288 | 294 | ||
289 | printk(KERN_INFO PFX "AGP aperture is %dM @ 0x%lx\n", | 295 | dev_info(&bridge->dev->dev, "AGP aperture is %dM @ 0x%lx\n", |
290 | bridge->driver->fetch_size(), bridge->gart_bus_addr); | 296 | bridge->driver->fetch_size(), bridge->gart_bus_addr); |
291 | 297 | ||
292 | } | 298 | } |
293 | 299 | ||
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index eaa1a355bb32..118dbde25dc7 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c | |||
@@ -429,6 +429,10 @@ int agp_bind_memory(struct agp_memory *curr, off_t pg_start) | |||
429 | 429 | ||
430 | curr->is_bound = true; | 430 | curr->is_bound = true; |
431 | curr->pg_start = pg_start; | 431 | curr->pg_start = pg_start; |
432 | spin_lock(&agp_bridge->mapped_lock); | ||
433 | list_add(&curr->mapped_list, &agp_bridge->mapped_list); | ||
434 | spin_unlock(&agp_bridge->mapped_lock); | ||
435 | |||
432 | return 0; | 436 | return 0; |
433 | } | 437 | } |
434 | EXPORT_SYMBOL(agp_bind_memory); | 438 | EXPORT_SYMBOL(agp_bind_memory); |
@@ -461,10 +465,34 @@ int agp_unbind_memory(struct agp_memory *curr) | |||
461 | 465 | ||
462 | curr->is_bound = false; | 466 | curr->is_bound = false; |
463 | curr->pg_start = 0; | 467 | curr->pg_start = 0; |
468 | spin_lock(&curr->bridge->mapped_lock); | ||
469 | list_del(&curr->mapped_list); | ||
470 | spin_unlock(&curr->bridge->mapped_lock); | ||
464 | return 0; | 471 | return 0; |
465 | } | 472 | } |
466 | EXPORT_SYMBOL(agp_unbind_memory); | 473 | EXPORT_SYMBOL(agp_unbind_memory); |
467 | 474 | ||
475 | /** | ||
476 | * agp_rebind_emmory - Rewrite the entire GATT, useful on resume | ||
477 | */ | ||
478 | int agp_rebind_memory(void) | ||
479 | { | ||
480 | struct agp_memory *curr; | ||
481 | int ret_val = 0; | ||
482 | |||
483 | spin_lock(&agp_bridge->mapped_lock); | ||
484 | list_for_each_entry(curr, &agp_bridge->mapped_list, mapped_list) { | ||
485 | ret_val = curr->bridge->driver->insert_memory(curr, | ||
486 | curr->pg_start, | ||
487 | curr->type); | ||
488 | if (ret_val != 0) | ||
489 | break; | ||
490 | } | ||
491 | spin_unlock(&agp_bridge->mapped_lock); | ||
492 | return ret_val; | ||
493 | } | ||
494 | EXPORT_SYMBOL(agp_rebind_memory); | ||
495 | |||
468 | /* End - Routines for handling swapping of agp_memory into the GATT */ | 496 | /* End - Routines for handling swapping of agp_memory into the GATT */ |
469 | 497 | ||
470 | 498 | ||
@@ -771,8 +799,8 @@ void agp_device_command(u32 bridge_agpstat, bool agp_v3) | |||
771 | if (!agp) | 799 | if (!agp) |
772 | continue; | 800 | continue; |
773 | 801 | ||
774 | printk(KERN_INFO PFX "Putting AGP V%d device at %s into %dx mode\n", | 802 | dev_info(&device->dev, "putting AGP V%d device into %dx mode\n", |
775 | agp_v3 ? 3 : 2, pci_name(device), mode); | 803 | agp_v3 ? 3 : 2, mode); |
776 | pci_write_config_dword(device, agp + PCI_AGP_COMMAND, bridge_agpstat); | 804 | pci_write_config_dword(device, agp + PCI_AGP_COMMAND, bridge_agpstat); |
777 | } | 805 | } |
778 | } | 806 | } |
@@ -800,10 +828,8 @@ void agp_generic_enable(struct agp_bridge_data *bridge, u32 requested_mode) | |||
800 | 828 | ||
801 | get_agp_version(agp_bridge); | 829 | get_agp_version(agp_bridge); |
802 | 830 | ||
803 | printk(KERN_INFO PFX "Found an AGP %d.%d compliant device at %s.\n", | 831 | dev_info(&agp_bridge->dev->dev, "AGP %d.%d bridge\n", |
804 | agp_bridge->major_version, | 832 | agp_bridge->major_version, agp_bridge->minor_version); |
805 | agp_bridge->minor_version, | ||
806 | pci_name(agp_bridge->dev)); | ||
807 | 833 | ||
808 | pci_read_config_dword(agp_bridge->dev, | 834 | pci_read_config_dword(agp_bridge->dev, |
809 | agp_bridge->capndx + PCI_AGP_STATUS, &bridge_agpstat); | 835 | agp_bridge->capndx + PCI_AGP_STATUS, &bridge_agpstat); |
@@ -832,8 +858,7 @@ void agp_generic_enable(struct agp_bridge_data *bridge, u32 requested_mode) | |||
832 | pci_write_config_dword(bridge->dev, | 858 | pci_write_config_dword(bridge->dev, |
833 | bridge->capndx+AGPCTRL, temp); | 859 | bridge->capndx+AGPCTRL, temp); |
834 | 860 | ||
835 | printk(KERN_INFO PFX "Device is in legacy mode," | 861 | dev_info(&bridge->dev->dev, "bridge is in legacy mode, falling back to 2.x\n"); |
836 | " falling back to 2.x\n"); | ||
837 | } | 862 | } |
838 | } | 863 | } |
839 | 864 | ||
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index df702642ab8f..016fdf0623a4 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -32,8 +32,8 @@ | |||
32 | #define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2 | 32 | #define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2 |
33 | #define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0 | 33 | #define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0 |
34 | #define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2 | 34 | #define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2 |
35 | #define PCI_DEVICE_ID_INTEL_IGD_HB 0x2A40 | 35 | #define PCI_DEVICE_ID_INTEL_GM45_HB 0x2A40 |
36 | #define PCI_DEVICE_ID_INTEL_IGD_IG 0x2A42 | 36 | #define PCI_DEVICE_ID_INTEL_GM45_IG 0x2A42 |
37 | #define PCI_DEVICE_ID_INTEL_IGD_E_HB 0x2E00 | 37 | #define PCI_DEVICE_ID_INTEL_IGD_E_HB 0x2E00 |
38 | #define PCI_DEVICE_ID_INTEL_IGD_E_IG 0x2E02 | 38 | #define PCI_DEVICE_ID_INTEL_IGD_E_IG 0x2E02 |
39 | #define PCI_DEVICE_ID_INTEL_Q45_HB 0x2E10 | 39 | #define PCI_DEVICE_ID_INTEL_Q45_HB 0x2E10 |
@@ -55,7 +55,7 @@ | |||
55 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ | 55 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ |
56 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \ | 56 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \ |
57 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB || \ | 57 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB || \ |
58 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_HB) | 58 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_GM45_HB) |
59 | 59 | ||
60 | #define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \ | 60 | #define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \ |
61 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \ | 61 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \ |
@@ -161,7 +161,7 @@ static int intel_i810_fetch_size(void) | |||
161 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); | 161 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); |
162 | 162 | ||
163 | if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) { | 163 | if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) { |
164 | printk(KERN_WARNING PFX "i810 is disabled\n"); | 164 | dev_warn(&agp_bridge->dev->dev, "i810 is disabled\n"); |
165 | return 0; | 165 | return 0; |
166 | } | 166 | } |
167 | if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) { | 167 | if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) { |
@@ -193,7 +193,8 @@ static int intel_i810_configure(void) | |||
193 | 193 | ||
194 | intel_private.registers = ioremap(temp, 128 * 4096); | 194 | intel_private.registers = ioremap(temp, 128 * 4096); |
195 | if (!intel_private.registers) { | 195 | if (!intel_private.registers) { |
196 | printk(KERN_ERR PFX "Unable to remap memory.\n"); | 196 | dev_err(&intel_private.pcidev->dev, |
197 | "can't remap memory\n"); | ||
197 | return -ENOMEM; | 198 | return -ENOMEM; |
198 | } | 199 | } |
199 | } | 200 | } |
@@ -201,7 +202,8 @@ static int intel_i810_configure(void) | |||
201 | if ((readl(intel_private.registers+I810_DRAM_CTL) | 202 | if ((readl(intel_private.registers+I810_DRAM_CTL) |
202 | & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { | 203 | & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { |
203 | /* This will need to be dynamically assigned */ | 204 | /* This will need to be dynamically assigned */ |
204 | printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n"); | 205 | dev_info(&intel_private.pcidev->dev, |
206 | "detected 4MB dedicated video ram\n"); | ||
205 | intel_private.num_dcache_entries = 1024; | 207 | intel_private.num_dcache_entries = 1024; |
206 | } | 208 | } |
207 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); | 209 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); |
@@ -500,8 +502,8 @@ static void intel_i830_init_gtt_entries(void) | |||
500 | size = 1024 + 512; | 502 | size = 1024 + 512; |
501 | break; | 503 | break; |
502 | default: | 504 | default: |
503 | printk(KERN_INFO PFX "Unknown page table size, " | 505 | dev_info(&intel_private.pcidev->dev, |
504 | "assuming 512KB\n"); | 506 | "unknown page table size, assuming 512KB\n"); |
505 | size = 512; | 507 | size = 512; |
506 | } | 508 | } |
507 | size += 4; /* add in BIOS popup space */ | 509 | size += 4; /* add in BIOS popup space */ |
@@ -515,8 +517,8 @@ static void intel_i830_init_gtt_entries(void) | |||
515 | size = 2048; | 517 | size = 2048; |
516 | break; | 518 | break; |
517 | default: | 519 | default: |
518 | printk(KERN_INFO PFX "Unknown page table size 0x%x, " | 520 | dev_info(&agp_bridge->dev->dev, |
519 | "assuming 512KB\n", | 521 | "unknown page table size 0x%x, assuming 512KB\n", |
520 | (gmch_ctrl & G33_PGETBL_SIZE_MASK)); | 522 | (gmch_ctrl & G33_PGETBL_SIZE_MASK)); |
521 | size = 512; | 523 | size = 512; |
522 | } | 524 | } |
@@ -627,11 +629,11 @@ static void intel_i830_init_gtt_entries(void) | |||
627 | } | 629 | } |
628 | } | 630 | } |
629 | if (gtt_entries > 0) | 631 | if (gtt_entries > 0) |
630 | printk(KERN_INFO PFX "Detected %dK %s memory.\n", | 632 | dev_info(&agp_bridge->dev->dev, "detected %dK %s memory\n", |
631 | gtt_entries / KB(1), local ? "local" : "stolen"); | 633 | gtt_entries / KB(1), local ? "local" : "stolen"); |
632 | else | 634 | else |
633 | printk(KERN_INFO PFX | 635 | dev_info(&agp_bridge->dev->dev, |
634 | "No pre-allocated video memory detected.\n"); | 636 | "no pre-allocated video memory detected\n"); |
635 | gtt_entries /= KB(4); | 637 | gtt_entries /= KB(4); |
636 | 638 | ||
637 | intel_private.gtt_entries = gtt_entries; | 639 | intel_private.gtt_entries = gtt_entries; |
@@ -801,10 +803,12 @@ static int intel_i830_insert_entries(struct agp_memory *mem, off_t pg_start, | |||
801 | num_entries = A_SIZE_FIX(temp)->num_entries; | 803 | num_entries = A_SIZE_FIX(temp)->num_entries; |
802 | 804 | ||
803 | if (pg_start < intel_private.gtt_entries) { | 805 | if (pg_start < intel_private.gtt_entries) { |
804 | printk(KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n", | 806 | dev_printk(KERN_DEBUG, &intel_private.pcidev->dev, |
805 | pg_start, intel_private.gtt_entries); | 807 | "pg_start == 0x%.8lx, intel_private.gtt_entries == 0x%.8x\n", |
808 | pg_start, intel_private.gtt_entries); | ||
806 | 809 | ||
807 | printk(KERN_INFO PFX "Trying to insert into local/stolen memory\n"); | 810 | dev_info(&intel_private.pcidev->dev, |
811 | "trying to insert into local/stolen memory\n"); | ||
808 | goto out_err; | 812 | goto out_err; |
809 | } | 813 | } |
810 | 814 | ||
@@ -851,7 +855,8 @@ static int intel_i830_remove_entries(struct agp_memory *mem, off_t pg_start, | |||
851 | return 0; | 855 | return 0; |
852 | 856 | ||
853 | if (pg_start < intel_private.gtt_entries) { | 857 | if (pg_start < intel_private.gtt_entries) { |
854 | printk(KERN_INFO PFX "Trying to disable local/stolen memory\n"); | 858 | dev_info(&intel_private.pcidev->dev, |
859 | "trying to disable local/stolen memory\n"); | ||
855 | return -EINVAL; | 860 | return -EINVAL; |
856 | } | 861 | } |
857 | 862 | ||
@@ -957,7 +962,7 @@ static void intel_i9xx_setup_flush(void) | |||
957 | if (intel_private.ifp_resource.start) { | 962 | if (intel_private.ifp_resource.start) { |
958 | intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE); | 963 | intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE); |
959 | if (!intel_private.i9xx_flush_page) | 964 | if (!intel_private.i9xx_flush_page) |
960 | printk(KERN_INFO "unable to ioremap flush page - no chipset flushing"); | 965 | dev_info(&intel_private.pcidev->dev, "can't ioremap flush page - no chipset flushing"); |
961 | } | 966 | } |
962 | } | 967 | } |
963 | 968 | ||
@@ -1028,10 +1033,12 @@ static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start, | |||
1028 | num_entries = A_SIZE_FIX(temp)->num_entries; | 1033 | num_entries = A_SIZE_FIX(temp)->num_entries; |
1029 | 1034 | ||
1030 | if (pg_start < intel_private.gtt_entries) { | 1035 | if (pg_start < intel_private.gtt_entries) { |
1031 | printk(KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n", | 1036 | dev_printk(KERN_DEBUG, &intel_private.pcidev->dev, |
1032 | pg_start, intel_private.gtt_entries); | 1037 | "pg_start == 0x%.8lx, intel_private.gtt_entries == 0x%.8x\n", |
1038 | pg_start, intel_private.gtt_entries); | ||
1033 | 1039 | ||
1034 | printk(KERN_INFO PFX "Trying to insert into local/stolen memory\n"); | 1040 | dev_info(&intel_private.pcidev->dev, |
1041 | "trying to insert into local/stolen memory\n"); | ||
1035 | goto out_err; | 1042 | goto out_err; |
1036 | } | 1043 | } |
1037 | 1044 | ||
@@ -1078,7 +1085,8 @@ static int intel_i915_remove_entries(struct agp_memory *mem, off_t pg_start, | |||
1078 | return 0; | 1085 | return 0; |
1079 | 1086 | ||
1080 | if (pg_start < intel_private.gtt_entries) { | 1087 | if (pg_start < intel_private.gtt_entries) { |
1081 | printk(KERN_INFO PFX "Trying to disable local/stolen memory\n"); | 1088 | dev_info(&intel_private.pcidev->dev, |
1089 | "trying to disable local/stolen memory\n"); | ||
1082 | return -EINVAL; | 1090 | return -EINVAL; |
1083 | } | 1091 | } |
1084 | 1092 | ||
@@ -1182,7 +1190,7 @@ static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge, | |||
1182 | static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) | 1190 | static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) |
1183 | { | 1191 | { |
1184 | switch (agp_bridge->dev->device) { | 1192 | switch (agp_bridge->dev->device) { |
1185 | case PCI_DEVICE_ID_INTEL_IGD_HB: | 1193 | case PCI_DEVICE_ID_INTEL_GM45_HB: |
1186 | case PCI_DEVICE_ID_INTEL_IGD_E_HB: | 1194 | case PCI_DEVICE_ID_INTEL_IGD_E_HB: |
1187 | case PCI_DEVICE_ID_INTEL_Q45_HB: | 1195 | case PCI_DEVICE_ID_INTEL_Q45_HB: |
1188 | case PCI_DEVICE_ID_INTEL_G45_HB: | 1196 | case PCI_DEVICE_ID_INTEL_G45_HB: |
@@ -1379,7 +1387,7 @@ static int intel_815_configure(void) | |||
1379 | /* the Intel 815 chipset spec. says that bits 29-31 in the | 1387 | /* the Intel 815 chipset spec. says that bits 29-31 in the |
1380 | * ATTBASE register are reserved -> try not to write them */ | 1388 | * ATTBASE register are reserved -> try not to write them */ |
1381 | if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) { | 1389 | if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) { |
1382 | printk(KERN_EMERG PFX "gatt bus addr too high"); | 1390 | dev_emerg(&agp_bridge->dev->dev, "gatt bus addr too high"); |
1383 | return -EINVAL; | 1391 | return -EINVAL; |
1384 | } | 1392 | } |
1385 | 1393 | ||
@@ -2117,8 +2125,8 @@ static const struct intel_driver_description { | |||
2117 | NULL, &intel_g33_driver }, | 2125 | NULL, &intel_g33_driver }, |
2118 | { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33", | 2126 | { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33", |
2119 | NULL, &intel_g33_driver }, | 2127 | NULL, &intel_g33_driver }, |
2120 | { PCI_DEVICE_ID_INTEL_IGD_HB, PCI_DEVICE_ID_INTEL_IGD_IG, 0, | 2128 | { PCI_DEVICE_ID_INTEL_GM45_HB, PCI_DEVICE_ID_INTEL_GM45_IG, 0, |
2121 | "Intel Integrated Graphics Device", NULL, &intel_i965_driver }, | 2129 | "Mobile Intel? GM45 Express", NULL, &intel_i965_driver }, |
2122 | { PCI_DEVICE_ID_INTEL_IGD_E_HB, PCI_DEVICE_ID_INTEL_IGD_E_IG, 0, | 2130 | { PCI_DEVICE_ID_INTEL_IGD_E_HB, PCI_DEVICE_ID_INTEL_IGD_E_IG, 0, |
2123 | "Intel Integrated Graphics Device", NULL, &intel_i965_driver }, | 2131 | "Intel Integrated Graphics Device", NULL, &intel_i965_driver }, |
2124 | { PCI_DEVICE_ID_INTEL_Q45_HB, PCI_DEVICE_ID_INTEL_Q45_IG, 0, | 2132 | { PCI_DEVICE_ID_INTEL_Q45_HB, PCI_DEVICE_ID_INTEL_Q45_IG, 0, |
@@ -2163,8 +2171,8 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, | |||
2163 | 2171 | ||
2164 | if (intel_agp_chipsets[i].name == NULL) { | 2172 | if (intel_agp_chipsets[i].name == NULL) { |
2165 | if (cap_ptr) | 2173 | if (cap_ptr) |
2166 | printk(KERN_WARNING PFX "Unsupported Intel chipset" | 2174 | dev_warn(&pdev->dev, "unsupported Intel chipset [%04x/%04x]\n", |
2167 | "(device id: %04x)\n", pdev->device); | 2175 | pdev->vendor, pdev->device); |
2168 | agp_put_bridge(bridge); | 2176 | agp_put_bridge(bridge); |
2169 | return -ENODEV; | 2177 | return -ENODEV; |
2170 | } | 2178 | } |
@@ -2172,9 +2180,8 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, | |||
2172 | if (bridge->driver == NULL) { | 2180 | if (bridge->driver == NULL) { |
2173 | /* bridge has no AGP and no IGD detected */ | 2181 | /* bridge has no AGP and no IGD detected */ |
2174 | if (cap_ptr) | 2182 | if (cap_ptr) |
2175 | printk(KERN_WARNING PFX "Failed to find bridge device " | 2183 | dev_warn(&pdev->dev, "can't find bridge device (chip_id: %04x)\n", |
2176 | "(chip_id: %04x)\n", | 2184 | intel_agp_chipsets[i].gmch_chip_id); |
2177 | intel_agp_chipsets[i].gmch_chip_id); | ||
2178 | agp_put_bridge(bridge); | 2185 | agp_put_bridge(bridge); |
2179 | return -ENODEV; | 2186 | return -ENODEV; |
2180 | } | 2187 | } |
@@ -2183,8 +2190,7 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, | |||
2183 | bridge->capndx = cap_ptr; | 2190 | bridge->capndx = cap_ptr; |
2184 | bridge->dev_private_data = &intel_private; | 2191 | bridge->dev_private_data = &intel_private; |
2185 | 2192 | ||
2186 | printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n", | 2193 | dev_info(&pdev->dev, "Intel %s Chipset\n", intel_agp_chipsets[i].name); |
2187 | intel_agp_chipsets[i].name); | ||
2188 | 2194 | ||
2189 | /* | 2195 | /* |
2190 | * The following fixes the case where the BIOS has "forgotten" to | 2196 | * The following fixes the case where the BIOS has "forgotten" to |
@@ -2194,7 +2200,7 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, | |||
2194 | r = &pdev->resource[0]; | 2200 | r = &pdev->resource[0]; |
2195 | if (!r->start && r->end) { | 2201 | if (!r->start && r->end) { |
2196 | if (pci_assign_resource(pdev, 0)) { | 2202 | if (pci_assign_resource(pdev, 0)) { |
2197 | printk(KERN_ERR PFX "could not assign resource 0\n"); | 2203 | dev_err(&pdev->dev, "can't assign resource 0\n"); |
2198 | agp_put_bridge(bridge); | 2204 | agp_put_bridge(bridge); |
2199 | return -ENODEV; | 2205 | return -ENODEV; |
2200 | } | 2206 | } |
@@ -2206,7 +2212,7 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, | |||
2206 | * 20030610 - hamish@zot.org | 2212 | * 20030610 - hamish@zot.org |
2207 | */ | 2213 | */ |
2208 | if (pci_enable_device(pdev)) { | 2214 | if (pci_enable_device(pdev)) { |
2209 | printk(KERN_ERR PFX "Unable to Enable PCI device\n"); | 2215 | dev_err(&pdev->dev, "can't enable PCI device\n"); |
2210 | agp_put_bridge(bridge); | 2216 | agp_put_bridge(bridge); |
2211 | return -ENODEV; | 2217 | return -ENODEV; |
2212 | } | 2218 | } |
@@ -2238,6 +2244,7 @@ static void __devexit agp_intel_remove(struct pci_dev *pdev) | |||
2238 | static int agp_intel_resume(struct pci_dev *pdev) | 2244 | static int agp_intel_resume(struct pci_dev *pdev) |
2239 | { | 2245 | { |
2240 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); | 2246 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); |
2247 | int ret_val; | ||
2241 | 2248 | ||
2242 | pci_restore_state(pdev); | 2249 | pci_restore_state(pdev); |
2243 | 2250 | ||
@@ -2265,6 +2272,10 @@ static int agp_intel_resume(struct pci_dev *pdev) | |||
2265 | else if (bridge->driver == &intel_i965_driver) | 2272 | else if (bridge->driver == &intel_i965_driver) |
2266 | intel_i915_configure(); | 2273 | intel_i915_configure(); |
2267 | 2274 | ||
2275 | ret_val = agp_rebind_memory(); | ||
2276 | if (ret_val != 0) | ||
2277 | return ret_val; | ||
2278 | |||
2268 | return 0; | 2279 | return 0; |
2269 | } | 2280 | } |
2270 | #endif | 2281 | #endif |
@@ -2315,7 +2326,7 @@ static struct pci_device_id agp_intel_pci_table[] = { | |||
2315 | ID(PCI_DEVICE_ID_INTEL_G33_HB), | 2326 | ID(PCI_DEVICE_ID_INTEL_G33_HB), |
2316 | ID(PCI_DEVICE_ID_INTEL_Q35_HB), | 2327 | ID(PCI_DEVICE_ID_INTEL_Q35_HB), |
2317 | ID(PCI_DEVICE_ID_INTEL_Q33_HB), | 2328 | ID(PCI_DEVICE_ID_INTEL_Q33_HB), |
2318 | ID(PCI_DEVICE_ID_INTEL_IGD_HB), | 2329 | ID(PCI_DEVICE_ID_INTEL_GM45_HB), |
2319 | ID(PCI_DEVICE_ID_INTEL_IGD_E_HB), | 2330 | ID(PCI_DEVICE_ID_INTEL_IGD_E_HB), |
2320 | ID(PCI_DEVICE_ID_INTEL_Q45_HB), | 2331 | ID(PCI_DEVICE_ID_INTEL_Q45_HB), |
2321 | ID(PCI_DEVICE_ID_INTEL_G45_HB), | 2332 | ID(PCI_DEVICE_ID_INTEL_G45_HB), |
diff --git a/drivers/char/agp/isoch.c b/drivers/char/agp/isoch.c index 3f9ccde62377..c73385cc4b8a 100644 --- a/drivers/char/agp/isoch.c +++ b/drivers/char/agp/isoch.c | |||
@@ -153,7 +153,7 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge, | |||
153 | 153 | ||
154 | /* Check if this configuration has any chance of working */ | 154 | /* Check if this configuration has any chance of working */ |
155 | if (tot_bw > target.maxbw) { | 155 | if (tot_bw > target.maxbw) { |
156 | printk(KERN_ERR PFX "isochronous bandwidth required " | 156 | dev_err(&td->dev, "isochronous bandwidth required " |
157 | "by AGP 3.0 devices exceeds that which is supported by " | 157 | "by AGP 3.0 devices exceeds that which is supported by " |
158 | "the AGP 3.0 bridge!\n"); | 158 | "the AGP 3.0 bridge!\n"); |
159 | ret = -ENODEV; | 159 | ret = -ENODEV; |
@@ -188,7 +188,7 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge, | |||
188 | /* Exit if the minimal ISOCH_N allocation among the masters is more | 188 | /* Exit if the minimal ISOCH_N allocation among the masters is more |
189 | * than the target can handle. */ | 189 | * than the target can handle. */ |
190 | if (tot_n > target.n) { | 190 | if (tot_n > target.n) { |
191 | printk(KERN_ERR PFX "number of isochronous " | 191 | dev_err(&td->dev, "number of isochronous " |
192 | "transactions per period required by AGP 3.0 devices " | 192 | "transactions per period required by AGP 3.0 devices " |
193 | "exceeds that which is supported by the AGP 3.0 " | 193 | "exceeds that which is supported by the AGP 3.0 " |
194 | "bridge!\n"); | 194 | "bridge!\n"); |
@@ -229,7 +229,7 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge, | |||
229 | /* Exit if the minimal RQ needs of the masters exceeds what the target | 229 | /* Exit if the minimal RQ needs of the masters exceeds what the target |
230 | * can provide. */ | 230 | * can provide. */ |
231 | if (tot_rq > rq_isoch) { | 231 | if (tot_rq > rq_isoch) { |
232 | printk(KERN_ERR PFX "number of request queue slots " | 232 | dev_err(&td->dev, "number of request queue slots " |
233 | "required by the isochronous bandwidth requested by " | 233 | "required by the isochronous bandwidth requested by " |
234 | "AGP 3.0 devices exceeds the number provided by the " | 234 | "AGP 3.0 devices exceeds the number provided by the " |
235 | "AGP 3.0 bridge!\n"); | 235 | "AGP 3.0 bridge!\n"); |
@@ -359,8 +359,9 @@ int agp_3_5_enable(struct agp_bridge_data *bridge) | |||
359 | case 0x0001: /* Unclassified device */ | 359 | case 0x0001: /* Unclassified device */ |
360 | /* Don't know what this is, but log it for investigation. */ | 360 | /* Don't know what this is, but log it for investigation. */ |
361 | if (mcapndx != 0) { | 361 | if (mcapndx != 0) { |
362 | printk (KERN_INFO PFX "Wacky, found unclassified AGP device. %x:%x\n", | 362 | dev_info(&td->dev, "wacky, found unclassified AGP device %s [%04x/%04x]\n", |
363 | dev->vendor, dev->device); | 363 | pci_name(dev), |
364 | dev->vendor, dev->device); | ||
364 | } | 365 | } |
365 | continue; | 366 | continue; |
366 | 367 | ||
@@ -407,17 +408,18 @@ int agp_3_5_enable(struct agp_bridge_data *bridge) | |||
407 | } | 408 | } |
408 | 409 | ||
409 | if (mcapndx == 0) { | 410 | if (mcapndx == 0) { |
410 | printk(KERN_ERR PFX "woah! Non-AGP device " | 411 | dev_err(&td->dev, "woah! Non-AGP device %s on " |
411 | "found on the secondary bus of an AGP 3.5 bridge!\n"); | 412 | "secondary bus of AGP 3.5 bridge!\n", |
413 | pci_name(dev)); | ||
412 | ret = -ENODEV; | 414 | ret = -ENODEV; |
413 | goto free_and_exit; | 415 | goto free_and_exit; |
414 | } | 416 | } |
415 | 417 | ||
416 | mmajor = (ncapid >> AGP_MAJOR_VERSION_SHIFT) & 0xf; | 418 | mmajor = (ncapid >> AGP_MAJOR_VERSION_SHIFT) & 0xf; |
417 | if (mmajor < 3) { | 419 | if (mmajor < 3) { |
418 | printk(KERN_ERR PFX "woah! AGP 2.0 device " | 420 | dev_err(&td->dev, "woah! AGP 2.0 device %s on " |
419 | "found on the secondary bus of an AGP 3.5 " | 421 | "secondary bus of AGP 3.5 bridge operating " |
420 | "bridge operating with AGP 3.0 electricals!\n"); | 422 | "with AGP 3.0 electricals!\n", pci_name(dev)); |
421 | ret = -ENODEV; | 423 | ret = -ENODEV; |
422 | goto free_and_exit; | 424 | goto free_and_exit; |
423 | } | 425 | } |
@@ -427,10 +429,10 @@ int agp_3_5_enable(struct agp_bridge_data *bridge) | |||
427 | pci_read_config_dword(dev, cur->capndx+AGPSTAT, &mstatus); | 429 | pci_read_config_dword(dev, cur->capndx+AGPSTAT, &mstatus); |
428 | 430 | ||
429 | if (((mstatus >> 3) & 0x1) == 0) { | 431 | if (((mstatus >> 3) & 0x1) == 0) { |
430 | printk(KERN_ERR PFX "woah! AGP 3.x device " | 432 | dev_err(&td->dev, "woah! AGP 3.x device %s not " |
431 | "not operating in AGP 3.x mode found on the " | 433 | "operating in AGP 3.x mode on secondary bus " |
432 | "secondary bus of an AGP 3.5 bridge operating " | 434 | "of AGP 3.5 bridge operating with AGP 3.0 " |
433 | "with AGP 3.0 electricals!\n"); | 435 | "electricals!\n", pci_name(dev)); |
434 | ret = -ENODEV; | 436 | ret = -ENODEV; |
435 | goto free_and_exit; | 437 | goto free_and_exit; |
436 | } | 438 | } |
@@ -444,9 +446,9 @@ int agp_3_5_enable(struct agp_bridge_data *bridge) | |||
444 | if (isoch) { | 446 | if (isoch) { |
445 | ret = agp_3_5_isochronous_node_enable(bridge, dev_list, ndevs); | 447 | ret = agp_3_5_isochronous_node_enable(bridge, dev_list, ndevs); |
446 | if (ret) { | 448 | if (ret) { |
447 | printk(KERN_INFO PFX "Something bad happened setting " | 449 | dev_info(&td->dev, "something bad happened setting " |
448 | "up isochronous xfers. Falling back to " | 450 | "up isochronous xfers; falling back to " |
449 | "non-isochronous xfer mode.\n"); | 451 | "non-isochronous xfer mode\n"); |
450 | } else { | 452 | } else { |
451 | goto free_and_exit; | 453 | goto free_and_exit; |
452 | } | 454 | } |
@@ -466,4 +468,3 @@ free_and_exit: | |||
466 | get_out: | 468 | get_out: |
467 | return ret; | 469 | return ret; |
468 | } | 470 | } |
469 | |||
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c index b6791846809f..2587ef96a960 100644 --- a/drivers/char/agp/sis-agp.c +++ b/drivers/char/agp/sis-agp.c | |||
@@ -79,10 +79,8 @@ static void sis_delayed_enable(struct agp_bridge_data *bridge, u32 mode) | |||
79 | u32 command; | 79 | u32 command; |
80 | int rate; | 80 | int rate; |
81 | 81 | ||
82 | printk(KERN_INFO PFX "Found an AGP %d.%d compliant device at %s.\n", | 82 | dev_info(&agp_bridge->dev->dev, "AGP %d.%d bridge\n", |
83 | agp_bridge->major_version, | 83 | agp_bridge->major_version, agp_bridge->minor_version); |
84 | agp_bridge->minor_version, | ||
85 | pci_name(agp_bridge->dev)); | ||
86 | 84 | ||
87 | pci_read_config_dword(agp_bridge->dev, agp_bridge->capndx + PCI_AGP_STATUS, &command); | 85 | pci_read_config_dword(agp_bridge->dev, agp_bridge->capndx + PCI_AGP_STATUS, &command); |
88 | command = agp_collect_device_status(bridge, mode, command); | 86 | command = agp_collect_device_status(bridge, mode, command); |
@@ -94,8 +92,8 @@ static void sis_delayed_enable(struct agp_bridge_data *bridge, u32 mode) | |||
94 | if (!agp) | 92 | if (!agp) |
95 | continue; | 93 | continue; |
96 | 94 | ||
97 | printk(KERN_INFO PFX "Putting AGP V3 device at %s into %dx mode\n", | 95 | dev_info(&agp_bridge->dev->dev, "putting AGP V3 device at %s into %dx mode\n", |
98 | pci_name(device), rate); | 96 | pci_name(device), rate); |
99 | 97 | ||
100 | pci_write_config_dword(device, agp + PCI_AGP_COMMAND, command); | 98 | pci_write_config_dword(device, agp + PCI_AGP_COMMAND, command); |
101 | 99 | ||
@@ -105,7 +103,7 @@ static void sis_delayed_enable(struct agp_bridge_data *bridge, u32 mode) | |||
105 | * cannot be configured | 103 | * cannot be configured |
106 | */ | 104 | */ |
107 | if (device->device == bridge->dev->device) { | 105 | if (device->device == bridge->dev->device) { |
108 | printk(KERN_INFO PFX "SiS delay workaround: giving bridge time to recover.\n"); | 106 | dev_info(&agp_bridge->dev->dev, "SiS delay workaround: giving bridge time to recover\n"); |
109 | msleep(10); | 107 | msleep(10); |
110 | } | 108 | } |
111 | } | 109 | } |
@@ -190,7 +188,8 @@ static int __devinit agp_sis_probe(struct pci_dev *pdev, | |||
190 | return -ENODEV; | 188 | return -ENODEV; |
191 | 189 | ||
192 | 190 | ||
193 | printk(KERN_INFO PFX "Detected SiS chipset - id:%i\n", pdev->device); | 191 | dev_info(&pdev->dev, "SiS chipset [%04x/%04x]\n", |
192 | pdev->vendor, pdev->device); | ||
194 | bridge = agp_alloc_bridge(); | 193 | bridge = agp_alloc_bridge(); |
195 | if (!bridge) | 194 | if (!bridge) |
196 | return -ENOMEM; | 195 | return -ENOMEM; |
@@ -242,7 +241,7 @@ static struct pci_device_id agp_sis_pci_table[] = { | |||
242 | .class = (PCI_CLASS_BRIDGE_HOST << 8), | 241 | .class = (PCI_CLASS_BRIDGE_HOST << 8), |
243 | .class_mask = ~0, | 242 | .class_mask = ~0, |
244 | .vendor = PCI_VENDOR_ID_SI, | 243 | .vendor = PCI_VENDOR_ID_SI, |
245 | .device = PCI_DEVICE_ID_SI_5591_AGP, | 244 | .device = PCI_DEVICE_ID_SI_5591, |
246 | .subvendor = PCI_ANY_ID, | 245 | .subvendor = PCI_ANY_ID, |
247 | .subdevice = PCI_ANY_ID, | 246 | .subdevice = PCI_ANY_ID, |
248 | }, | 247 | }, |
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c index 0e054c134490..2fb27fe4c10c 100644 --- a/drivers/char/agp/sworks-agp.c +++ b/drivers/char/agp/sworks-agp.c | |||
@@ -241,7 +241,8 @@ static void serverworks_tlbflush(struct agp_memory *temp) | |||
241 | while (readb(serverworks_private.registers+SVWRKS_POSTFLUSH) == 1) { | 241 | while (readb(serverworks_private.registers+SVWRKS_POSTFLUSH) == 1) { |
242 | cpu_relax(); | 242 | cpu_relax(); |
243 | if (time_after(jiffies, timeout)) { | 243 | if (time_after(jiffies, timeout)) { |
244 | printk(KERN_ERR PFX "TLB post flush took more than 3 seconds\n"); | 244 | dev_err(&serverworks_private.svrwrks_dev->dev, |
245 | "TLB post flush took more than 3 seconds\n"); | ||
245 | break; | 246 | break; |
246 | } | 247 | } |
247 | } | 248 | } |
@@ -251,7 +252,8 @@ static void serverworks_tlbflush(struct agp_memory *temp) | |||
251 | while (readl(serverworks_private.registers+SVWRKS_DIRFLUSH) == 1) { | 252 | while (readl(serverworks_private.registers+SVWRKS_DIRFLUSH) == 1) { |
252 | cpu_relax(); | 253 | cpu_relax(); |
253 | if (time_after(jiffies, timeout)) { | 254 | if (time_after(jiffies, timeout)) { |
254 | printk(KERN_ERR PFX "TLB Dir flush took more than 3 seconds\n"); | 255 | dev_err(&serverworks_private.svrwrks_dev->dev, |
256 | "TLB Dir flush took more than 3 seconds\n"); | ||
255 | break; | 257 | break; |
256 | } | 258 | } |
257 | } | 259 | } |
@@ -271,7 +273,7 @@ static int serverworks_configure(void) | |||
271 | temp = (temp & PCI_BASE_ADDRESS_MEM_MASK); | 273 | temp = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
272 | serverworks_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096); | 274 | serverworks_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096); |
273 | if (!serverworks_private.registers) { | 275 | if (!serverworks_private.registers) { |
274 | printk (KERN_ERR PFX "Unable to ioremap() memory.\n"); | 276 | dev_err(&agp_bridge->dev->dev, "can't ioremap(%#x)\n", temp); |
275 | return -ENOMEM; | 277 | return -ENOMEM; |
276 | } | 278 | } |
277 | 279 | ||
@@ -451,7 +453,7 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev, | |||
451 | 453 | ||
452 | switch (pdev->device) { | 454 | switch (pdev->device) { |
453 | case 0x0006: | 455 | case 0x0006: |
454 | printk (KERN_ERR PFX "ServerWorks CNB20HE is unsupported due to lack of documentation.\n"); | 456 | dev_err(&pdev->dev, "ServerWorks CNB20HE is unsupported due to lack of documentation\n"); |
455 | return -ENODEV; | 457 | return -ENODEV; |
456 | 458 | ||
457 | case PCI_DEVICE_ID_SERVERWORKS_HE: | 459 | case PCI_DEVICE_ID_SERVERWORKS_HE: |
@@ -461,8 +463,8 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev, | |||
461 | 463 | ||
462 | default: | 464 | default: |
463 | if (cap_ptr) | 465 | if (cap_ptr) |
464 | printk(KERN_ERR PFX "Unsupported Serverworks chipset " | 466 | dev_err(&pdev->dev, "unsupported Serverworks chipset " |
465 | "(device id: %04x)\n", pdev->device); | 467 | "[%04x/%04x]\n", pdev->vendor, pdev->device); |
466 | return -ENODEV; | 468 | return -ENODEV; |
467 | } | 469 | } |
468 | 470 | ||
@@ -470,8 +472,7 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev, | |||
470 | bridge_dev = pci_get_bus_and_slot((unsigned int)pdev->bus->number, | 472 | bridge_dev = pci_get_bus_and_slot((unsigned int)pdev->bus->number, |
471 | PCI_DEVFN(0, 1)); | 473 | PCI_DEVFN(0, 1)); |
472 | if (!bridge_dev) { | 474 | if (!bridge_dev) { |
473 | printk(KERN_INFO PFX "Detected a Serverworks chipset " | 475 | dev_info(&pdev->dev, "can't find secondary device\n"); |
474 | "but could not find the secondary device.\n"); | ||
475 | return -ENODEV; | 476 | return -ENODEV; |
476 | } | 477 | } |
477 | 478 | ||
@@ -482,8 +483,8 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev, | |||
482 | if (temp & PCI_BASE_ADDRESS_MEM_TYPE_64) { | 483 | if (temp & PCI_BASE_ADDRESS_MEM_TYPE_64) { |
483 | pci_read_config_dword(pdev, SVWRKS_APSIZE + 4, &temp2); | 484 | pci_read_config_dword(pdev, SVWRKS_APSIZE + 4, &temp2); |
484 | if (temp2 != 0) { | 485 | if (temp2 != 0) { |
485 | printk(KERN_INFO PFX "Detected 64 bit aperture address, " | 486 | dev_info(&pdev->dev, "64 bit aperture address, " |
486 | "but top bits are not zero. Disabling agp\n"); | 487 | "but top bits are not zero; disabling AGP\n"); |
487 | return -ENODEV; | 488 | return -ENODEV; |
488 | } | 489 | } |
489 | serverworks_private.mm_addr_ofs = 0x18; | 490 | serverworks_private.mm_addr_ofs = 0x18; |
@@ -495,8 +496,8 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev, | |||
495 | pci_read_config_dword(pdev, | 496 | pci_read_config_dword(pdev, |
496 | serverworks_private.mm_addr_ofs + 4, &temp2); | 497 | serverworks_private.mm_addr_ofs + 4, &temp2); |
497 | if (temp2 != 0) { | 498 | if (temp2 != 0) { |
498 | printk(KERN_INFO PFX "Detected 64 bit MMIO address, " | 499 | dev_info(&pdev->dev, "64 bit MMIO address, but top " |
499 | "but top bits are not zero. Disabling agp\n"); | 500 | "bits are not zero; disabling AGP\n"); |
500 | return -ENODEV; | 501 | return -ENODEV; |
501 | } | 502 | } |
502 | } | 503 | } |
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index d2fa3cfca02a..eef72709ec53 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c | |||
@@ -46,8 +46,8 @@ static int uninorth_fetch_size(void) | |||
46 | break; | 46 | break; |
47 | 47 | ||
48 | if (i == agp_bridge->driver->num_aperture_sizes) { | 48 | if (i == agp_bridge->driver->num_aperture_sizes) { |
49 | printk(KERN_ERR PFX "Invalid aperture size, using" | 49 | dev_err(&agp_bridge->dev->dev, "invalid aperture size, " |
50 | " default\n"); | 50 | "using default\n"); |
51 | size = 0; | 51 | size = 0; |
52 | aperture = NULL; | 52 | aperture = NULL; |
53 | } | 53 | } |
@@ -108,8 +108,8 @@ static int uninorth_configure(void) | |||
108 | 108 | ||
109 | current_size = A_SIZE_32(agp_bridge->current_size); | 109 | current_size = A_SIZE_32(agp_bridge->current_size); |
110 | 110 | ||
111 | printk(KERN_INFO PFX "configuring for size idx: %d\n", | 111 | dev_info(&agp_bridge->dev->dev, "configuring for size idx: %d\n", |
112 | current_size->size_value); | 112 | current_size->size_value); |
113 | 113 | ||
114 | /* aperture size and gatt addr */ | 114 | /* aperture size and gatt addr */ |
115 | pci_write_config_dword(agp_bridge->dev, | 115 | pci_write_config_dword(agp_bridge->dev, |
@@ -197,8 +197,9 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
197 | gp = (u32 *) &agp_bridge->gatt_table[pg_start]; | 197 | gp = (u32 *) &agp_bridge->gatt_table[pg_start]; |
198 | for (i = 0; i < mem->page_count; ++i) { | 198 | for (i = 0; i < mem->page_count; ++i) { |
199 | if (gp[i]) { | 199 | if (gp[i]) { |
200 | printk("u3_insert_memory: entry 0x%x occupied (%x)\n", | 200 | dev_info(&agp_bridge->dev->dev, |
201 | i, gp[i]); | 201 | "u3_insert_memory: entry 0x%x occupied (%x)\n", |
202 | i, gp[i]); | ||
202 | return -EBUSY; | 203 | return -EBUSY; |
203 | } | 204 | } |
204 | } | 205 | } |
@@ -276,8 +277,8 @@ static void uninorth_agp_enable(struct agp_bridge_data *bridge, u32 mode) | |||
276 | &scratch); | 277 | &scratch); |
277 | } while ((scratch & PCI_AGP_COMMAND_AGP) == 0 && ++timeout < 1000); | 278 | } while ((scratch & PCI_AGP_COMMAND_AGP) == 0 && ++timeout < 1000); |
278 | if ((scratch & PCI_AGP_COMMAND_AGP) == 0) | 279 | if ((scratch & PCI_AGP_COMMAND_AGP) == 0) |
279 | printk(KERN_ERR PFX "failed to write UniNorth AGP" | 280 | dev_err(&bridge->dev->dev, "can't write UniNorth AGP " |
280 | " command register\n"); | 281 | "command register\n"); |
281 | 282 | ||
282 | if (uninorth_rev >= 0x30) { | 283 | if (uninorth_rev >= 0x30) { |
283 | /* This is an AGP V3 */ | 284 | /* This is an AGP V3 */ |
@@ -330,8 +331,8 @@ static int agp_uninorth_suspend(struct pci_dev *pdev) | |||
330 | pci_read_config_dword(device, agp + PCI_AGP_COMMAND, &cmd); | 331 | pci_read_config_dword(device, agp + PCI_AGP_COMMAND, &cmd); |
331 | if (!(cmd & PCI_AGP_COMMAND_AGP)) | 332 | if (!(cmd & PCI_AGP_COMMAND_AGP)) |
332 | continue; | 333 | continue; |
333 | printk("uninorth-agp: disabling AGP on device %s\n", | 334 | dev_info(&pdev->dev, "disabling AGP on device %s\n", |
334 | pci_name(device)); | 335 | pci_name(device)); |
335 | cmd &= ~PCI_AGP_COMMAND_AGP; | 336 | cmd &= ~PCI_AGP_COMMAND_AGP; |
336 | pci_write_config_dword(device, agp + PCI_AGP_COMMAND, cmd); | 337 | pci_write_config_dword(device, agp + PCI_AGP_COMMAND, cmd); |
337 | } | 338 | } |
@@ -341,8 +342,7 @@ static int agp_uninorth_suspend(struct pci_dev *pdev) | |||
341 | pci_read_config_dword(pdev, agp + PCI_AGP_COMMAND, &cmd); | 342 | pci_read_config_dword(pdev, agp + PCI_AGP_COMMAND, &cmd); |
342 | bridge->dev_private_data = (void *)(long)cmd; | 343 | bridge->dev_private_data = (void *)(long)cmd; |
343 | if (cmd & PCI_AGP_COMMAND_AGP) { | 344 | if (cmd & PCI_AGP_COMMAND_AGP) { |
344 | printk("uninorth-agp: disabling AGP on bridge %s\n", | 345 | dev_info(&pdev->dev, "disabling AGP on bridge\n"); |
345 | pci_name(pdev)); | ||
346 | cmd &= ~PCI_AGP_COMMAND_AGP; | 346 | cmd &= ~PCI_AGP_COMMAND_AGP; |
347 | pci_write_config_dword(pdev, agp + PCI_AGP_COMMAND, cmd); | 347 | pci_write_config_dword(pdev, agp + PCI_AGP_COMMAND, cmd); |
348 | } | 348 | } |
@@ -591,14 +591,14 @@ static int __devinit agp_uninorth_probe(struct pci_dev *pdev, | |||
591 | /* probe for known chipsets */ | 591 | /* probe for known chipsets */ |
592 | for (j = 0; devs[j].chipset_name != NULL; ++j) { | 592 | for (j = 0; devs[j].chipset_name != NULL; ++j) { |
593 | if (pdev->device == devs[j].device_id) { | 593 | if (pdev->device == devs[j].device_id) { |
594 | printk(KERN_INFO PFX "Detected Apple %s chipset\n", | 594 | dev_info(&pdev->dev, "Apple %s chipset\n", |
595 | devs[j].chipset_name); | 595 | devs[j].chipset_name); |
596 | goto found; | 596 | goto found; |
597 | } | 597 | } |
598 | } | 598 | } |
599 | 599 | ||
600 | printk(KERN_ERR PFX "Unsupported Apple chipset (device id: %04x).\n", | 600 | dev_err(&pdev->dev, "unsupported Apple chipset [%04x/%04x]\n", |
601 | pdev->device); | 601 | pdev->vendor, pdev->device); |
602 | return -ENODEV; | 602 | return -ENODEV; |
603 | 603 | ||
604 | found: | 604 | found: |
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index 3530ff417a51..6e763e3f5a81 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c | |||
@@ -1254,7 +1254,7 @@ static int rs_break(struct tty_struct *tty, int break_state) | |||
1254 | unsigned long flags; | 1254 | unsigned long flags; |
1255 | 1255 | ||
1256 | if (serial_paranoia_check(info, tty->name, "rs_break")) | 1256 | if (serial_paranoia_check(info, tty->name, "rs_break")) |
1257 | return; | 1257 | return -EINVAL; |
1258 | 1258 | ||
1259 | local_irq_save(flags); | 1259 | local_irq_save(flags); |
1260 | if (break_state == -1) | 1260 | if (break_state == -1) |
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c index 34275c6f1da2..74e9cd81b5b2 100644 --- a/drivers/char/ds1620.c +++ b/drivers/char/ds1620.c | |||
@@ -10,7 +10,7 @@ | |||
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/smp_lock.h> | 11 | #include <linux/smp_lock.h> |
12 | 12 | ||
13 | #include <asm/hardware.h> | 13 | #include <mach/hardware.h> |
14 | #include <asm/mach-types.h> | 14 | #include <asm/mach-types.h> |
15 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
16 | #include <asm/therm.h> | 16 | #include <asm/therm.h> |
diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c index 67fbd7aab5db..34d15d548236 100644 --- a/drivers/char/efirtc.c +++ b/drivers/char/efirtc.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/rtc.h> | 37 | #include <linux/rtc.h> |
38 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
39 | #include <linux/efi.h> | 39 | #include <linux/efi.h> |
40 | #include <linux/smp_lock.h> | ||
41 | #include <linux/uaccess.h> | 40 | #include <linux/uaccess.h> |
42 | 41 | ||
43 | #include <asm/system.h> | 42 | #include <asm/system.h> |
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 02aac104842d..fd64137b1ab9 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -322,11 +322,10 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) | |||
322 | 322 | ||
323 | hp->tty = tty; | 323 | hp->tty = tty; |
324 | 324 | ||
325 | if (hp->ops->notifier_add) | ||
326 | rc = hp->ops->notifier_add(hp, hp->data); | ||
327 | |||
328 | spin_unlock_irqrestore(&hp->lock, flags); | 325 | spin_unlock_irqrestore(&hp->lock, flags); |
329 | 326 | ||
327 | if (hp->ops->notifier_add) | ||
328 | rc = hp->ops->notifier_add(hp, hp->data); | ||
330 | 329 | ||
331 | /* | 330 | /* |
332 | * If the notifier fails we return an error. The tty layer | 331 | * If the notifier fails we return an error. The tty layer |
diff --git a/drivers/char/hvc_console.h b/drivers/char/hvc_console.h index d9ce10915625..9790201718ae 100644 --- a/drivers/char/hvc_console.h +++ b/drivers/char/hvc_console.h | |||
@@ -6,7 +6,7 @@ | |||
6 | * Ryan S. Arnold <rsa@us.ibm.com> | 6 | * Ryan S. Arnold <rsa@us.ibm.com> |
7 | * | 7 | * |
8 | * hvc_console header information: | 8 | * hvc_console header information: |
9 | * moved here from include/asm-powerpc/hvconsole.h | 9 | * moved here from arch/powerpc/include/asm/hvconsole.h |
10 | * and drivers/char/hvc_console.c | 10 | * and drivers/char/hvc_console.c |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or modify | 12 | * This program is free software; you can redistribute it and/or modify |
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c index 786d518e9477..473d9b14439a 100644 --- a/drivers/char/hvcs.c +++ b/drivers/char/hvcs.c | |||
@@ -114,7 +114,7 @@ | |||
114 | * the hvcs_final_close() function in order to get it out of the spinlock. | 114 | * the hvcs_final_close() function in order to get it out of the spinlock. |
115 | * Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping | 115 | * Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping |
116 | * on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from | 116 | * on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from |
117 | * include/asm-powerpc/hvcserver.h | 117 | * arch/powerepc/include/asm/hvcserver.h |
118 | * | 118 | * |
119 | * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to | 119 | * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to |
120 | * prevent possible lockup with realtime scheduling as similarily pointed out by | 120 | * prevent possible lockup with realtime scheduling as similarily pointed out by |
diff --git a/drivers/char/hw_random/ixp4xx-rng.c b/drivers/char/hw_random/ixp4xx-rng.c index bab43ca32ac1..263567f5f392 100644 --- a/drivers/char/hw_random/ixp4xx-rng.c +++ b/drivers/char/hw_random/ixp4xx-rng.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/hw_random.h> | 23 | #include <linux/hw_random.h> |
24 | 24 | ||
25 | #include <asm/io.h> | 25 | #include <asm/io.h> |
26 | #include <asm/hardware.h> | 26 | #include <mach/hardware.h> |
27 | 27 | ||
28 | 28 | ||
29 | static int ixp4xx_rng_data_read(struct hwrng *rng, u32 *buffer) | 29 | static int ixp4xx_rng_data_read(struct hwrng *rng, u32 *buffer) |
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c index f7feae4ebb5e..128202e18fc9 100644 --- a/drivers/char/hw_random/via-rng.c +++ b/drivers/char/hw_random/via-rng.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <asm/io.h> | 31 | #include <asm/io.h> |
32 | #include <asm/msr.h> | 32 | #include <asm/msr.h> |
33 | #include <asm/cpufeature.h> | 33 | #include <asm/cpufeature.h> |
34 | #include <asm/i387.h> | ||
34 | 35 | ||
35 | 36 | ||
36 | #define PFX KBUILD_MODNAME ": " | 37 | #define PFX KBUILD_MODNAME ": " |
@@ -67,16 +68,23 @@ enum { | |||
67 | * Another possible performance boost may come from simply buffering | 68 | * Another possible performance boost may come from simply buffering |
68 | * until we have 4 bytes, thus returning a u32 at a time, | 69 | * until we have 4 bytes, thus returning a u32 at a time, |
69 | * instead of the current u8-at-a-time. | 70 | * instead of the current u8-at-a-time. |
71 | * | ||
72 | * Padlock instructions can generate a spurious DNA fault, so | ||
73 | * we have to call them in the context of irq_ts_save/restore() | ||
70 | */ | 74 | */ |
71 | 75 | ||
72 | static inline u32 xstore(u32 *addr, u32 edx_in) | 76 | static inline u32 xstore(u32 *addr, u32 edx_in) |
73 | { | 77 | { |
74 | u32 eax_out; | 78 | u32 eax_out; |
79 | int ts_state; | ||
80 | |||
81 | ts_state = irq_ts_save(); | ||
75 | 82 | ||
76 | asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */" | 83 | asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */" |
77 | :"=m"(*addr), "=a"(eax_out) | 84 | :"=m"(*addr), "=a"(eax_out) |
78 | :"D"(addr), "d"(edx_in)); | 85 | :"D"(addr), "d"(edx_in)); |
79 | 86 | ||
87 | irq_ts_restore(ts_state); | ||
80 | return eax_out; | 88 | return eax_out; |
81 | } | 89 | } |
82 | 90 | ||
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 192688344ed2..8e8afb6141f9 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -66,8 +66,8 @@ | |||
66 | #include <linux/ctype.h> | 66 | #include <linux/ctype.h> |
67 | 67 | ||
68 | #ifdef CONFIG_PPC_OF | 68 | #ifdef CONFIG_PPC_OF |
69 | #include <asm/of_device.h> | 69 | #include <linux/of_device.h> |
70 | #include <asm/of_platform.h> | 70 | #include <linux/of_platform.h> |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #define PFX "ipmi_si: " | 73 | #define PFX "ipmi_si: " |
@@ -2695,15 +2695,13 @@ static __devinit void default_find_bmc(void) | |||
2695 | for (i = 0; ; i++) { | 2695 | for (i = 0; ; i++) { |
2696 | if (!ipmi_defaults[i].port) | 2696 | if (!ipmi_defaults[i].port) |
2697 | break; | 2697 | break; |
2698 | |||
2699 | info = kzalloc(sizeof(*info), GFP_KERNEL); | ||
2700 | if (!info) | ||
2701 | return; | ||
2702 | |||
2703 | #ifdef CONFIG_PPC_MERGE | 2698 | #ifdef CONFIG_PPC_MERGE |
2704 | if (check_legacy_ioport(ipmi_defaults[i].port)) | 2699 | if (check_legacy_ioport(ipmi_defaults[i].port)) |
2705 | continue; | 2700 | continue; |
2706 | #endif | 2701 | #endif |
2702 | info = kzalloc(sizeof(*info), GFP_KERNEL); | ||
2703 | if (!info) | ||
2704 | return; | ||
2707 | 2705 | ||
2708 | info->addr_source = NULL; | 2706 | info->addr_source = NULL; |
2709 | 2707 | ||
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index e30575e87648..b638403e8e9c 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -1612,8 +1612,10 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) | |||
1612 | 1612 | ||
1613 | switch (cmd) { | 1613 | switch (cmd) { |
1614 | case MOXA_GET_MAJOR: | 1614 | case MOXA_GET_MAJOR: |
1615 | printk(KERN_WARNING "mxser: '%s' uses deprecated ioctl %x, fix " | 1615 | if (printk_ratelimit()) |
1616 | "your userspace\n", current->comm, cmd); | 1616 | printk(KERN_WARNING "mxser: '%s' uses deprecated ioctl " |
1617 | "%x (GET_MAJOR), fix your userspace\n", | ||
1618 | current->comm, cmd); | ||
1617 | return put_user(ttymajor, (int __user *)argp); | 1619 | return put_user(ttymajor, (int __user *)argp); |
1618 | 1620 | ||
1619 | case MOXA_CHKPORTENABLE: | 1621 | case MOXA_CHKPORTENABLE: |
diff --git a/drivers/char/pcmcia/ipwireless/tty.c b/drivers/char/pcmcia/ipwireless/tty.c index b1414507997c..3a23e7694d55 100644 --- a/drivers/char/pcmcia/ipwireless/tty.c +++ b/drivers/char/pcmcia/ipwireless/tty.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/tty_driver.h> | 29 | #include <linux/tty_driver.h> |
30 | #include <linux/tty_flip.h> | 30 | #include <linux/tty_flip.h> |
31 | #include <linux/uaccess.h> | 31 | #include <linux/uaccess.h> |
32 | #include <linux/version.h> | ||
33 | 32 | ||
34 | #include "tty.h" | 33 | #include "tty.h" |
35 | #include "network.h" | 34 | #include "network.h" |
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index d1fceabe3aef..c240562c218b 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -232,7 +232,6 @@ typedef struct _mgslpc_info { | |||
232 | 232 | ||
233 | /* SPPP/Cisco HDLC device parts */ | 233 | /* SPPP/Cisco HDLC device parts */ |
234 | int netcount; | 234 | int netcount; |
235 | int dosyncppp; | ||
236 | spinlock_t netlock; | 235 | spinlock_t netlock; |
237 | 236 | ||
238 | #if SYNCLINK_GENERIC_HDLC | 237 | #if SYNCLINK_GENERIC_HDLC |
@@ -459,13 +458,11 @@ static int ttymajor=0; | |||
459 | 458 | ||
460 | static int debug_level = 0; | 459 | static int debug_level = 0; |
461 | static int maxframe[MAX_DEVICE_COUNT] = {0,}; | 460 | static int maxframe[MAX_DEVICE_COUNT] = {0,}; |
462 | static int dosyncppp[MAX_DEVICE_COUNT] = {1,1,1,1}; | ||
463 | 461 | ||
464 | module_param(break_on_load, bool, 0); | 462 | module_param(break_on_load, bool, 0); |
465 | module_param(ttymajor, int, 0); | 463 | module_param(ttymajor, int, 0); |
466 | module_param(debug_level, int, 0); | 464 | module_param(debug_level, int, 0); |
467 | module_param_array(maxframe, int, NULL, 0); | 465 | module_param_array(maxframe, int, NULL, 0); |
468 | module_param_array(dosyncppp, int, NULL, 0); | ||
469 | 466 | ||
470 | MODULE_LICENSE("GPL"); | 467 | MODULE_LICENSE("GPL"); |
471 | 468 | ||
@@ -2915,7 +2912,6 @@ static void mgslpc_add_device(MGSLPC_INFO *info) | |||
2915 | if (info->line < MAX_DEVICE_COUNT) { | 2912 | if (info->line < MAX_DEVICE_COUNT) { |
2916 | if (maxframe[info->line]) | 2913 | if (maxframe[info->line]) |
2917 | info->max_frame_size = maxframe[info->line]; | 2914 | info->max_frame_size = maxframe[info->line]; |
2918 | info->dosyncppp = dosyncppp[info->line]; | ||
2919 | } | 2915 | } |
2920 | 2916 | ||
2921 | mgslpc_device_count++; | 2917 | mgslpc_device_count++; |
diff --git a/drivers/char/random.c b/drivers/char/random.c index e0d0e371909c..7ce1ac4baa6d 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -407,7 +407,7 @@ struct entropy_store { | |||
407 | /* read-write data: */ | 407 | /* read-write data: */ |
408 | spinlock_t lock; | 408 | spinlock_t lock; |
409 | unsigned add_ptr; | 409 | unsigned add_ptr; |
410 | int entropy_count; | 410 | int entropy_count; /* Must at no time exceed ->POOLBITS! */ |
411 | int input_rotate; | 411 | int input_rotate; |
412 | }; | 412 | }; |
413 | 413 | ||
@@ -520,6 +520,7 @@ static void mix_pool_bytes(struct entropy_store *r, const void *in, int bytes) | |||
520 | static void credit_entropy_bits(struct entropy_store *r, int nbits) | 520 | static void credit_entropy_bits(struct entropy_store *r, int nbits) |
521 | { | 521 | { |
522 | unsigned long flags; | 522 | unsigned long flags; |
523 | int entropy_count; | ||
523 | 524 | ||
524 | if (!nbits) | 525 | if (!nbits) |
525 | return; | 526 | return; |
@@ -527,20 +528,20 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) | |||
527 | spin_lock_irqsave(&r->lock, flags); | 528 | spin_lock_irqsave(&r->lock, flags); |
528 | 529 | ||
529 | DEBUG_ENT("added %d entropy credits to %s\n", nbits, r->name); | 530 | DEBUG_ENT("added %d entropy credits to %s\n", nbits, r->name); |
530 | r->entropy_count += nbits; | 531 | entropy_count = r->entropy_count; |
531 | if (r->entropy_count < 0) { | 532 | entropy_count += nbits; |
533 | if (entropy_count < 0) { | ||
532 | DEBUG_ENT("negative entropy/overflow\n"); | 534 | DEBUG_ENT("negative entropy/overflow\n"); |
533 | r->entropy_count = 0; | 535 | entropy_count = 0; |
534 | } else if (r->entropy_count > r->poolinfo->POOLBITS) | 536 | } else if (entropy_count > r->poolinfo->POOLBITS) |
535 | r->entropy_count = r->poolinfo->POOLBITS; | 537 | entropy_count = r->poolinfo->POOLBITS; |
538 | r->entropy_count = entropy_count; | ||
536 | 539 | ||
537 | /* should we wake readers? */ | 540 | /* should we wake readers? */ |
538 | if (r == &input_pool && | 541 | if (r == &input_pool && entropy_count >= random_read_wakeup_thresh) { |
539 | r->entropy_count >= random_read_wakeup_thresh) { | ||
540 | wake_up_interruptible(&random_read_wait); | 542 | wake_up_interruptible(&random_read_wait); |
541 | kill_fasync(&fasync, SIGIO, POLL_IN); | 543 | kill_fasync(&fasync, SIGIO, POLL_IN); |
542 | } | 544 | } |
543 | |||
544 | spin_unlock_irqrestore(&r->lock, flags); | 545 | spin_unlock_irqrestore(&r->lock, flags); |
545 | } | 546 | } |
546 | 547 | ||
@@ -1571,6 +1572,7 @@ u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport) | |||
1571 | 1572 | ||
1572 | return half_md4_transform(hash, keyptr->secret); | 1573 | return half_md4_transform(hash, keyptr->secret); |
1573 | } | 1574 | } |
1575 | EXPORT_SYMBOL_GPL(secure_ipv4_port_ephemeral); | ||
1574 | 1576 | ||
1575 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 1577 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
1576 | u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, | 1578 | u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, |
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index d9799e2bcfbf..f53d4d00faf0 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -78,7 +78,6 @@ | |||
78 | #include <linux/wait.h> | 78 | #include <linux/wait.h> |
79 | #include <linux/bcd.h> | 79 | #include <linux/bcd.h> |
80 | #include <linux/delay.h> | 80 | #include <linux/delay.h> |
81 | #include <linux/smp_lock.h> | ||
82 | #include <linux/uaccess.h> | 81 | #include <linux/uaccess.h> |
83 | 82 | ||
84 | #include <asm/current.h> | 83 | #include <asm/current.h> |
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index ef6706f09061..500f5176b6ba 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c | |||
@@ -304,7 +304,6 @@ struct mgsl_struct { | |||
304 | 304 | ||
305 | /* generic HDLC device parts */ | 305 | /* generic HDLC device parts */ |
306 | int netcount; | 306 | int netcount; |
307 | int dosyncppp; | ||
308 | spinlock_t netlock; | 307 | spinlock_t netlock; |
309 | 308 | ||
310 | #if SYNCLINK_GENERIC_HDLC | 309 | #if SYNCLINK_GENERIC_HDLC |
@@ -868,7 +867,6 @@ static int irq[MAX_ISA_DEVICES]; | |||
868 | static int dma[MAX_ISA_DEVICES]; | 867 | static int dma[MAX_ISA_DEVICES]; |
869 | static int debug_level; | 868 | static int debug_level; |
870 | static int maxframe[MAX_TOTAL_DEVICES]; | 869 | static int maxframe[MAX_TOTAL_DEVICES]; |
871 | static int dosyncppp[MAX_TOTAL_DEVICES]; | ||
872 | static int txdmabufs[MAX_TOTAL_DEVICES]; | 870 | static int txdmabufs[MAX_TOTAL_DEVICES]; |
873 | static int txholdbufs[MAX_TOTAL_DEVICES]; | 871 | static int txholdbufs[MAX_TOTAL_DEVICES]; |
874 | 872 | ||
@@ -879,7 +877,6 @@ module_param_array(irq, int, NULL, 0); | |||
879 | module_param_array(dma, int, NULL, 0); | 877 | module_param_array(dma, int, NULL, 0); |
880 | module_param(debug_level, int, 0); | 878 | module_param(debug_level, int, 0); |
881 | module_param_array(maxframe, int, NULL, 0); | 879 | module_param_array(maxframe, int, NULL, 0); |
882 | module_param_array(dosyncppp, int, NULL, 0); | ||
883 | module_param_array(txdmabufs, int, NULL, 0); | 880 | module_param_array(txdmabufs, int, NULL, 0); |
884 | module_param_array(txholdbufs, int, NULL, 0); | 881 | module_param_array(txholdbufs, int, NULL, 0); |
885 | 882 | ||
@@ -4258,7 +4255,6 @@ static void mgsl_add_device( struct mgsl_struct *info ) | |||
4258 | if (info->line < MAX_TOTAL_DEVICES) { | 4255 | if (info->line < MAX_TOTAL_DEVICES) { |
4259 | if (maxframe[info->line]) | 4256 | if (maxframe[info->line]) |
4260 | info->max_frame_size = maxframe[info->line]; | 4257 | info->max_frame_size = maxframe[info->line]; |
4261 | info->dosyncppp = dosyncppp[info->line]; | ||
4262 | 4258 | ||
4263 | if (txdmabufs[info->line]) { | 4259 | if (txdmabufs[info->line]) { |
4264 | info->num_tx_dma_buffers = txdmabufs[info->line]; | 4260 | info->num_tx_dma_buffers = txdmabufs[info->line]; |
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 3e9058993e41..08911ed66494 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c | |||
@@ -47,7 +47,6 @@ | |||
47 | 47 | ||
48 | 48 | ||
49 | #include <linux/module.h> | 49 | #include <linux/module.h> |
50 | #include <linux/version.h> | ||
51 | #include <linux/errno.h> | 50 | #include <linux/errno.h> |
52 | #include <linux/signal.h> | 51 | #include <linux/signal.h> |
53 | #include <linux/sched.h> | 52 | #include <linux/sched.h> |
@@ -128,17 +127,14 @@ static int slgt_device_count; | |||
128 | static int ttymajor; | 127 | static int ttymajor; |
129 | static int debug_level; | 128 | static int debug_level; |
130 | static int maxframe[MAX_DEVICES]; | 129 | static int maxframe[MAX_DEVICES]; |
131 | static int dosyncppp[MAX_DEVICES]; | ||
132 | 130 | ||
133 | module_param(ttymajor, int, 0); | 131 | module_param(ttymajor, int, 0); |
134 | module_param(debug_level, int, 0); | 132 | module_param(debug_level, int, 0); |
135 | module_param_array(maxframe, int, NULL, 0); | 133 | module_param_array(maxframe, int, NULL, 0); |
136 | module_param_array(dosyncppp, int, NULL, 0); | ||
137 | 134 | ||
138 | MODULE_PARM_DESC(ttymajor, "TTY major device number override: 0=auto assigned"); | 135 | MODULE_PARM_DESC(ttymajor, "TTY major device number override: 0=auto assigned"); |
139 | MODULE_PARM_DESC(debug_level, "Debug syslog output: 0=disabled, 1 to 5=increasing detail"); | 136 | MODULE_PARM_DESC(debug_level, "Debug syslog output: 0=disabled, 1 to 5=increasing detail"); |
140 | MODULE_PARM_DESC(maxframe, "Maximum frame size used by device (4096 to 65535)"); | 137 | MODULE_PARM_DESC(maxframe, "Maximum frame size used by device (4096 to 65535)"); |
141 | MODULE_PARM_DESC(dosyncppp, "Enable synchronous net device, 0=disable 1=enable"); | ||
142 | 138 | ||
143 | /* | 139 | /* |
144 | * tty support and callbacks | 140 | * tty support and callbacks |
@@ -349,7 +345,6 @@ struct slgt_info { | |||
349 | /* SPPP/Cisco HDLC device parts */ | 345 | /* SPPP/Cisco HDLC device parts */ |
350 | 346 | ||
351 | int netcount; | 347 | int netcount; |
352 | int dosyncppp; | ||
353 | spinlock_t netlock; | 348 | spinlock_t netlock; |
354 | #if SYNCLINK_GENERIC_HDLC | 349 | #if SYNCLINK_GENERIC_HDLC |
355 | struct net_device *netdev; | 350 | struct net_device *netdev; |
@@ -3405,7 +3400,6 @@ static void add_device(struct slgt_info *info) | |||
3405 | if (info->line < MAX_DEVICES) { | 3400 | if (info->line < MAX_DEVICES) { |
3406 | if (maxframe[info->line]) | 3401 | if (maxframe[info->line]) |
3407 | info->max_frame_size = maxframe[info->line]; | 3402 | info->max_frame_size = maxframe[info->line]; |
3408 | info->dosyncppp = dosyncppp[info->line]; | ||
3409 | } | 3403 | } |
3410 | 3404 | ||
3411 | slgt_device_count++; | 3405 | slgt_device_count++; |
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index c0490cbd0db2..6bdb44f7bec2 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c | |||
@@ -270,7 +270,6 @@ typedef struct _synclinkmp_info { | |||
270 | 270 | ||
271 | /* SPPP/Cisco HDLC device parts */ | 271 | /* SPPP/Cisco HDLC device parts */ |
272 | int netcount; | 272 | int netcount; |
273 | int dosyncppp; | ||
274 | spinlock_t netlock; | 273 | spinlock_t netlock; |
275 | 274 | ||
276 | #if SYNCLINK_GENERIC_HDLC | 275 | #if SYNCLINK_GENERIC_HDLC |
@@ -469,13 +468,11 @@ static int ttymajor = 0; | |||
469 | */ | 468 | */ |
470 | static int debug_level = 0; | 469 | static int debug_level = 0; |
471 | static int maxframe[MAX_DEVICES] = {0,}; | 470 | static int maxframe[MAX_DEVICES] = {0,}; |
472 | static int dosyncppp[MAX_DEVICES] = {0,}; | ||
473 | 471 | ||
474 | module_param(break_on_load, bool, 0); | 472 | module_param(break_on_load, bool, 0); |
475 | module_param(ttymajor, int, 0); | 473 | module_param(ttymajor, int, 0); |
476 | module_param(debug_level, int, 0); | 474 | module_param(debug_level, int, 0); |
477 | module_param_array(maxframe, int, NULL, 0); | 475 | module_param_array(maxframe, int, NULL, 0); |
478 | module_param_array(dosyncppp, int, NULL, 0); | ||
479 | 476 | ||
480 | static char *driver_name = "SyncLink MultiPort driver"; | 477 | static char *driver_name = "SyncLink MultiPort driver"; |
481 | static char *driver_version = "$Revision: 4.38 $"; | 478 | static char *driver_version = "$Revision: 4.38 $"; |
@@ -3752,7 +3749,6 @@ static void add_device(SLMP_INFO *info) | |||
3752 | if (info->line < MAX_DEVICES) { | 3749 | if (info->line < MAX_DEVICES) { |
3753 | if (maxframe[info->line]) | 3750 | if (maxframe[info->line]) |
3754 | info->max_frame_size = maxframe[info->line]; | 3751 | info->max_frame_size = maxframe[info->line]; |
3755 | info->dosyncppp = dosyncppp[info->line]; | ||
3756 | } | 3752 | } |
3757 | 3753 | ||
3758 | synclinkmp_device_count++; | 3754 | synclinkmp_device_count++; |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index e1b46bc7e43c..daeb8f766971 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -1161,8 +1161,8 @@ void disassociate_ctty(int on_exit) | |||
1161 | tty = get_current_tty(); | 1161 | tty = get_current_tty(); |
1162 | if (tty) { | 1162 | if (tty) { |
1163 | tty_pgrp = get_pid(tty->pgrp); | 1163 | tty_pgrp = get_pid(tty->pgrp); |
1164 | mutex_unlock(&tty_mutex); | ||
1165 | lock_kernel(); | 1164 | lock_kernel(); |
1165 | mutex_unlock(&tty_mutex); | ||
1166 | /* XXX: here we race, there is nothing protecting tty */ | 1166 | /* XXX: here we race, there is nothing protecting tty */ |
1167 | if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) | 1167 | if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) |
1168 | tty_vhangup(tty); | 1168 | tty_vhangup(tty); |
@@ -2496,45 +2496,26 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) | |||
2496 | } | 2496 | } |
2497 | 2497 | ||
2498 | /** | 2498 | /** |
2499 | * tiocswinsz - implement window size set ioctl | 2499 | * tty_do_resize - resize event |
2500 | * @tty; tty | 2500 | * @tty: tty being resized |
2501 | * @arg: user buffer for result | 2501 | * @real_tty: real tty (not the same as tty if using a pty/tty pair) |
2502 | * | 2502 | * @rows: rows (character) |
2503 | * Copies the user idea of the window size to the kernel. Traditionally | 2503 | * @cols: cols (character) |
2504 | * this is just advisory information but for the Linux console it | ||
2505 | * actually has driver level meaning and triggers a VC resize. | ||
2506 | * | 2504 | * |
2507 | * Locking: | 2505 | * Update the termios variables and send the neccessary signals to |
2508 | * Called function use the console_sem is used to ensure we do | 2506 | * peform a terminal resize correctly |
2509 | * not try and resize the console twice at once. | ||
2510 | * The tty->termios_mutex is used to ensure we don't double | ||
2511 | * resize and get confused. Lock order - tty->termios_mutex before | ||
2512 | * console sem | ||
2513 | */ | 2507 | */ |
2514 | 2508 | ||
2515 | static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | 2509 | int tty_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, |
2516 | struct winsize __user *arg) | 2510 | struct winsize *ws) |
2517 | { | 2511 | { |
2518 | struct winsize tmp_ws; | ||
2519 | struct pid *pgrp, *rpgrp; | 2512 | struct pid *pgrp, *rpgrp; |
2520 | unsigned long flags; | 2513 | unsigned long flags; |
2521 | 2514 | ||
2522 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) | 2515 | /* For a PTY we need to lock the tty side */ |
2523 | return -EFAULT; | 2516 | mutex_lock(&real_tty->termios_mutex); |
2524 | 2517 | if (!memcmp(ws, &tty->winsize, sizeof(*ws))) | |
2525 | mutex_lock(&tty->termios_mutex); | ||
2526 | if (!memcmp(&tmp_ws, &tty->winsize, sizeof(*arg))) | ||
2527 | goto done; | 2518 | goto done; |
2528 | |||
2529 | #ifdef CONFIG_VT | ||
2530 | if (tty->driver->type == TTY_DRIVER_TYPE_CONSOLE) { | ||
2531 | if (vc_lock_resize(tty->driver_data, tmp_ws.ws_col, | ||
2532 | tmp_ws.ws_row)) { | ||
2533 | mutex_unlock(&tty->termios_mutex); | ||
2534 | return -ENXIO; | ||
2535 | } | ||
2536 | } | ||
2537 | #endif | ||
2538 | /* Get the PID values and reference them so we can | 2519 | /* Get the PID values and reference them so we can |
2539 | avoid holding the tty ctrl lock while sending signals */ | 2520 | avoid holding the tty ctrl lock while sending signals */ |
2540 | spin_lock_irqsave(&tty->ctrl_lock, flags); | 2521 | spin_lock_irqsave(&tty->ctrl_lock, flags); |
@@ -2550,14 +2531,42 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | |||
2550 | put_pid(pgrp); | 2531 | put_pid(pgrp); |
2551 | put_pid(rpgrp); | 2532 | put_pid(rpgrp); |
2552 | 2533 | ||
2553 | tty->winsize = tmp_ws; | 2534 | tty->winsize = *ws; |
2554 | real_tty->winsize = tmp_ws; | 2535 | real_tty->winsize = *ws; |
2555 | done: | 2536 | done: |
2556 | mutex_unlock(&tty->termios_mutex); | 2537 | mutex_unlock(&real_tty->termios_mutex); |
2557 | return 0; | 2538 | return 0; |
2558 | } | 2539 | } |
2559 | 2540 | ||
2560 | /** | 2541 | /** |
2542 | * tiocswinsz - implement window size set ioctl | ||
2543 | * @tty; tty | ||
2544 | * @arg: user buffer for result | ||
2545 | * | ||
2546 | * Copies the user idea of the window size to the kernel. Traditionally | ||
2547 | * this is just advisory information but for the Linux console it | ||
2548 | * actually has driver level meaning and triggers a VC resize. | ||
2549 | * | ||
2550 | * Locking: | ||
2551 | * Driver dependant. The default do_resize method takes the | ||
2552 | * tty termios mutex and ctrl_lock. The console takes its own lock | ||
2553 | * then calls into the default method. | ||
2554 | */ | ||
2555 | |||
2556 | static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | ||
2557 | struct winsize __user *arg) | ||
2558 | { | ||
2559 | struct winsize tmp_ws; | ||
2560 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) | ||
2561 | return -EFAULT; | ||
2562 | |||
2563 | if (tty->ops->resize) | ||
2564 | return tty->ops->resize(tty, real_tty, &tmp_ws); | ||
2565 | else | ||
2566 | return tty_do_resize(tty, real_tty, &tmp_ws); | ||
2567 | } | ||
2568 | |||
2569 | /** | ||
2561 | * tioccons - allow admin to move logical console | 2570 | * tioccons - allow admin to move logical console |
2562 | * @file: the file to become console | 2571 | * @file: the file to become console |
2563 | * | 2572 | * |
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c index ea9fc5d03b99..bf34e4597421 100644 --- a/drivers/char/tty_ioctl.c +++ b/drivers/char/tty_ioctl.c | |||
@@ -937,12 +937,14 @@ int tty_mode_ioctl(struct tty_struct *tty, struct file *file, | |||
937 | return 0; | 937 | return 0; |
938 | #endif | 938 | #endif |
939 | case TIOCGSOFTCAR: | 939 | case TIOCGSOFTCAR: |
940 | return put_user(C_CLOCAL(tty) ? 1 : 0, | 940 | /* FIXME: for correctness we may need to take the termios |
941 | lock here - review */ | ||
942 | return put_user(C_CLOCAL(real_tty) ? 1 : 0, | ||
941 | (int __user *)arg); | 943 | (int __user *)arg); |
942 | case TIOCSSOFTCAR: | 944 | case TIOCSSOFTCAR: |
943 | if (get_user(arg, (unsigned int __user *) arg)) | 945 | if (get_user(arg, (unsigned int __user *) arg)) |
944 | return -EFAULT; | 946 | return -EFAULT; |
945 | return tty_change_softcar(tty, arg); | 947 | return tty_change_softcar(real_tty, arg); |
946 | default: | 948 | default: |
947 | return -ENOIOCTLCMD; | 949 | return -ENOIOCTLCMD; |
948 | } | 950 | } |
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c index 241cbdea65ab..f307f135cbfb 100644 --- a/drivers/char/tty_ldisc.c +++ b/drivers/char/tty_ldisc.c | |||
@@ -169,7 +169,7 @@ static int tty_ldisc_get(int disc, struct tty_ldisc *ld) | |||
169 | if (disc < N_TTY || disc >= NR_LDISCS) | 169 | if (disc < N_TTY || disc >= NR_LDISCS) |
170 | return -EINVAL; | 170 | return -EINVAL; |
171 | err = tty_ldisc_try_get(disc, ld); | 171 | err = tty_ldisc_try_get(disc, ld); |
172 | if (err == -EAGAIN) { | 172 | if (err < 0) { |
173 | request_module("tty-ldisc-%d", disc); | 173 | request_module("tty-ldisc-%d", disc); |
174 | err = tty_ldisc_try_get(disc, ld); | 174 | err = tty_ldisc_try_get(disc, ld); |
175 | } | 175 | } |
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c deleted file mode 100644 index 65fb848e1cce..000000000000 --- a/drivers/char/viocons.c +++ /dev/null | |||
@@ -1,1171 +0,0 @@ | |||
1 | /* -*- linux-c -*- | ||
2 | * | ||
3 | * drivers/char/viocons.c | ||
4 | * | ||
5 | * iSeries Virtual Terminal | ||
6 | * | ||
7 | * Authors: Dave Boutcher <boutcher@us.ibm.com> | ||
8 | * Ryan Arnold <ryanarn@us.ibm.com> | ||
9 | * Colin Devilbiss <devilbis@us.ibm.com> | ||
10 | * Stephen Rothwell | ||
11 | * | ||
12 | * (C) Copyright 2000, 2001, 2002, 2003, 2004 IBM Corporation | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation; either version 2 of the | ||
17 | * License, or (at your option) anyu later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, but | ||
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
22 | * General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software Foundation, | ||
26 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
27 | */ | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/proc_fs.h> | ||
30 | #include <linux/errno.h> | ||
31 | #include <linux/vmalloc.h> | ||
32 | #include <linux/mm.h> | ||
33 | #include <linux/console.h> | ||
34 | #include <linux/module.h> | ||
35 | #include <asm/uaccess.h> | ||
36 | #include <linux/init.h> | ||
37 | #include <linux/wait.h> | ||
38 | #include <linux/spinlock.h> | ||
39 | #include <asm/ioctls.h> | ||
40 | #include <linux/kd.h> | ||
41 | #include <linux/tty.h> | ||
42 | #include <linux/tty_flip.h> | ||
43 | #include <linux/sysrq.h> | ||
44 | |||
45 | #include <asm/firmware.h> | ||
46 | #include <asm/iseries/vio.h> | ||
47 | #include <asm/iseries/hv_lp_event.h> | ||
48 | #include <asm/iseries/hv_call_event.h> | ||
49 | #include <asm/iseries/hv_lp_config.h> | ||
50 | #include <asm/iseries/hv_call.h> | ||
51 | |||
52 | #ifdef CONFIG_VT | ||
53 | #error You must turn off CONFIG_VT to use CONFIG_VIOCONS | ||
54 | #endif | ||
55 | |||
56 | #define VIOTTY_MAGIC (0x0DCB) | ||
57 | #define VTTY_PORTS 10 | ||
58 | |||
59 | #define VIOCONS_KERN_WARN KERN_WARNING "viocons: " | ||
60 | #define VIOCONS_KERN_INFO KERN_INFO "viocons: " | ||
61 | |||
62 | static DEFINE_SPINLOCK(consolelock); | ||
63 | static DEFINE_SPINLOCK(consoleloglock); | ||
64 | |||
65 | static int vio_sysrq_pressed; | ||
66 | |||
67 | #define VIOCHAR_NUM_BUF 16 | ||
68 | |||
69 | /* | ||
70 | * Our port information. We store a pointer to one entry in the | ||
71 | * tty_driver_data | ||
72 | */ | ||
73 | static struct port_info { | ||
74 | int magic; | ||
75 | struct tty_struct *tty; | ||
76 | HvLpIndex lp; | ||
77 | u8 vcons; | ||
78 | u64 seq; /* sequence number of last HV send */ | ||
79 | u64 ack; /* last ack from HV */ | ||
80 | /* | ||
81 | * When we get writes faster than we can send it to the partition, | ||
82 | * buffer the data here. Note that used is a bit map of used buffers. | ||
83 | * It had better have enough bits to hold VIOCHAR_NUM_BUF the bitops assume | ||
84 | * it is a multiple of unsigned long | ||
85 | */ | ||
86 | unsigned long used; | ||
87 | u8 *buffer[VIOCHAR_NUM_BUF]; | ||
88 | int bufferBytes[VIOCHAR_NUM_BUF]; | ||
89 | int curbuf; | ||
90 | int bufferOverflow; | ||
91 | int overflowMessage; | ||
92 | } port_info[VTTY_PORTS]; | ||
93 | |||
94 | #define viochar_is_console(pi) ((pi) == &port_info[0]) | ||
95 | #define viochar_port(pi) ((pi) - &port_info[0]) | ||
96 | |||
97 | static void initDataEvent(struct viocharlpevent *viochar, HvLpIndex lp); | ||
98 | |||
99 | static struct tty_driver *viotty_driver; | ||
100 | |||
101 | static void hvlog(char *fmt, ...) | ||
102 | { | ||
103 | int i; | ||
104 | unsigned long flags; | ||
105 | va_list args; | ||
106 | static char buf[256]; | ||
107 | |||
108 | spin_lock_irqsave(&consoleloglock, flags); | ||
109 | va_start(args, fmt); | ||
110 | i = vscnprintf(buf, sizeof(buf) - 1, fmt, args); | ||
111 | va_end(args); | ||
112 | buf[i++] = '\r'; | ||
113 | HvCall_writeLogBuffer(buf, i); | ||
114 | spin_unlock_irqrestore(&consoleloglock, flags); | ||
115 | } | ||
116 | |||
117 | static void hvlogOutput(const char *buf, int count) | ||
118 | { | ||
119 | unsigned long flags; | ||
120 | int begin; | ||
121 | int index; | ||
122 | static const char cr = '\r'; | ||
123 | |||
124 | begin = 0; | ||
125 | spin_lock_irqsave(&consoleloglock, flags); | ||
126 | for (index = 0; index < count; index++) { | ||
127 | if (buf[index] == '\n') { | ||
128 | /* | ||
129 | * Start right after the last '\n' or at the zeroth | ||
130 | * array position and output the number of characters | ||
131 | * including the newline. | ||
132 | */ | ||
133 | HvCall_writeLogBuffer(&buf[begin], index - begin + 1); | ||
134 | begin = index + 1; | ||
135 | HvCall_writeLogBuffer(&cr, 1); | ||
136 | } | ||
137 | } | ||
138 | if ((index - begin) > 0) | ||
139 | HvCall_writeLogBuffer(&buf[begin], index - begin); | ||
140 | spin_unlock_irqrestore(&consoleloglock, flags); | ||
141 | } | ||
142 | |||
143 | /* | ||
144 | * Make sure we're pointing to a valid port_info structure. Shamelessly | ||
145 | * plagerized from serial.c | ||
146 | */ | ||
147 | static inline int viotty_paranoia_check(struct port_info *pi, | ||
148 | char *name, const char *routine) | ||
149 | { | ||
150 | static const char *bad_pi_addr = VIOCONS_KERN_WARN | ||
151 | "warning: bad address for port_info struct (%s) in %s\n"; | ||
152 | static const char *badmagic = VIOCONS_KERN_WARN | ||
153 | "warning: bad magic number for port_info struct (%s) in %s\n"; | ||
154 | |||
155 | if ((pi < &port_info[0]) || (viochar_port(pi) > VTTY_PORTS)) { | ||
156 | printk(bad_pi_addr, name, routine); | ||
157 | return 1; | ||
158 | } | ||
159 | if (pi->magic != VIOTTY_MAGIC) { | ||
160 | printk(badmagic, name, routine); | ||
161 | return 1; | ||
162 | } | ||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | /* | ||
167 | * Add data to our pending-send buffers. | ||
168 | * | ||
169 | * NOTE: Don't use printk in here because it gets nastily recursive. | ||
170 | * hvlog can be used to log to the hypervisor buffer | ||
171 | */ | ||
172 | static int buffer_add(struct port_info *pi, const char *buf, size_t len) | ||
173 | { | ||
174 | size_t bleft; | ||
175 | size_t curlen; | ||
176 | const char *curbuf; | ||
177 | int nextbuf; | ||
178 | |||
179 | curbuf = buf; | ||
180 | bleft = len; | ||
181 | while (bleft > 0) { | ||
182 | /* | ||
183 | * If there is no space left in the current buffer, we have | ||
184 | * filled everything up, so return. If we filled the previous | ||
185 | * buffer we would already have moved to the next one. | ||
186 | */ | ||
187 | if (pi->bufferBytes[pi->curbuf] == VIOCHAR_MAX_DATA) { | ||
188 | hvlog ("\n\rviocons: No overflow buffer available for memcpy().\n"); | ||
189 | pi->bufferOverflow++; | ||
190 | pi->overflowMessage = 1; | ||
191 | break; | ||
192 | } | ||
193 | |||
194 | /* | ||
195 | * Turn on the "used" bit for this buffer. If it's already on, | ||
196 | * that's fine. | ||
197 | */ | ||
198 | set_bit(pi->curbuf, &pi->used); | ||
199 | |||
200 | /* | ||
201 | * See if this buffer has been allocated. If not, allocate it. | ||
202 | */ | ||
203 | if (pi->buffer[pi->curbuf] == NULL) { | ||
204 | pi->buffer[pi->curbuf] = | ||
205 | kmalloc(VIOCHAR_MAX_DATA, GFP_ATOMIC); | ||
206 | if (pi->buffer[pi->curbuf] == NULL) { | ||
207 | hvlog("\n\rviocons: kmalloc failed allocating spaces for buffer %d.", | ||
208 | pi->curbuf); | ||
209 | break; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | /* Figure out how much we can copy into this buffer. */ | ||
214 | if (bleft < (VIOCHAR_MAX_DATA - pi->bufferBytes[pi->curbuf])) | ||
215 | curlen = bleft; | ||
216 | else | ||
217 | curlen = VIOCHAR_MAX_DATA - pi->bufferBytes[pi->curbuf]; | ||
218 | |||
219 | /* Copy the data into the buffer. */ | ||
220 | memcpy(pi->buffer[pi->curbuf] + pi->bufferBytes[pi->curbuf], | ||
221 | curbuf, curlen); | ||
222 | |||
223 | pi->bufferBytes[pi->curbuf] += curlen; | ||
224 | curbuf += curlen; | ||
225 | bleft -= curlen; | ||
226 | |||
227 | /* | ||
228 | * Now see if we've filled this buffer. If not then | ||
229 | * we'll try to use it again later. If we've filled it | ||
230 | * up then we'll advance the curbuf to the next in the | ||
231 | * circular queue. | ||
232 | */ | ||
233 | if (pi->bufferBytes[pi->curbuf] == VIOCHAR_MAX_DATA) { | ||
234 | nextbuf = (pi->curbuf + 1) % VIOCHAR_NUM_BUF; | ||
235 | /* | ||
236 | * Move to the next buffer if it hasn't been used yet | ||
237 | */ | ||
238 | if (test_bit(nextbuf, &pi->used) == 0) | ||
239 | pi->curbuf = nextbuf; | ||
240 | } | ||
241 | } | ||
242 | return len - bleft; | ||
243 | } | ||
244 | |||
245 | /* | ||
246 | * Send pending data | ||
247 | * | ||
248 | * NOTE: Don't use printk in here because it gets nastily recursive. | ||
249 | * hvlog can be used to log to the hypervisor buffer | ||
250 | */ | ||
251 | static void send_buffers(struct port_info *pi) | ||
252 | { | ||
253 | HvLpEvent_Rc hvrc; | ||
254 | int nextbuf; | ||
255 | struct viocharlpevent *viochar; | ||
256 | unsigned long flags; | ||
257 | |||
258 | spin_lock_irqsave(&consolelock, flags); | ||
259 | |||
260 | viochar = (struct viocharlpevent *) | ||
261 | vio_get_event_buffer(viomajorsubtype_chario); | ||
262 | |||
263 | /* Make sure we got a buffer */ | ||
264 | if (viochar == NULL) { | ||
265 | hvlog("\n\rviocons: Can't get viochar buffer in sendBuffers()."); | ||
266 | spin_unlock_irqrestore(&consolelock, flags); | ||
267 | return; | ||
268 | } | ||
269 | |||
270 | if (pi->used == 0) { | ||
271 | hvlog("\n\rviocons: in sendbuffers(), but no buffers used.\n"); | ||
272 | vio_free_event_buffer(viomajorsubtype_chario, viochar); | ||
273 | spin_unlock_irqrestore(&consolelock, flags); | ||
274 | return; | ||
275 | } | ||
276 | |||
277 | /* | ||
278 | * curbuf points to the buffer we're filling. We want to | ||
279 | * start sending AFTER this one. | ||
280 | */ | ||
281 | nextbuf = (pi->curbuf + 1) % VIOCHAR_NUM_BUF; | ||
282 | |||
283 | /* | ||
284 | * Loop until we find a buffer with the used bit on | ||
285 | */ | ||
286 | while (test_bit(nextbuf, &pi->used) == 0) | ||
287 | nextbuf = (nextbuf + 1) % VIOCHAR_NUM_BUF; | ||
288 | |||
289 | initDataEvent(viochar, pi->lp); | ||
290 | |||
291 | /* | ||
292 | * While we have buffers with data, and our send window | ||
293 | * is open, send them | ||
294 | */ | ||
295 | while ((test_bit(nextbuf, &pi->used)) && | ||
296 | ((pi->seq - pi->ack) < VIOCHAR_WINDOW)) { | ||
297 | viochar->len = pi->bufferBytes[nextbuf]; | ||
298 | viochar->event.xCorrelationToken = pi->seq++; | ||
299 | viochar->event.xSizeMinus1 = | ||
300 | offsetof(struct viocharlpevent, data) + viochar->len; | ||
301 | |||
302 | memcpy(viochar->data, pi->buffer[nextbuf], viochar->len); | ||
303 | |||
304 | hvrc = HvCallEvent_signalLpEvent(&viochar->event); | ||
305 | if (hvrc) { | ||
306 | /* | ||
307 | * MUST unlock the spinlock before doing a printk | ||
308 | */ | ||
309 | vio_free_event_buffer(viomajorsubtype_chario, viochar); | ||
310 | spin_unlock_irqrestore(&consolelock, flags); | ||
311 | |||
312 | printk(VIOCONS_KERN_WARN | ||
313 | "error sending event! return code %d\n", | ||
314 | (int)hvrc); | ||
315 | return; | ||
316 | } | ||
317 | |||
318 | /* | ||
319 | * clear the used bit, zero the number of bytes in | ||
320 | * this buffer, and move to the next buffer | ||
321 | */ | ||
322 | clear_bit(nextbuf, &pi->used); | ||
323 | pi->bufferBytes[nextbuf] = 0; | ||
324 | nextbuf = (nextbuf + 1) % VIOCHAR_NUM_BUF; | ||
325 | } | ||
326 | |||
327 | /* | ||
328 | * If we have emptied all the buffers, start at 0 again. | ||
329 | * this will re-use any allocated buffers | ||
330 | */ | ||
331 | if (pi->used == 0) { | ||
332 | pi->curbuf = 0; | ||
333 | |||
334 | if (pi->overflowMessage) | ||
335 | pi->overflowMessage = 0; | ||
336 | |||
337 | if (pi->tty) { | ||
338 | tty_wakeup(pi->tty); | ||
339 | } | ||
340 | } | ||
341 | |||
342 | vio_free_event_buffer(viomajorsubtype_chario, viochar); | ||
343 | spin_unlock_irqrestore(&consolelock, flags); | ||
344 | } | ||
345 | |||
346 | /* | ||
347 | * Our internal writer. Gets called both from the console device and | ||
348 | * the tty device. the tty pointer will be NULL if called from the console. | ||
349 | * Return total number of bytes "written". | ||
350 | * | ||
351 | * NOTE: Don't use printk in here because it gets nastily recursive. hvlog | ||
352 | * can be used to log to the hypervisor buffer | ||
353 | */ | ||
354 | static int internal_write(struct port_info *pi, const char *buf, size_t len) | ||
355 | { | ||
356 | HvLpEvent_Rc hvrc; | ||
357 | size_t bleft; | ||
358 | size_t curlen; | ||
359 | const char *curbuf; | ||
360 | unsigned long flags; | ||
361 | struct viocharlpevent *viochar; | ||
362 | |||
363 | /* | ||
364 | * Write to the hvlog of inbound data are now done prior to | ||
365 | * calling internal_write() since internal_write() is only called in | ||
366 | * the event that an lp event path is active, which isn't the case for | ||
367 | * logging attempts prior to console initialization. | ||
368 | * | ||
369 | * If there is already data queued for this port, send it prior to | ||
370 | * attempting to send any new data. | ||
371 | */ | ||
372 | if (pi->used) | ||
373 | send_buffers(pi); | ||
374 | |||
375 | spin_lock_irqsave(&consolelock, flags); | ||
376 | |||
377 | viochar = vio_get_event_buffer(viomajorsubtype_chario); | ||
378 | if (viochar == NULL) { | ||
379 | spin_unlock_irqrestore(&consolelock, flags); | ||
380 | hvlog("\n\rviocons: Can't get vio buffer in internal_write()."); | ||
381 | return -EAGAIN; | ||
382 | } | ||
383 | initDataEvent(viochar, pi->lp); | ||
384 | |||
385 | curbuf = buf; | ||
386 | bleft = len; | ||
387 | |||
388 | while ((bleft > 0) && (pi->used == 0) && | ||
389 | ((pi->seq - pi->ack) < VIOCHAR_WINDOW)) { | ||
390 | if (bleft > VIOCHAR_MAX_DATA) | ||
391 | curlen = VIOCHAR_MAX_DATA; | ||
392 | else | ||
393 | curlen = bleft; | ||
394 | |||
395 | viochar->event.xCorrelationToken = pi->seq++; | ||
396 | memcpy(viochar->data, curbuf, curlen); | ||
397 | viochar->len = curlen; | ||
398 | viochar->event.xSizeMinus1 = | ||
399 | offsetof(struct viocharlpevent, data) + curlen; | ||
400 | |||
401 | hvrc = HvCallEvent_signalLpEvent(&viochar->event); | ||
402 | if (hvrc) { | ||
403 | hvlog("viocons: error sending event! %d\n", (int)hvrc); | ||
404 | goto out; | ||
405 | } | ||
406 | curbuf += curlen; | ||
407 | bleft -= curlen; | ||
408 | } | ||
409 | |||
410 | /* If we didn't send it all, buffer as much of it as we can. */ | ||
411 | if (bleft > 0) | ||
412 | bleft -= buffer_add(pi, curbuf, bleft); | ||
413 | out: | ||
414 | vio_free_event_buffer(viomajorsubtype_chario, viochar); | ||
415 | spin_unlock_irqrestore(&consolelock, flags); | ||
416 | return len - bleft; | ||
417 | } | ||
418 | |||
419 | static struct port_info *get_port_data(struct tty_struct *tty) | ||
420 | { | ||
421 | unsigned long flags; | ||
422 | struct port_info *pi; | ||
423 | |||
424 | spin_lock_irqsave(&consolelock, flags); | ||
425 | if (tty) { | ||
426 | pi = (struct port_info *)tty->driver_data; | ||
427 | if (!pi || viotty_paranoia_check(pi, tty->name, | ||
428 | "get_port_data")) { | ||
429 | pi = NULL; | ||
430 | } | ||
431 | } else | ||
432 | /* | ||
433 | * If this is the console device, use the lp from | ||
434 | * the first port entry | ||
435 | */ | ||
436 | pi = &port_info[0]; | ||
437 | spin_unlock_irqrestore(&consolelock, flags); | ||
438 | return pi; | ||
439 | } | ||
440 | |||
441 | /* | ||
442 | * Initialize the common fields in a charLpEvent | ||
443 | */ | ||
444 | static void initDataEvent(struct viocharlpevent *viochar, HvLpIndex lp) | ||
445 | { | ||
446 | struct HvLpEvent *hev = &viochar->event; | ||
447 | |||
448 | memset(viochar, 0, sizeof(struct viocharlpevent)); | ||
449 | |||
450 | hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DEFERRED_ACK | | ||
451 | HV_LP_EVENT_INT; | ||
452 | hev->xType = HvLpEvent_Type_VirtualIo; | ||
453 | hev->xSubtype = viomajorsubtype_chario | viochardata; | ||
454 | hev->xSourceLp = HvLpConfig_getLpIndex(); | ||
455 | hev->xTargetLp = lp; | ||
456 | hev->xSizeMinus1 = sizeof(struct viocharlpevent); | ||
457 | hev->xSourceInstanceId = viopath_sourceinst(lp); | ||
458 | hev->xTargetInstanceId = viopath_targetinst(lp); | ||
459 | } | ||
460 | |||
461 | /* | ||
462 | * early console device write | ||
463 | */ | ||
464 | static void viocons_write_early(struct console *co, const char *s, unsigned count) | ||
465 | { | ||
466 | hvlogOutput(s, count); | ||
467 | } | ||
468 | |||
469 | /* | ||
470 | * console device write | ||
471 | */ | ||
472 | static void viocons_write(struct console *co, const char *s, unsigned count) | ||
473 | { | ||
474 | int index; | ||
475 | int begin; | ||
476 | struct port_info *pi; | ||
477 | |||
478 | static const char cr = '\r'; | ||
479 | |||
480 | /* | ||
481 | * Check port data first because the target LP might be valid but | ||
482 | * simply not active, in which case we want to hvlog the output. | ||
483 | */ | ||
484 | pi = get_port_data(NULL); | ||
485 | if (pi == NULL) { | ||
486 | hvlog("\n\rviocons_write: unable to get port data."); | ||
487 | return; | ||
488 | } | ||
489 | |||
490 | hvlogOutput(s, count); | ||
491 | |||
492 | if (!viopath_isactive(pi->lp)) | ||
493 | return; | ||
494 | |||
495 | /* | ||
496 | * Any newline character found will cause a | ||
497 | * carriage return character to be emitted as well. | ||
498 | */ | ||
499 | begin = 0; | ||
500 | for (index = 0; index < count; index++) { | ||
501 | if (s[index] == '\n') { | ||
502 | /* | ||
503 | * Newline found. Print everything up to and | ||
504 | * including the newline | ||
505 | */ | ||
506 | internal_write(pi, &s[begin], index - begin + 1); | ||
507 | begin = index + 1; | ||
508 | /* Emit a carriage return as well */ | ||
509 | internal_write(pi, &cr, 1); | ||
510 | } | ||
511 | } | ||
512 | |||
513 | /* If any characters left to write, write them now */ | ||
514 | if ((index - begin) > 0) | ||
515 | internal_write(pi, &s[begin], index - begin); | ||
516 | } | ||
517 | |||
518 | /* | ||
519 | * Work out the device associate with this console | ||
520 | */ | ||
521 | static struct tty_driver *viocons_device(struct console *c, int *index) | ||
522 | { | ||
523 | *index = c->index; | ||
524 | return viotty_driver; | ||
525 | } | ||
526 | |||
527 | /* | ||
528 | * console device I/O methods | ||
529 | */ | ||
530 | static struct console viocons_early = { | ||
531 | .name = "viocons", | ||
532 | .write = viocons_write_early, | ||
533 | .flags = CON_PRINTBUFFER, | ||
534 | .index = -1, | ||
535 | }; | ||
536 | |||
537 | static struct console viocons = { | ||
538 | .name = "viocons", | ||
539 | .write = viocons_write, | ||
540 | .device = viocons_device, | ||
541 | .flags = CON_PRINTBUFFER, | ||
542 | .index = -1, | ||
543 | }; | ||
544 | |||
545 | /* | ||
546 | * TTY Open method | ||
547 | */ | ||
548 | static int viotty_open(struct tty_struct *tty, struct file *filp) | ||
549 | { | ||
550 | int port; | ||
551 | unsigned long flags; | ||
552 | struct port_info *pi; | ||
553 | |||
554 | port = tty->index; | ||
555 | |||
556 | if ((port < 0) || (port >= VTTY_PORTS)) | ||
557 | return -ENODEV; | ||
558 | |||
559 | spin_lock_irqsave(&consolelock, flags); | ||
560 | |||
561 | pi = &port_info[port]; | ||
562 | /* If some other TTY is already connected here, reject the open */ | ||
563 | if ((pi->tty) && (pi->tty != tty)) { | ||
564 | spin_unlock_irqrestore(&consolelock, flags); | ||
565 | printk(VIOCONS_KERN_WARN | ||
566 | "attempt to open device twice from different ttys\n"); | ||
567 | return -EBUSY; | ||
568 | } | ||
569 | tty->driver_data = pi; | ||
570 | pi->tty = tty; | ||
571 | spin_unlock_irqrestore(&consolelock, flags); | ||
572 | |||
573 | return 0; | ||
574 | } | ||
575 | |||
576 | /* | ||
577 | * TTY Close method | ||
578 | */ | ||
579 | static void viotty_close(struct tty_struct *tty, struct file *filp) | ||
580 | { | ||
581 | unsigned long flags; | ||
582 | struct port_info *pi; | ||
583 | |||
584 | spin_lock_irqsave(&consolelock, flags); | ||
585 | pi = (struct port_info *)tty->driver_data; | ||
586 | |||
587 | if (!pi || viotty_paranoia_check(pi, tty->name, "viotty_close")) { | ||
588 | spin_unlock_irqrestore(&consolelock, flags); | ||
589 | return; | ||
590 | } | ||
591 | if (tty->count == 1) | ||
592 | pi->tty = NULL; | ||
593 | spin_unlock_irqrestore(&consolelock, flags); | ||
594 | } | ||
595 | |||
596 | /* | ||
597 | * TTY Write method | ||
598 | */ | ||
599 | static int viotty_write(struct tty_struct *tty, const unsigned char *buf, | ||
600 | int count) | ||
601 | { | ||
602 | struct port_info *pi; | ||
603 | |||
604 | pi = get_port_data(tty); | ||
605 | if (pi == NULL) { | ||
606 | hvlog("\n\rviotty_write: no port data."); | ||
607 | return -ENODEV; | ||
608 | } | ||
609 | |||
610 | if (viochar_is_console(pi)) | ||
611 | hvlogOutput(buf, count); | ||
612 | |||
613 | /* | ||
614 | * If the path to this LP is closed, don't bother doing anything more. | ||
615 | * just dump the data on the floor and return count. For some reason | ||
616 | * some user level programs will attempt to probe available tty's and | ||
617 | * they'll attempt a viotty_write on an invalid port which maps to an | ||
618 | * invalid target lp. If this is the case then ignore the | ||
619 | * viotty_write call and, since the viopath isn't active to this | ||
620 | * partition, return count. | ||
621 | */ | ||
622 | if (!viopath_isactive(pi->lp)) | ||
623 | return count; | ||
624 | |||
625 | return internal_write(pi, buf, count); | ||
626 | } | ||
627 | |||
628 | /* | ||
629 | * TTY put_char method | ||
630 | */ | ||
631 | static int viotty_put_char(struct tty_struct *tty, unsigned char ch) | ||
632 | { | ||
633 | struct port_info *pi; | ||
634 | |||
635 | pi = get_port_data(tty); | ||
636 | if (pi == NULL) | ||
637 | return 0; | ||
638 | |||
639 | /* This will append '\r' as well if the char is '\n' */ | ||
640 | if (viochar_is_console(pi)) | ||
641 | hvlogOutput(&ch, 1); | ||
642 | |||
643 | if (viopath_isactive(pi->lp)) | ||
644 | internal_write(pi, &ch, 1); | ||
645 | return 1; | ||
646 | } | ||
647 | |||
648 | /* | ||
649 | * TTY write_room method | ||
650 | */ | ||
651 | static int viotty_write_room(struct tty_struct *tty) | ||
652 | { | ||
653 | int i; | ||
654 | int room = 0; | ||
655 | struct port_info *pi; | ||
656 | unsigned long flags; | ||
657 | |||
658 | spin_lock_irqsave(&consolelock, flags); | ||
659 | pi = (struct port_info *)tty->driver_data; | ||
660 | if (!pi || viotty_paranoia_check(pi, tty->name, "viotty_write_room")) { | ||
661 | spin_unlock_irqrestore(&consolelock, flags); | ||
662 | return 0; | ||
663 | } | ||
664 | |||
665 | /* If no buffers are used, return the max size. */ | ||
666 | if (pi->used == 0) { | ||
667 | spin_unlock_irqrestore(&consolelock, flags); | ||
668 | return VIOCHAR_MAX_DATA * VIOCHAR_NUM_BUF; | ||
669 | } | ||
670 | |||
671 | /* | ||
672 | * We retain the spinlock because we want to get an accurate | ||
673 | * count and it can change on us between each operation if we | ||
674 | * don't hold the spinlock. | ||
675 | */ | ||
676 | for (i = 0; ((i < VIOCHAR_NUM_BUF) && (room < VIOCHAR_MAX_DATA)); i++) | ||
677 | room += (VIOCHAR_MAX_DATA - pi->bufferBytes[i]); | ||
678 | spin_unlock_irqrestore(&consolelock, flags); | ||
679 | |||
680 | if (room > VIOCHAR_MAX_DATA) | ||
681 | room = VIOCHAR_MAX_DATA; | ||
682 | return room; | ||
683 | } | ||
684 | |||
685 | /* | ||
686 | * TTY chars_in_buffer method | ||
687 | */ | ||
688 | static int viotty_chars_in_buffer(struct tty_struct *tty) | ||
689 | { | ||
690 | return 0; | ||
691 | } | ||
692 | |||
693 | static int viotty_ioctl(struct tty_struct *tty, struct file *file, | ||
694 | unsigned int cmd, unsigned long arg) | ||
695 | { | ||
696 | switch (cmd) { | ||
697 | /* | ||
698 | * the ioctls below read/set the flags usually shown in the leds | ||
699 | * don't use them - they will go away without warning | ||
700 | */ | ||
701 | case KDGETLED: | ||
702 | case KDGKBLED: | ||
703 | return put_user(0, (char *)arg); | ||
704 | |||
705 | case KDSKBLED: | ||
706 | return 0; | ||
707 | } | ||
708 | /* FIXME: WTF is this being called for ??? */ | ||
709 | lock_kernel(); | ||
710 | ret = n_tty_ioctl(tty, file, cmd, arg); | ||
711 | unlock_kernel(); | ||
712 | return ret; | ||
713 | } | ||
714 | |||
715 | /* | ||
716 | * Handle an open charLpEvent. Could be either interrupt or ack | ||
717 | */ | ||
718 | static void vioHandleOpenEvent(struct HvLpEvent *event) | ||
719 | { | ||
720 | unsigned long flags; | ||
721 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
722 | u8 port = cevent->virtual_device; | ||
723 | struct port_info *pi; | ||
724 | int reject = 0; | ||
725 | |||
726 | if (hvlpevent_is_ack(event)) { | ||
727 | if (port >= VTTY_PORTS) | ||
728 | return; | ||
729 | |||
730 | spin_lock_irqsave(&consolelock, flags); | ||
731 | /* Got the lock, don't cause console output */ | ||
732 | |||
733 | pi = &port_info[port]; | ||
734 | if (event->xRc == HvLpEvent_Rc_Good) { | ||
735 | pi->seq = pi->ack = 0; | ||
736 | /* | ||
737 | * This line allows connections from the primary | ||
738 | * partition but once one is connected from the | ||
739 | * primary partition nothing short of a reboot | ||
740 | * of linux will allow access from the hosting | ||
741 | * partition again without a required iSeries fix. | ||
742 | */ | ||
743 | pi->lp = event->xTargetLp; | ||
744 | } | ||
745 | |||
746 | spin_unlock_irqrestore(&consolelock, flags); | ||
747 | if (event->xRc != HvLpEvent_Rc_Good) | ||
748 | printk(VIOCONS_KERN_WARN | ||
749 | "handle_open_event: event->xRc == (%d).\n", | ||
750 | event->xRc); | ||
751 | |||
752 | if (event->xCorrelationToken != 0) { | ||
753 | atomic_t *aptr= (atomic_t *)event->xCorrelationToken; | ||
754 | atomic_set(aptr, 1); | ||
755 | } else | ||
756 | printk(VIOCONS_KERN_WARN | ||
757 | "weird...got open ack without atomic\n"); | ||
758 | return; | ||
759 | } | ||
760 | |||
761 | /* This had better require an ack, otherwise complain */ | ||
762 | if (!hvlpevent_need_ack(event)) { | ||
763 | printk(VIOCONS_KERN_WARN "viocharopen without ack bit!\n"); | ||
764 | return; | ||
765 | } | ||
766 | |||
767 | spin_lock_irqsave(&consolelock, flags); | ||
768 | /* Got the lock, don't cause console output */ | ||
769 | |||
770 | /* Make sure this is a good virtual tty */ | ||
771 | if (port >= VTTY_PORTS) { | ||
772 | event->xRc = HvLpEvent_Rc_SubtypeError; | ||
773 | cevent->subtype_result_code = viorc_openRejected; | ||
774 | /* | ||
775 | * Flag state here since we can't printk while holding | ||
776 | * a spinlock. | ||
777 | */ | ||
778 | reject = 1; | ||
779 | } else { | ||
780 | pi = &port_info[port]; | ||
781 | if ((pi->lp != HvLpIndexInvalid) && | ||
782 | (pi->lp != event->xSourceLp)) { | ||
783 | /* | ||
784 | * If this is tty is already connected to a different | ||
785 | * partition, fail. | ||
786 | */ | ||
787 | event->xRc = HvLpEvent_Rc_SubtypeError; | ||
788 | cevent->subtype_result_code = viorc_openRejected; | ||
789 | reject = 2; | ||
790 | } else { | ||
791 | pi->lp = event->xSourceLp; | ||
792 | event->xRc = HvLpEvent_Rc_Good; | ||
793 | cevent->subtype_result_code = viorc_good; | ||
794 | pi->seq = pi->ack = 0; | ||
795 | reject = 0; | ||
796 | } | ||
797 | } | ||
798 | |||
799 | spin_unlock_irqrestore(&consolelock, flags); | ||
800 | |||
801 | if (reject == 1) | ||
802 | printk(VIOCONS_KERN_WARN "open rejected: bad virtual tty.\n"); | ||
803 | else if (reject == 2) | ||
804 | printk(VIOCONS_KERN_WARN | ||
805 | "open rejected: console in exclusive use by another partition.\n"); | ||
806 | |||
807 | /* Return the acknowledgement */ | ||
808 | HvCallEvent_ackLpEvent(event); | ||
809 | } | ||
810 | |||
811 | /* | ||
812 | * Handle a close charLpEvent. This should ONLY be an Interrupt because the | ||
813 | * virtual console should never actually issue a close event to the hypervisor | ||
814 | * because the virtual console never goes away. A close event coming from the | ||
815 | * hypervisor simply means that there are no client consoles connected to the | ||
816 | * virtual console. | ||
817 | * | ||
818 | * Regardless of the number of connections masqueraded on the other side of | ||
819 | * the hypervisor ONLY ONE close event should be called to accompany the ONE | ||
820 | * open event that is called. The close event should ONLY be called when NO | ||
821 | * MORE connections (masqueraded or not) exist on the other side of the | ||
822 | * hypervisor. | ||
823 | */ | ||
824 | static void vioHandleCloseEvent(struct HvLpEvent *event) | ||
825 | { | ||
826 | unsigned long flags; | ||
827 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
828 | u8 port = cevent->virtual_device; | ||
829 | |||
830 | if (hvlpevent_is_int(event)) { | ||
831 | if (port >= VTTY_PORTS) { | ||
832 | printk(VIOCONS_KERN_WARN | ||
833 | "close message from invalid virtual device.\n"); | ||
834 | return; | ||
835 | } | ||
836 | |||
837 | /* For closes, just mark the console partition invalid */ | ||
838 | spin_lock_irqsave(&consolelock, flags); | ||
839 | /* Got the lock, don't cause console output */ | ||
840 | |||
841 | if (port_info[port].lp == event->xSourceLp) | ||
842 | port_info[port].lp = HvLpIndexInvalid; | ||
843 | |||
844 | spin_unlock_irqrestore(&consolelock, flags); | ||
845 | printk(VIOCONS_KERN_INFO "close from %d\n", event->xSourceLp); | ||
846 | } else | ||
847 | printk(VIOCONS_KERN_WARN | ||
848 | "got unexpected close acknowlegement\n"); | ||
849 | } | ||
850 | |||
851 | /* | ||
852 | * Handle a config charLpEvent. Could be either interrupt or ack | ||
853 | */ | ||
854 | static void vioHandleConfig(struct HvLpEvent *event) | ||
855 | { | ||
856 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
857 | |||
858 | HvCall_writeLogBuffer(cevent->data, cevent->len); | ||
859 | |||
860 | if (cevent->data[0] == 0x01) | ||
861 | printk(VIOCONS_KERN_INFO "window resized to %d: %d: %d: %d\n", | ||
862 | cevent->data[1], cevent->data[2], | ||
863 | cevent->data[3], cevent->data[4]); | ||
864 | else | ||
865 | printk(VIOCONS_KERN_WARN "unknown config event\n"); | ||
866 | } | ||
867 | |||
868 | /* | ||
869 | * Handle a data charLpEvent. | ||
870 | */ | ||
871 | static void vioHandleData(struct HvLpEvent *event) | ||
872 | { | ||
873 | struct tty_struct *tty; | ||
874 | unsigned long flags; | ||
875 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
876 | struct port_info *pi; | ||
877 | int index; | ||
878 | int num_pushed; | ||
879 | u8 port = cevent->virtual_device; | ||
880 | |||
881 | if (port >= VTTY_PORTS) { | ||
882 | printk(VIOCONS_KERN_WARN "data on invalid virtual device %d\n", | ||
883 | port); | ||
884 | return; | ||
885 | } | ||
886 | |||
887 | /* | ||
888 | * Hold the spinlock so that we don't take an interrupt that | ||
889 | * changes tty between the time we fetch the port_info | ||
890 | * pointer and the time we paranoia check. | ||
891 | */ | ||
892 | spin_lock_irqsave(&consolelock, flags); | ||
893 | pi = &port_info[port]; | ||
894 | |||
895 | /* | ||
896 | * Change 05/01/2003 - Ryan Arnold: If a partition other than | ||
897 | * the current exclusive partition tries to send us data | ||
898 | * events then just drop them on the floor because we don't | ||
899 | * want his stinking data. He isn't authorized to receive | ||
900 | * data because he wasn't the first one to get the console, | ||
901 | * therefore he shouldn't be allowed to send data either. | ||
902 | * This will work without an iSeries fix. | ||
903 | */ | ||
904 | if (pi->lp != event->xSourceLp) { | ||
905 | spin_unlock_irqrestore(&consolelock, flags); | ||
906 | return; | ||
907 | } | ||
908 | |||
909 | tty = pi->tty; | ||
910 | if (tty == NULL) { | ||
911 | spin_unlock_irqrestore(&consolelock, flags); | ||
912 | printk(VIOCONS_KERN_WARN "no tty for virtual device %d\n", | ||
913 | port); | ||
914 | return; | ||
915 | } | ||
916 | |||
917 | if (tty->magic != TTY_MAGIC) { | ||
918 | spin_unlock_irqrestore(&consolelock, flags); | ||
919 | printk(VIOCONS_KERN_WARN "tty bad magic\n"); | ||
920 | return; | ||
921 | } | ||
922 | |||
923 | /* | ||
924 | * Just to be paranoid, make sure the tty points back to this port | ||
925 | */ | ||
926 | pi = (struct port_info *)tty->driver_data; | ||
927 | if (!pi || viotty_paranoia_check(pi, tty->name, "vioHandleData")) { | ||
928 | spin_unlock_irqrestore(&consolelock, flags); | ||
929 | return; | ||
930 | } | ||
931 | spin_unlock_irqrestore(&consolelock, flags); | ||
932 | |||
933 | /* | ||
934 | * Change 07/21/2003 - Ryan Arnold: functionality added to | ||
935 | * support sysrq utilizing ^O as the sysrq key. The sysrq | ||
936 | * functionality will only work if built into the kernel and | ||
937 | * then only if sysrq is enabled through the proc filesystem. | ||
938 | */ | ||
939 | num_pushed = 0; | ||
940 | for (index = 0; index < cevent->len; index++) { | ||
941 | /* | ||
942 | * Will be optimized away if !CONFIG_MAGIC_SYSRQ: | ||
943 | */ | ||
944 | if (sysrq_on()) { | ||
945 | /* 0x0f is the ascii character for ^O */ | ||
946 | if (cevent->data[index] == '\x0f') { | ||
947 | vio_sysrq_pressed = 1; | ||
948 | /* | ||
949 | * continue because we don't want to add | ||
950 | * the sysrq key into the data string. | ||
951 | */ | ||
952 | continue; | ||
953 | } else if (vio_sysrq_pressed) { | ||
954 | handle_sysrq(cevent->data[index], tty); | ||
955 | vio_sysrq_pressed = 0; | ||
956 | /* | ||
957 | * continue because we don't want to add | ||
958 | * the sysrq sequence into the data string. | ||
959 | */ | ||
960 | continue; | ||
961 | } | ||
962 | } | ||
963 | /* | ||
964 | * The sysrq sequence isn't included in this check if | ||
965 | * sysrq is enabled and compiled into the kernel because | ||
966 | * the sequence will never get inserted into the buffer. | ||
967 | * Don't attempt to copy more data into the buffer than we | ||
968 | * have room for because it would fail without indication. | ||
969 | */ | ||
970 | if(tty_insert_flip_char(tty, cevent->data[index], TTY_NORMAL) == 0) { | ||
971 | printk(VIOCONS_KERN_WARN "input buffer overflow!\n"); | ||
972 | break; | ||
973 | } | ||
974 | num_pushed++; | ||
975 | } | ||
976 | |||
977 | if (num_pushed) | ||
978 | tty_flip_buffer_push(tty); | ||
979 | } | ||
980 | |||
981 | /* | ||
982 | * Handle an ack charLpEvent. | ||
983 | */ | ||
984 | static void vioHandleAck(struct HvLpEvent *event) | ||
985 | { | ||
986 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
987 | unsigned long flags; | ||
988 | u8 port = cevent->virtual_device; | ||
989 | |||
990 | if (port >= VTTY_PORTS) { | ||
991 | printk(VIOCONS_KERN_WARN "data on invalid virtual device\n"); | ||
992 | return; | ||
993 | } | ||
994 | |||
995 | spin_lock_irqsave(&consolelock, flags); | ||
996 | port_info[port].ack = event->xCorrelationToken; | ||
997 | spin_unlock_irqrestore(&consolelock, flags); | ||
998 | |||
999 | if (port_info[port].used) | ||
1000 | send_buffers(&port_info[port]); | ||
1001 | } | ||
1002 | |||
1003 | /* | ||
1004 | * Handle charLpEvents and route to the appropriate routine | ||
1005 | */ | ||
1006 | static void vioHandleCharEvent(struct HvLpEvent *event) | ||
1007 | { | ||
1008 | int charminor; | ||
1009 | |||
1010 | if (event == NULL) | ||
1011 | return; | ||
1012 | |||
1013 | charminor = event->xSubtype & VIOMINOR_SUBTYPE_MASK; | ||
1014 | switch (charminor) { | ||
1015 | case viocharopen: | ||
1016 | vioHandleOpenEvent(event); | ||
1017 | break; | ||
1018 | case viocharclose: | ||
1019 | vioHandleCloseEvent(event); | ||
1020 | break; | ||
1021 | case viochardata: | ||
1022 | vioHandleData(event); | ||
1023 | break; | ||
1024 | case viocharack: | ||
1025 | vioHandleAck(event); | ||
1026 | break; | ||
1027 | case viocharconfig: | ||
1028 | vioHandleConfig(event); | ||
1029 | break; | ||
1030 | default: | ||
1031 | if (hvlpevent_is_int(event) && hvlpevent_need_ack(event)) { | ||
1032 | event->xRc = HvLpEvent_Rc_InvalidSubtype; | ||
1033 | HvCallEvent_ackLpEvent(event); | ||
1034 | } | ||
1035 | } | ||
1036 | } | ||
1037 | |||
1038 | /* | ||
1039 | * Send an open event | ||
1040 | */ | ||
1041 | static int send_open(HvLpIndex remoteLp, void *sem) | ||
1042 | { | ||
1043 | return HvCallEvent_signalLpEventFast(remoteLp, | ||
1044 | HvLpEvent_Type_VirtualIo, | ||
1045 | viomajorsubtype_chario | viocharopen, | ||
1046 | HvLpEvent_AckInd_DoAck, HvLpEvent_AckType_ImmediateAck, | ||
1047 | viopath_sourceinst(remoteLp), | ||
1048 | viopath_targetinst(remoteLp), | ||
1049 | (u64)(unsigned long)sem, VIOVERSION << 16, | ||
1050 | 0, 0, 0, 0); | ||
1051 | } | ||
1052 | |||
1053 | static const struct tty_operations serial_ops = { | ||
1054 | .open = viotty_open, | ||
1055 | .close = viotty_close, | ||
1056 | .write = viotty_write, | ||
1057 | .put_char = viotty_put_char, | ||
1058 | .write_room = viotty_write_room, | ||
1059 | .chars_in_buffer = viotty_chars_in_buffer, | ||
1060 | .ioctl = viotty_ioctl, | ||
1061 | }; | ||
1062 | |||
1063 | static int __init viocons_init2(void) | ||
1064 | { | ||
1065 | atomic_t wait_flag; | ||
1066 | int rc; | ||
1067 | |||
1068 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) | ||
1069 | return -ENODEV; | ||
1070 | |||
1071 | /* +2 for fudge */ | ||
1072 | rc = viopath_open(HvLpConfig_getPrimaryLpIndex(), | ||
1073 | viomajorsubtype_chario, VIOCHAR_WINDOW + 2); | ||
1074 | if (rc) | ||
1075 | printk(VIOCONS_KERN_WARN "error opening to primary %d\n", rc); | ||
1076 | |||
1077 | if (viopath_hostLp == HvLpIndexInvalid) | ||
1078 | vio_set_hostlp(); | ||
1079 | |||
1080 | /* | ||
1081 | * And if the primary is not the same as the hosting LP, open to the | ||
1082 | * hosting lp | ||
1083 | */ | ||
1084 | if ((viopath_hostLp != HvLpIndexInvalid) && | ||
1085 | (viopath_hostLp != HvLpConfig_getPrimaryLpIndex())) { | ||
1086 | printk(VIOCONS_KERN_INFO "open path to hosting (%d)\n", | ||
1087 | viopath_hostLp); | ||
1088 | rc = viopath_open(viopath_hostLp, viomajorsubtype_chario, | ||
1089 | VIOCHAR_WINDOW + 2); /* +2 for fudge */ | ||
1090 | if (rc) | ||
1091 | printk(VIOCONS_KERN_WARN | ||
1092 | "error opening to partition %d: %d\n", | ||
1093 | viopath_hostLp, rc); | ||
1094 | } | ||
1095 | |||
1096 | if (vio_setHandler(viomajorsubtype_chario, vioHandleCharEvent) < 0) | ||
1097 | printk(VIOCONS_KERN_WARN | ||
1098 | "error seting handler for console events!\n"); | ||
1099 | |||
1100 | /* | ||
1101 | * First, try to open the console to the hosting lp. | ||
1102 | * Wait on a semaphore for the response. | ||
1103 | */ | ||
1104 | atomic_set(&wait_flag, 0); | ||
1105 | if ((viopath_isactive(viopath_hostLp)) && | ||
1106 | (send_open(viopath_hostLp, (void *)&wait_flag) == 0)) { | ||
1107 | printk(VIOCONS_KERN_INFO "hosting partition %d\n", | ||
1108 | viopath_hostLp); | ||
1109 | while (atomic_read(&wait_flag) == 0) | ||
1110 | mb(); | ||
1111 | atomic_set(&wait_flag, 0); | ||
1112 | } | ||
1113 | |||
1114 | /* | ||
1115 | * If we don't have an active console, try the primary | ||
1116 | */ | ||
1117 | if ((!viopath_isactive(port_info[0].lp)) && | ||
1118 | (viopath_isactive(HvLpConfig_getPrimaryLpIndex())) && | ||
1119 | (send_open(HvLpConfig_getPrimaryLpIndex(), (void *)&wait_flag) | ||
1120 | == 0)) { | ||
1121 | printk(VIOCONS_KERN_INFO "opening console to primary partition\n"); | ||
1122 | while (atomic_read(&wait_flag) == 0) | ||
1123 | mb(); | ||
1124 | } | ||
1125 | |||
1126 | /* Initialize the tty_driver structure */ | ||
1127 | viotty_driver = alloc_tty_driver(VTTY_PORTS); | ||
1128 | viotty_driver->owner = THIS_MODULE; | ||
1129 | viotty_driver->driver_name = "vioconsole"; | ||
1130 | viotty_driver->name = "tty"; | ||
1131 | viotty_driver->name_base = 1; | ||
1132 | viotty_driver->major = TTY_MAJOR; | ||
1133 | viotty_driver->minor_start = 1; | ||
1134 | viotty_driver->type = TTY_DRIVER_TYPE_CONSOLE; | ||
1135 | viotty_driver->subtype = 1; | ||
1136 | viotty_driver->init_termios = tty_std_termios; | ||
1137 | viotty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; | ||
1138 | tty_set_operations(viotty_driver, &serial_ops); | ||
1139 | |||
1140 | if (tty_register_driver(viotty_driver)) { | ||
1141 | printk(VIOCONS_KERN_WARN "couldn't register console driver\n"); | ||
1142 | put_tty_driver(viotty_driver); | ||
1143 | viotty_driver = NULL; | ||
1144 | } | ||
1145 | |||
1146 | unregister_console(&viocons_early); | ||
1147 | register_console(&viocons); | ||
1148 | |||
1149 | return 0; | ||
1150 | } | ||
1151 | |||
1152 | static int __init viocons_init(void) | ||
1153 | { | ||
1154 | int i; | ||
1155 | |||
1156 | if (!firmware_has_feature(FW_FEATURE_ISERIES)) | ||
1157 | return -ENODEV; | ||
1158 | |||
1159 | printk(VIOCONS_KERN_INFO "registering console\n"); | ||
1160 | for (i = 0; i < VTTY_PORTS; i++) { | ||
1161 | port_info[i].lp = HvLpIndexInvalid; | ||
1162 | port_info[i].magic = VIOTTY_MAGIC; | ||
1163 | } | ||
1164 | HvCall_setLogBufferFormatAndCodepage(HvCall_LogBuffer_ASCII, 437); | ||
1165 | add_preferred_console("viocons", 0, NULL); | ||
1166 | register_console(&viocons_early); | ||
1167 | return 0; | ||
1168 | } | ||
1169 | |||
1170 | console_initcall(viocons_init); | ||
1171 | module_init(viocons_init2); | ||
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 82a51f38a546..60359c360912 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -803,7 +803,25 @@ static inline int resize_screen(struct vc_data *vc, int width, int height, | |||
803 | */ | 803 | */ |
804 | #define VC_RESIZE_MAXCOL (32767) | 804 | #define VC_RESIZE_MAXCOL (32767) |
805 | #define VC_RESIZE_MAXROW (32767) | 805 | #define VC_RESIZE_MAXROW (32767) |
806 | int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | 806 | |
807 | /** | ||
808 | * vc_do_resize - resizing method for the tty | ||
809 | * @tty: tty being resized | ||
810 | * @real_tty: real tty (different to tty if a pty/tty pair) | ||
811 | * @vc: virtual console private data | ||
812 | * @cols: columns | ||
813 | * @lines: lines | ||
814 | * | ||
815 | * Resize a virtual console, clipping according to the actual constraints. | ||
816 | * If the caller passes a tty structure then update the termios winsize | ||
817 | * information and perform any neccessary signal handling. | ||
818 | * | ||
819 | * Caller must hold the console semaphore. Takes the termios mutex and | ||
820 | * ctrl_lock of the tty IFF a tty is passed. | ||
821 | */ | ||
822 | |||
823 | static int vc_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | ||
824 | struct vc_data *vc, unsigned int cols, unsigned int lines) | ||
807 | { | 825 | { |
808 | unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; | 826 | unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; |
809 | unsigned int old_cols, old_rows, old_row_size, old_screen_size; | 827 | unsigned int old_cols, old_rows, old_row_size, old_screen_size; |
@@ -907,26 +925,15 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | |||
907 | gotoxy(vc, vc->vc_x, vc->vc_y); | 925 | gotoxy(vc, vc->vc_x, vc->vc_y); |
908 | save_cur(vc); | 926 | save_cur(vc); |
909 | 927 | ||
910 | if (vc->vc_tty) { | 928 | if (tty) { |
911 | struct winsize ws, *cws = &vc->vc_tty->winsize; | 929 | /* Rewrite the requested winsize data with the actual |
912 | struct pid *pgrp = NULL; | 930 | resulting sizes */ |
913 | 931 | struct winsize ws; | |
914 | memset(&ws, 0, sizeof(ws)); | 932 | memset(&ws, 0, sizeof(ws)); |
915 | ws.ws_row = vc->vc_rows; | 933 | ws.ws_row = vc->vc_rows; |
916 | ws.ws_col = vc->vc_cols; | 934 | ws.ws_col = vc->vc_cols; |
917 | ws.ws_ypixel = vc->vc_scan_lines; | 935 | ws.ws_ypixel = vc->vc_scan_lines; |
918 | 936 | tty_do_resize(tty, real_tty, &ws); | |
919 | mutex_lock(&vc->vc_tty->termios_mutex); | ||
920 | spin_lock_irq(&vc->vc_tty->ctrl_lock); | ||
921 | if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col)) | ||
922 | pgrp = get_pid(vc->vc_tty->pgrp); | ||
923 | spin_unlock_irq(&vc->vc_tty->ctrl_lock); | ||
924 | if (pgrp) { | ||
925 | kill_pgrp(vc->vc_tty->pgrp, SIGWINCH, 1); | ||
926 | put_pid(pgrp); | ||
927 | } | ||
928 | *cws = ws; | ||
929 | mutex_unlock(&vc->vc_tty->termios_mutex); | ||
930 | } | 937 | } |
931 | 938 | ||
932 | if (CON_IS_VISIBLE(vc)) | 939 | if (CON_IS_VISIBLE(vc)) |
@@ -934,14 +941,47 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | |||
934 | return err; | 941 | return err; |
935 | } | 942 | } |
936 | 943 | ||
937 | int vc_lock_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | 944 | /** |
945 | * vc_resize - resize a VT | ||
946 | * @vc: virtual console | ||
947 | * @cols: columns | ||
948 | * @rows: rows | ||
949 | * | ||
950 | * Resize a virtual console as seen from the console end of things. We | ||
951 | * use the common vc_do_resize methods to update the structures. The | ||
952 | * caller must hold the console sem to protect console internals and | ||
953 | * vc->vc_tty | ||
954 | */ | ||
955 | |||
956 | int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) | ||
957 | { | ||
958 | return vc_do_resize(vc->vc_tty, vc->vc_tty, vc, cols, rows); | ||
959 | } | ||
960 | |||
961 | /** | ||
962 | * vt_resize - resize a VT | ||
963 | * @tty: tty to resize | ||
964 | * @real_tty: tty if a pty/tty pair | ||
965 | * @ws: winsize attributes | ||
966 | * | ||
967 | * Resize a virtual terminal. This is called by the tty layer as we | ||
968 | * register our own handler for resizing. The mutual helper does all | ||
969 | * the actual work. | ||
970 | * | ||
971 | * Takes the console sem and the called methods then take the tty | ||
972 | * termios_mutex and the tty ctrl_lock in that order. | ||
973 | */ | ||
974 | |||
975 | int vt_resize(struct tty_struct *tty, struct tty_struct *real_tty, | ||
976 | struct winsize *ws) | ||
938 | { | 977 | { |
939 | int rc; | 978 | struct vc_data *vc = tty->driver_data; |
979 | int ret; | ||
940 | 980 | ||
941 | acquire_console_sem(); | 981 | acquire_console_sem(); |
942 | rc = vc_resize(vc, cols, lines); | 982 | ret = vc_do_resize(tty, real_tty, vc, ws->ws_col, ws->ws_row); |
943 | release_console_sem(); | 983 | release_console_sem(); |
944 | return rc; | 984 | return ret; |
945 | } | 985 | } |
946 | 986 | ||
947 | void vc_deallocate(unsigned int currcons) | 987 | void vc_deallocate(unsigned int currcons) |
@@ -2909,6 +2949,7 @@ static const struct tty_operations con_ops = { | |||
2909 | .start = con_start, | 2949 | .start = con_start, |
2910 | .throttle = con_throttle, | 2950 | .throttle = con_throttle, |
2911 | .unthrottle = con_unthrottle, | 2951 | .unthrottle = con_unthrottle, |
2952 | .resize = vt_resize, | ||
2912 | }; | 2953 | }; |
2913 | 2954 | ||
2914 | int __init vty_init(void) | 2955 | int __init vty_init(void) |
@@ -4063,7 +4104,6 @@ EXPORT_SYMBOL(default_blu); | |||
4063 | EXPORT_SYMBOL(update_region); | 4104 | EXPORT_SYMBOL(update_region); |
4064 | EXPORT_SYMBOL(redraw_screen); | 4105 | EXPORT_SYMBOL(redraw_screen); |
4065 | EXPORT_SYMBOL(vc_resize); | 4106 | EXPORT_SYMBOL(vc_resize); |
4066 | EXPORT_SYMBOL(vc_lock_resize); | ||
4067 | EXPORT_SYMBOL(fg_console); | 4107 | EXPORT_SYMBOL(fg_console); |
4068 | EXPORT_SYMBOL(console_blank_hook); | 4108 | EXPORT_SYMBOL(console_blank_hook); |
4069 | EXPORT_SYMBOL(console_blanked); | 4109 | EXPORT_SYMBOL(console_blanked); |
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c index 3211afd9d57e..c904e9ad4a71 100644 --- a/drivers/char/vt_ioctl.c +++ b/drivers/char/vt_ioctl.c | |||
@@ -947,14 +947,16 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, | |||
947 | get_user(cc, &vtsizes->v_cols)) | 947 | get_user(cc, &vtsizes->v_cols)) |
948 | ret = -EFAULT; | 948 | ret = -EFAULT; |
949 | else { | 949 | else { |
950 | acquire_console_sem(); | ||
950 | for (i = 0; i < MAX_NR_CONSOLES; i++) { | 951 | for (i = 0; i < MAX_NR_CONSOLES; i++) { |
951 | vc = vc_cons[i].d; | 952 | vc = vc_cons[i].d; |
952 | 953 | ||
953 | if (vc) { | 954 | if (vc) { |
954 | vc->vc_resize_user = 1; | 955 | vc->vc_resize_user = 1; |
955 | vc_lock_resize(vc_cons[i].d, cc, ll); | 956 | vc_resize(vc_cons[i].d, cc, ll); |
956 | } | 957 | } |
957 | } | 958 | } |
959 | release_console_sem(); | ||
958 | } | 960 | } |
959 | break; | 961 | break; |
960 | } | 962 | } |
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.h b/drivers/char/xilinx_hwicap/buffer_icap.h index c5b1840906b2..8b0252bf06e2 100644 --- a/drivers/char/xilinx_hwicap/buffer_icap.h +++ b/drivers/char/xilinx_hwicap/buffer_icap.h | |||
@@ -38,7 +38,6 @@ | |||
38 | 38 | ||
39 | #include <linux/types.h> | 39 | #include <linux/types.h> |
40 | #include <linux/cdev.h> | 40 | #include <linux/cdev.h> |
41 | #include <linux/version.h> | ||
42 | #include <linux/platform_device.h> | 41 | #include <linux/platform_device.h> |
43 | 42 | ||
44 | #include <asm/io.h> | 43 | #include <asm/io.h> |
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.h b/drivers/char/xilinx_hwicap/fifo_icap.h index ffabd3ba2bd8..62bda453c90b 100644 --- a/drivers/char/xilinx_hwicap/fifo_icap.h +++ b/drivers/char/xilinx_hwicap/fifo_icap.h | |||
@@ -38,7 +38,6 @@ | |||
38 | 38 | ||
39 | #include <linux/types.h> | 39 | #include <linux/types.h> |
40 | #include <linux/cdev.h> | 40 | #include <linux/cdev.h> |
41 | #include <linux/version.h> | ||
42 | #include <linux/platform_device.h> | 41 | #include <linux/platform_device.h> |
43 | 42 | ||
44 | #include <asm/io.h> | 43 | #include <asm/io.h> |
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index 8bfee5fb7223..278c9857bcf5 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c | |||
@@ -74,7 +74,6 @@ | |||
74 | * currently programmed in the FPGA. | 74 | * currently programmed in the FPGA. |
75 | */ | 75 | */ |
76 | 76 | ||
77 | #include <linux/version.h> | ||
78 | #include <linux/module.h> | 77 | #include <linux/module.h> |
79 | #include <linux/kernel.h> | 78 | #include <linux/kernel.h> |
80 | #include <linux/types.h> | 79 | #include <linux/types.h> |
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.h b/drivers/char/xilinx_hwicap/xilinx_hwicap.h index 1f9c8b082dbe..24d0d9b938fb 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.h +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.h | |||
@@ -38,7 +38,6 @@ | |||
38 | 38 | ||
39 | #include <linux/types.h> | 39 | #include <linux/types.h> |
40 | #include <linux/cdev.h> | 40 | #include <linux/cdev.h> |
41 | #include <linux/version.h> | ||
42 | #include <linux/platform_device.h> | 41 | #include <linux/platform_device.h> |
43 | 42 | ||
44 | #include <asm/io.h> | 43 | #include <asm/io.h> |