diff options
308 files changed, 6444 insertions, 2276 deletions
diff --git a/Documentation/Intel-IOMMU.txt b/Documentation/Intel-IOMMU.txt new file mode 100644 index 000000000000..c2321903aa09 --- /dev/null +++ b/Documentation/Intel-IOMMU.txt | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | Linux IOMMU Support | ||
| 2 | =================== | ||
| 3 | |||
| 4 | The architecture spec can be obtained from the below location. | ||
| 5 | |||
| 6 | http://www.intel.com/technology/virtualization/ | ||
| 7 | |||
| 8 | This guide gives a quick cheat sheet for some basic understanding. | ||
| 9 | |||
| 10 | Some Keywords | ||
| 11 | |||
| 12 | DMAR - DMA remapping | ||
| 13 | DRHD - DMA Engine Reporting Structure | ||
| 14 | RMRR - Reserved memory Region Reporting Structure | ||
| 15 | ZLR - Zero length reads from PCI devices | ||
| 16 | IOVA - IO Virtual address. | ||
| 17 | |||
| 18 | Basic stuff | ||
| 19 | ----------- | ||
| 20 | |||
| 21 | ACPI enumerates and lists the different DMA engines in the platform, and | ||
| 22 | device scope relationships between PCI devices and which DMA engine controls | ||
| 23 | them. | ||
| 24 | |||
| 25 | What is RMRR? | ||
| 26 | ------------- | ||
| 27 | |||
| 28 | There are some devices the BIOS controls, for e.g USB devices to perform | ||
| 29 | PS2 emulation. The regions of memory used for these devices are marked | ||
| 30 | reserved in the e820 map. When we turn on DMA translation, DMA to those | ||
| 31 | regions will fail. Hence BIOS uses RMRR to specify these regions along with | ||
| 32 | devices that need to access these regions. OS is expected to setup | ||
| 33 | unity mappings for these regions for these devices to access these regions. | ||
| 34 | |||
| 35 | How is IOVA generated? | ||
| 36 | --------------------- | ||
| 37 | |||
| 38 | Well behaved drivers call pci_map_*() calls before sending command to device | ||
| 39 | that needs to perform DMA. Once DMA is completed and mapping is no longer | ||
| 40 | required, device performs a pci_unmap_*() calls to unmap the region. | ||
| 41 | |||
| 42 | The Intel IOMMU driver allocates a virtual address per domain. Each PCIE | ||
| 43 | device has its own domain (hence protection). Devices under p2p bridges | ||
| 44 | share the virtual address with all devices under the p2p bridge due to | ||
| 45 | transaction id aliasing for p2p bridges. | ||
| 46 | |||
| 47 | IOVA generation is pretty generic. We used the same technique as vmalloc() | ||
| 48 | but these are not global address spaces, but separate for each domain. | ||
| 49 | Different DMA engines may support different number of domains. | ||
| 50 | |||
| 51 | We also allocate gaurd pages with each mapping, so we can attempt to catch | ||
| 52 | any overflow that might happen. | ||
| 53 | |||
| 54 | |||
| 55 | Graphics Problems? | ||
| 56 | ------------------ | ||
| 57 | If you encounter issues with graphics devices, you can try adding | ||
| 58 | option intel_iommu=igfx_off to turn off the integrated graphics engine. | ||
| 59 | |||
| 60 | If it happens to be a PCI device included in the INCLUDE_ALL Engine, | ||
| 61 | then try enabling CONFIG_DMAR_GFX_WA to setup a 1-1 map. We hear | ||
| 62 | graphics drivers may be in process of using DMA api's in the near | ||
| 63 | future and at that time this option can be yanked out. | ||
| 64 | |||
| 65 | Some exceptions to IOVA | ||
| 66 | ----------------------- | ||
| 67 | Interrupt ranges are not address translated, (0xfee00000 - 0xfeefffff). | ||
| 68 | The same is true for peer to peer transactions. Hence we reserve the | ||
| 69 | address from PCI MMIO ranges so they are not allocated for IOVA addresses. | ||
| 70 | |||
| 71 | |||
| 72 | Fault reporting | ||
| 73 | --------------- | ||
| 74 | When errors are reported, the DMA engine signals via an interrupt. The fault | ||
| 75 | reason and device that caused it with fault reason is printed on console. | ||
| 76 | |||
| 77 | See below for sample. | ||
| 78 | |||
| 79 | |||
| 80 | Boot Message Sample | ||
| 81 | ------------------- | ||
| 82 | |||
| 83 | Something like this gets printed indicating presence of DMAR tables | ||
| 84 | in ACPI. | ||
| 85 | |||
| 86 | ACPI: DMAR (v001 A M I OEMDMAR 0x00000001 MSFT 0x00000097) @ 0x000000007f5b5ef0 | ||
| 87 | |||
| 88 | When DMAR is being processed and initialized by ACPI, prints DMAR locations | ||
| 89 | and any RMRR's processed. | ||
| 90 | |||
| 91 | ACPI DMAR:Host address width 36 | ||
| 92 | ACPI DMAR:DRHD (flags: 0x00000000)base: 0x00000000fed90000 | ||
| 93 | ACPI DMAR:DRHD (flags: 0x00000000)base: 0x00000000fed91000 | ||
| 94 | ACPI DMAR:DRHD (flags: 0x00000001)base: 0x00000000fed93000 | ||
| 95 | ACPI DMAR:RMRR base: 0x00000000000ed000 end: 0x00000000000effff | ||
| 96 | ACPI DMAR:RMRR base: 0x000000007f600000 end: 0x000000007fffffff | ||
| 97 | |||
| 98 | When DMAR is enabled for use, you will notice.. | ||
| 99 | |||
| 100 | PCI-DMA: Using DMAR IOMMU | ||
| 101 | |||
| 102 | Fault reporting | ||
| 103 | --------------- | ||
| 104 | |||
| 105 | DMAR:[DMA Write] Request device [00:02.0] fault addr 6df084000 | ||
| 106 | DMAR:[fault reason 05] PTE Write access is not set | ||
| 107 | DMAR:[DMA Write] Request device [00:02.0] fault addr 6df084000 | ||
| 108 | DMAR:[fault reason 05] PTE Write access is not set | ||
| 109 | |||
| 110 | TBD | ||
| 111 | ---- | ||
| 112 | |||
| 113 | - For compatibility testing, could use unity map domain for all devices, just | ||
| 114 | provide a 1-1 for all useful memory under a single domain for all devices. | ||
| 115 | - API for paravirt ops for abstracting functionlity for VMM folks. | ||
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 6b0f963f5379..6bb9be54ab76 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
| @@ -14,18 +14,6 @@ Who: Jiri Slaby <jirislaby@gmail.com> | |||
| 14 | 14 | ||
| 15 | --------------------------- | 15 | --------------------------- |
| 16 | 16 | ||
| 17 | What: V4L2 VIDIOC_G_MPEGCOMP and VIDIOC_S_MPEGCOMP | ||
| 18 | When: October 2007 | ||
| 19 | Why: Broken attempt to set MPEG compression parameters. These ioctls are | ||
| 20 | not able to implement the wide variety of parameters that can be set | ||
| 21 | by hardware MPEG encoders. A new MPEG control mechanism was created | ||
| 22 | in kernel 2.6.18 that replaces these ioctls. See the V4L2 specification | ||
| 23 | (section 1.9: Extended controls) for more information on this topic. | ||
| 24 | Who: Hans Verkuil <hverkuil@xs4all.nl> and | ||
| 25 | Mauro Carvalho Chehab <mchehab@infradead.org> | ||
| 26 | |||
| 27 | --------------------------- | ||
| 28 | |||
| 29 | What: dev->power.power_state | 17 | What: dev->power.power_state |
| 30 | When: July 2007 | 18 | When: July 2007 |
| 31 | Why: Broken design for runtime control over driver power states, confusing | 19 | Why: Broken design for runtime control over driver power states, confusing |
| @@ -49,10 +37,10 @@ Who: David Miller <davem@davemloft.net> | |||
| 49 | --------------------------- | 37 | --------------------------- |
| 50 | 38 | ||
| 51 | What: Video4Linux API 1 ioctls and video_decoder.h from Video devices. | 39 | What: Video4Linux API 1 ioctls and video_decoder.h from Video devices. |
| 52 | When: December 2006 | 40 | When: December 2008 |
| 53 | Files: include/linux/video_decoder.h | 41 | Files: include/linux/video_decoder.h include/linux/videodev.h |
| 54 | Check: include/linux/video_decoder.h | 42 | Check: include/linux/video_decoder.h include/linux/videodev.h |
| 55 | Why: V4L1 AP1 was replaced by V4L2 API. during migration from 2.4 to 2.6 | 43 | Why: V4L1 AP1 was replaced by V4L2 API during migration from 2.4 to 2.6 |
| 56 | series. The old API have lots of drawbacks and don't provide enough | 44 | series. The old API have lots of drawbacks and don't provide enough |
| 57 | means to work with all video and audio standards. The newer API is | 45 | means to work with all video and audio standards. The newer API is |
| 58 | already available on the main drivers and should be used instead. | 46 | already available on the main drivers and should be used instead. |
| @@ -61,7 +49,9 @@ Why: V4L1 AP1 was replaced by V4L2 API. during migration from 2.4 to 2.6 | |||
| 61 | Decoder iocts are using internally to allow video drivers to | 49 | Decoder iocts are using internally to allow video drivers to |
| 62 | communicate with video decoders. This should also be improved to allow | 50 | communicate with video decoders. This should also be improved to allow |
| 63 | V4L2 calls being translated into compatible internal ioctls. | 51 | V4L2 calls being translated into compatible internal ioctls. |
| 64 | Who: Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 52 | Compatibility ioctls will be provided, for a while, via |
| 53 | v4l1-compat module. | ||
| 54 | Who: Mauro Carvalho Chehab <mchehab@infradead.org> | ||
| 65 | 55 | ||
| 66 | --------------------------- | 56 | --------------------------- |
| 67 | 57 | ||
diff --git a/Documentation/filesystems/Exporting b/Documentation/filesystems/Exporting index 31047e0fe14b..87019d2b5981 100644 --- a/Documentation/filesystems/Exporting +++ b/Documentation/filesystems/Exporting | |||
| @@ -2,9 +2,12 @@ | |||
| 2 | Making Filesystems Exportable | 2 | Making Filesystems Exportable |
| 3 | ============================= | 3 | ============================= |
| 4 | 4 | ||
| 5 | Most filesystem operations require a dentry (or two) as a starting | 5 | Overview |
| 6 | -------- | ||
| 7 | |||
| 8 | All filesystem operations require a dentry (or two) as a starting | ||
| 6 | point. Local applications have a reference-counted hold on suitable | 9 | point. Local applications have a reference-counted hold on suitable |
| 7 | dentrys via open file descriptors or cwd/root. However remote | 10 | dentries via open file descriptors or cwd/root. However remote |
| 8 | applications that access a filesystem via a remote filesystem protocol | 11 | applications that access a filesystem via a remote filesystem protocol |
| 9 | such as NFS may not be able to hold such a reference, and so need a | 12 | such as NFS may not be able to hold such a reference, and so need a |
| 10 | different way to refer to a particular dentry. As the alternative | 13 | different way to refer to a particular dentry. As the alternative |
| @@ -13,14 +16,14 @@ server-reboot (among other things, though these tend to be the most | |||
| 13 | problematic), there is no simple answer like 'filename'. | 16 | problematic), there is no simple answer like 'filename'. |
| 14 | 17 | ||
| 15 | The mechanism discussed here allows each filesystem implementation to | 18 | The mechanism discussed here allows each filesystem implementation to |
| 16 | specify how to generate an opaque (out side of the filesystem) byte | 19 | specify how to generate an opaque (outside of the filesystem) byte |
| 17 | string for any dentry, and how to find an appropriate dentry for any | 20 | string for any dentry, and how to find an appropriate dentry for any |
| 18 | given opaque byte string. | 21 | given opaque byte string. |
| 19 | This byte string will be called a "filehandle fragment" as it | 22 | This byte string will be called a "filehandle fragment" as it |
| 20 | corresponds to part of an NFS filehandle. | 23 | corresponds to part of an NFS filehandle. |
| 21 | 24 | ||
| 22 | A filesystem which supports the mapping between filehandle fragments | 25 | A filesystem which supports the mapping between filehandle fragments |
| 23 | and dentrys will be termed "exportable". | 26 | and dentries will be termed "exportable". |
| 24 | 27 | ||
| 25 | 28 | ||
| 26 | 29 | ||
| @@ -89,11 +92,9 @@ For a filesystem to be exportable it must: | |||
| 89 | 1/ provide the filehandle fragment routines described below. | 92 | 1/ provide the filehandle fragment routines described below. |
| 90 | 2/ make sure that d_splice_alias is used rather than d_add | 93 | 2/ make sure that d_splice_alias is used rather than d_add |
| 91 | when ->lookup finds an inode for a given parent and name. | 94 | when ->lookup finds an inode for a given parent and name. |
| 92 | Typically the ->lookup routine will end: | 95 | Typically the ->lookup routine will end with a: |
| 93 | if (inode) | 96 | |
| 94 | return d_splice(inode, dentry); | 97 | return d_splice_alias(inode, dentry); |
| 95 | d_add(dentry, inode); | ||
| 96 | return NULL; | ||
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | 100 | ||
| @@ -101,67 +102,39 @@ For a filesystem to be exportable it must: | |||
| 101 | A file system implementation declares that instances of the filesystem | 102 | A file system implementation declares that instances of the filesystem |
| 102 | are exportable by setting the s_export_op field in the struct | 103 | are exportable by setting the s_export_op field in the struct |
| 103 | super_block. This field must point to a "struct export_operations" | 104 | super_block. This field must point to a "struct export_operations" |
| 104 | struct which could potentially be full of NULLs, though normally at | 105 | struct which has the following members: |
| 105 | least get_parent will be set. | 106 | |
| 106 | 107 | encode_fh (optional) | |
| 107 | The primary operations are decode_fh and encode_fh. | 108 | Takes a dentry and creates a filehandle fragment which can later be used |
| 108 | decode_fh takes a filehandle fragment and tries to find or create a | 109 | to find or create a dentry for the same object. The default |
| 109 | dentry for the object referred to by the filehandle. | 110 | implementation creates a filehandle fragment that encodes a 32bit inode |
| 110 | encode_fh takes a dentry and creates a filehandle fragment which can | 111 | and generation number for the inode encoded, and if necessary the |
| 111 | later be used to find/create a dentry for the same object. | 112 | same information for the parent. |
| 112 | 113 | ||
| 113 | decode_fh will probably make use of "find_exported_dentry". | 114 | fh_to_dentry (mandatory) |
| 114 | This function lives in the "exportfs" module which a filesystem does | 115 | Given a filehandle fragment, this should find the implied object and |
| 115 | not need unless it is being exported. So rather that calling | 116 | create a dentry for it (possibly with d_alloc_anon). |
| 116 | find_exported_dentry directly, each filesystem should call it through | 117 | |
| 117 | the find_exported_dentry pointer in it's export_operations table. | 118 | fh_to_parent (optional but strongly recommended) |
| 118 | This field is set correctly by the exporting agent (e.g. nfsd) when a | 119 | Given a filehandle fragment, this should find the parent of the |
| 119 | filesystem is exported, and before any export operations are called. | 120 | implied object and create a dentry for it (possibly with d_alloc_anon). |
| 120 | 121 | May fail if the filehandle fragment is too small. | |
| 121 | find_exported_dentry needs three support functions from the | 122 | |
| 122 | filesystem: | 123 | get_parent (optional but strongly recommended) |
| 123 | get_name. When given a parent dentry and a child dentry, this | 124 | When given a dentry for a directory, this should return a dentry for |
| 124 | should find a name in the directory identified by the parent | 125 | the parent. Quite possibly the parent dentry will have been allocated |
| 125 | dentry, which leads to the object identified by the child dentry. | 126 | by d_alloc_anon. The default get_parent function just returns an error |
| 126 | If no get_name function is supplied, a default implementation is | 127 | so any filehandle lookup that requires finding a parent will fail. |
| 127 | provided which uses vfs_readdir to find potential names, and | 128 | ->lookup("..") is *not* used as a default as it can leave ".." entries |
| 128 | matches inode numbers to find the correct match. | 129 | in the dcache which are too messy to work with. |
| 129 | 130 | ||
| 130 | get_parent. When given a dentry for a directory, this should return | 131 | get_name (optional) |
| 131 | a dentry for the parent. Quite possibly the parent dentry will | 132 | When given a parent dentry and a child dentry, this should find a name |
| 132 | have been allocated by d_alloc_anon. | 133 | in the directory identified by the parent dentry, which leads to the |
| 133 | The default get_parent function just returns an error so any | 134 | object identified by the child dentry. If no get_name function is |
| 134 | filehandle lookup that requires finding a parent will fail. | 135 | supplied, a default implementation is provided which uses vfs_readdir |
| 135 | ->lookup("..") is *not* used as a default as it can leave ".." | 136 | to find potential names, and matches inode numbers to find the correct |
| 136 | entries in the dcache which are too messy to work with. | 137 | match. |
| 137 | |||
| 138 | get_dentry. When given an opaque datum, this should find the | ||
| 139 | implied object and create a dentry for it (possibly with | ||
| 140 | d_alloc_anon). | ||
| 141 | The opaque datum is whatever is passed down by the decode_fh | ||
| 142 | function, and is often simply a fragment of the filehandle | ||
| 143 | fragment. | ||
| 144 | decode_fh passes two datums through find_exported_dentry. One that | ||
| 145 | should be used to identify the target object, and one that can be | ||
| 146 | used to identify the object's parent, should that be necessary. | ||
| 147 | The default get_dentry function assumes that the datum contains an | ||
| 148 | inode number and a generation number, and it attempts to get the | ||
| 149 | inode using "iget" and check it's validity by matching the | ||
| 150 | generation number. A filesystem should only depend on the default | ||
| 151 | if iget can safely be used this way. | ||
| 152 | |||
| 153 | If decode_fh and/or encode_fh are left as NULL, then default | ||
| 154 | implementations are used. These defaults are suitable for ext2 and | ||
| 155 | extremely similar filesystems (like ext3). | ||
| 156 | |||
| 157 | The default encode_fh creates a filehandle fragment from the inode | ||
| 158 | number and generation number of the target together with the inode | ||
| 159 | number and generation number of the parent (if the parent is | ||
| 160 | required). | ||
| 161 | |||
| 162 | The default decode_fh extract the target and parent datums from the | ||
| 163 | filehandle assuming the format used by the default encode_fh and | ||
| 164 | passed them to find_exported_dentry. | ||
| 165 | 138 | ||
| 166 | 139 | ||
| 167 | A filehandle fragment consists of an array of 1 or more 4byte words, | 140 | A filehandle fragment consists of an array of 1 or more 4byte words, |
| @@ -172,5 +145,3 @@ generated by encode_fh, in which case it will have been padded with | |||
| 172 | nuls. Rather, the encode_fh routine should choose a "type" which | 145 | nuls. Rather, the encode_fh routine should choose a "type" which |
| 173 | indicates the decode_fh how much of the filehandle is valid, and how | 146 | indicates the decode_fh how much of the filehandle is valid, and how |
| 174 | it should be interpreted. | 147 | it should be interpreted. |
| 175 | |||
| 176 | |||
diff --git a/Documentation/i386/boot.txt b/Documentation/i386/boot.txt index 35985b34d5a6..2f75e750e4f5 100644 --- a/Documentation/i386/boot.txt +++ b/Documentation/i386/boot.txt | |||
| @@ -168,6 +168,8 @@ Offset Proto Name Meaning | |||
| 168 | 0234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not | 168 | 0234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not |
| 169 | 0235/3 N/A pad2 Unused | 169 | 0235/3 N/A pad2 Unused |
| 170 | 0238/4 2.06+ cmdline_size Maximum size of the kernel command line | 170 | 0238/4 2.06+ cmdline_size Maximum size of the kernel command line |
| 171 | 023C/4 2.07+ hardware_subarch Hardware subarchitecture | ||
| 172 | 0240/8 2.07+ hardware_subarch_data Subarchitecture-specific data | ||
| 171 | 173 | ||
| 172 | (1) For backwards compatibility, if the setup_sects field contains 0, the | 174 | (1) For backwards compatibility, if the setup_sects field contains 0, the |
| 173 | real value is 4. | 175 | real value is 4. |
| @@ -204,7 +206,7 @@ boot loaders can ignore those fields. | |||
| 204 | 206 | ||
| 205 | The byte order of all fields is littleendian (this is x86, after all.) | 207 | The byte order of all fields is littleendian (this is x86, after all.) |
| 206 | 208 | ||
| 207 | Field name: setup_secs | 209 | Field name: setup_sects |
| 208 | Type: read | 210 | Type: read |
| 209 | Offset/size: 0x1f1/1 | 211 | Offset/size: 0x1f1/1 |
| 210 | Protocol: ALL | 212 | Protocol: ALL |
| @@ -356,6 +358,13 @@ Protocol: 2.00+ | |||
| 356 | - If 0, the protected-mode code is loaded at 0x10000. | 358 | - If 0, the protected-mode code is loaded at 0x10000. |
| 357 | - If 1, the protected-mode code is loaded at 0x100000. | 359 | - If 1, the protected-mode code is loaded at 0x100000. |
| 358 | 360 | ||
| 361 | Bit 6 (write): KEEP_SEGMENTS | ||
| 362 | Protocol: 2.07+ | ||
| 363 | - if 0, reload the segment registers in the 32bit entry point. | ||
| 364 | - if 1, do not reload the segment registers in the 32bit entry point. | ||
| 365 | Assume that %cs %ds %ss %es are all set to flat segments with | ||
| 366 | a base of 0 (or the equivalent for their environment). | ||
| 367 | |||
| 359 | Bit 7 (write): CAN_USE_HEAP | 368 | Bit 7 (write): CAN_USE_HEAP |
| 360 | Set this bit to 1 to indicate that the value entered in the | 369 | Set this bit to 1 to indicate that the value entered in the |
| 361 | heap_end_ptr is valid. If this field is clear, some setup code | 370 | heap_end_ptr is valid. If this field is clear, some setup code |
| @@ -480,6 +489,29 @@ Protocol: 2.06+ | |||
| 480 | cmdline_size characters. With protocol version 2.05 and earlier, the | 489 | cmdline_size characters. With protocol version 2.05 and earlier, the |
| 481 | maximum size was 255. | 490 | maximum size was 255. |
| 482 | 491 | ||
| 492 | Field name: hardware_subarch | ||
| 493 | Type: write | ||
| 494 | Offset/size: 0x23c/4 | ||
| 495 | Protocol: 2.07+ | ||
| 496 | |||
| 497 | In a paravirtualized environment the hardware low level architectural | ||
| 498 | pieces such as interrupt handling, page table handling, and | ||
| 499 | accessing process control registers needs to be done differently. | ||
| 500 | |||
| 501 | This field allows the bootloader to inform the kernel we are in one | ||
| 502 | one of those environments. | ||
| 503 | |||
| 504 | 0x00000000 The default x86/PC environment | ||
| 505 | 0x00000001 lguest | ||
| 506 | 0x00000002 Xen | ||
| 507 | |||
| 508 | Field name: hardware_subarch_data | ||
| 509 | Type: write | ||
| 510 | Offset/size: 0x240/8 | ||
| 511 | Protocol: 2.07+ | ||
| 512 | |||
| 513 | A pointer to data that is specific to hardware subarch | ||
| 514 | |||
| 483 | 515 | ||
| 484 | **** THE KERNEL COMMAND LINE | 516 | **** THE KERNEL COMMAND LINE |
| 485 | 517 | ||
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 6166e2d7da76..7a7753321a26 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt | |||
| @@ -519,17 +519,17 @@ more details, with real examples. | |||
| 519 | to the user why it stops. | 519 | to the user why it stops. |
| 520 | 520 | ||
| 521 | cc-cross-prefix | 521 | cc-cross-prefix |
| 522 | cc-cross-prefix is used to check if there exist a $(CC) in path with | 522 | cc-cross-prefix is used to check if there exists a $(CC) in path with |
| 523 | one of the listed prefixes. The first prefix where there exist a | 523 | one of the listed prefixes. The first prefix where there exist a |
| 524 | prefix$(CC) in the PATH is returned - and if no prefix$(CC) is found | 524 | prefix$(CC) in the PATH is returned - and if no prefix$(CC) is found |
| 525 | then nothing is returned. | 525 | then nothing is returned. |
| 526 | Additional prefixes are separated by a single space in the | 526 | Additional prefixes are separated by a single space in the |
| 527 | call of cc-cross-prefix. | 527 | call of cc-cross-prefix. |
| 528 | This functionality is usefull for architecture Makefile that try | 528 | This functionality is useful for architecture Makefiles that try |
| 529 | to set CROSS_COMPILE to well know values but may have several | 529 | to set CROSS_COMPILE to well-known values but may have several |
| 530 | values to select between. | 530 | values to select between. |
| 531 | It is recommended only to try to set CROSS_COMPILE is it is a cross | 531 | It is recommended only to try to set CROSS_COMPILE if it is a cross |
| 532 | build (host arch is different from target arch). And is CROSS_COMPILE | 532 | build (host arch is different from target arch). And if CROSS_COMPILE |
| 533 | is already set then leave it with the old value. | 533 | is already set then leave it with the old value. |
| 534 | 534 | ||
| 535 | Example: | 535 | Example: |
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 6accd360da73..b2361667839f 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
| @@ -772,6 +772,23 @@ and is between 256 and 4096 characters. It is defined in the file | |||
| 772 | 772 | ||
| 773 | inttest= [IA64] | 773 | inttest= [IA64] |
| 774 | 774 | ||
| 775 | intel_iommu= [DMAR] Intel IOMMU driver (DMAR) option | ||
| 776 | off | ||
| 777 | Disable intel iommu driver. | ||
| 778 | igfx_off [Default Off] | ||
| 779 | By default, gfx is mapped as normal device. If a gfx | ||
| 780 | device has a dedicated DMAR unit, the DMAR unit is | ||
| 781 | bypassed by not enabling DMAR with this option. In | ||
| 782 | this case, gfx device will use physical address for | ||
| 783 | DMA. | ||
| 784 | forcedac [x86_64] | ||
| 785 | With this option iommu will not optimize to look | ||
| 786 | for io virtual address below 32 bit forcing dual | ||
| 787 | address cycle on pci bus for cards supporting greater | ||
| 788 | than 32 bit addressing. The default is to look | ||
| 789 | for translation below 32 bit and if not available | ||
| 790 | then look in the higher range. | ||
| 791 | |||
| 775 | io7= [HW] IO7 for Marvel based alpha systems | 792 | io7= [HW] IO7 for Marvel based alpha systems |
| 776 | See comment before marvel_specify_io7 in | 793 | See comment before marvel_specify_io7 in |
| 777 | arch/alpha/kernel/core_marvel.c. | 794 | arch/alpha/kernel/core_marvel.c. |
diff --git a/Documentation/memory-hotplug.txt b/Documentation/memory-hotplug.txt index 5fbcc22c98e9..168117bd6ee8 100644 --- a/Documentation/memory-hotplug.txt +++ b/Documentation/memory-hotplug.txt | |||
| @@ -2,7 +2,8 @@ | |||
| 2 | Memory Hotplug | 2 | Memory Hotplug |
| 3 | ============== | 3 | ============== |
| 4 | 4 | ||
| 5 | Last Updated: Jul 28 2007 | 5 | Created: Jul 28 2007 |
| 6 | Add description of notifier of memory hotplug Oct 11 2007 | ||
| 6 | 7 | ||
| 7 | This document is about memory hotplug including how-to-use and current status. | 8 | This document is about memory hotplug including how-to-use and current status. |
| 8 | Because Memory Hotplug is still under development, contents of this text will | 9 | Because Memory Hotplug is still under development, contents of this text will |
| @@ -24,7 +25,8 @@ be changed often. | |||
| 24 | 6.1 Memory offline and ZONE_MOVABLE | 25 | 6.1 Memory offline and ZONE_MOVABLE |
| 25 | 6.2. How to offline memory | 26 | 6.2. How to offline memory |
| 26 | 7. Physical memory remove | 27 | 7. Physical memory remove |
| 27 | 8. Future Work List | 28 | 8. Memory hotplug event notifier |
| 29 | 9. Future Work List | ||
| 28 | 30 | ||
| 29 | Note(1): x86_64's has special implementation for memory hotplug. | 31 | Note(1): x86_64's has special implementation for memory hotplug. |
| 30 | This text does not describe it. | 32 | This text does not describe it. |
| @@ -307,8 +309,58 @@ Need more implementation yet.... | |||
| 307 | - Notification completion of remove works by OS to firmware. | 309 | - Notification completion of remove works by OS to firmware. |
| 308 | - Guard from remove if not yet. | 310 | - Guard from remove if not yet. |
| 309 | 311 | ||
| 312 | -------------------------------- | ||
| 313 | 8. Memory hotplug event notifier | ||
| 314 | -------------------------------- | ||
| 315 | Memory hotplug has event notifer. There are 6 types of notification. | ||
| 316 | |||
| 317 | MEMORY_GOING_ONLINE | ||
| 318 | Generated before new memory becomes available in order to be able to | ||
| 319 | prepare subsystems to handle memory. The page allocator is still unable | ||
| 320 | to allocate from the new memory. | ||
| 321 | |||
| 322 | MEMORY_CANCEL_ONLINE | ||
| 323 | Generated if MEMORY_GOING_ONLINE fails. | ||
| 324 | |||
| 325 | MEMORY_ONLINE | ||
| 326 | Generated when memory has succesfully brought online. The callback may | ||
| 327 | allocate pages from the new memory. | ||
| 328 | |||
| 329 | MEMORY_GOING_OFFLINE | ||
| 330 | Generated to begin the process of offlining memory. Allocations are no | ||
| 331 | longer possible from the memory but some of the memory to be offlined | ||
| 332 | is still in use. The callback can be used to free memory known to a | ||
| 333 | subsystem from the indicated memory section. | ||
| 334 | |||
| 335 | MEMORY_CANCEL_OFFLINE | ||
| 336 | Generated if MEMORY_GOING_OFFLINE fails. Memory is available again from | ||
| 337 | the section that we attempted to offline. | ||
| 338 | |||
| 339 | MEMORY_OFFLINE | ||
| 340 | Generated after offlining memory is complete. | ||
| 341 | |||
| 342 | A callback routine can be registered by | ||
| 343 | hotplug_memory_notifier(callback_func, priority) | ||
| 344 | |||
| 345 | The second argument of callback function (action) is event types of above. | ||
| 346 | The third argument is passed by pointer of struct memory_notify. | ||
| 347 | |||
| 348 | struct memory_notify { | ||
| 349 | unsigned long start_pfn; | ||
| 350 | unsigned long nr_pages; | ||
| 351 | int status_cahnge_nid; | ||
| 352 | } | ||
| 353 | |||
| 354 | start_pfn is start_pfn of online/offline memory. | ||
| 355 | nr_pages is # of pages of online/offline memory. | ||
| 356 | status_change_nid is set node id when N_HIGH_MEMORY of nodemask is (will be) | ||
| 357 | set/clear. It means a new(memoryless) node gets new memory by online and a | ||
| 358 | node loses all memory. If this is -1, then nodemask status is not changed. | ||
| 359 | If status_changed_nid >= 0, callback should create/discard structures for the | ||
| 360 | node if necessary. | ||
| 361 | |||
| 310 | -------------- | 362 | -------------- |
| 311 | 8. Future Work | 363 | 9. Future Work |
| 312 | -------------- | 364 | -------------- |
| 313 | - allowing memory hot-add to ZONE_MOVABLE. maybe we need some switch like | 365 | - allowing memory hot-add to ZONE_MOVABLE. maybe we need some switch like |
| 314 | sysctl or new control file. | 366 | sysctl or new control file. |
| @@ -1505,15 +1505,16 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) | |||
| 1505 | # and we build for the host arch | 1505 | # and we build for the host arch |
| 1506 | quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) | 1506 | quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) |
| 1507 | cmd_depmod = \ | 1507 | cmd_depmod = \ |
| 1508 | if [ -r System.map -a -x $(DEPMOD) -a "$(SUBARCH)" = "$(ARCH)" ]; then \ | 1508 | if [ -r System.map -a -x $(DEPMOD) ]; then \ |
| 1509 | $(DEPMOD) -ae -F System.map \ | 1509 | $(DEPMOD) -ae -F System.map \ |
| 1510 | $(if $(strip $(INSTALL_MOD_PATH)), -b $(INSTALL_MOD_PATH) -r) \ | 1510 | $(if $(strip $(INSTALL_MOD_PATH)), -b $(INSTALL_MOD_PATH) -r) \ |
| 1511 | $(KERNELRELEASE); \ | 1511 | $(KERNELRELEASE); \ |
| 1512 | fi | 1512 | fi |
| 1513 | 1513 | ||
| 1514 | # Create temporary dir for module support files | 1514 | # Create temporary dir for module support files |
| 1515 | cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR); rm -f $(MODVERDIR)/* | 1515 | # clean it up only when building all modules |
| 1516 | 1516 | cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ | |
| 1517 | $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) | ||
| 1517 | 1518 | ||
| 1518 | a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ | 1519 | a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ |
| 1519 | $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ | 1520 | $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ |
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c index e1c470752ebc..ee07dceae1d4 100644 --- a/arch/alpha/kernel/pci_iommu.c +++ b/arch/alpha/kernel/pci_iommu.c | |||
| @@ -465,7 +465,7 @@ EXPORT_SYMBOL(pci_free_consistent); | |||
| 465 | Write dma_length of each leader with the combined lengths of | 465 | Write dma_length of each leader with the combined lengths of |
| 466 | the mergable followers. */ | 466 | the mergable followers. */ |
| 467 | 467 | ||
| 468 | #define SG_ENT_VIRT_ADDRESS(SG) (page_address((SG)->page) + (SG)->offset) | 468 | #define SG_ENT_VIRT_ADDRESS(SG) (sg_virt((SG))) |
| 469 | #define SG_ENT_PHYS_ADDRESS(SG) __pa(SG_ENT_VIRT_ADDRESS(SG)) | 469 | #define SG_ENT_PHYS_ADDRESS(SG) __pa(SG_ENT_VIRT_ADDRESS(SG)) |
| 470 | 470 | ||
| 471 | static void | 471 | static void |
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 44ab0dad4035..9d371e476552 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c | |||
| @@ -442,7 +442,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
| 442 | BUG_ON(dir == DMA_NONE); | 442 | BUG_ON(dir == DMA_NONE); |
| 443 | 443 | ||
| 444 | for (i = 0; i < nents; i++, sg++) { | 444 | for (i = 0; i < nents; i++, sg++) { |
| 445 | struct page *page = sg->page; | 445 | struct page *page = sg_page(sg); |
| 446 | unsigned int offset = sg->offset; | 446 | unsigned int offset = sg->offset; |
| 447 | unsigned int length = sg->length; | 447 | unsigned int length = sg->length; |
| 448 | void *ptr = page_address(page) + offset; | 448 | void *ptr = page_address(page) + offset; |
diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c index 94d7b119b71e..a16cb03c5291 100644 --- a/arch/blackfin/kernel/dma-mapping.c +++ b/arch/blackfin/kernel/dma-mapping.c | |||
| @@ -160,8 +160,7 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
| 160 | BUG_ON(direction == DMA_NONE); | 160 | BUG_ON(direction == DMA_NONE); |
| 161 | 161 | ||
| 162 | for (i = 0; i < nents; i++, sg++) { | 162 | for (i = 0; i < nents; i++, sg++) { |
| 163 | sg->dma_address = (dma_addr_t)(page_address(sg->page) + | 163 | sg->dma_address = (dma_addr_t) sg_virt(sg); |
| 164 | sg->offset); | ||
| 165 | 164 | ||
| 166 | invalidate_dcache_range(sg_dma_address(sg), | 165 | invalidate_dcache_range(sg_dma_address(sg), |
| 167 | sg_dma_address(sg) + | 166 | sg_dma_address(sg) + |
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c index 3c95f4184b99..bc859a311eaf 100644 --- a/arch/ia64/hp/common/sba_iommu.c +++ b/arch/ia64/hp/common/sba_iommu.c | |||
| @@ -246,7 +246,7 @@ static int reserve_sba_gart = 1; | |||
| 246 | static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t); | 246 | static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t); |
| 247 | static SBA_INLINE void sba_free_range(struct ioc *, dma_addr_t, size_t); | 247 | static SBA_INLINE void sba_free_range(struct ioc *, dma_addr_t, size_t); |
| 248 | 248 | ||
| 249 | #define sba_sg_address(sg) (page_address((sg)->page) + (sg)->offset) | 249 | #define sba_sg_address(sg) sg_virt((sg)) |
| 250 | 250 | ||
| 251 | #ifdef FULL_VALID_PDIR | 251 | #ifdef FULL_VALID_PDIR |
| 252 | static u64 prefetch_spill_page; | 252 | static u64 prefetch_spill_page; |
diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c index a3a558a06757..6ef9b5219930 100644 --- a/arch/ia64/hp/sim/simscsi.c +++ b/arch/ia64/hp/sim/simscsi.c | |||
| @@ -131,7 +131,7 @@ simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset) | |||
| 131 | stat.fd = desc[sc->device->id]; | 131 | stat.fd = desc[sc->device->id]; |
| 132 | 132 | ||
| 133 | scsi_for_each_sg(sc, sl, scsi_sg_count(sc), i) { | 133 | scsi_for_each_sg(sc, sl, scsi_sg_count(sc), i) { |
| 134 | req.addr = __pa(page_address(sl->page) + sl->offset); | 134 | req.addr = __pa(sg_virt(sl)); |
| 135 | req.len = sl->length; | 135 | req.len = sl->length; |
| 136 | if (DBG) | 136 | if (DBG) |
| 137 | printk("simscsi_sg_%s @ %lx (off %lx) use_sg=%d len=%d\n", | 137 | printk("simscsi_sg_%s @ %lx (off %lx) use_sg=%d len=%d\n", |
| @@ -212,7 +212,7 @@ static void simscsi_fillresult(struct scsi_cmnd *sc, char *buf, unsigned len) | |||
| 212 | if (!len) | 212 | if (!len) |
| 213 | break; | 213 | break; |
| 214 | thislen = min(len, slp->length); | 214 | thislen = min(len, slp->length); |
| 215 | memcpy(page_address(slp->page) + slp->offset, buf, thislen); | 215 | memcpy(sg_virt(slp), buf, thislen); |
| 216 | len -= thislen; | 216 | len -= thislen; |
| 217 | } | 217 | } |
| 218 | } | 218 | } |
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c index 8e4894b205e2..3f7ea13358e9 100644 --- a/arch/ia64/kernel/efi.c +++ b/arch/ia64/kernel/efi.c | |||
| @@ -1090,7 +1090,8 @@ efi_memmap_init(unsigned long *s, unsigned long *e) | |||
| 1090 | 1090 | ||
| 1091 | void | 1091 | void |
| 1092 | efi_initialize_iomem_resources(struct resource *code_resource, | 1092 | efi_initialize_iomem_resources(struct resource *code_resource, |
| 1093 | struct resource *data_resource) | 1093 | struct resource *data_resource, |
| 1094 | struct resource *bss_resource) | ||
| 1094 | { | 1095 | { |
| 1095 | struct resource *res; | 1096 | struct resource *res; |
| 1096 | void *efi_map_start, *efi_map_end, *p; | 1097 | void *efi_map_start, *efi_map_end, *p; |
| @@ -1171,6 +1172,7 @@ efi_initialize_iomem_resources(struct resource *code_resource, | |||
| 1171 | */ | 1172 | */ |
| 1172 | insert_resource(res, code_resource); | 1173 | insert_resource(res, code_resource); |
| 1173 | insert_resource(res, data_resource); | 1174 | insert_resource(res, data_resource); |
| 1175 | insert_resource(res, bss_resource); | ||
| 1174 | #ifdef CONFIG_KEXEC | 1176 | #ifdef CONFIG_KEXEC |
| 1175 | insert_resource(res, &efi_memmap_res); | 1177 | insert_resource(res, &efi_memmap_res); |
| 1176 | insert_resource(res, &boot_param_res); | 1178 | insert_resource(res, &boot_param_res); |
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index cbf67f1aa291..ae6c3c02e117 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c | |||
| @@ -90,7 +90,12 @@ static struct resource code_resource = { | |||
| 90 | .name = "Kernel code", | 90 | .name = "Kernel code", |
| 91 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | 91 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM |
| 92 | }; | 92 | }; |
| 93 | extern char _text[], _end[], _etext[]; | 93 | |
| 94 | static struct resource bss_resource = { | ||
| 95 | .name = "Kernel bss", | ||
| 96 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | ||
| 97 | }; | ||
| 98 | extern char _text[], _end[], _etext[], _edata[], _bss[]; | ||
| 94 | 99 | ||
| 95 | unsigned long ia64_max_cacheline_size; | 100 | unsigned long ia64_max_cacheline_size; |
| 96 | 101 | ||
| @@ -200,8 +205,11 @@ static int __init register_memory(void) | |||
| 200 | code_resource.start = ia64_tpa(_text); | 205 | code_resource.start = ia64_tpa(_text); |
| 201 | code_resource.end = ia64_tpa(_etext) - 1; | 206 | code_resource.end = ia64_tpa(_etext) - 1; |
| 202 | data_resource.start = ia64_tpa(_etext); | 207 | data_resource.start = ia64_tpa(_etext); |
| 203 | data_resource.end = ia64_tpa(_end) - 1; | 208 | data_resource.end = ia64_tpa(_edata) - 1; |
| 204 | efi_initialize_iomem_resources(&code_resource, &data_resource); | 209 | bss_resource.start = ia64_tpa(_bss); |
| 210 | bss_resource.end = ia64_tpa(_end) - 1; | ||
| 211 | efi_initialize_iomem_resources(&code_resource, &data_resource, | ||
| 212 | &bss_resource); | ||
| 205 | 213 | ||
| 206 | return 0; | 214 | return 0; |
| 207 | } | 215 | } |
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c index ecd8a52b9b9e..511db2fd7bff 100644 --- a/arch/ia64/sn/pci/pci_dma.c +++ b/arch/ia64/sn/pci/pci_dma.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #include <asm/sn/pcidev.h> | 16 | #include <asm/sn/pcidev.h> |
| 17 | #include <asm/sn/sn_sal.h> | 17 | #include <asm/sn/sn_sal.h> |
| 18 | 18 | ||
| 19 | #define SG_ENT_VIRT_ADDRESS(sg) (page_address((sg)->page) + (sg)->offset) | 19 | #define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg))) |
| 20 | #define SG_ENT_PHYS_ADDRESS(SG) virt_to_phys(SG_ENT_VIRT_ADDRESS(SG)) | 20 | #define SG_ENT_PHYS_ADDRESS(SG) virt_to_phys(SG_ENT_VIRT_ADDRESS(SG)) |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
diff --git a/arch/m68k/kernel/dma.c b/arch/m68k/kernel/dma.c index 9d4e4b5b6bd8..ef490e1ce600 100644 --- a/arch/m68k/kernel/dma.c +++ b/arch/m68k/kernel/dma.c | |||
| @@ -121,7 +121,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
| 121 | int i; | 121 | int i; |
| 122 | 122 | ||
| 123 | for (i = 0; i < nents; sg++, i++) { | 123 | for (i = 0; i < nents; sg++, i++) { |
| 124 | sg->dma_address = page_to_phys(sg->page) + sg->offset; | 124 | sg->dma_address = sg_phys(sg); |
| 125 | dma_sync_single_for_device(dev, sg->dma_address, sg->length, dir); | 125 | dma_sync_single_for_device(dev, sg->dma_address, sg->length, dir); |
| 126 | } | 126 | } |
| 127 | return nents; | 127 | return nents; |
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c index 98b5e5bac02e..b0b034c4654f 100644 --- a/arch/mips/mm/dma-default.c +++ b/arch/mips/mm/dma-default.c | |||
| @@ -165,12 +165,11 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
| 165 | for (i = 0; i < nents; i++, sg++) { | 165 | for (i = 0; i < nents; i++, sg++) { |
| 166 | unsigned long addr; | 166 | unsigned long addr; |
| 167 | 167 | ||
| 168 | addr = (unsigned long) page_address(sg->page); | 168 | addr = (unsigned long) sg_virt(sg); |
| 169 | if (!plat_device_is_coherent(dev) && addr) | 169 | if (!plat_device_is_coherent(dev) && addr) |
| 170 | __dma_sync(addr + sg->offset, sg->length, direction); | 170 | __dma_sync(addr, sg->length, direction); |
| 171 | sg->dma_address = plat_map_dma_mem(dev, | 171 | sg->dma_address = plat_map_dma_mem(dev, |
| 172 | (void *)(addr + sg->offset), | 172 | (void *)addr, sg->length); |
| 173 | sg->length); | ||
| 174 | } | 173 | } |
| 175 | 174 | ||
| 176 | return nents; | 175 | return nents; |
| @@ -223,10 +222,9 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, | |||
| 223 | for (i = 0; i < nhwentries; i++, sg++) { | 222 | for (i = 0; i < nhwentries; i++, sg++) { |
| 224 | if (!plat_device_is_coherent(dev) && | 223 | if (!plat_device_is_coherent(dev) && |
| 225 | direction != DMA_TO_DEVICE) { | 224 | direction != DMA_TO_DEVICE) { |
| 226 | addr = (unsigned long) page_address(sg->page); | 225 | addr = (unsigned long) sg_virt(sg); |
| 227 | if (addr) | 226 | if (addr) |
| 228 | __dma_sync(addr + sg->offset, sg->length, | 227 | __dma_sync(addr, sg->length, direction); |
| 229 | direction); | ||
| 230 | } | 228 | } |
| 231 | plat_unmap_dma_mem(sg->dma_address); | 229 | plat_unmap_dma_mem(sg->dma_address); |
| 232 | } | 230 | } |
| @@ -304,7 +302,7 @@ void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, | |||
| 304 | /* Make sure that gcc doesn't leave the empty loop body. */ | 302 | /* Make sure that gcc doesn't leave the empty loop body. */ |
| 305 | for (i = 0; i < nelems; i++, sg++) { | 303 | for (i = 0; i < nelems; i++, sg++) { |
| 306 | if (cpu_is_noncoherent_r10000(dev)) | 304 | if (cpu_is_noncoherent_r10000(dev)) |
| 307 | __dma_sync((unsigned long)page_address(sg->page), | 305 | __dma_sync((unsigned long)page_address(sg_page(sg)), |
| 308 | sg->length, direction); | 306 | sg->length, direction); |
| 309 | plat_unmap_dma_mem(sg->dma_address); | 307 | plat_unmap_dma_mem(sg->dma_address); |
| 310 | } | 308 | } |
| @@ -322,7 +320,7 @@ void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nele | |||
| 322 | /* Make sure that gcc doesn't leave the empty loop body. */ | 320 | /* Make sure that gcc doesn't leave the empty loop body. */ |
| 323 | for (i = 0; i < nelems; i++, sg++) { | 321 | for (i = 0; i < nelems; i++, sg++) { |
| 324 | if (!plat_device_is_coherent(dev)) | 322 | if (!plat_device_is_coherent(dev)) |
| 325 | __dma_sync((unsigned long)page_address(sg->page), | 323 | __dma_sync((unsigned long)page_address(sg_page(sg)), |
| 326 | sg->length, direction); | 324 | sg->length, direction); |
| 327 | plat_unmap_dma_mem(sg->dma_address); | 325 | plat_unmap_dma_mem(sg->dma_address); |
| 328 | } | 326 | } |
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c index 9001104b56b0..14206e3f0819 100644 --- a/arch/powerpc/kernel/dma_64.c +++ b/arch/powerpc/kernel/dma_64.c | |||
| @@ -161,8 +161,7 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, | |||
| 161 | int i; | 161 | int i; |
| 162 | 162 | ||
| 163 | for_each_sg(sgl, sg, nents, i) { | 163 | for_each_sg(sgl, sg, nents, i) { |
| 164 | sg->dma_address = (page_to_phys(sg->page) + sg->offset) | | 164 | sg->dma_address = sg_phys(sg) | dma_direct_offset; |
| 165 | dma_direct_offset; | ||
| 166 | sg->dma_length = sg->length; | 165 | sg->dma_length = sg->length; |
| 167 | } | 166 | } |
| 168 | 167 | ||
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c index 289d7e935918..72fd87156b24 100644 --- a/arch/powerpc/kernel/ibmebus.c +++ b/arch/powerpc/kernel/ibmebus.c | |||
| @@ -102,8 +102,7 @@ static int ibmebus_map_sg(struct device *dev, | |||
| 102 | int i; | 102 | int i; |
| 103 | 103 | ||
| 104 | for_each_sg(sgl, sg, nents, i) { | 104 | for_each_sg(sgl, sg, nents, i) { |
| 105 | sg->dma_address = (dma_addr_t)page_address(sg->page) | 105 | sg->dma_address = (dma_addr_t) sg_virt(sg); |
| 106 | + sg->offset; | ||
| 107 | sg->dma_length = sg->length; | 106 | sg->dma_length = sg->length; |
| 108 | } | 107 | } |
| 109 | 108 | ||
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index 306a6f75b6c5..2d0c9ef555e9 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c | |||
| @@ -307,7 +307,7 @@ int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist, | |||
| 307 | continue; | 307 | continue; |
| 308 | } | 308 | } |
| 309 | /* Allocate iommu entries for that segment */ | 309 | /* Allocate iommu entries for that segment */ |
| 310 | vaddr = (unsigned long)page_address(s->page) + s->offset; | 310 | vaddr = (unsigned long) sg_virt(s); |
| 311 | npages = iommu_num_pages(vaddr, slen); | 311 | npages = iommu_num_pages(vaddr, slen); |
| 312 | entry = iommu_range_alloc(tbl, npages, &handle, mask >> IOMMU_PAGE_SHIFT, 0); | 312 | entry = iommu_range_alloc(tbl, npages, &handle, mask >> IOMMU_PAGE_SHIFT, 0); |
| 313 | 313 | ||
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c index 07e64b48e7fc..6405f4a36763 100644 --- a/arch/powerpc/platforms/ps3/system-bus.c +++ b/arch/powerpc/platforms/ps3/system-bus.c | |||
| @@ -628,9 +628,8 @@ static int ps3_sb_map_sg(struct device *_dev, struct scatterlist *sgl, | |||
| 628 | int i; | 628 | int i; |
| 629 | 629 | ||
| 630 | for_each_sg(sgl, sg, nents, i) { | 630 | for_each_sg(sgl, sg, nents, i) { |
| 631 | int result = ps3_dma_map(dev->d_region, | 631 | int result = ps3_dma_map(dev->d_region, sg_phys(sg), |
| 632 | page_to_phys(sg->page) + sg->offset, sg->length, | 632 | sg->length, &sg->dma_address, 0); |
| 633 | &sg->dma_address, 0); | ||
| 634 | 633 | ||
| 635 | if (result) { | 634 | if (result) { |
| 636 | pr_debug("%s:%d: ps3_dma_map failed (%d)\n", | 635 | pr_debug("%s:%d: ps3_dma_map failed (%d)\n", |
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index 9c3ed88853f3..97aa50d1e4ae 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c | |||
| @@ -727,9 +727,8 @@ int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sgl, int nents, | |||
| 727 | BUG_ON(direction == PCI_DMA_NONE); | 727 | BUG_ON(direction == PCI_DMA_NONE); |
| 728 | /* IIep is write-through, not flushing. */ | 728 | /* IIep is write-through, not flushing. */ |
| 729 | for_each_sg(sgl, sg, nents, n) { | 729 | for_each_sg(sgl, sg, nents, n) { |
| 730 | BUG_ON(page_address(sg->page) == NULL); | 730 | BUG_ON(page_address(sg_page(sg)) == NULL); |
| 731 | sg->dvma_address = | 731 | sg->dvma_address = virt_to_phys(sg_virt(sg)); |
| 732 | virt_to_phys(page_address(sg->page)) + sg->offset; | ||
| 733 | sg->dvma_length = sg->length; | 732 | sg->dvma_length = sg->length; |
| 734 | } | 733 | } |
| 735 | return nents; | 734 | return nents; |
| @@ -748,9 +747,9 @@ void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sgl, int nents, | |||
| 748 | BUG_ON(direction == PCI_DMA_NONE); | 747 | BUG_ON(direction == PCI_DMA_NONE); |
| 749 | if (direction != PCI_DMA_TODEVICE) { | 748 | if (direction != PCI_DMA_TODEVICE) { |
| 750 | for_each_sg(sgl, sg, nents, n) { | 749 | for_each_sg(sgl, sg, nents, n) { |
| 751 | BUG_ON(page_address(sg->page) == NULL); | 750 | BUG_ON(page_address(sg_page(sg)) == NULL); |
| 752 | mmu_inval_dma_area( | 751 | mmu_inval_dma_area( |
| 753 | (unsigned long) page_address(sg->page), | 752 | (unsigned long) page_address(sg_page(sg)), |
| 754 | (sg->length + PAGE_SIZE-1) & PAGE_MASK); | 753 | (sg->length + PAGE_SIZE-1) & PAGE_MASK); |
| 755 | } | 754 | } |
| 756 | } | 755 | } |
| @@ -798,9 +797,9 @@ void pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sgl, int | |||
| 798 | BUG_ON(direction == PCI_DMA_NONE); | 797 | BUG_ON(direction == PCI_DMA_NONE); |
| 799 | if (direction != PCI_DMA_TODEVICE) { | 798 | if (direction != PCI_DMA_TODEVICE) { |
| 800 | for_each_sg(sgl, sg, nents, n) { | 799 | for_each_sg(sgl, sg, nents, n) { |
| 801 | BUG_ON(page_address(sg->page) == NULL); | 800 | BUG_ON(page_address(sg_page(sg)) == NULL); |
| 802 | mmu_inval_dma_area( | 801 | mmu_inval_dma_area( |
| 803 | (unsigned long) page_address(sg->page), | 802 | (unsigned long) page_address(sg_page(sg)), |
| 804 | (sg->length + PAGE_SIZE-1) & PAGE_MASK); | 803 | (sg->length + PAGE_SIZE-1) & PAGE_MASK); |
| 805 | } | 804 | } |
| 806 | } | 805 | } |
| @@ -814,9 +813,9 @@ void pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sgl, | |||
| 814 | BUG_ON(direction == PCI_DMA_NONE); | 813 | BUG_ON(direction == PCI_DMA_NONE); |
| 815 | if (direction != PCI_DMA_TODEVICE) { | 814 | if (direction != PCI_DMA_TODEVICE) { |
| 816 | for_each_sg(sgl, sg, nents, n) { | 815 | for_each_sg(sgl, sg, nents, n) { |
| 817 | BUG_ON(page_address(sg->page) == NULL); | 816 | BUG_ON(page_address(sg_page(sg)) == NULL); |
| 818 | mmu_inval_dma_area( | 817 | mmu_inval_dma_area( |
| 819 | (unsigned long) page_address(sg->page), | 818 | (unsigned long) page_address(sg_page(sg)), |
| 820 | (sg->length + PAGE_SIZE-1) & PAGE_MASK); | 819 | (sg->length + PAGE_SIZE-1) & PAGE_MASK); |
| 821 | } | 820 | } |
| 822 | } | 821 | } |
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c index 375b4db63704..1666087c5b80 100644 --- a/arch/sparc/mm/io-unit.c +++ b/arch/sparc/mm/io-unit.c | |||
| @@ -144,7 +144,7 @@ static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus | |||
| 144 | spin_lock_irqsave(&iounit->lock, flags); | 144 | spin_lock_irqsave(&iounit->lock, flags); |
| 145 | while (sz != 0) { | 145 | while (sz != 0) { |
| 146 | --sz; | 146 | --sz; |
| 147 | sg->dvma_address = iounit_get_area(iounit, (unsigned long)page_address(sg->page) + sg->offset, sg->length); | 147 | sg->dvma_address = iounit_get_area(iounit, sg_virt(sg), sg->length); |
| 148 | sg->dvma_length = sg->length; | 148 | sg->dvma_length = sg->length; |
| 149 | sg = sg_next(sg); | 149 | sg = sg_next(sg); |
| 150 | } | 150 | } |
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c index 283656d9f6ea..4b934270f05e 100644 --- a/arch/sparc/mm/iommu.c +++ b/arch/sparc/mm/iommu.c | |||
| @@ -238,7 +238,7 @@ static void iommu_get_scsi_sgl_noflush(struct scatterlist *sg, int sz, struct sb | |||
| 238 | while (sz != 0) { | 238 | while (sz != 0) { |
| 239 | --sz; | 239 | --sz; |
| 240 | n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; | 240 | n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; |
| 241 | sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset; | 241 | sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset; |
| 242 | sg->dvma_length = (__u32) sg->length; | 242 | sg->dvma_length = (__u32) sg->length; |
| 243 | sg = sg_next(sg); | 243 | sg = sg_next(sg); |
| 244 | } | 244 | } |
| @@ -252,7 +252,7 @@ static void iommu_get_scsi_sgl_gflush(struct scatterlist *sg, int sz, struct sbu | |||
| 252 | while (sz != 0) { | 252 | while (sz != 0) { |
| 253 | --sz; | 253 | --sz; |
| 254 | n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; | 254 | n = (sg->length + sg->offset + PAGE_SIZE-1) >> PAGE_SHIFT; |
| 255 | sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset; | 255 | sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset; |
| 256 | sg->dvma_length = (__u32) sg->length; | 256 | sg->dvma_length = (__u32) sg->length; |
| 257 | sg = sg_next(sg); | 257 | sg = sg_next(sg); |
| 258 | } | 258 | } |
| @@ -273,7 +273,7 @@ static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbu | |||
| 273 | * XXX Is this a good assumption? | 273 | * XXX Is this a good assumption? |
| 274 | * XXX What if someone else unmaps it here and races us? | 274 | * XXX What if someone else unmaps it here and races us? |
| 275 | */ | 275 | */ |
| 276 | if ((page = (unsigned long) page_address(sg->page)) != 0) { | 276 | if ((page = (unsigned long) page_address(sg_page(sg))) != 0) { |
| 277 | for (i = 0; i < n; i++) { | 277 | for (i = 0; i < n; i++) { |
| 278 | if (page != oldpage) { /* Already flushed? */ | 278 | if (page != oldpage) { /* Already flushed? */ |
| 279 | flush_page_for_dma(page); | 279 | flush_page_for_dma(page); |
| @@ -283,7 +283,7 @@ static void iommu_get_scsi_sgl_pflush(struct scatterlist *sg, int sz, struct sbu | |||
| 283 | } | 283 | } |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | sg->dvma_address = iommu_get_one(sg->page, n, sbus) + sg->offset; | 286 | sg->dvma_address = iommu_get_one(sg_page(sg), n, sbus) + sg->offset; |
| 287 | sg->dvma_length = (__u32) sg->length; | 287 | sg->dvma_length = (__u32) sg->length; |
| 288 | sg = sg_next(sg); | 288 | sg = sg_next(sg); |
| 289 | } | 289 | } |
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c index ee6708fc4492..a2cc141291c7 100644 --- a/arch/sparc/mm/sun4c.c +++ b/arch/sparc/mm/sun4c.c | |||
| @@ -1228,7 +1228,7 @@ static void sun4c_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus * | |||
| 1228 | { | 1228 | { |
| 1229 | while (sz != 0) { | 1229 | while (sz != 0) { |
| 1230 | --sz; | 1230 | --sz; |
| 1231 | sg->dvma_address = (__u32)sun4c_lockarea(page_address(sg->page) + sg->offset, sg->length); | 1231 | sg->dvma_address = (__u32)sun4c_lockarea(sg_virt(sg), sg->length); |
| 1232 | sg->dvma_length = sg->length; | 1232 | sg->dvma_length = sg->length; |
| 1233 | sg = sg_next(sg); | 1233 | sg = sg_next(sg); |
| 1234 | } | 1234 | } |
diff --git a/arch/sparc64/kernel/iommu.c b/arch/sparc64/kernel/iommu.c index 29af777d7ac9..070a4846c0cb 100644 --- a/arch/sparc64/kernel/iommu.c +++ b/arch/sparc64/kernel/iommu.c | |||
| @@ -472,8 +472,7 @@ static void dma_4u_unmap_single(struct device *dev, dma_addr_t bus_addr, | |||
| 472 | spin_unlock_irqrestore(&iommu->lock, flags); | 472 | spin_unlock_irqrestore(&iommu->lock, flags); |
| 473 | } | 473 | } |
| 474 | 474 | ||
| 475 | #define SG_ENT_PHYS_ADDRESS(SG) \ | 475 | #define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG)))) |
| 476 | (__pa(page_address((SG)->page)) + (SG)->offset) | ||
| 477 | 476 | ||
| 478 | static void fill_sg(iopte_t *iopte, struct scatterlist *sg, | 477 | static void fill_sg(iopte_t *iopte, struct scatterlist *sg, |
| 479 | int nused, int nelems, | 478 | int nused, int nelems, |
| @@ -565,9 +564,7 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist, | |||
| 565 | /* Fast path single entry scatterlists. */ | 564 | /* Fast path single entry scatterlists. */ |
| 566 | if (nelems == 1) { | 565 | if (nelems == 1) { |
| 567 | sglist->dma_address = | 566 | sglist->dma_address = |
| 568 | dma_4u_map_single(dev, | 567 | dma_4u_map_single(dev, sg_virt(sglist), |
| 569 | (page_address(sglist->page) + | ||
| 570 | sglist->offset), | ||
| 571 | sglist->length, direction); | 568 | sglist->length, direction); |
| 572 | if (unlikely(sglist->dma_address == DMA_ERROR_CODE)) | 569 | if (unlikely(sglist->dma_address == DMA_ERROR_CODE)) |
| 573 | return 0; | 570 | return 0; |
diff --git a/arch/sparc64/kernel/iommu_common.c b/arch/sparc64/kernel/iommu_common.c index d7ca900ec51d..78e8277df655 100644 --- a/arch/sparc64/kernel/iommu_common.c +++ b/arch/sparc64/kernel/iommu_common.c | |||
| @@ -73,7 +73,7 @@ static int verify_one_map(struct scatterlist *dma_sg, struct scatterlist **__sg, | |||
| 73 | 73 | ||
| 74 | daddr = dma_sg->dma_address; | 74 | daddr = dma_sg->dma_address; |
| 75 | sglen = sg->length; | 75 | sglen = sg->length; |
| 76 | sgaddr = (unsigned long) (page_address(sg->page) + sg->offset); | 76 | sgaddr = (unsigned long) sg_virt(sg); |
| 77 | while (dlen > 0) { | 77 | while (dlen > 0) { |
| 78 | unsigned long paddr; | 78 | unsigned long paddr; |
| 79 | 79 | ||
| @@ -123,7 +123,7 @@ static int verify_one_map(struct scatterlist *dma_sg, struct scatterlist **__sg, | |||
| 123 | sg = sg_next(sg); | 123 | sg = sg_next(sg); |
| 124 | if (--nents <= 0) | 124 | if (--nents <= 0) |
| 125 | break; | 125 | break; |
| 126 | sgaddr = (unsigned long) (page_address(sg->page) + sg->offset); | 126 | sgaddr = (unsigned long) sg_virt(sg); |
| 127 | sglen = sg->length; | 127 | sglen = sg->length; |
| 128 | } | 128 | } |
| 129 | if (dlen < 0) { | 129 | if (dlen < 0) { |
| @@ -191,7 +191,7 @@ void verify_sglist(struct scatterlist *sglist, int nents, iopte_t *iopte, int np | |||
| 191 | printk("sg(%d): page_addr(%p) off(%x) length(%x) " | 191 | printk("sg(%d): page_addr(%p) off(%x) length(%x) " |
| 192 | "dma_address[%016x] dma_length[%016x]\n", | 192 | "dma_address[%016x] dma_length[%016x]\n", |
| 193 | i, | 193 | i, |
| 194 | page_address(sg->page), sg->offset, | 194 | page_address(sg_page(sg)), sg->offset, |
| 195 | sg->length, | 195 | sg->length, |
| 196 | sg->dma_address, sg->dma_length); | 196 | sg->dma_address, sg->dma_length); |
| 197 | } | 197 | } |
| @@ -207,15 +207,14 @@ unsigned long prepare_sg(struct scatterlist *sg, int nents) | |||
| 207 | unsigned long prev; | 207 | unsigned long prev; |
| 208 | u32 dent_addr, dent_len; | 208 | u32 dent_addr, dent_len; |
| 209 | 209 | ||
| 210 | prev = (unsigned long) (page_address(sg->page) + sg->offset); | 210 | prev = (unsigned long) sg_virt(sg); |
| 211 | prev += (unsigned long) (dent_len = sg->length); | 211 | prev += (unsigned long) (dent_len = sg->length); |
| 212 | dent_addr = (u32) ((unsigned long)(page_address(sg->page) + sg->offset) | 212 | dent_addr = (u32) ((unsigned long)(sg_virt(sg)) & (IO_PAGE_SIZE - 1UL)); |
| 213 | & (IO_PAGE_SIZE - 1UL)); | ||
| 214 | while (--nents) { | 213 | while (--nents) { |
| 215 | unsigned long addr; | 214 | unsigned long addr; |
| 216 | 215 | ||
| 217 | sg = sg_next(sg); | 216 | sg = sg_next(sg); |
| 218 | addr = (unsigned long) (page_address(sg->page) + sg->offset); | 217 | addr = (unsigned long) sg_virt(sg); |
| 219 | if (! VCONTIG(prev, addr)) { | 218 | if (! VCONTIG(prev, addr)) { |
| 220 | dma_sg->dma_address = dent_addr; | 219 | dma_sg->dma_address = dent_addr; |
| 221 | dma_sg->dma_length = dent_len; | 220 | dma_sg->dma_length = dent_len; |
diff --git a/arch/sparc64/kernel/ldc.c b/arch/sparc64/kernel/ldc.c index 85a2be0b0962..c8313cb60f0a 100644 --- a/arch/sparc64/kernel/ldc.c +++ b/arch/sparc64/kernel/ldc.c | |||
| @@ -2057,7 +2057,7 @@ static void fill_cookies(struct cookie_state *sp, unsigned long pa, | |||
| 2057 | 2057 | ||
| 2058 | static int sg_count_one(struct scatterlist *sg) | 2058 | static int sg_count_one(struct scatterlist *sg) |
| 2059 | { | 2059 | { |
| 2060 | unsigned long base = page_to_pfn(sg->page) << PAGE_SHIFT; | 2060 | unsigned long base = page_to_pfn(sg_page(sg)) << PAGE_SHIFT; |
| 2061 | long len = sg->length; | 2061 | long len = sg->length; |
| 2062 | 2062 | ||
| 2063 | if ((sg->offset | len) & (8UL - 1)) | 2063 | if ((sg->offset | len) & (8UL - 1)) |
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c index fe46ace3e59f..8c4875bdb4a8 100644 --- a/arch/sparc64/kernel/pci_sun4v.c +++ b/arch/sparc64/kernel/pci_sun4v.c | |||
| @@ -365,8 +365,7 @@ static void dma_4v_unmap_single(struct device *dev, dma_addr_t bus_addr, | |||
| 365 | spin_unlock_irqrestore(&iommu->lock, flags); | 365 | spin_unlock_irqrestore(&iommu->lock, flags); |
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | #define SG_ENT_PHYS_ADDRESS(SG) \ | 368 | #define SG_ENT_PHYS_ADDRESS(SG) (__pa(sg_virt((SG)))) |
| 369 | (__pa(page_address((SG)->page)) + (SG)->offset) | ||
| 370 | 369 | ||
| 371 | static long fill_sg(long entry, struct device *dev, | 370 | static long fill_sg(long entry, struct device *dev, |
| 372 | struct scatterlist *sg, | 371 | struct scatterlist *sg, |
| @@ -477,9 +476,7 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist, | |||
| 477 | /* Fast path single entry scatterlists. */ | 476 | /* Fast path single entry scatterlists. */ |
| 478 | if (nelems == 1) { | 477 | if (nelems == 1) { |
| 479 | sglist->dma_address = | 478 | sglist->dma_address = |
| 480 | dma_4v_map_single(dev, | 479 | dma_4v_map_single(dev, sg_virt(sglist), |
| 481 | (page_address(sglist->page) + | ||
| 482 | sglist->offset), | ||
| 483 | sglist->length, direction); | 480 | sglist->length, direction); |
| 484 | if (unlikely(sglist->dma_address == DMA_ERROR_CODE)) | 481 | if (unlikely(sglist->dma_address == DMA_ERROR_CODE)) |
| 485 | return 0; | 482 | return 0; |
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 25b248a02507..3a8cd3dfb51c 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c | |||
| @@ -1115,7 +1115,7 @@ static void do_ubd_request(struct request_queue *q) | |||
| 1115 | } | 1115 | } |
| 1116 | prepare_request(req, io_req, | 1116 | prepare_request(req, io_req, |
| 1117 | (unsigned long long) req->sector << 9, | 1117 | (unsigned long long) req->sector << 9, |
| 1118 | sg->offset, sg->length, sg->page); | 1118 | sg->offset, sg->length, sg_page(sg)); |
| 1119 | 1119 | ||
| 1120 | last_sectors = sg->length >> 9; | 1120 | last_sectors = sg->length >> 9; |
| 1121 | n = os_write_file(thread_fd, &io_req, | 1121 | n = os_write_file(thread_fd, &io_req, |
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S index f35ea2237522..a0ae2e7f6cec 100644 --- a/arch/x86/boot/compressed/head_32.S +++ b/arch/x86/boot/compressed/head_32.S | |||
| @@ -27,13 +27,22 @@ | |||
| 27 | #include <asm/segment.h> | 27 | #include <asm/segment.h> |
| 28 | #include <asm/page.h> | 28 | #include <asm/page.h> |
| 29 | #include <asm/boot.h> | 29 | #include <asm/boot.h> |
| 30 | #include <asm/asm-offsets.h> | ||
| 30 | 31 | ||
| 31 | .section ".text.head","ax",@progbits | 32 | .section ".text.head","ax",@progbits |
| 32 | .globl startup_32 | 33 | .globl startup_32 |
| 33 | 34 | ||
| 34 | startup_32: | 35 | startup_32: |
| 35 | cld | 36 | /* check to see if KEEP_SEGMENTS flag is meaningful */ |
| 36 | cli | 37 | cmpw $0x207, BP_version(%esi) |
| 38 | jb 1f | ||
| 39 | |||
| 40 | /* test KEEP_SEGMENTS flag to see if the bootloader is asking | ||
| 41 | * us to not reload segments */ | ||
| 42 | testb $(1<<6), BP_loadflags(%esi) | ||
| 43 | jnz 2f | ||
| 44 | |||
| 45 | 1: cli | ||
| 37 | movl $(__BOOT_DS),%eax | 46 | movl $(__BOOT_DS),%eax |
| 38 | movl %eax,%ds | 47 | movl %eax,%ds |
| 39 | movl %eax,%es | 48 | movl %eax,%es |
| @@ -41,6 +50,8 @@ startup_32: | |||
| 41 | movl %eax,%gs | 50 | movl %eax,%gs |
| 42 | movl %eax,%ss | 51 | movl %eax,%ss |
| 43 | 52 | ||
| 53 | 2: cld | ||
| 54 | |||
| 44 | /* Calculate the delta between where we were compiled to run | 55 | /* Calculate the delta between where we were compiled to run |
| 45 | * at and where we were actually loaded at. This can only be done | 56 | * at and where we were actually loaded at. This can only be done |
| 46 | * with a short local call on x86. Nothing else will tell us what | 57 | * with a short local call on x86. Nothing else will tell us what |
diff --git a/arch/x86/boot/compressed/misc_32.c b/arch/x86/boot/compressed/misc_32.c index 1dc1e19c0a9f..b74d60d1b2fa 100644 --- a/arch/x86/boot/compressed/misc_32.c +++ b/arch/x86/boot/compressed/misc_32.c | |||
| @@ -247,6 +247,9 @@ static void putstr(const char *s) | |||
| 247 | int x,y,pos; | 247 | int x,y,pos; |
| 248 | char c; | 248 | char c; |
| 249 | 249 | ||
| 250 | if (RM_SCREEN_INFO.orig_video_mode == 0 && lines == 0 && cols == 0) | ||
| 251 | return; | ||
| 252 | |||
| 250 | x = RM_SCREEN_INFO.orig_x; | 253 | x = RM_SCREEN_INFO.orig_x; |
| 251 | y = RM_SCREEN_INFO.orig_y; | 254 | y = RM_SCREEN_INFO.orig_y; |
| 252 | 255 | ||
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index f3140e596d40..8353c81c41c0 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S | |||
| @@ -119,7 +119,7 @@ _start: | |||
| 119 | # Part 2 of the header, from the old setup.S | 119 | # Part 2 of the header, from the old setup.S |
| 120 | 120 | ||
| 121 | .ascii "HdrS" # header signature | 121 | .ascii "HdrS" # header signature |
| 122 | .word 0x0206 # header version number (>= 0x0105) | 122 | .word 0x0207 # header version number (>= 0x0105) |
| 123 | # or else old loadlin-1.5 will fail) | 123 | # or else old loadlin-1.5 will fail) |
| 124 | .globl realmode_swtch | 124 | .globl realmode_swtch |
| 125 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG | 125 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG |
| @@ -214,6 +214,11 @@ cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line, | |||
| 214 | #added with boot protocol | 214 | #added with boot protocol |
| 215 | #version 2.06 | 215 | #version 2.06 |
| 216 | 216 | ||
| 217 | hardware_subarch: .long 0 # subarchitecture, added with 2.07 | ||
| 218 | # default to 0 for normal x86 PC | ||
| 219 | |||
| 220 | hardware_subarch_data: .quad 0 | ||
| 221 | |||
| 217 | # End of setup header ##################################################### | 222 | # End of setup header ##################################################### |
| 218 | 223 | ||
| 219 | .section ".inittext", "ax" | 224 | .section ".inittext", "ax" |
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c index f1b7cdda82b3..f8764716b0c0 100644 --- a/arch/x86/kernel/asm-offsets_32.c +++ b/arch/x86/kernel/asm-offsets_32.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <asm/fixmap.h> | 15 | #include <asm/fixmap.h> |
| 16 | #include <asm/processor.h> | 16 | #include <asm/processor.h> |
| 17 | #include <asm/thread_info.h> | 17 | #include <asm/thread_info.h> |
| 18 | #include <asm/bootparam.h> | ||
| 18 | #include <asm/elf.h> | 19 | #include <asm/elf.h> |
| 19 | 20 | ||
| 20 | #include <xen/interface/xen.h> | 21 | #include <xen/interface/xen.h> |
| @@ -146,4 +147,10 @@ void foo(void) | |||
| 146 | OFFSET(LGUEST_PAGES_regs_errcode, lguest_pages, regs.errcode); | 147 | OFFSET(LGUEST_PAGES_regs_errcode, lguest_pages, regs.errcode); |
| 147 | OFFSET(LGUEST_PAGES_regs, lguest_pages, regs); | 148 | OFFSET(LGUEST_PAGES_regs, lguest_pages, regs); |
| 148 | #endif | 149 | #endif |
| 150 | |||
| 151 | BLANK(); | ||
| 152 | OFFSET(BP_scratch, boot_params, scratch); | ||
| 153 | OFFSET(BP_loadflags, boot_params, hdr.loadflags); | ||
| 154 | OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch); | ||
| 155 | OFFSET(BP_version, boot_params, hdr.version); | ||
| 149 | } | 156 | } |
diff --git a/arch/x86/kernel/e820_32.c b/arch/x86/kernel/e820_32.c index 58fd54eb5577..18f500d185a2 100644 --- a/arch/x86/kernel/e820_32.c +++ b/arch/x86/kernel/e820_32.c | |||
| @@ -51,6 +51,13 @@ struct resource code_resource = { | |||
| 51 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | 51 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | struct resource bss_resource = { | ||
| 55 | .name = "Kernel bss", | ||
| 56 | .start = 0, | ||
| 57 | .end = 0, | ||
| 58 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | ||
| 59 | }; | ||
| 60 | |||
| 54 | static struct resource system_rom_resource = { | 61 | static struct resource system_rom_resource = { |
| 55 | .name = "System ROM", | 62 | .name = "System ROM", |
| 56 | .start = 0xf0000, | 63 | .start = 0xf0000, |
| @@ -254,7 +261,9 @@ static void __init probe_roms(void) | |||
| 254 | * and also for regions reported as reserved by the e820. | 261 | * and also for regions reported as reserved by the e820. |
| 255 | */ | 262 | */ |
| 256 | static void __init | 263 | static void __init |
| 257 | legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource) | 264 | legacy_init_iomem_resources(struct resource *code_resource, |
| 265 | struct resource *data_resource, | ||
| 266 | struct resource *bss_resource) | ||
| 258 | { | 267 | { |
| 259 | int i; | 268 | int i; |
| 260 | 269 | ||
| @@ -287,6 +296,7 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat | |||
| 287 | */ | 296 | */ |
| 288 | request_resource(res, code_resource); | 297 | request_resource(res, code_resource); |
| 289 | request_resource(res, data_resource); | 298 | request_resource(res, data_resource); |
| 299 | request_resource(res, bss_resource); | ||
| 290 | #ifdef CONFIG_KEXEC | 300 | #ifdef CONFIG_KEXEC |
| 291 | if (crashk_res.start != crashk_res.end) | 301 | if (crashk_res.start != crashk_res.end) |
| 292 | request_resource(res, &crashk_res); | 302 | request_resource(res, &crashk_res); |
| @@ -307,9 +317,11 @@ static int __init request_standard_resources(void) | |||
| 307 | 317 | ||
| 308 | printk("Setting up standard PCI resources\n"); | 318 | printk("Setting up standard PCI resources\n"); |
| 309 | if (efi_enabled) | 319 | if (efi_enabled) |
| 310 | efi_initialize_iomem_resources(&code_resource, &data_resource); | 320 | efi_initialize_iomem_resources(&code_resource, |
| 321 | &data_resource, &bss_resource); | ||
| 311 | else | 322 | else |
| 312 | legacy_init_iomem_resources(&code_resource, &data_resource); | 323 | legacy_init_iomem_resources(&code_resource, |
| 324 | &data_resource, &bss_resource); | ||
| 313 | 325 | ||
| 314 | /* EFI systems may still have VGA */ | 326 | /* EFI systems may still have VGA */ |
| 315 | request_resource(&iomem_resource, &video_ram_resource); | 327 | request_resource(&iomem_resource, &video_ram_resource); |
diff --git a/arch/x86/kernel/e820_64.c b/arch/x86/kernel/e820_64.c index 57616865d8a0..04698e0b056c 100644 --- a/arch/x86/kernel/e820_64.c +++ b/arch/x86/kernel/e820_64.c | |||
| @@ -47,7 +47,7 @@ unsigned long end_pfn_map; | |||
| 47 | */ | 47 | */ |
| 48 | static unsigned long __initdata end_user_pfn = MAXMEM>>PAGE_SHIFT; | 48 | static unsigned long __initdata end_user_pfn = MAXMEM>>PAGE_SHIFT; |
| 49 | 49 | ||
| 50 | extern struct resource code_resource, data_resource; | 50 | extern struct resource code_resource, data_resource, bss_resource; |
| 51 | 51 | ||
| 52 | /* Check for some hardcoded bad areas that early boot is not allowed to touch */ | 52 | /* Check for some hardcoded bad areas that early boot is not allowed to touch */ |
| 53 | static inline int bad_addr(unsigned long *addrp, unsigned long size) | 53 | static inline int bad_addr(unsigned long *addrp, unsigned long size) |
| @@ -225,6 +225,7 @@ void __init e820_reserve_resources(void) | |||
| 225 | */ | 225 | */ |
| 226 | request_resource(res, &code_resource); | 226 | request_resource(res, &code_resource); |
| 227 | request_resource(res, &data_resource); | 227 | request_resource(res, &data_resource); |
| 228 | request_resource(res, &bss_resource); | ||
| 228 | #ifdef CONFIG_KEXEC | 229 | #ifdef CONFIG_KEXEC |
| 229 | if (crashk_res.start != crashk_res.end) | 230 | if (crashk_res.start != crashk_res.end) |
| 230 | request_resource(res, &crashk_res); | 231 | request_resource(res, &crashk_res); |
| @@ -729,3 +730,22 @@ __init void e820_setup_gap(void) | |||
| 729 | printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n", | 730 | printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n", |
| 730 | pci_mem_start, gapstart, gapsize); | 731 | pci_mem_start, gapstart, gapsize); |
| 731 | } | 732 | } |
| 733 | |||
| 734 | int __init arch_get_ram_range(int slot, u64 *addr, u64 *size) | ||
| 735 | { | ||
| 736 | int i; | ||
| 737 | |||
| 738 | if (slot < 0 || slot >= e820.nr_map) | ||
| 739 | return -1; | ||
| 740 | for (i = slot; i < e820.nr_map; i++) { | ||
| 741 | if (e820.map[i].type != E820_RAM) | ||
| 742 | continue; | ||
| 743 | break; | ||
| 744 | } | ||
| 745 | if (i == e820.nr_map || e820.map[i].addr > (max_pfn << PAGE_SHIFT)) | ||
| 746 | return -1; | ||
| 747 | *addr = e820.map[i].addr; | ||
| 748 | *size = min_t(u64, e820.map[i].size + e820.map[i].addr, | ||
| 749 | max_pfn << PAGE_SHIFT) - *addr; | ||
| 750 | return i + 1; | ||
| 751 | } | ||
diff --git a/arch/x86/kernel/efi_32.c b/arch/x86/kernel/efi_32.c index b42558c48e9d..e2be78f49399 100644 --- a/arch/x86/kernel/efi_32.c +++ b/arch/x86/kernel/efi_32.c | |||
| @@ -603,7 +603,8 @@ void __init efi_enter_virtual_mode(void) | |||
| 603 | 603 | ||
| 604 | void __init | 604 | void __init |
| 605 | efi_initialize_iomem_resources(struct resource *code_resource, | 605 | efi_initialize_iomem_resources(struct resource *code_resource, |
| 606 | struct resource *data_resource) | 606 | struct resource *data_resource, |
| 607 | struct resource *bss_resource) | ||
| 607 | { | 608 | { |
| 608 | struct resource *res; | 609 | struct resource *res; |
| 609 | efi_memory_desc_t *md; | 610 | efi_memory_desc_t *md; |
| @@ -675,6 +676,7 @@ efi_initialize_iomem_resources(struct resource *code_resource, | |||
| 675 | if (md->type == EFI_CONVENTIONAL_MEMORY) { | 676 | if (md->type == EFI_CONVENTIONAL_MEMORY) { |
| 676 | request_resource(res, code_resource); | 677 | request_resource(res, code_resource); |
| 677 | request_resource(res, data_resource); | 678 | request_resource(res, data_resource); |
| 679 | request_resource(res, bss_resource); | ||
| 678 | #ifdef CONFIG_KEXEC | 680 | #ifdef CONFIG_KEXEC |
| 679 | request_resource(res, &crashk_res); | 681 | request_resource(res, &crashk_res); |
| 680 | #endif | 682 | #endif |
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S index 39677965e161..00b1c2c56454 100644 --- a/arch/x86/kernel/head_32.S +++ b/arch/x86/kernel/head_32.S | |||
| @@ -79,22 +79,30 @@ INIT_MAP_BEYOND_END = BOOTBITMAP_SIZE + (PAGE_TABLE_SIZE + ALLOCATOR_SLOP)*PAGE_ | |||
| 79 | */ | 79 | */ |
| 80 | .section .text.head,"ax",@progbits | 80 | .section .text.head,"ax",@progbits |
| 81 | ENTRY(startup_32) | 81 | ENTRY(startup_32) |
| 82 | /* check to see if KEEP_SEGMENTS flag is meaningful */ | ||
| 83 | cmpw $0x207, BP_version(%esi) | ||
| 84 | jb 1f | ||
| 85 | |||
| 86 | /* test KEEP_SEGMENTS flag to see if the bootloader is asking | ||
| 87 | us to not reload segments */ | ||
| 88 | testb $(1<<6), BP_loadflags(%esi) | ||
| 89 | jnz 2f | ||
| 82 | 90 | ||
| 83 | /* | 91 | /* |
| 84 | * Set segments to known values. | 92 | * Set segments to known values. |
| 85 | */ | 93 | */ |
| 86 | cld | 94 | 1: lgdt boot_gdt_descr - __PAGE_OFFSET |
| 87 | lgdt boot_gdt_descr - __PAGE_OFFSET | ||
| 88 | movl $(__BOOT_DS),%eax | 95 | movl $(__BOOT_DS),%eax |
| 89 | movl %eax,%ds | 96 | movl %eax,%ds |
| 90 | movl %eax,%es | 97 | movl %eax,%es |
| 91 | movl %eax,%fs | 98 | movl %eax,%fs |
| 92 | movl %eax,%gs | 99 | movl %eax,%gs |
| 100 | 2: | ||
| 93 | 101 | ||
| 94 | /* | 102 | /* |
| 95 | * Clear BSS first so that there are no surprises... | 103 | * Clear BSS first so that there are no surprises... |
| 96 | * No need to cld as DF is already clear from cld above... | ||
| 97 | */ | 104 | */ |
| 105 | cld | ||
| 98 | xorl %eax,%eax | 106 | xorl %eax,%eax |
| 99 | movl $__bss_start - __PAGE_OFFSET,%edi | 107 | movl $__bss_start - __PAGE_OFFSET,%edi |
| 100 | movl $__bss_stop - __PAGE_OFFSET,%ecx | 108 | movl $__bss_stop - __PAGE_OFFSET,%ecx |
| @@ -128,6 +136,35 @@ ENTRY(startup_32) | |||
| 128 | movsl | 136 | movsl |
| 129 | 1: | 137 | 1: |
| 130 | 138 | ||
| 139 | #ifdef CONFIG_PARAVIRT | ||
| 140 | cmpw $0x207, (boot_params + BP_version - __PAGE_OFFSET) | ||
| 141 | jb default_entry | ||
| 142 | |||
| 143 | /* Paravirt-compatible boot parameters. Look to see what architecture | ||
| 144 | we're booting under. */ | ||
| 145 | movl (boot_params + BP_hardware_subarch - __PAGE_OFFSET), %eax | ||
| 146 | cmpl $num_subarch_entries, %eax | ||
| 147 | jae bad_subarch | ||
| 148 | |||
| 149 | movl subarch_entries - __PAGE_OFFSET(,%eax,4), %eax | ||
| 150 | subl $__PAGE_OFFSET, %eax | ||
| 151 | jmp *%eax | ||
| 152 | |||
| 153 | bad_subarch: | ||
| 154 | WEAK(lguest_entry) | ||
| 155 | WEAK(xen_entry) | ||
| 156 | /* Unknown implementation; there's really | ||
| 157 | nothing we can do at this point. */ | ||
| 158 | ud2a | ||
| 159 | .data | ||
| 160 | subarch_entries: | ||
| 161 | .long default_entry /* normal x86/PC */ | ||
| 162 | .long lguest_entry /* lguest hypervisor */ | ||
| 163 | .long xen_entry /* Xen hypervisor */ | ||
| 164 | num_subarch_entries = (. - subarch_entries) / 4 | ||
| 165 | .previous | ||
| 166 | #endif /* CONFIG_PARAVIRT */ | ||
| 167 | |||
| 131 | /* | 168 | /* |
| 132 | * Initialize page tables. This creates a PDE and a set of page | 169 | * Initialize page tables. This creates a PDE and a set of page |
| 133 | * tables, which are located immediately beyond _end. The variable | 170 | * tables, which are located immediately beyond _end. The variable |
| @@ -140,6 +177,7 @@ ENTRY(startup_32) | |||
| 140 | */ | 177 | */ |
| 141 | page_pde_offset = (__PAGE_OFFSET >> 20); | 178 | page_pde_offset = (__PAGE_OFFSET >> 20); |
| 142 | 179 | ||
| 180 | default_entry: | ||
| 143 | movl $(pg0 - __PAGE_OFFSET), %edi | 181 | movl $(pg0 - __PAGE_OFFSET), %edi |
| 144 | movl $(swapper_pg_dir - __PAGE_OFFSET), %edx | 182 | movl $(swapper_pg_dir - __PAGE_OFFSET), %edx |
| 145 | movl $0x007, %eax /* 0x007 = PRESENT+RW+USER */ | 183 | movl $0x007, %eax /* 0x007 = PRESENT+RW+USER */ |
diff --git a/arch/x86/kernel/io_apic_64.c b/arch/x86/kernel/io_apic_64.c index b3c2d268d708..953328b55a30 100644 --- a/arch/x86/kernel/io_apic_64.c +++ b/arch/x86/kernel/io_apic_64.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include <linux/sysdev.h> | 31 | #include <linux/sysdev.h> |
| 32 | #include <linux/msi.h> | 32 | #include <linux/msi.h> |
| 33 | #include <linux/htirq.h> | 33 | #include <linux/htirq.h> |
| 34 | #include <linux/dmar.h> | ||
| 34 | #ifdef CONFIG_ACPI | 35 | #ifdef CONFIG_ACPI |
| 35 | #include <acpi/acpi_bus.h> | 36 | #include <acpi/acpi_bus.h> |
| 36 | #endif | 37 | #endif |
| @@ -2031,8 +2032,64 @@ void arch_teardown_msi_irq(unsigned int irq) | |||
| 2031 | destroy_irq(irq); | 2032 | destroy_irq(irq); |
| 2032 | } | 2033 | } |
| 2033 | 2034 | ||
| 2034 | #endif /* CONFIG_PCI_MSI */ | 2035 | #ifdef CONFIG_DMAR |
| 2036 | #ifdef CONFIG_SMP | ||
| 2037 | static void dmar_msi_set_affinity(unsigned int irq, cpumask_t mask) | ||
| 2038 | { | ||
| 2039 | struct irq_cfg *cfg = irq_cfg + irq; | ||
| 2040 | struct msi_msg msg; | ||
| 2041 | unsigned int dest; | ||
| 2042 | cpumask_t tmp; | ||
| 2043 | |||
| 2044 | cpus_and(tmp, mask, cpu_online_map); | ||
| 2045 | if (cpus_empty(tmp)) | ||
| 2046 | return; | ||
| 2047 | |||
| 2048 | if (assign_irq_vector(irq, mask)) | ||
| 2049 | return; | ||
| 2050 | |||
| 2051 | cpus_and(tmp, cfg->domain, mask); | ||
| 2052 | dest = cpu_mask_to_apicid(tmp); | ||
| 2053 | |||
| 2054 | dmar_msi_read(irq, &msg); | ||
| 2055 | |||
| 2056 | msg.data &= ~MSI_DATA_VECTOR_MASK; | ||
| 2057 | msg.data |= MSI_DATA_VECTOR(cfg->vector); | ||
| 2058 | msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK; | ||
| 2059 | msg.address_lo |= MSI_ADDR_DEST_ID(dest); | ||
| 2060 | |||
| 2061 | dmar_msi_write(irq, &msg); | ||
| 2062 | irq_desc[irq].affinity = mask; | ||
| 2063 | } | ||
| 2064 | #endif /* CONFIG_SMP */ | ||
| 2065 | |||
| 2066 | struct irq_chip dmar_msi_type = { | ||
| 2067 | .name = "DMAR_MSI", | ||
| 2068 | .unmask = dmar_msi_unmask, | ||
| 2069 | .mask = dmar_msi_mask, | ||
| 2070 | .ack = ack_apic_edge, | ||
| 2071 | #ifdef CONFIG_SMP | ||
| 2072 | .set_affinity = dmar_msi_set_affinity, | ||
| 2073 | #endif | ||
| 2074 | .retrigger = ioapic_retrigger_irq, | ||
| 2075 | }; | ||
| 2076 | |||
| 2077 | int arch_setup_dmar_msi(unsigned int irq) | ||
| 2078 | { | ||
| 2079 | int ret; | ||
| 2080 | struct msi_msg msg; | ||
| 2081 | |||
| 2082 | ret = msi_compose_msg(NULL, irq, &msg); | ||
| 2083 | if (ret < 0) | ||
| 2084 | return ret; | ||
| 2085 | dmar_msi_write(irq, &msg); | ||
| 2086 | set_irq_chip_and_handler_name(irq, &dmar_msi_type, handle_edge_irq, | ||
| 2087 | "edge"); | ||
| 2088 | return 0; | ||
| 2089 | } | ||
| 2090 | #endif | ||
| 2035 | 2091 | ||
| 2092 | #endif /* CONFIG_PCI_MSI */ | ||
| 2036 | /* | 2093 | /* |
| 2037 | * Hypertransport interrupt support | 2094 | * Hypertransport interrupt support |
| 2038 | */ | 2095 | */ |
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c index 5098f58063a5..1a20fe31338b 100644 --- a/arch/x86/kernel/pci-calgary_64.c +++ b/arch/x86/kernel/pci-calgary_64.c | |||
| @@ -411,8 +411,10 @@ static int calgary_nontranslate_map_sg(struct device* dev, | |||
| 411 | int i; | 411 | int i; |
| 412 | 412 | ||
| 413 | for_each_sg(sg, s, nelems, i) { | 413 | for_each_sg(sg, s, nelems, i) { |
| 414 | BUG_ON(!s->page); | 414 | struct page *p = sg_page(s); |
| 415 | s->dma_address = virt_to_bus(page_address(s->page) +s->offset); | 415 | |
| 416 | BUG_ON(!p); | ||
| 417 | s->dma_address = virt_to_bus(sg_virt(s)); | ||
| 416 | s->dma_length = s->length; | 418 | s->dma_length = s->length; |
| 417 | } | 419 | } |
| 418 | return nelems; | 420 | return nelems; |
| @@ -432,9 +434,9 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg, | |||
| 432 | return calgary_nontranslate_map_sg(dev, sg, nelems, direction); | 434 | return calgary_nontranslate_map_sg(dev, sg, nelems, direction); |
| 433 | 435 | ||
| 434 | for_each_sg(sg, s, nelems, i) { | 436 | for_each_sg(sg, s, nelems, i) { |
| 435 | BUG_ON(!s->page); | 437 | BUG_ON(!sg_page(s)); |
| 436 | 438 | ||
| 437 | vaddr = (unsigned long)page_address(s->page) + s->offset; | 439 | vaddr = (unsigned long) sg_virt(s); |
| 438 | npages = num_dma_pages(vaddr, s->length); | 440 | npages = num_dma_pages(vaddr, s->length); |
| 439 | 441 | ||
| 440 | entry = iommu_range_alloc(tbl, npages); | 442 | entry = iommu_range_alloc(tbl, npages); |
diff --git a/arch/x86/kernel/pci-dma_64.c b/arch/x86/kernel/pci-dma_64.c index afaf9f12c032..393e2725a6e3 100644 --- a/arch/x86/kernel/pci-dma_64.c +++ b/arch/x86/kernel/pci-dma_64.c | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <linux/string.h> | 7 | #include <linux/string.h> |
| 8 | #include <linux/pci.h> | 8 | #include <linux/pci.h> |
| 9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
| 10 | #include <linux/dmar.h> | ||
| 10 | #include <asm/io.h> | 11 | #include <asm/io.h> |
| 11 | #include <asm/iommu.h> | 12 | #include <asm/iommu.h> |
| 12 | #include <asm/calgary.h> | 13 | #include <asm/calgary.h> |
| @@ -305,6 +306,8 @@ void __init pci_iommu_alloc(void) | |||
| 305 | detect_calgary(); | 306 | detect_calgary(); |
| 306 | #endif | 307 | #endif |
| 307 | 308 | ||
| 309 | detect_intel_iommu(); | ||
| 310 | |||
| 308 | #ifdef CONFIG_SWIOTLB | 311 | #ifdef CONFIG_SWIOTLB |
| 309 | pci_swiotlb_init(); | 312 | pci_swiotlb_init(); |
| 310 | #endif | 313 | #endif |
| @@ -316,6 +319,8 @@ static int __init pci_iommu_init(void) | |||
| 316 | calgary_iommu_init(); | 319 | calgary_iommu_init(); |
| 317 | #endif | 320 | #endif |
| 318 | 321 | ||
| 322 | intel_iommu_init(); | ||
| 323 | |||
| 319 | #ifdef CONFIG_IOMMU | 324 | #ifdef CONFIG_IOMMU |
| 320 | gart_iommu_init(); | 325 | gart_iommu_init(); |
| 321 | #endif | 326 | #endif |
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c index 5cdfab65e93f..c56e9ee64964 100644 --- a/arch/x86/kernel/pci-gart_64.c +++ b/arch/x86/kernel/pci-gart_64.c | |||
| @@ -302,7 +302,7 @@ static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg, | |||
| 302 | #endif | 302 | #endif |
| 303 | 303 | ||
| 304 | for_each_sg(sg, s, nents, i) { | 304 | for_each_sg(sg, s, nents, i) { |
| 305 | unsigned long addr = page_to_phys(s->page) + s->offset; | 305 | unsigned long addr = sg_phys(s); |
| 306 | if (nonforced_iommu(dev, addr, s->length)) { | 306 | if (nonforced_iommu(dev, addr, s->length)) { |
| 307 | addr = dma_map_area(dev, addr, s->length, dir); | 307 | addr = dma_map_area(dev, addr, s->length, dir); |
| 308 | if (addr == bad_dma_address) { | 308 | if (addr == bad_dma_address) { |
| @@ -397,7 +397,7 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
| 397 | start_sg = sgmap = sg; | 397 | start_sg = sgmap = sg; |
| 398 | ps = NULL; /* shut up gcc */ | 398 | ps = NULL; /* shut up gcc */ |
| 399 | for_each_sg(sg, s, nents, i) { | 399 | for_each_sg(sg, s, nents, i) { |
| 400 | dma_addr_t addr = page_to_phys(s->page) + s->offset; | 400 | dma_addr_t addr = sg_phys(s); |
| 401 | s->dma_address = addr; | 401 | s->dma_address = addr; |
| 402 | BUG_ON(s->length == 0); | 402 | BUG_ON(s->length == 0); |
| 403 | 403 | ||
diff --git a/arch/x86/kernel/pci-nommu_64.c b/arch/x86/kernel/pci-nommu_64.c index e85d4360360c..faf70bdca335 100644 --- a/arch/x86/kernel/pci-nommu_64.c +++ b/arch/x86/kernel/pci-nommu_64.c | |||
| @@ -62,8 +62,8 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg, | |||
| 62 | int i; | 62 | int i; |
| 63 | 63 | ||
| 64 | for_each_sg(sg, s, nents, i) { | 64 | for_each_sg(sg, s, nents, i) { |
| 65 | BUG_ON(!s->page); | 65 | BUG_ON(!sg_page(s)); |
| 66 | s->dma_address = virt_to_bus(page_address(s->page) +s->offset); | 66 | s->dma_address = virt_to_bus(sg_virt(s)); |
| 67 | if (!check_addr("map_sg", hwdev, s->dma_address, s->length)) | 67 | if (!check_addr("map_sg", hwdev, s->dma_address, s->length)) |
| 68 | return 0; | 68 | return 0; |
| 69 | s->dma_length = s->length; | 69 | s->dma_length = s->length; |
diff --git a/arch/x86/kernel/setup_32.c b/arch/x86/kernel/setup_32.c index ba2e165a8a0f..cc0e91447b76 100644 --- a/arch/x86/kernel/setup_32.c +++ b/arch/x86/kernel/setup_32.c | |||
| @@ -60,6 +60,7 @@ | |||
| 60 | #include <asm/vmi.h> | 60 | #include <asm/vmi.h> |
| 61 | #include <setup_arch.h> | 61 | #include <setup_arch.h> |
| 62 | #include <bios_ebda.h> | 62 | #include <bios_ebda.h> |
| 63 | #include <asm/cacheflush.h> | ||
| 63 | 64 | ||
| 64 | /* This value is set up by the early boot code to point to the value | 65 | /* This value is set up by the early boot code to point to the value |
| 65 | immediately after the boot time page tables. It contains a *physical* | 66 | immediately after the boot time page tables. It contains a *physical* |
| @@ -73,6 +74,7 @@ int disable_pse __devinitdata = 0; | |||
| 73 | */ | 74 | */ |
| 74 | extern struct resource code_resource; | 75 | extern struct resource code_resource; |
| 75 | extern struct resource data_resource; | 76 | extern struct resource data_resource; |
| 77 | extern struct resource bss_resource; | ||
| 76 | 78 | ||
| 77 | /* cpu data as detected by the assembly code in head.S */ | 79 | /* cpu data as detected by the assembly code in head.S */ |
| 78 | struct cpuinfo_x86 new_cpu_data __cpuinitdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; | 80 | struct cpuinfo_x86 new_cpu_data __cpuinitdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; |
| @@ -600,6 +602,8 @@ void __init setup_arch(char **cmdline_p) | |||
| 600 | code_resource.end = virt_to_phys(_etext)-1; | 602 | code_resource.end = virt_to_phys(_etext)-1; |
| 601 | data_resource.start = virt_to_phys(_etext); | 603 | data_resource.start = virt_to_phys(_etext); |
| 602 | data_resource.end = virt_to_phys(_edata)-1; | 604 | data_resource.end = virt_to_phys(_edata)-1; |
| 605 | bss_resource.start = virt_to_phys(&__bss_start); | ||
| 606 | bss_resource.end = virt_to_phys(&__bss_stop)-1; | ||
| 603 | 607 | ||
| 604 | parse_early_param(); | 608 | parse_early_param(); |
| 605 | 609 | ||
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c index 31322d42eaae..e7a9e36bd52d 100644 --- a/arch/x86/kernel/setup_64.c +++ b/arch/x86/kernel/setup_64.c | |||
| @@ -58,6 +58,7 @@ | |||
| 58 | #include <asm/numa.h> | 58 | #include <asm/numa.h> |
| 59 | #include <asm/sections.h> | 59 | #include <asm/sections.h> |
| 60 | #include <asm/dmi.h> | 60 | #include <asm/dmi.h> |
| 61 | #include <asm/cacheflush.h> | ||
| 61 | 62 | ||
| 62 | /* | 63 | /* |
| 63 | * Machine setup.. | 64 | * Machine setup.. |
| @@ -133,6 +134,12 @@ struct resource code_resource = { | |||
| 133 | .end = 0, | 134 | .end = 0, |
| 134 | .flags = IORESOURCE_RAM, | 135 | .flags = IORESOURCE_RAM, |
| 135 | }; | 136 | }; |
| 137 | struct resource bss_resource = { | ||
| 138 | .name = "Kernel bss", | ||
| 139 | .start = 0, | ||
| 140 | .end = 0, | ||
| 141 | .flags = IORESOURCE_RAM, | ||
| 142 | }; | ||
| 136 | 143 | ||
| 137 | #ifdef CONFIG_PROC_VMCORE | 144 | #ifdef CONFIG_PROC_VMCORE |
| 138 | /* elfcorehdr= specifies the location of elf core header | 145 | /* elfcorehdr= specifies the location of elf core header |
| @@ -276,6 +283,8 @@ void __init setup_arch(char **cmdline_p) | |||
| 276 | code_resource.end = virt_to_phys(&_etext)-1; | 283 | code_resource.end = virt_to_phys(&_etext)-1; |
| 277 | data_resource.start = virt_to_phys(&_etext); | 284 | data_resource.start = virt_to_phys(&_etext); |
| 278 | data_resource.end = virt_to_phys(&_edata)-1; | 285 | data_resource.end = virt_to_phys(&_edata)-1; |
| 286 | bss_resource.start = virt_to_phys(&__bss_start); | ||
| 287 | bss_resource.end = virt_to_phys(&__bss_stop)-1; | ||
| 279 | 288 | ||
| 280 | early_identify_cpu(&boot_cpu_data); | 289 | early_identify_cpu(&boot_cpu_data); |
| 281 | 290 | ||
diff --git a/arch/x86/mm/pageattr_64.c b/arch/x86/mm/pageattr_64.c index c7b7dfe1d405..c40afbaaf93d 100644 --- a/arch/x86/mm/pageattr_64.c +++ b/arch/x86/mm/pageattr_64.c | |||
| @@ -61,10 +61,10 @@ static struct page *split_large_page(unsigned long address, pgprot_t prot, | |||
| 61 | return base; | 61 | return base; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static void cache_flush_page(void *adr) | 64 | void clflush_cache_range(void *adr, int size) |
| 65 | { | 65 | { |
| 66 | int i; | 66 | int i; |
| 67 | for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size) | 67 | for (i = 0; i < size; i += boot_cpu_data.x86_clflush_size) |
| 68 | clflush(adr+i); | 68 | clflush(adr+i); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| @@ -80,7 +80,7 @@ static void flush_kernel_map(void *arg) | |||
| 80 | asm volatile("wbinvd" ::: "memory"); | 80 | asm volatile("wbinvd" ::: "memory"); |
| 81 | else list_for_each_entry(pg, l, lru) { | 81 | else list_for_each_entry(pg, l, lru) { |
| 82 | void *adr = page_address(pg); | 82 | void *adr = page_address(pg); |
| 83 | cache_flush_page(adr); | 83 | clflush_cache_range(adr, PAGE_SIZE); |
| 84 | } | 84 | } |
| 85 | __flush_tlb_all(); | 85 | __flush_tlb_all(); |
| 86 | } | 86 | } |
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig index aab25f3ba3ce..c2d24991bb2b 100644 --- a/arch/x86_64/Kconfig +++ b/arch/x86_64/Kconfig | |||
| @@ -750,6 +750,38 @@ config PCI_DOMAINS | |||
| 750 | depends on PCI | 750 | depends on PCI |
| 751 | default y | 751 | default y |
| 752 | 752 | ||
| 753 | config DMAR | ||
| 754 | bool "Support for DMA Remapping Devices (EXPERIMENTAL)" | ||
| 755 | depends on PCI_MSI && ACPI && EXPERIMENTAL | ||
| 756 | default y | ||
| 757 | help | ||
| 758 | DMA remapping (DMAR) devices support enables independent address | ||
| 759 | translations for Direct Memory Access (DMA) from devices. | ||
| 760 | These DMA remapping devices are reported via ACPI tables | ||
| 761 | and include PCI device scope covered by these DMA | ||
| 762 | remapping devices. | ||
| 763 | |||
| 764 | config DMAR_GFX_WA | ||
| 765 | bool "Support for Graphics workaround" | ||
| 766 | depends on DMAR | ||
| 767 | default y | ||
| 768 | help | ||
| 769 | Current Graphics drivers tend to use physical address | ||
| 770 | for DMA and avoid using DMA APIs. Setting this config | ||
| 771 | option permits the IOMMU driver to set a unity map for | ||
| 772 | all the OS-visible memory. Hence the driver can continue | ||
| 773 | to use physical addresses for DMA. | ||
| 774 | |||
| 775 | config DMAR_FLOPPY_WA | ||
| 776 | bool | ||
| 777 | depends on DMAR | ||
| 778 | default y | ||
| 779 | help | ||
| 780 | Floppy disk drivers are know to bypass DMA API calls | ||
| 781 | thereby failing to work when IOMMU is enabled. This | ||
| 782 | workaround will setup a 1:1 mapping for the first | ||
| 783 | 16M to make floppy (an ISA device) work. | ||
| 784 | |||
| 753 | source "drivers/pci/pcie/Kconfig" | 785 | source "drivers/pci/pcie/Kconfig" |
| 754 | 786 | ||
| 755 | source "drivers/pci/Kconfig" | 787 | source "drivers/pci/Kconfig" |
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 8025d646ab30..61c2e396f2fa 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c | |||
| @@ -1354,8 +1354,9 @@ new_segment: | |||
| 1354 | else | 1354 | else |
| 1355 | sg = sg_next(sg); | 1355 | sg = sg_next(sg); |
| 1356 | 1356 | ||
| 1357 | memset(sg, 0, sizeof(*sg)); | 1357 | sg_dma_len(sg) = 0; |
| 1358 | sg->page = bvec->bv_page; | 1358 | sg_dma_address(sg) = 0; |
| 1359 | sg_set_page(sg, bvec->bv_page); | ||
| 1359 | sg->length = nbytes; | 1360 | sg->length = nbytes; |
| 1360 | sg->offset = bvec->bv_offset; | 1361 | sg->offset = bvec->bv_offset; |
| 1361 | nsegs++; | 1362 | nsegs++; |
| @@ -1363,6 +1364,9 @@ new_segment: | |||
| 1363 | bvprv = bvec; | 1364 | bvprv = bvec; |
| 1364 | } /* segments in rq */ | 1365 | } /* segments in rq */ |
| 1365 | 1366 | ||
| 1367 | if (sg) | ||
| 1368 | __sg_mark_end(sg); | ||
| 1369 | |||
| 1366 | return nsegs; | 1370 | return nsegs; |
| 1367 | } | 1371 | } |
| 1368 | 1372 | ||
diff --git a/crypto/digest.c b/crypto/digest.c index e56de6748b15..8871dec8cae7 100644 --- a/crypto/digest.c +++ b/crypto/digest.c | |||
| @@ -41,7 +41,7 @@ static int update2(struct hash_desc *desc, | |||
| 41 | return 0; | 41 | return 0; |
| 42 | 42 | ||
| 43 | for (;;) { | 43 | for (;;) { |
| 44 | struct page *pg = sg->page; | 44 | struct page *pg = sg_page(sg); |
| 45 | unsigned int offset = sg->offset; | 45 | unsigned int offset = sg->offset; |
| 46 | unsigned int l = sg->length; | 46 | unsigned int l = sg->length; |
| 47 | 47 | ||
diff --git a/crypto/hmac.c b/crypto/hmac.c index 8802fb6dd5a6..e4eb6ac53b5c 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c | |||
| @@ -159,7 +159,8 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg, | |||
| 159 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; | 159 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; |
| 160 | 160 | ||
| 161 | sg_set_buf(sg1, ipad, bs); | 161 | sg_set_buf(sg1, ipad, bs); |
| 162 | sg1[1].page = (void *)sg; | 162 | |
| 163 | sg_set_page(&sg[1], (void *) sg); | ||
| 163 | sg1[1].length = 0; | 164 | sg1[1].length = 0; |
| 164 | sg_set_buf(sg2, opad, bs + ds); | 165 | sg_set_buf(sg2, opad, bs + ds); |
| 165 | 166 | ||
diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c index d6852c33cfb7..b9bbda0bb9f9 100644 --- a/crypto/scatterwalk.c +++ b/crypto/scatterwalk.c | |||
| @@ -54,7 +54,7 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out, | |||
| 54 | if (out) { | 54 | if (out) { |
| 55 | struct page *page; | 55 | struct page *page; |
| 56 | 56 | ||
| 57 | page = walk->sg->page + ((walk->offset - 1) >> PAGE_SHIFT); | 57 | page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); |
| 58 | flush_dcache_page(page); | 58 | flush_dcache_page(page); |
| 59 | } | 59 | } |
| 60 | 60 | ||
diff --git a/crypto/scatterwalk.h b/crypto/scatterwalk.h index 9c73e37a42ce..87ed681cceba 100644 --- a/crypto/scatterwalk.h +++ b/crypto/scatterwalk.h | |||
| @@ -22,13 +22,13 @@ | |||
| 22 | 22 | ||
| 23 | static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) | 23 | static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg) |
| 24 | { | 24 | { |
| 25 | return (++sg)->length ? sg : (void *)sg->page; | 25 | return (++sg)->length ? sg : (void *) sg_page(sg); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, | 28 | static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in, |
| 29 | struct scatter_walk *walk_out) | 29 | struct scatter_walk *walk_out) |
| 30 | { | 30 | { |
| 31 | return !(((walk_in->sg->page - walk_out->sg->page) << PAGE_SHIFT) + | 31 | return !(((sg_page(walk_in->sg) - sg_page(walk_out->sg)) << PAGE_SHIFT) + |
| 32 | (int)(walk_in->offset - walk_out->offset)); | 32 | (int)(walk_in->offset - walk_out->offset)); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| @@ -60,7 +60,7 @@ static inline unsigned int scatterwalk_aligned(struct scatter_walk *walk, | |||
| 60 | 60 | ||
| 61 | static inline struct page *scatterwalk_page(struct scatter_walk *walk) | 61 | static inline struct page *scatterwalk_page(struct scatter_walk *walk) |
| 62 | { | 62 | { |
| 63 | return walk->sg->page + (walk->offset >> PAGE_SHIFT); | 63 | return sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static inline void scatterwalk_unmap(void *vaddr, int out) | 66 | static inline void scatterwalk_unmap(void *vaddr, int out) |
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 18d489c8b935..d741c63af42c 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
| @@ -317,7 +317,7 @@ static void test_cipher(char *algo, int enc, | |||
| 317 | goto out; | 317 | goto out; |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | q = kmap(sg[0].page) + sg[0].offset; | 320 | q = kmap(sg_page(&sg[0])) + sg[0].offset; |
| 321 | hexdump(q, cipher_tv[i].rlen); | 321 | hexdump(q, cipher_tv[i].rlen); |
| 322 | 322 | ||
| 323 | printk("%s\n", | 323 | printk("%s\n", |
| @@ -390,7 +390,7 @@ static void test_cipher(char *algo, int enc, | |||
| 390 | temp = 0; | 390 | temp = 0; |
| 391 | for (k = 0; k < cipher_tv[i].np; k++) { | 391 | for (k = 0; k < cipher_tv[i].np; k++) { |
| 392 | printk("page %u\n", k); | 392 | printk("page %u\n", k); |
| 393 | q = kmap(sg[k].page) + sg[k].offset; | 393 | q = kmap(sg_page(&sg[k])) + sg[k].offset; |
| 394 | hexdump(q, cipher_tv[i].tap[k]); | 394 | hexdump(q, cipher_tv[i].tap[k]); |
| 395 | printk("%s\n", | 395 | printk("%s\n", |
| 396 | memcmp(q, cipher_tv[i].result + temp, | 396 | memcmp(q, cipher_tv[i].result + temp, |
diff --git a/crypto/xcbc.c b/crypto/xcbc.c index 9f502b86e0ea..ac68f3b62fde 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c | |||
| @@ -120,7 +120,7 @@ static int crypto_xcbc_digest_update2(struct hash_desc *pdesc, | |||
| 120 | 120 | ||
| 121 | do { | 121 | do { |
| 122 | 122 | ||
| 123 | struct page *pg = sg[i].page; | 123 | struct page *pg = sg_page(&sg[i]); |
| 124 | unsigned int offset = sg[i].offset; | 124 | unsigned int offset = sg[i].offset; |
| 125 | unsigned int slen = sg[i].length; | 125 | unsigned int slen = sg[i].length; |
| 126 | 126 | ||
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 629eadbd0ec0..69092bce1ada 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
| @@ -4296,7 +4296,7 @@ void ata_sg_clean(struct ata_queued_cmd *qc) | |||
| 4296 | sg_last(sg, qc->orig_n_elem)->length += qc->pad_len; | 4296 | sg_last(sg, qc->orig_n_elem)->length += qc->pad_len; |
| 4297 | if (pad_buf) { | 4297 | if (pad_buf) { |
| 4298 | struct scatterlist *psg = &qc->pad_sgent; | 4298 | struct scatterlist *psg = &qc->pad_sgent; |
| 4299 | void *addr = kmap_atomic(psg->page, KM_IRQ0); | 4299 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); |
| 4300 | memcpy(addr + psg->offset, pad_buf, qc->pad_len); | 4300 | memcpy(addr + psg->offset, pad_buf, qc->pad_len); |
| 4301 | kunmap_atomic(addr, KM_IRQ0); | 4301 | kunmap_atomic(addr, KM_IRQ0); |
| 4302 | } | 4302 | } |
| @@ -4686,11 +4686,11 @@ static int ata_sg_setup(struct ata_queued_cmd *qc) | |||
| 4686 | * data in this function or read data in ata_sg_clean. | 4686 | * data in this function or read data in ata_sg_clean. |
| 4687 | */ | 4687 | */ |
| 4688 | offset = lsg->offset + lsg->length - qc->pad_len; | 4688 | offset = lsg->offset + lsg->length - qc->pad_len; |
| 4689 | psg->page = nth_page(lsg->page, offset >> PAGE_SHIFT); | 4689 | sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT)); |
| 4690 | psg->offset = offset_in_page(offset); | 4690 | psg->offset = offset_in_page(offset); |
| 4691 | 4691 | ||
| 4692 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | 4692 | if (qc->tf.flags & ATA_TFLAG_WRITE) { |
| 4693 | void *addr = kmap_atomic(psg->page, KM_IRQ0); | 4693 | void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); |
| 4694 | memcpy(pad_buf, addr + psg->offset, qc->pad_len); | 4694 | memcpy(pad_buf, addr + psg->offset, qc->pad_len); |
| 4695 | kunmap_atomic(addr, KM_IRQ0); | 4695 | kunmap_atomic(addr, KM_IRQ0); |
| 4696 | } | 4696 | } |
| @@ -4836,7 +4836,7 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) | |||
| 4836 | if (qc->curbytes == qc->nbytes - qc->sect_size) | 4836 | if (qc->curbytes == qc->nbytes - qc->sect_size) |
| 4837 | ap->hsm_task_state = HSM_ST_LAST; | 4837 | ap->hsm_task_state = HSM_ST_LAST; |
| 4838 | 4838 | ||
| 4839 | page = qc->cursg->page; | 4839 | page = sg_page(qc->cursg); |
| 4840 | offset = qc->cursg->offset + qc->cursg_ofs; | 4840 | offset = qc->cursg->offset + qc->cursg_ofs; |
| 4841 | 4841 | ||
| 4842 | /* get the current page and offset */ | 4842 | /* get the current page and offset */ |
| @@ -4988,7 +4988,7 @@ next_sg: | |||
| 4988 | 4988 | ||
| 4989 | sg = qc->cursg; | 4989 | sg = qc->cursg; |
| 4990 | 4990 | ||
| 4991 | page = sg->page; | 4991 | page = sg_page(sg); |
| 4992 | offset = sg->offset + qc->cursg_ofs; | 4992 | offset = sg->offset + qc->cursg_ofs; |
| 4993 | 4993 | ||
| 4994 | /* get the current page and offset */ | 4994 | /* get the current page and offset */ |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 9fbb39cd0f58..5b758b9ad0b8 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
| @@ -1544,7 +1544,7 @@ static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd *cmd, u8 **buf_out) | |||
| 1544 | struct scatterlist *sg = scsi_sglist(cmd); | 1544 | struct scatterlist *sg = scsi_sglist(cmd); |
| 1545 | 1545 | ||
| 1546 | if (sg) { | 1546 | if (sg) { |
| 1547 | buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 1547 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; |
| 1548 | buflen = sg->length; | 1548 | buflen = sg->length; |
| 1549 | } else { | 1549 | } else { |
| 1550 | buf = NULL; | 1550 | buf = NULL; |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index c41d0728efe2..7868707c7eda 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
| @@ -137,7 +137,7 @@ static ssize_t show_mem_state(struct sys_device *dev, char *buf) | |||
| 137 | return len; | 137 | return len; |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | static inline int memory_notify(unsigned long val, void *v) | 140 | int memory_notify(unsigned long val, void *v) |
| 141 | { | 141 | { |
| 142 | return blocking_notifier_call_chain(&memory_chain, val, v); | 142 | return blocking_notifier_call_chain(&memory_chain, val, v); |
| 143 | } | 143 | } |
| @@ -183,7 +183,6 @@ memory_block_action(struct memory_block *mem, unsigned long action) | |||
| 183 | break; | 183 | break; |
| 184 | case MEM_OFFLINE: | 184 | case MEM_OFFLINE: |
| 185 | mem->state = MEM_GOING_OFFLINE; | 185 | mem->state = MEM_GOING_OFFLINE; |
| 186 | memory_notify(MEM_GOING_OFFLINE, NULL); | ||
| 187 | start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; | 186 | start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; |
| 188 | ret = remove_memory(start_paddr, | 187 | ret = remove_memory(start_paddr, |
| 189 | PAGES_PER_SECTION << PAGE_SHIFT); | 188 | PAGES_PER_SECTION << PAGE_SHIFT); |
| @@ -191,7 +190,6 @@ memory_block_action(struct memory_block *mem, unsigned long action) | |||
| 191 | mem->state = old_state; | 190 | mem->state = old_state; |
| 192 | break; | 191 | break; |
| 193 | } | 192 | } |
| 194 | memory_notify(MEM_MAPPING_INVALID, NULL); | ||
| 195 | break; | 193 | break; |
| 196 | default: | 194 | default: |
| 197 | printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n", | 195 | printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n", |
| @@ -199,11 +197,6 @@ memory_block_action(struct memory_block *mem, unsigned long action) | |||
| 199 | WARN_ON(1); | 197 | WARN_ON(1); |
| 200 | ret = -EINVAL; | 198 | ret = -EINVAL; |
| 201 | } | 199 | } |
| 202 | /* | ||
| 203 | * For now, only notify on successful memory operations | ||
| 204 | */ | ||
| 205 | if (!ret) | ||
| 206 | memory_notify(action, NULL); | ||
| 207 | 200 | ||
| 208 | return ret; | 201 | return ret; |
| 209 | } | 202 | } |
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 84d6aa500e26..53505422867c 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c | |||
| @@ -345,6 +345,7 @@ static bool DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller) | |||
| 345 | Command->V1.ScatterGatherList = | 345 | Command->V1.ScatterGatherList = |
| 346 | (DAC960_V1_ScatterGatherSegment_T *)ScatterGatherCPU; | 346 | (DAC960_V1_ScatterGatherSegment_T *)ScatterGatherCPU; |
| 347 | Command->V1.ScatterGatherListDMA = ScatterGatherDMA; | 347 | Command->V1.ScatterGatherListDMA = ScatterGatherDMA; |
| 348 | sg_init_table(Command->cmd_sglist, DAC960_V1_ScatterGatherLimit); | ||
| 348 | } else { | 349 | } else { |
| 349 | Command->cmd_sglist = Command->V2.ScatterList; | 350 | Command->cmd_sglist = Command->V2.ScatterList; |
| 350 | Command->V2.ScatterGatherList = | 351 | Command->V2.ScatterGatherList = |
| @@ -353,6 +354,7 @@ static bool DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller) | |||
| 353 | Command->V2.RequestSense = | 354 | Command->V2.RequestSense = |
| 354 | (DAC960_SCSI_RequestSense_T *)RequestSenseCPU; | 355 | (DAC960_SCSI_RequestSense_T *)RequestSenseCPU; |
| 355 | Command->V2.RequestSenseDMA = RequestSenseDMA; | 356 | Command->V2.RequestSenseDMA = RequestSenseDMA; |
| 357 | sg_init_table(Command->cmd_sglist, DAC960_V2_ScatterGatherLimit); | ||
| 356 | } | 358 | } |
| 357 | } | 359 | } |
| 358 | return true; | 360 | return true; |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 7c2cfde08f18..5a6fe17fc638 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
| @@ -2610,7 +2610,7 @@ static void do_cciss_request(struct request_queue *q) | |||
| 2610 | (int)creq->nr_sectors); | 2610 | (int)creq->nr_sectors); |
| 2611 | #endif /* CCISS_DEBUG */ | 2611 | #endif /* CCISS_DEBUG */ |
| 2612 | 2612 | ||
| 2613 | memset(tmp_sg, 0, sizeof(tmp_sg)); | 2613 | sg_init_table(tmp_sg, MAXSGENTRIES); |
| 2614 | seg = blk_rq_map_sg(q, creq, tmp_sg); | 2614 | seg = blk_rq_map_sg(q, creq, tmp_sg); |
| 2615 | 2615 | ||
| 2616 | /* get the DMA records for the setup */ | 2616 | /* get the DMA records for the setup */ |
| @@ -2621,7 +2621,7 @@ static void do_cciss_request(struct request_queue *q) | |||
| 2621 | 2621 | ||
| 2622 | for (i = 0; i < seg; i++) { | 2622 | for (i = 0; i < seg; i++) { |
| 2623 | c->SG[i].Len = tmp_sg[i].length; | 2623 | c->SG[i].Len = tmp_sg[i].length; |
| 2624 | temp64.val = (__u64) pci_map_page(h->pdev, tmp_sg[i].page, | 2624 | temp64.val = (__u64) pci_map_page(h->pdev, sg_page(&tmp_sg[i]), |
| 2625 | tmp_sg[i].offset, | 2625 | tmp_sg[i].offset, |
| 2626 | tmp_sg[i].length, dir); | 2626 | tmp_sg[i].length, dir); |
| 2627 | c->SG[i].Addr.lower = temp64.val32.lower; | 2627 | c->SG[i].Addr.lower = temp64.val32.lower; |
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index 568603d3043e..efab27fa1083 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
| @@ -918,6 +918,7 @@ queue_next: | |||
| 918 | DBGPX( | 918 | DBGPX( |
| 919 | printk("sector=%d, nr_sectors=%d\n", creq->sector, creq->nr_sectors); | 919 | printk("sector=%d, nr_sectors=%d\n", creq->sector, creq->nr_sectors); |
| 920 | ); | 920 | ); |
| 921 | sg_init_table(tmp_sg, SG_MAX); | ||
| 921 | seg = blk_rq_map_sg(q, creq, tmp_sg); | 922 | seg = blk_rq_map_sg(q, creq, tmp_sg); |
| 922 | 923 | ||
| 923 | /* Now do all the DMA Mappings */ | 924 | /* Now do all the DMA Mappings */ |
| @@ -929,7 +930,7 @@ DBGPX( | |||
| 929 | { | 930 | { |
| 930 | c->req.sg[i].size = tmp_sg[i].length; | 931 | c->req.sg[i].size = tmp_sg[i].length; |
| 931 | c->req.sg[i].addr = (__u32) pci_map_page(h->pci_dev, | 932 | c->req.sg[i].addr = (__u32) pci_map_page(h->pci_dev, |
| 932 | tmp_sg[i].page, | 933 | sg_page(&tmp_sg[i]), |
| 933 | tmp_sg[i].offset, | 934 | tmp_sg[i].offset, |
| 934 | tmp_sg[i].length, dir); | 935 | tmp_sg[i].length, dir); |
| 935 | } | 936 | } |
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c index 40535036e893..1b58b010797f 100644 --- a/drivers/block/cryptoloop.c +++ b/drivers/block/cryptoloop.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/crypto.h> | 26 | #include <linux/crypto.h> |
| 27 | #include <linux/blkdev.h> | 27 | #include <linux/blkdev.h> |
| 28 | #include <linux/loop.h> | 28 | #include <linux/loop.h> |
| 29 | #include <linux/scatterlist.h> | ||
| 29 | #include <asm/semaphore.h> | 30 | #include <asm/semaphore.h> |
| 30 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
| 31 | 32 | ||
| @@ -119,14 +120,17 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
| 119 | .tfm = tfm, | 120 | .tfm = tfm, |
| 120 | .flags = CRYPTO_TFM_REQ_MAY_SLEEP, | 121 | .flags = CRYPTO_TFM_REQ_MAY_SLEEP, |
| 121 | }; | 122 | }; |
| 122 | struct scatterlist sg_out = { NULL, }; | 123 | struct scatterlist sg_out; |
| 123 | struct scatterlist sg_in = { NULL, }; | 124 | struct scatterlist sg_in; |
| 124 | 125 | ||
| 125 | encdec_cbc_t encdecfunc; | 126 | encdec_cbc_t encdecfunc; |
| 126 | struct page *in_page, *out_page; | 127 | struct page *in_page, *out_page; |
| 127 | unsigned in_offs, out_offs; | 128 | unsigned in_offs, out_offs; |
| 128 | int err; | 129 | int err; |
| 129 | 130 | ||
| 131 | sg_init_table(&sg_out, 1); | ||
| 132 | sg_init_table(&sg_in, 1); | ||
| 133 | |||
| 130 | if (cmd == READ) { | 134 | if (cmd == READ) { |
| 131 | in_page = raw_page; | 135 | in_page = raw_page; |
| 132 | in_offs = raw_off; | 136 | in_offs = raw_off; |
| @@ -146,11 +150,11 @@ cryptoloop_transfer(struct loop_device *lo, int cmd, | |||
| 146 | u32 iv[4] = { 0, }; | 150 | u32 iv[4] = { 0, }; |
| 147 | iv[0] = cpu_to_le32(IV & 0xffffffff); | 151 | iv[0] = cpu_to_le32(IV & 0xffffffff); |
| 148 | 152 | ||
| 149 | sg_in.page = in_page; | 153 | sg_set_page(&sg_in, in_page); |
| 150 | sg_in.offset = in_offs; | 154 | sg_in.offset = in_offs; |
| 151 | sg_in.length = sz; | 155 | sg_in.length = sz; |
| 152 | 156 | ||
| 153 | sg_out.page = out_page; | 157 | sg_set_page(&sg_out, out_page); |
| 154 | sg_out.offset = out_offs; | 158 | sg_out.offset = out_offs; |
| 155 | sg_out.length = sz; | 159 | sg_out.length = sz; |
| 156 | 160 | ||
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 317a790c153b..7276f7d207c2 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c | |||
| @@ -388,6 +388,7 @@ static int __send_request(struct request *req) | |||
| 388 | op = VD_OP_BWRITE; | 388 | op = VD_OP_BWRITE; |
| 389 | } | 389 | } |
| 390 | 390 | ||
| 391 | sg_init_table(sg, port->ring_cookies); | ||
| 391 | nsg = blk_rq_map_sg(req->q, req, sg); | 392 | nsg = blk_rq_map_sg(req->q, req, sg); |
| 392 | 393 | ||
| 393 | len = 0; | 394 | len = 0; |
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index 402209fec59a..282a69558e8a 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c | |||
| @@ -522,6 +522,7 @@ static struct carm_request *carm_get_request(struct carm_host *host) | |||
| 522 | host->n_msgs++; | 522 | host->n_msgs++; |
| 523 | 523 | ||
| 524 | assert(host->n_msgs <= CARM_MAX_REQ); | 524 | assert(host->n_msgs <= CARM_MAX_REQ); |
| 525 | sg_init_table(crq->sg, CARM_MAX_REQ_SG); | ||
| 525 | return crq; | 526 | return crq; |
| 526 | } | 527 | } |
| 527 | 528 | ||
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index c57dd2b3a0c8..14143f2c484d 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/usb_usual.h> | 25 | #include <linux/usb_usual.h> |
| 26 | #include <linux/blkdev.h> | 26 | #include <linux/blkdev.h> |
| 27 | #include <linux/timer.h> | 27 | #include <linux/timer.h> |
| 28 | #include <linux/scatterlist.h> | ||
| 28 | #include <scsi/scsi.h> | 29 | #include <scsi/scsi.h> |
| 29 | 30 | ||
| 30 | #define DRV_NAME "ub" | 31 | #define DRV_NAME "ub" |
| @@ -656,6 +657,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) | |||
| 656 | if ((cmd = ub_get_cmd(lun)) == NULL) | 657 | if ((cmd = ub_get_cmd(lun)) == NULL) |
| 657 | return -1; | 658 | return -1; |
| 658 | memset(cmd, 0, sizeof(struct ub_scsi_cmd)); | 659 | memset(cmd, 0, sizeof(struct ub_scsi_cmd)); |
| 660 | sg_init_table(cmd->sgv, UB_MAX_REQ_SG); | ||
| 659 | 661 | ||
| 660 | blkdev_dequeue_request(rq); | 662 | blkdev_dequeue_request(rq); |
| 661 | 663 | ||
| @@ -1309,9 +1311,8 @@ static void ub_data_start(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1309 | else | 1311 | else |
| 1310 | pipe = sc->send_bulk_pipe; | 1312 | pipe = sc->send_bulk_pipe; |
| 1311 | sc->last_pipe = pipe; | 1313 | sc->last_pipe = pipe; |
| 1312 | usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, | 1314 | usb_fill_bulk_urb(&sc->work_urb, sc->dev, pipe, sg_virt(sg), |
| 1313 | page_address(sg->page) + sg->offset, sg->length, | 1315 | sg->length, ub_urb_complete, sc); |
| 1314 | ub_urb_complete, sc); | ||
| 1315 | sc->work_urb.actual_length = 0; | 1316 | sc->work_urb.actual_length = 0; |
| 1316 | sc->work_urb.error_count = 0; | 1317 | sc->work_urb.error_count = 0; |
| 1317 | sc->work_urb.status = 0; | 1318 | sc->work_urb.status = 0; |
| @@ -1427,7 +1428,7 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
| 1427 | scmd->state = UB_CMDST_INIT; | 1428 | scmd->state = UB_CMDST_INIT; |
| 1428 | scmd->nsg = 1; | 1429 | scmd->nsg = 1; |
| 1429 | sg = &scmd->sgv[0]; | 1430 | sg = &scmd->sgv[0]; |
| 1430 | sg->page = virt_to_page(sc->top_sense); | 1431 | sg_set_page(sg, virt_to_page(sc->top_sense)); |
| 1431 | sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1); | 1432 | sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1); |
| 1432 | sg->length = UB_SENSE_SIZE; | 1433 | sg->length = UB_SENSE_SIZE; |
| 1433 | scmd->len = UB_SENSE_SIZE; | 1434 | scmd->len = UB_SENSE_SIZE; |
| @@ -1863,7 +1864,7 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, | |||
| 1863 | cmd->state = UB_CMDST_INIT; | 1864 | cmd->state = UB_CMDST_INIT; |
| 1864 | cmd->nsg = 1; | 1865 | cmd->nsg = 1; |
| 1865 | sg = &cmd->sgv[0]; | 1866 | sg = &cmd->sgv[0]; |
| 1866 | sg->page = virt_to_page(p); | 1867 | sg_set_page(sg, virt_to_page(p)); |
| 1867 | sg->offset = (unsigned long)p & (PAGE_SIZE-1); | 1868 | sg->offset = (unsigned long)p & (PAGE_SIZE-1); |
| 1868 | sg->length = 8; | 1869 | sg->length = 8; |
| 1869 | cmd->len = 8; | 1870 | cmd->len = 8; |
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c index e824b672e05a..ab5d404faa11 100644 --- a/drivers/block/viodasd.c +++ b/drivers/block/viodasd.c | |||
| @@ -41,6 +41,7 @@ | |||
| 41 | #include <linux/dma-mapping.h> | 41 | #include <linux/dma-mapping.h> |
| 42 | #include <linux/completion.h> | 42 | #include <linux/completion.h> |
| 43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
| 44 | #include <linux/scatterlist.h> | ||
| 44 | 45 | ||
| 45 | #include <asm/uaccess.h> | 46 | #include <asm/uaccess.h> |
| 46 | #include <asm/vio.h> | 47 | #include <asm/vio.h> |
| @@ -270,6 +271,7 @@ static int send_request(struct request *req) | |||
| 270 | d = req->rq_disk->private_data; | 271 | d = req->rq_disk->private_data; |
| 271 | 272 | ||
| 272 | /* Now build the scatter-gather list */ | 273 | /* Now build the scatter-gather list */ |
| 274 | sg_init_table(sg, VIOMAXBLOCKDMA); | ||
| 273 | nsg = blk_rq_map_sg(req->q, req, sg); | 275 | nsg = blk_rq_map_sg(req->q, req, sg); |
| 274 | nsg = dma_map_sg(d->dev, sg, nsg, direction); | 276 | nsg = dma_map_sg(d->dev, sg, nsg, direction); |
| 275 | 277 | ||
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c index 2f307c4df335..67588326ae56 100644 --- a/drivers/firewire/fw-ohci.c +++ b/drivers/firewire/fw-ohci.c | |||
| @@ -606,7 +606,7 @@ static int | |||
| 606 | at_context_queue_packet(struct context *ctx, struct fw_packet *packet) | 606 | at_context_queue_packet(struct context *ctx, struct fw_packet *packet) |
| 607 | { | 607 | { |
| 608 | struct fw_ohci *ohci = ctx->ohci; | 608 | struct fw_ohci *ohci = ctx->ohci; |
| 609 | dma_addr_t d_bus, payload_bus; | 609 | dma_addr_t d_bus, uninitialized_var(payload_bus); |
| 610 | struct driver_data *driver_data; | 610 | struct driver_data *driver_data; |
| 611 | struct descriptor *d, *last; | 611 | struct descriptor *d, *last; |
| 612 | __le32 *header; | 612 | __le32 *header; |
| @@ -1459,7 +1459,7 @@ ohci_allocate_iso_context(struct fw_card *card, int type, size_t header_size) | |||
| 1459 | /* FIXME: We need a fallback for pre 1.1 OHCI. */ | 1459 | /* FIXME: We need a fallback for pre 1.1 OHCI. */ |
| 1460 | if (callback == handle_ir_dualbuffer_packet && | 1460 | if (callback == handle_ir_dualbuffer_packet && |
| 1461 | ohci->version < OHCI_VERSION_1_1) | 1461 | ohci->version < OHCI_VERSION_1_1) |
| 1462 | return ERR_PTR(-EINVAL); | 1462 | return ERR_PTR(-ENOSYS); |
| 1463 | 1463 | ||
| 1464 | spin_lock_irqsave(&ohci->lock, flags); | 1464 | spin_lock_irqsave(&ohci->lock, flags); |
| 1465 | index = ffs(*mask) - 1; | 1465 | index = ffs(*mask) - 1; |
| @@ -1778,7 +1778,7 @@ ohci_queue_iso(struct fw_iso_context *base, | |||
| 1778 | buffer, payload); | 1778 | buffer, payload); |
| 1779 | else | 1779 | else |
| 1780 | /* FIXME: Implement fallback for OHCI 1.0 controllers. */ | 1780 | /* FIXME: Implement fallback for OHCI 1.0 controllers. */ |
| 1781 | return -EINVAL; | 1781 | return -ENOSYS; |
| 1782 | } | 1782 | } |
| 1783 | 1783 | ||
| 1784 | static const struct fw_card_driver ohci_driver = { | 1784 | static const struct fw_card_driver ohci_driver = { |
| @@ -1898,7 +1898,12 @@ pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) | |||
| 1898 | ohci->version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff; | 1898 | ohci->version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff; |
| 1899 | fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n", | 1899 | fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n", |
| 1900 | dev->dev.bus_id, ohci->version >> 16, ohci->version & 0xff); | 1900 | dev->dev.bus_id, ohci->version >> 16, ohci->version & 0xff); |
| 1901 | 1901 | if (ohci->version < OHCI_VERSION_1_1) { | |
| 1902 | fw_notify(" Isochronous I/O is not yet implemented for " | ||
| 1903 | "OHCI 1.0 chips.\n"); | ||
| 1904 | fw_notify(" Cameras, audio devices etc. won't work on " | ||
| 1905 | "this controller with this driver version.\n"); | ||
| 1906 | } | ||
| 1902 | return 0; | 1907 | return 0; |
| 1903 | 1908 | ||
| 1904 | fail_self_id: | 1909 | fail_self_id: |
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c index ff20377b4c82..e196aefa2070 100644 --- a/drivers/ide/cris/ide-cris.c +++ b/drivers/ide/cris/ide-cris.c | |||
| @@ -935,11 +935,11 @@ static int cris_ide_build_dmatable (ide_drive_t *drive) | |||
| 935 | * than two possibly non-adjacent physical 4kB pages. | 935 | * than two possibly non-adjacent physical 4kB pages. |
| 936 | */ | 936 | */ |
| 937 | /* group sequential buffers into one large buffer */ | 937 | /* group sequential buffers into one large buffer */ |
| 938 | addr = page_to_phys(sg->page) + sg->offset; | 938 | addr = sg_phys(sg); |
| 939 | size = sg_dma_len(sg); | 939 | size = sg_dma_len(sg); |
| 940 | while (--i) { | 940 | while (--i) { |
| 941 | sg = sg_next(sg); | 941 | sg = sg_next(sg); |
| 942 | if ((addr + size) != page_to_phys(sg->page) + sg->offset) | 942 | if ((addr + size) != sg_phys(sg)) |
| 943 | break; | 943 | break; |
| 944 | size += sg_dma_len(sg); | 944 | size += sg_dma_len(sg); |
| 945 | } | 945 | } |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index d5146c57e5b3..ec55a173c08a 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
| @@ -1317,12 +1317,14 @@ static int hwif_init(ide_hwif_t *hwif) | |||
| 1317 | if (!hwif->sg_max_nents) | 1317 | if (!hwif->sg_max_nents) |
| 1318 | hwif->sg_max_nents = PRD_ENTRIES; | 1318 | hwif->sg_max_nents = PRD_ENTRIES; |
| 1319 | 1319 | ||
| 1320 | hwif->sg_table = kzalloc(sizeof(struct scatterlist)*hwif->sg_max_nents, | 1320 | hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents, |
| 1321 | GFP_KERNEL); | 1321 | GFP_KERNEL); |
| 1322 | if (!hwif->sg_table) { | 1322 | if (!hwif->sg_table) { |
| 1323 | printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); | 1323 | printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); |
| 1324 | goto out; | 1324 | goto out; |
| 1325 | } | 1325 | } |
| 1326 | |||
| 1327 | sg_init_table(hwif->sg_table, hwif->sg_max_nents); | ||
| 1326 | 1328 | ||
| 1327 | if (init_irq(hwif) == 0) | 1329 | if (init_irq(hwif) == 0) |
| 1328 | goto done; | 1330 | goto done; |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 73ef6bf5fbcc..d066546f2831 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
| @@ -261,7 +261,7 @@ static void ide_pio_sector(ide_drive_t *drive, unsigned int write) | |||
| 261 | hwif->cursg = sg; | 261 | hwif->cursg = sg; |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | page = cursg->page; | 264 | page = sg_page(cursg); |
| 265 | offset = cursg->offset + hwif->cursg_ofs * SECTOR_SIZE; | 265 | offset = cursg->offset + hwif->cursg_ofs * SECTOR_SIZE; |
| 266 | 266 | ||
| 267 | /* get the current page and offset */ | 267 | /* get the current page and offset */ |
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c index 1de58566e5b6..a4ce3ba15d61 100644 --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c | |||
| @@ -276,8 +276,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
| 276 | 276 | ||
| 277 | if (iswrite) { | 277 | if (iswrite) { |
| 278 | if(!put_source_flags(ahwif->tx_chan, | 278 | if(!put_source_flags(ahwif->tx_chan, |
| 279 | (void*)(page_address(sg->page) | 279 | (void*) sg_virt(sg), |
| 280 | + sg->offset), | ||
| 281 | tc, flags)) { | 280 | tc, flags)) { |
| 282 | printk(KERN_ERR "%s failed %d\n", | 281 | printk(KERN_ERR "%s failed %d\n", |
| 283 | __FUNCTION__, __LINE__); | 282 | __FUNCTION__, __LINE__); |
| @@ -285,8 +284,7 @@ static int auide_build_dmatable(ide_drive_t *drive) | |||
| 285 | } else | 284 | } else |
| 286 | { | 285 | { |
| 287 | if(!put_dest_flags(ahwif->rx_chan, | 286 | if(!put_dest_flags(ahwif->rx_chan, |
| 288 | (void*)(page_address(sg->page) | 287 | (void*) sg_virt(sg), |
| 289 | + sg->offset), | ||
| 290 | tc, flags)) { | 288 | tc, flags)) { |
| 291 | printk(KERN_ERR "%s failed %d\n", | 289 | printk(KERN_ERR "%s failed %d\n", |
| 292 | __FUNCTION__, __LINE__); | 290 | __FUNCTION__, __LINE__); |
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c index 45d605581922..25e113b50d86 100644 --- a/drivers/ieee1394/dma.c +++ b/drivers/ieee1394/dma.c | |||
| @@ -111,7 +111,7 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, | |||
| 111 | unsigned long va = | 111 | unsigned long va = |
| 112 | (unsigned long)dma->kvirt + (i << PAGE_SHIFT); | 112 | (unsigned long)dma->kvirt + (i << PAGE_SHIFT); |
| 113 | 113 | ||
| 114 | dma->sglist[i].page = vmalloc_to_page((void *)va); | 114 | sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va)); |
| 115 | dma->sglist[i].length = PAGE_SIZE; | 115 | dma->sglist[i].length = PAGE_SIZE; |
| 116 | } | 116 | } |
| 117 | 117 | ||
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 1b353b964b33..d5dfe11aa5c6 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c | |||
| @@ -1466,7 +1466,7 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, | |||
| 1466 | cmd->dma_size = sgpnt[0].length; | 1466 | cmd->dma_size = sgpnt[0].length; |
| 1467 | cmd->dma_type = CMD_DMA_PAGE; | 1467 | cmd->dma_type = CMD_DMA_PAGE; |
| 1468 | cmd->cmd_dma = dma_map_page(hi->host->device.parent, | 1468 | cmd->cmd_dma = dma_map_page(hi->host->device.parent, |
| 1469 | sgpnt[0].page, sgpnt[0].offset, | 1469 | sg_page(&sgpnt[0]), sgpnt[0].offset, |
| 1470 | cmd->dma_size, cmd->dma_dir); | 1470 | cmd->dma_size, cmd->dma_dir); |
| 1471 | 1471 | ||
| 1472 | orb->data_descriptor_lo = cmd->cmd_dma; | 1472 | orb->data_descriptor_lo = cmd->cmd_dma; |
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 2f54e29dc7a6..14159ff29408 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c | |||
| @@ -55,9 +55,11 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d | |||
| 55 | ib_dma_unmap_sg(dev, chunk->page_list, | 55 | ib_dma_unmap_sg(dev, chunk->page_list, |
| 56 | chunk->nents, DMA_BIDIRECTIONAL); | 56 | chunk->nents, DMA_BIDIRECTIONAL); |
| 57 | for (i = 0; i < chunk->nents; ++i) { | 57 | for (i = 0; i < chunk->nents; ++i) { |
| 58 | struct page *page = sg_page(&chunk->page_list[i]); | ||
| 59 | |||
| 58 | if (umem->writable && dirty) | 60 | if (umem->writable && dirty) |
| 59 | set_page_dirty_lock(chunk->page_list[i].page); | 61 | set_page_dirty_lock(page); |
| 60 | put_page(chunk->page_list[i].page); | 62 | put_page(page); |
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | kfree(chunk); | 65 | kfree(chunk); |
| @@ -164,11 +166,12 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, | |||
| 164 | } | 166 | } |
| 165 | 167 | ||
| 166 | chunk->nents = min_t(int, ret, IB_UMEM_MAX_PAGE_CHUNK); | 168 | chunk->nents = min_t(int, ret, IB_UMEM_MAX_PAGE_CHUNK); |
| 169 | sg_init_table(chunk->page_list, chunk->nents); | ||
| 167 | for (i = 0; i < chunk->nents; ++i) { | 170 | for (i = 0; i < chunk->nents; ++i) { |
| 168 | if (vma_list && | 171 | if (vma_list && |
| 169 | !is_vm_hugetlb_page(vma_list[i + off])) | 172 | !is_vm_hugetlb_page(vma_list[i + off])) |
| 170 | umem->hugetlb = 0; | 173 | umem->hugetlb = 0; |
| 171 | chunk->page_list[i].page = page_list[i + off]; | 174 | sg_set_page(&chunk->page_list[i], page_list[i + off]); |
| 172 | chunk->page_list[i].offset = 0; | 175 | chunk->page_list[i].offset = 0; |
| 173 | chunk->page_list[i].length = PAGE_SIZE; | 176 | chunk->page_list[i].length = PAGE_SIZE; |
| 174 | } | 177 | } |
| @@ -179,7 +182,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, | |||
| 179 | DMA_BIDIRECTIONAL); | 182 | DMA_BIDIRECTIONAL); |
| 180 | if (chunk->nmap <= 0) { | 183 | if (chunk->nmap <= 0) { |
| 181 | for (i = 0; i < chunk->nents; ++i) | 184 | for (i = 0; i < chunk->nents; ++i) |
| 182 | put_page(chunk->page_list[i].page); | 185 | put_page(sg_page(&chunk->page_list[i])); |
| 183 | kfree(chunk); | 186 | kfree(chunk); |
| 184 | 187 | ||
| 185 | ret = -ENOMEM; | 188 | ret = -ENOMEM; |
diff --git a/drivers/infiniband/hw/ipath/ipath_dma.c b/drivers/infiniband/hw/ipath/ipath_dma.c index 22709a4f8fc8..e90a0ea538a0 100644 --- a/drivers/infiniband/hw/ipath/ipath_dma.c +++ b/drivers/infiniband/hw/ipath/ipath_dma.c | |||
| @@ -108,7 +108,7 @@ static int ipath_map_sg(struct ib_device *dev, struct scatterlist *sgl, | |||
| 108 | BUG_ON(!valid_dma_direction(direction)); | 108 | BUG_ON(!valid_dma_direction(direction)); |
| 109 | 109 | ||
| 110 | for_each_sg(sgl, sg, nents, i) { | 110 | for_each_sg(sgl, sg, nents, i) { |
| 111 | addr = (u64) page_address(sg->page); | 111 | addr = (u64) page_address(sg_page(sg)); |
| 112 | /* TODO: handle highmem pages */ | 112 | /* TODO: handle highmem pages */ |
| 113 | if (!addr) { | 113 | if (!addr) { |
| 114 | ret = 0; | 114 | ret = 0; |
| @@ -127,7 +127,7 @@ static void ipath_unmap_sg(struct ib_device *dev, | |||
| 127 | 127 | ||
| 128 | static u64 ipath_sg_dma_address(struct ib_device *dev, struct scatterlist *sg) | 128 | static u64 ipath_sg_dma_address(struct ib_device *dev, struct scatterlist *sg) |
| 129 | { | 129 | { |
| 130 | u64 addr = (u64) page_address(sg->page); | 130 | u64 addr = (u64) page_address(sg_page(sg)); |
| 131 | 131 | ||
| 132 | if (addr) | 132 | if (addr) |
| 133 | addr += sg->offset; | 133 | addr += sg->offset; |
diff --git a/drivers/infiniband/hw/ipath/ipath_mr.c b/drivers/infiniband/hw/ipath/ipath_mr.c index e442470a2375..db4ba92f79fc 100644 --- a/drivers/infiniband/hw/ipath/ipath_mr.c +++ b/drivers/infiniband/hw/ipath/ipath_mr.c | |||
| @@ -225,7 +225,7 @@ struct ib_mr *ipath_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, | |||
| 225 | for (i = 0; i < chunk->nents; i++) { | 225 | for (i = 0; i < chunk->nents; i++) { |
| 226 | void *vaddr; | 226 | void *vaddr; |
| 227 | 227 | ||
| 228 | vaddr = page_address(chunk->page_list[i].page); | 228 | vaddr = page_address(sg_page(&chunk->page_list[i])); |
| 229 | if (!vaddr) { | 229 | if (!vaddr) { |
| 230 | ret = ERR_PTR(-EINVAL); | 230 | ret = ERR_PTR(-EINVAL); |
| 231 | goto bail; | 231 | goto bail; |
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index e61f3e626980..007b38157fc4 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
| @@ -71,7 +71,7 @@ static void mthca_free_icm_pages(struct mthca_dev *dev, struct mthca_icm_chunk * | |||
| 71 | PCI_DMA_BIDIRECTIONAL); | 71 | PCI_DMA_BIDIRECTIONAL); |
| 72 | 72 | ||
| 73 | for (i = 0; i < chunk->npages; ++i) | 73 | for (i = 0; i < chunk->npages; ++i) |
| 74 | __free_pages(chunk->mem[i].page, | 74 | __free_pages(sg_page(&chunk->mem[i]), |
| 75 | get_order(chunk->mem[i].length)); | 75 | get_order(chunk->mem[i].length)); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| @@ -81,7 +81,7 @@ static void mthca_free_icm_coherent(struct mthca_dev *dev, struct mthca_icm_chun | |||
| 81 | 81 | ||
| 82 | for (i = 0; i < chunk->npages; ++i) { | 82 | for (i = 0; i < chunk->npages; ++i) { |
| 83 | dma_free_coherent(&dev->pdev->dev, chunk->mem[i].length, | 83 | dma_free_coherent(&dev->pdev->dev, chunk->mem[i].length, |
| 84 | lowmem_page_address(chunk->mem[i].page), | 84 | lowmem_page_address(sg_page(&chunk->mem[i])), |
| 85 | sg_dma_address(&chunk->mem[i])); | 85 | sg_dma_address(&chunk->mem[i])); |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| @@ -107,10 +107,13 @@ void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm, int coherent) | |||
| 107 | 107 | ||
| 108 | static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_mask) | 108 | static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_mask) |
| 109 | { | 109 | { |
| 110 | mem->page = alloc_pages(gfp_mask, order); | 110 | struct page *page; |
| 111 | if (!mem->page) | 111 | |
| 112 | page = alloc_pages(gfp_mask, order); | ||
| 113 | if (!page) | ||
| 112 | return -ENOMEM; | 114 | return -ENOMEM; |
| 113 | 115 | ||
| 116 | sg_set_page(mem, page); | ||
| 114 | mem->length = PAGE_SIZE << order; | 117 | mem->length = PAGE_SIZE << order; |
| 115 | mem->offset = 0; | 118 | mem->offset = 0; |
| 116 | return 0; | 119 | return 0; |
| @@ -157,6 +160,7 @@ struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages, | |||
| 157 | if (!chunk) | 160 | if (!chunk) |
| 158 | goto fail; | 161 | goto fail; |
| 159 | 162 | ||
| 163 | sg_init_table(chunk->mem, MTHCA_ICM_CHUNK_LEN); | ||
| 160 | chunk->npages = 0; | 164 | chunk->npages = 0; |
| 161 | chunk->nsg = 0; | 165 | chunk->nsg = 0; |
| 162 | list_add_tail(&chunk->list, &icm->chunk_list); | 166 | list_add_tail(&chunk->list, &icm->chunk_list); |
| @@ -304,7 +308,7 @@ void *mthca_table_find(struct mthca_icm_table *table, int obj, dma_addr_t *dma_h | |||
| 304 | * so if we found the page, dma_handle has already | 308 | * so if we found the page, dma_handle has already |
| 305 | * been assigned to. */ | 309 | * been assigned to. */ |
| 306 | if (chunk->mem[i].length > offset) { | 310 | if (chunk->mem[i].length > offset) { |
| 307 | page = chunk->mem[i].page; | 311 | page = sg_page(&chunk->mem[i]); |
| 308 | goto out; | 312 | goto out; |
| 309 | } | 313 | } |
| 310 | offset -= chunk->mem[i].length; | 314 | offset -= chunk->mem[i].length; |
| @@ -445,6 +449,7 @@ static u64 mthca_uarc_virt(struct mthca_dev *dev, struct mthca_uar *uar, int pag | |||
| 445 | int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, | 449 | int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, |
| 446 | struct mthca_user_db_table *db_tab, int index, u64 uaddr) | 450 | struct mthca_user_db_table *db_tab, int index, u64 uaddr) |
| 447 | { | 451 | { |
| 452 | struct page *pages[1]; | ||
| 448 | int ret = 0; | 453 | int ret = 0; |
| 449 | u8 status; | 454 | u8 status; |
| 450 | int i; | 455 | int i; |
| @@ -472,16 +477,17 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, | |||
| 472 | } | 477 | } |
| 473 | 478 | ||
| 474 | ret = get_user_pages(current, current->mm, uaddr & PAGE_MASK, 1, 1, 0, | 479 | ret = get_user_pages(current, current->mm, uaddr & PAGE_MASK, 1, 1, 0, |
| 475 | &db_tab->page[i].mem.page, NULL); | 480 | pages, NULL); |
| 476 | if (ret < 0) | 481 | if (ret < 0) |
| 477 | goto out; | 482 | goto out; |
| 478 | 483 | ||
| 484 | sg_set_page(&db_tab->page[i].mem, pages[0]); | ||
| 479 | db_tab->page[i].mem.length = MTHCA_ICM_PAGE_SIZE; | 485 | db_tab->page[i].mem.length = MTHCA_ICM_PAGE_SIZE; |
| 480 | db_tab->page[i].mem.offset = uaddr & ~PAGE_MASK; | 486 | db_tab->page[i].mem.offset = uaddr & ~PAGE_MASK; |
| 481 | 487 | ||
| 482 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); | 488 | ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); |
| 483 | if (ret < 0) { | 489 | if (ret < 0) { |
| 484 | put_page(db_tab->page[i].mem.page); | 490 | put_page(pages[0]); |
| 485 | goto out; | 491 | goto out; |
| 486 | } | 492 | } |
| 487 | 493 | ||
| @@ -491,7 +497,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, | |||
| 491 | ret = -EINVAL; | 497 | ret = -EINVAL; |
| 492 | if (ret) { | 498 | if (ret) { |
| 493 | pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); | 499 | pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); |
| 494 | put_page(db_tab->page[i].mem.page); | 500 | put_page(sg_page(&db_tab->page[i].mem)); |
| 495 | goto out; | 501 | goto out; |
| 496 | } | 502 | } |
| 497 | 503 | ||
| @@ -557,7 +563,7 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar, | |||
| 557 | if (db_tab->page[i].uvirt) { | 563 | if (db_tab->page[i].uvirt) { |
| 558 | mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1, &status); | 564 | mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1, &status); |
| 559 | pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); | 565 | pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); |
| 560 | put_page(db_tab->page[i].mem.page); | 566 | put_page(sg_page(&db_tab->page[i].mem)); |
| 561 | } | 567 | } |
| 562 | } | 568 | } |
| 563 | 569 | ||
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index f3529b6f0a33..d68798061795 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c | |||
| @@ -131,7 +131,7 @@ static int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask, | |||
| 131 | 131 | ||
| 132 | p = mem; | 132 | p = mem; |
| 133 | for_each_sg(sgl, sg, data->size, i) { | 133 | for_each_sg(sgl, sg, data->size, i) { |
| 134 | from = kmap_atomic(sg->page, KM_USER0); | 134 | from = kmap_atomic(sg_page(sg), KM_USER0); |
| 135 | memcpy(p, | 135 | memcpy(p, |
| 136 | from + sg->offset, | 136 | from + sg->offset, |
| 137 | sg->length); | 137 | sg->length); |
| @@ -191,7 +191,7 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask, | |||
| 191 | 191 | ||
| 192 | p = mem; | 192 | p = mem; |
| 193 | for_each_sg(sgl, sg, sg_size, i) { | 193 | for_each_sg(sgl, sg, sg_size, i) { |
| 194 | to = kmap_atomic(sg->page, KM_SOFTIRQ0); | 194 | to = kmap_atomic(sg_page(sg), KM_SOFTIRQ0); |
| 195 | memcpy(to + sg->offset, | 195 | memcpy(to + sg->offset, |
| 196 | p, | 196 | p, |
| 197 | sg->length); | 197 | sg->length); |
| @@ -300,7 +300,7 @@ static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data, | |||
| 300 | for_each_sg(sgl, sg, data->dma_nents, i) { | 300 | for_each_sg(sgl, sg, data->dma_nents, i) { |
| 301 | /* iser_dbg("Checking sg iobuf [%d]: phys=0x%08lX " | 301 | /* iser_dbg("Checking sg iobuf [%d]: phys=0x%08lX " |
| 302 | "offset: %ld sz: %ld\n", i, | 302 | "offset: %ld sz: %ld\n", i, |
| 303 | (unsigned long)page_to_phys(sg->page), | 303 | (unsigned long)sg_phys(sg), |
| 304 | (unsigned long)sg->offset, | 304 | (unsigned long)sg->offset, |
| 305 | (unsigned long)sg->length); */ | 305 | (unsigned long)sg->length); */ |
| 306 | end_addr = ib_sg_dma_address(ibdev, sg) + | 306 | end_addr = ib_sg_dma_address(ibdev, sg) + |
| @@ -336,7 +336,7 @@ static void iser_data_buf_dump(struct iser_data_buf *data, | |||
| 336 | iser_err("sg[%d] dma_addr:0x%lX page:0x%p " | 336 | iser_err("sg[%d] dma_addr:0x%lX page:0x%p " |
| 337 | "off:0x%x sz:0x%x dma_len:0x%x\n", | 337 | "off:0x%x sz:0x%x dma_len:0x%x\n", |
| 338 | i, (unsigned long)ib_sg_dma_address(ibdev, sg), | 338 | i, (unsigned long)ib_sg_dma_address(ibdev, sg), |
| 339 | sg->page, sg->offset, | 339 | sg_page(sg), sg->offset, |
| 340 | sg->length, ib_sg_dma_len(ibdev, sg)); | 340 | sg->length, ib_sg_dma_len(ibdev, sg)); |
| 341 | } | 341 | } |
| 342 | 342 | ||
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 0eb5416798bd..ac54f697c508 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
| @@ -348,16 +348,17 @@ static int crypt_convert(struct crypt_config *cc, | |||
| 348 | ctx->idx_out < ctx->bio_out->bi_vcnt) { | 348 | ctx->idx_out < ctx->bio_out->bi_vcnt) { |
| 349 | struct bio_vec *bv_in = bio_iovec_idx(ctx->bio_in, ctx->idx_in); | 349 | struct bio_vec *bv_in = bio_iovec_idx(ctx->bio_in, ctx->idx_in); |
| 350 | struct bio_vec *bv_out = bio_iovec_idx(ctx->bio_out, ctx->idx_out); | 350 | struct bio_vec *bv_out = bio_iovec_idx(ctx->bio_out, ctx->idx_out); |
| 351 | struct scatterlist sg_in = { | 351 | struct scatterlist sg_in, sg_out; |
| 352 | .page = bv_in->bv_page, | 352 | |
| 353 | .offset = bv_in->bv_offset + ctx->offset_in, | 353 | sg_init_table(&sg_in, 1); |
| 354 | .length = 1 << SECTOR_SHIFT | 354 | sg_set_page(&sg_in, bv_in->bv_page); |
| 355 | }; | 355 | sg_in.offset = bv_in->bv_offset + ctx->offset_in; |
| 356 | struct scatterlist sg_out = { | 356 | sg_in.length = 1 << SECTOR_SHIFT; |
| 357 | .page = bv_out->bv_page, | 357 | |
| 358 | .offset = bv_out->bv_offset + ctx->offset_out, | 358 | sg_init_table(&sg_out, 1); |
| 359 | .length = 1 << SECTOR_SHIFT | 359 | sg_set_page(&sg_out, bv_out->bv_page); |
| 360 | }; | 360 | sg_out.offset = bv_out->bv_offset + ctx->offset_out; |
| 361 | sg_out.length = 1 << SECTOR_SHIFT; | ||
| 361 | 362 | ||
| 362 | ctx->offset_in += sg_in.length; | 363 | ctx->offset_in += sg_in.length; |
| 363 | if (ctx->offset_in >= bv_in->bv_len) { | 364 | if (ctx->offset_in >= bv_in->bv_len) { |
diff --git a/drivers/media/common/ir-keymaps.c b/drivers/media/common/ir-keymaps.c index aefcf28da1ca..185e8a860c1a 100644 --- a/drivers/media/common/ir-keymaps.c +++ b/drivers/media/common/ir-keymaps.c | |||
| @@ -1074,41 +1074,41 @@ EXPORT_SYMBOL_GPL(ir_codes_manli); | |||
| 1074 | /* Mike Baikov <mike@baikov.com> */ | 1074 | /* Mike Baikov <mike@baikov.com> */ |
| 1075 | IR_KEYTAB_TYPE ir_codes_gotview7135[IR_KEYTAB_SIZE] = { | 1075 | IR_KEYTAB_TYPE ir_codes_gotview7135[IR_KEYTAB_SIZE] = { |
| 1076 | 1076 | ||
| 1077 | [ 0x21 ] = KEY_POWER, | 1077 | [ 0x11 ] = KEY_POWER, |
| 1078 | [ 0x69 ] = KEY_TV, | 1078 | [ 0x35 ] = KEY_TV, |
| 1079 | [ 0x33 ] = KEY_0, | 1079 | [ 0x1b ] = KEY_0, |
| 1080 | [ 0x51 ] = KEY_1, | 1080 | [ 0x29 ] = KEY_1, |
| 1081 | [ 0x31 ] = KEY_2, | 1081 | [ 0x19 ] = KEY_2, |
| 1082 | [ 0x71 ] = KEY_3, | 1082 | [ 0x39 ] = KEY_3, |
| 1083 | [ 0x3b ] = KEY_4, | 1083 | [ 0x1f ] = KEY_4, |
| 1084 | [ 0x58 ] = KEY_5, | 1084 | [ 0x2c ] = KEY_5, |
| 1085 | [ 0x41 ] = KEY_6, | 1085 | [ 0x21 ] = KEY_6, |
| 1086 | [ 0x48 ] = KEY_7, | 1086 | [ 0x24 ] = KEY_7, |
| 1087 | [ 0x30 ] = KEY_8, | 1087 | [ 0x18 ] = KEY_8, |
| 1088 | [ 0x53 ] = KEY_9, | 1088 | [ 0x2b ] = KEY_9, |
| 1089 | [ 0x73 ] = KEY_AGAIN, /* LOOP */ | 1089 | [ 0x3b ] = KEY_AGAIN, /* LOOP */ |
| 1090 | [ 0x0a ] = KEY_AUDIO, | 1090 | [ 0x06 ] = KEY_AUDIO, |
| 1091 | [ 0x61 ] = KEY_PRINT, /* PREVIEW */ | 1091 | [ 0x31 ] = KEY_PRINT, /* PREVIEW */ |
| 1092 | [ 0x7a ] = KEY_VIDEO, | 1092 | [ 0x3e ] = KEY_VIDEO, |
| 1093 | [ 0x20 ] = KEY_CHANNELUP, | 1093 | [ 0x10 ] = KEY_CHANNELUP, |
| 1094 | [ 0x40 ] = KEY_CHANNELDOWN, | 1094 | [ 0x20 ] = KEY_CHANNELDOWN, |
| 1095 | [ 0x18 ] = KEY_VOLUMEDOWN, | 1095 | [ 0x0c ] = KEY_VOLUMEDOWN, |
| 1096 | [ 0x50 ] = KEY_VOLUMEUP, | 1096 | [ 0x28 ] = KEY_VOLUMEUP, |
| 1097 | [ 0x10 ] = KEY_MUTE, | 1097 | [ 0x08 ] = KEY_MUTE, |
| 1098 | [ 0x4a ] = KEY_SEARCH, | 1098 | [ 0x26 ] = KEY_SEARCH, /*SCAN*/ |
| 1099 | [ 0x7b ] = KEY_SHUFFLE, /* SNAPSHOT */ | 1099 | [ 0x3f ] = KEY_SHUFFLE, /* SNAPSHOT */ |
| 1100 | [ 0x22 ] = KEY_RECORD, | 1100 | [ 0x12 ] = KEY_RECORD, |
| 1101 | [ 0x62 ] = KEY_STOP, | 1101 | [ 0x32 ] = KEY_STOP, |
| 1102 | [ 0x78 ] = KEY_PLAY, | 1102 | [ 0x3c ] = KEY_PLAY, |
| 1103 | [ 0x39 ] = KEY_REWIND, | 1103 | [ 0x1d ] = KEY_REWIND, |
| 1104 | [ 0x59 ] = KEY_PAUSE, | 1104 | [ 0x2d ] = KEY_PAUSE, |
| 1105 | [ 0x19 ] = KEY_FORWARD, | 1105 | [ 0x0d ] = KEY_FORWARD, |
| 1106 | [ 0x09 ] = KEY_ZOOM, | 1106 | [ 0x05 ] = KEY_ZOOM, /*FULL*/ |
| 1107 | 1107 | ||
| 1108 | [ 0x52 ] = KEY_F21, /* LIVE TIMESHIFT */ | 1108 | [ 0x2a ] = KEY_F21, /* LIVE TIMESHIFT */ |
| 1109 | [ 0x1a ] = KEY_F22, /* MIN TIMESHIFT */ | 1109 | [ 0x0e ] = KEY_F22, /* MIN TIMESHIFT */ |
| 1110 | [ 0x3a ] = KEY_F23, /* TIMESHIFT */ | 1110 | [ 0x1e ] = KEY_F23, /* TIMESHIFT */ |
| 1111 | [ 0x70 ] = KEY_F24, /* NORMAL TIMESHIFT */ | 1111 | [ 0x38 ] = KEY_F24, /* NORMAL TIMESHIFT */ |
| 1112 | }; | 1112 | }; |
| 1113 | 1113 | ||
| 1114 | EXPORT_SYMBOL_GPL(ir_codes_gotview7135); | 1114 | EXPORT_SYMBOL_GPL(ir_codes_gotview7135); |
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c index 365a22118a09..2b1f8b4be00a 100644 --- a/drivers/media/common/saa7146_core.c +++ b/drivers/media/common/saa7146_core.c | |||
| @@ -112,12 +112,13 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) | |||
| 112 | sglist = kcalloc(nr_pages, sizeof(struct scatterlist), GFP_KERNEL); | 112 | sglist = kcalloc(nr_pages, sizeof(struct scatterlist), GFP_KERNEL); |
| 113 | if (NULL == sglist) | 113 | if (NULL == sglist) |
| 114 | return NULL; | 114 | return NULL; |
| 115 | sg_init_table(sglist, nr_pages); | ||
| 115 | for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) { | 116 | for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) { |
| 116 | pg = vmalloc_to_page(virt); | 117 | pg = vmalloc_to_page(virt); |
| 117 | if (NULL == pg) | 118 | if (NULL == pg) |
| 118 | goto err; | 119 | goto err; |
| 119 | BUG_ON(PageHighMem(pg)); | 120 | BUG_ON(PageHighMem(pg)); |
| 120 | sglist[i].page = pg; | 121 | sg_set_page(&sglist[i], pg); |
| 121 | sglist[i].length = PAGE_SIZE; | 122 | sglist[i].length = PAGE_SIZE; |
| 122 | } | 123 | } |
| 123 | return sglist; | 124 | return sglist; |
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index a05e5c182288..db08b0a8888a 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c | |||
| @@ -345,7 +345,9 @@ static int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
| 345 | struct dvb_demux *demux = dvbdmxfeed->demux; | 345 | struct dvb_demux *demux = dvbdmxfeed->demux; |
| 346 | struct cinergyt2 *cinergyt2 = demux->priv; | 346 | struct cinergyt2 *cinergyt2 = demux->priv; |
| 347 | 347 | ||
| 348 | if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) | 348 | if (cinergyt2->disconnect_pending) |
| 349 | return -EAGAIN; | ||
| 350 | if (mutex_lock_interruptible(&cinergyt2->sem)) | ||
| 349 | return -ERESTARTSYS; | 351 | return -ERESTARTSYS; |
| 350 | 352 | ||
| 351 | if (cinergyt2->streaming == 0) | 353 | if (cinergyt2->streaming == 0) |
| @@ -361,7 +363,9 @@ static int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
| 361 | struct dvb_demux *demux = dvbdmxfeed->demux; | 363 | struct dvb_demux *demux = dvbdmxfeed->demux; |
| 362 | struct cinergyt2 *cinergyt2 = demux->priv; | 364 | struct cinergyt2 *cinergyt2 = demux->priv; |
| 363 | 365 | ||
| 364 | if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) | 366 | if (cinergyt2->disconnect_pending) |
| 367 | return -EAGAIN; | ||
| 368 | if (mutex_lock_interruptible(&cinergyt2->sem)) | ||
| 365 | return -ERESTARTSYS; | 369 | return -ERESTARTSYS; |
| 366 | 370 | ||
| 367 | if (--cinergyt2->streaming == 0) | 371 | if (--cinergyt2->streaming == 0) |
| @@ -481,12 +485,16 @@ static int cinergyt2_open (struct inode *inode, struct file *file) | |||
| 481 | { | 485 | { |
| 482 | struct dvb_device *dvbdev = file->private_data; | 486 | struct dvb_device *dvbdev = file->private_data; |
| 483 | struct cinergyt2 *cinergyt2 = dvbdev->priv; | 487 | struct cinergyt2 *cinergyt2 = dvbdev->priv; |
| 484 | int err = -ERESTARTSYS; | 488 | int err = -EAGAIN; |
| 485 | 489 | ||
| 486 | if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->wq_sem)) | 490 | if (cinergyt2->disconnect_pending) |
| 491 | goto out; | ||
| 492 | err = mutex_lock_interruptible(&cinergyt2->wq_sem); | ||
| 493 | if (err) | ||
| 487 | goto out; | 494 | goto out; |
| 488 | 495 | ||
| 489 | if (mutex_lock_interruptible(&cinergyt2->sem)) | 496 | err = mutex_lock_interruptible(&cinergyt2->sem); |
| 497 | if (err) | ||
| 490 | goto out_unlock1; | 498 | goto out_unlock1; |
| 491 | 499 | ||
| 492 | if ((err = dvb_generic_open(inode, file))) | 500 | if ((err = dvb_generic_open(inode, file))) |
| @@ -550,7 +558,9 @@ static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct | |||
| 550 | struct cinergyt2 *cinergyt2 = dvbdev->priv; | 558 | struct cinergyt2 *cinergyt2 = dvbdev->priv; |
| 551 | unsigned int mask = 0; | 559 | unsigned int mask = 0; |
| 552 | 560 | ||
| 553 | if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) | 561 | if (cinergyt2->disconnect_pending) |
| 562 | return -EAGAIN; | ||
| 563 | if (mutex_lock_interruptible(&cinergyt2->sem)) | ||
| 554 | return -ERESTARTSYS; | 564 | return -ERESTARTSYS; |
| 555 | 565 | ||
| 556 | poll_wait(file, &cinergyt2->poll_wq, wait); | 566 | poll_wait(file, &cinergyt2->poll_wq, wait); |
| @@ -625,7 +635,9 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file, | |||
| 625 | if (copy_from_user(&p, (void __user*) arg, sizeof(p))) | 635 | if (copy_from_user(&p, (void __user*) arg, sizeof(p))) |
| 626 | return -EFAULT; | 636 | return -EFAULT; |
| 627 | 637 | ||
| 628 | if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) | 638 | if (cinergyt2->disconnect_pending) |
| 639 | return -EAGAIN; | ||
| 640 | if (mutex_lock_interruptible(&cinergyt2->sem)) | ||
| 629 | return -ERESTARTSYS; | 641 | return -ERESTARTSYS; |
| 630 | 642 | ||
| 631 | param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; | 643 | param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; |
| @@ -996,7 +1008,9 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state) | |||
| 996 | { | 1008 | { |
| 997 | struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); | 1009 | struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); |
| 998 | 1010 | ||
| 999 | if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->wq_sem)) | 1011 | if (cinergyt2->disconnect_pending) |
| 1012 | return -EAGAIN; | ||
| 1013 | if (mutex_lock_interruptible(&cinergyt2->wq_sem)) | ||
| 1000 | return -ERESTARTSYS; | 1014 | return -ERESTARTSYS; |
| 1001 | 1015 | ||
| 1002 | cinergyt2_suspend_rc(cinergyt2); | 1016 | cinergyt2_suspend_rc(cinergyt2); |
| @@ -1017,16 +1031,18 @@ static int cinergyt2_resume (struct usb_interface *intf) | |||
| 1017 | { | 1031 | { |
| 1018 | struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); | 1032 | struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); |
| 1019 | struct dvbt_set_parameters_msg *param = &cinergyt2->param; | 1033 | struct dvbt_set_parameters_msg *param = &cinergyt2->param; |
| 1020 | int err = -ERESTARTSYS; | 1034 | int err = -EAGAIN; |
| 1021 | 1035 | ||
| 1022 | if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->wq_sem)) | 1036 | if (cinergyt2->disconnect_pending) |
| 1037 | goto out; | ||
| 1038 | err = mutex_lock_interruptible(&cinergyt2->wq_sem); | ||
| 1039 | if (err) | ||
| 1023 | goto out; | 1040 | goto out; |
| 1024 | 1041 | ||
| 1025 | if (mutex_lock_interruptible(&cinergyt2->sem)) | 1042 | err = mutex_lock_interruptible(&cinergyt2->sem); |
| 1043 | if (err) | ||
| 1026 | goto out_unlock1; | 1044 | goto out_unlock1; |
| 1027 | 1045 | ||
| 1028 | err = 0; | ||
| 1029 | |||
| 1030 | if (!cinergyt2->sleeping) { | 1046 | if (!cinergyt2->sleeping) { |
| 1031 | cinergyt2_sleep(cinergyt2, 0); | 1047 | cinergyt2_sleep(cinergyt2, 0); |
| 1032 | cinergyt2_command(cinergyt2, (char *) param, sizeof(*param), NULL, 0); | 1048 | cinergyt2_command(cinergyt2, (char *) param, sizeof(*param), NULL, 0); |
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 084a508a03da..89437fdab8be 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c | |||
| @@ -972,7 +972,7 @@ static int dvb_ca_en50221_thread(void *data) | |||
| 972 | /* main loop */ | 972 | /* main loop */ |
| 973 | while (!kthread_should_stop()) { | 973 | while (!kthread_should_stop()) { |
| 974 | /* sleep for a bit */ | 974 | /* sleep for a bit */ |
| 975 | while (!ca->wakeup) { | 975 | if (!ca->wakeup) { |
| 976 | set_current_state(TASK_INTERRUPTIBLE); | 976 | set_current_state(TASK_INTERRUPTIBLE); |
| 977 | schedule_timeout(ca->delay); | 977 | schedule_timeout(ca->delay); |
| 978 | if (kthread_should_stop()) | 978 | if (kthread_should_stop()) |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c index e8c4a8694532..58452b52002c 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_devices.c +++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c | |||
| @@ -828,7 +828,7 @@ MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); | |||
| 828 | #define DIB0700_DEFAULT_DEVICE_PROPERTIES \ | 828 | #define DIB0700_DEFAULT_DEVICE_PROPERTIES \ |
| 829 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, \ | 829 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, \ |
| 830 | .usb_ctrl = DEVICE_SPECIFIC, \ | 830 | .usb_ctrl = DEVICE_SPECIFIC, \ |
| 831 | .firmware = "dvb-usb-dib0700-03-pre1.fw", \ | 831 | .firmware = "dvb-usb-dib0700-1.10.fw", \ |
| 832 | .download_firmware = dib0700_download_firmware, \ | 832 | .download_firmware = dib0700_download_firmware, \ |
| 833 | .no_reconnect = 1, \ | 833 | .no_reconnect = 1, \ |
| 834 | .size_of_priv = sizeof(struct dib0700_state), \ | 834 | .size_of_priv = sizeof(struct dib0700_state), \ |
diff --git a/drivers/media/radio/miropcm20-radio.c b/drivers/media/radio/miropcm20-radio.c index c7c9d1dc0690..3ae56fef8c92 100644 --- a/drivers/media/radio/miropcm20-radio.c +++ b/drivers/media/radio/miropcm20-radio.c | |||
| @@ -229,7 +229,6 @@ static struct video_device pcm20_radio = { | |||
| 229 | .owner = THIS_MODULE, | 229 | .owner = THIS_MODULE, |
| 230 | .name = "Miro PCM 20 radio", | 230 | .name = "Miro PCM 20 radio", |
| 231 | .type = VID_TYPE_TUNER, | 231 | .type = VID_TYPE_TUNER, |
| 232 | .hardware = VID_HARDWARE_RTRACK, | ||
| 233 | .fops = &pcm20_fops, | 232 | .fops = &pcm20_fops, |
| 234 | .priv = &pcm20_unit | 233 | .priv = &pcm20_unit |
| 235 | }; | 234 | }; |
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c index 0c963db03614..5e4b9ddb23c0 100644 --- a/drivers/media/radio/radio-gemtek.c +++ b/drivers/media/radio/radio-gemtek.c | |||
| @@ -554,7 +554,6 @@ static struct video_device gemtek_radio = { | |||
| 554 | .owner = THIS_MODULE, | 554 | .owner = THIS_MODULE, |
| 555 | .name = "GemTek Radio card", | 555 | .name = "GemTek Radio card", |
| 556 | .type = VID_TYPE_TUNER, | 556 | .type = VID_TYPE_TUNER, |
| 557 | .hardware = VID_HARDWARE_GEMTEK, | ||
| 558 | .fops = &gemtek_fops, | 557 | .fops = &gemtek_fops, |
| 559 | .vidioc_querycap = vidioc_querycap, | 558 | .vidioc_querycap = vidioc_querycap, |
| 560 | .vidioc_g_tuner = vidioc_g_tuner, | 559 | .vidioc_g_tuner = vidioc_g_tuner, |
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c index 19e9929ffa0f..c94a4d0f2804 100644 --- a/drivers/media/video/arv.c +++ b/drivers/media/video/arv.c | |||
| @@ -755,7 +755,6 @@ static struct video_device ar_template = { | |||
| 755 | .owner = THIS_MODULE, | 755 | .owner = THIS_MODULE, |
| 756 | .name = "Colour AR VGA", | 756 | .name = "Colour AR VGA", |
| 757 | .type = VID_TYPE_CAPTURE, | 757 | .type = VID_TYPE_CAPTURE, |
| 758 | .hardware = VID_HARDWARE_ARV, | ||
| 759 | .fops = &ar_fops, | 758 | .fops = &ar_fops, |
| 760 | .release = ar_release, | 759 | .release = ar_release, |
| 761 | .minor = -1, | 760 | .minor = -1, |
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index 7a332b3efe51..9feeb636ff9b 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
| @@ -3877,7 +3877,6 @@ static struct video_device bttv_video_template = | |||
| 3877 | .name = "UNSET", | 3877 | .name = "UNSET", |
| 3878 | .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER| | 3878 | .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER| |
| 3879 | VID_TYPE_CLIPPING|VID_TYPE_SCALES, | 3879 | VID_TYPE_CLIPPING|VID_TYPE_SCALES, |
| 3880 | .hardware = VID_HARDWARE_BT848, | ||
| 3881 | .fops = &bttv_fops, | 3880 | .fops = &bttv_fops, |
| 3882 | .minor = -1, | 3881 | .minor = -1, |
| 3883 | }; | 3882 | }; |
| @@ -3886,7 +3885,6 @@ static struct video_device bttv_vbi_template = | |||
| 3886 | { | 3885 | { |
| 3887 | .name = "bt848/878 vbi", | 3886 | .name = "bt848/878 vbi", |
| 3888 | .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT, | 3887 | .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT, |
| 3889 | .hardware = VID_HARDWARE_BT848, | ||
| 3890 | .fops = &bttv_fops, | 3888 | .fops = &bttv_fops, |
| 3891 | .minor = -1, | 3889 | .minor = -1, |
| 3892 | }; | 3890 | }; |
| @@ -4034,7 +4032,6 @@ static struct video_device radio_template = | |||
| 4034 | { | 4032 | { |
| 4035 | .name = "bt848/878 radio", | 4033 | .name = "bt848/878 radio", |
| 4036 | .type = VID_TYPE_TUNER, | 4034 | .type = VID_TYPE_TUNER, |
| 4037 | .hardware = VID_HARDWARE_BT848, | ||
| 4038 | .fops = &radio_fops, | 4035 | .fops = &radio_fops, |
| 4039 | .minor = -1, | 4036 | .minor = -1, |
| 4040 | }; | 4037 | }; |
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c index 7f7e3d3398d0..58423525591f 100644 --- a/drivers/media/video/bw-qcam.c +++ b/drivers/media/video/bw-qcam.c | |||
| @@ -899,7 +899,6 @@ static struct video_device qcam_template= | |||
| 899 | .owner = THIS_MODULE, | 899 | .owner = THIS_MODULE, |
| 900 | .name = "Connectix Quickcam", | 900 | .name = "Connectix Quickcam", |
| 901 | .type = VID_TYPE_CAPTURE, | 901 | .type = VID_TYPE_CAPTURE, |
| 902 | .hardware = VID_HARDWARE_QCAM_BW, | ||
| 903 | .fops = &qcam_fops, | 902 | .fops = &qcam_fops, |
| 904 | }; | 903 | }; |
| 905 | 904 | ||
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c index f76c6a6c3766..cf1546b5a7f1 100644 --- a/drivers/media/video/c-qcam.c +++ b/drivers/media/video/c-qcam.c | |||
| @@ -699,7 +699,6 @@ static struct video_device qcam_template= | |||
| 699 | .owner = THIS_MODULE, | 699 | .owner = THIS_MODULE, |
| 700 | .name = "Colour QuickCam", | 700 | .name = "Colour QuickCam", |
| 701 | .type = VID_TYPE_CAPTURE, | 701 | .type = VID_TYPE_CAPTURE, |
| 702 | .hardware = VID_HARDWARE_QCAM_C, | ||
| 703 | .fops = &qcam_fops, | 702 | .fops = &qcam_fops, |
| 704 | }; | 703 | }; |
| 705 | 704 | ||
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index a1d02e5ce0fd..7c630f5ee725 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c | |||
| @@ -65,10 +65,6 @@ MODULE_PARM_DESC(colorspace_conv, | |||
| 65 | 65 | ||
| 66 | #define ABOUT "V4L-Driver for Vision CPiA based cameras" | 66 | #define ABOUT "V4L-Driver for Vision CPiA based cameras" |
| 67 | 67 | ||
| 68 | #ifndef VID_HARDWARE_CPIA | ||
| 69 | #define VID_HARDWARE_CPIA 24 /* FIXME -> from linux/videodev.h */ | ||
| 70 | #endif | ||
| 71 | |||
| 72 | #define CPIA_MODULE_CPIA (0<<5) | 68 | #define CPIA_MODULE_CPIA (0<<5) |
| 73 | #define CPIA_MODULE_SYSTEM (1<<5) | 69 | #define CPIA_MODULE_SYSTEM (1<<5) |
| 74 | #define CPIA_MODULE_VP_CTRL (5<<5) | 70 | #define CPIA_MODULE_VP_CTRL (5<<5) |
| @@ -3804,7 +3800,6 @@ static struct video_device cpia_template = { | |||
| 3804 | .owner = THIS_MODULE, | 3800 | .owner = THIS_MODULE, |
| 3805 | .name = "CPiA Camera", | 3801 | .name = "CPiA Camera", |
| 3806 | .type = VID_TYPE_CAPTURE, | 3802 | .type = VID_TYPE_CAPTURE, |
| 3807 | .hardware = VID_HARDWARE_CPIA, | ||
| 3808 | .fops = &cpia_fops, | 3803 | .fops = &cpia_fops, |
| 3809 | }; | 3804 | }; |
| 3810 | 3805 | ||
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c index e3aaba1e0e0a..e378abec806d 100644 --- a/drivers/media/video/cpia2/cpia2_v4l.c +++ b/drivers/media/video/cpia2/cpia2_v4l.c | |||
| @@ -86,10 +86,6 @@ MODULE_LICENSE("GPL"); | |||
| 86 | 86 | ||
| 87 | #define ABOUT "V4L-Driver for Vision CPiA2 based cameras" | 87 | #define ABOUT "V4L-Driver for Vision CPiA2 based cameras" |
| 88 | 88 | ||
| 89 | #ifndef VID_HARDWARE_CPIA2 | ||
| 90 | #error "VID_HARDWARE_CPIA2 should have been defined in linux/videodev.h" | ||
| 91 | #endif | ||
| 92 | |||
| 93 | struct control_menu_info { | 89 | struct control_menu_info { |
| 94 | int value; | 90 | int value; |
| 95 | char name[32]; | 91 | char name[32]; |
| @@ -1942,7 +1938,6 @@ static struct video_device cpia2_template = { | |||
| 1942 | .type= VID_TYPE_CAPTURE, | 1938 | .type= VID_TYPE_CAPTURE, |
| 1943 | .type2 = V4L2_CAP_VIDEO_CAPTURE | | 1939 | .type2 = V4L2_CAP_VIDEO_CAPTURE | |
| 1944 | V4L2_CAP_STREAMING, | 1940 | V4L2_CAP_STREAMING, |
| 1945 | .hardware= VID_HARDWARE_CPIA2, | ||
| 1946 | .minor= -1, | 1941 | .minor= -1, |
| 1947 | .fops= &fops_template, | 1942 | .fops= &fops_template, |
| 1948 | .release= video_device_release, | 1943 | .release= video_device_release, |
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c index af16505bd2e0..3cdd136477e5 100644 --- a/drivers/media/video/cx23885/cx23885-core.c +++ b/drivers/media/video/cx23885/cx23885-core.c | |||
| @@ -793,7 +793,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
| 793 | dev->pci->subsystem_device); | 793 | dev->pci->subsystem_device); |
| 794 | 794 | ||
| 795 | cx23885_devcount--; | 795 | cx23885_devcount--; |
| 796 | goto fail_free; | 796 | return -ENODEV; |
| 797 | } | 797 | } |
| 798 | 798 | ||
| 799 | /* PCIe stuff */ | 799 | /* PCIe stuff */ |
| @@ -835,10 +835,6 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
| 835 | } | 835 | } |
| 836 | 836 | ||
| 837 | return 0; | 837 | return 0; |
| 838 | |||
| 839 | fail_free: | ||
| 840 | kfree(dev); | ||
| 841 | return -ENODEV; | ||
| 842 | } | 838 | } |
| 843 | 839 | ||
| 844 | void cx23885_dev_unregister(struct cx23885_dev *dev) | 840 | void cx23885_dev_unregister(struct cx23885_dev *dev) |
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c index 141dadf7cf1b..40ffd7a5579a 100644 --- a/drivers/media/video/cx88/cx88-alsa.c +++ b/drivers/media/video/cx88/cx88-alsa.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include <sound/pcm_params.h> | 39 | #include <sound/pcm_params.h> |
| 40 | #include <sound/control.h> | 40 | #include <sound/control.h> |
| 41 | #include <sound/initval.h> | 41 | #include <sound/initval.h> |
| 42 | #include <sound/tlv.h> | ||
| 42 | 43 | ||
| 43 | #include "cx88.h" | 44 | #include "cx88.h" |
| 44 | #include "cx88-reg.h" | 45 | #include "cx88-reg.h" |
| @@ -82,6 +83,7 @@ typedef struct cx88_audio_dev snd_cx88_card_t; | |||
| 82 | 83 | ||
| 83 | 84 | ||
| 84 | 85 | ||
| 86 | |||
| 85 | /**************************************************************************** | 87 | /**************************************************************************** |
| 86 | Module global static vars | 88 | Module global static vars |
| 87 | ****************************************************************************/ | 89 | ****************************************************************************/ |
| @@ -545,8 +547,8 @@ static int __devinit snd_cx88_pcm(snd_cx88_card_t *chip, int device, char *name) | |||
| 545 | /**************************************************************************** | 547 | /**************************************************************************** |
| 546 | CONTROL INTERFACE | 548 | CONTROL INTERFACE |
| 547 | ****************************************************************************/ | 549 | ****************************************************************************/ |
| 548 | static int snd_cx88_capture_volume_info(struct snd_kcontrol *kcontrol, | 550 | static int snd_cx88_volume_info(struct snd_kcontrol *kcontrol, |
| 549 | struct snd_ctl_elem_info *info) | 551 | struct snd_ctl_elem_info *info) |
| 550 | { | 552 | { |
| 551 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 553 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
| 552 | info->count = 2; | 554 | info->count = 2; |
| @@ -556,9 +558,8 @@ static int snd_cx88_capture_volume_info(struct snd_kcontrol *kcontrol, | |||
| 556 | return 0; | 558 | return 0; |
| 557 | } | 559 | } |
| 558 | 560 | ||
| 559 | /* OK - TODO: test it */ | 561 | static int snd_cx88_volume_get(struct snd_kcontrol *kcontrol, |
| 560 | static int snd_cx88_capture_volume_get(struct snd_kcontrol *kcontrol, | 562 | struct snd_ctl_elem_value *value) |
| 561 | struct snd_ctl_elem_value *value) | ||
| 562 | { | 563 | { |
| 563 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | 564 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); |
| 564 | struct cx88_core *core=chip->core; | 565 | struct cx88_core *core=chip->core; |
| @@ -573,8 +574,8 @@ static int snd_cx88_capture_volume_get(struct snd_kcontrol *kcontrol, | |||
| 573 | } | 574 | } |
| 574 | 575 | ||
| 575 | /* OK - TODO: test it */ | 576 | /* OK - TODO: test it */ |
| 576 | static int snd_cx88_capture_volume_put(struct snd_kcontrol *kcontrol, | 577 | static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol, |
| 577 | struct snd_ctl_elem_value *value) | 578 | struct snd_ctl_elem_value *value) |
| 578 | { | 579 | { |
| 579 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | 580 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); |
| 580 | struct cx88_core *core=chip->core; | 581 | struct cx88_core *core=chip->core; |
| @@ -605,14 +606,67 @@ static int snd_cx88_capture_volume_put(struct snd_kcontrol *kcontrol, | |||
| 605 | return changed; | 606 | return changed; |
| 606 | } | 607 | } |
| 607 | 608 | ||
| 608 | static struct snd_kcontrol_new snd_cx88_capture_volume = { | 609 | static const DECLARE_TLV_DB_SCALE(snd_cx88_db_scale, -6300, 100, 0); |
| 610 | |||
| 611 | static struct snd_kcontrol_new snd_cx88_volume = { | ||
| 612 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
| 613 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
| 614 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, | ||
| 615 | .name = "Playback Volume", | ||
| 616 | .info = snd_cx88_volume_info, | ||
| 617 | .get = snd_cx88_volume_get, | ||
| 618 | .put = snd_cx88_volume_put, | ||
| 619 | .tlv.p = snd_cx88_db_scale, | ||
| 620 | }; | ||
| 621 | |||
| 622 | static int snd_cx88_switch_get(struct snd_kcontrol *kcontrol, | ||
| 623 | struct snd_ctl_elem_value *value) | ||
| 624 | { | ||
| 625 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | ||
| 626 | struct cx88_core *core = chip->core; | ||
| 627 | u32 bit = kcontrol->private_value; | ||
| 628 | |||
| 629 | value->value.integer.value[0] = !(cx_read(AUD_VOL_CTL) & bit); | ||
| 630 | return 0; | ||
| 631 | } | ||
| 632 | |||
| 633 | static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, | ||
| 634 | struct snd_ctl_elem_value *value) | ||
| 635 | { | ||
| 636 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | ||
| 637 | struct cx88_core *core = chip->core; | ||
| 638 | u32 bit = kcontrol->private_value; | ||
| 639 | int ret = 0; | ||
| 640 | u32 vol; | ||
| 641 | |||
| 642 | spin_lock_irq(&chip->reg_lock); | ||
| 643 | vol = cx_read(AUD_VOL_CTL); | ||
| 644 | if (value->value.integer.value[0] != !(vol & bit)) { | ||
| 645 | vol ^= bit; | ||
| 646 | cx_write(AUD_VOL_CTL, vol); | ||
| 647 | ret = 1; | ||
| 648 | } | ||
| 649 | spin_unlock_irq(&chip->reg_lock); | ||
| 650 | return ret; | ||
| 651 | } | ||
| 652 | |||
| 653 | static struct snd_kcontrol_new snd_cx88_dac_switch = { | ||
| 609 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 654 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 610 | .name = "Capture Volume", | 655 | .name = "Playback Switch", |
| 611 | .info = snd_cx88_capture_volume_info, | 656 | .info = snd_ctl_boolean_mono_info, |
| 612 | .get = snd_cx88_capture_volume_get, | 657 | .get = snd_cx88_switch_get, |
| 613 | .put = snd_cx88_capture_volume_put, | 658 | .put = snd_cx88_switch_put, |
| 659 | .private_value = (1<<8), | ||
| 614 | }; | 660 | }; |
| 615 | 661 | ||
| 662 | static struct snd_kcontrol_new snd_cx88_source_switch = { | ||
| 663 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
| 664 | .name = "Capture Switch", | ||
| 665 | .info = snd_ctl_boolean_mono_info, | ||
| 666 | .get = snd_cx88_switch_get, | ||
| 667 | .put = snd_cx88_switch_put, | ||
| 668 | .private_value = (1<<6), | ||
| 669 | }; | ||
| 616 | 670 | ||
| 617 | /**************************************************************************** | 671 | /**************************************************************************** |
| 618 | Basic Flow for Sound Devices | 672 | Basic Flow for Sound Devices |
| @@ -762,7 +816,13 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci, | |||
| 762 | if (err < 0) | 816 | if (err < 0) |
| 763 | goto error; | 817 | goto error; |
| 764 | 818 | ||
| 765 | err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_capture_volume, chip)); | 819 | err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_volume, chip)); |
| 820 | if (err < 0) | ||
| 821 | goto error; | ||
| 822 | err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_dac_switch, chip)); | ||
| 823 | if (err < 0) | ||
| 824 | goto error; | ||
| 825 | err = snd_ctl_add(card, snd_ctl_new1(&snd_cx88_source_switch, chip)); | ||
| 766 | if (err < 0) | 826 | if (err < 0) |
| 767 | goto error; | 827 | goto error; |
| 768 | 828 | ||
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index 6d6f5048d762..f33f0b47142c 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c | |||
| @@ -527,44 +527,6 @@ static void blackbird_codec_settings(struct cx8802_dev *dev) | |||
| 527 | cx2341x_update(dev, blackbird_mbox_func, NULL, &dev->params); | 527 | cx2341x_update(dev, blackbird_mbox_func, NULL, &dev->params); |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | static struct v4l2_mpeg_compression default_mpeg_params = { | ||
| 531 | .st_type = V4L2_MPEG_PS_2, | ||
| 532 | .st_bitrate = { | ||
| 533 | .mode = V4L2_BITRATE_CBR, | ||
| 534 | .min = 0, | ||
| 535 | .target = 0, | ||
| 536 | .max = 0 | ||
| 537 | }, | ||
| 538 | .ts_pid_pmt = 16, | ||
| 539 | .ts_pid_audio = 260, | ||
| 540 | .ts_pid_video = 256, | ||
| 541 | .ts_pid_pcr = 259, | ||
| 542 | .ps_size = 0, | ||
| 543 | .au_type = V4L2_MPEG_AU_2_II, | ||
| 544 | .au_bitrate = { | ||
| 545 | .mode = V4L2_BITRATE_CBR, | ||
| 546 | .min = 224, | ||
| 547 | .target = 224, | ||
| 548 | .max = 224 | ||
| 549 | }, | ||
| 550 | .au_sample_rate = 48000, | ||
| 551 | .au_pesid = 0, | ||
| 552 | .vi_type = V4L2_MPEG_VI_2, | ||
| 553 | .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3, | ||
| 554 | .vi_bitrate = { | ||
| 555 | .mode = V4L2_BITRATE_CBR, | ||
| 556 | .min = 4000, | ||
| 557 | .target = 4500, | ||
| 558 | .max = 6000 | ||
| 559 | }, | ||
| 560 | .vi_frame_rate = 25, | ||
| 561 | .vi_frames_per_gop = 12, | ||
| 562 | .vi_bframes_count = 2, | ||
| 563 | .vi_pesid = 0, | ||
| 564 | .closed_gops = 1, | ||
| 565 | .pulldown = 0 | ||
| 566 | }; | ||
| 567 | |||
| 568 | static int blackbird_initialize_codec(struct cx8802_dev *dev) | 530 | static int blackbird_initialize_codec(struct cx8802_dev *dev) |
| 569 | { | 531 | { |
| 570 | struct cx88_core *core = dev->core; | 532 | struct cx88_core *core = dev->core; |
| @@ -852,23 +814,6 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
| 852 | return videobuf_streamoff(&fh->mpegq); | 814 | return videobuf_streamoff(&fh->mpegq); |
| 853 | } | 815 | } |
| 854 | 816 | ||
| 855 | static int vidioc_g_mpegcomp (struct file *file, void *fh, | ||
| 856 | struct v4l2_mpeg_compression *f) | ||
| 857 | { | ||
| 858 | printk(KERN_WARNING "VIDIOC_G_MPEGCOMP is obsolete. " | ||
| 859 | "Replace with VIDIOC_G_EXT_CTRLS!"); | ||
| 860 | memcpy(f,&default_mpeg_params,sizeof(*f)); | ||
| 861 | return 0; | ||
| 862 | } | ||
| 863 | |||
| 864 | static int vidioc_s_mpegcomp (struct file *file, void *fh, | ||
| 865 | struct v4l2_mpeg_compression *f) | ||
| 866 | { | ||
| 867 | printk(KERN_WARNING "VIDIOC_S_MPEGCOMP is obsolete. " | ||
| 868 | "Replace with VIDIOC_S_EXT_CTRLS!"); | ||
| 869 | return 0; | ||
| 870 | } | ||
| 871 | |||
| 872 | static int vidioc_g_ext_ctrls (struct file *file, void *priv, | 817 | static int vidioc_g_ext_ctrls (struct file *file, void *priv, |
| 873 | struct v4l2_ext_controls *f) | 818 | struct v4l2_ext_controls *f) |
| 874 | { | 819 | { |
| @@ -1216,8 +1161,6 @@ static struct video_device cx8802_mpeg_template = | |||
| 1216 | .vidioc_dqbuf = vidioc_dqbuf, | 1161 | .vidioc_dqbuf = vidioc_dqbuf, |
| 1217 | .vidioc_streamon = vidioc_streamon, | 1162 | .vidioc_streamon = vidioc_streamon, |
| 1218 | .vidioc_streamoff = vidioc_streamoff, | 1163 | .vidioc_streamoff = vidioc_streamoff, |
| 1219 | .vidioc_g_mpegcomp = vidioc_g_mpegcomp, | ||
| 1220 | .vidioc_s_mpegcomp = vidioc_s_mpegcomp, | ||
| 1221 | .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls, | 1164 | .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls, |
| 1222 | .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, | 1165 | .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, |
| 1223 | .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, | 1166 | .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, |
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index d16e5c6d21c0..fce19caf9d04 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c | |||
| @@ -475,8 +475,9 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 475 | break; | 475 | break; |
| 476 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: | 476 | case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: |
| 477 | #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) | 477 | #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE)) |
| 478 | /* MT352 is on a secondary I2C bus made from some GPIO lines */ | ||
| 478 | dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, | 479 | dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, |
| 479 | &((struct vp3054_i2c_state *)dev->card_priv)->adap); | 480 | &dev->vp3054->adap); |
| 480 | if (dev->dvb.frontend != NULL) { | 481 | if (dev->dvb.frontend != NULL) { |
| 481 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 482 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, |
| 482 | &dev->core->i2c_adap, DVB_PLL_FMD1216ME); | 483 | &dev->core->i2c_adap, DVB_PLL_FMD1216ME); |
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index a652f294d23d..448c67380945 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
| @@ -79,7 +79,8 @@ static int cx8802_start_dma(struct cx8802_dev *dev, | |||
| 79 | { | 79 | { |
| 80 | struct cx88_core *core = dev->core; | 80 | struct cx88_core *core = dev->core; |
| 81 | 81 | ||
| 82 | dprintk(1, "cx8802_start_dma w: %d, h: %d, f: %d\n", dev->width, dev->height, buf->vb.field); | 82 | dprintk(1, "cx8802_start_dma w: %d, h: %d, f: %d\n", |
| 83 | buf->vb.width, buf->vb.height, buf->vb.field); | ||
| 83 | 84 | ||
| 84 | /* setup fifo + format */ | 85 | /* setup fifo + format */ |
| 85 | cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], | 86 | cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], |
| @@ -177,7 +178,6 @@ static int cx8802_restart_queue(struct cx8802_dev *dev, | |||
| 177 | struct cx88_dmaqueue *q) | 178 | struct cx88_dmaqueue *q) |
| 178 | { | 179 | { |
| 179 | struct cx88_buffer *buf; | 180 | struct cx88_buffer *buf; |
| 180 | struct list_head *item; | ||
| 181 | 181 | ||
| 182 | dprintk( 1, "cx8802_restart_queue\n" ); | 182 | dprintk( 1, "cx8802_restart_queue\n" ); |
| 183 | if (list_empty(&q->active)) | 183 | if (list_empty(&q->active)) |
| @@ -223,10 +223,8 @@ static int cx8802_restart_queue(struct cx8802_dev *dev, | |||
| 223 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", | 223 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", |
| 224 | buf, buf->vb.i); | 224 | buf, buf->vb.i); |
| 225 | cx8802_start_dma(dev, q, buf); | 225 | cx8802_start_dma(dev, q, buf); |
| 226 | list_for_each(item,&q->active) { | 226 | list_for_each_entry(buf, &q->active, vb.queue) |
| 227 | buf = list_entry(item, struct cx88_buffer, vb.queue); | ||
| 228 | buf->count = q->count++; | 227 | buf->count = q->count++; |
| 229 | } | ||
| 230 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 228 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
| 231 | return 0; | 229 | return 0; |
| 232 | } | 230 | } |
| @@ -572,42 +570,29 @@ int cx8802_resume_common(struct pci_dev *pci_dev) | |||
| 572 | return 0; | 570 | return 0; |
| 573 | } | 571 | } |
| 574 | 572 | ||
| 573 | #if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \ | ||
| 574 | defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE) | ||
| 575 | struct cx8802_dev * cx8802_get_device(struct inode *inode) | 575 | struct cx8802_dev * cx8802_get_device(struct inode *inode) |
| 576 | { | 576 | { |
| 577 | int minor = iminor(inode); | 577 | int minor = iminor(inode); |
| 578 | struct cx8802_dev *h = NULL; | 578 | struct cx8802_dev *dev; |
| 579 | struct list_head *list; | ||
| 580 | 579 | ||
| 581 | list_for_each(list,&cx8802_devlist) { | 580 | list_for_each_entry(dev, &cx8802_devlist, devlist) |
| 582 | h = list_entry(list, struct cx8802_dev, devlist); | 581 | if (dev->mpeg_dev && dev->mpeg_dev->minor == minor) |
| 583 | if (h->mpeg_dev && h->mpeg_dev->minor == minor) | 582 | return dev; |
| 584 | return h; | ||
| 585 | } | ||
| 586 | 583 | ||
| 587 | return NULL; | 584 | return NULL; |
| 588 | } | 585 | } |
| 586 | EXPORT_SYMBOL(cx8802_get_device); | ||
| 587 | #endif | ||
| 589 | 588 | ||
| 590 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) | 589 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) |
| 591 | { | 590 | { |
| 592 | struct cx8802_dev *h = NULL; | 591 | struct cx8802_driver *d; |
| 593 | struct cx8802_driver *d = NULL; | ||
| 594 | struct list_head *list; | ||
| 595 | struct list_head *list2; | ||
| 596 | |||
| 597 | list_for_each(list,&cx8802_devlist) { | ||
| 598 | h = list_entry(list, struct cx8802_dev, devlist); | ||
| 599 | if (h != dev) | ||
| 600 | continue; | ||
| 601 | |||
| 602 | list_for_each(list2, &h->drvlist.devlist) { | ||
| 603 | d = list_entry(list2, struct cx8802_driver, devlist); | ||
| 604 | 592 | ||
| 605 | /* only unregister the correct driver type */ | 593 | list_for_each_entry(d, &dev->drvlist, drvlist) |
| 606 | if (d->type_id == btype) { | 594 | if (d->type_id == btype) |
| 607 | return d; | 595 | return d; |
| 608 | } | ||
| 609 | } | ||
| 610 | } | ||
| 611 | 596 | ||
| 612 | return NULL; | 597 | return NULL; |
| 613 | } | 598 | } |
| @@ -671,10 +656,9 @@ static int cx8802_check_driver(struct cx8802_driver *drv) | |||
| 671 | 656 | ||
| 672 | int cx8802_register_driver(struct cx8802_driver *drv) | 657 | int cx8802_register_driver(struct cx8802_driver *drv) |
| 673 | { | 658 | { |
| 674 | struct cx8802_dev *h; | 659 | struct cx8802_dev *dev; |
| 675 | struct cx8802_driver *driver; | 660 | struct cx8802_driver *driver; |
| 676 | struct list_head *list; | 661 | int err, i = 0; |
| 677 | int err = 0, i = 0; | ||
| 678 | 662 | ||
| 679 | printk(KERN_INFO | 663 | printk(KERN_INFO |
| 680 | "cx88/2: registering cx8802 driver, type: %s access: %s\n", | 664 | "cx88/2: registering cx8802 driver, type: %s access: %s\n", |
| @@ -686,14 +670,12 @@ int cx8802_register_driver(struct cx8802_driver *drv) | |||
| 686 | return err; | 670 | return err; |
| 687 | } | 671 | } |
| 688 | 672 | ||
| 689 | list_for_each(list,&cx8802_devlist) { | 673 | list_for_each_entry(dev, &cx8802_devlist, devlist) { |
| 690 | h = list_entry(list, struct cx8802_dev, devlist); | ||
| 691 | |||
| 692 | printk(KERN_INFO | 674 | printk(KERN_INFO |
| 693 | "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", | 675 | "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", |
| 694 | h->core->name, h->pci->subsystem_vendor, | 676 | dev->core->name, dev->pci->subsystem_vendor, |
| 695 | h->pci->subsystem_device, h->core->board.name, | 677 | dev->pci->subsystem_device, dev->core->board.name, |
| 696 | h->core->boardnr); | 678 | dev->core->boardnr); |
| 697 | 679 | ||
| 698 | /* Bring up a new struct for each driver instance */ | 680 | /* Bring up a new struct for each driver instance */ |
| 699 | driver = kzalloc(sizeof(*drv),GFP_KERNEL); | 681 | driver = kzalloc(sizeof(*drv),GFP_KERNEL); |
| @@ -701,7 +683,7 @@ int cx8802_register_driver(struct cx8802_driver *drv) | |||
| 701 | return -ENOMEM; | 683 | return -ENOMEM; |
| 702 | 684 | ||
| 703 | /* Snapshot of the driver registration data */ | 685 | /* Snapshot of the driver registration data */ |
| 704 | drv->core = h->core; | 686 | drv->core = dev->core; |
| 705 | drv->suspend = cx8802_suspend_common; | 687 | drv->suspend = cx8802_suspend_common; |
| 706 | drv->resume = cx8802_resume_common; | 688 | drv->resume = cx8802_resume_common; |
| 707 | drv->request_acquire = cx8802_request_acquire; | 689 | drv->request_acquire = cx8802_request_acquire; |
| @@ -712,49 +694,38 @@ int cx8802_register_driver(struct cx8802_driver *drv) | |||
| 712 | if (err == 0) { | 694 | if (err == 0) { |
| 713 | i++; | 695 | i++; |
| 714 | mutex_lock(&drv->core->lock); | 696 | mutex_lock(&drv->core->lock); |
| 715 | list_add_tail(&driver->devlist,&h->drvlist.devlist); | 697 | list_add_tail(&driver->drvlist, &dev->drvlist); |
| 716 | mutex_unlock(&drv->core->lock); | 698 | mutex_unlock(&drv->core->lock); |
| 717 | } else { | 699 | } else { |
| 718 | printk(KERN_ERR | 700 | printk(KERN_ERR |
| 719 | "%s/2: cx8802 probe failed, err = %d\n", | 701 | "%s/2: cx8802 probe failed, err = %d\n", |
| 720 | h->core->name, err); | 702 | dev->core->name, err); |
| 721 | } | 703 | } |
| 722 | 704 | ||
| 723 | } | 705 | } |
| 724 | if (i == 0) | ||
| 725 | err = -ENODEV; | ||
| 726 | else | ||
| 727 | err = 0; | ||
| 728 | 706 | ||
| 729 | return err; | 707 | return i ? 0 : -ENODEV; |
| 730 | } | 708 | } |
| 731 | 709 | ||
| 732 | int cx8802_unregister_driver(struct cx8802_driver *drv) | 710 | int cx8802_unregister_driver(struct cx8802_driver *drv) |
| 733 | { | 711 | { |
| 734 | struct cx8802_dev *h; | 712 | struct cx8802_dev *dev; |
| 735 | struct cx8802_driver *d; | 713 | struct cx8802_driver *d, *dtmp; |
| 736 | struct list_head *list; | 714 | int err = 0; |
| 737 | struct list_head *list2, *q; | ||
| 738 | int err = 0, i = 0; | ||
| 739 | 715 | ||
| 740 | printk(KERN_INFO | 716 | printk(KERN_INFO |
| 741 | "cx88/2: unregistering cx8802 driver, type: %s access: %s\n", | 717 | "cx88/2: unregistering cx8802 driver, type: %s access: %s\n", |
| 742 | drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird", | 718 | drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird", |
| 743 | drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive"); | 719 | drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive"); |
| 744 | 720 | ||
| 745 | list_for_each(list,&cx8802_devlist) { | 721 | list_for_each_entry(dev, &cx8802_devlist, devlist) { |
| 746 | i++; | ||
| 747 | h = list_entry(list, struct cx8802_dev, devlist); | ||
| 748 | |||
| 749 | printk(KERN_INFO | 722 | printk(KERN_INFO |
| 750 | "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", | 723 | "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", |
| 751 | h->core->name, h->pci->subsystem_vendor, | 724 | dev->core->name, dev->pci->subsystem_vendor, |
| 752 | h->pci->subsystem_device, h->core->board.name, | 725 | dev->pci->subsystem_device, dev->core->board.name, |
| 753 | h->core->boardnr); | 726 | dev->core->boardnr); |
| 754 | |||
| 755 | list_for_each_safe(list2, q, &h->drvlist.devlist) { | ||
| 756 | d = list_entry(list2, struct cx8802_driver, devlist); | ||
| 757 | 727 | ||
| 728 | list_for_each_entry_safe(d, dtmp, &dev->drvlist, drvlist) { | ||
| 758 | /* only unregister the correct driver type */ | 729 | /* only unregister the correct driver type */ |
| 759 | if (d->type_id != drv->type_id) | 730 | if (d->type_id != drv->type_id) |
| 760 | continue; | 731 | continue; |
| @@ -762,12 +733,12 @@ int cx8802_unregister_driver(struct cx8802_driver *drv) | |||
| 762 | err = d->remove(d); | 733 | err = d->remove(d); |
| 763 | if (err == 0) { | 734 | if (err == 0) { |
| 764 | mutex_lock(&drv->core->lock); | 735 | mutex_lock(&drv->core->lock); |
| 765 | list_del(list2); | 736 | list_del(&d->drvlist); |
| 766 | mutex_unlock(&drv->core->lock); | 737 | mutex_unlock(&drv->core->lock); |
| 738 | kfree(d); | ||
| 767 | } else | 739 | } else |
| 768 | printk(KERN_ERR "%s/2: cx8802 driver remove " | 740 | printk(KERN_ERR "%s/2: cx8802 driver remove " |
| 769 | "failed (%d)\n", h->core->name, err); | 741 | "failed (%d)\n", dev->core->name, err); |
| 770 | |||
| 771 | } | 742 | } |
| 772 | 743 | ||
| 773 | } | 744 | } |
| @@ -805,7 +776,7 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev, | |||
| 805 | if (err != 0) | 776 | if (err != 0) |
| 806 | goto fail_free; | 777 | goto fail_free; |
| 807 | 778 | ||
| 808 | INIT_LIST_HEAD(&dev->drvlist.devlist); | 779 | INIT_LIST_HEAD(&dev->drvlist); |
| 809 | list_add_tail(&dev->devlist,&cx8802_devlist); | 780 | list_add_tail(&dev->devlist,&cx8802_devlist); |
| 810 | 781 | ||
| 811 | /* Maintain a reference so cx88-video can query the 8802 device. */ | 782 | /* Maintain a reference so cx88-video can query the 8802 device. */ |
| @@ -825,23 +796,30 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev, | |||
| 825 | static void __devexit cx8802_remove(struct pci_dev *pci_dev) | 796 | static void __devexit cx8802_remove(struct pci_dev *pci_dev) |
| 826 | { | 797 | { |
| 827 | struct cx8802_dev *dev; | 798 | struct cx8802_dev *dev; |
| 828 | struct cx8802_driver *h; | ||
| 829 | struct list_head *list; | ||
| 830 | 799 | ||
| 831 | dev = pci_get_drvdata(pci_dev); | 800 | dev = pci_get_drvdata(pci_dev); |
| 832 | 801 | ||
| 833 | dprintk( 1, "%s\n", __FUNCTION__); | 802 | dprintk( 1, "%s\n", __FUNCTION__); |
| 834 | 803 | ||
| 835 | list_for_each(list,&dev->drvlist.devlist) { | 804 | if (!list_empty(&dev->drvlist)) { |
| 836 | h = list_entry(list, struct cx8802_driver, devlist); | 805 | struct cx8802_driver *drv, *tmp; |
| 837 | dprintk( 1, " ->driver\n"); | 806 | int err; |
| 838 | if (h->remove == NULL) { | 807 | |
| 839 | printk(KERN_ERR "%s .. skipping driver, no probe function\n", __FUNCTION__); | 808 | printk(KERN_WARNING "%s/2: Trying to remove cx8802 driver " |
| 840 | continue; | 809 | "while cx8802 sub-drivers still loaded?!\n", |
| 810 | dev->core->name); | ||
| 811 | |||
| 812 | list_for_each_entry_safe(drv, tmp, &dev->drvlist, drvlist) { | ||
| 813 | err = drv->remove(drv); | ||
| 814 | if (err == 0) { | ||
| 815 | mutex_lock(&drv->core->lock); | ||
| 816 | list_del(&drv->drvlist); | ||
| 817 | mutex_unlock(&drv->core->lock); | ||
| 818 | } else | ||
| 819 | printk(KERN_ERR "%s/2: cx8802 driver remove " | ||
| 820 | "failed (%d)\n", dev->core->name, err); | ||
| 821 | kfree(drv); | ||
| 841 | } | 822 | } |
| 842 | printk(KERN_INFO "%s .. Removing driver type %d\n", __FUNCTION__, h->type_id); | ||
| 843 | cx8802_unregister_driver(h); | ||
| 844 | list_del(&dev->drvlist.devlist); | ||
| 845 | } | 823 | } |
| 846 | 824 | ||
| 847 | /* Destroy any 8802 reference. */ | 825 | /* Destroy any 8802 reference. */ |
| @@ -901,7 +879,6 @@ EXPORT_SYMBOL(cx8802_fini_common); | |||
| 901 | 879 | ||
| 902 | EXPORT_SYMBOL(cx8802_register_driver); | 880 | EXPORT_SYMBOL(cx8802_register_driver); |
| 903 | EXPORT_SYMBOL(cx8802_unregister_driver); | 881 | EXPORT_SYMBOL(cx8802_unregister_driver); |
| 904 | EXPORT_SYMBOL(cx8802_get_device); | ||
| 905 | EXPORT_SYMBOL(cx8802_get_driver); | 882 | EXPORT_SYMBOL(cx8802_get_driver); |
| 906 | /* ----------------------------------------------------------- */ | 883 | /* ----------------------------------------------------------- */ |
| 907 | /* | 884 | /* |
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 231ae6c4dd22..5ee05f8f3fad 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
| @@ -1675,7 +1675,6 @@ static struct video_device cx8800_radio_template = | |||
| 1675 | { | 1675 | { |
| 1676 | .name = "cx8800-radio", | 1676 | .name = "cx8800-radio", |
| 1677 | .type = VID_TYPE_TUNER, | 1677 | .type = VID_TYPE_TUNER, |
| 1678 | .hardware = 0, | ||
| 1679 | .fops = &radio_fops, | 1678 | .fops = &radio_fops, |
| 1680 | .minor = -1, | 1679 | .minor = -1, |
| 1681 | .vidioc_querycap = radio_querycap, | 1680 | .vidioc_querycap = radio_querycap, |
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c index 77c37889232b..6ce5af488471 100644 --- a/drivers/media/video/cx88/cx88-vp3054-i2c.c +++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c | |||
| @@ -41,7 +41,7 @@ static void vp3054_bit_setscl(void *data, int state) | |||
| 41 | { | 41 | { |
| 42 | struct cx8802_dev *dev = data; | 42 | struct cx8802_dev *dev = data; |
| 43 | struct cx88_core *core = dev->core; | 43 | struct cx88_core *core = dev->core; |
| 44 | struct vp3054_i2c_state *vp3054_i2c = dev->card_priv; | 44 | struct vp3054_i2c_state *vp3054_i2c = dev->vp3054; |
| 45 | 45 | ||
| 46 | if (state) { | 46 | if (state) { |
| 47 | vp3054_i2c->state |= 0x0001; /* SCL high */ | 47 | vp3054_i2c->state |= 0x0001; /* SCL high */ |
| @@ -58,7 +58,7 @@ static void vp3054_bit_setsda(void *data, int state) | |||
| 58 | { | 58 | { |
| 59 | struct cx8802_dev *dev = data; | 59 | struct cx8802_dev *dev = data; |
| 60 | struct cx88_core *core = dev->core; | 60 | struct cx88_core *core = dev->core; |
| 61 | struct vp3054_i2c_state *vp3054_i2c = dev->card_priv; | 61 | struct vp3054_i2c_state *vp3054_i2c = dev->vp3054; |
| 62 | 62 | ||
| 63 | if (state) { | 63 | if (state) { |
| 64 | vp3054_i2c->state |= 0x0002; /* SDA high */ | 64 | vp3054_i2c->state |= 0x0002; /* SDA high */ |
| @@ -113,10 +113,10 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) | |||
| 113 | if (core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) | 113 | if (core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) |
| 114 | return 0; | 114 | return 0; |
| 115 | 115 | ||
| 116 | dev->card_priv = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL); | 116 | vp3054_i2c = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL); |
| 117 | if (dev->card_priv == NULL) | 117 | if (vp3054_i2c == NULL) |
| 118 | return -ENOMEM; | 118 | return -ENOMEM; |
| 119 | vp3054_i2c = dev->card_priv; | 119 | dev->vp3054 = vp3054_i2c; |
| 120 | 120 | ||
| 121 | memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, | 121 | memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, |
| 122 | sizeof(vp3054_i2c->algo)); | 122 | sizeof(vp3054_i2c->algo)); |
| @@ -139,8 +139,8 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) | |||
| 139 | if (0 != rc) { | 139 | if (0 != rc) { |
| 140 | printk("%s: vp3054_i2c register FAILED\n", core->name); | 140 | printk("%s: vp3054_i2c register FAILED\n", core->name); |
| 141 | 141 | ||
| 142 | kfree(dev->card_priv); | 142 | kfree(dev->vp3054); |
| 143 | dev->card_priv = NULL; | 143 | dev->vp3054 = NULL; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | return rc; | 146 | return rc; |
| @@ -148,7 +148,7 @@ int vp3054_i2c_probe(struct cx8802_dev *dev) | |||
| 148 | 148 | ||
| 149 | void vp3054_i2c_remove(struct cx8802_dev *dev) | 149 | void vp3054_i2c_remove(struct cx8802_dev *dev) |
| 150 | { | 150 | { |
| 151 | struct vp3054_i2c_state *vp3054_i2c = dev->card_priv; | 151 | struct vp3054_i2c_state *vp3054_i2c = dev->vp3054; |
| 152 | 152 | ||
| 153 | if (vp3054_i2c == NULL || | 153 | if (vp3054_i2c == NULL || |
| 154 | dev->core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) | 154 | dev->core->boardnr != CX88_BOARD_DNTV_LIVE_DVB_T_PRO) |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 42e0a9b8c550..eb296bdecb1e 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
| @@ -412,7 +412,9 @@ struct cx8802_suspend_state { | |||
| 412 | 412 | ||
| 413 | struct cx8802_driver { | 413 | struct cx8802_driver { |
| 414 | struct cx88_core *core; | 414 | struct cx88_core *core; |
| 415 | struct list_head devlist; | 415 | |
| 416 | /* List of drivers attached to device */ | ||
| 417 | struct list_head drvlist; | ||
| 416 | 418 | ||
| 417 | /* Type of driver and access required */ | 419 | /* Type of driver and access required */ |
| 418 | enum cx88_board_type type_id; | 420 | enum cx88_board_type type_id; |
| @@ -453,27 +455,33 @@ struct cx8802_dev { | |||
| 453 | 455 | ||
| 454 | /* for blackbird only */ | 456 | /* for blackbird only */ |
| 455 | struct list_head devlist; | 457 | struct list_head devlist; |
| 458 | #if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \ | ||
| 459 | defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE) | ||
| 456 | struct video_device *mpeg_dev; | 460 | struct video_device *mpeg_dev; |
| 457 | u32 mailbox; | 461 | u32 mailbox; |
| 458 | int width; | 462 | int width; |
| 459 | int height; | 463 | int height; |
| 460 | 464 | ||
| 465 | /* mpeg params */ | ||
| 466 | struct cx2341x_mpeg_params params; | ||
| 467 | #endif | ||
| 468 | |||
| 461 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) | 469 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) |
| 462 | /* for dvb only */ | 470 | /* for dvb only */ |
| 463 | struct videobuf_dvb dvb; | 471 | struct videobuf_dvb dvb; |
| 472 | #endif | ||
| 464 | 473 | ||
| 465 | void *card_priv; | 474 | #if defined(CONFIG_VIDEO_CX88_VP3054) || \ |
| 475 | defined(CONFIG_VIDEO_CX88_VP3054_MODULE) | ||
| 476 | /* For VP3045 secondary I2C bus support */ | ||
| 477 | struct vp3054_i2c_state *vp3054; | ||
| 466 | #endif | 478 | #endif |
| 467 | /* for switching modulation types */ | 479 | /* for switching modulation types */ |
| 468 | unsigned char ts_gen_cntrl; | 480 | unsigned char ts_gen_cntrl; |
| 469 | 481 | ||
| 470 | /* mpeg params */ | ||
| 471 | struct cx2341x_mpeg_params params; | ||
| 472 | |||
| 473 | /* List of attached drivers */ | 482 | /* List of attached drivers */ |
| 474 | struct cx8802_driver drvlist; | 483 | struct list_head drvlist; |
| 475 | struct work_struct request_module_wk; | 484 | struct work_struct request_module_wk; |
| 476 | |||
| 477 | }; | 485 | }; |
| 478 | 486 | ||
| 479 | /* ----------------------------------------------------------- */ | 487 | /* ----------------------------------------------------------- */ |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index d3282ec62c5b..d56484f20467 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
| @@ -648,7 +648,7 @@ void em28xx_uninit_isoc(struct em28xx *dev) | |||
| 648 | */ | 648 | */ |
| 649 | int em28xx_init_isoc(struct em28xx *dev) | 649 | int em28xx_init_isoc(struct em28xx *dev) |
| 650 | { | 650 | { |
| 651 | /* change interface to 3 which allowes the biggest packet sizes */ | 651 | /* change interface to 3 which allows the biggest packet sizes */ |
| 652 | int i, errCode; | 652 | int i, errCode; |
| 653 | const int sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size; | 653 | const int sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size; |
| 654 | 654 | ||
| @@ -673,6 +673,7 @@ int em28xx_init_isoc(struct em28xx *dev) | |||
| 673 | ("unable to allocate %i bytes for transfer buffer %i\n", | 673 | ("unable to allocate %i bytes for transfer buffer %i\n", |
| 674 | sb_size, i); | 674 | sb_size, i); |
| 675 | em28xx_uninit_isoc(dev); | 675 | em28xx_uninit_isoc(dev); |
| 676 | usb_free_urb(urb); | ||
| 676 | return -ENOMEM; | 677 | return -ENOMEM; |
| 677 | } | 678 | } |
| 678 | memset(dev->transfer_buffer[i], 0, sb_size); | 679 | memset(dev->transfer_buffer[i], 0, sb_size); |
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index e467682aabd7..a4c2a907124a 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
| @@ -1617,7 +1617,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
| 1617 | 1617 | ||
| 1618 | /* Fills VBI device info */ | 1618 | /* Fills VBI device info */ |
| 1619 | dev->vbi_dev->type = VFL_TYPE_VBI; | 1619 | dev->vbi_dev->type = VFL_TYPE_VBI; |
| 1620 | dev->vbi_dev->hardware = 0; | ||
| 1621 | dev->vbi_dev->fops = &em28xx_v4l_fops; | 1620 | dev->vbi_dev->fops = &em28xx_v4l_fops; |
| 1622 | dev->vbi_dev->minor = -1; | 1621 | dev->vbi_dev->minor = -1; |
| 1623 | dev->vbi_dev->dev = &dev->udev->dev; | 1622 | dev->vbi_dev->dev = &dev->udev->dev; |
| @@ -1629,7 +1628,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
| 1629 | dev->vdev->type = VID_TYPE_CAPTURE; | 1628 | dev->vdev->type = VID_TYPE_CAPTURE; |
| 1630 | if (dev->has_tuner) | 1629 | if (dev->has_tuner) |
| 1631 | dev->vdev->type |= VID_TYPE_TUNER; | 1630 | dev->vdev->type |= VID_TYPE_TUNER; |
| 1632 | dev->vdev->hardware = 0; | ||
| 1633 | dev->vdev->fops = &em28xx_v4l_fops; | 1631 | dev->vdev->fops = &em28xx_v4l_fops; |
| 1634 | dev->vdev->minor = -1; | 1632 | dev->vdev->minor = -1; |
| 1635 | dev->vdev->dev = &dev->udev->dev; | 1633 | dev->vdev->dev = &dev->udev->dev; |
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c index d5fef4c01c87..d19d73b81ede 100644 --- a/drivers/media/video/et61x251/et61x251_core.c +++ b/drivers/media/video/et61x251/et61x251_core.c | |||
| @@ -2585,7 +2585,6 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
| 2585 | strcpy(cam->v4ldev->name, "ET61X[12]51 PC Camera"); | 2585 | strcpy(cam->v4ldev->name, "ET61X[12]51 PC Camera"); |
| 2586 | cam->v4ldev->owner = THIS_MODULE; | 2586 | cam->v4ldev->owner = THIS_MODULE; |
| 2587 | cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; | 2587 | cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; |
| 2588 | cam->v4ldev->hardware = 0; | ||
| 2589 | cam->v4ldev->fops = &et61x251_fops; | 2588 | cam->v4ldev->fops = &et61x251_fops; |
| 2590 | cam->v4ldev->minor = video_nr[dev_nr]; | 2589 | cam->v4ldev->minor = video_nr[dev_nr]; |
| 2591 | cam->v4ldev->release = video_device_release; | 2590 | cam->v4ldev->release = video_device_release; |
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index d98dd0d1e373..29779d8bf7fb 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c | |||
| @@ -528,6 +528,7 @@ static int ir_probe(struct i2c_adapter *adap) | |||
| 528 | break; | 528 | break; |
| 529 | case I2C_HW_B_CX2388x: | 529 | case I2C_HW_B_CX2388x: |
| 530 | probe = probe_cx88; | 530 | probe = probe_cx88; |
| 531 | break; | ||
| 531 | case I2C_HW_B_CX23885: | 532 | case I2C_HW_B_CX23885: |
| 532 | probe = probe_cx23885; | 533 | probe = probe_cx23885; |
| 533 | break; | 534 | break; |
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index fd7a932e1d33..6d2dd8764f81 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
| @@ -1003,8 +1003,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
| 1003 | 1003 | ||
| 1004 | IVTV_DEBUG_INFO("base addr: 0x%08x\n", itv->base_addr); | 1004 | IVTV_DEBUG_INFO("base addr: 0x%08x\n", itv->base_addr); |
| 1005 | 1005 | ||
| 1006 | mutex_lock(&itv->serialize_lock); | ||
| 1007 | |||
| 1008 | /* PCI Device Setup */ | 1006 | /* PCI Device Setup */ |
| 1009 | if ((retval = ivtv_setup_pci(itv, dev, pci_id)) != 0) { | 1007 | if ((retval = ivtv_setup_pci(itv, dev, pci_id)) != 0) { |
| 1010 | if (retval == -EIO) | 1008 | if (retval == -EIO) |
| @@ -1064,7 +1062,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
| 1064 | IVTV_DEBUG_INFO("activating i2c...\n"); | 1062 | IVTV_DEBUG_INFO("activating i2c...\n"); |
| 1065 | if (init_ivtv_i2c(itv)) { | 1063 | if (init_ivtv_i2c(itv)) { |
| 1066 | IVTV_ERR("Could not initialize i2c\n"); | 1064 | IVTV_ERR("Could not initialize i2c\n"); |
| 1067 | goto free_irq; | 1065 | goto free_io; |
| 1068 | } | 1066 | } |
| 1069 | 1067 | ||
| 1070 | IVTV_DEBUG_INFO("Active card count: %d.\n", ivtv_cards_active); | 1068 | IVTV_DEBUG_INFO("Active card count: %d.\n", ivtv_cards_active); |
| @@ -1176,7 +1174,11 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
| 1176 | IVTV_ERR("Failed to register irq %d\n", retval); | 1174 | IVTV_ERR("Failed to register irq %d\n", retval); |
| 1177 | goto free_streams; | 1175 | goto free_streams; |
| 1178 | } | 1176 | } |
| 1179 | mutex_unlock(&itv->serialize_lock); | 1177 | retval = ivtv_streams_register(itv); |
| 1178 | if (retval) { | ||
| 1179 | IVTV_ERR("Error %d registering devices\n", retval); | ||
| 1180 | goto free_irq; | ||
| 1181 | } | ||
| 1180 | IVTV_INFO("Initialized card #%d: %s\n", itv->num, itv->card_name); | 1182 | IVTV_INFO("Initialized card #%d: %s\n", itv->num, itv->card_name); |
| 1181 | return 0; | 1183 | return 0; |
| 1182 | 1184 | ||
| @@ -1195,7 +1197,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
| 1195 | release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); | 1197 | release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); |
| 1196 | free_workqueue: | 1198 | free_workqueue: |
| 1197 | destroy_workqueue(itv->irq_work_queues); | 1199 | destroy_workqueue(itv->irq_work_queues); |
| 1198 | mutex_unlock(&itv->serialize_lock); | ||
| 1199 | err: | 1200 | err: |
| 1200 | if (retval == 0) | 1201 | if (retval == 0) |
| 1201 | retval = -ENODEV; | 1202 | retval = -ENODEV; |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index da50fa4a72a5..a200a8a95a2d 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
| @@ -822,6 +822,11 @@ int ivtv_v4l2_close(struct inode *inode, struct file *filp) | |||
| 822 | crystal_freq.flags = 0; | 822 | crystal_freq.flags = 0; |
| 823 | ivtv_saa7115(itv, VIDIOC_INT_S_CRYSTAL_FREQ, &crystal_freq); | 823 | ivtv_saa7115(itv, VIDIOC_INT_S_CRYSTAL_FREQ, &crystal_freq); |
| 824 | } | 824 | } |
| 825 | if (atomic_read(&itv->capturing) > 0) { | ||
| 826 | /* Undo video mute */ | ||
| 827 | ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1, | ||
| 828 | itv->params.video_mute | (itv->params.video_mute_yuv << 8)); | ||
| 829 | } | ||
| 825 | /* Done! Unmute and continue. */ | 830 | /* Done! Unmute and continue. */ |
| 826 | ivtv_unmute(itv); | 831 | ivtv_unmute(itv); |
| 827 | ivtv_release_stream(s); | 832 | ivtv_release_stream(s); |
| @@ -892,6 +897,7 @@ static int ivtv_serialized_open(struct ivtv_stream *s, struct file *filp) | |||
| 892 | if (atomic_read(&itv->capturing) > 0) { | 897 | if (atomic_read(&itv->capturing) > 0) { |
| 893 | /* switching to radio while capture is | 898 | /* switching to radio while capture is |
| 894 | in progress is not polite */ | 899 | in progress is not polite */ |
| 900 | ivtv_release_stream(s); | ||
| 895 | kfree(item); | 901 | kfree(item); |
| 896 | return -EBUSY; | 902 | return -EBUSY; |
| 897 | } | 903 | } |
| @@ -947,7 +953,7 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp) | |||
| 947 | if (itv == NULL) { | 953 | if (itv == NULL) { |
| 948 | /* Couldn't find a device registered | 954 | /* Couldn't find a device registered |
| 949 | on that minor, shouldn't happen! */ | 955 | on that minor, shouldn't happen! */ |
| 950 | IVTV_WARN("No ivtv device found on minor %d\n", minor); | 956 | printk(KERN_WARNING "No ivtv device found on minor %d\n", minor); |
| 951 | return -ENXIO; | 957 | return -ENXIO; |
| 952 | } | 958 | } |
| 953 | 959 | ||
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index 206eee7542db..fd6826f472e3 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
| @@ -555,6 +555,7 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype, | |||
| 555 | 555 | ||
| 556 | /* set window size */ | 556 | /* set window size */ |
| 557 | if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { | 557 | if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
| 558 | struct cx2341x_mpeg_params *p = &itv->params; | ||
| 558 | int w = fmt->fmt.pix.width; | 559 | int w = fmt->fmt.pix.width; |
| 559 | int h = fmt->fmt.pix.height; | 560 | int h = fmt->fmt.pix.height; |
| 560 | 561 | ||
| @@ -566,17 +567,19 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype, | |||
| 566 | fmt->fmt.pix.width = w; | 567 | fmt->fmt.pix.width = w; |
| 567 | fmt->fmt.pix.height = h; | 568 | fmt->fmt.pix.height = h; |
| 568 | 569 | ||
| 569 | if (!set_fmt || (itv->params.width == w && itv->params.height == h)) | 570 | if (!set_fmt || (p->width == w && p->height == h)) |
| 570 | return 0; | 571 | return 0; |
| 571 | if (atomic_read(&itv->capturing) > 0) | 572 | if (atomic_read(&itv->capturing) > 0) |
| 572 | return -EBUSY; | 573 | return -EBUSY; |
| 573 | 574 | ||
| 574 | itv->params.width = w; | 575 | p->width = w; |
| 575 | itv->params.height = h; | 576 | p->height = h; |
| 576 | if (w != 720 || h != (itv->is_50hz ? 576 : 480)) | 577 | if (w != 720 || h != (itv->is_50hz ? 576 : 480)) |
| 577 | itv->params.video_temporal_filter = 0; | 578 | p->video_temporal_filter = 0; |
| 578 | else | 579 | else |
| 579 | itv->params.video_temporal_filter = 8; | 580 | p->video_temporal_filter = 8; |
| 581 | if (p->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) | ||
| 582 | fmt->fmt.pix.width /= 2; | ||
| 580 | itv->video_dec_func(itv, VIDIOC_S_FMT, fmt); | 583 | itv->video_dec_func(itv, VIDIOC_S_FMT, fmt); |
| 581 | return ivtv_get_fmt(itv, streamtype, fmt); | 584 | return ivtv_get_fmt(itv, streamtype, fmt); |
| 582 | } | 585 | } |
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index fd135985e70f..aa03e61ef310 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
| @@ -166,10 +166,9 @@ static void ivtv_stream_init(struct ivtv *itv, int type) | |||
| 166 | ivtv_queue_init(&s->q_io); | 166 | ivtv_queue_init(&s->q_io); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | static int ivtv_reg_dev(struct ivtv *itv, int type) | 169 | static int ivtv_prep_dev(struct ivtv *itv, int type) |
| 170 | { | 170 | { |
| 171 | struct ivtv_stream *s = &itv->streams[type]; | 171 | struct ivtv_stream *s = &itv->streams[type]; |
| 172 | int vfl_type = ivtv_stream_info[type].vfl_type; | ||
| 173 | int minor_offset = ivtv_stream_info[type].minor_offset; | 172 | int minor_offset = ivtv_stream_info[type].minor_offset; |
| 174 | int minor; | 173 | int minor; |
| 175 | 174 | ||
| @@ -187,15 +186,12 @@ static int ivtv_reg_dev(struct ivtv *itv, int type) | |||
| 187 | if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) | 186 | if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) |
| 188 | return 0; | 187 | return 0; |
| 189 | 188 | ||
| 190 | if (minor_offset >= 0) | 189 | /* card number + user defined offset + device offset */ |
| 191 | /* card number + user defined offset + device offset */ | 190 | minor = itv->num + ivtv_first_minor + minor_offset; |
| 192 | minor = itv->num + ivtv_first_minor + minor_offset; | ||
| 193 | else | ||
| 194 | minor = -1; | ||
| 195 | 191 | ||
| 196 | /* User explicitly selected 0 buffers for these streams, so don't | 192 | /* User explicitly selected 0 buffers for these streams, so don't |
| 197 | create them. */ | 193 | create them. */ |
| 198 | if (minor >= 0 && ivtv_stream_info[type].dma != PCI_DMA_NONE && | 194 | if (ivtv_stream_info[type].dma != PCI_DMA_NONE && |
| 199 | itv->options.kilobytes[type] == 0) { | 195 | itv->options.kilobytes[type] == 0) { |
| 200 | IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name); | 196 | IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name); |
| 201 | return 0; | 197 | return 0; |
| @@ -223,21 +219,53 @@ static int ivtv_reg_dev(struct ivtv *itv, int type) | |||
| 223 | s->v4l2dev->fops = ivtv_stream_info[type].fops; | 219 | s->v4l2dev->fops = ivtv_stream_info[type].fops; |
| 224 | s->v4l2dev->release = video_device_release; | 220 | s->v4l2dev->release = video_device_release; |
| 225 | 221 | ||
| 226 | if (minor >= 0) { | 222 | return 0; |
| 227 | /* Register device. First try the desired minor, then any free one. */ | 223 | } |
| 228 | if (video_register_device(s->v4l2dev, vfl_type, minor) && | 224 | |
| 229 | video_register_device(s->v4l2dev, vfl_type, -1)) { | 225 | /* Initialize v4l2 variables and prepare v4l2 devices */ |
| 230 | IVTV_ERR("Couldn't register v4l2 device for %s minor %d\n", | 226 | int ivtv_streams_setup(struct ivtv *itv) |
| 231 | s->name, minor); | 227 | { |
| 232 | video_device_release(s->v4l2dev); | 228 | int type; |
| 233 | s->v4l2dev = NULL; | 229 | |
| 234 | return -ENOMEM; | 230 | /* Setup V4L2 Devices */ |
| 235 | } | 231 | for (type = 0; type < IVTV_MAX_STREAMS; type++) { |
| 232 | /* Prepare device */ | ||
| 233 | if (ivtv_prep_dev(itv, type)) | ||
| 234 | break; | ||
| 235 | |||
| 236 | if (itv->streams[type].v4l2dev == NULL) | ||
| 237 | continue; | ||
| 238 | |||
| 239 | /* Allocate Stream */ | ||
| 240 | if (ivtv_stream_alloc(&itv->streams[type])) | ||
| 241 | break; | ||
| 236 | } | 242 | } |
| 237 | else { | 243 | if (type == IVTV_MAX_STREAMS) |
| 238 | /* Don't register a 'hidden' stream (OSD) */ | ||
| 239 | IVTV_INFO("Created framebuffer stream for %s\n", s->name); | ||
| 240 | return 0; | 244 | return 0; |
| 245 | |||
| 246 | /* One or more streams could not be initialized. Clean 'em all up. */ | ||
| 247 | ivtv_streams_cleanup(itv); | ||
| 248 | return -ENOMEM; | ||
| 249 | } | ||
| 250 | |||
| 251 | static int ivtv_reg_dev(struct ivtv *itv, int type) | ||
| 252 | { | ||
| 253 | struct ivtv_stream *s = &itv->streams[type]; | ||
| 254 | int vfl_type = ivtv_stream_info[type].vfl_type; | ||
| 255 | int minor; | ||
| 256 | |||
| 257 | if (s->v4l2dev == NULL) | ||
| 258 | return 0; | ||
| 259 | |||
| 260 | minor = s->v4l2dev->minor; | ||
| 261 | /* Register device. First try the desired minor, then any free one. */ | ||
| 262 | if (video_register_device(s->v4l2dev, vfl_type, minor) && | ||
| 263 | video_register_device(s->v4l2dev, vfl_type, -1)) { | ||
| 264 | IVTV_ERR("Couldn't register v4l2 device for %s minor %d\n", | ||
| 265 | s->name, minor); | ||
| 266 | video_device_release(s->v4l2dev); | ||
| 267 | s->v4l2dev = NULL; | ||
| 268 | return -ENOMEM; | ||
| 241 | } | 269 | } |
| 242 | 270 | ||
| 243 | switch (vfl_type) { | 271 | switch (vfl_type) { |
| @@ -262,27 +290,18 @@ static int ivtv_reg_dev(struct ivtv *itv, int type) | |||
| 262 | return 0; | 290 | return 0; |
| 263 | } | 291 | } |
| 264 | 292 | ||
| 265 | /* Initialize v4l2 variables and register v4l2 devices */ | 293 | /* Register v4l2 devices */ |
| 266 | int ivtv_streams_setup(struct ivtv *itv) | 294 | int ivtv_streams_register(struct ivtv *itv) |
| 267 | { | 295 | { |
| 268 | int type; | 296 | int type; |
| 297 | int err = 0; | ||
| 269 | 298 | ||
| 270 | /* Setup V4L2 Devices */ | 299 | /* Register V4L2 devices */ |
| 271 | for (type = 0; type < IVTV_MAX_STREAMS; type++) { | 300 | for (type = 0; type < IVTV_MAX_STREAMS; type++) |
| 272 | /* Register Device */ | 301 | err |= ivtv_reg_dev(itv, type); |
| 273 | if (ivtv_reg_dev(itv, type)) | ||
| 274 | break; | ||
| 275 | |||
| 276 | if (itv->streams[type].v4l2dev == NULL) | ||
| 277 | continue; | ||
| 278 | 302 | ||
| 279 | /* Allocate Stream */ | 303 | if (err == 0) |
| 280 | if (ivtv_stream_alloc(&itv->streams[type])) | ||
| 281 | break; | ||
| 282 | } | ||
| 283 | if (type == IVTV_MAX_STREAMS) { | ||
| 284 | return 0; | 304 | return 0; |
| 285 | } | ||
| 286 | 305 | ||
| 287 | /* One or more streams could not be initialized. Clean 'em all up. */ | 306 | /* One or more streams could not be initialized. Clean 'em all up. */ |
| 288 | ivtv_streams_cleanup(itv); | 307 | ivtv_streams_cleanup(itv); |
| @@ -303,11 +322,8 @@ void ivtv_streams_cleanup(struct ivtv *itv) | |||
| 303 | continue; | 322 | continue; |
| 304 | 323 | ||
| 305 | ivtv_stream_free(&itv->streams[type]); | 324 | ivtv_stream_free(&itv->streams[type]); |
| 306 | /* Free Device */ | 325 | /* Unregister device */ |
| 307 | if (vdev->minor == -1) /* 'Hidden' never registered stream (OSD) */ | 326 | video_unregister_device(vdev); |
| 308 | video_device_release(vdev); | ||
| 309 | else /* All others, just unregister. */ | ||
| 310 | video_unregister_device(vdev); | ||
| 311 | } | 327 | } |
| 312 | } | 328 | } |
| 313 | 329 | ||
| @@ -425,6 +441,7 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s) | |||
| 425 | { | 441 | { |
| 426 | u32 data[CX2341X_MBOX_MAX_DATA]; | 442 | u32 data[CX2341X_MBOX_MAX_DATA]; |
| 427 | struct ivtv *itv = s->itv; | 443 | struct ivtv *itv = s->itv; |
| 444 | struct cx2341x_mpeg_params *p = &itv->params; | ||
| 428 | int captype = 0, subtype = 0; | 445 | int captype = 0, subtype = 0; |
| 429 | int enable_passthrough = 0; | 446 | int enable_passthrough = 0; |
| 430 | 447 | ||
| @@ -445,7 +462,7 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s) | |||
| 445 | } | 462 | } |
| 446 | itv->mpg_data_received = itv->vbi_data_inserted = 0; | 463 | itv->mpg_data_received = itv->vbi_data_inserted = 0; |
| 447 | itv->dualwatch_jiffies = jiffies; | 464 | itv->dualwatch_jiffies = jiffies; |
| 448 | itv->dualwatch_stereo_mode = itv->params.audio_properties & 0x0300; | 465 | itv->dualwatch_stereo_mode = p->audio_properties & 0x0300; |
| 449 | itv->search_pack_header = 0; | 466 | itv->search_pack_header = 0; |
| 450 | break; | 467 | break; |
| 451 | 468 | ||
| @@ -477,9 +494,6 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s) | |||
| 477 | s->subtype = subtype; | 494 | s->subtype = subtype; |
| 478 | s->buffers_stolen = 0; | 495 | s->buffers_stolen = 0; |
| 479 | 496 | ||
| 480 | /* mute/unmute video */ | ||
| 481 | ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1, test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? 1 : 0); | ||
| 482 | |||
| 483 | /* Clear Streamoff flags in case left from last capture */ | 497 | /* Clear Streamoff flags in case left from last capture */ |
| 484 | clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags); | 498 | clear_bit(IVTV_F_S_STREAMOFF, &s->s_flags); |
| 485 | 499 | ||
| @@ -536,7 +550,12 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s) | |||
| 536 | itv->pgm_info_offset, itv->pgm_info_num); | 550 | itv->pgm_info_offset, itv->pgm_info_num); |
| 537 | 551 | ||
| 538 | /* Setup API for Stream */ | 552 | /* Setup API for Stream */ |
| 539 | cx2341x_update(itv, ivtv_api_func, NULL, &itv->params); | 553 | cx2341x_update(itv, ivtv_api_func, NULL, p); |
| 554 | |||
| 555 | /* mute if capturing radio */ | ||
| 556 | if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) | ||
| 557 | ivtv_vapi(itv, CX2341X_ENC_MUTE_VIDEO, 1, | ||
| 558 | 1 | (p->video_mute_yuv << 8)); | ||
| 540 | } | 559 | } |
| 541 | 560 | ||
| 542 | /* Vsync Setup */ | 561 | /* Vsync Setup */ |
| @@ -585,6 +604,7 @@ static int ivtv_setup_v4l2_decode_stream(struct ivtv_stream *s) | |||
| 585 | { | 604 | { |
| 586 | u32 data[CX2341X_MBOX_MAX_DATA]; | 605 | u32 data[CX2341X_MBOX_MAX_DATA]; |
| 587 | struct ivtv *itv = s->itv; | 606 | struct ivtv *itv = s->itv; |
| 607 | struct cx2341x_mpeg_params *p = &itv->params; | ||
| 588 | int datatype; | 608 | int datatype; |
| 589 | 609 | ||
| 590 | if (s->v4l2dev == NULL) | 610 | if (s->v4l2dev == NULL) |
| @@ -623,7 +643,7 @@ static int ivtv_setup_v4l2_decode_stream(struct ivtv_stream *s) | |||
| 623 | break; | 643 | break; |
| 624 | } | 644 | } |
| 625 | if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype, | 645 | if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype, |
| 626 | itv->params.width, itv->params.height, itv->params.audio_properties)) { | 646 | p->width, p->height, p->audio_properties)) { |
| 627 | IVTV_DEBUG_WARN("Couldn't initialize decoder source\n"); | 647 | IVTV_DEBUG_WARN("Couldn't initialize decoder source\n"); |
| 628 | } | 648 | } |
| 629 | return 0; | 649 | return 0; |
diff --git a/drivers/media/video/ivtv/ivtv-streams.h b/drivers/media/video/ivtv/ivtv-streams.h index 8f5f5b1c7c89..3d76a415fbd8 100644 --- a/drivers/media/video/ivtv/ivtv-streams.h +++ b/drivers/media/video/ivtv/ivtv-streams.h | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #define IVTV_STREAMS_H | 22 | #define IVTV_STREAMS_H |
| 23 | 23 | ||
| 24 | int ivtv_streams_setup(struct ivtv *itv); | 24 | int ivtv_streams_setup(struct ivtv *itv); |
| 25 | int ivtv_streams_register(struct ivtv *itv); | ||
| 25 | void ivtv_streams_cleanup(struct ivtv *itv); | 26 | void ivtv_streams_cleanup(struct ivtv *itv); |
| 26 | 27 | ||
| 27 | /* Capture related */ | 28 | /* Capture related */ |
diff --git a/drivers/media/video/ivtv/ivtv-udma.c b/drivers/media/video/ivtv/ivtv-udma.c index c4626d1cdf41..912b424e5204 100644 --- a/drivers/media/video/ivtv/ivtv-udma.c +++ b/drivers/media/video/ivtv/ivtv-udma.c | |||
| @@ -63,10 +63,10 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info | |||
| 63 | memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); | 63 | memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); |
| 64 | kunmap_atomic(src, KM_BOUNCE_READ); | 64 | kunmap_atomic(src, KM_BOUNCE_READ); |
| 65 | local_irq_restore(flags); | 65 | local_irq_restore(flags); |
| 66 | dma->SGlist[map_offset].page = dma->bouncemap[map_offset]; | 66 | sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset]); |
| 67 | } | 67 | } |
| 68 | else { | 68 | else { |
| 69 | dma->SGlist[map_offset].page = dma->map[map_offset]; | 69 | sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset]); |
| 70 | } | 70 | } |
| 71 | offset = 0; | 71 | offset = 0; |
| 72 | map_offset++; | 72 | map_offset++; |
diff --git a/drivers/media/video/ivtv/ivtv-yuv.c b/drivers/media/video/ivtv/ivtv-yuv.c index e2288f224ab6..9091c4837bbc 100644 --- a/drivers/media/video/ivtv/ivtv-yuv.c +++ b/drivers/media/video/ivtv/ivtv-yuv.c | |||
| @@ -710,7 +710,7 @@ static u32 ivtv_yuv_window_setup (struct ivtv *itv, struct yuv_frame_info *windo | |||
| 710 | 710 | ||
| 711 | /* If there's nothing to safe to display, we may as well stop now */ | 711 | /* If there's nothing to safe to display, we may as well stop now */ |
| 712 | if ((int)window->dst_w <= 2 || (int)window->dst_h <= 2 || (int)window->src_w <= 2 || (int)window->src_h <= 2) { | 712 | if ((int)window->dst_w <= 2 || (int)window->dst_h <= 2 || (int)window->src_w <= 2 || (int)window->src_h <= 2) { |
| 713 | return 0; | 713 | return IVTV_YUV_UPDATE_INVALID; |
| 714 | } | 714 | } |
| 715 | 715 | ||
| 716 | /* Ensure video remains inside OSD area */ | 716 | /* Ensure video remains inside OSD area */ |
| @@ -791,7 +791,7 @@ static u32 ivtv_yuv_window_setup (struct ivtv *itv, struct yuv_frame_info *windo | |||
| 791 | 791 | ||
| 792 | /* Check again. If there's nothing to safe to display, stop now */ | 792 | /* Check again. If there's nothing to safe to display, stop now */ |
| 793 | if ((int)window->dst_w <= 2 || (int)window->dst_h <= 2 || (int)window->src_w <= 2 || (int)window->src_h <= 2) { | 793 | if ((int)window->dst_w <= 2 || (int)window->dst_h <= 2 || (int)window->src_w <= 2 || (int)window->src_h <= 2) { |
| 794 | return 0; | 794 | return IVTV_YUV_UPDATE_INVALID; |
| 795 | } | 795 | } |
| 796 | 796 | ||
| 797 | /* Both x offset & width are linked, so they have to be done together */ | 797 | /* Both x offset & width are linked, so they have to be done together */ |
| @@ -840,110 +840,118 @@ void ivtv_yuv_work_handler (struct ivtv *itv) | |||
| 840 | if (!(yuv_update = ivtv_yuv_window_setup (itv, &window))) | 840 | if (!(yuv_update = ivtv_yuv_window_setup (itv, &window))) |
| 841 | return; | 841 | return; |
| 842 | 842 | ||
| 843 | /* Update horizontal settings */ | 843 | if (yuv_update & IVTV_YUV_UPDATE_INVALID) { |
| 844 | if (yuv_update & IVTV_YUV_UPDATE_HORIZONTAL) | 844 | write_reg(0x01008080, 0x2898); |
| 845 | ivtv_yuv_handle_horizontal(itv, &window); | 845 | } else if (yuv_update) { |
| 846 | write_reg(0x00108080, 0x2898); | ||
| 846 | 847 | ||
| 847 | if (yuv_update & IVTV_YUV_UPDATE_VERTICAL) | 848 | if (yuv_update & IVTV_YUV_UPDATE_HORIZONTAL) |
| 848 | ivtv_yuv_handle_vertical(itv, &window); | 849 | ivtv_yuv_handle_horizontal(itv, &window); |
| 850 | |||
| 851 | if (yuv_update & IVTV_YUV_UPDATE_VERTICAL) | ||
| 852 | ivtv_yuv_handle_vertical(itv, &window); | ||
| 853 | } | ||
| 849 | 854 | ||
| 850 | memcpy(&itv->yuv_info.old_frame_info, &window, sizeof (itv->yuv_info.old_frame_info)); | 855 | memcpy(&itv->yuv_info.old_frame_info, &window, sizeof (itv->yuv_info.old_frame_info)); |
| 851 | } | 856 | } |
| 852 | 857 | ||
| 853 | static void ivtv_yuv_init (struct ivtv *itv) | 858 | static void ivtv_yuv_init (struct ivtv *itv) |
| 854 | { | 859 | { |
| 860 | struct yuv_playback_info *yi = &itv->yuv_info; | ||
| 861 | |||
| 855 | IVTV_DEBUG_YUV("ivtv_yuv_init\n"); | 862 | IVTV_DEBUG_YUV("ivtv_yuv_init\n"); |
| 856 | 863 | ||
| 857 | /* Take a snapshot of the current register settings */ | 864 | /* Take a snapshot of the current register settings */ |
| 858 | itv->yuv_info.reg_2834 = read_reg(0x02834); | 865 | yi->reg_2834 = read_reg(0x02834); |
| 859 | itv->yuv_info.reg_2838 = read_reg(0x02838); | 866 | yi->reg_2838 = read_reg(0x02838); |
| 860 | itv->yuv_info.reg_283c = read_reg(0x0283c); | 867 | yi->reg_283c = read_reg(0x0283c); |
| 861 | itv->yuv_info.reg_2840 = read_reg(0x02840); | 868 | yi->reg_2840 = read_reg(0x02840); |
| 862 | itv->yuv_info.reg_2844 = read_reg(0x02844); | 869 | yi->reg_2844 = read_reg(0x02844); |
| 863 | itv->yuv_info.reg_2848 = read_reg(0x02848); | 870 | yi->reg_2848 = read_reg(0x02848); |
| 864 | itv->yuv_info.reg_2854 = read_reg(0x02854); | 871 | yi->reg_2854 = read_reg(0x02854); |
| 865 | itv->yuv_info.reg_285c = read_reg(0x0285c); | 872 | yi->reg_285c = read_reg(0x0285c); |
| 866 | itv->yuv_info.reg_2864 = read_reg(0x02864); | 873 | yi->reg_2864 = read_reg(0x02864); |
| 867 | itv->yuv_info.reg_2870 = read_reg(0x02870); | 874 | yi->reg_2870 = read_reg(0x02870); |
| 868 | itv->yuv_info.reg_2874 = read_reg(0x02874); | 875 | yi->reg_2874 = read_reg(0x02874); |
| 869 | itv->yuv_info.reg_2898 = read_reg(0x02898); | 876 | yi->reg_2898 = read_reg(0x02898); |
| 870 | itv->yuv_info.reg_2890 = read_reg(0x02890); | 877 | yi->reg_2890 = read_reg(0x02890); |
| 871 | 878 | ||
| 872 | itv->yuv_info.reg_289c = read_reg(0x0289c); | 879 | yi->reg_289c = read_reg(0x0289c); |
| 873 | itv->yuv_info.reg_2918 = read_reg(0x02918); | 880 | yi->reg_2918 = read_reg(0x02918); |
| 874 | itv->yuv_info.reg_291c = read_reg(0x0291c); | 881 | yi->reg_291c = read_reg(0x0291c); |
| 875 | itv->yuv_info.reg_2920 = read_reg(0x02920); | 882 | yi->reg_2920 = read_reg(0x02920); |
| 876 | itv->yuv_info.reg_2924 = read_reg(0x02924); | 883 | yi->reg_2924 = read_reg(0x02924); |
| 877 | itv->yuv_info.reg_2928 = read_reg(0x02928); | 884 | yi->reg_2928 = read_reg(0x02928); |
| 878 | itv->yuv_info.reg_292c = read_reg(0x0292c); | 885 | yi->reg_292c = read_reg(0x0292c); |
| 879 | itv->yuv_info.reg_2930 = read_reg(0x02930); | 886 | yi->reg_2930 = read_reg(0x02930); |
| 880 | itv->yuv_info.reg_2934 = read_reg(0x02934); | 887 | yi->reg_2934 = read_reg(0x02934); |
| 881 | itv->yuv_info.reg_2938 = read_reg(0x02938); | 888 | yi->reg_2938 = read_reg(0x02938); |
| 882 | itv->yuv_info.reg_293c = read_reg(0x0293c); | 889 | yi->reg_293c = read_reg(0x0293c); |
| 883 | itv->yuv_info.reg_2940 = read_reg(0x02940); | 890 | yi->reg_2940 = read_reg(0x02940); |
| 884 | itv->yuv_info.reg_2944 = read_reg(0x02944); | 891 | yi->reg_2944 = read_reg(0x02944); |
| 885 | itv->yuv_info.reg_2948 = read_reg(0x02948); | 892 | yi->reg_2948 = read_reg(0x02948); |
| 886 | itv->yuv_info.reg_294c = read_reg(0x0294c); | 893 | yi->reg_294c = read_reg(0x0294c); |
| 887 | itv->yuv_info.reg_2950 = read_reg(0x02950); | 894 | yi->reg_2950 = read_reg(0x02950); |
| 888 | itv->yuv_info.reg_2954 = read_reg(0x02954); | 895 | yi->reg_2954 = read_reg(0x02954); |
| 889 | itv->yuv_info.reg_2958 = read_reg(0x02958); | 896 | yi->reg_2958 = read_reg(0x02958); |
| 890 | itv->yuv_info.reg_295c = read_reg(0x0295c); | 897 | yi->reg_295c = read_reg(0x0295c); |
| 891 | itv->yuv_info.reg_2960 = read_reg(0x02960); | 898 | yi->reg_2960 = read_reg(0x02960); |
| 892 | itv->yuv_info.reg_2964 = read_reg(0x02964); | 899 | yi->reg_2964 = read_reg(0x02964); |
| 893 | itv->yuv_info.reg_2968 = read_reg(0x02968); | 900 | yi->reg_2968 = read_reg(0x02968); |
| 894 | itv->yuv_info.reg_296c = read_reg(0x0296c); | 901 | yi->reg_296c = read_reg(0x0296c); |
| 895 | itv->yuv_info.reg_2970 = read_reg(0x02970); | 902 | yi->reg_2970 = read_reg(0x02970); |
| 896 | 903 | ||
| 897 | itv->yuv_info.v_filter_1 = -1; | 904 | yi->v_filter_1 = -1; |
| 898 | itv->yuv_info.v_filter_2 = -1; | 905 | yi->v_filter_2 = -1; |
| 899 | itv->yuv_info.h_filter = -1; | 906 | yi->h_filter = -1; |
| 900 | 907 | ||
| 901 | /* Set some valid size info */ | 908 | /* Set some valid size info */ |
| 902 | itv->yuv_info.osd_x_offset = read_reg(0x02a04) & 0x00000FFF; | 909 | yi->osd_x_offset = read_reg(0x02a04) & 0x00000FFF; |
| 903 | itv->yuv_info.osd_y_offset = (read_reg(0x02a04) >> 16) & 0x00000FFF; | 910 | yi->osd_y_offset = (read_reg(0x02a04) >> 16) & 0x00000FFF; |
| 904 | 911 | ||
| 905 | /* Bit 2 of reg 2878 indicates current decoder output format | 912 | /* Bit 2 of reg 2878 indicates current decoder output format |
| 906 | 0 : NTSC 1 : PAL */ | 913 | 0 : NTSC 1 : PAL */ |
| 907 | if (read_reg(0x2878) & 4) | 914 | if (read_reg(0x2878) & 4) |
| 908 | itv->yuv_info.decode_height = 576; | 915 | yi->decode_height = 576; |
| 909 | else | 916 | else |
| 910 | itv->yuv_info.decode_height = 480; | 917 | yi->decode_height = 480; |
| 911 | 918 | ||
| 912 | /* If no visible size set, assume full size */ | 919 | if (!itv->osd_info) { |
| 913 | if (!itv->yuv_info.osd_vis_w) | 920 | yi->osd_vis_w = 720 - yi->osd_x_offset; |
| 914 | itv->yuv_info.osd_vis_w = 720 - itv->yuv_info.osd_x_offset; | 921 | yi->osd_vis_h = yi->decode_height - yi->osd_y_offset; |
| 915 | |||
| 916 | if (!itv->yuv_info.osd_vis_h) { | ||
| 917 | itv->yuv_info.osd_vis_h = itv->yuv_info.decode_height - itv->yuv_info.osd_y_offset; | ||
| 918 | } else { | 922 | } else { |
| 919 | /* If output video standard has changed, requested height may | 923 | /* If no visible size set, assume full size */ |
| 920 | not be legal */ | 924 | if (!yi->osd_vis_w) |
| 921 | if (itv->yuv_info.osd_vis_h + itv->yuv_info.osd_y_offset > itv->yuv_info.decode_height) { | 925 | yi->osd_vis_w = 720 - yi->osd_x_offset; |
| 922 | IVTV_DEBUG_WARN("Clipping yuv output - fb size (%d) exceeds video standard limit (%d)\n", | 926 | |
| 923 | itv->yuv_info.osd_vis_h + itv->yuv_info.osd_y_offset, | 927 | if (!yi->osd_vis_h) |
| 924 | itv->yuv_info.decode_height); | 928 | yi->osd_vis_h = yi->decode_height - yi->osd_y_offset; |
| 925 | itv->yuv_info.osd_vis_h = itv->yuv_info.decode_height - itv->yuv_info.osd_y_offset; | 929 | else { |
| 930 | /* If output video standard has changed, requested height may | ||
| 931 | not be legal */ | ||
| 932 | if (yi->osd_vis_h + yi->osd_y_offset > yi->decode_height) { | ||
| 933 | IVTV_DEBUG_WARN("Clipping yuv output - fb size (%d) exceeds video standard limit (%d)\n", | ||
| 934 | yi->osd_vis_h + yi->osd_y_offset, | ||
| 935 | yi->decode_height); | ||
| 936 | yi->osd_vis_h = yi->decode_height - yi->osd_y_offset; | ||
| 937 | } | ||
| 926 | } | 938 | } |
| 927 | } | 939 | } |
| 928 | 940 | ||
| 929 | /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */ | 941 | /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */ |
| 930 | itv->yuv_info.blanking_ptr = kzalloc(720*16,GFP_KERNEL); | 942 | yi->blanking_ptr = kzalloc(720*16, GFP_KERNEL); |
| 931 | if (itv->yuv_info.blanking_ptr) { | 943 | if (yi->blanking_ptr) |
| 932 | itv->yuv_info.blanking_dmaptr = pci_map_single(itv->dev, itv->yuv_info.blanking_ptr, 720*16, PCI_DMA_TODEVICE); | 944 | yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE); |
| 933 | } | ||
| 934 | else { | 945 | else { |
| 935 | itv->yuv_info.blanking_dmaptr = 0; | 946 | yi->blanking_dmaptr = 0; |
| 936 | IVTV_DEBUG_WARN ("Failed to allocate yuv blanking buffer\n"); | 947 | IVTV_DEBUG_WARN("Failed to allocate yuv blanking buffer\n"); |
| 937 | } | 948 | } |
| 938 | 949 | ||
| 939 | IVTV_DEBUG_WARN("Enable video output\n"); | ||
| 940 | write_reg_sync(0x00108080, 0x2898); | ||
| 941 | |||
| 942 | /* Enable YUV decoder output */ | 950 | /* Enable YUV decoder output */ |
| 943 | write_reg_sync(0x01, IVTV_REG_VDM); | 951 | write_reg_sync(0x01, IVTV_REG_VDM); |
| 944 | 952 | ||
| 945 | set_bit(IVTV_F_I_DECODING_YUV, &itv->i_flags); | 953 | set_bit(IVTV_F_I_DECODING_YUV, &itv->i_flags); |
| 946 | atomic_set(&itv->yuv_info.next_dma_frame,0); | 954 | atomic_set(&yi->next_dma_frame, 0); |
| 947 | } | 955 | } |
| 948 | 956 | ||
| 949 | int ivtv_yuv_prep_frame(struct ivtv *itv, struct ivtv_dma_frame *args) | 957 | int ivtv_yuv_prep_frame(struct ivtv *itv, struct ivtv_dma_frame *args) |
diff --git a/drivers/media/video/ivtv/ivtv-yuv.h b/drivers/media/video/ivtv/ivtv-yuv.h index f7215eeca018..3b966f0a204a 100644 --- a/drivers/media/video/ivtv/ivtv-yuv.h +++ b/drivers/media/video/ivtv/ivtv-yuv.h | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | 34 | ||
| 35 | #define IVTV_YUV_UPDATE_HORIZONTAL 0x01 | 35 | #define IVTV_YUV_UPDATE_HORIZONTAL 0x01 |
| 36 | #define IVTV_YUV_UPDATE_VERTICAL 0x02 | 36 | #define IVTV_YUV_UPDATE_VERTICAL 0x02 |
| 37 | #define IVTV_YUV_UPDATE_INVALID 0x04 | ||
| 37 | 38 | ||
| 38 | extern const u32 yuv_offset[4]; | 39 | extern const u32 yuv_offset[4]; |
| 39 | 40 | ||
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c index 9684048fe56c..52ffd154a3d8 100644 --- a/drivers/media/video/ivtv/ivtvfb.c +++ b/drivers/media/video/ivtv/ivtvfb.c | |||
| @@ -55,7 +55,6 @@ | |||
| 55 | static int ivtvfb_card_id = -1; | 55 | static int ivtvfb_card_id = -1; |
| 56 | static int ivtvfb_debug = 0; | 56 | static int ivtvfb_debug = 0; |
| 57 | static int osd_laced; | 57 | static int osd_laced; |
| 58 | static int osd_compat; | ||
| 59 | static int osd_depth; | 58 | static int osd_depth; |
| 60 | static int osd_upper; | 59 | static int osd_upper; |
| 61 | static int osd_left; | 60 | static int osd_left; |
| @@ -65,7 +64,6 @@ static int osd_xres; | |||
| 65 | module_param(ivtvfb_card_id, int, 0444); | 64 | module_param(ivtvfb_card_id, int, 0444); |
| 66 | module_param_named(debug,ivtvfb_debug, int, 0644); | 65 | module_param_named(debug,ivtvfb_debug, int, 0644); |
| 67 | module_param(osd_laced, bool, 0444); | 66 | module_param(osd_laced, bool, 0444); |
| 68 | module_param(osd_compat, bool, 0444); | ||
| 69 | module_param(osd_depth, int, 0444); | 67 | module_param(osd_depth, int, 0444); |
| 70 | module_param(osd_upper, int, 0444); | 68 | module_param(osd_upper, int, 0444); |
| 71 | module_param(osd_left, int, 0444); | 69 | module_param(osd_left, int, 0444); |
| @@ -80,12 +78,6 @@ MODULE_PARM_DESC(debug, | |||
| 80 | "Debug level (bitmask). Default: errors only\n" | 78 | "Debug level (bitmask). Default: errors only\n" |
| 81 | "\t\t\t(debug = 3 gives full debugging)"); | 79 | "\t\t\t(debug = 3 gives full debugging)"); |
| 82 | 80 | ||
| 83 | MODULE_PARM_DESC(osd_compat, | ||
| 84 | "Compatibility mode - Display size is locked (use for old X drivers)\n" | ||
| 85 | "\t\t\t0=off\n" | ||
| 86 | "\t\t\t1=on\n" | ||
| 87 | "\t\t\tdefault off"); | ||
| 88 | |||
| 89 | /* Why upper, left, xres, yres, depth, laced ? To match terminology used | 81 | /* Why upper, left, xres, yres, depth, laced ? To match terminology used |
| 90 | by fbset. | 82 | by fbset. |
| 91 | Why start at 1 for left & upper coordinate ? Because X doesn't allow 0 */ | 83 | Why start at 1 for left & upper coordinate ? Because X doesn't allow 0 */ |
| @@ -166,9 +158,6 @@ struct osd_info { | |||
| 166 | unsigned long fb_end_aligned_physaddr; | 158 | unsigned long fb_end_aligned_physaddr; |
| 167 | #endif | 159 | #endif |
| 168 | 160 | ||
| 169 | /* Current osd mode */ | ||
| 170 | int osd_mode; | ||
| 171 | |||
| 172 | /* Store the buffer offset */ | 161 | /* Store the buffer offset */ |
| 173 | int set_osd_coords_x; | 162 | int set_osd_coords_x; |
| 174 | int set_osd_coords_y; | 163 | int set_osd_coords_y; |
| @@ -470,13 +459,11 @@ static int ivtvfb_set_var(struct ivtv *itv, struct fb_var_screeninfo *var) | |||
| 470 | IVTVFB_DEBUG_WARN("ivtvfb_set_var - Invalid bpp\n"); | 459 | IVTVFB_DEBUG_WARN("ivtvfb_set_var - Invalid bpp\n"); |
| 471 | } | 460 | } |
| 472 | 461 | ||
| 473 | /* Change osd mode if needed. | 462 | /* Set video mode. Although rare, the display can become scrambled even |
| 474 | Although rare, things can go wrong. The extra mode | 463 | if we don't change mode. Always 'bounce' to osd_mode via mode 0 */ |
| 475 | change seems to help... */ | 464 | if (osd_mode != -1) { |
| 476 | if (osd_mode != -1 && osd_mode != oi->osd_mode) { | ||
| 477 | ivtv_vapi(itv, CX2341X_OSD_SET_PIXEL_FORMAT, 1, 0); | 465 | ivtv_vapi(itv, CX2341X_OSD_SET_PIXEL_FORMAT, 1, 0); |
| 478 | ivtv_vapi(itv, CX2341X_OSD_SET_PIXEL_FORMAT, 1, osd_mode); | 466 | ivtv_vapi(itv, CX2341X_OSD_SET_PIXEL_FORMAT, 1, osd_mode); |
| 479 | oi->osd_mode = osd_mode; | ||
| 480 | } | 467 | } |
| 481 | 468 | ||
| 482 | oi->bits_per_pixel = var->bits_per_pixel; | 469 | oi->bits_per_pixel = var->bits_per_pixel; |
| @@ -579,14 +566,6 @@ static int _ivtvfb_check_var(struct fb_var_screeninfo *var, struct ivtv *itv) | |||
| 579 | osd_height_limit = 480; | 566 | osd_height_limit = 480; |
| 580 | } | 567 | } |
| 581 | 568 | ||
| 582 | /* Check the bits per pixel */ | ||
| 583 | if (osd_compat) { | ||
| 584 | if (var->bits_per_pixel != 32) { | ||
| 585 | IVTVFB_DEBUG_WARN("Invalid colour mode: %d\n", var->bits_per_pixel); | ||
| 586 | return -EINVAL; | ||
| 587 | } | ||
| 588 | } | ||
| 589 | |||
| 590 | if (var->bits_per_pixel == 8 || var->bits_per_pixel == 32) { | 569 | if (var->bits_per_pixel == 8 || var->bits_per_pixel == 32) { |
| 591 | var->transp.offset = 24; | 570 | var->transp.offset = 24; |
| 592 | var->transp.length = 8; | 571 | var->transp.length = 8; |
| @@ -638,32 +617,20 @@ static int _ivtvfb_check_var(struct fb_var_screeninfo *var, struct ivtv *itv) | |||
| 638 | } | 617 | } |
| 639 | 618 | ||
| 640 | /* Check the resolution */ | 619 | /* Check the resolution */ |
| 641 | if (osd_compat) { | 620 | if (var->xres > IVTV_OSD_MAX_WIDTH || var->yres > osd_height_limit) { |
| 642 | if (var->xres != oi->ivtvfb_defined.xres || | 621 | IVTVFB_DEBUG_WARN("Invalid resolution: %dx%d\n", |
| 643 | var->yres != oi->ivtvfb_defined.yres || | 622 | var->xres, var->yres); |
| 644 | var->xres_virtual != oi->ivtvfb_defined.xres_virtual || | 623 | return -EINVAL; |
| 645 | var->yres_virtual != oi->ivtvfb_defined.yres_virtual) { | ||
| 646 | IVTVFB_DEBUG_WARN("Invalid resolution: %dx%d (virtual %dx%d)\n", | ||
| 647 | var->xres, var->yres, var->xres_virtual, var->yres_virtual); | ||
| 648 | return -EINVAL; | ||
| 649 | } | ||
| 650 | } | 624 | } |
| 651 | else { | ||
| 652 | if (var->xres > IVTV_OSD_MAX_WIDTH || var->yres > osd_height_limit) { | ||
| 653 | IVTVFB_DEBUG_WARN("Invalid resolution: %dx%d\n", | ||
| 654 | var->xres, var->yres); | ||
| 655 | return -EINVAL; | ||
| 656 | } | ||
| 657 | 625 | ||
| 658 | /* Max horizontal size is 1023 @ 32bpp, 2046 & 16bpp, 4092 @ 8bpp */ | 626 | /* Max horizontal size is 1023 @ 32bpp, 2046 & 16bpp, 4092 @ 8bpp */ |
| 659 | if (var->xres_virtual > 4095 / (var->bits_per_pixel / 8) || | 627 | if (var->xres_virtual > 4095 / (var->bits_per_pixel / 8) || |
| 660 | var->xres_virtual * var->yres_virtual * (var->bits_per_pixel / 8) > oi->video_buffer_size || | 628 | var->xres_virtual * var->yres_virtual * (var->bits_per_pixel / 8) > oi->video_buffer_size || |
| 661 | var->xres_virtual < var->xres || | 629 | var->xres_virtual < var->xres || |
| 662 | var->yres_virtual < var->yres) { | 630 | var->yres_virtual < var->yres) { |
| 663 | IVTVFB_DEBUG_WARN("Invalid virtual resolution: %dx%d\n", | 631 | IVTVFB_DEBUG_WARN("Invalid virtual resolution: %dx%d\n", |
| 664 | var->xres_virtual, var->yres_virtual); | 632 | var->xres_virtual, var->yres_virtual); |
| 665 | return -EINVAL; | 633 | return -EINVAL; |
| 666 | } | ||
| 667 | } | 634 | } |
| 668 | 635 | ||
| 669 | /* Some extra checks if in 8 bit mode */ | 636 | /* Some extra checks if in 8 bit mode */ |
| @@ -877,17 +844,15 @@ static int ivtvfb_init_vidmode(struct ivtv *itv) | |||
| 877 | 844 | ||
| 878 | /* Color mode */ | 845 | /* Color mode */ |
| 879 | 846 | ||
| 880 | if (osd_compat) osd_depth = 32; | 847 | if (osd_depth != 8 && osd_depth != 16 && osd_depth != 32) |
| 881 | if (osd_depth != 8 && osd_depth != 16 && osd_depth != 32) osd_depth = 8; | 848 | osd_depth = 8; |
| 882 | oi->bits_per_pixel = osd_depth; | 849 | oi->bits_per_pixel = osd_depth; |
| 883 | oi->bytes_per_pixel = oi->bits_per_pixel / 8; | 850 | oi->bytes_per_pixel = oi->bits_per_pixel / 8; |
| 884 | 851 | ||
| 885 | /* Invalidate current osd mode to force a mode switch later */ | ||
| 886 | oi->osd_mode = -1; | ||
| 887 | |||
| 888 | /* Horizontal size & position */ | 852 | /* Horizontal size & position */ |
| 889 | 853 | ||
| 890 | if (osd_xres > 720) osd_xres = 720; | 854 | if (osd_xres > 720) |
| 855 | osd_xres = 720; | ||
| 891 | 856 | ||
| 892 | /* Must be a multiple of 4 for 8bpp & 2 for 16bpp */ | 857 | /* Must be a multiple of 4 for 8bpp & 2 for 16bpp */ |
| 893 | if (osd_depth == 8) | 858 | if (osd_depth == 8) |
| @@ -895,10 +860,7 @@ static int ivtvfb_init_vidmode(struct ivtv *itv) | |||
| 895 | else if (osd_depth == 16) | 860 | else if (osd_depth == 16) |
| 896 | osd_xres &= ~1; | 861 | osd_xres &= ~1; |
| 897 | 862 | ||
| 898 | if (osd_xres) | 863 | start_window.width = osd_xres ? osd_xres : 640; |
| 899 | start_window.width = osd_xres; | ||
| 900 | else | ||
| 901 | start_window.width = osd_compat ? 720: 640; | ||
| 902 | 864 | ||
| 903 | /* Check horizontal start (osd_left). */ | 865 | /* Check horizontal start (osd_left). */ |
| 904 | if (osd_left && osd_left + start_window.width > 721) { | 866 | if (osd_left && osd_left + start_window.width > 721) { |
| @@ -921,10 +883,7 @@ static int ivtvfb_init_vidmode(struct ivtv *itv) | |||
| 921 | if (osd_yres > max_height) | 883 | if (osd_yres > max_height) |
| 922 | osd_yres = max_height; | 884 | osd_yres = max_height; |
| 923 | 885 | ||
| 924 | if (osd_yres) | 886 | start_window.height = osd_yres ? osd_yres : itv->is_50hz ? 480 : 400; |
| 925 | start_window.height = osd_yres; | ||
| 926 | else | ||
| 927 | start_window.height = osd_compat ? max_height : (itv->is_50hz ? 480 : 400); | ||
| 928 | 887 | ||
| 929 | /* Check vertical start (osd_upper). */ | 888 | /* Check vertical start (osd_upper). */ |
| 930 | if (osd_upper + start_window.height > max_height + 1) { | 889 | if (osd_upper + start_window.height > max_height + 1) { |
| @@ -1127,10 +1086,6 @@ static int ivtvfb_init_card(struct ivtv *itv) | |||
| 1127 | /* Enable the osd */ | 1086 | /* Enable the osd */ |
| 1128 | ivtvfb_blank(FB_BLANK_UNBLANK, &itv->osd_info->ivtvfb_info); | 1087 | ivtvfb_blank(FB_BLANK_UNBLANK, &itv->osd_info->ivtvfb_info); |
| 1129 | 1088 | ||
| 1130 | /* Note if we're running in compatibility mode */ | ||
| 1131 | if (osd_compat) | ||
| 1132 | IVTVFB_INFO("Running in compatibility mode. Display resize & mode change disabled\n"); | ||
| 1133 | |||
| 1134 | /* Allocate DMA */ | 1089 | /* Allocate DMA */ |
| 1135 | ivtv_udma_alloc(itv); | 1090 | ivtv_udma_alloc(itv); |
| 1136 | return 0; | 1091 | return 0; |
| @@ -1177,9 +1132,12 @@ static void ivtvfb_cleanup(void) | |||
| 1177 | for (i = 0; i < ivtv_cards_active; i++) { | 1132 | for (i = 0; i < ivtv_cards_active; i++) { |
| 1178 | itv = ivtv_cards[i]; | 1133 | itv = ivtv_cards[i]; |
| 1179 | if (itv && (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) && itv->osd_info) { | 1134 | if (itv && (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) && itv->osd_info) { |
| 1135 | if (unregister_framebuffer(&itv->osd_info->ivtvfb_info)) { | ||
| 1136 | IVTVFB_WARN("Framebuffer %d is in use, cannot unload\n", i); | ||
| 1137 | return; | ||
| 1138 | } | ||
| 1180 | IVTVFB_DEBUG_INFO("Unregister framebuffer %d\n", i); | 1139 | IVTVFB_DEBUG_INFO("Unregister framebuffer %d\n", i); |
| 1181 | ivtvfb_blank(FB_BLANK_POWERDOWN, &itv->osd_info->ivtvfb_info); | 1140 | ivtvfb_blank(FB_BLANK_POWERDOWN, &itv->osd_info->ivtvfb_info); |
| 1182 | unregister_framebuffer(&itv->osd_info->ivtvfb_info); | ||
| 1183 | ivtvfb_release_buffers(itv); | 1141 | ivtvfb_release_buffers(itv); |
| 1184 | itv->osd_video_pbase = 0; | 1142 | itv->osd_video_pbase = 0; |
| 1185 | } | 1143 | } |
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c index 69283926a8dc..c31163290432 100644 --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c | |||
| @@ -1762,7 +1762,6 @@ static struct video_device meye_template = { | |||
| 1762 | .owner = THIS_MODULE, | 1762 | .owner = THIS_MODULE, |
| 1763 | .name = "meye", | 1763 | .name = "meye", |
| 1764 | .type = VID_TYPE_CAPTURE, | 1764 | .type = VID_TYPE_CAPTURE, |
| 1765 | .hardware = VID_HARDWARE_MEYE, | ||
| 1766 | .fops = &meye_fops, | 1765 | .fops = &meye_fops, |
| 1767 | .release = video_device_release, | 1766 | .release = video_device_release, |
| 1768 | .minor = -1, | 1767 | .minor = -1, |
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c index b8d4ac0d938e..d55d5800efb4 100644 --- a/drivers/media/video/ov511.c +++ b/drivers/media/video/ov511.c | |||
| @@ -4668,7 +4668,6 @@ static struct video_device vdev_template = { | |||
| 4668 | .owner = THIS_MODULE, | 4668 | .owner = THIS_MODULE, |
| 4669 | .name = "OV511 USB Camera", | 4669 | .name = "OV511 USB Camera", |
| 4670 | .type = VID_TYPE_CAPTURE, | 4670 | .type = VID_TYPE_CAPTURE, |
| 4671 | .hardware = VID_HARDWARE_OV511, | ||
| 4672 | .fops = &ov511_fops, | 4671 | .fops = &ov511_fops, |
| 4673 | .release = video_device_release, | 4672 | .release = video_device_release, |
| 4674 | .minor = -1, | 4673 | .minor = -1, |
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c index 0ef73d9d5848..ce4b2f9791ee 100644 --- a/drivers/media/video/planb.c +++ b/drivers/media/video/planb.c | |||
| @@ -2013,7 +2013,6 @@ static struct video_device planb_template= | |||
| 2013 | .owner = THIS_MODULE, | 2013 | .owner = THIS_MODULE, |
| 2014 | .name = PLANB_DEVICE_NAME, | 2014 | .name = PLANB_DEVICE_NAME, |
| 2015 | .type = VID_TYPE_OVERLAY, | 2015 | .type = VID_TYPE_OVERLAY, |
| 2016 | .hardware = VID_HARDWARE_PLANB, | ||
| 2017 | .open = planb_open, | 2016 | .open = planb_open, |
| 2018 | .close = planb_close, | 2017 | .close = planb_close, |
| 2019 | .read = planb_read, | 2018 | .read = planb_read, |
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c index b5a67f0dd19f..6820c2aabd30 100644 --- a/drivers/media/video/pms.c +++ b/drivers/media/video/pms.c | |||
| @@ -895,7 +895,6 @@ static struct video_device pms_template= | |||
| 895 | .owner = THIS_MODULE, | 895 | .owner = THIS_MODULE, |
| 896 | .name = "Mediavision PMS", | 896 | .name = "Mediavision PMS", |
| 897 | .type = VID_TYPE_CAPTURE, | 897 | .type = VID_TYPE_CAPTURE, |
| 898 | .hardware = VID_HARDWARE_PMS, | ||
| 899 | .fops = &pms_fops, | 898 | .fops = &pms_fops, |
| 900 | }; | 899 | }; |
| 901 | 900 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c index 20b614436d2c..205087a3e136 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c +++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c | |||
| @@ -209,6 +209,11 @@ static int pvr2_encoder_cmd(void *ctxt, | |||
| 209 | 209 | ||
| 210 | LOCK_TAKE(hdw->ctl_lock); do { | 210 | LOCK_TAKE(hdw->ctl_lock); do { |
| 211 | 211 | ||
| 212 | if (!hdw->flag_encoder_ok) { | ||
| 213 | ret = -EIO; | ||
| 214 | break; | ||
| 215 | } | ||
| 216 | |||
| 212 | retry_flag = 0; | 217 | retry_flag = 0; |
| 213 | try_count++; | 218 | try_count++; |
| 214 | ret = 0; | 219 | ret = 0; |
| @@ -273,6 +278,7 @@ static int pvr2_encoder_cmd(void *ctxt, | |||
| 273 | ret = -EBUSY; | 278 | ret = -EBUSY; |
| 274 | } | 279 | } |
| 275 | if (ret) { | 280 | if (ret) { |
| 281 | hdw->flag_encoder_ok = 0; | ||
| 276 | pvr2_trace( | 282 | pvr2_trace( |
| 277 | PVR2_TRACE_ERROR_LEGS, | 283 | PVR2_TRACE_ERROR_LEGS, |
| 278 | "Giving up on command." | 284 | "Giving up on command." |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h index 985d9ae7f5ee..f873994b088c 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | |||
| @@ -225,11 +225,12 @@ struct pvr2_hdw { | |||
| 225 | unsigned int cmd_debug_write_len; // | 225 | unsigned int cmd_debug_write_len; // |
| 226 | unsigned int cmd_debug_read_len; // | 226 | unsigned int cmd_debug_read_len; // |
| 227 | 227 | ||
| 228 | int flag_ok; // device in known good state | 228 | int flag_ok; /* device in known good state */ |
| 229 | int flag_disconnected; // flag_ok == 0 due to disconnect | 229 | int flag_disconnected; /* flag_ok == 0 due to disconnect */ |
| 230 | int flag_init_ok; // true if structure is fully initialized | 230 | int flag_init_ok; /* true if structure is fully initialized */ |
| 231 | int flag_streaming_enabled; // true if streaming should be on | 231 | int flag_streaming_enabled; /* true if streaming should be on */ |
| 232 | int fw1_state; // current situation with fw1 | 232 | int fw1_state; /* current situation with fw1 */ |
| 233 | int flag_encoder_ok; /* True if encoder is healthy */ | ||
| 233 | 234 | ||
| 234 | int flag_decoder_is_tuned; | 235 | int flag_decoder_is_tuned; |
| 235 | 236 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 27b12b4b5c88..402c59488253 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
| @@ -1248,6 +1248,8 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) | |||
| 1248 | time we configure the encoder, then we'll fully configure it. */ | 1248 | time we configure the encoder, then we'll fully configure it. */ |
| 1249 | hdw->enc_cur_valid = 0; | 1249 | hdw->enc_cur_valid = 0; |
| 1250 | 1250 | ||
| 1251 | hdw->flag_encoder_ok = 0; | ||
| 1252 | |||
| 1251 | /* First prepare firmware loading */ | 1253 | /* First prepare firmware loading */ |
| 1252 | ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/ | 1254 | ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/ |
| 1253 | ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000088); /*gpio dir*/ | 1255 | ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000088); /*gpio dir*/ |
| @@ -1346,6 +1348,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) | |||
| 1346 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 1348 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 1347 | "firmware2 upload post-proc failure"); | 1349 | "firmware2 upload post-proc failure"); |
| 1348 | } else { | 1350 | } else { |
| 1351 | hdw->flag_encoder_ok = !0; | ||
| 1349 | hdw->subsys_enabled_mask |= (1<<PVR2_SUBSYS_B_ENC_FIRMWARE); | 1352 | hdw->subsys_enabled_mask |= (1<<PVR2_SUBSYS_B_ENC_FIRMWARE); |
| 1350 | } | 1353 | } |
| 1351 | return ret; | 1354 | return ret; |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c index 4563b3df8a0d..7a596ea7cfe6 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c | |||
| @@ -1121,15 +1121,12 @@ static const struct file_operations vdev_fops = { | |||
| 1121 | }; | 1121 | }; |
| 1122 | 1122 | ||
| 1123 | 1123 | ||
| 1124 | #define VID_HARDWARE_PVRUSB2 38 /* FIXME : need a good value */ | ||
| 1125 | |||
| 1126 | static struct video_device vdev_template = { | 1124 | static struct video_device vdev_template = { |
| 1127 | .owner = THIS_MODULE, | 1125 | .owner = THIS_MODULE, |
| 1128 | .type = VID_TYPE_CAPTURE | VID_TYPE_TUNER, | 1126 | .type = VID_TYPE_CAPTURE | VID_TYPE_TUNER, |
| 1129 | .type2 = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE | 1127 | .type2 = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE |
| 1130 | | V4L2_CAP_TUNER | V4L2_CAP_AUDIO | 1128 | | V4L2_CAP_TUNER | V4L2_CAP_AUDIO |
| 1131 | | V4L2_CAP_READWRITE), | 1129 | | V4L2_CAP_READWRITE), |
| 1132 | .hardware = VID_HARDWARE_PVRUSB2, | ||
| 1133 | .fops = &vdev_fops, | 1130 | .fops = &vdev_fops, |
| 1134 | }; | 1131 | }; |
| 1135 | 1132 | ||
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index 950da2542148..7300ace8f44e 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
| @@ -166,7 +166,6 @@ static struct video_device pwc_template = { | |||
| 166 | .owner = THIS_MODULE, | 166 | .owner = THIS_MODULE, |
| 167 | .name = "Philips Webcam", /* Filled in later */ | 167 | .name = "Philips Webcam", /* Filled in later */ |
| 168 | .type = VID_TYPE_CAPTURE, | 168 | .type = VID_TYPE_CAPTURE, |
| 169 | .hardware = VID_HARDWARE_PWC, | ||
| 170 | .release = video_device_release, | 169 | .release = video_device_release, |
| 171 | .fops = &pwc_fops, | 170 | .fops = &pwc_fops, |
| 172 | .minor = -1, | 171 | .minor = -1, |
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 57f1f5d409e0..002e70a33a4f 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c | |||
| @@ -71,7 +71,6 @@ static const struct v4l2_format v4l2_format_table[] = | |||
| 71 | 71 | ||
| 72 | struct saa6752hs_state { | 72 | struct saa6752hs_state { |
| 73 | struct i2c_client client; | 73 | struct i2c_client client; |
| 74 | struct v4l2_mpeg_compression old_params; | ||
| 75 | struct saa6752hs_mpeg_params params; | 74 | struct saa6752hs_mpeg_params params; |
| 76 | enum saa6752hs_videoformat video_format; | 75 | enum saa6752hs_videoformat video_format; |
| 77 | v4l2_std_id standard; | 76 | v4l2_std_id standard; |
| @@ -161,35 +160,6 @@ static struct saa6752hs_mpeg_params param_defaults = | |||
| 161 | .au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K, | 160 | .au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K, |
| 162 | }; | 161 | }; |
| 163 | 162 | ||
| 164 | static struct v4l2_mpeg_compression old_param_defaults = | ||
| 165 | { | ||
| 166 | .st_type = V4L2_MPEG_TS_2, | ||
| 167 | .st_bitrate = { | ||
| 168 | .mode = V4L2_BITRATE_CBR, | ||
| 169 | .target = 7000, | ||
| 170 | }, | ||
| 171 | |||
| 172 | .ts_pid_pmt = 16, | ||
| 173 | .ts_pid_video = 260, | ||
| 174 | .ts_pid_audio = 256, | ||
| 175 | .ts_pid_pcr = 259, | ||
| 176 | |||
| 177 | .vi_type = V4L2_MPEG_VI_2, | ||
| 178 | .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3, | ||
| 179 | .vi_bitrate = { | ||
| 180 | .mode = V4L2_BITRATE_VBR, | ||
| 181 | .target = 4000, | ||
| 182 | .max = 6000, | ||
| 183 | }, | ||
| 184 | |||
| 185 | .au_type = V4L2_MPEG_AU_2_II, | ||
| 186 | .au_bitrate = { | ||
| 187 | .mode = V4L2_BITRATE_CBR, | ||
| 188 | .target = 256, | ||
| 189 | }, | ||
| 190 | |||
| 191 | }; | ||
| 192 | |||
| 193 | /* ---------------------------------------------------------------------- */ | 163 | /* ---------------------------------------------------------------------- */ |
| 194 | 164 | ||
| 195 | static int saa6752hs_chip_command(struct i2c_client* client, | 165 | static int saa6752hs_chip_command(struct i2c_client* client, |
| @@ -362,74 +332,6 @@ static void saa6752hs_set_subsampling(struct i2c_client* client, | |||
| 362 | } | 332 | } |
| 363 | 333 | ||
| 364 | 334 | ||
| 365 | static void saa6752hs_old_set_params(struct i2c_client* client, | ||
| 366 | struct v4l2_mpeg_compression* params) | ||
| 367 | { | ||
| 368 | struct saa6752hs_state *h = i2c_get_clientdata(client); | ||
| 369 | |||
| 370 | /* check PIDs */ | ||
| 371 | if (params->ts_pid_pmt <= MPEG_PID_MAX) { | ||
| 372 | h->old_params.ts_pid_pmt = params->ts_pid_pmt; | ||
| 373 | h->params.ts_pid_pmt = params->ts_pid_pmt; | ||
| 374 | } | ||
| 375 | if (params->ts_pid_pcr <= MPEG_PID_MAX) { | ||
| 376 | h->old_params.ts_pid_pcr = params->ts_pid_pcr; | ||
| 377 | h->params.ts_pid_pcr = params->ts_pid_pcr; | ||
| 378 | } | ||
| 379 | if (params->ts_pid_video <= MPEG_PID_MAX) { | ||
| 380 | h->old_params.ts_pid_video = params->ts_pid_video; | ||
| 381 | h->params.ts_pid_video = params->ts_pid_video; | ||
| 382 | } | ||
| 383 | if (params->ts_pid_audio <= MPEG_PID_MAX) { | ||
| 384 | h->old_params.ts_pid_audio = params->ts_pid_audio; | ||
| 385 | h->params.ts_pid_audio = params->ts_pid_audio; | ||
| 386 | } | ||
| 387 | |||
| 388 | /* check bitrate parameters */ | ||
| 389 | if ((params->vi_bitrate.mode == V4L2_BITRATE_CBR) || | ||
| 390 | (params->vi_bitrate.mode == V4L2_BITRATE_VBR)) { | ||
| 391 | h->old_params.vi_bitrate.mode = params->vi_bitrate.mode; | ||
| 392 | h->params.vi_bitrate_mode = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ? | ||
| 393 | V4L2_MPEG_VIDEO_BITRATE_MODE_VBR : V4L2_MPEG_VIDEO_BITRATE_MODE_CBR; | ||
| 394 | } | ||
| 395 | if (params->vi_bitrate.mode != V4L2_BITRATE_NONE) | ||
| 396 | h->old_params.st_bitrate.target = params->st_bitrate.target; | ||
| 397 | if (params->vi_bitrate.mode != V4L2_BITRATE_NONE) | ||
| 398 | h->old_params.vi_bitrate.target = params->vi_bitrate.target; | ||
| 399 | if (params->vi_bitrate.mode == V4L2_BITRATE_VBR) | ||
| 400 | h->old_params.vi_bitrate.max = params->vi_bitrate.max; | ||
| 401 | if (params->au_bitrate.mode != V4L2_BITRATE_NONE) | ||
| 402 | h->old_params.au_bitrate.target = params->au_bitrate.target; | ||
| 403 | |||
| 404 | /* aspect ratio */ | ||
| 405 | if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3 || | ||
| 406 | params->vi_aspect_ratio == V4L2_MPEG_ASPECT_16_9) { | ||
| 407 | h->old_params.vi_aspect_ratio = params->vi_aspect_ratio; | ||
| 408 | if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3) | ||
| 409 | h->params.vi_aspect = V4L2_MPEG_VIDEO_ASPECT_4x3; | ||
| 410 | else | ||
| 411 | h->params.vi_aspect = V4L2_MPEG_VIDEO_ASPECT_16x9; | ||
| 412 | } | ||
| 413 | |||
| 414 | /* range checks */ | ||
| 415 | if (h->old_params.st_bitrate.target > MPEG_TOTAL_TARGET_BITRATE_MAX) | ||
| 416 | h->old_params.st_bitrate.target = MPEG_TOTAL_TARGET_BITRATE_MAX; | ||
| 417 | if (h->old_params.vi_bitrate.target > MPEG_VIDEO_TARGET_BITRATE_MAX) | ||
| 418 | h->old_params.vi_bitrate.target = MPEG_VIDEO_TARGET_BITRATE_MAX; | ||
| 419 | if (h->old_params.vi_bitrate.max > MPEG_VIDEO_MAX_BITRATE_MAX) | ||
| 420 | h->old_params.vi_bitrate.max = MPEG_VIDEO_MAX_BITRATE_MAX; | ||
| 421 | h->params.vi_bitrate = params->vi_bitrate.target; | ||
| 422 | h->params.vi_bitrate_peak = params->vi_bitrate.max; | ||
| 423 | if (h->old_params.au_bitrate.target <= 256) { | ||
| 424 | h->old_params.au_bitrate.target = 256; | ||
| 425 | h->params.au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K; | ||
| 426 | } | ||
| 427 | else { | ||
| 428 | h->old_params.au_bitrate.target = 384; | ||
| 429 | h->params.au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_384K; | ||
| 430 | } | ||
| 431 | } | ||
| 432 | |||
| 433 | static int handle_ctrl(struct saa6752hs_mpeg_params *params, | 335 | static int handle_ctrl(struct saa6752hs_mpeg_params *params, |
| 434 | struct v4l2_ext_control *ctrl, unsigned int cmd) | 336 | struct v4l2_ext_control *ctrl, unsigned int cmd) |
| 435 | { | 337 | { |
| @@ -697,7 +599,6 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind) | |||
| 697 | return -ENOMEM; | 599 | return -ENOMEM; |
| 698 | h->client = client_template; | 600 | h->client = client_template; |
| 699 | h->params = param_defaults; | 601 | h->params = param_defaults; |
| 700 | h->old_params = old_param_defaults; | ||
| 701 | h->client.adapter = adap; | 602 | h->client.adapter = adap; |
| 702 | h->client.addr = addr; | 603 | h->client.addr = addr; |
| 703 | 604 | ||
| @@ -734,23 +635,11 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
| 734 | { | 635 | { |
| 735 | struct saa6752hs_state *h = i2c_get_clientdata(client); | 636 | struct saa6752hs_state *h = i2c_get_clientdata(client); |
| 736 | struct v4l2_ext_controls *ctrls = arg; | 637 | struct v4l2_ext_controls *ctrls = arg; |
| 737 | struct v4l2_mpeg_compression *old_params = arg; | ||
| 738 | struct saa6752hs_mpeg_params params; | 638 | struct saa6752hs_mpeg_params params; |
| 739 | int err = 0; | 639 | int err = 0; |
| 740 | int i; | 640 | int i; |
| 741 | 641 | ||
| 742 | switch (cmd) { | 642 | switch (cmd) { |
| 743 | case VIDIOC_S_MPEGCOMP: | ||
| 744 | if (NULL == old_params) { | ||
| 745 | /* apply settings and start encoder */ | ||
| 746 | saa6752hs_init(client); | ||
| 747 | break; | ||
| 748 | } | ||
| 749 | saa6752hs_old_set_params(client, old_params); | ||
| 750 | /* fall through */ | ||
| 751 | case VIDIOC_G_MPEGCOMP: | ||
| 752 | *old_params = h->old_params; | ||
| 753 | break; | ||
| 754 | case VIDIOC_S_EXT_CTRLS: | 643 | case VIDIOC_S_EXT_CTRLS: |
| 755 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 644 | if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) |
| 756 | return -EINVAL; | 645 | return -EINVAL; |
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 1a4a24471f20..a499eea379e6 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
| @@ -429,7 +429,7 @@ int saa7134_set_dmabits(struct saa7134_dev *dev) | |||
| 429 | 429 | ||
| 430 | assert_spin_locked(&dev->slock); | 430 | assert_spin_locked(&dev->slock); |
| 431 | 431 | ||
| 432 | if (dev->inresume) | 432 | if (dev->insuspend) |
| 433 | return 0; | 433 | return 0; |
| 434 | 434 | ||
| 435 | /* video capture -- dma 0 + video task A */ | 435 | /* video capture -- dma 0 + video task A */ |
| @@ -563,6 +563,9 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id) | |||
| 563 | unsigned long report,status; | 563 | unsigned long report,status; |
| 564 | int loop, handled = 0; | 564 | int loop, handled = 0; |
| 565 | 565 | ||
| 566 | if (dev->insuspend) | ||
| 567 | goto out; | ||
| 568 | |||
| 566 | for (loop = 0; loop < 10; loop++) { | 569 | for (loop = 0; loop < 10; loop++) { |
| 567 | report = saa_readl(SAA7134_IRQ_REPORT); | 570 | report = saa_readl(SAA7134_IRQ_REPORT); |
| 568 | status = saa_readl(SAA7134_IRQ_STATUS); | 571 | status = saa_readl(SAA7134_IRQ_STATUS); |
| @@ -1163,6 +1166,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) | |||
| 1163 | kfree(dev); | 1166 | kfree(dev); |
| 1164 | } | 1167 | } |
| 1165 | 1168 | ||
| 1169 | #ifdef CONFIG_PM | ||
| 1166 | static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) | 1170 | static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) |
| 1167 | { | 1171 | { |
| 1168 | 1172 | ||
| @@ -1176,6 +1180,19 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) | |||
| 1176 | saa_writel(SAA7134_IRQ2, 0); | 1180 | saa_writel(SAA7134_IRQ2, 0); |
| 1177 | saa_writel(SAA7134_MAIN_CTRL, 0); | 1181 | saa_writel(SAA7134_MAIN_CTRL, 0); |
| 1178 | 1182 | ||
| 1183 | synchronize_irq(pci_dev->irq); | ||
| 1184 | dev->insuspend = 1; | ||
| 1185 | |||
| 1186 | /* Disable timeout timers - if we have active buffers, we will | ||
| 1187 | fill them on resume*/ | ||
| 1188 | |||
| 1189 | del_timer(&dev->video_q.timeout); | ||
| 1190 | del_timer(&dev->vbi_q.timeout); | ||
| 1191 | del_timer(&dev->ts_q.timeout); | ||
| 1192 | |||
| 1193 | if (dev->remote) | ||
| 1194 | saa7134_ir_stop(dev); | ||
| 1195 | |||
| 1179 | pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); | 1196 | pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); |
| 1180 | pci_save_state(pci_dev); | 1197 | pci_save_state(pci_dev); |
| 1181 | 1198 | ||
| @@ -1194,24 +1211,27 @@ static int saa7134_resume(struct pci_dev *pci_dev) | |||
| 1194 | /* Do things that are done in saa7134_initdev , | 1211 | /* Do things that are done in saa7134_initdev , |
| 1195 | except of initializing memory structures.*/ | 1212 | except of initializing memory structures.*/ |
| 1196 | 1213 | ||
| 1197 | dev->inresume = 1; | ||
| 1198 | saa7134_board_init1(dev); | 1214 | saa7134_board_init1(dev); |
| 1199 | 1215 | ||
| 1216 | /* saa7134_hwinit1 */ | ||
| 1200 | if (saa7134_boards[dev->board].video_out) | 1217 | if (saa7134_boards[dev->board].video_out) |
| 1201 | saa7134_videoport_init(dev); | 1218 | saa7134_videoport_init(dev); |
| 1202 | |||
| 1203 | if (card_has_mpeg(dev)) | 1219 | if (card_has_mpeg(dev)) |
| 1204 | saa7134_ts_init_hw(dev); | 1220 | saa7134_ts_init_hw(dev); |
| 1205 | 1221 | if (dev->remote) | |
| 1222 | saa7134_ir_start(dev, dev->remote); | ||
| 1206 | saa7134_hw_enable1(dev); | 1223 | saa7134_hw_enable1(dev); |
| 1207 | saa7134_set_decoder(dev); | 1224 | |
| 1208 | saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); | 1225 | |
| 1209 | saa7134_board_init2(dev); | 1226 | saa7134_board_init2(dev); |
| 1210 | saa7134_hw_enable2(dev); | ||
| 1211 | 1227 | ||
| 1228 | /*saa7134_hwinit2*/ | ||
| 1229 | saa7134_set_tvnorm_hw(dev); | ||
| 1212 | saa7134_tvaudio_setmute(dev); | 1230 | saa7134_tvaudio_setmute(dev); |
| 1213 | saa7134_tvaudio_setvolume(dev, dev->ctl_volume); | 1231 | saa7134_tvaudio_setvolume(dev, dev->ctl_volume); |
| 1232 | saa7134_tvaudio_do_scan(dev); | ||
| 1214 | saa7134_enable_i2s(dev); | 1233 | saa7134_enable_i2s(dev); |
| 1234 | saa7134_hw_enable2(dev); | ||
| 1215 | 1235 | ||
| 1216 | /*resume unfinished buffer(s)*/ | 1236 | /*resume unfinished buffer(s)*/ |
| 1217 | spin_lock_irqsave(&dev->slock, flags); | 1237 | spin_lock_irqsave(&dev->slock, flags); |
| @@ -1219,13 +1239,19 @@ static int saa7134_resume(struct pci_dev *pci_dev) | |||
| 1219 | saa7134_buffer_requeue(dev, &dev->vbi_q); | 1239 | saa7134_buffer_requeue(dev, &dev->vbi_q); |
| 1220 | saa7134_buffer_requeue(dev, &dev->ts_q); | 1240 | saa7134_buffer_requeue(dev, &dev->ts_q); |
| 1221 | 1241 | ||
| 1242 | /* FIXME: Disable DMA audio sound - temporary till proper support | ||
| 1243 | is implemented*/ | ||
| 1244 | |||
| 1245 | dev->dmasound.dma_running = 0; | ||
| 1246 | |||
| 1222 | /* start DMA now*/ | 1247 | /* start DMA now*/ |
| 1223 | dev->inresume = 0; | 1248 | dev->insuspend = 0; |
| 1224 | saa7134_set_dmabits(dev); | 1249 | saa7134_set_dmabits(dev); |
| 1225 | spin_unlock_irqrestore(&dev->slock, flags); | 1250 | spin_unlock_irqrestore(&dev->slock, flags); |
| 1226 | 1251 | ||
| 1227 | return 0; | 1252 | return 0; |
| 1228 | } | 1253 | } |
| 1254 | #endif | ||
| 1229 | 1255 | ||
| 1230 | /* ----------------------------------------------------------- */ | 1256 | /* ----------------------------------------------------------- */ |
| 1231 | 1257 | ||
| @@ -1262,8 +1288,10 @@ static struct pci_driver saa7134_pci_driver = { | |||
| 1262 | .id_table = saa7134_pci_tbl, | 1288 | .id_table = saa7134_pci_tbl, |
| 1263 | .probe = saa7134_initdev, | 1289 | .probe = saa7134_initdev, |
| 1264 | .remove = __devexit_p(saa7134_finidev), | 1290 | .remove = __devexit_p(saa7134_finidev), |
| 1291 | #ifdef CONFIG_PM | ||
| 1265 | .suspend = saa7134_suspend, | 1292 | .suspend = saa7134_suspend, |
| 1266 | .resume = saa7134_resume | 1293 | .resume = saa7134_resume |
| 1294 | #endif | ||
| 1267 | }; | 1295 | }; |
| 1268 | 1296 | ||
| 1269 | static int saa7134_init(void) | 1297 | static int saa7134_init(void) |
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index 34ca874dd7fe..75d0c5bf46d2 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c | |||
| @@ -284,17 +284,6 @@ static int ts_do_ioctl(struct inode *inode, struct file *file, | |||
| 284 | case VIDIOC_S_CTRL: | 284 | case VIDIOC_S_CTRL: |
| 285 | return saa7134_common_ioctl(dev, cmd, arg); | 285 | return saa7134_common_ioctl(dev, cmd, arg); |
| 286 | 286 | ||
| 287 | case VIDIOC_S_MPEGCOMP: | ||
| 288 | printk(KERN_WARNING "VIDIOC_S_MPEGCOMP is obsolete. " | ||
| 289 | "Replace with VIDIOC_S_EXT_CTRLS!"); | ||
| 290 | saa7134_i2c_call_clients(dev, VIDIOC_S_MPEGCOMP, arg); | ||
| 291 | ts_init_encoder(dev); | ||
| 292 | return 0; | ||
| 293 | case VIDIOC_G_MPEGCOMP: | ||
| 294 | printk(KERN_WARNING "VIDIOC_G_MPEGCOMP is obsolete. " | ||
| 295 | "Replace with VIDIOC_G_EXT_CTRLS!"); | ||
| 296 | saa7134_i2c_call_clients(dev, VIDIOC_G_MPEGCOMP, arg); | ||
| 297 | return 0; | ||
| 298 | case VIDIOC_S_EXT_CTRLS: | 287 | case VIDIOC_S_EXT_CTRLS: |
| 299 | /* count == 0 is abused in saa6752hs.c, so that special | 288 | /* count == 0 is abused in saa6752hs.c, so that special |
| 300 | case is handled here explicitly. */ | 289 | case is handled here explicitly. */ |
| @@ -342,7 +331,6 @@ static struct video_device saa7134_empress_template = | |||
| 342 | .name = "saa7134-empress", | 331 | .name = "saa7134-empress", |
| 343 | .type = 0 /* FIXME */, | 332 | .type = 0 /* FIXME */, |
| 344 | .type2 = 0 /* FIXME */, | 333 | .type2 = 0 /* FIXME */, |
| 345 | .hardware = 0, | ||
| 346 | .fops = &ts_fops, | 334 | .fops = &ts_fops, |
| 347 | .minor = -1, | 335 | .minor = -1, |
| 348 | }; | 336 | }; |
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 80d2644f765a..3abaa1b8ac9d 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
| @@ -44,6 +44,14 @@ module_param(ir_rc5_remote_gap, int, 0644); | |||
| 44 | static int ir_rc5_key_timeout = 115; | 44 | static int ir_rc5_key_timeout = 115; |
| 45 | module_param(ir_rc5_key_timeout, int, 0644); | 45 | module_param(ir_rc5_key_timeout, int, 0644); |
| 46 | 46 | ||
| 47 | static int repeat_delay = 500; | ||
| 48 | module_param(repeat_delay, int, 0644); | ||
| 49 | MODULE_PARM_DESC(repeat_delay, "delay before key repeat started"); | ||
| 50 | static int repeat_period = 33; | ||
| 51 | module_param(repeat_period, int, 0644); | ||
| 52 | MODULE_PARM_DESC(repeat_period, "repeat period between" | ||
| 53 | "keypresses when key is down"); | ||
| 54 | |||
| 47 | #define dprintk(fmt, arg...) if (ir_debug) \ | 55 | #define dprintk(fmt, arg...) if (ir_debug) \ |
| 48 | printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) | 56 | printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) |
| 49 | #define i2cdprintk(fmt, arg...) if (ir_debug) \ | 57 | #define i2cdprintk(fmt, arg...) if (ir_debug) \ |
| @@ -59,6 +67,13 @@ static int build_key(struct saa7134_dev *dev) | |||
| 59 | struct card_ir *ir = dev->remote; | 67 | struct card_ir *ir = dev->remote; |
| 60 | u32 gpio, data; | 68 | u32 gpio, data; |
| 61 | 69 | ||
| 70 | /* here comes the additional handshake steps for some cards */ | ||
| 71 | switch (dev->board) { | ||
| 72 | case SAA7134_BOARD_GOTVIEW_7135: | ||
| 73 | saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80); | ||
| 74 | saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80); | ||
| 75 | break; | ||
| 76 | } | ||
| 62 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ | 77 | /* rising SAA7134_GPIO_GPRESCAN reads the status */ |
| 63 | saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); | 78 | saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); |
| 64 | saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); | 79 | saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); |
| @@ -159,7 +174,7 @@ static void saa7134_input_timer(unsigned long data) | |||
| 159 | mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); | 174 | mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); |
| 160 | } | 175 | } |
| 161 | 176 | ||
| 162 | static void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) | 177 | void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) |
| 163 | { | 178 | { |
| 164 | if (ir->polling) { | 179 | if (ir->polling) { |
| 165 | setup_timer(&ir->timer, saa7134_input_timer, | 180 | setup_timer(&ir->timer, saa7134_input_timer, |
| @@ -182,7 +197,7 @@ static void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) | |||
| 182 | } | 197 | } |
| 183 | } | 198 | } |
| 184 | 199 | ||
| 185 | static void saa7134_ir_stop(struct saa7134_dev *dev) | 200 | void saa7134_ir_stop(struct saa7134_dev *dev) |
| 186 | { | 201 | { |
| 187 | if (dev->remote->polling) | 202 | if (dev->remote->polling) |
| 188 | del_timer_sync(&dev->remote->timer); | 203 | del_timer_sync(&dev->remote->timer); |
| @@ -285,10 +300,10 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
| 285 | break; | 300 | break; |
| 286 | case SAA7134_BOARD_GOTVIEW_7135: | 301 | case SAA7134_BOARD_GOTVIEW_7135: |
| 287 | ir_codes = ir_codes_gotview7135; | 302 | ir_codes = ir_codes_gotview7135; |
| 288 | mask_keycode = 0x0003EC; | 303 | mask_keycode = 0x0003CC; |
| 289 | mask_keyup = 0x008000; | ||
| 290 | mask_keydown = 0x000010; | 304 | mask_keydown = 0x000010; |
| 291 | polling = 50; // ms | 305 | polling = 5; /* ms */ |
| 306 | saa_setb(SAA7134_GPIO_GPMODE1, 0x80); | ||
| 292 | break; | 307 | break; |
| 293 | case SAA7134_BOARD_VIDEOMATE_TV_PVR: | 308 | case SAA7134_BOARD_VIDEOMATE_TV_PVR: |
| 294 | case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: | 309 | case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: |
| @@ -386,6 +401,10 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
| 386 | if (err) | 401 | if (err) |
| 387 | goto err_out_stop; | 402 | goto err_out_stop; |
| 388 | 403 | ||
| 404 | /* the remote isn't as bouncy as a keyboard */ | ||
| 405 | ir->dev->rep[REP_DELAY] = repeat_delay; | ||
| 406 | ir->dev->rep[REP_PERIOD] = repeat_period; | ||
| 407 | |||
| 389 | return 0; | 408 | return 0; |
| 390 | 409 | ||
| 391 | err_out_stop: | 410 | err_out_stop: |
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index 1b9e39a5ea47..f8e304c76232 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/kthread.h> | 27 | #include <linux/kthread.h> |
| 28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
| 30 | #include <linux/freezer.h> | ||
| 30 | #include <asm/div64.h> | 31 | #include <asm/div64.h> |
| 31 | 32 | ||
| 32 | #include "saa7134-reg.h" | 33 | #include "saa7134-reg.h" |
| @@ -231,7 +232,7 @@ static void mute_input_7134(struct saa7134_dev *dev) | |||
| 231 | } | 232 | } |
| 232 | 233 | ||
| 233 | if (dev->hw_mute == mute && | 234 | if (dev->hw_mute == mute && |
| 234 | dev->hw_input == in && !dev->inresume) { | 235 | dev->hw_input == in && !dev->insuspend) { |
| 235 | dprintk("mute/input: nothing to do [mute=%d,input=%s]\n", | 236 | dprintk("mute/input: nothing to do [mute=%d,input=%s]\n", |
| 236 | mute,in->name); | 237 | mute,in->name); |
| 237 | return; | 238 | return; |
| @@ -502,13 +503,17 @@ static int tvaudio_thread(void *data) | |||
| 502 | unsigned int i, audio, nscan; | 503 | unsigned int i, audio, nscan; |
| 503 | int max1,max2,carrier,rx,mode,lastmode,default_carrier; | 504 | int max1,max2,carrier,rx,mode,lastmode,default_carrier; |
| 504 | 505 | ||
| 505 | allow_signal(SIGTERM); | 506 | |
| 507 | set_freezable(); | ||
| 508 | |||
| 506 | for (;;) { | 509 | for (;;) { |
| 507 | tvaudio_sleep(dev,-1); | 510 | tvaudio_sleep(dev,-1); |
| 508 | if (kthread_should_stop() || signal_pending(current)) | 511 | if (kthread_should_stop()) |
| 509 | goto done; | 512 | goto done; |
| 510 | 513 | ||
| 511 | restart: | 514 | restart: |
| 515 | try_to_freeze(); | ||
| 516 | |||
| 512 | dev->thread.scan1 = dev->thread.scan2; | 517 | dev->thread.scan1 = dev->thread.scan2; |
| 513 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); | 518 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); |
| 514 | dev->tvaudio = NULL; | 519 | dev->tvaudio = NULL; |
| @@ -612,9 +617,12 @@ static int tvaudio_thread(void *data) | |||
| 612 | 617 | ||
| 613 | lastmode = 42; | 618 | lastmode = 42; |
| 614 | for (;;) { | 619 | for (;;) { |
| 620 | |||
| 621 | try_to_freeze(); | ||
| 622 | |||
| 615 | if (tvaudio_sleep(dev,5000)) | 623 | if (tvaudio_sleep(dev,5000)) |
| 616 | goto restart; | 624 | goto restart; |
| 617 | if (kthread_should_stop() || signal_pending(current)) | 625 | if (kthread_should_stop()) |
| 618 | break; | 626 | break; |
| 619 | if (UNSET == dev->thread.mode) { | 627 | if (UNSET == dev->thread.mode) { |
| 620 | rx = tvaudio_getstereo(dev,&tvaudio[i]); | 628 | rx = tvaudio_getstereo(dev,&tvaudio[i]); |
| @@ -630,6 +638,7 @@ static int tvaudio_thread(void *data) | |||
| 630 | } | 638 | } |
| 631 | 639 | ||
| 632 | done: | 640 | done: |
| 641 | dev->thread.stopped = 1; | ||
| 633 | return 0; | 642 | return 0; |
| 634 | } | 643 | } |
| 635 | 644 | ||
| @@ -777,7 +786,8 @@ static int tvaudio_thread_ddep(void *data) | |||
| 777 | struct saa7134_dev *dev = data; | 786 | struct saa7134_dev *dev = data; |
| 778 | u32 value, norms, clock; | 787 | u32 value, norms, clock; |
| 779 | 788 | ||
| 780 | allow_signal(SIGTERM); | 789 | |
| 790 | set_freezable(); | ||
| 781 | 791 | ||
| 782 | clock = saa7134_boards[dev->board].audio_clock; | 792 | clock = saa7134_boards[dev->board].audio_clock; |
| 783 | if (UNSET != audio_clock_override) | 793 | if (UNSET != audio_clock_override) |
| @@ -790,10 +800,13 @@ static int tvaudio_thread_ddep(void *data) | |||
| 790 | 800 | ||
| 791 | for (;;) { | 801 | for (;;) { |
| 792 | tvaudio_sleep(dev,-1); | 802 | tvaudio_sleep(dev,-1); |
| 793 | if (kthread_should_stop() || signal_pending(current)) | 803 | if (kthread_should_stop()) |
| 794 | goto done; | 804 | goto done; |
| 795 | 805 | ||
| 796 | restart: | 806 | restart: |
| 807 | |||
| 808 | try_to_freeze(); | ||
| 809 | |||
| 797 | dev->thread.scan1 = dev->thread.scan2; | 810 | dev->thread.scan1 = dev->thread.scan2; |
| 798 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); | 811 | dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); |
| 799 | 812 | ||
| @@ -870,6 +883,7 @@ static int tvaudio_thread_ddep(void *data) | |||
| 870 | } | 883 | } |
| 871 | 884 | ||
| 872 | done: | 885 | done: |
| 886 | dev->thread.stopped = 1; | ||
| 873 | return 0; | 887 | return 0; |
| 874 | } | 888 | } |
| 875 | 889 | ||
| @@ -997,7 +1011,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) | |||
| 997 | int saa7134_tvaudio_fini(struct saa7134_dev *dev) | 1011 | int saa7134_tvaudio_fini(struct saa7134_dev *dev) |
| 998 | { | 1012 | { |
| 999 | /* shutdown tvaudio thread */ | 1013 | /* shutdown tvaudio thread */ |
| 1000 | if (dev->thread.thread) | 1014 | if (dev->thread.thread && !dev->thread.stopped) |
| 1001 | kthread_stop(dev->thread.thread); | 1015 | kthread_stop(dev->thread.thread); |
| 1002 | 1016 | ||
| 1003 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ | 1017 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ |
| @@ -1013,7 +1027,9 @@ int saa7134_tvaudio_do_scan(struct saa7134_dev *dev) | |||
| 1013 | } else if (dev->thread.thread) { | 1027 | } else if (dev->thread.thread) { |
| 1014 | dev->thread.mode = UNSET; | 1028 | dev->thread.mode = UNSET; |
| 1015 | dev->thread.scan2++; | 1029 | dev->thread.scan2++; |
| 1016 | wake_up_process(dev->thread.thread); | 1030 | |
| 1031 | if (!dev->insuspend && !dev->thread.stopped) | ||
| 1032 | wake_up_process(dev->thread.thread); | ||
| 1017 | } else { | 1033 | } else { |
| 1018 | dev->automute = 0; | 1034 | dev->automute = 0; |
| 1019 | saa7134_tvaudio_setmute(dev); | 1035 | saa7134_tvaudio_setmute(dev); |
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 471b92793c12..3b9ffb4b648a 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
| @@ -560,15 +560,8 @@ void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm) | |||
| 560 | 560 | ||
| 561 | dev->crop_current = dev->crop_defrect; | 561 | dev->crop_current = dev->crop_defrect; |
| 562 | 562 | ||
| 563 | saa7134_set_decoder(dev); | 563 | saa7134_set_tvnorm_hw(dev); |
| 564 | 564 | ||
| 565 | if (card_in(dev, dev->ctl_input).tv) { | ||
| 566 | if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290) | ||
| 567 | && ((card(dev).tuner_config == 1) | ||
| 568 | || (card(dev).tuner_config == 2))) | ||
| 569 | saa7134_set_gpio(dev, 22, 5); | ||
| 570 | saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &norm->id); | ||
| 571 | } | ||
| 572 | } | 565 | } |
| 573 | 566 | ||
| 574 | static void video_mux(struct saa7134_dev *dev, int input) | 567 | static void video_mux(struct saa7134_dev *dev, int input) |
| @@ -579,7 +572,8 @@ static void video_mux(struct saa7134_dev *dev, int input) | |||
| 579 | saa7134_tvaudio_setinput(dev, &card_in(dev, input)); | 572 | saa7134_tvaudio_setinput(dev, &card_in(dev, input)); |
| 580 | } | 573 | } |
| 581 | 574 | ||
| 582 | void saa7134_set_decoder(struct saa7134_dev *dev) | 575 | |
| 576 | static void saa7134_set_decoder(struct saa7134_dev *dev) | ||
| 583 | { | 577 | { |
| 584 | int luma_control, sync_control, mux; | 578 | int luma_control, sync_control, mux; |
| 585 | 579 | ||
| @@ -630,6 +624,19 @@ void saa7134_set_decoder(struct saa7134_dev *dev) | |||
| 630 | saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80); | 624 | saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80); |
| 631 | } | 625 | } |
| 632 | 626 | ||
| 627 | void saa7134_set_tvnorm_hw(struct saa7134_dev *dev) | ||
| 628 | { | ||
| 629 | saa7134_set_decoder(dev); | ||
| 630 | |||
| 631 | if (card_in(dev, dev->ctl_input).tv) { | ||
| 632 | if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290) | ||
| 633 | && ((card(dev).tuner_config == 1) | ||
| 634 | || (card(dev).tuner_config == 2))) | ||
| 635 | saa7134_set_gpio(dev, 22, 5); | ||
| 636 | saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); | ||
| 637 | } | ||
| 638 | } | ||
| 639 | |||
| 633 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) | 640 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) |
| 634 | { | 641 | { |
| 635 | static const struct { | 642 | static const struct { |
| @@ -2352,7 +2359,6 @@ struct video_device saa7134_video_template = | |||
| 2352 | .name = "saa7134-video", | 2359 | .name = "saa7134-video", |
| 2353 | .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER| | 2360 | .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER| |
| 2354 | VID_TYPE_CLIPPING|VID_TYPE_SCALES, | 2361 | VID_TYPE_CLIPPING|VID_TYPE_SCALES, |
| 2355 | .hardware = 0, | ||
| 2356 | .fops = &video_fops, | 2362 | .fops = &video_fops, |
| 2357 | .minor = -1, | 2363 | .minor = -1, |
| 2358 | }; | 2364 | }; |
| @@ -2361,7 +2367,6 @@ struct video_device saa7134_vbi_template = | |||
| 2361 | { | 2367 | { |
| 2362 | .name = "saa7134-vbi", | 2368 | .name = "saa7134-vbi", |
| 2363 | .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT, | 2369 | .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT, |
| 2364 | .hardware = 0, | ||
| 2365 | .fops = &video_fops, | 2370 | .fops = &video_fops, |
| 2366 | .minor = -1, | 2371 | .minor = -1, |
| 2367 | }; | 2372 | }; |
| @@ -2370,7 +2375,6 @@ struct video_device saa7134_radio_template = | |||
| 2370 | { | 2375 | { |
| 2371 | .name = "saa7134-radio", | 2376 | .name = "saa7134-radio", |
| 2372 | .type = VID_TYPE_TUNER, | 2377 | .type = VID_TYPE_TUNER, |
| 2373 | .hardware = 0, | ||
| 2374 | .fops = &radio_fops, | 2378 | .fops = &radio_fops, |
| 2375 | .minor = -1, | 2379 | .minor = -1, |
| 2376 | }; | 2380 | }; |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 28ec6804bd5d..66a390c321a7 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
| @@ -333,6 +333,7 @@ struct saa7134_thread { | |||
| 333 | unsigned int scan1; | 333 | unsigned int scan1; |
| 334 | unsigned int scan2; | 334 | unsigned int scan2; |
| 335 | unsigned int mode; | 335 | unsigned int mode; |
| 336 | unsigned int stopped; | ||
| 336 | }; | 337 | }; |
| 337 | 338 | ||
| 338 | /* buffer for one video/vbi/ts frame */ | 339 | /* buffer for one video/vbi/ts frame */ |
| @@ -524,7 +525,7 @@ struct saa7134_dev { | |||
| 524 | unsigned int hw_mute; | 525 | unsigned int hw_mute; |
| 525 | int last_carrier; | 526 | int last_carrier; |
| 526 | int nosignal; | 527 | int nosignal; |
| 527 | unsigned int inresume; | 528 | unsigned int insuspend; |
| 528 | 529 | ||
| 529 | /* SAA7134_MPEG_* */ | 530 | /* SAA7134_MPEG_* */ |
| 530 | struct saa7134_ts ts; | 531 | struct saa7134_ts ts; |
| @@ -632,7 +633,7 @@ extern struct video_device saa7134_radio_template; | |||
| 632 | 633 | ||
| 633 | void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm); | 634 | void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm); |
| 634 | int saa7134_videoport_init(struct saa7134_dev *dev); | 635 | int saa7134_videoport_init(struct saa7134_dev *dev); |
| 635 | void saa7134_set_decoder(struct saa7134_dev *dev); | 636 | void saa7134_set_tvnorm_hw(struct saa7134_dev *dev); |
| 636 | 637 | ||
| 637 | int saa7134_common_ioctl(struct saa7134_dev *dev, | 638 | int saa7134_common_ioctl(struct saa7134_dev *dev, |
| 638 | unsigned int cmd, void *arg); | 639 | unsigned int cmd, void *arg); |
| @@ -706,6 +707,8 @@ int saa7134_input_init1(struct saa7134_dev *dev); | |||
| 706 | void saa7134_input_fini(struct saa7134_dev *dev); | 707 | void saa7134_input_fini(struct saa7134_dev *dev); |
| 707 | void saa7134_input_irq(struct saa7134_dev *dev); | 708 | void saa7134_input_irq(struct saa7134_dev *dev); |
| 708 | void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir); | 709 | void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir); |
| 710 | void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir); | ||
| 711 | void saa7134_ir_stop(struct saa7134_dev *dev); | ||
| 709 | 712 | ||
| 710 | 713 | ||
| 711 | /* | 714 | /* |
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c index 93fb04ed99a0..d5d7d6cf734a 100644 --- a/drivers/media/video/se401.c +++ b/drivers/media/video/se401.c | |||
| @@ -1231,7 +1231,6 @@ static struct video_device se401_template = { | |||
| 1231 | .owner = THIS_MODULE, | 1231 | .owner = THIS_MODULE, |
| 1232 | .name = "se401 USB camera", | 1232 | .name = "se401 USB camera", |
| 1233 | .type = VID_TYPE_CAPTURE, | 1233 | .type = VID_TYPE_CAPTURE, |
| 1234 | .hardware = VID_HARDWARE_SE401, | ||
| 1235 | .fops = &se401_fops, | 1234 | .fops = &se401_fops, |
| 1236 | }; | 1235 | }; |
| 1237 | 1236 | ||
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index 6991e06f7651..511847912c48 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c | |||
| @@ -3319,7 +3319,6 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
| 3319 | strcpy(cam->v4ldev->name, "SN9C1xx PC Camera"); | 3319 | strcpy(cam->v4ldev->name, "SN9C1xx PC Camera"); |
| 3320 | cam->v4ldev->owner = THIS_MODULE; | 3320 | cam->v4ldev->owner = THIS_MODULE; |
| 3321 | cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; | 3321 | cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; |
| 3322 | cam->v4ldev->hardware = 0; | ||
| 3323 | cam->v4ldev->fops = &sn9c102_fops; | 3322 | cam->v4ldev->fops = &sn9c102_fops; |
| 3324 | cam->v4ldev->minor = video_nr[dev_nr]; | 3323 | cam->v4ldev->minor = video_nr[dev_nr]; |
| 3325 | cam->v4ldev->release = video_device_release; | 3324 | cam->v4ldev->release = video_device_release; |
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c index eb220461ac77..3fb85af5d1f2 100644 --- a/drivers/media/video/stradis.c +++ b/drivers/media/video/stradis.c | |||
| @@ -1917,7 +1917,6 @@ static const struct file_operations saa_fops = { | |||
| 1917 | static struct video_device saa_template = { | 1917 | static struct video_device saa_template = { |
| 1918 | .name = "SAA7146A", | 1918 | .name = "SAA7146A", |
| 1919 | .type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY, | 1919 | .type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY, |
| 1920 | .hardware = VID_HARDWARE_SAA7146, | ||
| 1921 | .fops = &saa_fops, | 1920 | .fops = &saa_fops, |
| 1922 | .minor = -1, | 1921 | .minor = -1, |
| 1923 | }; | 1922 | }; |
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c index 9e009a7ab863..afc32aa56fde 100644 --- a/drivers/media/video/stv680.c +++ b/drivers/media/video/stv680.c | |||
| @@ -1398,7 +1398,6 @@ static struct video_device stv680_template = { | |||
| 1398 | .owner = THIS_MODULE, | 1398 | .owner = THIS_MODULE, |
| 1399 | .name = "STV0680 USB camera", | 1399 | .name = "STV0680 USB camera", |
| 1400 | .type = VID_TYPE_CAPTURE, | 1400 | .type = VID_TYPE_CAPTURE, |
| 1401 | .hardware = VID_HARDWARE_SE401, | ||
| 1402 | .fops = &stv680_fops, | 1401 | .fops = &stv680_fops, |
| 1403 | .release = video_device_release, | 1402 | .release = video_device_release, |
| 1404 | .minor = -1, | 1403 | .minor = -1, |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 94843086cda9..6a777604f070 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
| @@ -113,7 +113,7 @@ static void fe_standby(struct tuner *t) | |||
| 113 | static int fe_has_signal(struct tuner *t) | 113 | static int fe_has_signal(struct tuner *t) |
| 114 | { | 114 | { |
| 115 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; | 115 | struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; |
| 116 | u16 strength; | 116 | u16 strength = 0; |
| 117 | 117 | ||
| 118 | if (fe_tuner_ops->get_rf_strength) | 118 | if (fe_tuner_ops->get_rf_strength) |
| 119 | fe_tuner_ops->get_rf_strength(&t->fe, &strength); | 119 | fe_tuner_ops->get_rf_strength(&t->fe, &strength); |
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c index 37ce36b9e587..fb434b5602a3 100644 --- a/drivers/media/video/usbvideo/usbvideo.c +++ b/drivers/media/video/usbvideo/usbvideo.c | |||
| @@ -952,7 +952,6 @@ static const struct file_operations usbvideo_fops = { | |||
| 952 | static const struct video_device usbvideo_template = { | 952 | static const struct video_device usbvideo_template = { |
| 953 | .owner = THIS_MODULE, | 953 | .owner = THIS_MODULE, |
| 954 | .type = VID_TYPE_CAPTURE, | 954 | .type = VID_TYPE_CAPTURE, |
| 955 | .hardware = VID_HARDWARE_CPIA, | ||
| 956 | .fops = &usbvideo_fops, | 955 | .fops = &usbvideo_fops, |
| 957 | }; | 956 | }; |
| 958 | 957 | ||
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c index db3c9e3deb26..da1ba0211108 100644 --- a/drivers/media/video/usbvideo/vicam.c +++ b/drivers/media/video/usbvideo/vicam.c | |||
| @@ -1074,7 +1074,6 @@ static struct video_device vicam_template = { | |||
| 1074 | .owner = THIS_MODULE, | 1074 | .owner = THIS_MODULE, |
| 1075 | .name = "ViCam-based USB Camera", | 1075 | .name = "ViCam-based USB Camera", |
| 1076 | .type = VID_TYPE_CAPTURE, | 1076 | .type = VID_TYPE_CAPTURE, |
| 1077 | .hardware = VID_HARDWARE_VICAM, | ||
| 1078 | .fops = &vicam_fops, | 1077 | .fops = &vicam_fops, |
| 1079 | .minor = -1, | 1078 | .minor = -1, |
| 1080 | }; | 1079 | }; |
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index e2f3c01cfa13..36e689fa16c0 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
| @@ -1400,7 +1400,6 @@ static const struct file_operations usbvision_fops = { | |||
| 1400 | static struct video_device usbvision_video_template = { | 1400 | static struct video_device usbvision_video_template = { |
| 1401 | .owner = THIS_MODULE, | 1401 | .owner = THIS_MODULE, |
| 1402 | .type = VID_TYPE_TUNER | VID_TYPE_CAPTURE, | 1402 | .type = VID_TYPE_TUNER | VID_TYPE_CAPTURE, |
| 1403 | .hardware = VID_HARDWARE_USBVISION, | ||
| 1404 | .fops = &usbvision_fops, | 1403 | .fops = &usbvision_fops, |
| 1405 | .name = "usbvision-video", | 1404 | .name = "usbvision-video", |
| 1406 | .release = video_device_release, | 1405 | .release = video_device_release, |
| @@ -1455,7 +1454,6 @@ static struct video_device usbvision_radio_template= | |||
| 1455 | { | 1454 | { |
| 1456 | .owner = THIS_MODULE, | 1455 | .owner = THIS_MODULE, |
| 1457 | .type = VID_TYPE_TUNER, | 1456 | .type = VID_TYPE_TUNER, |
| 1458 | .hardware = VID_HARDWARE_USBVISION, | ||
| 1459 | .fops = &usbvision_radio_fops, | 1457 | .fops = &usbvision_radio_fops, |
| 1460 | .name = "usbvision-radio", | 1458 | .name = "usbvision-radio", |
| 1461 | .release = video_device_release, | 1459 | .release = video_device_release, |
| @@ -1492,7 +1490,6 @@ static struct video_device usbvision_vbi_template= | |||
| 1492 | { | 1490 | { |
| 1493 | .owner = THIS_MODULE, | 1491 | .owner = THIS_MODULE, |
| 1494 | .type = VID_TYPE_TUNER, | 1492 | .type = VID_TYPE_TUNER, |
| 1495 | .hardware = VID_HARDWARE_USBVISION, | ||
| 1496 | .fops = &usbvision_vbi_fops, | 1493 | .fops = &usbvision_vbi_fops, |
| 1497 | .release = video_device_release, | 1494 | .release = video_device_release, |
| 1498 | .name = "usbvision-vbi", | 1495 | .name = "usbvision-vbi", |
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 321249240d05..1141b4bf41ce 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
| @@ -317,8 +317,6 @@ static const char *v4l2_ioctls[] = { | |||
| 317 | [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", | 317 | [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", |
| 318 | [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", | 318 | [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", |
| 319 | [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", | 319 | [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", |
| 320 | [_IOC_NR(VIDIOC_G_MPEGCOMP)] = "VIDIOC_G_MPEGCOMP", | ||
| 321 | [_IOC_NR(VIDIOC_S_MPEGCOMP)] = "VIDIOC_S_MPEGCOMP", | ||
| 322 | [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", | 320 | [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", |
| 323 | [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", | 321 | [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", |
| 324 | [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", | 322 | [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", |
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index 5599a36490fc..89a44f16f0ba 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c | |||
| @@ -967,6 +967,7 @@ int videobuf_cgmbuf(struct videobuf_queue *q, | |||
| 967 | 967 | ||
| 968 | return 0; | 968 | return 0; |
| 969 | } | 969 | } |
| 970 | EXPORT_SYMBOL_GPL(videobuf_cgmbuf); | ||
| 970 | #endif | 971 | #endif |
| 971 | 972 | ||
| 972 | /* --------------------------------------------------------------------- */ | 973 | /* --------------------------------------------------------------------- */ |
| @@ -985,7 +986,6 @@ EXPORT_SYMBOL_GPL(videobuf_reqbufs); | |||
| 985 | EXPORT_SYMBOL_GPL(videobuf_querybuf); | 986 | EXPORT_SYMBOL_GPL(videobuf_querybuf); |
| 986 | EXPORT_SYMBOL_GPL(videobuf_qbuf); | 987 | EXPORT_SYMBOL_GPL(videobuf_qbuf); |
| 987 | EXPORT_SYMBOL_GPL(videobuf_dqbuf); | 988 | EXPORT_SYMBOL_GPL(videobuf_dqbuf); |
| 988 | EXPORT_SYMBOL_GPL(videobuf_cgmbuf); | ||
| 989 | EXPORT_SYMBOL_GPL(videobuf_streamon); | 989 | EXPORT_SYMBOL_GPL(videobuf_streamon); |
| 990 | EXPORT_SYMBOL_GPL(videobuf_streamoff); | 990 | EXPORT_SYMBOL_GPL(videobuf_streamoff); |
| 991 | 991 | ||
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 3eb6123227b2..0a18286279d3 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
| @@ -60,12 +60,13 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages) | |||
| 60 | sglist = kcalloc(nr_pages, sizeof(struct scatterlist), GFP_KERNEL); | 60 | sglist = kcalloc(nr_pages, sizeof(struct scatterlist), GFP_KERNEL); |
| 61 | if (NULL == sglist) | 61 | if (NULL == sglist) |
| 62 | return NULL; | 62 | return NULL; |
| 63 | sg_init_table(sglist, nr_pages); | ||
| 63 | for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) { | 64 | for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) { |
| 64 | pg = vmalloc_to_page(virt); | 65 | pg = vmalloc_to_page(virt); |
| 65 | if (NULL == pg) | 66 | if (NULL == pg) |
| 66 | goto err; | 67 | goto err; |
| 67 | BUG_ON(PageHighMem(pg)); | 68 | BUG_ON(PageHighMem(pg)); |
| 68 | sglist[i].page = pg; | 69 | sg_set_page(&sglist[i], pg); |
| 69 | sglist[i].length = PAGE_SIZE; | 70 | sglist[i].length = PAGE_SIZE; |
| 70 | } | 71 | } |
| 71 | return sglist; | 72 | return sglist; |
| @@ -86,13 +87,14 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset) | |||
| 86 | sglist = kcalloc(nr_pages, sizeof(*sglist), GFP_KERNEL); | 87 | sglist = kcalloc(nr_pages, sizeof(*sglist), GFP_KERNEL); |
| 87 | if (NULL == sglist) | 88 | if (NULL == sglist) |
| 88 | return NULL; | 89 | return NULL; |
| 90 | sg_init_table(sglist, nr_pages); | ||
| 89 | 91 | ||
| 90 | if (NULL == pages[0]) | 92 | if (NULL == pages[0]) |
| 91 | goto nopage; | 93 | goto nopage; |
| 92 | if (PageHighMem(pages[0])) | 94 | if (PageHighMem(pages[0])) |
| 93 | /* DMA to highmem pages might not work */ | 95 | /* DMA to highmem pages might not work */ |
| 94 | goto highmem; | 96 | goto highmem; |
| 95 | sglist[0].page = pages[0]; | 97 | sg_set_page(&sglist[0], pages[0]); |
| 96 | sglist[0].offset = offset; | 98 | sglist[0].offset = offset; |
| 97 | sglist[0].length = PAGE_SIZE - offset; | 99 | sglist[0].length = PAGE_SIZE - offset; |
| 98 | for (i = 1; i < nr_pages; i++) { | 100 | for (i = 1; i < nr_pages; i++) { |
| @@ -100,7 +102,7 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset) | |||
| 100 | goto nopage; | 102 | goto nopage; |
| 101 | if (PageHighMem(pages[i])) | 103 | if (PageHighMem(pages[i])) |
| 102 | goto highmem; | 104 | goto highmem; |
| 103 | sglist[i].page = pages[i]; | 105 | sg_set_page(&sglist[i], pages[i]); |
| 104 | sglist[i].length = PAGE_SIZE; | 106 | sglist[i].length = PAGE_SIZE; |
| 105 | } | 107 | } |
| 106 | return sglist; | 108 | return sglist; |
diff --git a/drivers/media/video/videocodec.c b/drivers/media/video/videocodec.c index f2bbd7a4d562..87951ec8254f 100644 --- a/drivers/media/video/videocodec.c +++ b/drivers/media/video/videocodec.c | |||
| @@ -86,8 +86,8 @@ videocodec_attach (struct videocodec_master *master) | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | dprintk(2, | 88 | dprintk(2, |
| 89 | "videocodec_attach: '%s', type: %x, flags %lx, magic %lx\n", | 89 | "videocodec_attach: '%s', flags %lx, magic %lx\n", |
| 90 | master->name, master->type, master->flags, master->magic); | 90 | master->name, master->flags, master->magic); |
| 91 | 91 | ||
| 92 | if (!h) { | 92 | if (!h) { |
| 93 | dprintk(1, | 93 | dprintk(1, |
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 8d8e517b344f..9611c3990285 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
| @@ -1313,48 +1313,6 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
| 1313 | ret=vfd->vidioc_cropcap(file, fh, p); | 1313 | ret=vfd->vidioc_cropcap(file, fh, p); |
| 1314 | break; | 1314 | break; |
| 1315 | } | 1315 | } |
| 1316 | case VIDIOC_G_MPEGCOMP: | ||
| 1317 | { | ||
| 1318 | struct v4l2_mpeg_compression *p=arg; | ||
| 1319 | |||
| 1320 | /*FIXME: Several fields not shown */ | ||
| 1321 | if (!vfd->vidioc_g_mpegcomp) | ||
| 1322 | break; | ||
| 1323 | ret=vfd->vidioc_g_mpegcomp(file, fh, p); | ||
| 1324 | if (!ret) | ||
| 1325 | dbgarg (cmd, "ts_pid_pmt=%d, ts_pid_audio=%d," | ||
| 1326 | " ts_pid_video=%d, ts_pid_pcr=%d, " | ||
| 1327 | "ps_size=%d, au_sample_rate=%d, " | ||
| 1328 | "au_pesid=%c, vi_frame_rate=%d, " | ||
| 1329 | "vi_frames_per_gop=%d, " | ||
| 1330 | "vi_bframes_count=%d, vi_pesid=%c\n", | ||
| 1331 | p->ts_pid_pmt,p->ts_pid_audio, | ||
| 1332 | p->ts_pid_video,p->ts_pid_pcr, | ||
| 1333 | p->ps_size, p->au_sample_rate, | ||
| 1334 | p->au_pesid, p->vi_frame_rate, | ||
| 1335 | p->vi_frames_per_gop, | ||
| 1336 | p->vi_bframes_count, p->vi_pesid); | ||
| 1337 | break; | ||
| 1338 | } | ||
| 1339 | case VIDIOC_S_MPEGCOMP: | ||
| 1340 | { | ||
| 1341 | struct v4l2_mpeg_compression *p=arg; | ||
| 1342 | /*FIXME: Several fields not shown */ | ||
| 1343 | if (!vfd->vidioc_s_mpegcomp) | ||
| 1344 | break; | ||
| 1345 | dbgarg (cmd, "ts_pid_pmt=%d, ts_pid_audio=%d, " | ||
| 1346 | "ts_pid_video=%d, ts_pid_pcr=%d, ps_size=%d, " | ||
| 1347 | "au_sample_rate=%d, au_pesid=%c, " | ||
| 1348 | "vi_frame_rate=%d, vi_frames_per_gop=%d, " | ||
| 1349 | "vi_bframes_count=%d, vi_pesid=%c\n", | ||
| 1350 | p->ts_pid_pmt,p->ts_pid_audio, p->ts_pid_video, | ||
| 1351 | p->ts_pid_pcr, p->ps_size, p->au_sample_rate, | ||
| 1352 | p->au_pesid, p->vi_frame_rate, | ||
| 1353 | p->vi_frames_per_gop, p->vi_bframes_count, | ||
| 1354 | p->vi_pesid); | ||
| 1355 | ret=vfd->vidioc_s_mpegcomp(file, fh, p); | ||
| 1356 | break; | ||
| 1357 | } | ||
| 1358 | case VIDIOC_G_JPEGCOMP: | 1316 | case VIDIOC_G_JPEGCOMP: |
| 1359 | { | 1317 | { |
| 1360 | struct v4l2_jpegcompression *p=arg; | 1318 | struct v4l2_jpegcompression *p=arg; |
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index b532aa280a1b..ee73dc75131c 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
| @@ -1119,7 +1119,6 @@ static const struct file_operations vivi_fops = { | |||
| 1119 | static struct video_device vivi = { | 1119 | static struct video_device vivi = { |
| 1120 | .name = "vivi", | 1120 | .name = "vivi", |
| 1121 | .type = VID_TYPE_CAPTURE, | 1121 | .type = VID_TYPE_CAPTURE, |
| 1122 | .hardware = 0, | ||
| 1123 | .fops = &vivi_fops, | 1122 | .fops = &vivi_fops, |
| 1124 | .minor = -1, | 1123 | .minor = -1, |
| 1125 | // .release = video_device_release, | 1124 | // .release = video_device_release, |
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c index 47366408637c..08aaae07c7e0 100644 --- a/drivers/media/video/w9966.c +++ b/drivers/media/video/w9966.c | |||
| @@ -196,7 +196,6 @@ static struct video_device w9966_template = { | |||
| 196 | .owner = THIS_MODULE, | 196 | .owner = THIS_MODULE, |
| 197 | .name = W9966_DRIVERNAME, | 197 | .name = W9966_DRIVERNAME, |
| 198 | .type = VID_TYPE_CAPTURE | VID_TYPE_SCALES, | 198 | .type = VID_TYPE_CAPTURE | VID_TYPE_SCALES, |
| 199 | .hardware = VID_HARDWARE_W9966, | ||
| 200 | .fops = &w9966_fops, | 199 | .fops = &w9966_fops, |
| 201 | }; | 200 | }; |
| 202 | 201 | ||
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c index 9e7f3e685d73..2ae1430f5f7d 100644 --- a/drivers/media/video/w9968cf.c +++ b/drivers/media/video/w9968cf.c | |||
| @@ -3549,7 +3549,6 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
| 3549 | strcpy(cam->v4ldev->name, symbolic(camlist, mod_id)); | 3549 | strcpy(cam->v4ldev->name, symbolic(camlist, mod_id)); |
| 3550 | cam->v4ldev->owner = THIS_MODULE; | 3550 | cam->v4ldev->owner = THIS_MODULE; |
| 3551 | cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; | 3551 | cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; |
| 3552 | cam->v4ldev->hardware = VID_HARDWARE_W9968CF; | ||
| 3553 | cam->v4ldev->fops = &w9968cf_fops; | 3552 | cam->v4ldev->fops = &w9968cf_fops; |
| 3554 | cam->v4ldev->minor = video_nr[dev_nr]; | 3553 | cam->v4ldev->minor = video_nr[dev_nr]; |
| 3555 | cam->v4ldev->release = video_device_release; | 3554 | cam->v4ldev->release = video_device_release; |
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c index 08a93c31c0a0..2c5665c82442 100644 --- a/drivers/media/video/zc0301/zc0301_core.c +++ b/drivers/media/video/zc0301/zc0301_core.c | |||
| @@ -1985,7 +1985,6 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
| 1985 | strcpy(cam->v4ldev->name, "ZC0301[P] PC Camera"); | 1985 | strcpy(cam->v4ldev->name, "ZC0301[P] PC Camera"); |
| 1986 | cam->v4ldev->owner = THIS_MODULE; | 1986 | cam->v4ldev->owner = THIS_MODULE; |
| 1987 | cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; | 1987 | cam->v4ldev->type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; |
| 1988 | cam->v4ldev->hardware = 0; | ||
| 1989 | cam->v4ldev->fops = &zc0301_fops; | 1988 | cam->v4ldev->fops = &zc0301_fops; |
| 1990 | cam->v4ldev->minor = video_nr[dev_nr]; | 1989 | cam->v4ldev->minor = video_nr[dev_nr]; |
| 1991 | cam->v4ldev->release = video_device_release; | 1990 | cam->v4ldev->release = video_device_release; |
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c index 48da36a15fca..6e0ac4c5c379 100644 --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c | |||
| @@ -1235,8 +1235,14 @@ zoran_setup_videocodec (struct zoran *zr, | |||
| 1235 | return m; | 1235 | return m; |
| 1236 | } | 1236 | } |
| 1237 | 1237 | ||
| 1238 | m->magic = 0L; /* magic not used */ | 1238 | /* magic and type are unused for master struct. Makes sense only at |
| 1239 | m->type = VID_HARDWARE_ZR36067; | 1239 | codec structs. |
| 1240 | In the past, .type were initialized to the old V4L1 .hardware | ||
| 1241 | value, as VID_HARDWARE_ZR36067 | ||
| 1242 | */ | ||
| 1243 | m->magic = 0L; | ||
| 1244 | m->type = 0; | ||
| 1245 | |||
| 1240 | m->flags = CODEC_FLAG_ENCODER | CODEC_FLAG_DECODER; | 1246 | m->flags = CODEC_FLAG_ENCODER | CODEC_FLAG_DECODER; |
| 1241 | strncpy(m->name, ZR_DEVNAME(zr), sizeof(m->name)); | 1247 | strncpy(m->name, ZR_DEVNAME(zr), sizeof(m->name)); |
| 1242 | m->data = zr; | 1248 | m->data = zr; |
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c index 419e5af78533..dd3d7d2c8b0e 100644 --- a/drivers/media/video/zoran_driver.c +++ b/drivers/media/video/zoran_driver.c | |||
| @@ -60,7 +60,6 @@ | |||
| 60 | 60 | ||
| 61 | #include <linux/spinlock.h> | 61 | #include <linux/spinlock.h> |
| 62 | #define MAP_NR(x) virt_to_page(x) | 62 | #define MAP_NR(x) virt_to_page(x) |
| 63 | #define ZORAN_HARDWARE VID_HARDWARE_ZR36067 | ||
| 64 | #define ZORAN_VID_TYPE ( \ | 63 | #define ZORAN_VID_TYPE ( \ |
| 65 | VID_TYPE_CAPTURE | \ | 64 | VID_TYPE_CAPTURE | \ |
| 66 | VID_TYPE_OVERLAY | \ | 65 | VID_TYPE_OVERLAY | \ |
| @@ -4659,7 +4658,6 @@ struct video_device zoran_template __devinitdata = { | |||
| 4659 | #ifdef CONFIG_VIDEO_V4L2 | 4658 | #ifdef CONFIG_VIDEO_V4L2 |
| 4660 | .type2 = ZORAN_V4L2_VID_FLAGS, | 4659 | .type2 = ZORAN_V4L2_VID_FLAGS, |
| 4661 | #endif | 4660 | #endif |
| 4662 | .hardware = ZORAN_HARDWARE, | ||
| 4663 | .fops = &zoran_fops, | 4661 | .fops = &zoran_fops, |
| 4664 | .release = &zoran_vdev_release, | 4662 | .release = &zoran_vdev_release, |
| 4665 | .minor = -1 | 4663 | .minor = -1 |
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index a5d0354bbbda..9203a0b221b3 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <linux/blkdev.h> | 13 | #include <linux/blkdev.h> |
| 14 | #include <linux/freezer.h> | 14 | #include <linux/freezer.h> |
| 15 | #include <linux/kthread.h> | 15 | #include <linux/kthread.h> |
| 16 | #include <linux/scatterlist.h> | ||
| 16 | 17 | ||
| 17 | #include <linux/mmc/card.h> | 18 | #include <linux/mmc/card.h> |
| 18 | #include <linux/mmc/host.h> | 19 | #include <linux/mmc/host.h> |
| @@ -153,19 +154,21 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock | |||
| 153 | blk_queue_max_hw_segments(mq->queue, bouncesz / 512); | 154 | blk_queue_max_hw_segments(mq->queue, bouncesz / 512); |
| 154 | blk_queue_max_segment_size(mq->queue, bouncesz); | 155 | blk_queue_max_segment_size(mq->queue, bouncesz); |
| 155 | 156 | ||
| 156 | mq->sg = kzalloc(sizeof(struct scatterlist), | 157 | mq->sg = kmalloc(sizeof(struct scatterlist), |
| 157 | GFP_KERNEL); | 158 | GFP_KERNEL); |
| 158 | if (!mq->sg) { | 159 | if (!mq->sg) { |
| 159 | ret = -ENOMEM; | 160 | ret = -ENOMEM; |
| 160 | goto cleanup_queue; | 161 | goto cleanup_queue; |
| 161 | } | 162 | } |
| 163 | sg_init_table(mq->sg, 1); | ||
| 162 | 164 | ||
| 163 | mq->bounce_sg = kzalloc(sizeof(struct scatterlist) * | 165 | mq->bounce_sg = kmalloc(sizeof(struct scatterlist) * |
| 164 | bouncesz / 512, GFP_KERNEL); | 166 | bouncesz / 512, GFP_KERNEL); |
| 165 | if (!mq->bounce_sg) { | 167 | if (!mq->bounce_sg) { |
| 166 | ret = -ENOMEM; | 168 | ret = -ENOMEM; |
| 167 | goto cleanup_queue; | 169 | goto cleanup_queue; |
| 168 | } | 170 | } |
| 171 | sg_init_table(mq->bounce_sg, bouncesz / 512); | ||
| 169 | } | 172 | } |
| 170 | } | 173 | } |
| 171 | #endif | 174 | #endif |
| @@ -302,12 +305,12 @@ static void copy_sg(struct scatterlist *dst, unsigned int dst_len, | |||
| 302 | BUG_ON(dst_len == 0); | 305 | BUG_ON(dst_len == 0); |
| 303 | 306 | ||
| 304 | if (dst_size == 0) { | 307 | if (dst_size == 0) { |
| 305 | dst_buf = page_address(dst->page) + dst->offset; | 308 | dst_buf = sg_virt(dst); |
| 306 | dst_size = dst->length; | 309 | dst_size = dst->length; |
| 307 | } | 310 | } |
| 308 | 311 | ||
| 309 | if (src_size == 0) { | 312 | if (src_size == 0) { |
| 310 | src_buf = page_address(src->page) + src->offset; | 313 | src_buf = sg_virt(dst); |
| 311 | src_size = src->length; | 314 | src_size = src->length; |
| 312 | } | 315 | } |
| 313 | 316 | ||
| @@ -353,9 +356,7 @@ unsigned int mmc_queue_map_sg(struct mmc_queue *mq) | |||
| 353 | return 1; | 356 | return 1; |
| 354 | } | 357 | } |
| 355 | 358 | ||
| 356 | mq->sg[0].page = virt_to_page(mq->bounce_buf); | 359 | sg_init_one(mq->sg, mq->bounce_buf, 0); |
| 357 | mq->sg[0].offset = offset_in_page(mq->bounce_buf); | ||
| 358 | mq->sg[0].length = 0; | ||
| 359 | 360 | ||
| 360 | while (sg_len) { | 361 | while (sg_len) { |
| 361 | mq->sg[0].length += mq->bounce_sg[sg_len - 1].length; | 362 | mq->sg[0].length += mq->bounce_sg[sg_len - 1].length; |
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index 7a452c2ad1f9..b1edcefdd4f9 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c | |||
| @@ -149,7 +149,7 @@ static inline void at91_mci_sg_to_dma(struct at91mci_host *host, struct mmc_data | |||
| 149 | 149 | ||
| 150 | sg = &data->sg[i]; | 150 | sg = &data->sg[i]; |
| 151 | 151 | ||
| 152 | sgbuffer = kmap_atomic(sg->page, KM_BIO_SRC_IRQ) + sg->offset; | 152 | sgbuffer = kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset; |
| 153 | amount = min(size, sg->length); | 153 | amount = min(size, sg->length); |
| 154 | size -= amount; | 154 | size -= amount; |
| 155 | 155 | ||
| @@ -226,7 +226,7 @@ static void at91_mci_pre_dma_read(struct at91mci_host *host) | |||
| 226 | sg = &data->sg[host->transfer_index++]; | 226 | sg = &data->sg[host->transfer_index++]; |
| 227 | pr_debug("sg = %p\n", sg); | 227 | pr_debug("sg = %p\n", sg); |
| 228 | 228 | ||
| 229 | sg->dma_address = dma_map_page(NULL, sg->page, sg->offset, sg->length, DMA_FROM_DEVICE); | 229 | sg->dma_address = dma_map_page(NULL, sg_page(sg), sg->offset, sg->length, DMA_FROM_DEVICE); |
| 230 | 230 | ||
| 231 | pr_debug("dma address = %08X, length = %d\n", sg->dma_address, sg->length); | 231 | pr_debug("dma address = %08X, length = %d\n", sg->dma_address, sg->length); |
| 232 | 232 | ||
| @@ -283,7 +283,7 @@ static void at91_mci_post_dma_read(struct at91mci_host *host) | |||
| 283 | int index; | 283 | int index; |
| 284 | 284 | ||
| 285 | /* Swap the contents of the buffer */ | 285 | /* Swap the contents of the buffer */ |
| 286 | buffer = kmap_atomic(sg->page, KM_BIO_SRC_IRQ) + sg->offset; | 286 | buffer = kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset; |
| 287 | pr_debug("buffer = %p, length = %d\n", buffer, sg->length); | 287 | pr_debug("buffer = %p, length = %d\n", buffer, sg->length); |
| 288 | 288 | ||
| 289 | for (index = 0; index < (sg->length / 4); index++) | 289 | for (index = 0; index < (sg->length / 4); index++) |
| @@ -292,7 +292,7 @@ static void at91_mci_post_dma_read(struct at91mci_host *host) | |||
| 292 | kunmap_atomic(buffer, KM_BIO_SRC_IRQ); | 292 | kunmap_atomic(buffer, KM_BIO_SRC_IRQ); |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | flush_dcache_page(sg->page); | 295 | flush_dcache_page(sg_page(sg)); |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | /* Is there another transfer to trigger? */ | 298 | /* Is there another transfer to trigger? */ |
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index 92c4d0dfee43..bcbb6d247bf7 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c | |||
| @@ -340,7 +340,7 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host) | |||
| 340 | 340 | ||
| 341 | /* This is the pointer to the data buffer */ | 341 | /* This is the pointer to the data buffer */ |
| 342 | sg = &data->sg[host->pio.index]; | 342 | sg = &data->sg[host->pio.index]; |
| 343 | sg_ptr = page_address(sg->page) + sg->offset + host->pio.offset; | 343 | sg_ptr = sg_virt(sg) + host->pio.offset; |
| 344 | 344 | ||
| 345 | /* This is the space left inside the buffer */ | 345 | /* This is the space left inside the buffer */ |
| 346 | sg_len = data->sg[host->pio.index].length - host->pio.offset; | 346 | sg_len = data->sg[host->pio.index].length - host->pio.offset; |
| @@ -400,7 +400,7 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host) | |||
| 400 | 400 | ||
| 401 | if (host->pio.index < host->dma.len) { | 401 | if (host->pio.index < host->dma.len) { |
| 402 | sg = &data->sg[host->pio.index]; | 402 | sg = &data->sg[host->pio.index]; |
| 403 | sg_ptr = page_address(sg->page) + sg->offset + host->pio.offset; | 403 | sg_ptr = sg_virt(sg) + host->pio.offset; |
| 404 | 404 | ||
| 405 | /* This is the space left inside the buffer */ | 405 | /* This is the space left inside the buffer */ |
| 406 | sg_len = sg_dma_len(&data->sg[host->pio.index]) - host->pio.offset; | 406 | sg_len = sg_dma_len(&data->sg[host->pio.index]) - host->pio.offset; |
| @@ -613,14 +613,11 @@ au1xmmc_prepare_data(struct au1xmmc_host *host, struct mmc_data *data) | |||
| 613 | 613 | ||
| 614 | if (host->flags & HOST_F_XMIT){ | 614 | if (host->flags & HOST_F_XMIT){ |
| 615 | ret = au1xxx_dbdma_put_source_flags(channel, | 615 | ret = au1xxx_dbdma_put_source_flags(channel, |
| 616 | (void *) (page_address(sg->page) + | 616 | (void *) sg_virt(sg), len, flags); |
| 617 | sg->offset), | ||
| 618 | len, flags); | ||
| 619 | } | 617 | } |
| 620 | else { | 618 | else { |
| 621 | ret = au1xxx_dbdma_put_dest_flags(channel, | 619 | ret = au1xxx_dbdma_put_dest_flags(channel, |
| 622 | (void *) (page_address(sg->page) + | 620 | (void *) sg_virt(sg), |
| 623 | sg->offset), | ||
| 624 | len, flags); | 621 | len, flags); |
| 625 | } | 622 | } |
| 626 | 623 | ||
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c index 6ebc41e7592c..fc72e1fadb6a 100644 --- a/drivers/mmc/host/imxmmc.c +++ b/drivers/mmc/host/imxmmc.c | |||
| @@ -262,7 +262,7 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | /* Convert back to virtual address */ | 264 | /* Convert back to virtual address */ |
| 265 | host->data_ptr = (u16*)(page_address(data->sg->page) + data->sg->offset); | 265 | host->data_ptr = (u16*)sg_virt(sg); |
| 266 | host->data_cnt = 0; | 266 | host->data_cnt = 0; |
| 267 | 267 | ||
| 268 | clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); | 268 | clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); |
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 7ae18eaed6c5..12c2d807c145 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
| @@ -813,7 +813,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd, | |||
| 813 | && dir == DMA_FROM_DEVICE) | 813 | && dir == DMA_FROM_DEVICE) |
| 814 | dir = DMA_BIDIRECTIONAL; | 814 | dir = DMA_BIDIRECTIONAL; |
| 815 | 815 | ||
| 816 | dma_addr = dma_map_page(dma_dev, sg->page, 0, | 816 | dma_addr = dma_map_page(dma_dev, sg_page(sg), 0, |
| 817 | PAGE_SIZE, dir); | 817 | PAGE_SIZE, dir); |
| 818 | if (direction == DMA_TO_DEVICE) | 818 | if (direction == DMA_TO_DEVICE) |
| 819 | t->tx_dma = dma_addr + sg->offset; | 819 | t->tx_dma = dma_addr + sg->offset; |
| @@ -822,7 +822,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd, | |||
| 822 | } | 822 | } |
| 823 | 823 | ||
| 824 | /* allow pio too; we don't allow highmem */ | 824 | /* allow pio too; we don't allow highmem */ |
| 825 | kmap_addr = kmap(sg->page); | 825 | kmap_addr = kmap(sg_page(sg)); |
| 826 | if (direction == DMA_TO_DEVICE) | 826 | if (direction == DMA_TO_DEVICE) |
| 827 | t->tx_buf = kmap_addr + sg->offset; | 827 | t->tx_buf = kmap_addr + sg->offset; |
| 828 | else | 828 | else |
| @@ -855,8 +855,8 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd, | |||
| 855 | 855 | ||
| 856 | /* discard mappings */ | 856 | /* discard mappings */ |
| 857 | if (direction == DMA_FROM_DEVICE) | 857 | if (direction == DMA_FROM_DEVICE) |
| 858 | flush_kernel_dcache_page(sg->page); | 858 | flush_kernel_dcache_page(sg_page(sg)); |
| 859 | kunmap(sg->page); | 859 | kunmap(sg_page(sg)); |
| 860 | if (dma_dev) | 860 | if (dma_dev) |
| 861 | dma_unmap_page(dma_dev, dma_addr, PAGE_SIZE, dir); | 861 | dma_unmap_page(dma_dev, dma_addr, PAGE_SIZE, dir); |
| 862 | 862 | ||
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 60a67dfcda6a..971e18b91f4a 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c | |||
| @@ -24,10 +24,10 @@ | |||
| 24 | #include <linux/mmc/host.h> | 24 | #include <linux/mmc/host.h> |
| 25 | #include <linux/mmc/card.h> | 25 | #include <linux/mmc/card.h> |
| 26 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
| 27 | #include <linux/scatterlist.h> | ||
| 27 | 28 | ||
| 28 | #include <asm/io.h> | 29 | #include <asm/io.h> |
| 29 | #include <asm/irq.h> | 30 | #include <asm/irq.h> |
| 30 | #include <asm/scatterlist.h> | ||
| 31 | #include <asm/mach-types.h> | 31 | #include <asm/mach-types.h> |
| 32 | 32 | ||
| 33 | #include <asm/arch/board.h> | 33 | #include <asm/arch/board.h> |
| @@ -383,7 +383,7 @@ mmc_omap_sg_to_buf(struct mmc_omap_host *host) | |||
| 383 | 383 | ||
| 384 | sg = host->data->sg + host->sg_idx; | 384 | sg = host->data->sg + host->sg_idx; |
| 385 | host->buffer_bytes_left = sg->length; | 385 | host->buffer_bytes_left = sg->length; |
| 386 | host->buffer = page_address(sg->page) + sg->offset; | 386 | host->buffer = sg_virt(sg); |
| 387 | if (host->buffer_bytes_left > host->total_bytes_left) | 387 | if (host->buffer_bytes_left > host->total_bytes_left) |
| 388 | host->buffer_bytes_left = host->total_bytes_left; | 388 | host->buffer_bytes_left = host->total_bytes_left; |
| 389 | } | 389 | } |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index b397121b947d..0db837e44b77 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
| @@ -231,7 +231,7 @@ static void sdhci_deactivate_led(struct sdhci_host *host) | |||
| 231 | 231 | ||
| 232 | static inline char* sdhci_sg_to_buffer(struct sdhci_host* host) | 232 | static inline char* sdhci_sg_to_buffer(struct sdhci_host* host) |
| 233 | { | 233 | { |
| 234 | return page_address(host->cur_sg->page) + host->cur_sg->offset; | 234 | return sg_virt(host->cur_sg); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | static inline int sdhci_next_sg(struct sdhci_host* host) | 237 | static inline int sdhci_next_sg(struct sdhci_host* host) |
diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c index 9b904795eb77..c11a3d256051 100644 --- a/drivers/mmc/host/tifm_sd.c +++ b/drivers/mmc/host/tifm_sd.c | |||
| @@ -192,7 +192,7 @@ static void tifm_sd_transfer_data(struct tifm_sd *host) | |||
| 192 | } | 192 | } |
| 193 | off = sg[host->sg_pos].offset + host->block_pos; | 193 | off = sg[host->sg_pos].offset + host->block_pos; |
| 194 | 194 | ||
| 195 | pg = nth_page(sg[host->sg_pos].page, off >> PAGE_SHIFT); | 195 | pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT); |
| 196 | p_off = offset_in_page(off); | 196 | p_off = offset_in_page(off); |
| 197 | p_cnt = PAGE_SIZE - p_off; | 197 | p_cnt = PAGE_SIZE - p_off; |
| 198 | p_cnt = min(p_cnt, cnt); | 198 | p_cnt = min(p_cnt, cnt); |
| @@ -241,18 +241,18 @@ static void tifm_sd_bounce_block(struct tifm_sd *host, struct mmc_data *r_data) | |||
| 241 | } | 241 | } |
| 242 | off = sg[host->sg_pos].offset + host->block_pos; | 242 | off = sg[host->sg_pos].offset + host->block_pos; |
| 243 | 243 | ||
| 244 | pg = nth_page(sg[host->sg_pos].page, off >> PAGE_SHIFT); | 244 | pg = nth_page(sg_page(&sg[host->sg_pos]), off >> PAGE_SHIFT); |
| 245 | p_off = offset_in_page(off); | 245 | p_off = offset_in_page(off); |
| 246 | p_cnt = PAGE_SIZE - p_off; | 246 | p_cnt = PAGE_SIZE - p_off; |
| 247 | p_cnt = min(p_cnt, cnt); | 247 | p_cnt = min(p_cnt, cnt); |
| 248 | p_cnt = min(p_cnt, t_size); | 248 | p_cnt = min(p_cnt, t_size); |
| 249 | 249 | ||
| 250 | if (r_data->flags & MMC_DATA_WRITE) | 250 | if (r_data->flags & MMC_DATA_WRITE) |
| 251 | tifm_sd_copy_page(host->bounce_buf.page, | 251 | tifm_sd_copy_page(sg_page(&host->bounce_buf), |
| 252 | r_data->blksz - t_size, | 252 | r_data->blksz - t_size, |
| 253 | pg, p_off, p_cnt); | 253 | pg, p_off, p_cnt); |
| 254 | else if (r_data->flags & MMC_DATA_READ) | 254 | else if (r_data->flags & MMC_DATA_READ) |
| 255 | tifm_sd_copy_page(pg, p_off, host->bounce_buf.page, | 255 | tifm_sd_copy_page(pg, p_off, sg_page(&host->bounce_buf), |
| 256 | r_data->blksz - t_size, p_cnt); | 256 | r_data->blksz - t_size, p_cnt); |
| 257 | 257 | ||
| 258 | t_size -= p_cnt; | 258 | t_size -= p_cnt; |
diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c index 80db11c05f2a..fa4c8c53cc7a 100644 --- a/drivers/mmc/host/wbsd.c +++ b/drivers/mmc/host/wbsd.c | |||
| @@ -269,7 +269,7 @@ static inline int wbsd_next_sg(struct wbsd_host *host) | |||
| 269 | 269 | ||
| 270 | static inline char *wbsd_sg_to_buffer(struct wbsd_host *host) | 270 | static inline char *wbsd_sg_to_buffer(struct wbsd_host *host) |
| 271 | { | 271 | { |
| 272 | return page_address(host->cur_sg->page) + host->cur_sg->offset; | 272 | return sg_virt(host->cur_sg); |
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data) | 275 | static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data) |
| @@ -283,7 +283,7 @@ static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data) | |||
| 283 | len = data->sg_len; | 283 | len = data->sg_len; |
| 284 | 284 | ||
| 285 | for (i = 0; i < len; i++) { | 285 | for (i = 0; i < len; i++) { |
| 286 | sgbuf = page_address(sg[i].page) + sg[i].offset; | 286 | sgbuf = sg_virt(&sg[i]); |
| 287 | memcpy(dmabuf, sgbuf, sg[i].length); | 287 | memcpy(dmabuf, sgbuf, sg[i].length); |
| 288 | dmabuf += sg[i].length; | 288 | dmabuf += sg[i].length; |
| 289 | } | 289 | } |
| @@ -300,7 +300,7 @@ static inline void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data) | |||
| 300 | len = data->sg_len; | 300 | len = data->sg_len; |
| 301 | 301 | ||
| 302 | for (i = 0; i < len; i++) { | 302 | for (i = 0; i < len; i++) { |
| 303 | sgbuf = page_address(sg[i].page) + sg[i].offset; | 303 | sgbuf = sg_virt(&sg[i]); |
| 304 | memcpy(sgbuf, dmabuf, sg[i].length); | 304 | memcpy(sgbuf, dmabuf, sg[i].length); |
| 305 | dmabuf += sg[i].length; | 305 | dmabuf += sg[i].length; |
| 306 | } | 306 | } |
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c index 4b3c109d5eae..887633b207d9 100644 --- a/drivers/net/mlx4/icm.c +++ b/drivers/net/mlx4/icm.c | |||
| @@ -60,7 +60,7 @@ static void mlx4_free_icm_pages(struct mlx4_dev *dev, struct mlx4_icm_chunk *chu | |||
| 60 | PCI_DMA_BIDIRECTIONAL); | 60 | PCI_DMA_BIDIRECTIONAL); |
| 61 | 61 | ||
| 62 | for (i = 0; i < chunk->npages; ++i) | 62 | for (i = 0; i < chunk->npages; ++i) |
| 63 | __free_pages(chunk->mem[i].page, | 63 | __free_pages(sg_page(&chunk->mem[i]), |
| 64 | get_order(chunk->mem[i].length)); | 64 | get_order(chunk->mem[i].length)); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| @@ -70,7 +70,7 @@ static void mlx4_free_icm_coherent(struct mlx4_dev *dev, struct mlx4_icm_chunk * | |||
| 70 | 70 | ||
| 71 | for (i = 0; i < chunk->npages; ++i) | 71 | for (i = 0; i < chunk->npages; ++i) |
| 72 | dma_free_coherent(&dev->pdev->dev, chunk->mem[i].length, | 72 | dma_free_coherent(&dev->pdev->dev, chunk->mem[i].length, |
| 73 | lowmem_page_address(chunk->mem[i].page), | 73 | lowmem_page_address(sg_page(&chunk->mem[i])), |
| 74 | sg_dma_address(&chunk->mem[i])); | 74 | sg_dma_address(&chunk->mem[i])); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -95,10 +95,13 @@ void mlx4_free_icm(struct mlx4_dev *dev, struct mlx4_icm *icm, int coherent) | |||
| 95 | 95 | ||
| 96 | static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_mask) | 96 | static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_mask) |
| 97 | { | 97 | { |
| 98 | mem->page = alloc_pages(gfp_mask, order); | 98 | struct page *page; |
| 99 | if (!mem->page) | 99 | |
| 100 | page = alloc_pages(gfp_mask, order); | ||
| 101 | if (!page) | ||
| 100 | return -ENOMEM; | 102 | return -ENOMEM; |
| 101 | 103 | ||
| 104 | sg_set_page(mem, page); | ||
| 102 | mem->length = PAGE_SIZE << order; | 105 | mem->length = PAGE_SIZE << order; |
| 103 | mem->offset = 0; | 106 | mem->offset = 0; |
| 104 | return 0; | 107 | return 0; |
| @@ -145,6 +148,7 @@ struct mlx4_icm *mlx4_alloc_icm(struct mlx4_dev *dev, int npages, | |||
| 145 | if (!chunk) | 148 | if (!chunk) |
| 146 | goto fail; | 149 | goto fail; |
| 147 | 150 | ||
| 151 | sg_init_table(chunk->mem, MLX4_ICM_CHUNK_LEN); | ||
| 148 | chunk->npages = 0; | 152 | chunk->npages = 0; |
| 149 | chunk->nsg = 0; | 153 | chunk->nsg = 0; |
| 150 | list_add_tail(&chunk->list, &icm->chunk_list); | 154 | list_add_tail(&chunk->list, &icm->chunk_list); |
| @@ -334,7 +338,7 @@ void *mlx4_table_find(struct mlx4_icm_table *table, int obj, dma_addr_t *dma_han | |||
| 334 | * been assigned to. | 338 | * been assigned to. |
| 335 | */ | 339 | */ |
| 336 | if (chunk->mem[i].length > offset) { | 340 | if (chunk->mem[i].length > offset) { |
| 337 | page = chunk->mem[i].page; | 341 | page = sg_page(&chunk->mem[i]); |
| 338 | goto out; | 342 | goto out; |
| 339 | } | 343 | } |
| 340 | offset -= chunk->mem[i].length; | 344 | offset -= chunk->mem[i].length; |
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c index c0b6d19d1457..bcb0885011c8 100644 --- a/drivers/net/ppp_mppe.c +++ b/drivers/net/ppp_mppe.c | |||
| @@ -55,7 +55,7 @@ | |||
| 55 | #include <linux/mm.h> | 55 | #include <linux/mm.h> |
| 56 | #include <linux/ppp_defs.h> | 56 | #include <linux/ppp_defs.h> |
| 57 | #include <linux/ppp-comp.h> | 57 | #include <linux/ppp-comp.h> |
| 58 | #include <asm/scatterlist.h> | 58 | #include <linux/scatterlist.h> |
| 59 | 59 | ||
| 60 | #include "ppp_mppe.h" | 60 | #include "ppp_mppe.h" |
| 61 | 61 | ||
| @@ -68,9 +68,7 @@ MODULE_VERSION("1.0.2"); | |||
| 68 | static unsigned int | 68 | static unsigned int |
| 69 | setup_sg(struct scatterlist *sg, const void *address, unsigned int length) | 69 | setup_sg(struct scatterlist *sg, const void *address, unsigned int length) |
| 70 | { | 70 | { |
| 71 | sg[0].page = virt_to_page(address); | 71 | sg_init_one(sg, address, length); |
| 72 | sg[0].offset = offset_in_page(address); | ||
| 73 | sg[0].length = length; | ||
| 74 | return length; | 72 | return length; |
| 75 | } | 73 | } |
| 76 | 74 | ||
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 006054a40995..555055650733 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile | |||
| @@ -20,6 +20,9 @@ obj-$(CONFIG_PCI_MSI) += msi.o | |||
| 20 | # Build the Hypertransport interrupt support | 20 | # Build the Hypertransport interrupt support |
| 21 | obj-$(CONFIG_HT_IRQ) += htirq.o | 21 | obj-$(CONFIG_HT_IRQ) += htirq.o |
| 22 | 22 | ||
| 23 | # Build Intel IOMMU support | ||
| 24 | obj-$(CONFIG_DMAR) += dmar.o iova.o intel-iommu.o | ||
| 25 | |||
| 23 | # | 26 | # |
| 24 | # Some architectures use the generic PCI setup functions | 27 | # Some architectures use the generic PCI setup functions |
| 25 | # | 28 | # |
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c new file mode 100644 index 000000000000..5dfdfdac92e1 --- /dev/null +++ b/drivers/pci/dmar.c | |||
| @@ -0,0 +1,329 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2006, Intel Corporation. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License along with | ||
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
| 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. | ||
| 16 | * | ||
| 17 | * Copyright (C) Ashok Raj <ashok.raj@intel.com> | ||
| 18 | * Copyright (C) Shaohua Li <shaohua.li@intel.com> | ||
| 19 | * Copyright (C) Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
| 20 | * | ||
| 21 | * This file implements early detection/parsing of DMA Remapping Devices | ||
| 22 | * reported to OS through BIOS via DMA remapping reporting (DMAR) ACPI | ||
| 23 | * tables. | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <linux/pci.h> | ||
| 27 | #include <linux/dmar.h> | ||
| 28 | |||
| 29 | #undef PREFIX | ||
| 30 | #define PREFIX "DMAR:" | ||
| 31 | |||
| 32 | /* No locks are needed as DMA remapping hardware unit | ||
| 33 | * list is constructed at boot time and hotplug of | ||
| 34 | * these units are not supported by the architecture. | ||
| 35 | */ | ||
| 36 | LIST_HEAD(dmar_drhd_units); | ||
| 37 | LIST_HEAD(dmar_rmrr_units); | ||
| 38 | |||
| 39 | static struct acpi_table_header * __initdata dmar_tbl; | ||
| 40 | |||
| 41 | static void __init dmar_register_drhd_unit(struct dmar_drhd_unit *drhd) | ||
| 42 | { | ||
| 43 | /* | ||
| 44 | * add INCLUDE_ALL at the tail, so scan the list will find it at | ||
| 45 | * the very end. | ||
| 46 | */ | ||
| 47 | if (drhd->include_all) | ||
| 48 | list_add_tail(&drhd->list, &dmar_drhd_units); | ||
| 49 | else | ||
| 50 | list_add(&drhd->list, &dmar_drhd_units); | ||
| 51 | } | ||
| 52 | |||
| 53 | static void __init dmar_register_rmrr_unit(struct dmar_rmrr_unit *rmrr) | ||
| 54 | { | ||
| 55 | list_add(&rmrr->list, &dmar_rmrr_units); | ||
| 56 | } | ||
| 57 | |||
| 58 | static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope, | ||
| 59 | struct pci_dev **dev, u16 segment) | ||
| 60 | { | ||
| 61 | struct pci_bus *bus; | ||
| 62 | struct pci_dev *pdev = NULL; | ||
| 63 | struct acpi_dmar_pci_path *path; | ||
| 64 | int count; | ||
| 65 | |||
| 66 | bus = pci_find_bus(segment, scope->bus); | ||
| 67 | path = (struct acpi_dmar_pci_path *)(scope + 1); | ||
| 68 | count = (scope->length - sizeof(struct acpi_dmar_device_scope)) | ||
| 69 | / sizeof(struct acpi_dmar_pci_path); | ||
| 70 | |||
| 71 | while (count) { | ||
| 72 | if (pdev) | ||
| 73 | pci_dev_put(pdev); | ||
| 74 | /* | ||
| 75 | * Some BIOSes list non-exist devices in DMAR table, just | ||
| 76 | * ignore it | ||
| 77 | */ | ||
| 78 | if (!bus) { | ||
| 79 | printk(KERN_WARNING | ||
| 80 | PREFIX "Device scope bus [%d] not found\n", | ||
| 81 | scope->bus); | ||
| 82 | break; | ||
| 83 | } | ||
| 84 | pdev = pci_get_slot(bus, PCI_DEVFN(path->dev, path->fn)); | ||
| 85 | if (!pdev) { | ||
| 86 | printk(KERN_WARNING PREFIX | ||
| 87 | "Device scope device [%04x:%02x:%02x.%02x] not found\n", | ||
| 88 | segment, bus->number, path->dev, path->fn); | ||
| 89 | break; | ||
| 90 | } | ||
| 91 | path ++; | ||
| 92 | count --; | ||
| 93 | bus = pdev->subordinate; | ||
| 94 | } | ||
| 95 | if (!pdev) { | ||
| 96 | printk(KERN_WARNING PREFIX | ||
| 97 | "Device scope device [%04x:%02x:%02x.%02x] not found\n", | ||
| 98 | segment, scope->bus, path->dev, path->fn); | ||
| 99 | *dev = NULL; | ||
| 100 | return 0; | ||
| 101 | } | ||
| 102 | if ((scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT && \ | ||
| 103 | pdev->subordinate) || (scope->entry_type == \ | ||
| 104 | ACPI_DMAR_SCOPE_TYPE_BRIDGE && !pdev->subordinate)) { | ||
| 105 | pci_dev_put(pdev); | ||
| 106 | printk(KERN_WARNING PREFIX | ||
| 107 | "Device scope type does not match for %s\n", | ||
| 108 | pci_name(pdev)); | ||
| 109 | return -EINVAL; | ||
| 110 | } | ||
| 111 | *dev = pdev; | ||
| 112 | return 0; | ||
| 113 | } | ||
| 114 | |||
| 115 | static int __init dmar_parse_dev_scope(void *start, void *end, int *cnt, | ||
| 116 | struct pci_dev ***devices, u16 segment) | ||
| 117 | { | ||
| 118 | struct acpi_dmar_device_scope *scope; | ||
| 119 | void * tmp = start; | ||
| 120 | int index; | ||
| 121 | int ret; | ||
| 122 | |||
| 123 | *cnt = 0; | ||
| 124 | while (start < end) { | ||
| 125 | scope = start; | ||
| 126 | if (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT || | ||
| 127 | scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE) | ||
| 128 | (*cnt)++; | ||
| 129 | else | ||
| 130 | printk(KERN_WARNING PREFIX | ||
| 131 | "Unsupported device scope\n"); | ||
| 132 | start += scope->length; | ||
| 133 | } | ||
| 134 | if (*cnt == 0) | ||
| 135 | return 0; | ||
| 136 | |||
| 137 | *devices = kcalloc(*cnt, sizeof(struct pci_dev *), GFP_KERNEL); | ||
| 138 | if (!*devices) | ||
| 139 | return -ENOMEM; | ||
| 140 | |||
| 141 | start = tmp; | ||
| 142 | index = 0; | ||
| 143 | while (start < end) { | ||
| 144 | scope = start; | ||
| 145 | if (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT || | ||
| 146 | scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE) { | ||
| 147 | ret = dmar_parse_one_dev_scope(scope, | ||
| 148 | &(*devices)[index], segment); | ||
| 149 | if (ret) { | ||
| 150 | kfree(*devices); | ||
| 151 | return ret; | ||
| 152 | } | ||
| 153 | index ++; | ||
| 154 | } | ||
| 155 | start += scope->length; | ||
| 156 | } | ||
| 157 | |||
| 158 | return 0; | ||
| 159 | } | ||
| 160 | |||
| 161 | /** | ||
| 162 | * dmar_parse_one_drhd - parses exactly one DMA remapping hardware definition | ||
| 163 | * structure which uniquely represent one DMA remapping hardware unit | ||
| 164 | * present in the platform | ||
| 165 | */ | ||
| 166 | static int __init | ||
| 167 | dmar_parse_one_drhd(struct acpi_dmar_header *header) | ||
| 168 | { | ||
| 169 | struct acpi_dmar_hardware_unit *drhd; | ||
| 170 | struct dmar_drhd_unit *dmaru; | ||
| 171 | int ret = 0; | ||
| 172 | static int include_all; | ||
| 173 | |||
| 174 | dmaru = kzalloc(sizeof(*dmaru), GFP_KERNEL); | ||
| 175 | if (!dmaru) | ||
| 176 | return -ENOMEM; | ||
| 177 | |||
| 178 | drhd = (struct acpi_dmar_hardware_unit *)header; | ||
| 179 | dmaru->reg_base_addr = drhd->address; | ||
| 180 | dmaru->include_all = drhd->flags & 0x1; /* BIT0: INCLUDE_ALL */ | ||
| 181 | |||
| 182 | if (!dmaru->include_all) | ||
| 183 | ret = dmar_parse_dev_scope((void *)(drhd + 1), | ||
| 184 | ((void *)drhd) + header->length, | ||
| 185 | &dmaru->devices_cnt, &dmaru->devices, | ||
| 186 | drhd->segment); | ||
| 187 | else { | ||
| 188 | /* Only allow one INCLUDE_ALL */ | ||
| 189 | if (include_all) { | ||
| 190 | printk(KERN_WARNING PREFIX "Only one INCLUDE_ALL " | ||
| 191 | "device scope is allowed\n"); | ||
| 192 | ret = -EINVAL; | ||
| 193 | } | ||
| 194 | include_all = 1; | ||
| 195 | } | ||
| 196 | |||
| 197 | if (ret || (dmaru->devices_cnt == 0 && !dmaru->include_all)) | ||
| 198 | kfree(dmaru); | ||
| 199 | else | ||
| 200 | dmar_register_drhd_unit(dmaru); | ||
| 201 | return ret; | ||
| 202 | } | ||
| 203 | |||
| 204 | static int __init | ||
| 205 | dmar_parse_one_rmrr(struct acpi_dmar_header *header) | ||
| 206 | { | ||
| 207 | struct acpi_dmar_reserved_memory *rmrr; | ||
| 208 | struct dmar_rmrr_unit *rmrru; | ||
| 209 | int ret = 0; | ||
| 210 | |||
| 211 | rmrru = kzalloc(sizeof(*rmrru), GFP_KERNEL); | ||
| 212 | if (!rmrru) | ||
| 213 | return -ENOMEM; | ||
| 214 | |||
| 215 | rmrr = (struct acpi_dmar_reserved_memory *)header; | ||
| 216 | rmrru->base_address = rmrr->base_address; | ||
| 217 | rmrru->end_address = rmrr->end_address; | ||
| 218 | ret = dmar_parse_dev_scope((void *)(rmrr + 1), | ||
| 219 | ((void *)rmrr) + header->length, | ||
| 220 | &rmrru->devices_cnt, &rmrru->devices, rmrr->segment); | ||
| 221 | |||
| 222 | if (ret || (rmrru->devices_cnt == 0)) | ||
| 223 | kfree(rmrru); | ||
| 224 | else | ||
| 225 | dmar_register_rmrr_unit(rmrru); | ||
| 226 | return ret; | ||
| 227 | } | ||
| 228 | |||
| 229 | static void __init | ||
| 230 | dmar_table_print_dmar_entry(struct acpi_dmar_header *header) | ||
| 231 | { | ||
| 232 | struct acpi_dmar_hardware_unit *drhd; | ||
| 233 | struct acpi_dmar_reserved_memory *rmrr; | ||
| 234 | |||
| 235 | switch (header->type) { | ||
| 236 | case ACPI_DMAR_TYPE_HARDWARE_UNIT: | ||
| 237 | drhd = (struct acpi_dmar_hardware_unit *)header; | ||
| 238 | printk (KERN_INFO PREFIX | ||
| 239 | "DRHD (flags: 0x%08x)base: 0x%016Lx\n", | ||
| 240 | drhd->flags, drhd->address); | ||
| 241 | break; | ||
| 242 | case ACPI_DMAR_TYPE_RESERVED_MEMORY: | ||
| 243 | rmrr = (struct acpi_dmar_reserved_memory *)header; | ||
| 244 | |||
| 245 | printk (KERN_INFO PREFIX | ||
| 246 | "RMRR base: 0x%016Lx end: 0x%016Lx\n", | ||
| 247 | rmrr->base_address, rmrr->end_address); | ||
| 248 | break; | ||
| 249 | } | ||
| 250 | } | ||
| 251 | |||
| 252 | /** | ||
| 253 | * parse_dmar_table - parses the DMA reporting table | ||
| 254 | */ | ||
| 255 | static int __init | ||
| 256 | parse_dmar_table(void) | ||
| 257 | { | ||
| 258 | struct acpi_table_dmar *dmar; | ||
| 259 | struct acpi_dmar_header *entry_header; | ||
| 260 | int ret = 0; | ||
| 261 | |||
| 262 | dmar = (struct acpi_table_dmar *)dmar_tbl; | ||
| 263 | if (!dmar) | ||
| 264 | return -ENODEV; | ||
| 265 | |||
| 266 | if (!dmar->width) { | ||
| 267 | printk (KERN_WARNING PREFIX "Zero: Invalid DMAR haw\n"); | ||
| 268 | return -EINVAL; | ||
| 269 | } | ||
| 270 | |||
| 271 | printk (KERN_INFO PREFIX "Host address width %d\n", | ||
| 272 | dmar->width + 1); | ||
| 273 | |||
| 274 | entry_header = (struct acpi_dmar_header *)(dmar + 1); | ||
| 275 | while (((unsigned long)entry_header) < | ||
| 276 | (((unsigned long)dmar) + dmar_tbl->length)) { | ||
| 277 | dmar_table_print_dmar_entry(entry_header); | ||
| 278 | |||
| 279 | switch (entry_header->type) { | ||
| 280 | case ACPI_DMAR_TYPE_HARDWARE_UNIT: | ||
| 281 | ret = dmar_parse_one_drhd(entry_header); | ||
| 282 | break; | ||
| 283 | case ACPI_DMAR_TYPE_RESERVED_MEMORY: | ||
| 284 | ret = dmar_parse_one_rmrr(entry_header); | ||
| 285 | break; | ||
| 286 | default: | ||
| 287 | printk(KERN_WARNING PREFIX | ||
| 288 | "Unknown DMAR structure type\n"); | ||
| 289 | ret = 0; /* for forward compatibility */ | ||
| 290 | break; | ||
| 291 | } | ||
| 292 | if (ret) | ||
| 293 | break; | ||
| 294 | |||
| 295 | entry_header = ((void *)entry_header + entry_header->length); | ||
| 296 | } | ||
| 297 | return ret; | ||
| 298 | } | ||
| 299 | |||
| 300 | |||
| 301 | int __init dmar_table_init(void) | ||
| 302 | { | ||
| 303 | |||
| 304 | parse_dmar_table(); | ||
| 305 | if (list_empty(&dmar_drhd_units)) { | ||
| 306 | printk(KERN_INFO PREFIX "No DMAR devices found\n"); | ||
| 307 | return -ENODEV; | ||
| 308 | } | ||
| 309 | return 0; | ||
| 310 | } | ||
| 311 | |||
| 312 | /** | ||
| 313 | * early_dmar_detect - checks to see if the platform supports DMAR devices | ||
| 314 | */ | ||
| 315 | int __init early_dmar_detect(void) | ||
| 316 | { | ||
| 317 | acpi_status status = AE_OK; | ||
| 318 | |||
| 319 | /* if we could find DMAR table, then there are DMAR devices */ | ||
| 320 | status = acpi_get_table(ACPI_SIG_DMAR, 0, | ||
| 321 | (struct acpi_table_header **)&dmar_tbl); | ||
| 322 | |||
| 323 | if (ACPI_SUCCESS(status) && !dmar_tbl) { | ||
| 324 | printk (KERN_WARNING PREFIX "Unable to map DMAR\n"); | ||
| 325 | status = AE_NOT_FOUND; | ||
| 326 | } | ||
| 327 | |||
| 328 | return (ACPI_SUCCESS(status) ? 1 : 0); | ||
| 329 | } | ||
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c new file mode 100644 index 000000000000..b3d70310af49 --- /dev/null +++ b/drivers/pci/intel-iommu.c | |||
| @@ -0,0 +1,2271 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2006, Intel Corporation. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License along with | ||
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
| 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. | ||
| 16 | * | ||
| 17 | * Copyright (C) Ashok Raj <ashok.raj@intel.com> | ||
| 18 | * Copyright (C) Shaohua Li <shaohua.li@intel.com> | ||
| 19 | * Copyright (C) Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/init.h> | ||
| 23 | #include <linux/bitmap.h> | ||
| 24 | #include <linux/slab.h> | ||
| 25 | #include <linux/irq.h> | ||
| 26 | #include <linux/interrupt.h> | ||
| 27 | #include <linux/sysdev.h> | ||
| 28 | #include <linux/spinlock.h> | ||
| 29 | #include <linux/pci.h> | ||
| 30 | #include <linux/dmar.h> | ||
| 31 | #include <linux/dma-mapping.h> | ||
| 32 | #include <linux/mempool.h> | ||
| 33 | #include "iova.h" | ||
| 34 | #include "intel-iommu.h" | ||
| 35 | #include <asm/proto.h> /* force_iommu in this header in x86-64*/ | ||
| 36 | #include <asm/cacheflush.h> | ||
| 37 | #include <asm/iommu.h> | ||
| 38 | #include "pci.h" | ||
| 39 | |||
| 40 | #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) | ||
| 41 | #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) | ||
| 42 | |||
| 43 | #define IOAPIC_RANGE_START (0xfee00000) | ||
| 44 | #define IOAPIC_RANGE_END (0xfeefffff) | ||
| 45 | #define IOVA_START_ADDR (0x1000) | ||
| 46 | |||
| 47 | #define DEFAULT_DOMAIN_ADDRESS_WIDTH 48 | ||
| 48 | |||
| 49 | #define DMAR_OPERATION_TIMEOUT (HZ*60) /* 1m */ | ||
| 50 | |||
| 51 | #define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) | ||
| 52 | |||
| 53 | static void domain_remove_dev_info(struct dmar_domain *domain); | ||
| 54 | |||
| 55 | static int dmar_disabled; | ||
| 56 | static int __initdata dmar_map_gfx = 1; | ||
| 57 | static int dmar_forcedac; | ||
| 58 | |||
| 59 | #define DUMMY_DEVICE_DOMAIN_INFO ((struct device_domain_info *)(-1)) | ||
| 60 | static DEFINE_SPINLOCK(device_domain_lock); | ||
| 61 | static LIST_HEAD(device_domain_list); | ||
| 62 | |||
| 63 | static int __init intel_iommu_setup(char *str) | ||
| 64 | { | ||
| 65 | if (!str) | ||
| 66 | return -EINVAL; | ||
| 67 | while (*str) { | ||
| 68 | if (!strncmp(str, "off", 3)) { | ||
| 69 | dmar_disabled = 1; | ||
| 70 | printk(KERN_INFO"Intel-IOMMU: disabled\n"); | ||
| 71 | } else if (!strncmp(str, "igfx_off", 8)) { | ||
| 72 | dmar_map_gfx = 0; | ||
| 73 | printk(KERN_INFO | ||
| 74 | "Intel-IOMMU: disable GFX device mapping\n"); | ||
| 75 | } else if (!strncmp(str, "forcedac", 8)) { | ||
| 76 | printk (KERN_INFO | ||
| 77 | "Intel-IOMMU: Forcing DAC for PCI devices\n"); | ||
| 78 | dmar_forcedac = 1; | ||
| 79 | } | ||
| 80 | |||
| 81 | str += strcspn(str, ","); | ||
| 82 | while (*str == ',') | ||
| 83 | str++; | ||
| 84 | } | ||
| 85 | return 0; | ||
| 86 | } | ||
| 87 | __setup("intel_iommu=", intel_iommu_setup); | ||
| 88 | |||
| 89 | static struct kmem_cache *iommu_domain_cache; | ||
| 90 | static struct kmem_cache *iommu_devinfo_cache; | ||
| 91 | static struct kmem_cache *iommu_iova_cache; | ||
| 92 | |||
| 93 | static inline void *iommu_kmem_cache_alloc(struct kmem_cache *cachep) | ||
| 94 | { | ||
| 95 | unsigned int flags; | ||
| 96 | void *vaddr; | ||
| 97 | |||
| 98 | /* trying to avoid low memory issues */ | ||
| 99 | flags = current->flags & PF_MEMALLOC; | ||
| 100 | current->flags |= PF_MEMALLOC; | ||
| 101 | vaddr = kmem_cache_alloc(cachep, GFP_ATOMIC); | ||
| 102 | current->flags &= (~PF_MEMALLOC | flags); | ||
| 103 | return vaddr; | ||
| 104 | } | ||
| 105 | |||
| 106 | |||
| 107 | static inline void *alloc_pgtable_page(void) | ||
| 108 | { | ||
| 109 | unsigned int flags; | ||
| 110 | void *vaddr; | ||
| 111 | |||
| 112 | /* trying to avoid low memory issues */ | ||
| 113 | flags = current->flags & PF_MEMALLOC; | ||
| 114 | current->flags |= PF_MEMALLOC; | ||
| 115 | vaddr = (void *)get_zeroed_page(GFP_ATOMIC); | ||
| 116 | current->flags &= (~PF_MEMALLOC | flags); | ||
| 117 | return vaddr; | ||
| 118 | } | ||
| 119 | |||
| 120 | static inline void free_pgtable_page(void *vaddr) | ||
| 121 | { | ||
| 122 | free_page((unsigned long)vaddr); | ||
| 123 | } | ||
| 124 | |||
| 125 | static inline void *alloc_domain_mem(void) | ||
| 126 | { | ||
| 127 | return iommu_kmem_cache_alloc(iommu_domain_cache); | ||
| 128 | } | ||
| 129 | |||
| 130 | static inline void free_domain_mem(void *vaddr) | ||
| 131 | { | ||
| 132 | kmem_cache_free(iommu_domain_cache, vaddr); | ||
| 133 | } | ||
| 134 | |||
| 135 | static inline void * alloc_devinfo_mem(void) | ||
| 136 | { | ||
| 137 | return iommu_kmem_cache_alloc(iommu_devinfo_cache); | ||
| 138 | } | ||
| 139 | |||
| 140 | static inline void free_devinfo_mem(void *vaddr) | ||
| 141 | { | ||
| 142 | kmem_cache_free(iommu_devinfo_cache, vaddr); | ||
| 143 | } | ||
| 144 | |||
| 145 | struct iova *alloc_iova_mem(void) | ||
| 146 | { | ||
| 147 | return iommu_kmem_cache_alloc(iommu_iova_cache); | ||
| 148 | } | ||
| 149 | |||
| 150 | void free_iova_mem(struct iova *iova) | ||
| 151 | { | ||
| 152 | kmem_cache_free(iommu_iova_cache, iova); | ||
| 153 | } | ||
| 154 | |||
| 155 | static inline void __iommu_flush_cache( | ||
| 156 | struct intel_iommu *iommu, void *addr, int size) | ||
| 157 | { | ||
| 158 | if (!ecap_coherent(iommu->ecap)) | ||
| 159 | clflush_cache_range(addr, size); | ||
| 160 | } | ||
| 161 | |||
| 162 | /* Gets context entry for a given bus and devfn */ | ||
| 163 | static struct context_entry * device_to_context_entry(struct intel_iommu *iommu, | ||
| 164 | u8 bus, u8 devfn) | ||
| 165 | { | ||
| 166 | struct root_entry *root; | ||
| 167 | struct context_entry *context; | ||
| 168 | unsigned long phy_addr; | ||
| 169 | unsigned long flags; | ||
| 170 | |||
| 171 | spin_lock_irqsave(&iommu->lock, flags); | ||
| 172 | root = &iommu->root_entry[bus]; | ||
| 173 | context = get_context_addr_from_root(root); | ||
| 174 | if (!context) { | ||
| 175 | context = (struct context_entry *)alloc_pgtable_page(); | ||
| 176 | if (!context) { | ||
| 177 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 178 | return NULL; | ||
| 179 | } | ||
| 180 | __iommu_flush_cache(iommu, (void *)context, PAGE_SIZE_4K); | ||
| 181 | phy_addr = virt_to_phys((void *)context); | ||
| 182 | set_root_value(root, phy_addr); | ||
| 183 | set_root_present(root); | ||
| 184 | __iommu_flush_cache(iommu, root, sizeof(*root)); | ||
| 185 | } | ||
| 186 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 187 | return &context[devfn]; | ||
| 188 | } | ||
| 189 | |||
| 190 | static int device_context_mapped(struct intel_iommu *iommu, u8 bus, u8 devfn) | ||
| 191 | { | ||
| 192 | struct root_entry *root; | ||
| 193 | struct context_entry *context; | ||
| 194 | int ret; | ||
| 195 | unsigned long flags; | ||
| 196 | |||
| 197 | spin_lock_irqsave(&iommu->lock, flags); | ||
| 198 | root = &iommu->root_entry[bus]; | ||
| 199 | context = get_context_addr_from_root(root); | ||
| 200 | if (!context) { | ||
| 201 | ret = 0; | ||
| 202 | goto out; | ||
| 203 | } | ||
| 204 | ret = context_present(context[devfn]); | ||
| 205 | out: | ||
| 206 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 207 | return ret; | ||
| 208 | } | ||
| 209 | |||
| 210 | static void clear_context_table(struct intel_iommu *iommu, u8 bus, u8 devfn) | ||
| 211 | { | ||
| 212 | struct root_entry *root; | ||
| 213 | struct context_entry *context; | ||
| 214 | unsigned long flags; | ||
| 215 | |||
| 216 | spin_lock_irqsave(&iommu->lock, flags); | ||
| 217 | root = &iommu->root_entry[bus]; | ||
| 218 | context = get_context_addr_from_root(root); | ||
| 219 | if (context) { | ||
| 220 | context_clear_entry(context[devfn]); | ||
| 221 | __iommu_flush_cache(iommu, &context[devfn], \ | ||
| 222 | sizeof(*context)); | ||
| 223 | } | ||
| 224 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 225 | } | ||
| 226 | |||
| 227 | static void free_context_table(struct intel_iommu *iommu) | ||
| 228 | { | ||
| 229 | struct root_entry *root; | ||
| 230 | int i; | ||
| 231 | unsigned long flags; | ||
| 232 | struct context_entry *context; | ||
| 233 | |||
| 234 | spin_lock_irqsave(&iommu->lock, flags); | ||
| 235 | if (!iommu->root_entry) { | ||
| 236 | goto out; | ||
| 237 | } | ||
| 238 | for (i = 0; i < ROOT_ENTRY_NR; i++) { | ||
| 239 | root = &iommu->root_entry[i]; | ||
| 240 | context = get_context_addr_from_root(root); | ||
| 241 | if (context) | ||
| 242 | free_pgtable_page(context); | ||
| 243 | } | ||
| 244 | free_pgtable_page(iommu->root_entry); | ||
| 245 | iommu->root_entry = NULL; | ||
| 246 | out: | ||
| 247 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 248 | } | ||
| 249 | |||
| 250 | /* page table handling */ | ||
| 251 | #define LEVEL_STRIDE (9) | ||
| 252 | #define LEVEL_MASK (((u64)1 << LEVEL_STRIDE) - 1) | ||
| 253 | |||
| 254 | static inline int agaw_to_level(int agaw) | ||
| 255 | { | ||
| 256 | return agaw + 2; | ||
| 257 | } | ||
| 258 | |||
| 259 | static inline int agaw_to_width(int agaw) | ||
| 260 | { | ||
| 261 | return 30 + agaw * LEVEL_STRIDE; | ||
| 262 | |||
| 263 | } | ||
| 264 | |||
| 265 | static inline int width_to_agaw(int width) | ||
| 266 | { | ||
| 267 | return (width - 30) / LEVEL_STRIDE; | ||
| 268 | } | ||
| 269 | |||
| 270 | static inline unsigned int level_to_offset_bits(int level) | ||
| 271 | { | ||
| 272 | return (12 + (level - 1) * LEVEL_STRIDE); | ||
| 273 | } | ||
| 274 | |||
| 275 | static inline int address_level_offset(u64 addr, int level) | ||
| 276 | { | ||
| 277 | return ((addr >> level_to_offset_bits(level)) & LEVEL_MASK); | ||
| 278 | } | ||
| 279 | |||
| 280 | static inline u64 level_mask(int level) | ||
| 281 | { | ||
| 282 | return ((u64)-1 << level_to_offset_bits(level)); | ||
| 283 | } | ||
| 284 | |||
| 285 | static inline u64 level_size(int level) | ||
| 286 | { | ||
| 287 | return ((u64)1 << level_to_offset_bits(level)); | ||
| 288 | } | ||
| 289 | |||
| 290 | static inline u64 align_to_level(u64 addr, int level) | ||
| 291 | { | ||
| 292 | return ((addr + level_size(level) - 1) & level_mask(level)); | ||
| 293 | } | ||
| 294 | |||
| 295 | static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr) | ||
| 296 | { | ||
| 297 | int addr_width = agaw_to_width(domain->agaw); | ||
| 298 | struct dma_pte *parent, *pte = NULL; | ||
| 299 | int level = agaw_to_level(domain->agaw); | ||
| 300 | int offset; | ||
| 301 | unsigned long flags; | ||
| 302 | |||
| 303 | BUG_ON(!domain->pgd); | ||
| 304 | |||
| 305 | addr &= (((u64)1) << addr_width) - 1; | ||
| 306 | parent = domain->pgd; | ||
| 307 | |||
| 308 | spin_lock_irqsave(&domain->mapping_lock, flags); | ||
| 309 | while (level > 0) { | ||
| 310 | void *tmp_page; | ||
| 311 | |||
| 312 | offset = address_level_offset(addr, level); | ||
| 313 | pte = &parent[offset]; | ||
| 314 | if (level == 1) | ||
| 315 | break; | ||
| 316 | |||
| 317 | if (!dma_pte_present(*pte)) { | ||
| 318 | tmp_page = alloc_pgtable_page(); | ||
| 319 | |||
| 320 | if (!tmp_page) { | ||
| 321 | spin_unlock_irqrestore(&domain->mapping_lock, | ||
| 322 | flags); | ||
| 323 | return NULL; | ||
| 324 | } | ||
| 325 | __iommu_flush_cache(domain->iommu, tmp_page, | ||
| 326 | PAGE_SIZE_4K); | ||
| 327 | dma_set_pte_addr(*pte, virt_to_phys(tmp_page)); | ||
| 328 | /* | ||
| 329 | * high level table always sets r/w, last level page | ||
| 330 | * table control read/write | ||
| 331 | */ | ||
| 332 | dma_set_pte_readable(*pte); | ||
| 333 | dma_set_pte_writable(*pte); | ||
| 334 | __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); | ||
| 335 | } | ||
| 336 | parent = phys_to_virt(dma_pte_addr(*pte)); | ||
| 337 | level--; | ||
| 338 | } | ||
| 339 | |||
| 340 | spin_unlock_irqrestore(&domain->mapping_lock, flags); | ||
| 341 | return pte; | ||
| 342 | } | ||
| 343 | |||
| 344 | /* return address's pte at specific level */ | ||
| 345 | static struct dma_pte *dma_addr_level_pte(struct dmar_domain *domain, u64 addr, | ||
| 346 | int level) | ||
| 347 | { | ||
| 348 | struct dma_pte *parent, *pte = NULL; | ||
| 349 | int total = agaw_to_level(domain->agaw); | ||
| 350 | int offset; | ||
| 351 | |||
| 352 | parent = domain->pgd; | ||
| 353 | while (level <= total) { | ||
| 354 | offset = address_level_offset(addr, total); | ||
| 355 | pte = &parent[offset]; | ||
| 356 | if (level == total) | ||
| 357 | return pte; | ||
| 358 | |||
| 359 | if (!dma_pte_present(*pte)) | ||
| 360 | break; | ||
| 361 | parent = phys_to_virt(dma_pte_addr(*pte)); | ||
| 362 | total--; | ||
| 363 | } | ||
| 364 | return NULL; | ||
| 365 | } | ||
| 366 | |||
| 367 | /* clear one page's page table */ | ||
| 368 | static void dma_pte_clear_one(struct dmar_domain *domain, u64 addr) | ||
| 369 | { | ||
| 370 | struct dma_pte *pte = NULL; | ||
| 371 | |||
| 372 | /* get last level pte */ | ||
| 373 | pte = dma_addr_level_pte(domain, addr, 1); | ||
| 374 | |||
| 375 | if (pte) { | ||
| 376 | dma_clear_pte(*pte); | ||
| 377 | __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); | ||
| 378 | } | ||
| 379 | } | ||
| 380 | |||
| 381 | /* clear last level pte, a tlb flush should be followed */ | ||
| 382 | static void dma_pte_clear_range(struct dmar_domain *domain, u64 start, u64 end) | ||
| 383 | { | ||
| 384 | int addr_width = agaw_to_width(domain->agaw); | ||
| 385 | |||
| 386 | start &= (((u64)1) << addr_width) - 1; | ||
| 387 | end &= (((u64)1) << addr_width) - 1; | ||
| 388 | /* in case it's partial page */ | ||
| 389 | start = PAGE_ALIGN_4K(start); | ||
| 390 | end &= PAGE_MASK_4K; | ||
| 391 | |||
| 392 | /* we don't need lock here, nobody else touches the iova range */ | ||
| 393 | while (start < end) { | ||
| 394 | dma_pte_clear_one(domain, start); | ||
| 395 | start += PAGE_SIZE_4K; | ||
| 396 | } | ||
| 397 | } | ||
| 398 | |||
| 399 | /* free page table pages. last level pte should already be cleared */ | ||
| 400 | static void dma_pte_free_pagetable(struct dmar_domain *domain, | ||
| 401 | u64 start, u64 end) | ||
| 402 | { | ||
| 403 | int addr_width = agaw_to_width(domain->agaw); | ||
| 404 | struct dma_pte *pte; | ||
| 405 | int total = agaw_to_level(domain->agaw); | ||
| 406 | int level; | ||
| 407 | u64 tmp; | ||
| 408 | |||
| 409 | start &= (((u64)1) << addr_width) - 1; | ||
| 410 | end &= (((u64)1) << addr_width) - 1; | ||
| 411 | |||
| 412 | /* we don't need lock here, nobody else touches the iova range */ | ||
| 413 | level = 2; | ||
| 414 | while (level <= total) { | ||
| 415 | tmp = align_to_level(start, level); | ||
| 416 | if (tmp >= end || (tmp + level_size(level) > end)) | ||
| 417 | return; | ||
| 418 | |||
| 419 | while (tmp < end) { | ||
| 420 | pte = dma_addr_level_pte(domain, tmp, level); | ||
| 421 | if (pte) { | ||
| 422 | free_pgtable_page( | ||
| 423 | phys_to_virt(dma_pte_addr(*pte))); | ||
| 424 | dma_clear_pte(*pte); | ||
| 425 | __iommu_flush_cache(domain->iommu, | ||
| 426 | pte, sizeof(*pte)); | ||
| 427 | } | ||
| 428 | tmp += level_size(level); | ||
| 429 | } | ||
| 430 | level++; | ||
| 431 | } | ||
| 432 | /* free pgd */ | ||
| 433 | if (start == 0 && end >= ((((u64)1) << addr_width) - 1)) { | ||
| 434 | free_pgtable_page(domain->pgd); | ||
| 435 | domain->pgd = NULL; | ||
| 436 | } | ||
| 437 | } | ||
| 438 | |||
| 439 | /* iommu handling */ | ||
| 440 | static int iommu_alloc_root_entry(struct intel_iommu *iommu) | ||
| 441 | { | ||
| 442 | struct root_entry *root; | ||
| 443 | unsigned long flags; | ||
| 444 | |||
| 445 | root = (struct root_entry *)alloc_pgtable_page(); | ||
| 446 | if (!root) | ||
| 447 | return -ENOMEM; | ||
| 448 | |||
| 449 | __iommu_flush_cache(iommu, root, PAGE_SIZE_4K); | ||
| 450 | |||
| 451 | spin_lock_irqsave(&iommu->lock, flags); | ||
| 452 | iommu->root_entry = root; | ||
| 453 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 454 | |||
| 455 | return 0; | ||
| 456 | } | ||
| 457 | |||
| 458 | #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \ | ||
| 459 | {\ | ||
| 460 | unsigned long start_time = jiffies;\ | ||
| 461 | while (1) {\ | ||
| 462 | sts = op (iommu->reg + offset);\ | ||
| 463 | if (cond)\ | ||
| 464 | break;\ | ||
| 465 | if (time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT))\ | ||
| 466 | panic("DMAR hardware is malfunctioning\n");\ | ||
| 467 | cpu_relax();\ | ||
| 468 | }\ | ||
| 469 | } | ||
| 470 | |||
| 471 | static void iommu_set_root_entry(struct intel_iommu *iommu) | ||
| 472 | { | ||
| 473 | void *addr; | ||
| 474 | u32 cmd, sts; | ||
| 475 | unsigned long flag; | ||
| 476 | |||
| 477 | addr = iommu->root_entry; | ||
| 478 | |||
| 479 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 480 | dmar_writeq(iommu->reg + DMAR_RTADDR_REG, virt_to_phys(addr)); | ||
| 481 | |||
| 482 | cmd = iommu->gcmd | DMA_GCMD_SRTP; | ||
| 483 | writel(cmd, iommu->reg + DMAR_GCMD_REG); | ||
| 484 | |||
| 485 | /* Make sure hardware complete it */ | ||
| 486 | IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, | ||
| 487 | readl, (sts & DMA_GSTS_RTPS), sts); | ||
| 488 | |||
| 489 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 490 | } | ||
| 491 | |||
| 492 | static void iommu_flush_write_buffer(struct intel_iommu *iommu) | ||
| 493 | { | ||
| 494 | u32 val; | ||
| 495 | unsigned long flag; | ||
| 496 | |||
| 497 | if (!cap_rwbf(iommu->cap)) | ||
| 498 | return; | ||
| 499 | val = iommu->gcmd | DMA_GCMD_WBF; | ||
| 500 | |||
| 501 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 502 | writel(val, iommu->reg + DMAR_GCMD_REG); | ||
| 503 | |||
| 504 | /* Make sure hardware complete it */ | ||
| 505 | IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, | ||
| 506 | readl, (!(val & DMA_GSTS_WBFS)), val); | ||
| 507 | |||
| 508 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 509 | } | ||
| 510 | |||
| 511 | /* return value determine if we need a write buffer flush */ | ||
| 512 | static int __iommu_flush_context(struct intel_iommu *iommu, | ||
| 513 | u16 did, u16 source_id, u8 function_mask, u64 type, | ||
| 514 | int non_present_entry_flush) | ||
| 515 | { | ||
| 516 | u64 val = 0; | ||
| 517 | unsigned long flag; | ||
| 518 | |||
| 519 | /* | ||
| 520 | * In the non-present entry flush case, if hardware doesn't cache | ||
| 521 | * non-present entry we do nothing and if hardware cache non-present | ||
| 522 | * entry, we flush entries of domain 0 (the domain id is used to cache | ||
| 523 | * any non-present entries) | ||
| 524 | */ | ||
| 525 | if (non_present_entry_flush) { | ||
| 526 | if (!cap_caching_mode(iommu->cap)) | ||
| 527 | return 1; | ||
| 528 | else | ||
| 529 | did = 0; | ||
| 530 | } | ||
| 531 | |||
| 532 | switch (type) { | ||
| 533 | case DMA_CCMD_GLOBAL_INVL: | ||
| 534 | val = DMA_CCMD_GLOBAL_INVL; | ||
| 535 | break; | ||
| 536 | case DMA_CCMD_DOMAIN_INVL: | ||
| 537 | val = DMA_CCMD_DOMAIN_INVL|DMA_CCMD_DID(did); | ||
| 538 | break; | ||
| 539 | case DMA_CCMD_DEVICE_INVL: | ||
| 540 | val = DMA_CCMD_DEVICE_INVL|DMA_CCMD_DID(did) | ||
| 541 | | DMA_CCMD_SID(source_id) | DMA_CCMD_FM(function_mask); | ||
| 542 | break; | ||
| 543 | default: | ||
| 544 | BUG(); | ||
| 545 | } | ||
| 546 | val |= DMA_CCMD_ICC; | ||
| 547 | |||
| 548 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 549 | dmar_writeq(iommu->reg + DMAR_CCMD_REG, val); | ||
| 550 | |||
| 551 | /* Make sure hardware complete it */ | ||
| 552 | IOMMU_WAIT_OP(iommu, DMAR_CCMD_REG, | ||
| 553 | dmar_readq, (!(val & DMA_CCMD_ICC)), val); | ||
| 554 | |||
| 555 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 556 | |||
| 557 | /* flush context entry will implictly flush write buffer */ | ||
| 558 | return 0; | ||
| 559 | } | ||
| 560 | |||
| 561 | static int inline iommu_flush_context_global(struct intel_iommu *iommu, | ||
| 562 | int non_present_entry_flush) | ||
| 563 | { | ||
| 564 | return __iommu_flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL, | ||
| 565 | non_present_entry_flush); | ||
| 566 | } | ||
| 567 | |||
| 568 | static int inline iommu_flush_context_domain(struct intel_iommu *iommu, u16 did, | ||
| 569 | int non_present_entry_flush) | ||
| 570 | { | ||
| 571 | return __iommu_flush_context(iommu, did, 0, 0, DMA_CCMD_DOMAIN_INVL, | ||
| 572 | non_present_entry_flush); | ||
| 573 | } | ||
| 574 | |||
| 575 | static int inline iommu_flush_context_device(struct intel_iommu *iommu, | ||
| 576 | u16 did, u16 source_id, u8 function_mask, int non_present_entry_flush) | ||
| 577 | { | ||
| 578 | return __iommu_flush_context(iommu, did, source_id, function_mask, | ||
| 579 | DMA_CCMD_DEVICE_INVL, non_present_entry_flush); | ||
| 580 | } | ||
| 581 | |||
| 582 | /* return value determine if we need a write buffer flush */ | ||
| 583 | static int __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did, | ||
| 584 | u64 addr, unsigned int size_order, u64 type, | ||
| 585 | int non_present_entry_flush) | ||
| 586 | { | ||
| 587 | int tlb_offset = ecap_iotlb_offset(iommu->ecap); | ||
| 588 | u64 val = 0, val_iva = 0; | ||
| 589 | unsigned long flag; | ||
| 590 | |||
| 591 | /* | ||
| 592 | * In the non-present entry flush case, if hardware doesn't cache | ||
| 593 | * non-present entry we do nothing and if hardware cache non-present | ||
| 594 | * entry, we flush entries of domain 0 (the domain id is used to cache | ||
| 595 | * any non-present entries) | ||
| 596 | */ | ||
| 597 | if (non_present_entry_flush) { | ||
| 598 | if (!cap_caching_mode(iommu->cap)) | ||
| 599 | return 1; | ||
| 600 | else | ||
| 601 | did = 0; | ||
| 602 | } | ||
| 603 | |||
| 604 | switch (type) { | ||
| 605 | case DMA_TLB_GLOBAL_FLUSH: | ||
| 606 | /* global flush doesn't need set IVA_REG */ | ||
| 607 | val = DMA_TLB_GLOBAL_FLUSH|DMA_TLB_IVT; | ||
| 608 | break; | ||
| 609 | case DMA_TLB_DSI_FLUSH: | ||
| 610 | val = DMA_TLB_DSI_FLUSH|DMA_TLB_IVT|DMA_TLB_DID(did); | ||
| 611 | break; | ||
| 612 | case DMA_TLB_PSI_FLUSH: | ||
| 613 | val = DMA_TLB_PSI_FLUSH|DMA_TLB_IVT|DMA_TLB_DID(did); | ||
| 614 | /* Note: always flush non-leaf currently */ | ||
| 615 | val_iva = size_order | addr; | ||
| 616 | break; | ||
| 617 | default: | ||
| 618 | BUG(); | ||
| 619 | } | ||
| 620 | /* Note: set drain read/write */ | ||
| 621 | #if 0 | ||
| 622 | /* | ||
| 623 | * This is probably to be super secure.. Looks like we can | ||
| 624 | * ignore it without any impact. | ||
| 625 | */ | ||
| 626 | if (cap_read_drain(iommu->cap)) | ||
| 627 | val |= DMA_TLB_READ_DRAIN; | ||
| 628 | #endif | ||
| 629 | if (cap_write_drain(iommu->cap)) | ||
| 630 | val |= DMA_TLB_WRITE_DRAIN; | ||
| 631 | |||
| 632 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 633 | /* Note: Only uses first TLB reg currently */ | ||
| 634 | if (val_iva) | ||
| 635 | dmar_writeq(iommu->reg + tlb_offset, val_iva); | ||
| 636 | dmar_writeq(iommu->reg + tlb_offset + 8, val); | ||
| 637 | |||
| 638 | /* Make sure hardware complete it */ | ||
| 639 | IOMMU_WAIT_OP(iommu, tlb_offset + 8, | ||
| 640 | dmar_readq, (!(val & DMA_TLB_IVT)), val); | ||
| 641 | |||
| 642 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 643 | |||
| 644 | /* check IOTLB invalidation granularity */ | ||
| 645 | if (DMA_TLB_IAIG(val) == 0) | ||
| 646 | printk(KERN_ERR"IOMMU: flush IOTLB failed\n"); | ||
| 647 | if (DMA_TLB_IAIG(val) != DMA_TLB_IIRG(type)) | ||
| 648 | pr_debug("IOMMU: tlb flush request %Lx, actual %Lx\n", | ||
| 649 | DMA_TLB_IIRG(type), DMA_TLB_IAIG(val)); | ||
| 650 | /* flush context entry will implictly flush write buffer */ | ||
| 651 | return 0; | ||
| 652 | } | ||
| 653 | |||
| 654 | static int inline iommu_flush_iotlb_global(struct intel_iommu *iommu, | ||
| 655 | int non_present_entry_flush) | ||
| 656 | { | ||
| 657 | return __iommu_flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH, | ||
| 658 | non_present_entry_flush); | ||
| 659 | } | ||
| 660 | |||
| 661 | static int inline iommu_flush_iotlb_dsi(struct intel_iommu *iommu, u16 did, | ||
| 662 | int non_present_entry_flush) | ||
| 663 | { | ||
| 664 | return __iommu_flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH, | ||
| 665 | non_present_entry_flush); | ||
| 666 | } | ||
| 667 | |||
| 668 | static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did, | ||
| 669 | u64 addr, unsigned int pages, int non_present_entry_flush) | ||
| 670 | { | ||
| 671 | unsigned int mask; | ||
| 672 | |||
| 673 | BUG_ON(addr & (~PAGE_MASK_4K)); | ||
| 674 | BUG_ON(pages == 0); | ||
| 675 | |||
| 676 | /* Fallback to domain selective flush if no PSI support */ | ||
| 677 | if (!cap_pgsel_inv(iommu->cap)) | ||
| 678 | return iommu_flush_iotlb_dsi(iommu, did, | ||
| 679 | non_present_entry_flush); | ||
| 680 | |||
| 681 | /* | ||
| 682 | * PSI requires page size to be 2 ^ x, and the base address is naturally | ||
| 683 | * aligned to the size | ||
| 684 | */ | ||
| 685 | mask = ilog2(__roundup_pow_of_two(pages)); | ||
| 686 | /* Fallback to domain selective flush if size is too big */ | ||
| 687 | if (mask > cap_max_amask_val(iommu->cap)) | ||
| 688 | return iommu_flush_iotlb_dsi(iommu, did, | ||
| 689 | non_present_entry_flush); | ||
| 690 | |||
| 691 | return __iommu_flush_iotlb(iommu, did, addr, mask, | ||
| 692 | DMA_TLB_PSI_FLUSH, non_present_entry_flush); | ||
| 693 | } | ||
| 694 | |||
| 695 | static int iommu_enable_translation(struct intel_iommu *iommu) | ||
| 696 | { | ||
| 697 | u32 sts; | ||
| 698 | unsigned long flags; | ||
| 699 | |||
| 700 | spin_lock_irqsave(&iommu->register_lock, flags); | ||
| 701 | writel(iommu->gcmd|DMA_GCMD_TE, iommu->reg + DMAR_GCMD_REG); | ||
| 702 | |||
| 703 | /* Make sure hardware complete it */ | ||
| 704 | IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, | ||
| 705 | readl, (sts & DMA_GSTS_TES), sts); | ||
| 706 | |||
| 707 | iommu->gcmd |= DMA_GCMD_TE; | ||
| 708 | spin_unlock_irqrestore(&iommu->register_lock, flags); | ||
| 709 | return 0; | ||
| 710 | } | ||
| 711 | |||
| 712 | static int iommu_disable_translation(struct intel_iommu *iommu) | ||
| 713 | { | ||
| 714 | u32 sts; | ||
| 715 | unsigned long flag; | ||
| 716 | |||
| 717 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 718 | iommu->gcmd &= ~DMA_GCMD_TE; | ||
| 719 | writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); | ||
| 720 | |||
| 721 | /* Make sure hardware complete it */ | ||
| 722 | IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, | ||
| 723 | readl, (!(sts & DMA_GSTS_TES)), sts); | ||
| 724 | |||
| 725 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 726 | return 0; | ||
| 727 | } | ||
| 728 | |||
| 729 | /* iommu interrupt handling. Most stuff are MSI-like. */ | ||
| 730 | |||
| 731 | static char *fault_reason_strings[] = | ||
| 732 | { | ||
| 733 | "Software", | ||
| 734 | "Present bit in root entry is clear", | ||
| 735 | "Present bit in context entry is clear", | ||
| 736 | "Invalid context entry", | ||
| 737 | "Access beyond MGAW", | ||
| 738 | "PTE Write access is not set", | ||
| 739 | "PTE Read access is not set", | ||
| 740 | "Next page table ptr is invalid", | ||
| 741 | "Root table address invalid", | ||
| 742 | "Context table ptr is invalid", | ||
| 743 | "non-zero reserved fields in RTP", | ||
| 744 | "non-zero reserved fields in CTP", | ||
| 745 | "non-zero reserved fields in PTE", | ||
| 746 | "Unknown" | ||
| 747 | }; | ||
| 748 | #define MAX_FAULT_REASON_IDX ARRAY_SIZE(fault_reason_strings) | ||
| 749 | |||
| 750 | char *dmar_get_fault_reason(u8 fault_reason) | ||
| 751 | { | ||
| 752 | if (fault_reason > MAX_FAULT_REASON_IDX) | ||
| 753 | return fault_reason_strings[MAX_FAULT_REASON_IDX]; | ||
| 754 | else | ||
| 755 | return fault_reason_strings[fault_reason]; | ||
| 756 | } | ||
| 757 | |||
| 758 | void dmar_msi_unmask(unsigned int irq) | ||
| 759 | { | ||
| 760 | struct intel_iommu *iommu = get_irq_data(irq); | ||
| 761 | unsigned long flag; | ||
| 762 | |||
| 763 | /* unmask it */ | ||
| 764 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 765 | writel(0, iommu->reg + DMAR_FECTL_REG); | ||
| 766 | /* Read a reg to force flush the post write */ | ||
| 767 | readl(iommu->reg + DMAR_FECTL_REG); | ||
| 768 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 769 | } | ||
| 770 | |||
| 771 | void dmar_msi_mask(unsigned int irq) | ||
| 772 | { | ||
| 773 | unsigned long flag; | ||
| 774 | struct intel_iommu *iommu = get_irq_data(irq); | ||
| 775 | |||
| 776 | /* mask it */ | ||
| 777 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 778 | writel(DMA_FECTL_IM, iommu->reg + DMAR_FECTL_REG); | ||
| 779 | /* Read a reg to force flush the post write */ | ||
| 780 | readl(iommu->reg + DMAR_FECTL_REG); | ||
| 781 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 782 | } | ||
| 783 | |||
| 784 | void dmar_msi_write(int irq, struct msi_msg *msg) | ||
| 785 | { | ||
| 786 | struct intel_iommu *iommu = get_irq_data(irq); | ||
| 787 | unsigned long flag; | ||
| 788 | |||
| 789 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 790 | writel(msg->data, iommu->reg + DMAR_FEDATA_REG); | ||
| 791 | writel(msg->address_lo, iommu->reg + DMAR_FEADDR_REG); | ||
| 792 | writel(msg->address_hi, iommu->reg + DMAR_FEUADDR_REG); | ||
| 793 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 794 | } | ||
| 795 | |||
| 796 | void dmar_msi_read(int irq, struct msi_msg *msg) | ||
| 797 | { | ||
| 798 | struct intel_iommu *iommu = get_irq_data(irq); | ||
| 799 | unsigned long flag; | ||
| 800 | |||
| 801 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 802 | msg->data = readl(iommu->reg + DMAR_FEDATA_REG); | ||
| 803 | msg->address_lo = readl(iommu->reg + DMAR_FEADDR_REG); | ||
| 804 | msg->address_hi = readl(iommu->reg + DMAR_FEUADDR_REG); | ||
| 805 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 806 | } | ||
| 807 | |||
| 808 | static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type, | ||
| 809 | u8 fault_reason, u16 source_id, u64 addr) | ||
| 810 | { | ||
| 811 | char *reason; | ||
| 812 | |||
| 813 | reason = dmar_get_fault_reason(fault_reason); | ||
| 814 | |||
| 815 | printk(KERN_ERR | ||
| 816 | "DMAR:[%s] Request device [%02x:%02x.%d] " | ||
| 817 | "fault addr %llx \n" | ||
| 818 | "DMAR:[fault reason %02d] %s\n", | ||
| 819 | (type ? "DMA Read" : "DMA Write"), | ||
| 820 | (source_id >> 8), PCI_SLOT(source_id & 0xFF), | ||
| 821 | PCI_FUNC(source_id & 0xFF), addr, fault_reason, reason); | ||
| 822 | return 0; | ||
| 823 | } | ||
| 824 | |||
| 825 | #define PRIMARY_FAULT_REG_LEN (16) | ||
| 826 | static irqreturn_t iommu_page_fault(int irq, void *dev_id) | ||
| 827 | { | ||
| 828 | struct intel_iommu *iommu = dev_id; | ||
| 829 | int reg, fault_index; | ||
| 830 | u32 fault_status; | ||
| 831 | unsigned long flag; | ||
| 832 | |||
| 833 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 834 | fault_status = readl(iommu->reg + DMAR_FSTS_REG); | ||
| 835 | |||
| 836 | /* TBD: ignore advanced fault log currently */ | ||
| 837 | if (!(fault_status & DMA_FSTS_PPF)) | ||
| 838 | goto clear_overflow; | ||
| 839 | |||
| 840 | fault_index = dma_fsts_fault_record_index(fault_status); | ||
| 841 | reg = cap_fault_reg_offset(iommu->cap); | ||
| 842 | while (1) { | ||
| 843 | u8 fault_reason; | ||
| 844 | u16 source_id; | ||
| 845 | u64 guest_addr; | ||
| 846 | int type; | ||
| 847 | u32 data; | ||
| 848 | |||
| 849 | /* highest 32 bits */ | ||
| 850 | data = readl(iommu->reg + reg + | ||
| 851 | fault_index * PRIMARY_FAULT_REG_LEN + 12); | ||
| 852 | if (!(data & DMA_FRCD_F)) | ||
| 853 | break; | ||
| 854 | |||
| 855 | fault_reason = dma_frcd_fault_reason(data); | ||
| 856 | type = dma_frcd_type(data); | ||
| 857 | |||
| 858 | data = readl(iommu->reg + reg + | ||
| 859 | fault_index * PRIMARY_FAULT_REG_LEN + 8); | ||
| 860 | source_id = dma_frcd_source_id(data); | ||
| 861 | |||
| 862 | guest_addr = dmar_readq(iommu->reg + reg + | ||
| 863 | fault_index * PRIMARY_FAULT_REG_LEN); | ||
| 864 | guest_addr = dma_frcd_page_addr(guest_addr); | ||
| 865 | /* clear the fault */ | ||
| 866 | writel(DMA_FRCD_F, iommu->reg + reg + | ||
| 867 | fault_index * PRIMARY_FAULT_REG_LEN + 12); | ||
| 868 | |||
| 869 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 870 | |||
| 871 | iommu_page_fault_do_one(iommu, type, fault_reason, | ||
| 872 | source_id, guest_addr); | ||
| 873 | |||
| 874 | fault_index++; | ||
| 875 | if (fault_index > cap_num_fault_regs(iommu->cap)) | ||
| 876 | fault_index = 0; | ||
| 877 | spin_lock_irqsave(&iommu->register_lock, flag); | ||
| 878 | } | ||
| 879 | clear_overflow: | ||
| 880 | /* clear primary fault overflow */ | ||
| 881 | fault_status = readl(iommu->reg + DMAR_FSTS_REG); | ||
| 882 | if (fault_status & DMA_FSTS_PFO) | ||
| 883 | writel(DMA_FSTS_PFO, iommu->reg + DMAR_FSTS_REG); | ||
| 884 | |||
| 885 | spin_unlock_irqrestore(&iommu->register_lock, flag); | ||
| 886 | return IRQ_HANDLED; | ||
| 887 | } | ||
| 888 | |||
| 889 | int dmar_set_interrupt(struct intel_iommu *iommu) | ||
| 890 | { | ||
| 891 | int irq, ret; | ||
| 892 | |||
| 893 | irq = create_irq(); | ||
| 894 | if (!irq) { | ||
| 895 | printk(KERN_ERR "IOMMU: no free vectors\n"); | ||
| 896 | return -EINVAL; | ||
| 897 | } | ||
| 898 | |||
| 899 | set_irq_data(irq, iommu); | ||
| 900 | iommu->irq = irq; | ||
| 901 | |||
| 902 | ret = arch_setup_dmar_msi(irq); | ||
| 903 | if (ret) { | ||
| 904 | set_irq_data(irq, NULL); | ||
| 905 | iommu->irq = 0; | ||
| 906 | destroy_irq(irq); | ||
| 907 | return 0; | ||
| 908 | } | ||
| 909 | |||
| 910 | /* Force fault register is cleared */ | ||
| 911 | iommu_page_fault(irq, iommu); | ||
| 912 | |||
| 913 | ret = request_irq(irq, iommu_page_fault, 0, iommu->name, iommu); | ||
| 914 | if (ret) | ||
| 915 | printk(KERN_ERR "IOMMU: can't request irq\n"); | ||
| 916 | return ret; | ||
| 917 | } | ||
| 918 | |||
| 919 | static int iommu_init_domains(struct intel_iommu *iommu) | ||
| 920 | { | ||
| 921 | unsigned long ndomains; | ||
| 922 | unsigned long nlongs; | ||
| 923 | |||
| 924 | ndomains = cap_ndoms(iommu->cap); | ||
| 925 | pr_debug("Number of Domains supportd <%ld>\n", ndomains); | ||
| 926 | nlongs = BITS_TO_LONGS(ndomains); | ||
| 927 | |||
| 928 | /* TBD: there might be 64K domains, | ||
| 929 | * consider other allocation for future chip | ||
| 930 | */ | ||
| 931 | iommu->domain_ids = kcalloc(nlongs, sizeof(unsigned long), GFP_KERNEL); | ||
| 932 | if (!iommu->domain_ids) { | ||
| 933 | printk(KERN_ERR "Allocating domain id array failed\n"); | ||
| 934 | return -ENOMEM; | ||
| 935 | } | ||
| 936 | iommu->domains = kcalloc(ndomains, sizeof(struct dmar_domain *), | ||
| 937 | GFP_KERNEL); | ||
| 938 | if (!iommu->domains) { | ||
| 939 | printk(KERN_ERR "Allocating domain array failed\n"); | ||
| 940 | kfree(iommu->domain_ids); | ||
| 941 | return -ENOMEM; | ||
| 942 | } | ||
| 943 | |||
| 944 | /* | ||
| 945 | * if Caching mode is set, then invalid translations are tagged | ||
| 946 | * with domainid 0. Hence we need to pre-allocate it. | ||
| 947 | */ | ||
| 948 | if (cap_caching_mode(iommu->cap)) | ||
| 949 | set_bit(0, iommu->domain_ids); | ||
| 950 | return 0; | ||
| 951 | } | ||
| 952 | |||
| 953 | static struct intel_iommu *alloc_iommu(struct dmar_drhd_unit *drhd) | ||
| 954 | { | ||
| 955 | struct intel_iommu *iommu; | ||
| 956 | int ret; | ||
| 957 | int map_size; | ||
| 958 | u32 ver; | ||
| 959 | |||
| 960 | iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); | ||
| 961 | if (!iommu) | ||
| 962 | return NULL; | ||
| 963 | iommu->reg = ioremap(drhd->reg_base_addr, PAGE_SIZE_4K); | ||
| 964 | if (!iommu->reg) { | ||
| 965 | printk(KERN_ERR "IOMMU: can't map the region\n"); | ||
| 966 | goto error; | ||
| 967 | } | ||
| 968 | iommu->cap = dmar_readq(iommu->reg + DMAR_CAP_REG); | ||
| 969 | iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG); | ||
| 970 | |||
| 971 | /* the registers might be more than one page */ | ||
| 972 | map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap), | ||
| 973 | cap_max_fault_reg_offset(iommu->cap)); | ||
| 974 | map_size = PAGE_ALIGN_4K(map_size); | ||
| 975 | if (map_size > PAGE_SIZE_4K) { | ||
| 976 | iounmap(iommu->reg); | ||
| 977 | iommu->reg = ioremap(drhd->reg_base_addr, map_size); | ||
| 978 | if (!iommu->reg) { | ||
| 979 | printk(KERN_ERR "IOMMU: can't map the region\n"); | ||
| 980 | goto error; | ||
| 981 | } | ||
| 982 | } | ||
| 983 | |||
| 984 | ver = readl(iommu->reg + DMAR_VER_REG); | ||
| 985 | pr_debug("IOMMU %llx: ver %d:%d cap %llx ecap %llx\n", | ||
| 986 | drhd->reg_base_addr, DMAR_VER_MAJOR(ver), DMAR_VER_MINOR(ver), | ||
| 987 | iommu->cap, iommu->ecap); | ||
| 988 | ret = iommu_init_domains(iommu); | ||
| 989 | if (ret) | ||
| 990 | goto error_unmap; | ||
| 991 | spin_lock_init(&iommu->lock); | ||
| 992 | spin_lock_init(&iommu->register_lock); | ||
| 993 | |||
| 994 | drhd->iommu = iommu; | ||
| 995 | return iommu; | ||
| 996 | error_unmap: | ||
| 997 | iounmap(iommu->reg); | ||
| 998 | iommu->reg = 0; | ||
| 999 | error: | ||
| 1000 | kfree(iommu); | ||
| 1001 | return NULL; | ||
| 1002 | } | ||
| 1003 | |||
| 1004 | static void domain_exit(struct dmar_domain *domain); | ||
| 1005 | static void free_iommu(struct intel_iommu *iommu) | ||
| 1006 | { | ||
| 1007 | struct dmar_domain *domain; | ||
| 1008 | int i; | ||
| 1009 | |||
| 1010 | if (!iommu) | ||
| 1011 | return; | ||
| 1012 | |||
| 1013 | i = find_first_bit(iommu->domain_ids, cap_ndoms(iommu->cap)); | ||
| 1014 | for (; i < cap_ndoms(iommu->cap); ) { | ||
| 1015 | domain = iommu->domains[i]; | ||
| 1016 | clear_bit(i, iommu->domain_ids); | ||
| 1017 | domain_exit(domain); | ||
| 1018 | i = find_next_bit(iommu->domain_ids, | ||
| 1019 | cap_ndoms(iommu->cap), i+1); | ||
| 1020 | } | ||
| 1021 | |||
| 1022 | if (iommu->gcmd & DMA_GCMD_TE) | ||
| 1023 | iommu_disable_translation(iommu); | ||
| 1024 | |||
| 1025 | if (iommu->irq) { | ||
| 1026 | set_irq_data(iommu->irq, NULL); | ||
| 1027 | /* This will mask the irq */ | ||
| 1028 | free_irq(iommu->irq, iommu); | ||
| 1029 | destroy_irq(iommu->irq); | ||
| 1030 | } | ||
| 1031 | |||
| 1032 | kfree(iommu->domains); | ||
| 1033 | kfree(iommu->domain_ids); | ||
| 1034 | |||
| 1035 | /* free context mapping */ | ||
| 1036 | free_context_table(iommu); | ||
| 1037 | |||
| 1038 | if (iommu->reg) | ||
| 1039 | iounmap(iommu->reg); | ||
| 1040 | kfree(iommu); | ||
| 1041 | } | ||
| 1042 | |||
| 1043 | static struct dmar_domain * iommu_alloc_domain(struct intel_iommu *iommu) | ||
| 1044 | { | ||
| 1045 | unsigned long num; | ||
| 1046 | unsigned long ndomains; | ||
| 1047 | struct dmar_domain *domain; | ||
| 1048 | unsigned long flags; | ||
| 1049 | |||
| 1050 | domain = alloc_domain_mem(); | ||
| 1051 | if (!domain) | ||
| 1052 | return NULL; | ||
| 1053 | |||
| 1054 | ndomains = cap_ndoms(iommu->cap); | ||
| 1055 | |||
| 1056 | spin_lock_irqsave(&iommu->lock, flags); | ||
| 1057 | num = find_first_zero_bit(iommu->domain_ids, ndomains); | ||
| 1058 | if (num >= ndomains) { | ||
| 1059 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 1060 | free_domain_mem(domain); | ||
| 1061 | printk(KERN_ERR "IOMMU: no free domain ids\n"); | ||
| 1062 | return NULL; | ||
| 1063 | } | ||
| 1064 | |||
| 1065 | set_bit(num, iommu->domain_ids); | ||
| 1066 | domain->id = num; | ||
| 1067 | domain->iommu = iommu; | ||
| 1068 | iommu->domains[num] = domain; | ||
| 1069 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 1070 | |||
| 1071 | return domain; | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | static void iommu_free_domain(struct dmar_domain *domain) | ||
| 1075 | { | ||
| 1076 | unsigned long flags; | ||
| 1077 | |||
| 1078 | spin_lock_irqsave(&domain->iommu->lock, flags); | ||
| 1079 | clear_bit(domain->id, domain->iommu->domain_ids); | ||
| 1080 | spin_unlock_irqrestore(&domain->iommu->lock, flags); | ||
| 1081 | } | ||
| 1082 | |||
| 1083 | static struct iova_domain reserved_iova_list; | ||
| 1084 | |||
| 1085 | static void dmar_init_reserved_ranges(void) | ||
| 1086 | { | ||
| 1087 | struct pci_dev *pdev = NULL; | ||
| 1088 | struct iova *iova; | ||
| 1089 | int i; | ||
| 1090 | u64 addr, size; | ||
| 1091 | |||
| 1092 | init_iova_domain(&reserved_iova_list); | ||
| 1093 | |||
| 1094 | /* IOAPIC ranges shouldn't be accessed by DMA */ | ||
| 1095 | iova = reserve_iova(&reserved_iova_list, IOVA_PFN(IOAPIC_RANGE_START), | ||
| 1096 | IOVA_PFN(IOAPIC_RANGE_END)); | ||
| 1097 | if (!iova) | ||
| 1098 | printk(KERN_ERR "Reserve IOAPIC range failed\n"); | ||
| 1099 | |||
| 1100 | /* Reserve all PCI MMIO to avoid peer-to-peer access */ | ||
| 1101 | for_each_pci_dev(pdev) { | ||
| 1102 | struct resource *r; | ||
| 1103 | |||
| 1104 | for (i = 0; i < PCI_NUM_RESOURCES; i++) { | ||
| 1105 | r = &pdev->resource[i]; | ||
| 1106 | if (!r->flags || !(r->flags & IORESOURCE_MEM)) | ||
| 1107 | continue; | ||
| 1108 | addr = r->start; | ||
| 1109 | addr &= PAGE_MASK_4K; | ||
| 1110 | size = r->end - addr; | ||
| 1111 | size = PAGE_ALIGN_4K(size); | ||
| 1112 | iova = reserve_iova(&reserved_iova_list, IOVA_PFN(addr), | ||
| 1113 | IOVA_PFN(size + addr) - 1); | ||
| 1114 | if (!iova) | ||
| 1115 | printk(KERN_ERR "Reserve iova failed\n"); | ||
| 1116 | } | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | } | ||
| 1120 | |||
| 1121 | static void domain_reserve_special_ranges(struct dmar_domain *domain) | ||
| 1122 | { | ||
| 1123 | copy_reserved_iova(&reserved_iova_list, &domain->iovad); | ||
| 1124 | } | ||
| 1125 | |||
| 1126 | static inline int guestwidth_to_adjustwidth(int gaw) | ||
| 1127 | { | ||
| 1128 | int agaw; | ||
| 1129 | int r = (gaw - 12) % 9; | ||
| 1130 | |||
| 1131 | if (r == 0) | ||
| 1132 | agaw = gaw; | ||
| 1133 | else | ||
| 1134 | agaw = gaw + 9 - r; | ||
| 1135 | if (agaw > 64) | ||
| 1136 | agaw = 64; | ||
| 1137 | return agaw; | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | static int domain_init(struct dmar_domain *domain, int guest_width) | ||
| 1141 | { | ||
| 1142 | struct intel_iommu *iommu; | ||
| 1143 | int adjust_width, agaw; | ||
| 1144 | unsigned long sagaw; | ||
| 1145 | |||
| 1146 | init_iova_domain(&domain->iovad); | ||
| 1147 | spin_lock_init(&domain->mapping_lock); | ||
| 1148 | |||
| 1149 | domain_reserve_special_ranges(domain); | ||
| 1150 | |||
| 1151 | /* calculate AGAW */ | ||
| 1152 | iommu = domain->iommu; | ||
| 1153 | if (guest_width > cap_mgaw(iommu->cap)) | ||
| 1154 | guest_width = cap_mgaw(iommu->cap); | ||
| 1155 | domain->gaw = guest_width; | ||
| 1156 | adjust_width = guestwidth_to_adjustwidth(guest_width); | ||
| 1157 | agaw = width_to_agaw(adjust_width); | ||
| 1158 | sagaw = cap_sagaw(iommu->cap); | ||
| 1159 | if (!test_bit(agaw, &sagaw)) { | ||
| 1160 | /* hardware doesn't support it, choose a bigger one */ | ||
| 1161 | pr_debug("IOMMU: hardware doesn't support agaw %d\n", agaw); | ||
| 1162 | agaw = find_next_bit(&sagaw, 5, agaw); | ||
| 1163 | if (agaw >= 5) | ||
| 1164 | return -ENODEV; | ||
| 1165 | } | ||
| 1166 | domain->agaw = agaw; | ||
| 1167 | INIT_LIST_HEAD(&domain->devices); | ||
| 1168 | |||
| 1169 | /* always allocate the top pgd */ | ||
| 1170 | domain->pgd = (struct dma_pte *)alloc_pgtable_page(); | ||
| 1171 | if (!domain->pgd) | ||
| 1172 | return -ENOMEM; | ||
| 1173 | __iommu_flush_cache(iommu, domain->pgd, PAGE_SIZE_4K); | ||
| 1174 | return 0; | ||
| 1175 | } | ||
| 1176 | |||
| 1177 | static void domain_exit(struct dmar_domain *domain) | ||
| 1178 | { | ||
| 1179 | u64 end; | ||
| 1180 | |||
| 1181 | /* Domain 0 is reserved, so dont process it */ | ||
| 1182 | if (!domain) | ||
| 1183 | return; | ||
| 1184 | |||
| 1185 | domain_remove_dev_info(domain); | ||
| 1186 | /* destroy iovas */ | ||
| 1187 | put_iova_domain(&domain->iovad); | ||
| 1188 | end = DOMAIN_MAX_ADDR(domain->gaw); | ||
| 1189 | end = end & (~PAGE_MASK_4K); | ||
| 1190 | |||
| 1191 | /* clear ptes */ | ||
| 1192 | dma_pte_clear_range(domain, 0, end); | ||
| 1193 | |||
| 1194 | /* free page tables */ | ||
| 1195 | dma_pte_free_pagetable(domain, 0, end); | ||
| 1196 | |||
| 1197 | iommu_free_domain(domain); | ||
| 1198 | free_domain_mem(domain); | ||
| 1199 | } | ||
| 1200 | |||
| 1201 | static int domain_context_mapping_one(struct dmar_domain *domain, | ||
| 1202 | u8 bus, u8 devfn) | ||
| 1203 | { | ||
| 1204 | struct context_entry *context; | ||
| 1205 | struct intel_iommu *iommu = domain->iommu; | ||
| 1206 | unsigned long flags; | ||
| 1207 | |||
| 1208 | pr_debug("Set context mapping for %02x:%02x.%d\n", | ||
| 1209 | bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); | ||
| 1210 | BUG_ON(!domain->pgd); | ||
| 1211 | context = device_to_context_entry(iommu, bus, devfn); | ||
| 1212 | if (!context) | ||
| 1213 | return -ENOMEM; | ||
| 1214 | spin_lock_irqsave(&iommu->lock, flags); | ||
| 1215 | if (context_present(*context)) { | ||
| 1216 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 1217 | return 0; | ||
| 1218 | } | ||
| 1219 | |||
| 1220 | context_set_domain_id(*context, domain->id); | ||
| 1221 | context_set_address_width(*context, domain->agaw); | ||
| 1222 | context_set_address_root(*context, virt_to_phys(domain->pgd)); | ||
| 1223 | context_set_translation_type(*context, CONTEXT_TT_MULTI_LEVEL); | ||
| 1224 | context_set_fault_enable(*context); | ||
| 1225 | context_set_present(*context); | ||
| 1226 | __iommu_flush_cache(iommu, context, sizeof(*context)); | ||
| 1227 | |||
| 1228 | /* it's a non-present to present mapping */ | ||
| 1229 | if (iommu_flush_context_device(iommu, domain->id, | ||
| 1230 | (((u16)bus) << 8) | devfn, DMA_CCMD_MASK_NOBIT, 1)) | ||
| 1231 | iommu_flush_write_buffer(iommu); | ||
| 1232 | else | ||
| 1233 | iommu_flush_iotlb_dsi(iommu, 0, 0); | ||
| 1234 | spin_unlock_irqrestore(&iommu->lock, flags); | ||
| 1235 | return 0; | ||
| 1236 | } | ||
| 1237 | |||
| 1238 | static int | ||
| 1239 | domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev) | ||
| 1240 | { | ||
| 1241 | int ret; | ||
| 1242 | struct pci_dev *tmp, *parent; | ||
| 1243 | |||
| 1244 | ret = domain_context_mapping_one(domain, pdev->bus->number, | ||
| 1245 | pdev->devfn); | ||
| 1246 | if (ret) | ||
| 1247 | return ret; | ||
| 1248 | |||
| 1249 | /* dependent device mapping */ | ||
| 1250 | tmp = pci_find_upstream_pcie_bridge(pdev); | ||
| 1251 | if (!tmp) | ||
| 1252 | return 0; | ||
| 1253 | /* Secondary interface's bus number and devfn 0 */ | ||
| 1254 | parent = pdev->bus->self; | ||
| 1255 | while (parent != tmp) { | ||
| 1256 | ret = domain_context_mapping_one(domain, parent->bus->number, | ||
| 1257 | parent->devfn); | ||
| 1258 | if (ret) | ||
| 1259 | return ret; | ||
| 1260 | parent = parent->bus->self; | ||
| 1261 | } | ||
| 1262 | if (tmp->is_pcie) /* this is a PCIE-to-PCI bridge */ | ||
| 1263 | return domain_context_mapping_one(domain, | ||
| 1264 | tmp->subordinate->number, 0); | ||
| 1265 | else /* this is a legacy PCI bridge */ | ||
| 1266 | return domain_context_mapping_one(domain, | ||
| 1267 | tmp->bus->number, tmp->devfn); | ||
| 1268 | } | ||
| 1269 | |||
| 1270 | static int domain_context_mapped(struct dmar_domain *domain, | ||
| 1271 | struct pci_dev *pdev) | ||
| 1272 | { | ||
| 1273 | int ret; | ||
| 1274 | struct pci_dev *tmp, *parent; | ||
| 1275 | |||
| 1276 | ret = device_context_mapped(domain->iommu, | ||
| 1277 | pdev->bus->number, pdev->devfn); | ||
| 1278 | if (!ret) | ||
| 1279 | return ret; | ||
| 1280 | /* dependent device mapping */ | ||
| 1281 | tmp = pci_find_upstream_pcie_bridge(pdev); | ||
| 1282 | if (!tmp) | ||
| 1283 | return ret; | ||
| 1284 | /* Secondary interface's bus number and devfn 0 */ | ||
| 1285 | parent = pdev->bus->self; | ||
| 1286 | while (parent != tmp) { | ||
| 1287 | ret = device_context_mapped(domain->iommu, parent->bus->number, | ||
| 1288 | parent->devfn); | ||
| 1289 | if (!ret) | ||
| 1290 | return ret; | ||
| 1291 | parent = parent->bus->self; | ||
| 1292 | } | ||
| 1293 | if (tmp->is_pcie) | ||
| 1294 | return device_context_mapped(domain->iommu, | ||
| 1295 | tmp->subordinate->number, 0); | ||
| 1296 | else | ||
| 1297 | return device_context_mapped(domain->iommu, | ||
| 1298 | tmp->bus->number, tmp->devfn); | ||
| 1299 | } | ||
| 1300 | |||
| 1301 | static int | ||
| 1302 | domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova, | ||
| 1303 | u64 hpa, size_t size, int prot) | ||
| 1304 | { | ||
| 1305 | u64 start_pfn, end_pfn; | ||
| 1306 | struct dma_pte *pte; | ||
| 1307 | int index; | ||
| 1308 | |||
| 1309 | if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0) | ||
| 1310 | return -EINVAL; | ||
| 1311 | iova &= PAGE_MASK_4K; | ||
| 1312 | start_pfn = ((u64)hpa) >> PAGE_SHIFT_4K; | ||
| 1313 | end_pfn = (PAGE_ALIGN_4K(((u64)hpa) + size)) >> PAGE_SHIFT_4K; | ||
| 1314 | index = 0; | ||
| 1315 | while (start_pfn < end_pfn) { | ||
| 1316 | pte = addr_to_dma_pte(domain, iova + PAGE_SIZE_4K * index); | ||
| 1317 | if (!pte) | ||
| 1318 | return -ENOMEM; | ||
| 1319 | /* We don't need lock here, nobody else | ||
| 1320 | * touches the iova range | ||
| 1321 | */ | ||
| 1322 | BUG_ON(dma_pte_addr(*pte)); | ||
| 1323 | dma_set_pte_addr(*pte, start_pfn << PAGE_SHIFT_4K); | ||
| 1324 | dma_set_pte_prot(*pte, prot); | ||
| 1325 | __iommu_flush_cache(domain->iommu, pte, sizeof(*pte)); | ||
| 1326 | start_pfn++; | ||
| 1327 | index++; | ||
| 1328 | } | ||
| 1329 | return 0; | ||
| 1330 | } | ||
| 1331 | |||
| 1332 | static void detach_domain_for_dev(struct dmar_domain *domain, u8 bus, u8 devfn) | ||
| 1333 | { | ||
| 1334 | clear_context_table(domain->iommu, bus, devfn); | ||
| 1335 | iommu_flush_context_global(domain->iommu, 0); | ||
| 1336 | iommu_flush_iotlb_global(domain->iommu, 0); | ||
| 1337 | } | ||
| 1338 | |||
| 1339 | static void domain_remove_dev_info(struct dmar_domain *domain) | ||
| 1340 | { | ||
| 1341 | struct device_domain_info *info; | ||
| 1342 | unsigned long flags; | ||
| 1343 | |||
| 1344 | spin_lock_irqsave(&device_domain_lock, flags); | ||
| 1345 | while (!list_empty(&domain->devices)) { | ||
| 1346 | info = list_entry(domain->devices.next, | ||
| 1347 | struct device_domain_info, link); | ||
| 1348 | list_del(&info->link); | ||
| 1349 | list_del(&info->global); | ||
| 1350 | if (info->dev) | ||
| 1351 | info->dev->dev.archdata.iommu = NULL; | ||
| 1352 | spin_unlock_irqrestore(&device_domain_lock, flags); | ||
| 1353 | |||
| 1354 | detach_domain_for_dev(info->domain, info->bus, info->devfn); | ||
| 1355 | free_devinfo_mem(info); | ||
| 1356 | |||
| 1357 | spin_lock_irqsave(&device_domain_lock, flags); | ||
| 1358 | } | ||
| 1359 | spin_unlock_irqrestore(&device_domain_lock, flags); | ||
| 1360 | } | ||
| 1361 | |||
| 1362 | /* | ||
| 1363 | * find_domain | ||
| 1364 | * Note: we use struct pci_dev->dev.archdata.iommu stores the info | ||
| 1365 | */ | ||
| 1366 | struct dmar_domain * | ||
| 1367 | find_domain(struct pci_dev *pdev) | ||
| 1368 | { | ||
| 1369 | struct device_domain_info *info; | ||
| 1370 | |||
| 1371 | /* No lock here, assumes no domain exit in normal case */ | ||
| 1372 | info = pdev->dev.archdata.iommu; | ||
| 1373 | if (info) | ||
| 1374 | return info->domain; | ||
| 1375 | return NULL; | ||
| 1376 | } | ||
| 1377 | |||
| 1378 | static int dmar_pci_device_match(struct pci_dev *devices[], int cnt, | ||
| 1379 | struct pci_dev *dev) | ||
| 1380 | { | ||
| 1381 | int index; | ||
| 1382 | |||
| 1383 | while (dev) { | ||
| 1384 | for (index = 0; index < cnt; index ++) | ||
| 1385 | if (dev == devices[index]) | ||
| 1386 | return 1; | ||
| 1387 | |||
| 1388 | /* Check our parent */ | ||
| 1389 | dev = dev->bus->self; | ||
| 1390 | } | ||
| 1391 | |||
| 1392 | return 0; | ||
| 1393 | } | ||
| 1394 | |||
| 1395 | static struct dmar_drhd_unit * | ||
| 1396 | dmar_find_matched_drhd_unit(struct pci_dev *dev) | ||
| 1397 | { | ||
| 1398 | struct dmar_drhd_unit *drhd = NULL; | ||
| 1399 | |||
| 1400 | list_for_each_entry(drhd, &dmar_drhd_units, list) { | ||
| 1401 | if (drhd->include_all || dmar_pci_device_match(drhd->devices, | ||
| 1402 | drhd->devices_cnt, dev)) | ||
| 1403 | return drhd; | ||
| 1404 | } | ||
| 1405 | |||
| 1406 | return NULL; | ||
| 1407 | } | ||
| 1408 | |||
| 1409 | /* domain is initialized */ | ||
| 1410 | static struct dmar_domain *get_domain_for_dev(struct pci_dev *pdev, int gaw) | ||
| 1411 | { | ||
| 1412 | struct dmar_domain *domain, *found = NULL; | ||
| 1413 | struct intel_iommu *iommu; | ||
| 1414 | struct dmar_drhd_unit *drhd; | ||
| 1415 | struct device_domain_info *info, *tmp; | ||
| 1416 | struct pci_dev *dev_tmp; | ||
| 1417 | unsigned long flags; | ||
| 1418 | int bus = 0, devfn = 0; | ||
| 1419 | |||
| 1420 | domain = find_domain(pdev); | ||
| 1421 | if (domain) | ||
| 1422 | return domain; | ||
| 1423 | |||
| 1424 | dev_tmp = pci_find_upstream_pcie_bridge(pdev); | ||
| 1425 | if (dev_tmp) { | ||
| 1426 | if (dev_tmp->is_pcie) { | ||
| 1427 | bus = dev_tmp->subordinate->number; | ||
| 1428 | devfn = 0; | ||
| 1429 | } else { | ||
| 1430 | bus = dev_tmp->bus->number; | ||
| 1431 | devfn = dev_tmp->devfn; | ||
| 1432 | } | ||
| 1433 | spin_lock_irqsave(&device_domain_lock, flags); | ||
| 1434 | list_for_each_entry(info, &device_domain_list, global) { | ||
| 1435 | if (info->bus == bus && info->devfn == devfn) { | ||
| 1436 | found = info->domain; | ||
| 1437 | break; | ||
| 1438 | } | ||
| 1439 | } | ||
| 1440 | spin_unlock_irqrestore(&device_domain_lock, flags); | ||
| 1441 | /* pcie-pci bridge already has a domain, uses it */ | ||
| 1442 | if (found) { | ||
| 1443 | domain = found; | ||
| 1444 | goto found_domain; | ||
| 1445 | } | ||
| 1446 | } | ||
| 1447 | |||
| 1448 | /* Allocate new domain for the device */ | ||
| 1449 | drhd = dmar_find_matched_drhd_unit(pdev); | ||
| 1450 | if (!drhd) { | ||
| 1451 | printk(KERN_ERR "IOMMU: can't find DMAR for device %s\n", | ||
| 1452 | pci_name(pdev)); | ||
| 1453 | return NULL; | ||
| 1454 | } | ||
| 1455 | iommu = drhd->iommu; | ||
| 1456 | |||
| 1457 | domain = iommu_alloc_domain(iommu); | ||
| 1458 | if (!domain) | ||
| 1459 | goto error; | ||
| 1460 | |||
| 1461 | if (domain_init(domain, gaw)) { | ||
| 1462 | domain_exit(domain); | ||
| 1463 | goto error; | ||
| 1464 | } | ||
| 1465 | |||
| 1466 | /* register pcie-to-pci device */ | ||
| 1467 | if (dev_tmp) { | ||
| 1468 | info = alloc_devinfo_mem(); | ||
| 1469 | if (!info) { | ||
| 1470 | domain_exit(domain); | ||
| 1471 | goto error; | ||
| 1472 | } | ||
| 1473 | info->bus = bus; | ||
| 1474 | info->devfn = devfn; | ||
| 1475 | info->dev = NULL; | ||
| 1476 | info->domain = domain; | ||
| 1477 | /* This domain is shared by devices under p2p bridge */ | ||
| 1478 | domain->flags |= DOMAIN_FLAG_MULTIPLE_DEVICES; | ||
| 1479 | |||
| 1480 | /* pcie-to-pci bridge already has a domain, uses it */ | ||
| 1481 | found = NULL; | ||
| 1482 | spin_lock_irqsave(&device_domain_lock, flags); | ||
| 1483 | list_for_each_entry(tmp, &device_domain_list, global) { | ||
| 1484 | if (tmp->bus == bus && tmp->devfn == devfn) { | ||
| 1485 | found = tmp->domain; | ||
| 1486 | break; | ||
| 1487 | } | ||
| 1488 | } | ||
| 1489 | if (found) { | ||
| 1490 | free_devinfo_mem(info); | ||
| 1491 | domain_exit(domain); | ||
| 1492 | domain = found; | ||
| 1493 | } else { | ||
| 1494 | list_add(&info->link, &domain->devices); | ||
| 1495 | list_add(&info->global, &device_domain_list); | ||
| 1496 | } | ||
| 1497 | spin_unlock_irqrestore(&device_domain_lock, flags); | ||
| 1498 | } | ||
| 1499 | |||
| 1500 | found_domain: | ||
| 1501 | info = alloc_devinfo_mem(); | ||
| 1502 | if (!info) | ||
| 1503 | goto error; | ||
| 1504 | info->bus = pdev->bus->number; | ||
| 1505 | info->devfn = pdev->devfn; | ||
| 1506 | info->dev = pdev; | ||
| 1507 | info->domain = domain; | ||
| 1508 | spin_lock_irqsave(&device_domain_lock, flags); | ||
| 1509 | /* somebody is fast */ | ||
| 1510 | found = find_domain(pdev); | ||
| 1511 | if (found != NULL) { | ||
| 1512 | spin_unlock_irqrestore(&device_domain_lock, flags); | ||
| 1513 | if (found != domain) { | ||
| 1514 | domain_exit(domain); | ||
| 1515 | domain = found; | ||
| 1516 | } | ||
| 1517 | free_devinfo_mem(info); | ||
| 1518 | return domain; | ||
| 1519 | } | ||
| 1520 | list_add(&info->link, &domain->devices); | ||
| 1521 | list_add(&info->global, &device_domain_list); | ||
| 1522 | pdev->dev.archdata.iommu = info; | ||
| 1523 | spin_unlock_irqrestore(&device_domain_lock, flags); | ||
| 1524 | return domain; | ||
| 1525 | error: | ||
| 1526 | /* recheck it here, maybe others set it */ | ||
| 1527 | return find_domain(pdev); | ||
| 1528 | } | ||
| 1529 | |||
| 1530 | static int iommu_prepare_identity_map(struct pci_dev *pdev, u64 start, u64 end) | ||
| 1531 | { | ||
| 1532 | struct dmar_domain *domain; | ||
| 1533 | unsigned long size; | ||
| 1534 | u64 base; | ||
| 1535 | int ret; | ||
| 1536 | |||
| 1537 | printk(KERN_INFO | ||
| 1538 | "IOMMU: Setting identity map for device %s [0x%Lx - 0x%Lx]\n", | ||
| 1539 | pci_name(pdev), start, end); | ||
| 1540 | /* page table init */ | ||
| 1541 | domain = get_domain_for_dev(pdev, DEFAULT_DOMAIN_ADDRESS_WIDTH); | ||
| 1542 | if (!domain) | ||
| 1543 | return -ENOMEM; | ||
| 1544 | |||
| 1545 | /* The address might not be aligned */ | ||
| 1546 | base = start & PAGE_MASK_4K; | ||
| 1547 | size = end - base; | ||
| 1548 | size = PAGE_ALIGN_4K(size); | ||
| 1549 | if (!reserve_iova(&domain->iovad, IOVA_PFN(base), | ||
| 1550 | IOVA_PFN(base + size) - 1)) { | ||
| 1551 | printk(KERN_ERR "IOMMU: reserve iova failed\n"); | ||
| 1552 | ret = -ENOMEM; | ||
| 1553 | goto error; | ||
| 1554 | } | ||
| 1555 | |||
| 1556 | pr_debug("Mapping reserved region %lx@%llx for %s\n", | ||
| 1557 | size, base, pci_name(pdev)); | ||
| 1558 | /* | ||
| 1559 | * RMRR range might have overlap with physical memory range, | ||
| 1560 | * clear it first | ||
| 1561 | */ | ||
| 1562 | dma_pte_clear_range(domain, base, base + size); | ||
| 1563 | |||
| 1564 | ret = domain_page_mapping(domain, base, base, size, | ||
| 1565 | DMA_PTE_READ|DMA_PTE_WRITE); | ||
| 1566 | if (ret) | ||
| 1567 | goto error; | ||
| 1568 | |||
| 1569 | /* context entry init */ | ||
| 1570 | ret = domain_context_mapping(domain, pdev); | ||
| 1571 | if (!ret) | ||
| 1572 | return 0; | ||
| 1573 | error: | ||
| 1574 | domain_exit(domain); | ||
| 1575 | return ret; | ||
| 1576 | |||
| 1577 | } | ||
| 1578 | |||
| 1579 | static inline int iommu_prepare_rmrr_dev(struct dmar_rmrr_unit *rmrr, | ||
| 1580 | struct pci_dev *pdev) | ||
| 1581 | { | ||
| 1582 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) | ||
| 1583 | return 0; | ||
| 1584 | return iommu_prepare_identity_map(pdev, rmrr->base_address, | ||
| 1585 | rmrr->end_address + 1); | ||
| 1586 | } | ||
| 1587 | |||
| 1588 | #ifdef CONFIG_DMAR_GFX_WA | ||
| 1589 | extern int arch_get_ram_range(int slot, u64 *addr, u64 *size); | ||
| 1590 | static void __init iommu_prepare_gfx_mapping(void) | ||
| 1591 | { | ||
| 1592 | struct pci_dev *pdev = NULL; | ||
| 1593 | u64 base, size; | ||
| 1594 | int slot; | ||
| 1595 | int ret; | ||
| 1596 | |||
| 1597 | for_each_pci_dev(pdev) { | ||
| 1598 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO || | ||
| 1599 | !IS_GFX_DEVICE(pdev)) | ||
| 1600 | continue; | ||
| 1601 | printk(KERN_INFO "IOMMU: gfx device %s 1-1 mapping\n", | ||
| 1602 | pci_name(pdev)); | ||
| 1603 | slot = arch_get_ram_range(0, &base, &size); | ||
| 1604 | while (slot >= 0) { | ||
| 1605 | ret = iommu_prepare_identity_map(pdev, | ||
| 1606 | base, base + size); | ||
| 1607 | if (ret) | ||
| 1608 | goto error; | ||
| 1609 | slot = arch_get_ram_range(slot, &base, &size); | ||
| 1610 | } | ||
| 1611 | continue; | ||
| 1612 | error: | ||
| 1613 | printk(KERN_ERR "IOMMU: mapping reserved region failed\n"); | ||
| 1614 | } | ||
| 1615 | } | ||
| 1616 | #endif | ||
| 1617 | |||
| 1618 | #ifdef CONFIG_DMAR_FLOPPY_WA | ||
| 1619 | static inline void iommu_prepare_isa(void) | ||
| 1620 | { | ||
| 1621 | struct pci_dev *pdev; | ||
| 1622 | int ret; | ||
| 1623 | |||
| 1624 | pdev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL); | ||
| 1625 | if (!pdev) | ||
| 1626 | return; | ||
| 1627 | |||
| 1628 | printk(KERN_INFO "IOMMU: Prepare 0-16M unity mapping for LPC\n"); | ||
| 1629 | ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024); | ||
| 1630 | |||
| 1631 | if (ret) | ||
| 1632 | printk("IOMMU: Failed to create 0-64M identity map, " | ||
| 1633 | "floppy might not work\n"); | ||
| 1634 | |||
| 1635 | } | ||
| 1636 | #else | ||
| 1637 | static inline void iommu_prepare_isa(void) | ||
| 1638 | { | ||
| 1639 | return; | ||
| 1640 | } | ||
| 1641 | #endif /* !CONFIG_DMAR_FLPY_WA */ | ||
| 1642 | |||
| 1643 | int __init init_dmars(void) | ||
| 1644 | { | ||
| 1645 | struct dmar_drhd_unit *drhd; | ||
| 1646 | struct dmar_rmrr_unit *rmrr; | ||
| 1647 | struct pci_dev *pdev; | ||
| 1648 | struct intel_iommu *iommu; | ||
| 1649 | int ret, unit = 0; | ||
| 1650 | |||
| 1651 | /* | ||
| 1652 | * for each drhd | ||
| 1653 | * allocate root | ||
| 1654 | * initialize and program root entry to not present | ||
| 1655 | * endfor | ||
| 1656 | */ | ||
| 1657 | for_each_drhd_unit(drhd) { | ||
| 1658 | if (drhd->ignored) | ||
| 1659 | continue; | ||
| 1660 | iommu = alloc_iommu(drhd); | ||
| 1661 | if (!iommu) { | ||
| 1662 | ret = -ENOMEM; | ||
| 1663 | goto error; | ||
| 1664 | } | ||
| 1665 | |||
| 1666 | /* | ||
| 1667 | * TBD: | ||
| 1668 | * we could share the same root & context tables | ||
| 1669 | * amoung all IOMMU's. Need to Split it later. | ||
| 1670 | */ | ||
| 1671 | ret = iommu_alloc_root_entry(iommu); | ||
| 1672 | if (ret) { | ||
| 1673 | printk(KERN_ERR "IOMMU: allocate root entry failed\n"); | ||
| 1674 | goto error; | ||
| 1675 | } | ||
| 1676 | } | ||
| 1677 | |||
| 1678 | /* | ||
| 1679 | * For each rmrr | ||
| 1680 | * for each dev attached to rmrr | ||
| 1681 | * do | ||
| 1682 | * locate drhd for dev, alloc domain for dev | ||
| 1683 | * allocate free domain | ||
| 1684 | * allocate page table entries for rmrr | ||
| 1685 | * if context not allocated for bus | ||
| 1686 | * allocate and init context | ||
| 1687 | * set present in root table for this bus | ||
| 1688 | * init context with domain, translation etc | ||
| 1689 | * endfor | ||
| 1690 | * endfor | ||
| 1691 | */ | ||
| 1692 | for_each_rmrr_units(rmrr) { | ||
| 1693 | int i; | ||
| 1694 | for (i = 0; i < rmrr->devices_cnt; i++) { | ||
| 1695 | pdev = rmrr->devices[i]; | ||
| 1696 | /* some BIOS lists non-exist devices in DMAR table */ | ||
| 1697 | if (!pdev) | ||
| 1698 | continue; | ||
| 1699 | ret = iommu_prepare_rmrr_dev(rmrr, pdev); | ||
| 1700 | if (ret) | ||
| 1701 | printk(KERN_ERR | ||
| 1702 | "IOMMU: mapping reserved region failed\n"); | ||
| 1703 | } | ||
| 1704 | } | ||
| 1705 | |||
| 1706 | iommu_prepare_gfx_mapping(); | ||
| 1707 | |||
| 1708 | iommu_prepare_isa(); | ||
| 1709 | |||
| 1710 | /* | ||
| 1711 | * for each drhd | ||
| 1712 | * enable fault log | ||
| 1713 | * global invalidate context cache | ||
| 1714 | * global invalidate iotlb | ||
| 1715 | * enable translation | ||
| 1716 | */ | ||
| 1717 | for_each_drhd_unit(drhd) { | ||
| 1718 | if (drhd->ignored) | ||
| 1719 | continue; | ||
| 1720 | iommu = drhd->iommu; | ||
| 1721 | sprintf (iommu->name, "dmar%d", unit++); | ||
| 1722 | |||
| 1723 | iommu_flush_write_buffer(iommu); | ||
| 1724 | |||
| 1725 | ret = dmar_set_interrupt(iommu); | ||
| 1726 | if (ret) | ||
| 1727 | goto error; | ||
| 1728 | |||
| 1729 | iommu_set_root_entry(iommu); | ||
| 1730 | |||
| 1731 | iommu_flush_context_global(iommu, 0); | ||
| 1732 | iommu_flush_iotlb_global(iommu, 0); | ||
| 1733 | |||
| 1734 | ret = iommu_enable_translation(iommu); | ||
| 1735 | if (ret) | ||
| 1736 | goto error; | ||
| 1737 | } | ||
| 1738 | |||
| 1739 | return 0; | ||
| 1740 | error: | ||
| 1741 | for_each_drhd_unit(drhd) { | ||
| 1742 | if (drhd->ignored) | ||
| 1743 | continue; | ||
| 1744 | iommu = drhd->iommu; | ||
| 1745 | free_iommu(iommu); | ||
| 1746 | } | ||
| 1747 | return ret; | ||
| 1748 | } | ||
| 1749 | |||
| 1750 | static inline u64 aligned_size(u64 host_addr, size_t size) | ||
| 1751 | { | ||
| 1752 | u64 addr; | ||
| 1753 | addr = (host_addr & (~PAGE_MASK_4K)) + size; | ||
| 1754 | return PAGE_ALIGN_4K(addr); | ||
| 1755 | } | ||
| 1756 | |||
| 1757 | struct iova * | ||
| 1758 | iommu_alloc_iova(struct dmar_domain *domain, size_t size, u64 end) | ||
| 1759 | { | ||
| 1760 | struct iova *piova; | ||
| 1761 | |||
| 1762 | /* Make sure it's in range */ | ||
| 1763 | end = min_t(u64, DOMAIN_MAX_ADDR(domain->gaw), end); | ||
| 1764 | if (!size || (IOVA_START_ADDR + size > end)) | ||
| 1765 | return NULL; | ||
| 1766 | |||
| 1767 | piova = alloc_iova(&domain->iovad, | ||
| 1768 | size >> PAGE_SHIFT_4K, IOVA_PFN(end), 1); | ||
| 1769 | return piova; | ||
| 1770 | } | ||
| 1771 | |||
| 1772 | static struct iova * | ||
| 1773 | __intel_alloc_iova(struct device *dev, struct dmar_domain *domain, | ||
| 1774 | size_t size) | ||
| 1775 | { | ||
| 1776 | struct pci_dev *pdev = to_pci_dev(dev); | ||
| 1777 | struct iova *iova = NULL; | ||
| 1778 | |||
| 1779 | if ((pdev->dma_mask <= DMA_32BIT_MASK) || (dmar_forcedac)) { | ||
| 1780 | iova = iommu_alloc_iova(domain, size, pdev->dma_mask); | ||
| 1781 | } else { | ||
| 1782 | /* | ||
| 1783 | * First try to allocate an io virtual address in | ||
| 1784 | * DMA_32BIT_MASK and if that fails then try allocating | ||
| 1785 | * from higer range | ||
| 1786 | */ | ||
| 1787 | iova = iommu_alloc_iova(domain, size, DMA_32BIT_MASK); | ||
| 1788 | if (!iova) | ||
| 1789 | iova = iommu_alloc_iova(domain, size, pdev->dma_mask); | ||
| 1790 | } | ||
| 1791 | |||
| 1792 | if (!iova) { | ||
| 1793 | printk(KERN_ERR"Allocating iova for %s failed", pci_name(pdev)); | ||
| 1794 | return NULL; | ||
| 1795 | } | ||
| 1796 | |||
| 1797 | return iova; | ||
| 1798 | } | ||
| 1799 | |||
| 1800 | static struct dmar_domain * | ||
| 1801 | get_valid_domain_for_dev(struct pci_dev *pdev) | ||
| 1802 | { | ||
| 1803 | struct dmar_domain *domain; | ||
| 1804 | int ret; | ||
| 1805 | |||
| 1806 | domain = get_domain_for_dev(pdev, | ||
| 1807 | DEFAULT_DOMAIN_ADDRESS_WIDTH); | ||
| 1808 | if (!domain) { | ||
| 1809 | printk(KERN_ERR | ||
| 1810 | "Allocating domain for %s failed", pci_name(pdev)); | ||
| 1811 | return 0; | ||
| 1812 | } | ||
| 1813 | |||
| 1814 | /* make sure context mapping is ok */ | ||
| 1815 | if (unlikely(!domain_context_mapped(domain, pdev))) { | ||
| 1816 | ret = domain_context_mapping(domain, pdev); | ||
| 1817 | if (ret) { | ||
| 1818 | printk(KERN_ERR | ||
| 1819 | "Domain context map for %s failed", | ||
| 1820 | pci_name(pdev)); | ||
| 1821 | return 0; | ||
| 1822 | } | ||
| 1823 | } | ||
| 1824 | |||
| 1825 | return domain; | ||
| 1826 | } | ||
| 1827 | |||
| 1828 | static dma_addr_t intel_map_single(struct device *hwdev, void *addr, | ||
| 1829 | size_t size, int dir) | ||
| 1830 | { | ||
| 1831 | struct pci_dev *pdev = to_pci_dev(hwdev); | ||
| 1832 | int ret; | ||
| 1833 | struct dmar_domain *domain; | ||
| 1834 | unsigned long start_addr; | ||
| 1835 | struct iova *iova; | ||
| 1836 | int prot = 0; | ||
| 1837 | |||
| 1838 | BUG_ON(dir == DMA_NONE); | ||
| 1839 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) | ||
| 1840 | return virt_to_bus(addr); | ||
| 1841 | |||
| 1842 | domain = get_valid_domain_for_dev(pdev); | ||
| 1843 | if (!domain) | ||
| 1844 | return 0; | ||
| 1845 | |||
| 1846 | addr = (void *)virt_to_phys(addr); | ||
| 1847 | size = aligned_size((u64)addr, size); | ||
| 1848 | |||
| 1849 | iova = __intel_alloc_iova(hwdev, domain, size); | ||
| 1850 | if (!iova) | ||
| 1851 | goto error; | ||
| 1852 | |||
| 1853 | start_addr = iova->pfn_lo << PAGE_SHIFT_4K; | ||
| 1854 | |||
| 1855 | /* | ||
| 1856 | * Check if DMAR supports zero-length reads on write only | ||
| 1857 | * mappings.. | ||
| 1858 | */ | ||
| 1859 | if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \ | ||
| 1860 | !cap_zlr(domain->iommu->cap)) | ||
| 1861 | prot |= DMA_PTE_READ; | ||
| 1862 | if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) | ||
| 1863 | prot |= DMA_PTE_WRITE; | ||
| 1864 | /* | ||
| 1865 | * addr - (addr + size) might be partial page, we should map the whole | ||
| 1866 | * page. Note: if two part of one page are separately mapped, we | ||
| 1867 | * might have two guest_addr mapping to the same host addr, but this | ||
| 1868 | * is not a big problem | ||
| 1869 | */ | ||
| 1870 | ret = domain_page_mapping(domain, start_addr, | ||
| 1871 | ((u64)addr) & PAGE_MASK_4K, size, prot); | ||
| 1872 | if (ret) | ||
| 1873 | goto error; | ||
| 1874 | |||
| 1875 | pr_debug("Device %s request: %lx@%llx mapping: %lx@%llx, dir %d\n", | ||
| 1876 | pci_name(pdev), size, (u64)addr, | ||
| 1877 | size, (u64)start_addr, dir); | ||
| 1878 | |||
| 1879 | /* it's a non-present to present mapping */ | ||
| 1880 | ret = iommu_flush_iotlb_psi(domain->iommu, domain->id, | ||
| 1881 | start_addr, size >> PAGE_SHIFT_4K, 1); | ||
| 1882 | if (ret) | ||
| 1883 | iommu_flush_write_buffer(domain->iommu); | ||
| 1884 | |||
| 1885 | return (start_addr + ((u64)addr & (~PAGE_MASK_4K))); | ||
| 1886 | |||
| 1887 | error: | ||
| 1888 | if (iova) | ||
| 1889 | __free_iova(&domain->iovad, iova); | ||
| 1890 | printk(KERN_ERR"Device %s request: %lx@%llx dir %d --- failed\n", | ||
| 1891 | pci_name(pdev), size, (u64)addr, dir); | ||
| 1892 | return 0; | ||
| 1893 | } | ||
| 1894 | |||
| 1895 | static void intel_unmap_single(struct device *dev, dma_addr_t dev_addr, | ||
| 1896 | size_t size, int dir) | ||
| 1897 | { | ||
| 1898 | struct pci_dev *pdev = to_pci_dev(dev); | ||
| 1899 | struct dmar_domain *domain; | ||
| 1900 | unsigned long start_addr; | ||
| 1901 | struct iova *iova; | ||
| 1902 | |||
| 1903 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) | ||
| 1904 | return; | ||
| 1905 | domain = find_domain(pdev); | ||
| 1906 | BUG_ON(!domain); | ||
| 1907 | |||
| 1908 | iova = find_iova(&domain->iovad, IOVA_PFN(dev_addr)); | ||
| 1909 | if (!iova) | ||
| 1910 | return; | ||
| 1911 | |||
| 1912 | start_addr = iova->pfn_lo << PAGE_SHIFT_4K; | ||
| 1913 | size = aligned_size((u64)dev_addr, size); | ||
| 1914 | |||
| 1915 | pr_debug("Device %s unmapping: %lx@%llx\n", | ||
| 1916 | pci_name(pdev), size, (u64)start_addr); | ||
| 1917 | |||
| 1918 | /* clear the whole page */ | ||
| 1919 | dma_pte_clear_range(domain, start_addr, start_addr + size); | ||
| 1920 | /* free page tables */ | ||
| 1921 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); | ||
| 1922 | |||
| 1923 | if (iommu_flush_iotlb_psi(domain->iommu, domain->id, start_addr, | ||
| 1924 | size >> PAGE_SHIFT_4K, 0)) | ||
| 1925 | iommu_flush_write_buffer(domain->iommu); | ||
| 1926 | |||
| 1927 | /* free iova */ | ||
| 1928 | __free_iova(&domain->iovad, iova); | ||
| 1929 | } | ||
| 1930 | |||
| 1931 | static void * intel_alloc_coherent(struct device *hwdev, size_t size, | ||
| 1932 | dma_addr_t *dma_handle, gfp_t flags) | ||
| 1933 | { | ||
| 1934 | void *vaddr; | ||
| 1935 | int order; | ||
| 1936 | |||
| 1937 | size = PAGE_ALIGN_4K(size); | ||
| 1938 | order = get_order(size); | ||
| 1939 | flags &= ~(GFP_DMA | GFP_DMA32); | ||
| 1940 | |||
| 1941 | vaddr = (void *)__get_free_pages(flags, order); | ||
| 1942 | if (!vaddr) | ||
| 1943 | return NULL; | ||
| 1944 | memset(vaddr, 0, size); | ||
| 1945 | |||
| 1946 | *dma_handle = intel_map_single(hwdev, vaddr, size, DMA_BIDIRECTIONAL); | ||
| 1947 | if (*dma_handle) | ||
| 1948 | return vaddr; | ||
| 1949 | free_pages((unsigned long)vaddr, order); | ||
| 1950 | return NULL; | ||
| 1951 | } | ||
| 1952 | |||
| 1953 | static void intel_free_coherent(struct device *hwdev, size_t size, | ||
| 1954 | void *vaddr, dma_addr_t dma_handle) | ||
| 1955 | { | ||
| 1956 | int order; | ||
| 1957 | |||
| 1958 | size = PAGE_ALIGN_4K(size); | ||
| 1959 | order = get_order(size); | ||
| 1960 | |||
| 1961 | intel_unmap_single(hwdev, dma_handle, size, DMA_BIDIRECTIONAL); | ||
| 1962 | free_pages((unsigned long)vaddr, order); | ||
| 1963 | } | ||
| 1964 | |||
| 1965 | #define SG_ENT_VIRT_ADDRESS(sg) (page_address((sg)->page) + (sg)->offset) | ||
| 1966 | static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist, | ||
| 1967 | int nelems, int dir) | ||
| 1968 | { | ||
| 1969 | int i; | ||
| 1970 | struct pci_dev *pdev = to_pci_dev(hwdev); | ||
| 1971 | struct dmar_domain *domain; | ||
| 1972 | unsigned long start_addr; | ||
| 1973 | struct iova *iova; | ||
| 1974 | size_t size = 0; | ||
| 1975 | void *addr; | ||
| 1976 | struct scatterlist *sg; | ||
| 1977 | |||
| 1978 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) | ||
| 1979 | return; | ||
| 1980 | |||
| 1981 | domain = find_domain(pdev); | ||
| 1982 | |||
| 1983 | iova = find_iova(&domain->iovad, IOVA_PFN(sglist[0].dma_address)); | ||
| 1984 | if (!iova) | ||
| 1985 | return; | ||
| 1986 | for_each_sg(sglist, sg, nelems, i) { | ||
| 1987 | addr = SG_ENT_VIRT_ADDRESS(sg); | ||
| 1988 | size += aligned_size((u64)addr, sg->length); | ||
| 1989 | } | ||
| 1990 | |||
| 1991 | start_addr = iova->pfn_lo << PAGE_SHIFT_4K; | ||
| 1992 | |||
| 1993 | /* clear the whole page */ | ||
| 1994 | dma_pte_clear_range(domain, start_addr, start_addr + size); | ||
| 1995 | /* free page tables */ | ||
| 1996 | dma_pte_free_pagetable(domain, start_addr, start_addr + size); | ||
| 1997 | |||
| 1998 | if (iommu_flush_iotlb_psi(domain->iommu, domain->id, start_addr, | ||
| 1999 | size >> PAGE_SHIFT_4K, 0)) | ||
| 2000 | iommu_flush_write_buffer(domain->iommu); | ||
| 2001 | |||
| 2002 | /* free iova */ | ||
| 2003 | __free_iova(&domain->iovad, iova); | ||
| 2004 | } | ||
| 2005 | |||
| 2006 | static int intel_nontranslate_map_sg(struct device *hddev, | ||
| 2007 | struct scatterlist *sglist, int nelems, int dir) | ||
| 2008 | { | ||
| 2009 | int i; | ||
| 2010 | struct scatterlist *sg; | ||
| 2011 | |||
| 2012 | for_each_sg(sglist, sg, nelems, i) { | ||
| 2013 | BUG_ON(!sg->page); | ||
| 2014 | sg->dma_address = virt_to_bus(SG_ENT_VIRT_ADDRESS(sg)); | ||
| 2015 | sg->dma_length = sg->length; | ||
| 2016 | } | ||
| 2017 | return nelems; | ||
| 2018 | } | ||
| 2019 | |||
| 2020 | static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, | ||
| 2021 | int nelems, int dir) | ||
| 2022 | { | ||
| 2023 | void *addr; | ||
| 2024 | int i; | ||
| 2025 | struct pci_dev *pdev = to_pci_dev(hwdev); | ||
| 2026 | struct dmar_domain *domain; | ||
| 2027 | size_t size = 0; | ||
| 2028 | int prot = 0; | ||
| 2029 | size_t offset = 0; | ||
| 2030 | struct iova *iova = NULL; | ||
| 2031 | int ret; | ||
| 2032 | struct scatterlist *sg; | ||
| 2033 | unsigned long start_addr; | ||
| 2034 | |||
| 2035 | BUG_ON(dir == DMA_NONE); | ||
| 2036 | if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) | ||
| 2037 | return intel_nontranslate_map_sg(hwdev, sglist, nelems, dir); | ||
| 2038 | |||
| 2039 | domain = get_valid_domain_for_dev(pdev); | ||
| 2040 | if (!domain) | ||
| 2041 | return 0; | ||
| 2042 | |||
| 2043 | for_each_sg(sglist, sg, nelems, i) { | ||
| 2044 | addr = SG_ENT_VIRT_ADDRESS(sg); | ||
| 2045 | addr = (void *)virt_to_phys(addr); | ||
| 2046 | size += aligned_size((u64)addr, sg->length); | ||
| 2047 | } | ||
| 2048 | |||
| 2049 | iova = __intel_alloc_iova(hwdev, domain, size); | ||
| 2050 | if (!iova) { | ||
| 2051 | sglist->dma_length = 0; | ||
| 2052 | return 0; | ||
| 2053 | } | ||
| 2054 | |||
| 2055 | /* | ||
| 2056 | * Check if DMAR supports zero-length reads on write only | ||
| 2057 | * mappings.. | ||
| 2058 | */ | ||
| 2059 | if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL || \ | ||
| 2060 | !cap_zlr(domain->iommu->cap)) | ||
| 2061 | prot |= DMA_PTE_READ; | ||
| 2062 | if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL) | ||
| 2063 | prot |= DMA_PTE_WRITE; | ||
| 2064 | |||
| 2065 | start_addr = iova->pfn_lo << PAGE_SHIFT_4K; | ||
| 2066 | offset = 0; | ||
| 2067 | for_each_sg(sglist, sg, nelems, i) { | ||
| 2068 | addr = SG_ENT_VIRT_ADDRESS(sg); | ||
| 2069 | addr = (void *)virt_to_phys(addr); | ||
| 2070 | size = aligned_size((u64)addr, sg->length); | ||
| 2071 | ret = domain_page_mapping(domain, start_addr + offset, | ||
| 2072 | ((u64)addr) & PAGE_MASK_4K, | ||
| 2073 | size, prot); | ||
| 2074 | if (ret) { | ||
| 2075 | /* clear the page */ | ||
| 2076 | dma_pte_clear_range(domain, start_addr, | ||
| 2077 | start_addr + offset); | ||
| 2078 | /* free page tables */ | ||
| 2079 | dma_pte_free_pagetable(domain, start_addr, | ||
| 2080 | start_addr + offset); | ||
| 2081 | /* free iova */ | ||
| 2082 | __free_iova(&domain->iovad, iova); | ||
| 2083 | return 0; | ||
| 2084 | } | ||
| 2085 | sg->dma_address = start_addr + offset + | ||
| 2086 | ((u64)addr & (~PAGE_MASK_4K)); | ||
| 2087 | sg->dma_length = sg->length; | ||
| 2088 | offset += size; | ||
| 2089 | } | ||
| 2090 | |||
| 2091 | /* it's a non-present to present mapping */ | ||
| 2092 | if (iommu_flush_iotlb_psi(domain->iommu, domain->id, | ||
| 2093 | start_addr, offset >> PAGE_SHIFT_4K, 1)) | ||
| 2094 | iommu_flush_write_buffer(domain->iommu); | ||
| 2095 | return nelems; | ||
| 2096 | } | ||
| 2097 | |||
| 2098 | static struct dma_mapping_ops intel_dma_ops = { | ||
| 2099 | .alloc_coherent = intel_alloc_coherent, | ||
| 2100 | .free_coherent = intel_free_coherent, | ||
| 2101 | .map_single = intel_map_single, | ||
| 2102 | .unmap_single = intel_unmap_single, | ||
| 2103 | .map_sg = intel_map_sg, | ||
| 2104 | .unmap_sg = intel_unmap_sg, | ||
| 2105 | }; | ||
| 2106 | |||
| 2107 | static inline int iommu_domain_cache_init(void) | ||
| 2108 | { | ||
| 2109 | int ret = 0; | ||
| 2110 | |||
| 2111 | iommu_domain_cache = kmem_cache_create("iommu_domain", | ||
| 2112 | sizeof(struct dmar_domain), | ||
| 2113 | 0, | ||
| 2114 | SLAB_HWCACHE_ALIGN, | ||
| 2115 | |||
| 2116 | NULL); | ||
| 2117 | if (!iommu_domain_cache) { | ||
| 2118 | printk(KERN_ERR "Couldn't create iommu_domain cache\n"); | ||
| 2119 | ret = -ENOMEM; | ||
| 2120 | } | ||
| 2121 | |||
| 2122 | return ret; | ||
| 2123 | } | ||
| 2124 | |||
| 2125 | static inline int iommu_devinfo_cache_init(void) | ||
| 2126 | { | ||
| 2127 | int ret = 0; | ||
| 2128 | |||
| 2129 | iommu_devinfo_cache = kmem_cache_create("iommu_devinfo", | ||
| 2130 | sizeof(struct device_domain_info), | ||
| 2131 | 0, | ||
| 2132 | SLAB_HWCACHE_ALIGN, | ||
| 2133 | |||
| 2134 | NULL); | ||
| 2135 | if (!iommu_devinfo_cache) { | ||
| 2136 | printk(KERN_ERR "Couldn't create devinfo cache\n"); | ||
| 2137 | ret = -ENOMEM; | ||
| 2138 | } | ||
| 2139 | |||
| 2140 | return ret; | ||
| 2141 | } | ||
| 2142 | |||
| 2143 | static inline int iommu_iova_cache_init(void) | ||
| 2144 | { | ||
| 2145 | int ret = 0; | ||
| 2146 | |||
| 2147 | iommu_iova_cache = kmem_cache_create("iommu_iova", | ||
| 2148 | sizeof(struct iova), | ||
| 2149 | 0, | ||
| 2150 | SLAB_HWCACHE_ALIGN, | ||
| 2151 | |||
| 2152 | NULL); | ||
| 2153 | if (!iommu_iova_cache) { | ||
| 2154 | printk(KERN_ERR "Couldn't create iova cache\n"); | ||
| 2155 | ret = -ENOMEM; | ||
| 2156 | } | ||
| 2157 | |||
| 2158 | return ret; | ||
| 2159 | } | ||
| 2160 | |||
| 2161 | static int __init iommu_init_mempool(void) | ||
| 2162 | { | ||
| 2163 | int ret; | ||
| 2164 | ret = iommu_iova_cache_init(); | ||
| 2165 | if (ret) | ||
| 2166 | return ret; | ||
| 2167 | |||
| 2168 | ret = iommu_domain_cache_init(); | ||
| 2169 | if (ret) | ||
| 2170 | goto domain_error; | ||
| 2171 | |||
| 2172 | ret = iommu_devinfo_cache_init(); | ||
| 2173 | if (!ret) | ||
| 2174 | return ret; | ||
| 2175 | |||
| 2176 | kmem_cache_destroy(iommu_domain_cache); | ||
| 2177 | domain_error: | ||
| 2178 | kmem_cache_destroy(iommu_iova_cache); | ||
| 2179 | |||
| 2180 | return -ENOMEM; | ||
| 2181 | } | ||
| 2182 | |||
| 2183 | static void __init iommu_exit_mempool(void) | ||
| 2184 | { | ||
| 2185 | kmem_cache_destroy(iommu_devinfo_cache); | ||
| 2186 | kmem_cache_destroy(iommu_domain_cache); | ||
| 2187 | kmem_cache_destroy(iommu_iova_cache); | ||
| 2188 | |||
| 2189 | } | ||
| 2190 | |||
| 2191 | void __init detect_intel_iommu(void) | ||
| 2192 | { | ||
| 2193 | if (swiotlb || no_iommu || iommu_detected || dmar_disabled) | ||
| 2194 | return; | ||
| 2195 | if (early_dmar_detect()) { | ||
| 2196 | iommu_detected = 1; | ||
| 2197 | } | ||
| 2198 | } | ||
| 2199 | |||
| 2200 | static void __init init_no_remapping_devices(void) | ||
| 2201 | { | ||
| 2202 | struct dmar_drhd_unit *drhd; | ||
| 2203 | |||
| 2204 | for_each_drhd_unit(drhd) { | ||
| 2205 | if (!drhd->include_all) { | ||
| 2206 | int i; | ||
| 2207 | for (i = 0; i < drhd->devices_cnt; i++) | ||
| 2208 | if (drhd->devices[i] != NULL) | ||
| 2209 | break; | ||
| 2210 | /* ignore DMAR unit if no pci devices exist */ | ||
| 2211 | if (i == drhd->devices_cnt) | ||
| 2212 | drhd->ignored = 1; | ||
| 2213 | } | ||
| 2214 | } | ||
| 2215 | |||
| 2216 | if (dmar_map_gfx) | ||
| 2217 | return; | ||
| 2218 | |||
| 2219 | for_each_drhd_unit(drhd) { | ||
| 2220 | int i; | ||
| 2221 | if (drhd->ignored || drhd->include_all) | ||
| 2222 | continue; | ||
| 2223 | |||
| 2224 | for (i = 0; i < drhd->devices_cnt; i++) | ||
| 2225 | if (drhd->devices[i] && | ||
| 2226 | !IS_GFX_DEVICE(drhd->devices[i])) | ||
| 2227 | break; | ||
| 2228 | |||
| 2229 | if (i < drhd->devices_cnt) | ||
| 2230 | continue; | ||
| 2231 | |||
| 2232 | /* bypass IOMMU if it is just for gfx devices */ | ||
| 2233 | drhd->ignored = 1; | ||
| 2234 | for (i = 0; i < drhd->devices_cnt; i++) { | ||
| 2235 | if (!drhd->devices[i]) | ||
| 2236 | continue; | ||
| 2237 | drhd->devices[i]->dev.archdata.iommu = DUMMY_DEVICE_DOMAIN_INFO; | ||
| 2238 | } | ||
| 2239 | } | ||
| 2240 | } | ||
| 2241 | |||
| 2242 | int __init intel_iommu_init(void) | ||
| 2243 | { | ||
| 2244 | int ret = 0; | ||
| 2245 | |||
| 2246 | if (no_iommu || swiotlb || dmar_disabled) | ||
| 2247 | return -ENODEV; | ||
| 2248 | |||
| 2249 | if (dmar_table_init()) | ||
| 2250 | return -ENODEV; | ||
| 2251 | |||
| 2252 | iommu_init_mempool(); | ||
| 2253 | dmar_init_reserved_ranges(); | ||
| 2254 | |||
| 2255 | init_no_remapping_devices(); | ||
| 2256 | |||
| 2257 | ret = init_dmars(); | ||
| 2258 | if (ret) { | ||
| 2259 | printk(KERN_ERR "IOMMU: dmar init failed\n"); | ||
| 2260 | put_iova_domain(&reserved_iova_list); | ||
| 2261 | iommu_exit_mempool(); | ||
| 2262 | return ret; | ||
| 2263 | } | ||
| 2264 | printk(KERN_INFO | ||
| 2265 | "PCI-DMA: Intel(R) Virtualization Technology for Directed I/O\n"); | ||
| 2266 | |||
| 2267 | force_iommu = 1; | ||
| 2268 | dma_ops = &intel_dma_ops; | ||
| 2269 | return 0; | ||
| 2270 | } | ||
| 2271 | |||
diff --git a/drivers/pci/intel-iommu.h b/drivers/pci/intel-iommu.h new file mode 100644 index 000000000000..ee88dd2400cb --- /dev/null +++ b/drivers/pci/intel-iommu.h | |||
| @@ -0,0 +1,325 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2006, Intel Corporation. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License along with | ||
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
| 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. | ||
| 16 | * | ||
| 17 | * Copyright (C) Ashok Raj <ashok.raj@intel.com> | ||
| 18 | * Copyright (C) Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef _INTEL_IOMMU_H_ | ||
| 22 | #define _INTEL_IOMMU_H_ | ||
| 23 | |||
| 24 | #include <linux/types.h> | ||
| 25 | #include <linux/msi.h> | ||
| 26 | #include "iova.h" | ||
| 27 | #include <linux/io.h> | ||
| 28 | |||
| 29 | /* | ||
| 30 | * Intel IOMMU register specification per version 1.0 public spec. | ||
| 31 | */ | ||
| 32 | |||
| 33 | #define DMAR_VER_REG 0x0 /* Arch version supported by this IOMMU */ | ||
| 34 | #define DMAR_CAP_REG 0x8 /* Hardware supported capabilities */ | ||
| 35 | #define DMAR_ECAP_REG 0x10 /* Extended capabilities supported */ | ||
| 36 | #define DMAR_GCMD_REG 0x18 /* Global command register */ | ||
| 37 | #define DMAR_GSTS_REG 0x1c /* Global status register */ | ||
| 38 | #define DMAR_RTADDR_REG 0x20 /* Root entry table */ | ||
| 39 | #define DMAR_CCMD_REG 0x28 /* Context command reg */ | ||
| 40 | #define DMAR_FSTS_REG 0x34 /* Fault Status register */ | ||
| 41 | #define DMAR_FECTL_REG 0x38 /* Fault control register */ | ||
| 42 | #define DMAR_FEDATA_REG 0x3c /* Fault event interrupt data register */ | ||
| 43 | #define DMAR_FEADDR_REG 0x40 /* Fault event interrupt addr register */ | ||
| 44 | #define DMAR_FEUADDR_REG 0x44 /* Upper address register */ | ||
| 45 | #define DMAR_AFLOG_REG 0x58 /* Advanced Fault control */ | ||
| 46 | #define DMAR_PMEN_REG 0x64 /* Enable Protected Memory Region */ | ||
| 47 | #define DMAR_PLMBASE_REG 0x68 /* PMRR Low addr */ | ||
| 48 | #define DMAR_PLMLIMIT_REG 0x6c /* PMRR low limit */ | ||
| 49 | #define DMAR_PHMBASE_REG 0x70 /* pmrr high base addr */ | ||
| 50 | #define DMAR_PHMLIMIT_REG 0x78 /* pmrr high limit */ | ||
| 51 | |||
| 52 | #define OFFSET_STRIDE (9) | ||
| 53 | /* | ||
| 54 | #define dmar_readl(dmar, reg) readl(dmar + reg) | ||
| 55 | #define dmar_readq(dmar, reg) ({ \ | ||
| 56 | u32 lo, hi; \ | ||
| 57 | lo = readl(dmar + reg); \ | ||
| 58 | hi = readl(dmar + reg + 4); \ | ||
| 59 | (((u64) hi) << 32) + lo; }) | ||
| 60 | */ | ||
| 61 | static inline u64 dmar_readq(void *addr) | ||
| 62 | { | ||
| 63 | u32 lo, hi; | ||
| 64 | lo = readl(addr); | ||
| 65 | hi = readl(addr + 4); | ||
| 66 | return (((u64) hi) << 32) + lo; | ||
| 67 | } | ||
| 68 | |||
| 69 | static inline void dmar_writeq(void __iomem *addr, u64 val) | ||
| 70 | { | ||
| 71 | writel((u32)val, addr); | ||
| 72 | writel((u32)(val >> 32), addr + 4); | ||
| 73 | } | ||
| 74 | |||
| 75 | #define DMAR_VER_MAJOR(v) (((v) & 0xf0) >> 4) | ||
| 76 | #define DMAR_VER_MINOR(v) ((v) & 0x0f) | ||
| 77 | |||
| 78 | /* | ||
| 79 | * Decoding Capability Register | ||
| 80 | */ | ||
| 81 | #define cap_read_drain(c) (((c) >> 55) & 1) | ||
| 82 | #define cap_write_drain(c) (((c) >> 54) & 1) | ||
| 83 | #define cap_max_amask_val(c) (((c) >> 48) & 0x3f) | ||
| 84 | #define cap_num_fault_regs(c) ((((c) >> 40) & 0xff) + 1) | ||
| 85 | #define cap_pgsel_inv(c) (((c) >> 39) & 1) | ||
| 86 | |||
| 87 | #define cap_super_page_val(c) (((c) >> 34) & 0xf) | ||
| 88 | #define cap_super_offset(c) (((find_first_bit(&cap_super_page_val(c), 4)) \ | ||
| 89 | * OFFSET_STRIDE) + 21) | ||
| 90 | |||
| 91 | #define cap_fault_reg_offset(c) ((((c) >> 24) & 0x3ff) * 16) | ||
| 92 | #define cap_max_fault_reg_offset(c) \ | ||
| 93 | (cap_fault_reg_offset(c) + cap_num_fault_regs(c) * 16) | ||
| 94 | |||
| 95 | #define cap_zlr(c) (((c) >> 22) & 1) | ||
| 96 | #define cap_isoch(c) (((c) >> 23) & 1) | ||
| 97 | #define cap_mgaw(c) ((((c) >> 16) & 0x3f) + 1) | ||
| 98 | #define cap_sagaw(c) (((c) >> 8) & 0x1f) | ||
| 99 | #define cap_caching_mode(c) (((c) >> 7) & 1) | ||
| 100 | #define cap_phmr(c) (((c) >> 6) & 1) | ||
| 101 | #define cap_plmr(c) (((c) >> 5) & 1) | ||
| 102 | #define cap_rwbf(c) (((c) >> 4) & 1) | ||
| 103 | #define cap_afl(c) (((c) >> 3) & 1) | ||
| 104 | #define cap_ndoms(c) (((unsigned long)1) << (4 + 2 * ((c) & 0x7))) | ||
| 105 | /* | ||
| 106 | * Extended Capability Register | ||
| 107 | */ | ||
| 108 | |||
| 109 | #define ecap_niotlb_iunits(e) ((((e) >> 24) & 0xff) + 1) | ||
| 110 | #define ecap_iotlb_offset(e) ((((e) >> 8) & 0x3ff) * 16) | ||
| 111 | #define ecap_max_iotlb_offset(e) \ | ||
| 112 | (ecap_iotlb_offset(e) + ecap_niotlb_iunits(e) * 16) | ||
| 113 | #define ecap_coherent(e) ((e) & 0x1) | ||
| 114 | |||
| 115 | |||
| 116 | /* IOTLB_REG */ | ||
| 117 | #define DMA_TLB_GLOBAL_FLUSH (((u64)1) << 60) | ||
| 118 | #define DMA_TLB_DSI_FLUSH (((u64)2) << 60) | ||
| 119 | #define DMA_TLB_PSI_FLUSH (((u64)3) << 60) | ||
| 120 | #define DMA_TLB_IIRG(type) ((type >> 60) & 7) | ||
| 121 | #define DMA_TLB_IAIG(val) (((val) >> 57) & 7) | ||
| 122 | #define DMA_TLB_READ_DRAIN (((u64)1) << 49) | ||
| 123 | #define DMA_TLB_WRITE_DRAIN (((u64)1) << 48) | ||
| 124 | #define DMA_TLB_DID(id) (((u64)((id) & 0xffff)) << 32) | ||
| 125 | #define DMA_TLB_IVT (((u64)1) << 63) | ||
| 126 | #define DMA_TLB_IH_NONLEAF (((u64)1) << 6) | ||
| 127 | #define DMA_TLB_MAX_SIZE (0x3f) | ||
| 128 | |||
| 129 | /* GCMD_REG */ | ||
| 130 | #define DMA_GCMD_TE (((u32)1) << 31) | ||
| 131 | #define DMA_GCMD_SRTP (((u32)1) << 30) | ||
| 132 | #define DMA_GCMD_SFL (((u32)1) << 29) | ||
| 133 | #define DMA_GCMD_EAFL (((u32)1) << 28) | ||
| 134 | #define DMA_GCMD_WBF (((u32)1) << 27) | ||
| 135 | |||
| 136 | /* GSTS_REG */ | ||
| 137 | #define DMA_GSTS_TES (((u32)1) << 31) | ||
| 138 | #define DMA_GSTS_RTPS (((u32)1) << 30) | ||
| 139 | #define DMA_GSTS_FLS (((u32)1) << 29) | ||
| 140 | #define DMA_GSTS_AFLS (((u32)1) << 28) | ||
| 141 | #define DMA_GSTS_WBFS (((u32)1) << 27) | ||
| 142 | |||
| 143 | /* CCMD_REG */ | ||
| 144 | #define DMA_CCMD_ICC (((u64)1) << 63) | ||
| 145 | #define DMA_CCMD_GLOBAL_INVL (((u64)1) << 61) | ||
| 146 | #define DMA_CCMD_DOMAIN_INVL (((u64)2) << 61) | ||
| 147 | #define DMA_CCMD_DEVICE_INVL (((u64)3) << 61) | ||
| 148 | #define DMA_CCMD_FM(m) (((u64)((m) & 0x3)) << 32) | ||
| 149 | #define DMA_CCMD_MASK_NOBIT 0 | ||
| 150 | #define DMA_CCMD_MASK_1BIT 1 | ||
| 151 | #define DMA_CCMD_MASK_2BIT 2 | ||
| 152 | #define DMA_CCMD_MASK_3BIT 3 | ||
| 153 | #define DMA_CCMD_SID(s) (((u64)((s) & 0xffff)) << 16) | ||
| 154 | #define DMA_CCMD_DID(d) ((u64)((d) & 0xffff)) | ||
| 155 | |||
| 156 | /* FECTL_REG */ | ||
| 157 | #define DMA_FECTL_IM (((u32)1) << 31) | ||
| 158 | |||
| 159 | /* FSTS_REG */ | ||
| 160 | #define DMA_FSTS_PPF ((u32)2) | ||
| 161 | #define DMA_FSTS_PFO ((u32)1) | ||
| 162 | #define dma_fsts_fault_record_index(s) (((s) >> 8) & 0xff) | ||
| 163 | |||
| 164 | /* FRCD_REG, 32 bits access */ | ||
| 165 | #define DMA_FRCD_F (((u32)1) << 31) | ||
| 166 | #define dma_frcd_type(d) ((d >> 30) & 1) | ||
| 167 | #define dma_frcd_fault_reason(c) (c & 0xff) | ||
| 168 | #define dma_frcd_source_id(c) (c & 0xffff) | ||
| 169 | #define dma_frcd_page_addr(d) (d & (((u64)-1) << 12)) /* low 64 bit */ | ||
| 170 | |||
| 171 | /* | ||
| 172 | * 0: Present | ||
| 173 | * 1-11: Reserved | ||
| 174 | * 12-63: Context Ptr (12 - (haw-1)) | ||
| 175 | * 64-127: Reserved | ||
| 176 | */ | ||
| 177 | struct root_entry { | ||
| 178 | u64 val; | ||
| 179 | u64 rsvd1; | ||
| 180 | }; | ||
| 181 | #define ROOT_ENTRY_NR (PAGE_SIZE_4K/sizeof(struct root_entry)) | ||
| 182 | static inline bool root_present(struct root_entry *root) | ||
| 183 | { | ||
| 184 | return (root->val & 1); | ||
| 185 | } | ||
| 186 | static inline void set_root_present(struct root_entry *root) | ||
| 187 | { | ||
| 188 | root->val |= 1; | ||
| 189 | } | ||
| 190 | static inline void set_root_value(struct root_entry *root, unsigned long value) | ||
| 191 | { | ||
| 192 | root->val |= value & PAGE_MASK_4K; | ||
| 193 | } | ||
| 194 | |||
| 195 | struct context_entry; | ||
| 196 | static inline struct context_entry * | ||
| 197 | get_context_addr_from_root(struct root_entry *root) | ||
| 198 | { | ||
| 199 | return (struct context_entry *) | ||
| 200 | (root_present(root)?phys_to_virt( | ||
| 201 | root->val & PAGE_MASK_4K): | ||
| 202 | NULL); | ||
| 203 | } | ||
| 204 | |||
| 205 | /* | ||
| 206 | * low 64 bits: | ||
| 207 | * 0: present | ||
| 208 | * 1: fault processing disable | ||
| 209 | * 2-3: translation type | ||
| 210 | * 12-63: address space root | ||
| 211 | * high 64 bits: | ||
| 212 | * 0-2: address width | ||
| 213 | * 3-6: aval | ||
| 214 | * 8-23: domain id | ||
| 215 | */ | ||
| 216 | struct context_entry { | ||
| 217 | u64 lo; | ||
| 218 | u64 hi; | ||
| 219 | }; | ||
| 220 | #define context_present(c) ((c).lo & 1) | ||
| 221 | #define context_fault_disable(c) (((c).lo >> 1) & 1) | ||
| 222 | #define context_translation_type(c) (((c).lo >> 2) & 3) | ||
| 223 | #define context_address_root(c) ((c).lo & PAGE_MASK_4K) | ||
| 224 | #define context_address_width(c) ((c).hi & 7) | ||
| 225 | #define context_domain_id(c) (((c).hi >> 8) & ((1 << 16) - 1)) | ||
| 226 | |||
| 227 | #define context_set_present(c) do {(c).lo |= 1;} while (0) | ||
| 228 | #define context_set_fault_enable(c) \ | ||
| 229 | do {(c).lo &= (((u64)-1) << 2) | 1;} while (0) | ||
| 230 | #define context_set_translation_type(c, val) \ | ||
| 231 | do { \ | ||
| 232 | (c).lo &= (((u64)-1) << 4) | 3; \ | ||
| 233 | (c).lo |= ((val) & 3) << 2; \ | ||
| 234 | } while (0) | ||
| 235 | #define CONTEXT_TT_MULTI_LEVEL 0 | ||
| 236 | #define context_set_address_root(c, val) \ | ||
| 237 | do {(c).lo |= (val) & PAGE_MASK_4K;} while (0) | ||
| 238 | #define context_set_address_width(c, val) do {(c).hi |= (val) & 7;} while (0) | ||
| 239 | #define context_set_domain_id(c, val) \ | ||
| 240 | do {(c).hi |= ((val) & ((1 << 16) - 1)) << 8;} while (0) | ||
| 241 | #define context_clear_entry(c) do {(c).lo = 0; (c).hi = 0;} while (0) | ||
| 242 | |||
| 243 | /* | ||
| 244 | * 0: readable | ||
| 245 | * 1: writable | ||
| 246 | * 2-6: reserved | ||
| 247 | * 7: super page | ||
| 248 | * 8-11: available | ||
| 249 | * 12-63: Host physcial address | ||
| 250 | */ | ||
| 251 | struct dma_pte { | ||
| 252 | u64 val; | ||
| 253 | }; | ||
| 254 | #define dma_clear_pte(p) do {(p).val = 0;} while (0) | ||
| 255 | |||
| 256 | #define DMA_PTE_READ (1) | ||
| 257 | #define DMA_PTE_WRITE (2) | ||
| 258 | |||
| 259 | #define dma_set_pte_readable(p) do {(p).val |= DMA_PTE_READ;} while (0) | ||
| 260 | #define dma_set_pte_writable(p) do {(p).val |= DMA_PTE_WRITE;} while (0) | ||
| 261 | #define dma_set_pte_prot(p, prot) \ | ||
| 262 | do {(p).val = ((p).val & ~3) | ((prot) & 3); } while (0) | ||
| 263 | #define dma_pte_addr(p) ((p).val & PAGE_MASK_4K) | ||
| 264 | #define dma_set_pte_addr(p, addr) do {\ | ||
| 265 | (p).val |= ((addr) & PAGE_MASK_4K); } while (0) | ||
| 266 | #define dma_pte_present(p) (((p).val & 3) != 0) | ||
| 267 | |||
| 268 | struct intel_iommu; | ||
| 269 | |||
| 270 | struct dmar_domain { | ||
| 271 | int id; /* domain id */ | ||
| 272 | struct intel_iommu *iommu; /* back pointer to owning iommu */ | ||
| 273 | |||
| 274 | struct list_head devices; /* all devices' list */ | ||
| 275 | struct iova_domain iovad; /* iova's that belong to this domain */ | ||
| 276 | |||
| 277 | struct dma_pte *pgd; /* virtual address */ | ||
| 278 | spinlock_t mapping_lock; /* page table lock */ | ||
| 279 | int gaw; /* max guest address width */ | ||
| 280 | |||
| 281 | /* adjusted guest address width, 0 is level 2 30-bit */ | ||
| 282 | int agaw; | ||
| 283 | |||
| 284 | #define DOMAIN_FLAG_MULTIPLE_DEVICES 1 | ||
| 285 | int flags; | ||
| 286 | }; | ||
| 287 | |||
| 288 | /* PCI domain-device relationship */ | ||
| 289 | struct device_domain_info { | ||
| 290 | struct list_head link; /* link to domain siblings */ | ||
| 291 | struct list_head global; /* link to global list */ | ||
| 292 | u8 bus; /* PCI bus numer */ | ||
| 293 | u8 devfn; /* PCI devfn number */ | ||
| 294 | struct pci_dev *dev; /* it's NULL for PCIE-to-PCI bridge */ | ||
| 295 | struct dmar_domain *domain; /* pointer to domain */ | ||
| 296 | }; | ||
| 297 | |||
| 298 | extern int init_dmars(void); | ||
| 299 | |||
| 300 | struct intel_iommu { | ||
| 301 | void __iomem *reg; /* Pointer to hardware regs, virtual addr */ | ||
| 302 | u64 cap; | ||
| 303 | u64 ecap; | ||
| 304 | unsigned long *domain_ids; /* bitmap of domains */ | ||
| 305 | struct dmar_domain **domains; /* ptr to domains */ | ||
| 306 | int seg; | ||
| 307 | u32 gcmd; /* Holds TE, EAFL. Don't need SRTP, SFL, WBF */ | ||
| 308 | spinlock_t lock; /* protect context, domain ids */ | ||
| 309 | spinlock_t register_lock; /* protect register handling */ | ||
| 310 | struct root_entry *root_entry; /* virtual address */ | ||
| 311 | |||
| 312 | unsigned int irq; | ||
| 313 | unsigned char name[7]; /* Device Name */ | ||
| 314 | struct msi_msg saved_msg; | ||
| 315 | struct sys_device sysdev; | ||
| 316 | }; | ||
| 317 | |||
| 318 | #ifndef CONFIG_DMAR_GFX_WA | ||
| 319 | static inline void iommu_prepare_gfx_mapping(void) | ||
| 320 | { | ||
| 321 | return; | ||
| 322 | } | ||
| 323 | #endif /* !CONFIG_DMAR_GFX_WA */ | ||
| 324 | |||
| 325 | #endif | ||
diff --git a/drivers/pci/iova.c b/drivers/pci/iova.c new file mode 100644 index 000000000000..a84571c29360 --- /dev/null +++ b/drivers/pci/iova.c | |||
| @@ -0,0 +1,394 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2006, Intel Corporation. | ||
| 3 | * | ||
| 4 | * This file is released under the GPLv2. | ||
| 5 | * | ||
| 6 | * Copyright (C) 2006 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include "iova.h" | ||
| 10 | |||
| 11 | void | ||
| 12 | init_iova_domain(struct iova_domain *iovad) | ||
| 13 | { | ||
| 14 | spin_lock_init(&iovad->iova_alloc_lock); | ||
| 15 | spin_lock_init(&iovad->iova_rbtree_lock); | ||
| 16 | iovad->rbroot = RB_ROOT; | ||
| 17 | iovad->cached32_node = NULL; | ||
| 18 | |||
| 19 | } | ||
| 20 | |||
| 21 | static struct rb_node * | ||
| 22 | __get_cached_rbnode(struct iova_domain *iovad, unsigned long *limit_pfn) | ||
| 23 | { | ||
| 24 | if ((*limit_pfn != DMA_32BIT_PFN) || | ||
| 25 | (iovad->cached32_node == NULL)) | ||
| 26 | return rb_last(&iovad->rbroot); | ||
| 27 | else { | ||
| 28 | struct rb_node *prev_node = rb_prev(iovad->cached32_node); | ||
| 29 | struct iova *curr_iova = | ||
| 30 | container_of(iovad->cached32_node, struct iova, node); | ||
| 31 | *limit_pfn = curr_iova->pfn_lo - 1; | ||
| 32 | return prev_node; | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | static void | ||
| 37 | __cached_rbnode_insert_update(struct iova_domain *iovad, | ||
| 38 | unsigned long limit_pfn, struct iova *new) | ||
| 39 | { | ||
| 40 | if (limit_pfn != DMA_32BIT_PFN) | ||
| 41 | return; | ||
| 42 | iovad->cached32_node = &new->node; | ||
| 43 | } | ||
| 44 | |||
| 45 | static void | ||
| 46 | __cached_rbnode_delete_update(struct iova_domain *iovad, struct iova *free) | ||
| 47 | { | ||
| 48 | struct iova *cached_iova; | ||
| 49 | struct rb_node *curr; | ||
| 50 | |||
| 51 | if (!iovad->cached32_node) | ||
| 52 | return; | ||
| 53 | curr = iovad->cached32_node; | ||
| 54 | cached_iova = container_of(curr, struct iova, node); | ||
| 55 | |||
| 56 | if (free->pfn_lo >= cached_iova->pfn_lo) | ||
| 57 | iovad->cached32_node = rb_next(&free->node); | ||
| 58 | } | ||
| 59 | |||
| 60 | /* Computes the padding size required, to make the | ||
| 61 | * the start address naturally aligned on its size | ||
| 62 | */ | ||
| 63 | static int | ||
| 64 | iova_get_pad_size(int size, unsigned int limit_pfn) | ||
| 65 | { | ||
| 66 | unsigned int pad_size = 0; | ||
| 67 | unsigned int order = ilog2(size); | ||
| 68 | |||
| 69 | if (order) | ||
| 70 | pad_size = (limit_pfn + 1) % (1 << order); | ||
| 71 | |||
| 72 | return pad_size; | ||
| 73 | } | ||
| 74 | |||
| 75 | static int __alloc_iova_range(struct iova_domain *iovad, unsigned long size, | ||
| 76 | unsigned long limit_pfn, struct iova *new, bool size_aligned) | ||
| 77 | { | ||
| 78 | struct rb_node *curr = NULL; | ||
| 79 | unsigned long flags; | ||
| 80 | unsigned long saved_pfn; | ||
| 81 | unsigned int pad_size = 0; | ||
| 82 | |||
| 83 | /* Walk the tree backwards */ | ||
| 84 | spin_lock_irqsave(&iovad->iova_rbtree_lock, flags); | ||
| 85 | saved_pfn = limit_pfn; | ||
| 86 | curr = __get_cached_rbnode(iovad, &limit_pfn); | ||
| 87 | while (curr) { | ||
| 88 | struct iova *curr_iova = container_of(curr, struct iova, node); | ||
| 89 | if (limit_pfn < curr_iova->pfn_lo) | ||
| 90 | goto move_left; | ||
| 91 | else if (limit_pfn < curr_iova->pfn_hi) | ||
| 92 | goto adjust_limit_pfn; | ||
| 93 | else { | ||
| 94 | if (size_aligned) | ||
| 95 | pad_size = iova_get_pad_size(size, limit_pfn); | ||
| 96 | if ((curr_iova->pfn_hi + size + pad_size) <= limit_pfn) | ||
| 97 | break; /* found a free slot */ | ||
| 98 | } | ||
| 99 | adjust_limit_pfn: | ||
| 100 | limit_pfn = curr_iova->pfn_lo - 1; | ||
| 101 | move_left: | ||
| 102 | curr = rb_prev(curr); | ||
| 103 | } | ||
| 104 | |||
| 105 | if (!curr) { | ||
| 106 | if (size_aligned) | ||
| 107 | pad_size = iova_get_pad_size(size, limit_pfn); | ||
| 108 | if ((IOVA_START_PFN + size + pad_size) > limit_pfn) { | ||
| 109 | spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags); | ||
| 110 | return -ENOMEM; | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | /* pfn_lo will point to size aligned address if size_aligned is set */ | ||
| 115 | new->pfn_lo = limit_pfn - (size + pad_size) + 1; | ||
| 116 | new->pfn_hi = new->pfn_lo + size - 1; | ||
| 117 | |||
| 118 | spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags); | ||
| 119 | return 0; | ||
| 120 | } | ||
| 121 | |||
| 122 | static void | ||
| 123 | iova_insert_rbtree(struct rb_root *root, struct iova *iova) | ||
| 124 | { | ||
| 125 | struct rb_node **new = &(root->rb_node), *parent = NULL; | ||
| 126 | /* Figure out where to put new node */ | ||
| 127 | while (*new) { | ||
| 128 | struct iova *this = container_of(*new, struct iova, node); | ||
| 129 | parent = *new; | ||
| 130 | |||
| 131 | if (iova->pfn_lo < this->pfn_lo) | ||
| 132 | new = &((*new)->rb_left); | ||
| 133 | else if (iova->pfn_lo > this->pfn_lo) | ||
| 134 | new = &((*new)->rb_right); | ||
| 135 | else | ||
| 136 | BUG(); /* this should not happen */ | ||
| 137 | } | ||
| 138 | /* Add new node and rebalance tree. */ | ||
| 139 | rb_link_node(&iova->node, parent, new); | ||
| 140 | rb_insert_color(&iova->node, root); | ||
| 141 | } | ||
| 142 | |||
| 143 | /** | ||
| 144 | * alloc_iova - allocates an iova | ||
| 145 | * @iovad - iova domain in question | ||
| 146 | * @size - size of page frames to allocate | ||
| 147 | * @limit_pfn - max limit address | ||
| 148 | * @size_aligned - set if size_aligned address range is required | ||
| 149 | * This function allocates an iova in the range limit_pfn to IOVA_START_PFN | ||
| 150 | * looking from limit_pfn instead from IOVA_START_PFN. If the size_aligned | ||
| 151 | * flag is set then the allocated address iova->pfn_lo will be naturally | ||
| 152 | * aligned on roundup_power_of_two(size). | ||
| 153 | */ | ||
| 154 | struct iova * | ||
| 155 | alloc_iova(struct iova_domain *iovad, unsigned long size, | ||
| 156 | unsigned long limit_pfn, | ||
| 157 | bool size_aligned) | ||
| 158 | { | ||
| 159 | unsigned long flags; | ||
| 160 | struct iova *new_iova; | ||
| 161 | int ret; | ||
| 162 | |||
| 163 | new_iova = alloc_iova_mem(); | ||
| 164 | if (!new_iova) | ||
| 165 | return NULL; | ||
| 166 | |||
| 167 | /* If size aligned is set then round the size to | ||
| 168 | * to next power of two. | ||
| 169 | */ | ||
| 170 | if (size_aligned) | ||
| 171 | size = __roundup_pow_of_two(size); | ||
| 172 | |||
| 173 | spin_lock_irqsave(&iovad->iova_alloc_lock, flags); | ||
| 174 | ret = __alloc_iova_range(iovad, size, limit_pfn, new_iova, | ||
| 175 | size_aligned); | ||
| 176 | |||
| 177 | if (ret) { | ||
| 178 | spin_unlock_irqrestore(&iovad->iova_alloc_lock, flags); | ||
| 179 | free_iova_mem(new_iova); | ||
| 180 | return NULL; | ||
| 181 | } | ||
| 182 | |||
| 183 | /* Insert the new_iova into domain rbtree by holding writer lock */ | ||
| 184 | spin_lock(&iovad->iova_rbtree_lock); | ||
| 185 | iova_insert_rbtree(&iovad->rbroot, new_iova); | ||
| 186 | __cached_rbnode_insert_update(iovad, limit_pfn, new_iova); | ||
| 187 | spin_unlock(&iovad->iova_rbtree_lock); | ||
| 188 | |||
| 189 | spin_unlock_irqrestore(&iovad->iova_alloc_lock, flags); | ||
| 190 | |||
| 191 | return new_iova; | ||
| 192 | } | ||
| 193 | |||
| 194 | /** | ||
| 195 | * find_iova - find's an iova for a given pfn | ||
| 196 | * @iovad - iova domain in question. | ||
| 197 | * pfn - page frame number | ||
| 198 | * This function finds and returns an iova belonging to the | ||
| 199 | * given doamin which matches the given pfn. | ||
| 200 | */ | ||
| 201 | struct iova *find_iova(struct iova_domain *iovad, unsigned long pfn) | ||
| 202 | { | ||
| 203 | unsigned long flags; | ||
| 204 | struct rb_node *node; | ||
| 205 | |||
| 206 | /* Take the lock so that no other thread is manipulating the rbtree */ | ||
| 207 | spin_lock_irqsave(&iovad->iova_rbtree_lock, flags); | ||
| 208 | node = iovad->rbroot.rb_node; | ||
| 209 | while (node) { | ||
| 210 | struct iova *iova = container_of(node, struct iova, node); | ||
| 211 | |||
| 212 | /* If pfn falls within iova's range, return iova */ | ||
| 213 | if ((pfn >= iova->pfn_lo) && (pfn <= iova->pfn_hi)) { | ||
| 214 | spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags); | ||
| 215 | /* We are not holding the lock while this iova | ||
| 216 | * is referenced by the caller as the same thread | ||
| 217 | * which called this function also calls __free_iova() | ||
| 218 | * and it is by desing that only one thread can possibly | ||
| 219 | * reference a particular iova and hence no conflict. | ||
| 220 | */ | ||
| 221 | return iova; | ||
| 222 | } | ||
| 223 | |||
| 224 | if (pfn < iova->pfn_lo) | ||
| 225 | node = node->rb_left; | ||
| 226 | else if (pfn > iova->pfn_lo) | ||
| 227 | node = node->rb_right; | ||
| 228 | } | ||
| 229 | |||
| 230 | spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags); | ||
| 231 | return NULL; | ||
| 232 | } | ||
| 233 | |||
| 234 | /** | ||
| 235 | * __free_iova - frees the given iova | ||
| 236 | * @iovad: iova domain in question. | ||
| 237 | * @iova: iova in question. | ||
| 238 | * Frees the given iova belonging to the giving domain | ||
| 239 | */ | ||
| 240 | void | ||
| 241 | __free_iova(struct iova_domain *iovad, struct iova *iova) | ||
| 242 | { | ||
| 243 | unsigned long flags; | ||
| 244 | |||
| 245 | spin_lock_irqsave(&iovad->iova_rbtree_lock, flags); | ||
| 246 | __cached_rbnode_delete_update(iovad, iova); | ||
| 247 | rb_erase(&iova->node, &iovad->rbroot); | ||
| 248 | spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags); | ||
| 249 | free_iova_mem(iova); | ||
| 250 | } | ||
| 251 | |||
| 252 | /** | ||
| 253 | * free_iova - finds and frees the iova for a given pfn | ||
| 254 | * @iovad: - iova domain in question. | ||
| 255 | * @pfn: - pfn that is allocated previously | ||
| 256 | * This functions finds an iova for a given pfn and then | ||
| 257 | * frees the iova from that domain. | ||
| 258 | */ | ||
| 259 | void | ||
| 260 | free_iova(struct iova_domain *iovad, unsigned long pfn) | ||
| 261 | { | ||
| 262 | struct iova *iova = find_iova(iovad, pfn); | ||
| 263 | if (iova) | ||
| 264 | __free_iova(iovad, iova); | ||
| 265 | |||
| 266 | } | ||
| 267 | |||
| 268 | /** | ||
| 269 | * put_iova_domain - destroys the iova doamin | ||
| 270 | * @iovad: - iova domain in question. | ||
| 271 | * All the iova's in that domain are destroyed. | ||
| 272 | */ | ||
| 273 | void put_iova_domain(struct iova_domain *iovad) | ||
| 274 | { | ||
| 275 | struct rb_node *node; | ||
| 276 | unsigned long flags; | ||
| 277 | |||
| 278 | spin_lock_irqsave(&iovad->iova_rbtree_lock, flags); | ||
| 279 | node = rb_first(&iovad->rbroot); | ||
| 280 | while (node) { | ||
| 281 | struct iova *iova = container_of(node, struct iova, node); | ||
| 282 | rb_erase(node, &iovad->rbroot); | ||
| 283 | free_iova_mem(iova); | ||
| 284 | node = rb_first(&iovad->rbroot); | ||
| 285 | } | ||
| 286 | spin_unlock_irqrestore(&iovad->iova_rbtree_lock, flags); | ||
| 287 | } | ||
| 288 | |||
| 289 | static int | ||
| 290 | __is_range_overlap(struct rb_node *node, | ||
| 291 | unsigned long pfn_lo, unsigned long pfn_hi) | ||
| 292 | { | ||
| 293 | struct iova *iova = container_of(node, struct iova, node); | ||
| 294 | |||
| 295 | if ((pfn_lo <= iova->pfn_hi) && (pfn_hi >= iova->pfn_lo)) | ||
| 296 | return 1; | ||
| 297 | return 0; | ||
| 298 | } | ||
| 299 | |||
| 300 | static struct iova * | ||
| 301 | __insert_new_range(struct iova_domain *iovad, | ||
| 302 | unsigned long pfn_lo, unsigned long pfn_hi) | ||
| 303 | { | ||
| 304 | struct iova *iova; | ||
| 305 | |||
| 306 | iova = alloc_iova_mem(); | ||
| 307 | if (!iova) | ||
| 308 | return iova; | ||
| 309 | |||
| 310 | iova->pfn_hi = pfn_hi; | ||
| 311 | iova->pfn_lo = pfn_lo; | ||
| 312 | iova_insert_rbtree(&iovad->rbroot, iova); | ||
| 313 | return iova; | ||
| 314 | } | ||
| 315 | |||
| 316 | static void | ||
| 317 | __adjust_overlap_range(struct iova *iova, | ||
| 318 | unsigned long *pfn_lo, unsigned long *pfn_hi) | ||
| 319 | { | ||
| 320 | if (*pfn_lo < iova->pfn_lo) | ||
| 321 | iova->pfn_lo = *pfn_lo; | ||
| 322 | if (*pfn_hi > iova->pfn_hi) | ||
| 323 | *pfn_lo = iova->pfn_hi + 1; | ||
| 324 | } | ||
| 325 | |||
| 326 | /** | ||
| 327 | * reserve_iova - reserves an iova in the given range | ||
| 328 | * @iovad: - iova domain pointer | ||
| 329 | * @pfn_lo: - lower page frame address | ||
| 330 | * @pfn_hi:- higher pfn adderss | ||
| 331 | * This function allocates reserves the address range from pfn_lo to pfn_hi so | ||
| 332 | * that this address is not dished out as part of alloc_iova. | ||
| 333 | */ | ||
| 334 | struct iova * | ||
| 335 | reserve_iova(struct iova_domain *iovad, | ||
| 336 | unsigned long pfn_lo, unsigned long pfn_hi) | ||
| 337 | { | ||
| 338 | struct rb_node *node; | ||
| 339 | unsigned long flags; | ||
| 340 | struct iova *iova; | ||
| 341 | unsigned int overlap = 0; | ||
| 342 | |||
| 343 | spin_lock_irqsave(&iovad->iova_alloc_lock, flags); | ||
| 344 | spin_lock(&iovad->iova_rbtree_lock); | ||
| 345 | for (node = rb_first(&iovad->rbroot); node; node = rb_next(node)) { | ||
| 346 | if (__is_range_overlap(node, pfn_lo, pfn_hi)) { | ||
| 347 | iova = container_of(node, struct iova, node); | ||
| 348 | __adjust_overlap_range(iova, &pfn_lo, &pfn_hi); | ||
| 349 | if ((pfn_lo >= iova->pfn_lo) && | ||
| 350 | (pfn_hi <= iova->pfn_hi)) | ||
| 351 | goto finish; | ||
| 352 | overlap = 1; | ||
| 353 | |||
| 354 | } else if (overlap) | ||
| 355 | break; | ||
| 356 | } | ||
| 357 | |||
| 358 | /* We are here either becasue this is the first reserver node | ||
| 359 | * or need to insert remaining non overlap addr range | ||
| 360 | */ | ||
| 361 | iova = __insert_new_range(iovad, pfn_lo, pfn_hi); | ||
| 362 | finish: | ||
| 363 | |||
| 364 | spin_unlock(&iovad->iova_rbtree_lock); | ||
| 365 | spin_unlock_irqrestore(&iovad->iova_alloc_lock, flags); | ||
| 366 | return iova; | ||
| 367 | } | ||
| 368 | |||
| 369 | /** | ||
| 370 | * copy_reserved_iova - copies the reserved between domains | ||
| 371 | * @from: - source doamin from where to copy | ||
| 372 | * @to: - destination domin where to copy | ||
| 373 | * This function copies reserved iova's from one doamin to | ||
| 374 | * other. | ||
| 375 | */ | ||
| 376 | void | ||
| 377 | copy_reserved_iova(struct iova_domain *from, struct iova_domain *to) | ||
| 378 | { | ||
| 379 | unsigned long flags; | ||
| 380 | struct rb_node *node; | ||
| 381 | |||
| 382 | spin_lock_irqsave(&from->iova_alloc_lock, flags); | ||
| 383 | spin_lock(&from->iova_rbtree_lock); | ||
| 384 | for (node = rb_first(&from->rbroot); node; node = rb_next(node)) { | ||
| 385 | struct iova *iova = container_of(node, struct iova, node); | ||
| 386 | struct iova *new_iova; | ||
| 387 | new_iova = reserve_iova(to, iova->pfn_lo, iova->pfn_hi); | ||
| 388 | if (!new_iova) | ||
| 389 | printk(KERN_ERR "Reserve iova range %lx@%lx failed\n", | ||
| 390 | iova->pfn_lo, iova->pfn_lo); | ||
| 391 | } | ||
| 392 | spin_unlock(&from->iova_rbtree_lock); | ||
| 393 | spin_unlock_irqrestore(&from->iova_alloc_lock, flags); | ||
| 394 | } | ||
diff --git a/drivers/pci/iova.h b/drivers/pci/iova.h new file mode 100644 index 000000000000..ae3028d5a941 --- /dev/null +++ b/drivers/pci/iova.h | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2006, Intel Corporation. | ||
| 3 | * | ||
| 4 | * This file is released under the GPLv2. | ||
| 5 | * | ||
| 6 | * Copyright (C) 2006 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | ||
| 7 | * | ||
| 8 | */ | ||
| 9 | |||
| 10 | #ifndef _IOVA_H_ | ||
| 11 | #define _IOVA_H_ | ||
| 12 | |||
| 13 | #include <linux/types.h> | ||
| 14 | #include <linux/kernel.h> | ||
| 15 | #include <linux/rbtree.h> | ||
| 16 | #include <linux/dma-mapping.h> | ||
| 17 | |||
| 18 | /* | ||
| 19 | * We need a fixed PAGE_SIZE of 4K irrespective of | ||
| 20 | * arch PAGE_SIZE for IOMMU page tables. | ||
| 21 | */ | ||
| 22 | #define PAGE_SHIFT_4K (12) | ||
| 23 | #define PAGE_SIZE_4K (1UL << PAGE_SHIFT_4K) | ||
| 24 | #define PAGE_MASK_4K (((u64)-1) << PAGE_SHIFT_4K) | ||
| 25 | #define PAGE_ALIGN_4K(addr) (((addr) + PAGE_SIZE_4K - 1) & PAGE_MASK_4K) | ||
| 26 | |||
| 27 | /* IO virtual address start page frame number */ | ||
| 28 | #define IOVA_START_PFN (1) | ||
| 29 | |||
| 30 | #define IOVA_PFN(addr) ((addr) >> PAGE_SHIFT_4K) | ||
| 31 | #define DMA_32BIT_PFN IOVA_PFN(DMA_32BIT_MASK) | ||
| 32 | #define DMA_64BIT_PFN IOVA_PFN(DMA_64BIT_MASK) | ||
| 33 | |||
| 34 | /* iova structure */ | ||
| 35 | struct iova { | ||
| 36 | struct rb_node node; | ||
| 37 | unsigned long pfn_hi; /* IOMMU dish out addr hi */ | ||
| 38 | unsigned long pfn_lo; /* IOMMU dish out addr lo */ | ||
| 39 | }; | ||
| 40 | |||
| 41 | /* holds all the iova translations for a domain */ | ||
| 42 | struct iova_domain { | ||
| 43 | spinlock_t iova_alloc_lock;/* Lock to protect iova allocation */ | ||
| 44 | spinlock_t iova_rbtree_lock; /* Lock to protect update of rbtree */ | ||
| 45 | struct rb_root rbroot; /* iova domain rbtree root */ | ||
| 46 | struct rb_node *cached32_node; /* Save last alloced node */ | ||
| 47 | }; | ||
| 48 | |||
| 49 | struct iova *alloc_iova_mem(void); | ||
| 50 | void free_iova_mem(struct iova *iova); | ||
| 51 | void free_iova(struct iova_domain *iovad, unsigned long pfn); | ||
| 52 | void __free_iova(struct iova_domain *iovad, struct iova *iova); | ||
| 53 | struct iova *alloc_iova(struct iova_domain *iovad, unsigned long size, | ||
| 54 | unsigned long limit_pfn, | ||
| 55 | bool size_aligned); | ||
| 56 | struct iova *reserve_iova(struct iova_domain *iovad, unsigned long pfn_lo, | ||
| 57 | unsigned long pfn_hi); | ||
| 58 | void copy_reserved_iova(struct iova_domain *from, struct iova_domain *to); | ||
| 59 | void init_iova_domain(struct iova_domain *iovad); | ||
| 60 | struct iova *find_iova(struct iova_domain *iovad, unsigned long pfn); | ||
| 61 | void put_iova_domain(struct iova_domain *iovad); | ||
| 62 | |||
| 63 | #endif | ||
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 6fda33de84e8..fc87e14b50de 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
| @@ -90,3 +90,4 @@ pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev) | |||
| 90 | return NULL; | 90 | return NULL; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev); | ||
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 5db6b6690b59..463a5a9d583d 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
| @@ -837,6 +837,19 @@ static void pci_release_dev(struct device *dev) | |||
| 837 | kfree(pci_dev); | 837 | kfree(pci_dev); |
| 838 | } | 838 | } |
| 839 | 839 | ||
| 840 | static void set_pcie_port_type(struct pci_dev *pdev) | ||
| 841 | { | ||
| 842 | int pos; | ||
| 843 | u16 reg16; | ||
| 844 | |||
| 845 | pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); | ||
| 846 | if (!pos) | ||
| 847 | return; | ||
| 848 | pdev->is_pcie = 1; | ||
| 849 | pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, ®16); | ||
| 850 | pdev->pcie_type = (reg16 & PCI_EXP_FLAGS_TYPE) >> 4; | ||
| 851 | } | ||
| 852 | |||
| 840 | /** | 853 | /** |
| 841 | * pci_cfg_space_size - get the configuration space size of the PCI device. | 854 | * pci_cfg_space_size - get the configuration space size of the PCI device. |
| 842 | * @dev: PCI device | 855 | * @dev: PCI device |
| @@ -951,6 +964,7 @@ pci_scan_device(struct pci_bus *bus, int devfn) | |||
| 951 | dev->device = (l >> 16) & 0xffff; | 964 | dev->device = (l >> 16) & 0xffff; |
| 952 | dev->cfg_size = pci_cfg_space_size(dev); | 965 | dev->cfg_size = pci_cfg_space_size(dev); |
| 953 | dev->error_state = pci_channel_io_normal; | 966 | dev->error_state = pci_channel_io_normal; |
| 967 | set_pcie_port_type(dev); | ||
| 954 | 968 | ||
| 955 | /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) | 969 | /* Assume 32-bit PCI; let 64-bit PCI cards (which are far rarer) |
| 956 | set this higher, assuming the system even supports it. */ | 970 | set this higher, assuming the system even supports it. */ |
diff --git a/drivers/pci/search.c b/drivers/pci/search.c index c6e79d01ce3d..b001b5922e33 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c | |||
| @@ -14,6 +14,40 @@ | |||
| 14 | #include "pci.h" | 14 | #include "pci.h" |
| 15 | 15 | ||
| 16 | DECLARE_RWSEM(pci_bus_sem); | 16 | DECLARE_RWSEM(pci_bus_sem); |
| 17 | /* | ||
| 18 | * find the upstream PCIE-to-PCI bridge of a PCI device | ||
| 19 | * if the device is PCIE, return NULL | ||
| 20 | * if the device isn't connected to a PCIE bridge (that is its parent is a | ||
| 21 | * legacy PCI bridge and the bridge is directly connected to bus 0), return its | ||
| 22 | * parent | ||
| 23 | */ | ||
| 24 | struct pci_dev * | ||
| 25 | pci_find_upstream_pcie_bridge(struct pci_dev *pdev) | ||
| 26 | { | ||
| 27 | struct pci_dev *tmp = NULL; | ||
| 28 | |||
| 29 | if (pdev->is_pcie) | ||
| 30 | return NULL; | ||
| 31 | while (1) { | ||
| 32 | if (!pdev->bus->self) | ||
| 33 | break; | ||
| 34 | pdev = pdev->bus->self; | ||
| 35 | /* a p2p bridge */ | ||
| 36 | if (!pdev->is_pcie) { | ||
| 37 | tmp = pdev; | ||
| 38 | continue; | ||
| 39 | } | ||
| 40 | /* PCI device should connect to a PCIE bridge */ | ||
| 41 | if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) { | ||
| 42 | /* Busted hardware? */ | ||
| 43 | WARN_ON_ONCE(1); | ||
| 44 | return NULL; | ||
| 45 | } | ||
| 46 | return pdev; | ||
| 47 | } | ||
| 48 | |||
| 49 | return tmp; | ||
| 50 | } | ||
| 17 | 51 | ||
| 18 | static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr) | 52 | static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr) |
| 19 | { | 53 | { |
diff --git a/drivers/power/apm_power.c b/drivers/power/apm_power.c index 39a90a6f0f80..bbf3ee10da04 100644 --- a/drivers/power/apm_power.c +++ b/drivers/power/apm_power.c | |||
| @@ -26,65 +26,124 @@ static struct power_supply *main_battery; | |||
| 26 | static void find_main_battery(void) | 26 | static void find_main_battery(void) |
| 27 | { | 27 | { |
| 28 | struct device *dev; | 28 | struct device *dev; |
| 29 | struct power_supply *bat, *batm; | 29 | struct power_supply *bat = NULL; |
| 30 | struct power_supply *max_charge_bat = NULL; | ||
| 31 | struct power_supply *max_energy_bat = NULL; | ||
| 30 | union power_supply_propval full; | 32 | union power_supply_propval full; |
| 31 | int max_charge = 0; | 33 | int max_charge = 0; |
| 34 | int max_energy = 0; | ||
| 32 | 35 | ||
| 33 | main_battery = NULL; | 36 | main_battery = NULL; |
| 34 | batm = NULL; | 37 | |
| 35 | list_for_each_entry(dev, &power_supply_class->devices, node) { | 38 | list_for_each_entry(dev, &power_supply_class->devices, node) { |
| 36 | bat = dev_get_drvdata(dev); | 39 | bat = dev_get_drvdata(dev); |
| 37 | /* If none of battery devices cantains 'use_for_apm' flag, | 40 | |
| 38 | choice one with maximum design charge */ | 41 | if (bat->use_for_apm) { |
| 39 | if (!PSY_PROP(bat, CHARGE_FULL_DESIGN, &full)) { | 42 | /* nice, we explicitly asked to report this battery. */ |
| 43 | main_battery = bat; | ||
| 44 | return; | ||
| 45 | } | ||
| 46 | |||
| 47 | if (!PSY_PROP(bat, CHARGE_FULL_DESIGN, &full) || | ||
| 48 | !PSY_PROP(bat, CHARGE_FULL, &full)) { | ||
| 40 | if (full.intval > max_charge) { | 49 | if (full.intval > max_charge) { |
| 41 | batm = bat; | 50 | max_charge_bat = bat; |
| 42 | max_charge = full.intval; | 51 | max_charge = full.intval; |
| 43 | } | 52 | } |
| 53 | } else if (!PSY_PROP(bat, ENERGY_FULL_DESIGN, &full) || | ||
| 54 | !PSY_PROP(bat, ENERGY_FULL, &full)) { | ||
| 55 | if (full.intval > max_energy) { | ||
| 56 | max_energy_bat = bat; | ||
| 57 | max_energy = full.intval; | ||
| 58 | } | ||
| 44 | } | 59 | } |
| 60 | } | ||
| 45 | 61 | ||
| 46 | if (bat->use_for_apm) | 62 | if ((max_energy_bat && max_charge_bat) && |
| 47 | main_battery = bat; | 63 | (max_energy_bat != max_charge_bat)) { |
| 64 | /* try guess battery with more capacity */ | ||
| 65 | if (!PSY_PROP(max_charge_bat, VOLTAGE_MAX_DESIGN, &full)) { | ||
| 66 | if (max_energy > max_charge * full.intval) | ||
| 67 | main_battery = max_energy_bat; | ||
| 68 | else | ||
| 69 | main_battery = max_charge_bat; | ||
| 70 | } else if (!PSY_PROP(max_energy_bat, VOLTAGE_MAX_DESIGN, | ||
| 71 | &full)) { | ||
| 72 | if (max_charge > max_energy / full.intval) | ||
| 73 | main_battery = max_charge_bat; | ||
| 74 | else | ||
| 75 | main_battery = max_energy_bat; | ||
| 76 | } else { | ||
| 77 | /* give up, choice any */ | ||
| 78 | main_battery = max_energy_bat; | ||
| 79 | } | ||
| 80 | } else if (max_charge_bat) { | ||
| 81 | main_battery = max_charge_bat; | ||
| 82 | } else if (max_energy_bat) { | ||
| 83 | main_battery = max_energy_bat; | ||
| 84 | } else { | ||
| 85 | /* give up, try the last if any */ | ||
| 86 | main_battery = bat; | ||
| 48 | } | 87 | } |
| 49 | if (!main_battery) | ||
| 50 | main_battery = batm; | ||
| 51 | } | 88 | } |
| 52 | 89 | ||
| 53 | static int calculate_time(int status) | 90 | static int calculate_time(int status, int using_charge) |
| 54 | { | 91 | { |
| 55 | union power_supply_propval charge_full, charge_empty; | 92 | union power_supply_propval full; |
| 56 | union power_supply_propval charge, I; | 93 | union power_supply_propval empty; |
| 94 | union power_supply_propval cur; | ||
| 95 | union power_supply_propval I; | ||
| 96 | enum power_supply_property full_prop; | ||
| 97 | enum power_supply_property full_design_prop; | ||
| 98 | enum power_supply_property empty_prop; | ||
| 99 | enum power_supply_property empty_design_prop; | ||
| 100 | enum power_supply_property cur_avg_prop; | ||
| 101 | enum power_supply_property cur_now_prop; | ||
| 57 | 102 | ||
| 58 | if (MPSY_PROP(CHARGE_FULL, &charge_full)) { | 103 | if (MPSY_PROP(CURRENT_AVG, &I)) { |
| 59 | /* if battery can't report this property, use design value */ | 104 | /* if battery can't report average value, use momentary */ |
| 60 | if (MPSY_PROP(CHARGE_FULL_DESIGN, &charge_full)) | 105 | if (MPSY_PROP(CURRENT_NOW, &I)) |
| 61 | return -1; | 106 | return -1; |
| 62 | } | 107 | } |
| 63 | 108 | ||
| 64 | if (MPSY_PROP(CHARGE_EMPTY, &charge_empty)) { | 109 | if (using_charge) { |
| 65 | /* if battery can't report this property, use design value */ | 110 | full_prop = POWER_SUPPLY_PROP_CHARGE_FULL; |
| 66 | if (MPSY_PROP(CHARGE_EMPTY_DESIGN, &charge_empty)) | 111 | full_design_prop = POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN; |
| 67 | charge_empty.intval = 0; | 112 | empty_prop = POWER_SUPPLY_PROP_CHARGE_EMPTY; |
| 113 | empty_design_prop = POWER_SUPPLY_PROP_CHARGE_EMPTY; | ||
| 114 | cur_avg_prop = POWER_SUPPLY_PROP_CHARGE_AVG; | ||
| 115 | cur_now_prop = POWER_SUPPLY_PROP_CHARGE_NOW; | ||
| 116 | } else { | ||
| 117 | full_prop = POWER_SUPPLY_PROP_ENERGY_FULL; | ||
| 118 | full_design_prop = POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN; | ||
| 119 | empty_prop = POWER_SUPPLY_PROP_ENERGY_EMPTY; | ||
| 120 | empty_design_prop = POWER_SUPPLY_PROP_CHARGE_EMPTY; | ||
| 121 | cur_avg_prop = POWER_SUPPLY_PROP_ENERGY_AVG; | ||
| 122 | cur_now_prop = POWER_SUPPLY_PROP_ENERGY_NOW; | ||
| 68 | } | 123 | } |
| 69 | 124 | ||
| 70 | if (MPSY_PROP(CHARGE_AVG, &charge)) { | 125 | if (_MPSY_PROP(full_prop, &full)) { |
| 71 | /* if battery can't report average value, use momentary */ | 126 | /* if battery can't report this property, use design value */ |
| 72 | if (MPSY_PROP(CHARGE_NOW, &charge)) | 127 | if (_MPSY_PROP(full_design_prop, &full)) |
| 73 | return -1; | 128 | return -1; |
| 74 | } | 129 | } |
| 75 | 130 | ||
| 76 | if (MPSY_PROP(CURRENT_AVG, &I)) { | 131 | if (_MPSY_PROP(empty_prop, &empty)) { |
| 132 | /* if battery can't report this property, use design value */ | ||
| 133 | if (_MPSY_PROP(empty_design_prop, &empty)) | ||
| 134 | empty.intval = 0; | ||
| 135 | } | ||
| 136 | |||
| 137 | if (_MPSY_PROP(cur_avg_prop, &cur)) { | ||
| 77 | /* if battery can't report average value, use momentary */ | 138 | /* if battery can't report average value, use momentary */ |
| 78 | if (MPSY_PROP(CURRENT_NOW, &I)) | 139 | if (_MPSY_PROP(cur_now_prop, &cur)) |
| 79 | return -1; | 140 | return -1; |
| 80 | } | 141 | } |
| 81 | 142 | ||
| 82 | if (status == POWER_SUPPLY_STATUS_CHARGING) | 143 | if (status == POWER_SUPPLY_STATUS_CHARGING) |
| 83 | return ((charge.intval - charge_full.intval) * 60L) / | 144 | return ((cur.intval - full.intval) * 60L) / I.intval; |
| 84 | I.intval; | ||
| 85 | else | 145 | else |
| 86 | return -((charge.intval - charge_empty.intval) * 60L) / | 146 | return -((cur.intval - empty.intval) * 60L) / I.intval; |
| 87 | I.intval; | ||
| 88 | } | 147 | } |
| 89 | 148 | ||
| 90 | static int calculate_capacity(int using_charge) | 149 | static int calculate_capacity(int using_charge) |
| @@ -200,18 +259,22 @@ static void apm_battery_apm_get_power_status(struct apm_power_info *info) | |||
| 200 | info->units = APM_UNITS_MINS; | 259 | info->units = APM_UNITS_MINS; |
| 201 | 260 | ||
| 202 | if (status.intval == POWER_SUPPLY_STATUS_CHARGING) { | 261 | if (status.intval == POWER_SUPPLY_STATUS_CHARGING) { |
| 203 | if (MPSY_PROP(TIME_TO_FULL_AVG, &time_to_full)) { | 262 | if (!MPSY_PROP(TIME_TO_FULL_AVG, &time_to_full) || |
| 204 | if (MPSY_PROP(TIME_TO_FULL_NOW, &time_to_full)) | 263 | !MPSY_PROP(TIME_TO_FULL_NOW, &time_to_full)) { |
| 205 | info->time = calculate_time(status.intval); | 264 | info->time = time_to_full.intval / 60; |
| 206 | else | 265 | } else { |
| 207 | info->time = time_to_full.intval / 60; | 266 | info->time = calculate_time(status.intval, 0); |
| 267 | if (info->time == -1) | ||
| 268 | info->time = calculate_time(status.intval, 1); | ||
| 208 | } | 269 | } |
| 209 | } else { | 270 | } else { |
| 210 | if (MPSY_PROP(TIME_TO_EMPTY_AVG, &time_to_empty)) { | 271 | if (!MPSY_PROP(TIME_TO_EMPTY_AVG, &time_to_empty) || |
| 211 | if (MPSY_PROP(TIME_TO_EMPTY_NOW, &time_to_empty)) | 272 | !MPSY_PROP(TIME_TO_EMPTY_NOW, &time_to_empty)) { |
| 212 | info->time = calculate_time(status.intval); | 273 | info->time = time_to_empty.intval / 60; |
| 213 | else | 274 | } else { |
| 214 | info->time = time_to_empty.intval / 60; | 275 | info->time = calculate_time(status.intval, 0); |
| 276 | if (info->time == -1) | ||
| 277 | info->time = calculate_time(status.intval, 1); | ||
| 215 | } | 278 | } |
| 216 | } | 279 | } |
| 217 | 280 | ||
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index fb14014ee16e..afb262b4be15 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
| @@ -1840,7 +1840,7 @@ static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, | |||
| 1840 | (scsi_bufflen(srb) < TW_MIN_SGL_LENGTH)) { | 1840 | (scsi_bufflen(srb) < TW_MIN_SGL_LENGTH)) { |
| 1841 | if (srb->sc_data_direction == DMA_TO_DEVICE || srb->sc_data_direction == DMA_BIDIRECTIONAL) { | 1841 | if (srb->sc_data_direction == DMA_TO_DEVICE || srb->sc_data_direction == DMA_BIDIRECTIONAL) { |
| 1842 | struct scatterlist *sg = scsi_sglist(srb); | 1842 | struct scatterlist *sg = scsi_sglist(srb); |
| 1843 | char *buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 1843 | char *buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; |
| 1844 | memcpy(tw_dev->generic_buffer_virt[request_id], buf, sg->length); | 1844 | memcpy(tw_dev->generic_buffer_virt[request_id], buf, sg->length); |
| 1845 | kunmap_atomic(buf - sg->offset, KM_IRQ0); | 1845 | kunmap_atomic(buf - sg->offset, KM_IRQ0); |
| 1846 | } | 1846 | } |
| @@ -1919,7 +1919,7 @@ static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int re | |||
| 1919 | char *buf; | 1919 | char *buf; |
| 1920 | unsigned long flags = 0; | 1920 | unsigned long flags = 0; |
| 1921 | local_irq_save(flags); | 1921 | local_irq_save(flags); |
| 1922 | buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 1922 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; |
| 1923 | memcpy(buf, tw_dev->generic_buffer_virt[request_id], sg->length); | 1923 | memcpy(buf, tw_dev->generic_buffer_virt[request_id], sg->length); |
| 1924 | kunmap_atomic(buf - sg->offset, KM_IRQ0); | 1924 | kunmap_atomic(buf - sg->offset, KM_IRQ0); |
| 1925 | local_irq_restore(flags); | 1925 | local_irq_restore(flags); |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index a64153b96034..59716ebeb10c 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
| @@ -1469,7 +1469,7 @@ static void tw_transfer_internal(TW_Device_Extension *tw_dev, int request_id, | |||
| 1469 | struct scatterlist *sg = scsi_sglist(cmd); | 1469 | struct scatterlist *sg = scsi_sglist(cmd); |
| 1470 | 1470 | ||
| 1471 | local_irq_save(flags); | 1471 | local_irq_save(flags); |
| 1472 | buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 1472 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; |
| 1473 | transfer_len = min(sg->length, len); | 1473 | transfer_len = min(sg->length, len); |
| 1474 | 1474 | ||
| 1475 | memcpy(buf, data, transfer_len); | 1475 | memcpy(buf, data, transfer_len); |
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 988f0bc5eda5..2597209183d0 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c | |||
| @@ -298,8 +298,7 @@ static __inline__ void initialize_SCp(Scsi_Cmnd * cmd) | |||
| 298 | if (cmd->use_sg) { | 298 | if (cmd->use_sg) { |
| 299 | cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; | 299 | cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; |
| 300 | cmd->SCp.buffers_residual = cmd->use_sg - 1; | 300 | cmd->SCp.buffers_residual = cmd->use_sg - 1; |
| 301 | cmd->SCp.ptr = page_address(cmd->SCp.buffer->page)+ | 301 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 302 | cmd->SCp.buffer->offset; | ||
| 303 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 302 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 304 | } else { | 303 | } else { |
| 305 | cmd->SCp.buffer = NULL; | 304 | cmd->SCp.buffer = NULL; |
| @@ -2143,8 +2142,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { | |||
| 2143 | ++cmd->SCp.buffer; | 2142 | ++cmd->SCp.buffer; |
| 2144 | --cmd->SCp.buffers_residual; | 2143 | --cmd->SCp.buffers_residual; |
| 2145 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 2144 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 2146 | cmd->SCp.ptr = page_address(cmd->SCp.buffer->page)+ | 2145 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 2147 | cmd->SCp.buffer->offset; | ||
| 2148 | dprintk(NDEBUG_INFORMATION, ("scsi%d : %d bytes and %d buffers left\n", instance->host_no, cmd->SCp.this_residual, cmd->SCp.buffers_residual)); | 2146 | dprintk(NDEBUG_INFORMATION, ("scsi%d : %d bytes and %d buffers left\n", instance->host_no, cmd->SCp.this_residual, cmd->SCp.buffers_residual)); |
| 2149 | } | 2147 | } |
| 2150 | /* | 2148 | /* |
diff --git a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c index 96e8e29aa05d..5b0efc903918 100644 --- a/drivers/scsi/NCR53C9x.c +++ b/drivers/scsi/NCR53C9x.c | |||
| @@ -927,7 +927,7 @@ static void esp_get_dmabufs(struct NCR_ESP *esp, Scsi_Cmnd *sp) | |||
| 927 | esp->dma_mmu_get_scsi_sgl(esp, sp); | 927 | esp->dma_mmu_get_scsi_sgl(esp, sp); |
| 928 | else | 928 | else |
| 929 | sp->SCp.ptr = | 929 | sp->SCp.ptr = |
| 930 | (char *) virt_to_phys((page_address(sp->SCp.buffer->page) + sp->SCp.buffer->offset)); | 930 | (char *) virt_to_phys(sg_virt(sp->SCp.buffer)); |
| 931 | } | 931 | } |
| 932 | } | 932 | } |
| 933 | 933 | ||
| @@ -1748,7 +1748,7 @@ static inline void advance_sg(struct NCR_ESP *esp, Scsi_Cmnd *sp) | |||
| 1748 | if (esp->dma_advance_sg) | 1748 | if (esp->dma_advance_sg) |
| 1749 | esp->dma_advance_sg (sp); | 1749 | esp->dma_advance_sg (sp); |
| 1750 | else | 1750 | else |
| 1751 | sp->SCp.ptr = (char *) virt_to_phys((page_address(sp->SCp.buffer->page) + sp->SCp.buffer->offset)); | 1751 | sp->SCp.ptr = (char *) virt_to_phys(sg_virt(sp->SCp.buffer)); |
| 1752 | 1752 | ||
| 1753 | } | 1753 | } |
| 1754 | 1754 | ||
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c index 3168a1794849..137d065db3da 100644 --- a/drivers/scsi/NCR53c406a.c +++ b/drivers/scsi/NCR53c406a.c | |||
| @@ -875,8 +875,7 @@ static void NCR53c406a_intr(void *dev_id) | |||
| 875 | outb(TRANSFER_INFO | DMA_OP, CMD_REG); | 875 | outb(TRANSFER_INFO | DMA_OP, CMD_REG); |
| 876 | #if USE_PIO | 876 | #if USE_PIO |
| 877 | scsi_for_each_sg(current_SC, sg, scsi_sg_count(current_SC), i) { | 877 | scsi_for_each_sg(current_SC, sg, scsi_sg_count(current_SC), i) { |
| 878 | NCR53c406a_pio_write(page_address(sg->page) + sg->offset, | 878 | NCR53c406a_pio_write(sg_virt(sg), sg->length); |
| 879 | sg->length); | ||
| 880 | } | 879 | } |
| 881 | REG0; | 880 | REG0; |
| 882 | #endif /* USE_PIO */ | 881 | #endif /* USE_PIO */ |
| @@ -897,8 +896,7 @@ static void NCR53c406a_intr(void *dev_id) | |||
| 897 | outb(TRANSFER_INFO | DMA_OP, CMD_REG); | 896 | outb(TRANSFER_INFO | DMA_OP, CMD_REG); |
| 898 | #if USE_PIO | 897 | #if USE_PIO |
| 899 | scsi_for_each_sg(current_SC, sg, scsi_sg_count(current_SC), i) { | 898 | scsi_for_each_sg(current_SC, sg, scsi_sg_count(current_SC), i) { |
| 900 | NCR53c406a_pio_read(page_address(sg->page) + sg->offset, | 899 | NCR53c406a_pio_read(sg_virt(sg), sg->length); |
| 901 | sg->length); | ||
| 902 | } | 900 | } |
| 903 | REG0; | 901 | REG0; |
| 904 | #endif /* USE_PIO */ | 902 | #endif /* USE_PIO */ |
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 80e448d0f3db..a77ab8d693d4 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
| @@ -356,7 +356,7 @@ static void aac_internal_transfer(struct scsi_cmnd *scsicmd, void *data, unsigne | |||
| 356 | int transfer_len; | 356 | int transfer_len; |
| 357 | struct scatterlist *sg = scsi_sglist(scsicmd); | 357 | struct scatterlist *sg = scsi_sglist(scsicmd); |
| 358 | 358 | ||
| 359 | buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 359 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; |
| 360 | transfer_len = min(sg->length, len + offset); | 360 | transfer_len = min(sg->length, len + offset); |
| 361 | 361 | ||
| 362 | transfer_len -= offset; | 362 | transfer_len -= offset; |
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index a58c265dc8af..ea8c69947644 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c | |||
| @@ -613,7 +613,7 @@ struct aha152x_scdata { | |||
| 613 | #define SCNEXT(SCpnt) SCDATA(SCpnt)->next | 613 | #define SCNEXT(SCpnt) SCDATA(SCpnt)->next |
| 614 | #define SCSEM(SCpnt) SCDATA(SCpnt)->done | 614 | #define SCSEM(SCpnt) SCDATA(SCpnt)->done |
| 615 | 615 | ||
| 616 | #define SG_ADDRESS(buffer) ((char *) (page_address((buffer)->page)+(buffer)->offset)) | 616 | #define SG_ADDRESS(buffer) ((char *) sg_virt((buffer))) |
| 617 | 617 | ||
| 618 | /* state handling */ | 618 | /* state handling */ |
| 619 | static void seldi_run(struct Scsi_Host *shpnt); | 619 | static void seldi_run(struct Scsi_Host *shpnt); |
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 961a1882cb7e..bbcc2c52d79f 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
| @@ -49,7 +49,7 @@ | |||
| 49 | #include "aha1542.h" | 49 | #include "aha1542.h" |
| 50 | 50 | ||
| 51 | #define SCSI_BUF_PA(address) isa_virt_to_bus(address) | 51 | #define SCSI_BUF_PA(address) isa_virt_to_bus(address) |
| 52 | #define SCSI_SG_PA(sgent) (isa_page_to_bus((sgent)->page) + (sgent)->offset) | 52 | #define SCSI_SG_PA(sgent) (isa_page_to_bus(sg_page((sgent))) + (sgent)->offset) |
| 53 | 53 | ||
| 54 | static void BAD_DMA(void *address, unsigned int length) | 54 | static void BAD_DMA(void *address, unsigned int length) |
| 55 | { | 55 | { |
| @@ -66,8 +66,7 @@ static void BAD_SG_DMA(Scsi_Cmnd * SCpnt, | |||
| 66 | int badseg) | 66 | int badseg) |
| 67 | { | 67 | { |
| 68 | printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%llx length %u\n", | 68 | printk(KERN_CRIT "sgpnt[%d:%d] page %p/0x%llx length %u\n", |
| 69 | badseg, nseg, | 69 | badseg, nseg, sg_virt(sgp), |
| 70 | page_address(sgp->page) + sgp->offset, | ||
| 71 | (unsigned long long)SCSI_SG_PA(sgp), | 70 | (unsigned long long)SCSI_SG_PA(sgp), |
| 72 | sgp->length); | 71 | sgp->length); |
| 73 | 72 | ||
| @@ -712,8 +711,7 @@ static int aha1542_queuecommand(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
| 712 | printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i); | 711 | printk(KERN_CRIT "Bad segment list supplied to aha1542.c (%d, %d)\n", SCpnt->use_sg, i); |
| 713 | scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { | 712 | scsi_for_each_sg(SCpnt, sg, SCpnt->use_sg, i) { |
| 714 | printk(KERN_CRIT "%d: %p %d\n", i, | 713 | printk(KERN_CRIT "%d: %p %d\n", i, |
| 715 | (page_address(sg->page) + | 714 | sg_virt(sg), sg->length); |
| 716 | sg->offset), sg->length); | ||
| 717 | }; | 715 | }; |
| 718 | printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr); | 716 | printk(KERN_CRIT "cptr %x: ", (unsigned int) cptr); |
| 719 | ptr = (unsigned char *) &cptr[i]; | 717 | ptr = (unsigned char *) &cptr[i]; |
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index f81777586b8f..f7a252885a5c 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c | |||
| @@ -1343,7 +1343,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \ | |||
| 1343 | /* 4 bytes: Areca io control code */ | 1343 | /* 4 bytes: Areca io control code */ |
| 1344 | 1344 | ||
| 1345 | sg = scsi_sglist(cmd); | 1345 | sg = scsi_sglist(cmd); |
| 1346 | buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 1346 | buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; |
| 1347 | if (scsi_sg_count(cmd) > 1) { | 1347 | if (scsi_sg_count(cmd) > 1) { |
| 1348 | retvalue = ARCMSR_MESSAGE_FAIL; | 1348 | retvalue = ARCMSR_MESSAGE_FAIL; |
| 1349 | goto message_out; | 1349 | goto message_out; |
| @@ -1593,7 +1593,7 @@ static void arcmsr_handle_virtual_command(struct AdapterControlBlock *acb, | |||
| 1593 | strncpy(&inqdata[32], "R001", 4); /* Product Revision */ | 1593 | strncpy(&inqdata[32], "R001", 4); /* Product Revision */ |
| 1594 | 1594 | ||
| 1595 | sg = scsi_sglist(cmd); | 1595 | sg = scsi_sglist(cmd); |
| 1596 | buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 1596 | buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; |
| 1597 | 1597 | ||
| 1598 | memcpy(buffer, inqdata, sizeof(inqdata)); | 1598 | memcpy(buffer, inqdata, sizeof(inqdata)); |
| 1599 | sg = scsi_sglist(cmd); | 1599 | sg = scsi_sglist(cmd); |
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 52d0b87e9aa4..d1780980fb20 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c | |||
| @@ -515,8 +515,7 @@ static inline void initialize_SCp(Scsi_Cmnd *cmd) | |||
| 515 | if (cmd->use_sg) { | 515 | if (cmd->use_sg) { |
| 516 | cmd->SCp.buffer = (struct scatterlist *)cmd->request_buffer; | 516 | cmd->SCp.buffer = (struct scatterlist *)cmd->request_buffer; |
| 517 | cmd->SCp.buffers_residual = cmd->use_sg - 1; | 517 | cmd->SCp.buffers_residual = cmd->use_sg - 1; |
| 518 | cmd->SCp.ptr = (char *)page_address(cmd->SCp.buffer->page) + | 518 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 519 | cmd->SCp.buffer->offset; | ||
| 520 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 519 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 521 | /* ++roman: Try to merge some scatter-buffers if they are at | 520 | /* ++roman: Try to merge some scatter-buffers if they are at |
| 522 | * contiguous physical addresses. | 521 | * contiguous physical addresses. |
| @@ -2054,8 +2053,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) | |||
| 2054 | ++cmd->SCp.buffer; | 2053 | ++cmd->SCp.buffer; |
| 2055 | --cmd->SCp.buffers_residual; | 2054 | --cmd->SCp.buffers_residual; |
| 2056 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 2055 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 2057 | cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + | 2056 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 2058 | cmd->SCp.buffer->offset; | ||
| 2059 | /* ++roman: Try to merge some scatter-buffers if | 2057 | /* ++roman: Try to merge some scatter-buffers if |
| 2060 | * they are at contiguous physical addresses. | 2058 | * they are at contiguous physical addresses. |
| 2061 | */ | 2059 | */ |
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c index 96180bb47e41..982c5092be11 100644 --- a/drivers/scsi/eata_pio.c +++ b/drivers/scsi/eata_pio.c | |||
| @@ -172,7 +172,7 @@ static void IncStat(struct scsi_pointer *SCp, unsigned int Increment) | |||
| 172 | SCp->Status = 0; | 172 | SCp->Status = 0; |
| 173 | else { | 173 | else { |
| 174 | SCp->buffer++; | 174 | SCp->buffer++; |
| 175 | SCp->ptr = page_address(SCp->buffer->page) + SCp->buffer->offset; | 175 | SCp->ptr = sg_virt(SCp->buffer); |
| 176 | SCp->this_residual = SCp->buffer->length; | 176 | SCp->this_residual = SCp->buffer->length; |
| 177 | } | 177 | } |
| 178 | } | 178 | } |
| @@ -410,7 +410,7 @@ static int eata_pio_queue(struct scsi_cmnd *cmd, | |||
| 410 | } else { | 410 | } else { |
| 411 | cmd->SCp.buffer = cmd->request_buffer; | 411 | cmd->SCp.buffer = cmd->request_buffer; |
| 412 | cmd->SCp.buffers_residual = cmd->use_sg; | 412 | cmd->SCp.buffers_residual = cmd->use_sg; |
| 413 | cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset; | 413 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 414 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 414 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 415 | } | 415 | } |
| 416 | cmd->SCp.Status = (cmd->SCp.this_residual != 0); /* TRUE as long as bytes | 416 | cmd->SCp.Status = (cmd->SCp.this_residual != 0); /* TRUE as long as bytes |
diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c index 668569e8856b..8335b608e571 100644 --- a/drivers/scsi/fd_mcs.c +++ b/drivers/scsi/fd_mcs.c | |||
| @@ -973,7 +973,7 @@ static irqreturn_t fd_mcs_intr(int irq, void *dev_id) | |||
| 973 | if (current_SC->SCp.buffers_residual) { | 973 | if (current_SC->SCp.buffers_residual) { |
| 974 | --current_SC->SCp.buffers_residual; | 974 | --current_SC->SCp.buffers_residual; |
| 975 | ++current_SC->SCp.buffer; | 975 | ++current_SC->SCp.buffer; |
| 976 | current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; | 976 | current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer); |
| 977 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; | 977 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; |
| 978 | } else | 978 | } else |
| 979 | break; | 979 | break; |
| @@ -1006,7 +1006,7 @@ static irqreturn_t fd_mcs_intr(int irq, void *dev_id) | |||
| 1006 | if (!current_SC->SCp.this_residual && current_SC->SCp.buffers_residual) { | 1006 | if (!current_SC->SCp.this_residual && current_SC->SCp.buffers_residual) { |
| 1007 | --current_SC->SCp.buffers_residual; | 1007 | --current_SC->SCp.buffers_residual; |
| 1008 | ++current_SC->SCp.buffer; | 1008 | ++current_SC->SCp.buffer; |
| 1009 | current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; | 1009 | current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer); |
| 1010 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; | 1010 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; |
| 1011 | } | 1011 | } |
| 1012 | } | 1012 | } |
| @@ -1109,7 +1109,7 @@ static int fd_mcs_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) | |||
| 1109 | 1109 | ||
| 1110 | if (current_SC->use_sg) { | 1110 | if (current_SC->use_sg) { |
| 1111 | current_SC->SCp.buffer = (struct scatterlist *) current_SC->request_buffer; | 1111 | current_SC->SCp.buffer = (struct scatterlist *) current_SC->request_buffer; |
| 1112 | current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; | 1112 | current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer); |
| 1113 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; | 1113 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; |
| 1114 | current_SC->SCp.buffers_residual = current_SC->use_sg - 1; | 1114 | current_SC->SCp.buffers_residual = current_SC->use_sg - 1; |
| 1115 | } else { | 1115 | } else { |
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c index 5d282e6a6ae1..2cd6b4959eb2 100644 --- a/drivers/scsi/fdomain.c +++ b/drivers/scsi/fdomain.c | |||
| @@ -1321,7 +1321,7 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id) | |||
| 1321 | if (current_SC->SCp.buffers_residual) { | 1321 | if (current_SC->SCp.buffers_residual) { |
| 1322 | --current_SC->SCp.buffers_residual; | 1322 | --current_SC->SCp.buffers_residual; |
| 1323 | ++current_SC->SCp.buffer; | 1323 | ++current_SC->SCp.buffer; |
| 1324 | current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; | 1324 | current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer); |
| 1325 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; | 1325 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; |
| 1326 | } else | 1326 | } else |
| 1327 | break; | 1327 | break; |
| @@ -1354,7 +1354,7 @@ static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id) | |||
| 1354 | && current_SC->SCp.buffers_residual) { | 1354 | && current_SC->SCp.buffers_residual) { |
| 1355 | --current_SC->SCp.buffers_residual; | 1355 | --current_SC->SCp.buffers_residual; |
| 1356 | ++current_SC->SCp.buffer; | 1356 | ++current_SC->SCp.buffer; |
| 1357 | current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset; | 1357 | current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer); |
| 1358 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; | 1358 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; |
| 1359 | } | 1359 | } |
| 1360 | } | 1360 | } |
| @@ -1439,8 +1439,7 @@ static int fdomain_16x0_queue(struct scsi_cmnd *SCpnt, | |||
| 1439 | 1439 | ||
| 1440 | if (scsi_sg_count(current_SC)) { | 1440 | if (scsi_sg_count(current_SC)) { |
| 1441 | current_SC->SCp.buffer = scsi_sglist(current_SC); | 1441 | current_SC->SCp.buffer = scsi_sglist(current_SC); |
| 1442 | current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) | 1442 | current_SC->SCp.ptr = sg_virt(current_SC->SCp.buffer); |
| 1443 | + current_SC->SCp.buffer->offset; | ||
| 1444 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; | 1443 | current_SC->SCp.this_residual = current_SC->SCp.buffer->length; |
| 1445 | current_SC->SCp.buffers_residual = scsi_sg_count(current_SC) - 1; | 1444 | current_SC->SCp.buffers_residual = scsi_sg_count(current_SC) - 1; |
| 1446 | } else { | 1445 | } else { |
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 3ac080ee6e2f..5ab3ce762485 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
| @@ -2374,18 +2374,18 @@ static void gdth_copy_internal_data(gdth_ha_str *ha, Scsi_Cmnd *scp, | |||
| 2374 | if (cpsum+cpnow > cpcount) | 2374 | if (cpsum+cpnow > cpcount) |
| 2375 | cpnow = cpcount - cpsum; | 2375 | cpnow = cpcount - cpsum; |
| 2376 | cpsum += cpnow; | 2376 | cpsum += cpnow; |
| 2377 | if (!sl->page) { | 2377 | if (!sg_page(sl)) { |
| 2378 | printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n", | 2378 | printk("GDT-HA %d: invalid sc/gt element in gdth_copy_internal_data()\n", |
| 2379 | ha->hanum); | 2379 | ha->hanum); |
| 2380 | return; | 2380 | return; |
| 2381 | } | 2381 | } |
| 2382 | local_irq_save(flags); | 2382 | local_irq_save(flags); |
| 2383 | address = kmap_atomic(sl->page, KM_BIO_SRC_IRQ) + sl->offset; | 2383 | address = kmap_atomic(sg_page(sl), KM_BIO_SRC_IRQ) + sl->offset; |
| 2384 | if (to_buffer) | 2384 | if (to_buffer) |
| 2385 | memcpy(buffer, address, cpnow); | 2385 | memcpy(buffer, address, cpnow); |
| 2386 | else | 2386 | else |
| 2387 | memcpy(address, buffer, cpnow); | 2387 | memcpy(address, buffer, cpnow); |
| 2388 | flush_dcache_page(sl->page); | 2388 | flush_dcache_page(sg_page(sl)); |
| 2389 | kunmap_atomic(address, KM_BIO_SRC_IRQ); | 2389 | kunmap_atomic(address, KM_BIO_SRC_IRQ); |
| 2390 | local_irq_restore(flags); | 2390 | local_irq_restore(flags); |
| 2391 | if (cpsum == cpcount) | 2391 | if (cpsum == cpcount) |
diff --git a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c index 714e6273a70d..db004a450732 100644 --- a/drivers/scsi/ibmmca.c +++ b/drivers/scsi/ibmmca.c | |||
| @@ -1828,7 +1828,7 @@ static int ibmmca_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) | |||
| 1828 | BUG_ON(scsi_sg_count(cmd) > 16); | 1828 | BUG_ON(scsi_sg_count(cmd) > 16); |
| 1829 | 1829 | ||
| 1830 | scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) { | 1830 | scsi_for_each_sg(cmd, sg, scsi_sg_count(cmd), i) { |
| 1831 | ld(shpnt)[ldn].sge[i].address = (void *) (isa_page_to_bus(sg->page) + sg->offset); | 1831 | ld(shpnt)[ldn].sge[i].address = (void *) (isa_page_to_bus(sg_page(sg)) + sg->offset); |
| 1832 | ld(shpnt)[ldn].sge[i].byte_length = sg->length; | 1832 | ld(shpnt)[ldn].sge[i].byte_length = sg->length; |
| 1833 | } | 1833 | } |
| 1834 | scb->enable |= IM_POINTER_TO_LIST; | 1834 | scb->enable |= IM_POINTER_TO_LIST; |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 252d1806467f..8d0244c2e7d4 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
| @@ -175,18 +175,18 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne | |||
| 175 | 175 | ||
| 176 | while (bcount) { | 176 | while (bcount) { |
| 177 | count = min(pc->sg->length - pc->b_count, bcount); | 177 | count = min(pc->sg->length - pc->b_count, bcount); |
| 178 | if (PageHighMem(pc->sg->page)) { | 178 | if (PageHighMem(sg_page(pc->sg))) { |
| 179 | unsigned long flags; | 179 | unsigned long flags; |
| 180 | 180 | ||
| 181 | local_irq_save(flags); | 181 | local_irq_save(flags); |
| 182 | buf = kmap_atomic(pc->sg->page, KM_IRQ0) + | 182 | buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) + |
| 183 | pc->sg->offset; | 183 | pc->sg->offset; |
| 184 | drive->hwif->atapi_input_bytes(drive, | 184 | drive->hwif->atapi_input_bytes(drive, |
| 185 | buf + pc->b_count, count); | 185 | buf + pc->b_count, count); |
| 186 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); | 186 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); |
| 187 | local_irq_restore(flags); | 187 | local_irq_restore(flags); |
| 188 | } else { | 188 | } else { |
| 189 | buf = page_address(pc->sg->page) + pc->sg->offset; | 189 | buf = sg_virt(pc->sg); |
| 190 | drive->hwif->atapi_input_bytes(drive, | 190 | drive->hwif->atapi_input_bytes(drive, |
| 191 | buf + pc->b_count, count); | 191 | buf + pc->b_count, count); |
| 192 | } | 192 | } |
| @@ -212,18 +212,18 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign | |||
| 212 | 212 | ||
| 213 | while (bcount) { | 213 | while (bcount) { |
| 214 | count = min(pc->sg->length - pc->b_count, bcount); | 214 | count = min(pc->sg->length - pc->b_count, bcount); |
| 215 | if (PageHighMem(pc->sg->page)) { | 215 | if (PageHighMem(sg_page(pc->sg))) { |
| 216 | unsigned long flags; | 216 | unsigned long flags; |
| 217 | 217 | ||
| 218 | local_irq_save(flags); | 218 | local_irq_save(flags); |
| 219 | buf = kmap_atomic(pc->sg->page, KM_IRQ0) + | 219 | buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) + |
| 220 | pc->sg->offset; | 220 | pc->sg->offset; |
| 221 | drive->hwif->atapi_output_bytes(drive, | 221 | drive->hwif->atapi_output_bytes(drive, |
| 222 | buf + pc->b_count, count); | 222 | buf + pc->b_count, count); |
| 223 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); | 223 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); |
| 224 | local_irq_restore(flags); | 224 | local_irq_restore(flags); |
| 225 | } else { | 225 | } else { |
| 226 | buf = page_address(pc->sg->page) + pc->sg->offset; | 226 | buf = sg_virt(pc->sg); |
| 227 | drive->hwif->atapi_output_bytes(drive, | 227 | drive->hwif->atapi_output_bytes(drive, |
| 228 | buf + pc->b_count, count); | 228 | buf + pc->b_count, count); |
| 229 | } | 229 | } |
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c index 74cdc1f0a78f..a3d0c6b14958 100644 --- a/drivers/scsi/imm.c +++ b/drivers/scsi/imm.c | |||
| @@ -705,9 +705,7 @@ static int imm_completion(struct scsi_cmnd *cmd) | |||
| 705 | cmd->SCp.buffer++; | 705 | cmd->SCp.buffer++; |
| 706 | cmd->SCp.this_residual = | 706 | cmd->SCp.this_residual = |
| 707 | cmd->SCp.buffer->length; | 707 | cmd->SCp.buffer->length; |
| 708 | cmd->SCp.ptr = | 708 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 709 | page_address(cmd->SCp.buffer->page) + | ||
| 710 | cmd->SCp.buffer->offset; | ||
| 711 | 709 | ||
| 712 | /* | 710 | /* |
| 713 | * Make sure that we transfer even number of bytes | 711 | * Make sure that we transfer even number of bytes |
| @@ -844,9 +842,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd) | |||
| 844 | cmd->SCp.buffer = | 842 | cmd->SCp.buffer = |
| 845 | (struct scatterlist *) cmd->request_buffer; | 843 | (struct scatterlist *) cmd->request_buffer; |
| 846 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 844 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 847 | cmd->SCp.ptr = | 845 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 848 | page_address(cmd->SCp.buffer->page) + | ||
| 849 | cmd->SCp.buffer->offset; | ||
| 850 | } else { | 846 | } else { |
| 851 | /* else fill the only available buffer */ | 847 | /* else fill the only available buffer */ |
| 852 | cmd->SCp.buffer = NULL; | 848 | cmd->SCp.buffer = NULL; |
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c index ab7cbf3449ce..c8b452f2878c 100644 --- a/drivers/scsi/in2000.c +++ b/drivers/scsi/in2000.c | |||
| @@ -372,7 +372,7 @@ static int in2000_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) | |||
| 372 | if (cmd->use_sg) { | 372 | if (cmd->use_sg) { |
| 373 | cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; | 373 | cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; |
| 374 | cmd->SCp.buffers_residual = cmd->use_sg - 1; | 374 | cmd->SCp.buffers_residual = cmd->use_sg - 1; |
| 375 | cmd->SCp.ptr = (char *) page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset; | 375 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 376 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 376 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 377 | } else { | 377 | } else { |
| 378 | cmd->SCp.buffer = NULL; | 378 | cmd->SCp.buffer = NULL; |
| @@ -764,7 +764,7 @@ static void transfer_bytes(Scsi_Cmnd * cmd, int data_in_dir) | |||
| 764 | ++cmd->SCp.buffer; | 764 | ++cmd->SCp.buffer; |
| 765 | --cmd->SCp.buffers_residual; | 765 | --cmd->SCp.buffers_residual; |
| 766 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 766 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 767 | cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset; | 767 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 768 | } | 768 | } |
| 769 | 769 | ||
| 770 | /* Set up hardware registers */ | 770 | /* Set up hardware registers */ |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index c316a0bcae6c..439b97a6a269 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
| @@ -2872,6 +2872,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len) | |||
| 2872 | } | 2872 | } |
| 2873 | 2873 | ||
| 2874 | scatterlist = sglist->scatterlist; | 2874 | scatterlist = sglist->scatterlist; |
| 2875 | sg_init_table(scatterlist, num_elem); | ||
| 2875 | 2876 | ||
| 2876 | sglist->order = order; | 2877 | sglist->order = order; |
| 2877 | sglist->num_sg = num_elem; | 2878 | sglist->num_sg = num_elem; |
| @@ -2884,12 +2885,12 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len) | |||
| 2884 | 2885 | ||
| 2885 | /* Free up what we already allocated */ | 2886 | /* Free up what we already allocated */ |
| 2886 | for (j = i - 1; j >= 0; j--) | 2887 | for (j = i - 1; j >= 0; j--) |
| 2887 | __free_pages(scatterlist[j].page, order); | 2888 | __free_pages(sg_page(&scatterlist[j]), order); |
| 2888 | kfree(sglist); | 2889 | kfree(sglist); |
| 2889 | return NULL; | 2890 | return NULL; |
| 2890 | } | 2891 | } |
| 2891 | 2892 | ||
| 2892 | scatterlist[i].page = page; | 2893 | sg_set_page(&scatterlist[i], page); |
| 2893 | } | 2894 | } |
| 2894 | 2895 | ||
| 2895 | return sglist; | 2896 | return sglist; |
| @@ -2910,7 +2911,7 @@ static void ipr_free_ucode_buffer(struct ipr_sglist *sglist) | |||
| 2910 | int i; | 2911 | int i; |
| 2911 | 2912 | ||
| 2912 | for (i = 0; i < sglist->num_sg; i++) | 2913 | for (i = 0; i < sglist->num_sg; i++) |
| 2913 | __free_pages(sglist->scatterlist[i].page, sglist->order); | 2914 | __free_pages(sg_page(&sglist->scatterlist[i]), sglist->order); |
| 2914 | 2915 | ||
| 2915 | kfree(sglist); | 2916 | kfree(sglist); |
| 2916 | } | 2917 | } |
| @@ -2940,9 +2941,11 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist, | |||
| 2940 | scatterlist = sglist->scatterlist; | 2941 | scatterlist = sglist->scatterlist; |
| 2941 | 2942 | ||
| 2942 | for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) { | 2943 | for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) { |
| 2943 | kaddr = kmap(scatterlist[i].page); | 2944 | struct page *page = sg_page(&scatterlist[i]); |
| 2945 | |||
| 2946 | kaddr = kmap(page); | ||
| 2944 | memcpy(kaddr, buffer, bsize_elem); | 2947 | memcpy(kaddr, buffer, bsize_elem); |
| 2945 | kunmap(scatterlist[i].page); | 2948 | kunmap(page); |
| 2946 | 2949 | ||
| 2947 | scatterlist[i].length = bsize_elem; | 2950 | scatterlist[i].length = bsize_elem; |
| 2948 | 2951 | ||
| @@ -2953,9 +2956,11 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist, | |||
| 2953 | } | 2956 | } |
| 2954 | 2957 | ||
| 2955 | if (len % bsize_elem) { | 2958 | if (len % bsize_elem) { |
| 2956 | kaddr = kmap(scatterlist[i].page); | 2959 | struct page *page = sg_page(&scatterlist[i]); |
| 2960 | |||
| 2961 | kaddr = kmap(page); | ||
| 2957 | memcpy(kaddr, buffer, len % bsize_elem); | 2962 | memcpy(kaddr, buffer, len % bsize_elem); |
| 2958 | kunmap(scatterlist[i].page); | 2963 | kunmap(page); |
| 2959 | 2964 | ||
| 2960 | scatterlist[i].length = len % bsize_elem; | 2965 | scatterlist[i].length = len % bsize_elem; |
| 2961 | } | 2966 | } |
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index edaac2714c5a..5c5a9b2628fc 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c | |||
| @@ -1515,7 +1515,7 @@ static int ips_is_passthru(struct scsi_cmnd *SC) | |||
| 1515 | /* kmap_atomic() ensures addressability of the user buffer.*/ | 1515 | /* kmap_atomic() ensures addressability of the user buffer.*/ |
| 1516 | /* local_irq_save() protects the KM_IRQ0 address slot. */ | 1516 | /* local_irq_save() protects the KM_IRQ0 address slot. */ |
| 1517 | local_irq_save(flags); | 1517 | local_irq_save(flags); |
| 1518 | buffer = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 1518 | buffer = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; |
| 1519 | if (buffer && buffer[0] == 'C' && buffer[1] == 'O' && | 1519 | if (buffer && buffer[0] == 'C' && buffer[1] == 'O' && |
| 1520 | buffer[2] == 'P' && buffer[3] == 'P') { | 1520 | buffer[2] == 'P' && buffer[3] == 'P') { |
| 1521 | kunmap_atomic(buffer - sg->offset, KM_IRQ0); | 1521 | kunmap_atomic(buffer - sg->offset, KM_IRQ0); |
| @@ -3523,7 +3523,7 @@ ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count) | |||
| 3523 | /* kmap_atomic() ensures addressability of the data buffer.*/ | 3523 | /* kmap_atomic() ensures addressability of the data buffer.*/ |
| 3524 | /* local_irq_save() protects the KM_IRQ0 address slot. */ | 3524 | /* local_irq_save() protects the KM_IRQ0 address slot. */ |
| 3525 | local_irq_save(flags); | 3525 | local_irq_save(flags); |
| 3526 | buffer = kmap_atomic(sg[i].page, KM_IRQ0) + sg[i].offset; | 3526 | buffer = kmap_atomic(sg_page(&sg[i]), KM_IRQ0) + sg[i].offset; |
| 3527 | memcpy(buffer, &cdata[xfer_cnt], min_cnt); | 3527 | memcpy(buffer, &cdata[xfer_cnt], min_cnt); |
| 3528 | kunmap_atomic(buffer - sg[i].offset, KM_IRQ0); | 3528 | kunmap_atomic(buffer - sg[i].offset, KM_IRQ0); |
| 3529 | local_irq_restore(flags); | 3529 | local_irq_restore(flags); |
| @@ -3556,7 +3556,7 @@ ips_scmd_buf_read(struct scsi_cmnd *scmd, void *data, unsigned int count) | |||
| 3556 | /* kmap_atomic() ensures addressability of the data buffer.*/ | 3556 | /* kmap_atomic() ensures addressability of the data buffer.*/ |
| 3557 | /* local_irq_save() protects the KM_IRQ0 address slot. */ | 3557 | /* local_irq_save() protects the KM_IRQ0 address slot. */ |
| 3558 | local_irq_save(flags); | 3558 | local_irq_save(flags); |
| 3559 | buffer = kmap_atomic(sg[i].page, KM_IRQ0) + sg[i].offset; | 3559 | buffer = kmap_atomic(sg_page(&sg[i]), KM_IRQ0) + sg[i].offset; |
| 3560 | memcpy(&cdata[xfer_cnt], buffer, min_cnt); | 3560 | memcpy(&cdata[xfer_cnt], buffer, min_cnt); |
| 3561 | kunmap_atomic(buffer - sg[i].offset, KM_IRQ0); | 3561 | kunmap_atomic(buffer - sg[i].offset, KM_IRQ0); |
| 3562 | local_irq_restore(flags); | 3562 | local_irq_restore(flags); |
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index a21455d0274c..6ce4109efdf3 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c | |||
| @@ -70,9 +70,7 @@ module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO); | |||
| 70 | static inline void | 70 | static inline void |
| 71 | iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size) | 71 | iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size) |
| 72 | { | 72 | { |
| 73 | ibuf->sg.page = virt_to_page(vbuf); | 73 | sg_init_one(&ibuf->sg, vbuf, size); |
| 74 | ibuf->sg.offset = offset_in_page(vbuf); | ||
| 75 | ibuf->sg.length = size; | ||
| 76 | ibuf->sent = 0; | 74 | ibuf->sent = 0; |
| 77 | ibuf->use_sendmsg = 1; | 75 | ibuf->use_sendmsg = 1; |
| 78 | } | 76 | } |
| @@ -80,13 +78,14 @@ iscsi_buf_init_iov(struct iscsi_buf *ibuf, char *vbuf, int size) | |||
| 80 | static inline void | 78 | static inline void |
| 81 | iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) | 79 | iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) |
| 82 | { | 80 | { |
| 83 | ibuf->sg.page = sg->page; | 81 | sg_init_table(&ibuf->sg, 1); |
| 82 | sg_set_page(&ibuf->sg, sg_page(sg)); | ||
| 84 | ibuf->sg.offset = sg->offset; | 83 | ibuf->sg.offset = sg->offset; |
| 85 | ibuf->sg.length = sg->length; | 84 | ibuf->sg.length = sg->length; |
| 86 | /* | 85 | /* |
| 87 | * Fastpath: sg element fits into single page | 86 | * Fastpath: sg element fits into single page |
| 88 | */ | 87 | */ |
| 89 | if (sg->length + sg->offset <= PAGE_SIZE && !PageSlab(sg->page)) | 88 | if (sg->length + sg->offset <= PAGE_SIZE && !PageSlab(sg_page(sg))) |
| 90 | ibuf->use_sendmsg = 0; | 89 | ibuf->use_sendmsg = 0; |
| 91 | else | 90 | else |
| 92 | ibuf->use_sendmsg = 1; | 91 | ibuf->use_sendmsg = 1; |
| @@ -716,7 +715,7 @@ static int iscsi_scsi_data_in(struct iscsi_conn *conn) | |||
| 716 | for (i = tcp_ctask->sg_count; i < scsi_sg_count(sc); i++) { | 715 | for (i = tcp_ctask->sg_count; i < scsi_sg_count(sc); i++) { |
| 717 | char *dest; | 716 | char *dest; |
| 718 | 717 | ||
| 719 | dest = kmap_atomic(sg[i].page, KM_SOFTIRQ0); | 718 | dest = kmap_atomic(sg_page(&sg[i]), KM_SOFTIRQ0); |
| 720 | rc = iscsi_ctask_copy(tcp_conn, ctask, dest + sg[i].offset, | 719 | rc = iscsi_ctask_copy(tcp_conn, ctask, dest + sg[i].offset, |
| 721 | sg[i].length, offset); | 720 | sg[i].length, offset); |
| 722 | kunmap_atomic(dest, KM_SOFTIRQ0); | 721 | kunmap_atomic(dest, KM_SOFTIRQ0); |
| @@ -1103,9 +1102,9 @@ iscsi_send(struct iscsi_conn *conn, struct iscsi_buf *buf, int size, int flags) | |||
| 1103 | * slab case. | 1102 | * slab case. |
| 1104 | */ | 1103 | */ |
| 1105 | if (buf->use_sendmsg) | 1104 | if (buf->use_sendmsg) |
| 1106 | res = sock_no_sendpage(sk, buf->sg.page, offset, size, flags); | 1105 | res = sock_no_sendpage(sk, sg_page(&buf->sg), offset, size, flags); |
| 1107 | else | 1106 | else |
| 1108 | res = tcp_conn->sendpage(sk, buf->sg.page, offset, size, flags); | 1107 | res = tcp_conn->sendpage(sk, sg_page(&buf->sg), offset, size, flags); |
| 1109 | 1108 | ||
| 1110 | if (res >= 0) { | 1109 | if (res >= 0) { |
| 1111 | conn->txdata_octets += res; | 1110 | conn->txdata_octets += res; |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 10d1aff9938a..66c652035730 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
| @@ -658,7 +658,7 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy) | |||
| 658 | struct scatterlist *sg; | 658 | struct scatterlist *sg; |
| 659 | 659 | ||
| 660 | sg = scsi_sglist(cmd); | 660 | sg = scsi_sglist(cmd); |
| 661 | buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset; | 661 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; |
| 662 | 662 | ||
| 663 | memset(buf, 0, cmd->cmnd[4]); | 663 | memset(buf, 0, cmd->cmnd[4]); |
| 664 | kunmap_atomic(buf - sg->offset, KM_IRQ0); | 664 | kunmap_atomic(buf - sg->offset, KM_IRQ0); |
| @@ -1542,10 +1542,8 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) | |||
| 1542 | if( cmd->cmnd[0] == INQUIRY && !islogical ) { | 1542 | if( cmd->cmnd[0] == INQUIRY && !islogical ) { |
| 1543 | 1543 | ||
| 1544 | sgl = scsi_sglist(cmd); | 1544 | sgl = scsi_sglist(cmd); |
| 1545 | if( sgl->page ) { | 1545 | if( sg_page(sgl) ) { |
| 1546 | c = *(unsigned char *) | 1546 | c = *(unsigned char *) sg_virt(&sgl[0]); |
| 1547 | page_address((&sgl[0])->page) + | ||
| 1548 | (&sgl[0])->offset; | ||
| 1549 | } else { | 1547 | } else { |
| 1550 | printk(KERN_WARNING | 1548 | printk(KERN_WARNING |
| 1551 | "megaraid: invalid sg.\n"); | 1549 | "megaraid: invalid sg.\n"); |
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 78779209ac89..c8923108183a 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c | |||
| @@ -1584,10 +1584,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) | |||
| 1584 | caddr_t vaddr; | 1584 | caddr_t vaddr; |
| 1585 | 1585 | ||
| 1586 | sgl = scsi_sglist(scp); | 1586 | sgl = scsi_sglist(scp); |
| 1587 | if (sgl->page) { | 1587 | if (sg_page(sgl)) { |
| 1588 | vaddr = (caddr_t) | 1588 | vaddr = (caddr_t) sg_virt(&sgl[0]); |
| 1589 | (page_address((&sgl[0])->page) | ||
| 1590 | + (&sgl[0])->offset); | ||
| 1591 | 1589 | ||
| 1592 | memset(vaddr, 0, scp->cmnd[4]); | 1590 | memset(vaddr, 0, scp->cmnd[4]); |
| 1593 | } | 1591 | } |
| @@ -2328,10 +2326,8 @@ megaraid_mbox_dpc(unsigned long devp) | |||
| 2328 | && IS_RAID_CH(raid_dev, scb->dev_channel)) { | 2326 | && IS_RAID_CH(raid_dev, scb->dev_channel)) { |
| 2329 | 2327 | ||
| 2330 | sgl = scsi_sglist(scp); | 2328 | sgl = scsi_sglist(scp); |
| 2331 | if (sgl->page) { | 2329 | if (sg_page(sgl)) { |
| 2332 | c = *(unsigned char *) | 2330 | c = *(unsigned char *) sg_virt(&sgl[0]); |
| 2333 | (page_address((&sgl[0])->page) + | ||
| 2334 | (&sgl[0])->offset); | ||
| 2335 | } else { | 2331 | } else { |
| 2336 | con_log(CL_ANN, (KERN_WARNING | 2332 | con_log(CL_ANN, (KERN_WARNING |
| 2337 | "megaraid mailbox: invalid sg:%d\n", | 2333 | "megaraid mailbox: invalid sg:%d\n", |
diff --git a/drivers/scsi/oktagon_esp.c b/drivers/scsi/oktagon_esp.c index 26a6d55faf3e..8e5eadbd5c51 100644 --- a/drivers/scsi/oktagon_esp.c +++ b/drivers/scsi/oktagon_esp.c | |||
| @@ -550,8 +550,7 @@ void dma_mmu_get_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd *sp) | |||
| 550 | 550 | ||
| 551 | void dma_mmu_get_scsi_sgl(struct NCR_ESP *esp, Scsi_Cmnd *sp) | 551 | void dma_mmu_get_scsi_sgl(struct NCR_ESP *esp, Scsi_Cmnd *sp) |
| 552 | { | 552 | { |
| 553 | sp->SCp.ptr = page_address(sp->SCp.buffer->page)+ | 553 | sp->SCp.ptr = sg_virt(sp->SCp.buffer); |
| 554 | sp->SCp.buffer->offset; | ||
| 555 | } | 554 | } |
| 556 | 555 | ||
| 557 | void dma_mmu_release_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd *sp) | 556 | void dma_mmu_release_scsi_one(struct NCR_ESP *esp, Scsi_Cmnd *sp) |
| @@ -564,8 +563,7 @@ void dma_mmu_release_scsi_sgl(struct NCR_ESP *esp, Scsi_Cmnd *sp) | |||
| 564 | 563 | ||
| 565 | void dma_advance_sg(Scsi_Cmnd *sp) | 564 | void dma_advance_sg(Scsi_Cmnd *sp) |
| 566 | { | 565 | { |
| 567 | sp->SCp.ptr = page_address(sp->SCp.buffer->page)+ | 566 | sp->SCp.ptr = sg_virt(sp->SCp.buffer); |
| 568 | sp->SCp.buffer->offset; | ||
| 569 | } | 567 | } |
| 570 | 568 | ||
| 571 | 569 | ||
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 331b789937c4..1c5c4b68f20f 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
| @@ -542,7 +542,7 @@ static int osst_verify_frame(struct osst_tape * STp, int frame_seq_number, int q | |||
| 542 | if (STp->raw) { | 542 | if (STp->raw) { |
| 543 | if (STp->buffer->syscall_result) { | 543 | if (STp->buffer->syscall_result) { |
| 544 | for (i=0; i < STp->buffer->sg_segs; i++) | 544 | for (i=0; i < STp->buffer->sg_segs; i++) |
| 545 | memset(page_address(STp->buffer->sg[i].page), | 545 | memset(page_address(sg_page(&STp->buffer->sg[i])), |
| 546 | 0, STp->buffer->sg[i].length); | 546 | 0, STp->buffer->sg[i].length); |
| 547 | strcpy(STp->buffer->b_data, "READ ERROR ON FRAME"); | 547 | strcpy(STp->buffer->b_data, "READ ERROR ON FRAME"); |
| 548 | } else | 548 | } else |
| @@ -4437,7 +4437,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp) | |||
| 4437 | for (i = 0, b_size = 0; | 4437 | for (i = 0, b_size = 0; |
| 4438 | (i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE); | 4438 | (i < STp->buffer->sg_segs) && ((b_size + STp->buffer->sg[i].length) <= OS_DATA_SIZE); |
| 4439 | b_size += STp->buffer->sg[i++].length); | 4439 | b_size += STp->buffer->sg[i++].length); |
| 4440 | STp->buffer->aux = (os_aux_t *) (page_address(STp->buffer->sg[i].page) + OS_DATA_SIZE - b_size); | 4440 | STp->buffer->aux = (os_aux_t *) (page_address(sg_page(&STp->buffer->sg[i])) + OS_DATA_SIZE - b_size); |
| 4441 | #if DEBUG | 4441 | #if DEBUG |
| 4442 | printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name, | 4442 | printk(OSST_DEB_MSG "%s:D: b_data points to %p in segment 0 at %p\n", name, |
| 4443 | STp->buffer->b_data, page_address(STp->buffer->sg[0].page)); | 4443 | STp->buffer->b_data, page_address(STp->buffer->sg[0].page)); |
| @@ -5252,25 +5252,26 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
| 5252 | /* Try to allocate the first segment up to OS_DATA_SIZE and the others | 5252 | /* Try to allocate the first segment up to OS_DATA_SIZE and the others |
| 5253 | big enough to reach the goal (code assumes no segments in place) */ | 5253 | big enough to reach the goal (code assumes no segments in place) */ |
| 5254 | for (b_size = OS_DATA_SIZE, order = OSST_FIRST_ORDER; b_size >= PAGE_SIZE; order--, b_size /= 2) { | 5254 | for (b_size = OS_DATA_SIZE, order = OSST_FIRST_ORDER; b_size >= PAGE_SIZE; order--, b_size /= 2) { |
| 5255 | STbuffer->sg[0].page = alloc_pages(priority, order); | 5255 | struct page *page = alloc_pages(priority, order); |
| 5256 | |||
| 5256 | STbuffer->sg[0].offset = 0; | 5257 | STbuffer->sg[0].offset = 0; |
| 5257 | if (STbuffer->sg[0].page != NULL) { | 5258 | if (page != NULL) { |
| 5259 | sg_set_page(&STbuffer->sg[0], page); | ||
| 5258 | STbuffer->sg[0].length = b_size; | 5260 | STbuffer->sg[0].length = b_size; |
| 5259 | STbuffer->b_data = page_address(STbuffer->sg[0].page); | 5261 | STbuffer->b_data = page_address(page); |
| 5260 | break; | 5262 | break; |
| 5261 | } | 5263 | } |
| 5262 | } | 5264 | } |
| 5263 | if (STbuffer->sg[0].page == NULL) { | 5265 | if (sg_page(&STbuffer->sg[0]) == NULL) { |
| 5264 | printk(KERN_NOTICE "osst :I: Can't allocate tape buffer main segment.\n"); | 5266 | printk(KERN_NOTICE "osst :I: Can't allocate tape buffer main segment.\n"); |
| 5265 | return 0; | 5267 | return 0; |
| 5266 | } | 5268 | } |
| 5267 | /* Got initial segment of 'bsize,order', continue with same size if possible, except for AUX */ | 5269 | /* Got initial segment of 'bsize,order', continue with same size if possible, except for AUX */ |
| 5268 | for (segs=STbuffer->sg_segs=1, got=b_size; | 5270 | for (segs=STbuffer->sg_segs=1, got=b_size; |
| 5269 | segs < max_segs && got < OS_FRAME_SIZE; ) { | 5271 | segs < max_segs && got < OS_FRAME_SIZE; ) { |
| 5270 | STbuffer->sg[segs].page = | 5272 | struct page *page = alloc_pages(priority, (OS_FRAME_SIZE - got <= PAGE_SIZE) ? 0 : order); |
| 5271 | alloc_pages(priority, (OS_FRAME_SIZE - got <= PAGE_SIZE) ? 0 : order); | ||
| 5272 | STbuffer->sg[segs].offset = 0; | 5273 | STbuffer->sg[segs].offset = 0; |
| 5273 | if (STbuffer->sg[segs].page == NULL) { | 5274 | if (page == NULL) { |
| 5274 | if (OS_FRAME_SIZE - got <= (max_segs - segs) * b_size / 2 && order) { | 5275 | if (OS_FRAME_SIZE - got <= (max_segs - segs) * b_size / 2 && order) { |
| 5275 | b_size /= 2; /* Large enough for the rest of the buffers */ | 5276 | b_size /= 2; /* Large enough for the rest of the buffers */ |
| 5276 | order--; | 5277 | order--; |
| @@ -5284,6 +5285,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma) | |||
| 5284 | normalize_buffer(STbuffer); | 5285 | normalize_buffer(STbuffer); |
| 5285 | return 0; | 5286 | return 0; |
| 5286 | } | 5287 | } |
| 5288 | sg_set_page(&STbuffer->sg[segs], page); | ||
| 5287 | STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size; | 5289 | STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size; |
| 5288 | got += STbuffer->sg[segs].length; | 5290 | got += STbuffer->sg[segs].length; |
| 5289 | STbuffer->buffer_size = got; | 5291 | STbuffer->buffer_size = got; |
| @@ -5316,7 +5318,7 @@ static void normalize_buffer(struct osst_buffer *STbuffer) | |||
| 5316 | b_size < STbuffer->sg[i].length; | 5318 | b_size < STbuffer->sg[i].length; |
| 5317 | b_size *= 2, order++); | 5319 | b_size *= 2, order++); |
| 5318 | 5320 | ||
| 5319 | __free_pages(STbuffer->sg[i].page, order); | 5321 | __free_pages(sg_page(&STbuffer->sg[i]), order); |
| 5320 | STbuffer->buffer_size -= STbuffer->sg[i].length; | 5322 | STbuffer->buffer_size -= STbuffer->sg[i].length; |
| 5321 | } | 5323 | } |
| 5322 | #if DEBUG | 5324 | #if DEBUG |
| @@ -5344,7 +5346,7 @@ static int append_to_buffer(const char __user *ubp, struct osst_buffer *st_bp, i | |||
| 5344 | for ( ; i < st_bp->sg_segs && do_count > 0; i++) { | 5346 | for ( ; i < st_bp->sg_segs && do_count > 0; i++) { |
| 5345 | cnt = st_bp->sg[i].length - offset < do_count ? | 5347 | cnt = st_bp->sg[i].length - offset < do_count ? |
| 5346 | st_bp->sg[i].length - offset : do_count; | 5348 | st_bp->sg[i].length - offset : do_count; |
| 5347 | res = copy_from_user(page_address(st_bp->sg[i].page) + offset, ubp, cnt); | 5349 | res = copy_from_user(page_address(sg_page(&st_bp->sg[i])) + offset, ubp, cnt); |
| 5348 | if (res) | 5350 | if (res) |
| 5349 | return (-EFAULT); | 5351 | return (-EFAULT); |
| 5350 | do_count -= cnt; | 5352 | do_count -= cnt; |
| @@ -5377,7 +5379,7 @@ static int from_buffer(struct osst_buffer *st_bp, char __user *ubp, int do_count | |||
| 5377 | for ( ; i < st_bp->sg_segs && do_count > 0; i++) { | 5379 | for ( ; i < st_bp->sg_segs && do_count > 0; i++) { |
| 5378 | cnt = st_bp->sg[i].length - offset < do_count ? | 5380 | cnt = st_bp->sg[i].length - offset < do_count ? |
| 5379 | st_bp->sg[i].length - offset : do_count; | 5381 | st_bp->sg[i].length - offset : do_count; |
| 5380 | res = copy_to_user(ubp, page_address(st_bp->sg[i].page) + offset, cnt); | 5382 | res = copy_to_user(ubp, page_address(sg_page(&st_bp->sg[i])) + offset, cnt); |
| 5381 | if (res) | 5383 | if (res) |
| 5382 | return (-EFAULT); | 5384 | return (-EFAULT); |
| 5383 | do_count -= cnt; | 5385 | do_count -= cnt; |
| @@ -5410,7 +5412,7 @@ static int osst_zero_buffer_tail(struct osst_buffer *st_bp) | |||
| 5410 | i < st_bp->sg_segs && do_count > 0; i++) { | 5412 | i < st_bp->sg_segs && do_count > 0; i++) { |
| 5411 | cnt = st_bp->sg[i].length - offset < do_count ? | 5413 | cnt = st_bp->sg[i].length - offset < do_count ? |
| 5412 | st_bp->sg[i].length - offset : do_count ; | 5414 | st_bp->sg[i].length - offset : do_count ; |
| 5413 | memset(page_address(st_bp->sg[i].page) + offset, 0, cnt); | 5415 | memset(page_address(sg_page(&st_bp->sg[i])) + offset, 0, cnt); |
| 5414 | do_count -= cnt; | 5416 | do_count -= cnt; |
| 5415 | offset = 0; | 5417 | offset = 0; |
| 5416 | } | 5418 | } |
| @@ -5430,7 +5432,7 @@ static int osst_copy_to_buffer(struct osst_buffer *st_bp, unsigned char *ptr) | |||
| 5430 | for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { | 5432 | for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { |
| 5431 | cnt = st_bp->sg[i].length < do_count ? | 5433 | cnt = st_bp->sg[i].length < do_count ? |
| 5432 | st_bp->sg[i].length : do_count ; | 5434 | st_bp->sg[i].length : do_count ; |
| 5433 | memcpy(page_address(st_bp->sg[i].page), ptr, cnt); | 5435 | memcpy(page_address(sg_page(&st_bp->sg[i])), ptr, cnt); |
| 5434 | do_count -= cnt; | 5436 | do_count -= cnt; |
| 5435 | ptr += cnt; | 5437 | ptr += cnt; |
| 5436 | } | 5438 | } |
| @@ -5451,7 +5453,7 @@ static int osst_copy_from_buffer(struct osst_buffer *st_bp, unsigned char *ptr) | |||
| 5451 | for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { | 5453 | for (i = 0; i < st_bp->sg_segs && do_count > 0; i++) { |
| 5452 | cnt = st_bp->sg[i].length < do_count ? | 5454 | cnt = st_bp->sg[i].length < do_count ? |
| 5453 | st_bp->sg[i].length : do_count ; | 5455 | st_bp->sg[i].length : do_count ; |
| 5454 | memcpy(ptr, page_address(st_bp->sg[i].page), cnt); | 5456 | memcpy(ptr, page_address(sg_page(&st_bp->sg[i])), cnt); |
| 5455 | do_count -= cnt; | 5457 | do_count -= cnt; |
| 5456 | ptr += cnt; | 5458 | ptr += cnt; |
| 5457 | } | 5459 | } |
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index 98397559c53b..7db28cd49446 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h | |||
| @@ -393,7 +393,7 @@ enum _burst_mode { | |||
| 393 | #define MSG_EXT_SDTR 0x01 | 393 | #define MSG_EXT_SDTR 0x01 |
| 394 | 394 | ||
| 395 | /* scatter-gather table */ | 395 | /* scatter-gather table */ |
| 396 | # define BUFFER_ADDR ((char *)((unsigned int)(SCpnt->SCp.buffer->page) + SCpnt->SCp.buffer->offset)) | 396 | # define BUFFER_ADDR ((char *)((sg_virt(SCpnt->SCp.buffer)))) |
| 397 | 397 | ||
| 398 | #endif /*__nsp_cs__*/ | 398 | #endif /*__nsp_cs__*/ |
| 399 | /* end */ | 399 | /* end */ |
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 190e2a7d7067..969b9387a0c3 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c | |||
| @@ -443,8 +443,7 @@ SYM53C500_intr(int irq, void *dev_id) | |||
| 443 | 443 | ||
| 444 | scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) { | 444 | scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) { |
| 445 | SYM53C500_pio_write(fast_pio, port_base, | 445 | SYM53C500_pio_write(fast_pio, port_base, |
| 446 | page_address(sg->page) + sg->offset, | 446 | sg_virt(sg), sg->length); |
| 447 | sg->length); | ||
| 448 | } | 447 | } |
| 449 | REG0(port_base); | 448 | REG0(port_base); |
| 450 | } | 449 | } |
| @@ -463,8 +462,7 @@ SYM53C500_intr(int irq, void *dev_id) | |||
| 463 | 462 | ||
| 464 | scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) { | 463 | scsi_for_each_sg(curSC, sg, scsi_sg_count(curSC), i) { |
| 465 | SYM53C500_pio_read(fast_pio, port_base, | 464 | SYM53C500_pio_read(fast_pio, port_base, |
| 466 | page_address(sg->page) + sg->offset, | 465 | sg_virt(sg), sg->length); |
| 467 | sg->length); | ||
| 468 | } | 466 | } |
| 469 | REG0(port_base); | 467 | REG0(port_base); |
| 470 | } | 468 | } |
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c index 67b6d76a6c8d..67ee51a3d7e1 100644 --- a/drivers/scsi/ppa.c +++ b/drivers/scsi/ppa.c | |||
| @@ -608,9 +608,7 @@ static int ppa_completion(struct scsi_cmnd *cmd) | |||
| 608 | cmd->SCp.buffer++; | 608 | cmd->SCp.buffer++; |
| 609 | cmd->SCp.this_residual = | 609 | cmd->SCp.this_residual = |
| 610 | cmd->SCp.buffer->length; | 610 | cmd->SCp.buffer->length; |
| 611 | cmd->SCp.ptr = | 611 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 612 | page_address(cmd->SCp.buffer->page) + | ||
| 613 | cmd->SCp.buffer->offset; | ||
| 614 | } | 612 | } |
| 615 | } | 613 | } |
| 616 | /* Now check to see if the drive is ready to comunicate */ | 614 | /* Now check to see if the drive is ready to comunicate */ |
| @@ -756,8 +754,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd) | |||
| 756 | /* if many buffers are available, start filling the first */ | 754 | /* if many buffers are available, start filling the first */ |
| 757 | cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; | 755 | cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; |
| 758 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 756 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 759 | cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + | 757 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 760 | cmd->SCp.buffer->offset; | ||
| 761 | } else { | 758 | } else { |
| 762 | /* else fill the only available buffer */ | 759 | /* else fill the only available buffer */ |
| 763 | cmd->SCp.buffer = NULL; | 760 | cmd->SCp.buffer = NULL; |
diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c index 0f43d1d046d9..03f19b8d19c9 100644 --- a/drivers/scsi/ps3rom.c +++ b/drivers/scsi/ps3rom.c | |||
| @@ -111,14 +111,14 @@ static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf) | |||
| 111 | req_len = act_len = 0; | 111 | req_len = act_len = 0; |
| 112 | scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) { | 112 | scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) { |
| 113 | if (active) { | 113 | if (active) { |
| 114 | kaddr = kmap_atomic(sgpnt->page, KM_IRQ0); | 114 | kaddr = kmap_atomic(sg_page(sgpnt), KM_IRQ0); |
| 115 | len = sgpnt->length; | 115 | len = sgpnt->length; |
| 116 | if ((req_len + len) > buflen) { | 116 | if ((req_len + len) > buflen) { |
| 117 | active = 0; | 117 | active = 0; |
| 118 | len = buflen - req_len; | 118 | len = buflen - req_len; |
| 119 | } | 119 | } |
| 120 | memcpy(kaddr + sgpnt->offset, buf + req_len, len); | 120 | memcpy(kaddr + sgpnt->offset, buf + req_len, len); |
| 121 | flush_kernel_dcache_page(sgpnt->page); | 121 | flush_kernel_dcache_page(sg_page(sgpnt)); |
| 122 | kunmap_atomic(kaddr, KM_IRQ0); | 122 | kunmap_atomic(kaddr, KM_IRQ0); |
| 123 | act_len += len; | 123 | act_len += len; |
| 124 | } | 124 | } |
| @@ -147,7 +147,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd *cmd, void *buf) | |||
| 147 | 147 | ||
| 148 | req_len = fin = 0; | 148 | req_len = fin = 0; |
| 149 | scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) { | 149 | scsi_for_each_sg(cmd, sgpnt, scsi_sg_count(cmd), k) { |
| 150 | kaddr = kmap_atomic(sgpnt->page, KM_IRQ0); | 150 | kaddr = kmap_atomic(sg_page(sgpnt->page), KM_IRQ0); |
| 151 | len = sgpnt->length; | 151 | len = sgpnt->length; |
| 152 | if ((req_len + len) > buflen) { | 152 | if ((req_len + len) > buflen) { |
| 153 | len = buflen - req_len; | 153 | len = buflen - req_len; |
diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c index 2bfbf26c00ed..de7b3bc2cbc9 100644 --- a/drivers/scsi/qlogicfas408.c +++ b/drivers/scsi/qlogicfas408.c | |||
| @@ -317,7 +317,7 @@ static unsigned int ql_pcmd(struct scsi_cmnd *cmd) | |||
| 317 | return ((priv->qabort == 1 ? | 317 | return ((priv->qabort == 1 ? |
| 318 | DID_ABORT : DID_RESET) << 16); | 318 | DID_ABORT : DID_RESET) << 16); |
| 319 | } | 319 | } |
| 320 | buf = page_address(sg->page) + sg->offset; | 320 | buf = sg_virt(sg); |
| 321 | if (ql_pdma(priv, phase, buf, sg->length)) | 321 | if (ql_pdma(priv, phase, buf, sg->length)) |
| 322 | break; | 322 | break; |
| 323 | } | 323 | } |
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 72ee4c9cfb1a..46cae5a212de 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
| @@ -625,7 +625,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, | |||
| 625 | scsi_for_each_sg(scp, sg, scp->use_sg, k) { | 625 | scsi_for_each_sg(scp, sg, scp->use_sg, k) { |
| 626 | if (active) { | 626 | if (active) { |
| 627 | kaddr = (unsigned char *) | 627 | kaddr = (unsigned char *) |
| 628 | kmap_atomic(sg->page, KM_USER0); | 628 | kmap_atomic(sg_page(sg), KM_USER0); |
| 629 | if (NULL == kaddr) | 629 | if (NULL == kaddr) |
| 630 | return (DID_ERROR << 16); | 630 | return (DID_ERROR << 16); |
| 631 | kaddr_off = (unsigned char *)kaddr + sg->offset; | 631 | kaddr_off = (unsigned char *)kaddr + sg->offset; |
| @@ -672,7 +672,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr, | |||
| 672 | sg = scsi_sglist(scp); | 672 | sg = scsi_sglist(scp); |
| 673 | req_len = fin = 0; | 673 | req_len = fin = 0; |
| 674 | for (k = 0; k < scp->use_sg; ++k, sg = sg_next(sg)) { | 674 | for (k = 0; k < scp->use_sg; ++k, sg = sg_next(sg)) { |
| 675 | kaddr = (unsigned char *)kmap_atomic(sg->page, KM_USER0); | 675 | kaddr = (unsigned char *)kmap_atomic(sg_page(sg), KM_USER0); |
| 676 | if (NULL == kaddr) | 676 | if (NULL == kaddr) |
| 677 | return -1; | 677 | return -1; |
| 678 | kaddr_off = (unsigned char *)kaddr + sg->offset; | 678 | kaddr_off = (unsigned char *)kaddr + sg->offset; |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index aac8a02cbe80..61fdaf02f251 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
| @@ -295,7 +295,7 @@ static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl, | |||
| 295 | int i, err, nr_vecs = 0; | 295 | int i, err, nr_vecs = 0; |
| 296 | 296 | ||
| 297 | for_each_sg(sgl, sg, nsegs, i) { | 297 | for_each_sg(sgl, sg, nsegs, i) { |
| 298 | page = sg->page; | 298 | page = sg_page(sg); |
| 299 | off = sg->offset; | 299 | off = sg->offset; |
| 300 | len = sg->length; | 300 | len = sg->length; |
| 301 | data_len += len; | 301 | data_len += len; |
| @@ -764,7 +764,7 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
| 764 | if (unlikely(!sgl)) | 764 | if (unlikely(!sgl)) |
| 765 | goto enomem; | 765 | goto enomem; |
| 766 | 766 | ||
| 767 | memset(sgl, 0, sizeof(*sgl) * sgp->size); | 767 | sg_init_table(sgl, sgp->size); |
| 768 | 768 | ||
| 769 | /* | 769 | /* |
| 770 | * first loop through, set initial index and return value | 770 | * first loop through, set initial index and return value |
| @@ -781,6 +781,13 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) | |||
| 781 | sg_chain(prev, SCSI_MAX_SG_SEGMENTS, sgl); | 781 | sg_chain(prev, SCSI_MAX_SG_SEGMENTS, sgl); |
| 782 | 782 | ||
| 783 | /* | 783 | /* |
| 784 | * if we have nothing left, mark the last segment as | ||
| 785 | * end-of-list | ||
| 786 | */ | ||
| 787 | if (!left) | ||
| 788 | sg_mark_end(sgl, this); | ||
| 789 | |||
| 790 | /* | ||
| 784 | * don't allow subsequent mempool allocs to sleep, it would | 791 | * don't allow subsequent mempool allocs to sleep, it would |
| 785 | * violate the mempool principle. | 792 | * violate the mempool principle. |
| 786 | */ | 793 | */ |
| @@ -2353,7 +2360,7 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int sg_count, | |||
| 2353 | *offset = *offset - len_complete + sg->offset; | 2360 | *offset = *offset - len_complete + sg->offset; |
| 2354 | 2361 | ||
| 2355 | /* Assumption: contiguous pages can be accessed as "page + i" */ | 2362 | /* Assumption: contiguous pages can be accessed as "page + i" */ |
| 2356 | page = nth_page(sg->page, (*offset >> PAGE_SHIFT)); | 2363 | page = nth_page(sg_page(sg), (*offset >> PAGE_SHIFT)); |
| 2357 | *offset &= ~PAGE_MASK; | 2364 | *offset &= ~PAGE_MASK; |
| 2358 | 2365 | ||
| 2359 | /* Bytes in this sg-entry from *offset to the end of the page */ | 2366 | /* Bytes in this sg-entry from *offset to the end of the page */ |
diff --git a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c index ce80fa9ad815..b11324479b5b 100644 --- a/drivers/scsi/seagate.c +++ b/drivers/scsi/seagate.c | |||
| @@ -999,14 +999,14 @@ connect_loop: | |||
| 999 | for (i = 0; i < nobuffs; ++i) | 999 | for (i = 0; i < nobuffs; ++i) |
| 1000 | printk("scsi%d : buffer %d address = %p length = %d\n", | 1000 | printk("scsi%d : buffer %d address = %p length = %d\n", |
| 1001 | hostno, i, | 1001 | hostno, i, |
| 1002 | page_address(buffer[i].page) + buffer[i].offset, | 1002 | sg_virt(&buffer[i]), |
| 1003 | buffer[i].length); | 1003 | buffer[i].length); |
| 1004 | } | 1004 | } |
| 1005 | #endif | 1005 | #endif |
| 1006 | 1006 | ||
| 1007 | buffer = (struct scatterlist *) SCint->request_buffer; | 1007 | buffer = (struct scatterlist *) SCint->request_buffer; |
| 1008 | len = buffer->length; | 1008 | len = buffer->length; |
| 1009 | data = page_address(buffer->page) + buffer->offset; | 1009 | data = sg_virt(buffer); |
| 1010 | } else { | 1010 | } else { |
| 1011 | DPRINTK (DEBUG_SG, "scsi%d : scatter gather not requested.\n", hostno); | 1011 | DPRINTK (DEBUG_SG, "scsi%d : scatter gather not requested.\n", hostno); |
| 1012 | buffer = NULL; | 1012 | buffer = NULL; |
| @@ -1239,7 +1239,7 @@ connect_loop: | |||
| 1239 | --nobuffs; | 1239 | --nobuffs; |
| 1240 | ++buffer; | 1240 | ++buffer; |
| 1241 | len = buffer->length; | 1241 | len = buffer->length; |
| 1242 | data = page_address(buffer->page) + buffer->offset; | 1242 | data = sg_virt(buffer); |
| 1243 | DPRINTK (DEBUG_SG, | 1243 | DPRINTK (DEBUG_SG, |
| 1244 | "scsi%d : next scatter-gather buffer len = %d address = %08x\n", | 1244 | "scsi%d : next scatter-gather buffer len = %d address = %08x\n", |
| 1245 | hostno, len, data); | 1245 | hostno, len, data); |
| @@ -1396,7 +1396,7 @@ connect_loop: | |||
| 1396 | --nobuffs; | 1396 | --nobuffs; |
| 1397 | ++buffer; | 1397 | ++buffer; |
| 1398 | len = buffer->length; | 1398 | len = buffer->length; |
| 1399 | data = page_address(buffer->page) + buffer->offset; | 1399 | data = sg_virt(buffer); |
| 1400 | DPRINTK (DEBUG_SG, "scsi%d : next scatter-gather buffer len = %d address = %08x\n", hostno, len, data); | 1400 | DPRINTK (DEBUG_SG, "scsi%d : next scatter-gather buffer len = %d address = %08x\n", hostno, len, data); |
| 1401 | } | 1401 | } |
| 1402 | break; | 1402 | break; |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 7238b2dfc497..cc1971002846 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
| @@ -1169,7 +1169,7 @@ sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type) | |||
| 1169 | len = vma->vm_end - sa; | 1169 | len = vma->vm_end - sa; |
| 1170 | len = (len < sg->length) ? len : sg->length; | 1170 | len = (len < sg->length) ? len : sg->length; |
| 1171 | if (offset < len) { | 1171 | if (offset < len) { |
| 1172 | page = virt_to_page(page_address(sg->page) + offset); | 1172 | page = virt_to_page(page_address(sg_page(sg)) + offset); |
| 1173 | get_page(page); /* increment page count */ | 1173 | get_page(page); /* increment page count */ |
| 1174 | break; | 1174 | break; |
| 1175 | } | 1175 | } |
| @@ -1717,13 +1717,13 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, | |||
| 1717 | goto out_unlock; */ | 1717 | goto out_unlock; */ |
| 1718 | } | 1718 | } |
| 1719 | 1719 | ||
| 1720 | sgl[0].page = pages[0]; | 1720 | sg_set_page(sgl, pages[0]); |
| 1721 | sgl[0].offset = uaddr & ~PAGE_MASK; | 1721 | sgl[0].offset = uaddr & ~PAGE_MASK; |
| 1722 | if (nr_pages > 1) { | 1722 | if (nr_pages > 1) { |
| 1723 | sgl[0].length = PAGE_SIZE - sgl[0].offset; | 1723 | sgl[0].length = PAGE_SIZE - sgl[0].offset; |
| 1724 | count -= sgl[0].length; | 1724 | count -= sgl[0].length; |
| 1725 | for (i=1; i < nr_pages ; i++) { | 1725 | for (i=1; i < nr_pages ; i++) { |
| 1726 | sgl[i].page = pages[i]; | 1726 | sg_set_page(&sgl[i], pages[i]); |
| 1727 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; | 1727 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; |
| 1728 | count -= PAGE_SIZE; | 1728 | count -= PAGE_SIZE; |
| 1729 | } | 1729 | } |
| @@ -1754,7 +1754,7 @@ st_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages, | |||
| 1754 | int i; | 1754 | int i; |
| 1755 | 1755 | ||
| 1756 | for (i=0; i < nr_pages; i++) { | 1756 | for (i=0; i < nr_pages; i++) { |
| 1757 | struct page *page = sgl[i].page; | 1757 | struct page *page = sg_page(&sgl[i]); |
| 1758 | 1758 | ||
| 1759 | if (dirtied) | 1759 | if (dirtied) |
| 1760 | SetPageDirty(page); | 1760 | SetPageDirty(page); |
| @@ -1854,7 +1854,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
| 1854 | scatter_elem_sz_prev = ret_sz; | 1854 | scatter_elem_sz_prev = ret_sz; |
| 1855 | } | 1855 | } |
| 1856 | } | 1856 | } |
| 1857 | sg->page = p; | 1857 | sg_set_page(sg, p); |
| 1858 | sg->length = (ret_sz > num) ? num : ret_sz; | 1858 | sg->length = (ret_sz > num) ? num : ret_sz; |
| 1859 | 1859 | ||
| 1860 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " | 1860 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " |
| @@ -1907,14 +1907,14 @@ sg_write_xfer(Sg_request * srp) | |||
| 1907 | onum = 1; | 1907 | onum = 1; |
| 1908 | 1908 | ||
| 1909 | ksglen = sg->length; | 1909 | ksglen = sg->length; |
| 1910 | p = page_address(sg->page); | 1910 | p = page_address(sg_page(sg)); |
| 1911 | for (j = 0, k = 0; j < onum; ++j) { | 1911 | for (j = 0, k = 0; j < onum; ++j) { |
| 1912 | res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up); | 1912 | res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up); |
| 1913 | if (res) | 1913 | if (res) |
| 1914 | return res; | 1914 | return res; |
| 1915 | 1915 | ||
| 1916 | for (; p; sg = sg_next(sg), ksglen = sg->length, | 1916 | for (; p; sg = sg_next(sg), ksglen = sg->length, |
| 1917 | p = page_address(sg->page)) { | 1917 | p = page_address(sg_page(sg))) { |
| 1918 | if (usglen <= 0) | 1918 | if (usglen <= 0) |
| 1919 | break; | 1919 | break; |
| 1920 | if (ksglen > usglen) { | 1920 | if (ksglen > usglen) { |
| @@ -1991,12 +1991,12 @@ sg_remove_scat(Sg_scatter_hold * schp) | |||
| 1991 | } else { | 1991 | } else { |
| 1992 | int k; | 1992 | int k; |
| 1993 | 1993 | ||
| 1994 | for (k = 0; (k < schp->k_use_sg) && sg->page; | 1994 | for (k = 0; (k < schp->k_use_sg) && sg_page(sg); |
| 1995 | ++k, sg = sg_next(sg)) { | 1995 | ++k, sg = sg_next(sg)) { |
| 1996 | SCSI_LOG_TIMEOUT(5, printk( | 1996 | SCSI_LOG_TIMEOUT(5, printk( |
| 1997 | "sg_remove_scat: k=%d, pg=0x%p, len=%d\n", | 1997 | "sg_remove_scat: k=%d, pg=0x%p, len=%d\n", |
| 1998 | k, sg->page, sg->length)); | 1998 | k, sg_page(sg), sg->length)); |
| 1999 | sg_page_free(sg->page, sg->length); | 1999 | sg_page_free(sg_page(sg), sg->length); |
| 2000 | } | 2000 | } |
| 2001 | } | 2001 | } |
| 2002 | kfree(schp->buffer); | 2002 | kfree(schp->buffer); |
| @@ -2038,7 +2038,7 @@ sg_read_xfer(Sg_request * srp) | |||
| 2038 | } else | 2038 | } else |
| 2039 | onum = 1; | 2039 | onum = 1; |
| 2040 | 2040 | ||
| 2041 | p = page_address(sg->page); | 2041 | p = page_address(sg_page(sg)); |
| 2042 | ksglen = sg->length; | 2042 | ksglen = sg->length; |
| 2043 | for (j = 0, k = 0; j < onum; ++j) { | 2043 | for (j = 0, k = 0; j < onum; ++j) { |
| 2044 | res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up); | 2044 | res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up); |
| @@ -2046,7 +2046,7 @@ sg_read_xfer(Sg_request * srp) | |||
| 2046 | return res; | 2046 | return res; |
| 2047 | 2047 | ||
| 2048 | for (; p; sg = sg_next(sg), ksglen = sg->length, | 2048 | for (; p; sg = sg_next(sg), ksglen = sg->length, |
| 2049 | p = page_address(sg->page)) { | 2049 | p = page_address(sg_page(sg))) { |
| 2050 | if (usglen <= 0) | 2050 | if (usglen <= 0) |
| 2051 | break; | 2051 | break; |
| 2052 | if (ksglen > usglen) { | 2052 | if (ksglen > usglen) { |
| @@ -2092,15 +2092,15 @@ sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) | |||
| 2092 | if ((!outp) || (num_read_xfer <= 0)) | 2092 | if ((!outp) || (num_read_xfer <= 0)) |
| 2093 | return 0; | 2093 | return 0; |
| 2094 | 2094 | ||
| 2095 | for (k = 0; (k < schp->k_use_sg) && sg->page; ++k, sg = sg_next(sg)) { | 2095 | for (k = 0; (k < schp->k_use_sg) && sg_page(sg); ++k, sg = sg_next(sg)) { |
| 2096 | num = sg->length; | 2096 | num = sg->length; |
| 2097 | if (num > num_read_xfer) { | 2097 | if (num > num_read_xfer) { |
| 2098 | if (__copy_to_user(outp, page_address(sg->page), | 2098 | if (__copy_to_user(outp, page_address(sg_page(sg)), |
| 2099 | num_read_xfer)) | 2099 | num_read_xfer)) |
| 2100 | return -EFAULT; | 2100 | return -EFAULT; |
| 2101 | break; | 2101 | break; |
| 2102 | } else { | 2102 | } else { |
| 2103 | if (__copy_to_user(outp, page_address(sg->page), | 2103 | if (__copy_to_user(outp, page_address(sg_page(sg)), |
| 2104 | num)) | 2104 | num)) |
| 2105 | return -EFAULT; | 2105 | return -EFAULT; |
| 2106 | num_read_xfer -= num; | 2106 | num_read_xfer -= num; |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 73c44cbdea47..ce69b9efc102 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
| @@ -3797,7 +3797,7 @@ static void buf_to_sg(struct st_buffer *STbp, unsigned int length) | |||
| 3797 | sg = &(STbp->sg[0]); | 3797 | sg = &(STbp->sg[0]); |
| 3798 | frp = STbp->frp; | 3798 | frp = STbp->frp; |
| 3799 | for (i=count=0; count < length; i++) { | 3799 | for (i=count=0; count < length; i++) { |
| 3800 | sg[i].page = frp[i].page; | 3800 | sg_set_page(&sg[i], frp[i].page); |
| 3801 | if (length - count > frp[i].length) | 3801 | if (length - count > frp[i].length) |
| 3802 | sg[i].length = frp[i].length; | 3802 | sg[i].length = frp[i].length; |
| 3803 | else | 3803 | else |
| @@ -4446,14 +4446,14 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa | |||
| 4446 | } | 4446 | } |
| 4447 | 4447 | ||
| 4448 | /* Populate the scatter/gather list */ | 4448 | /* Populate the scatter/gather list */ |
| 4449 | sgl[0].page = pages[0]; | 4449 | sg_set_page(&sgl[0], pages[0]); |
| 4450 | sgl[0].offset = uaddr & ~PAGE_MASK; | 4450 | sgl[0].offset = uaddr & ~PAGE_MASK; |
| 4451 | if (nr_pages > 1) { | 4451 | if (nr_pages > 1) { |
| 4452 | sgl[0].length = PAGE_SIZE - sgl[0].offset; | 4452 | sgl[0].length = PAGE_SIZE - sgl[0].offset; |
| 4453 | count -= sgl[0].length; | 4453 | count -= sgl[0].length; |
| 4454 | for (i=1; i < nr_pages ; i++) { | 4454 | for (i=1; i < nr_pages ; i++) { |
| 4455 | sg_set_page(&sgl[i], pages[i]);; | ||
| 4455 | sgl[i].offset = 0; | 4456 | sgl[i].offset = 0; |
| 4456 | sgl[i].page = pages[i]; | ||
| 4457 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; | 4457 | sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; |
| 4458 | count -= PAGE_SIZE; | 4458 | count -= PAGE_SIZE; |
| 4459 | } | 4459 | } |
| @@ -4483,7 +4483,7 @@ static int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_p | |||
| 4483 | int i; | 4483 | int i; |
| 4484 | 4484 | ||
| 4485 | for (i=0; i < nr_pages; i++) { | 4485 | for (i=0; i < nr_pages; i++) { |
| 4486 | struct page *page = sgl[i].page; | 4486 | struct page *page = sg_page(&sgl[i]); |
| 4487 | 4487 | ||
| 4488 | if (dirtied) | 4488 | if (dirtied) |
| 4489 | SetPageDirty(page); | 4489 | SetPageDirty(page); |
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 4aafe89b557f..2dcde373b20e 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c | |||
| @@ -272,8 +272,7 @@ static struct scsi_host_template *the_template = NULL; | |||
| 272 | #define HOSTNO instance->host_no | 272 | #define HOSTNO instance->host_no |
| 273 | #define H_NO(cmd) (cmd)->device->host->host_no | 273 | #define H_NO(cmd) (cmd)->device->host->host_no |
| 274 | 274 | ||
| 275 | #define SGADDR(buffer) (void *)(((unsigned long)page_address((buffer)->page)) + \ | 275 | #define SGADDR(buffer) (void *)(((unsigned long)sg_virt(((buffer))))) |
| 276 | (buffer)->offset) | ||
| 277 | 276 | ||
| 278 | #ifdef SUPPORT_TAGS | 277 | #ifdef SUPPORT_TAGS |
| 279 | 278 | ||
diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c index 8befab7e9839..90cee94d9522 100644 --- a/drivers/scsi/sym53c416.c +++ b/drivers/scsi/sym53c416.c | |||
| @@ -196,7 +196,7 @@ static unsigned int sym53c416_base_3[2] = {0,0}; | |||
| 196 | 196 | ||
| 197 | #define MAXHOSTS 4 | 197 | #define MAXHOSTS 4 |
| 198 | 198 | ||
| 199 | #define SG_ADDRESS(buffer) ((char *) (page_address((buffer)->page)+(buffer)->offset)) | 199 | #define SG_ADDRESS(buffer) ((char *) sg_virt((buffer))) |
| 200 | 200 | ||
| 201 | enum phases | 201 | enum phases |
| 202 | { | 202 | { |
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c index 5c72ca31a47a..44193049c4ae 100644 --- a/drivers/scsi/tmscsim.c +++ b/drivers/scsi/tmscsim.c | |||
| @@ -430,10 +430,7 @@ static __inline__ void dc390_Going_remove (struct dc390_dcb* pDCB, struct dc390_ | |||
| 430 | 430 | ||
| 431 | static struct scatterlist* dc390_sg_build_single(struct scatterlist *sg, void *addr, unsigned int length) | 431 | static struct scatterlist* dc390_sg_build_single(struct scatterlist *sg, void *addr, unsigned int length) |
| 432 | { | 432 | { |
| 433 | memset(sg, 0, sizeof(struct scatterlist)); | 433 | sg_init_one(sg, addr, length); |
| 434 | sg->page = virt_to_page(addr); | ||
| 435 | sg->length = length; | ||
| 436 | sg->offset = (unsigned long)addr & ~PAGE_MASK; | ||
| 437 | return sg; | 434 | return sg; |
| 438 | } | 435 | } |
| 439 | 436 | ||
diff --git a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c index ea72bbeb8f9d..6d1f0edd7985 100644 --- a/drivers/scsi/ultrastor.c +++ b/drivers/scsi/ultrastor.c | |||
| @@ -681,7 +681,7 @@ static inline void build_sg_list(struct mscp *mscp, struct scsi_cmnd *SCpnt) | |||
| 681 | 681 | ||
| 682 | max = scsi_sg_count(SCpnt); | 682 | max = scsi_sg_count(SCpnt); |
| 683 | scsi_for_each_sg(SCpnt, sg, max, i) { | 683 | scsi_for_each_sg(SCpnt, sg, max, i) { |
| 684 | mscp->sglist[i].address = isa_page_to_bus(sg->page) + sg->offset; | 684 | mscp->sglist[i].address = isa_page_to_bus(sg_page(sg)) + sg->offset; |
| 685 | mscp->sglist[i].num_bytes = sg->length; | 685 | mscp->sglist[i].num_bytes = sg->length; |
| 686 | transfer_length += sg->length; | 686 | transfer_length += sg->length; |
| 687 | } | 687 | } |
diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c index 0e8e642fd3b0..fdbb92d1f722 100644 --- a/drivers/scsi/wd33c93.c +++ b/drivers/scsi/wd33c93.c | |||
| @@ -410,8 +410,7 @@ wd33c93_queuecommand(struct scsi_cmnd *cmd, | |||
| 410 | if (cmd->use_sg) { | 410 | if (cmd->use_sg) { |
| 411 | cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; | 411 | cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer; |
| 412 | cmd->SCp.buffers_residual = cmd->use_sg - 1; | 412 | cmd->SCp.buffers_residual = cmd->use_sg - 1; |
| 413 | cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + | 413 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 414 | cmd->SCp.buffer->offset; | ||
| 415 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 414 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 416 | } else { | 415 | } else { |
| 417 | cmd->SCp.buffer = NULL; | 416 | cmd->SCp.buffer = NULL; |
| @@ -745,8 +744,7 @@ transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd, | |||
| 745 | ++cmd->SCp.buffer; | 744 | ++cmd->SCp.buffer; |
| 746 | --cmd->SCp.buffers_residual; | 745 | --cmd->SCp.buffers_residual; |
| 747 | cmd->SCp.this_residual = cmd->SCp.buffer->length; | 746 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
| 748 | cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + | 747 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
| 749 | cmd->SCp.buffer->offset; | ||
| 750 | } | 748 | } |
| 751 | if (!cmd->SCp.this_residual) /* avoid bogus setups */ | 749 | if (!cmd->SCp.this_residual) /* avoid bogus setups */ |
| 752 | return; | 750 | return; |
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c index 255c611e78b8..03cd44f231df 100644 --- a/drivers/scsi/wd7000.c +++ b/drivers/scsi/wd7000.c | |||
| @@ -1123,7 +1123,7 @@ static int wd7000_queuecommand(struct scsi_cmnd *SCpnt, | |||
| 1123 | any2scsi(scb->maxlen, nseg * sizeof(Sgb)); | 1123 | any2scsi(scb->maxlen, nseg * sizeof(Sgb)); |
| 1124 | 1124 | ||
| 1125 | scsi_for_each_sg(SCpnt, sg, nseg, i) { | 1125 | scsi_for_each_sg(SCpnt, sg, nseg, i) { |
| 1126 | any2scsi(sgb[i].ptr, isa_page_to_bus(sg->page) + sg->offset); | 1126 | any2scsi(sgb[i].ptr, isa_page_to_bus(sg_page(sg)) + sg->offset); |
| 1127 | any2scsi(sgb[i].len, sg->length); | 1127 | any2scsi(sgb[i].len, sg->length); |
| 1128 | } | 1128 | } |
| 1129 | } else { | 1129 | } else { |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 8dd5a6afd513..90d64a808464 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
| @@ -437,13 +437,11 @@ int usb_sg_init ( | |||
| 437 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_IOMMU) | 437 | #if defined(CONFIG_HIGHMEM) || defined(CONFIG_IOMMU) |
| 438 | io->urbs[i]->transfer_buffer = NULL; | 438 | io->urbs[i]->transfer_buffer = NULL; |
| 439 | #else | 439 | #else |
| 440 | io->urbs[i]->transfer_buffer = | 440 | io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); |
| 441 | page_address(sg[i].page) + sg[i].offset; | ||
| 442 | #endif | 441 | #endif |
| 443 | } else { | 442 | } else { |
| 444 | /* hc may use _only_ transfer_buffer */ | 443 | /* hc may use _only_ transfer_buffer */ |
| 445 | io->urbs [i]->transfer_buffer = | 444 | io->urbs [i]->transfer_buffer = sg_virt(&sg[i]); |
| 446 | page_address (sg [i].page) + sg [i].offset; | ||
| 447 | len = sg [i].length; | 445 | len = sg [i].length; |
| 448 | } | 446 | } |
| 449 | 447 | ||
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index e7d982a71548..91e999c9f680 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c | |||
| @@ -519,8 +519,7 @@ static void mts_do_sg (struct urb* transfer) | |||
| 519 | context->fragment++; | 519 | context->fragment++; |
| 520 | mts_int_submit_urb(transfer, | 520 | mts_int_submit_urb(transfer, |
| 521 | context->data_pipe, | 521 | context->data_pipe, |
| 522 | page_address(sg[context->fragment].page) + | 522 | sg_virt(&sg[context->fragment]), |
| 523 | sg[context->fragment].offset, | ||
| 524 | sg[context->fragment].length, | 523 | sg[context->fragment].length, |
| 525 | context->fragment + 1 == scsi_sg_count(context->srb) ? | 524 | context->fragment + 1 == scsi_sg_count(context->srb) ? |
| 526 | mts_data_done : mts_do_sg); | 525 | mts_data_done : mts_do_sg); |
| @@ -557,7 +556,7 @@ mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc) | |||
| 557 | return; | 556 | return; |
| 558 | } else { | 557 | } else { |
| 559 | sg = scsi_sglist(srb); | 558 | sg = scsi_sglist(srb); |
| 560 | desc->context.data = page_address(sg[0].page) + sg[0].offset; | 559 | desc->context.data = sg_virt(&sg[0]); |
| 561 | desc->context.data_length = sg[0].length; | 560 | desc->context.data_length = sg[0].length; |
| 562 | } | 561 | } |
| 563 | 562 | ||
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index e901d31e051b..ea3162146481 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
| @@ -360,9 +360,9 @@ static void free_sglist (struct scatterlist *sg, int nents) | |||
| 360 | if (!sg) | 360 | if (!sg) |
| 361 | return; | 361 | return; |
| 362 | for (i = 0; i < nents; i++) { | 362 | for (i = 0; i < nents; i++) { |
| 363 | if (!sg [i].page) | 363 | if (!sg_page(&sg[i])) |
| 364 | continue; | 364 | continue; |
| 365 | kfree (page_address (sg [i].page) + sg [i].offset); | 365 | kfree (sg_virt(&sg[i])); |
| 366 | } | 366 | } |
| 367 | kfree (sg); | 367 | kfree (sg); |
| 368 | } | 368 | } |
diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c index cc8f7c52c729..889622baac20 100644 --- a/drivers/usb/storage/protocol.c +++ b/drivers/usb/storage/protocol.c | |||
| @@ -195,7 +195,7 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, | |||
| 195 | * the *offset and *index values for the next loop. */ | 195 | * the *offset and *index values for the next loop. */ |
| 196 | cnt = 0; | 196 | cnt = 0; |
| 197 | while (cnt < buflen) { | 197 | while (cnt < buflen) { |
| 198 | struct page *page = sg->page + | 198 | struct page *page = sg_page(sg) + |
| 199 | ((sg->offset + *offset) >> PAGE_SHIFT); | 199 | ((sg->offset + *offset) >> PAGE_SHIFT); |
| 200 | unsigned int poff = | 200 | unsigned int poff = |
| 201 | (sg->offset + *offset) & (PAGE_SIZE-1); | 201 | (sg->offset + *offset) & (PAGE_SIZE-1); |
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h index 0a3ee5a322b0..5574ba3ab1f9 100644 --- a/fs/cifs/cifsfs.h +++ b/fs/cifs/cifsfs.h | |||
| @@ -103,7 +103,7 @@ extern int cifs_ioctl(struct inode *inode, struct file *filep, | |||
| 103 | unsigned int command, unsigned long arg); | 103 | unsigned int command, unsigned long arg); |
| 104 | 104 | ||
| 105 | #ifdef CONFIG_CIFS_EXPERIMENTAL | 105 | #ifdef CONFIG_CIFS_EXPERIMENTAL |
| 106 | extern struct export_operations cifs_export_ops; | 106 | extern const struct export_operations cifs_export_ops; |
| 107 | #endif /* EXPERIMENTAL */ | 107 | #endif /* EXPERIMENTAL */ |
| 108 | 108 | ||
| 109 | #define CIFS_VERSION "1.51" | 109 | #define CIFS_VERSION "1.51" |
diff --git a/fs/cifs/export.c b/fs/cifs/export.c index d614b91caeca..75949d6a5f1b 100644 --- a/fs/cifs/export.c +++ b/fs/cifs/export.c | |||
| @@ -53,7 +53,7 @@ static struct dentry *cifs_get_parent(struct dentry *dentry) | |||
| 53 | return ERR_PTR(-EACCES); | 53 | return ERR_PTR(-EACCES); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | struct export_operations cifs_export_ops = { | 56 | const struct export_operations cifs_export_ops = { |
| 57 | .get_parent = cifs_get_parent, | 57 | .get_parent = cifs_get_parent, |
| 58 | /* Following five export operations are unneeded so far and can default: | 58 | /* Following five export operations are unneeded so far and can default: |
| 59 | .get_dentry = | 59 | .get_dentry = |
diff --git a/fs/dcache.c b/fs/dcache.c index 2bb3f7ac683b..d9ca1e5ceb92 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
| @@ -1479,6 +1479,8 @@ static void switch_names(struct dentry *dentry, struct dentry *target) | |||
| 1479 | * dentry:internal, target:external. Steal target's | 1479 | * dentry:internal, target:external. Steal target's |
| 1480 | * storage and make target internal. | 1480 | * storage and make target internal. |
| 1481 | */ | 1481 | */ |
| 1482 | memcpy(target->d_iname, dentry->d_name.name, | ||
| 1483 | dentry->d_name.len + 1); | ||
| 1482 | dentry->d_name.name = target->d_name.name; | 1484 | dentry->d_name.name = target->d_name.name; |
| 1483 | target->d_name.name = target->d_iname; | 1485 | target->d_name.name = target->d_iname; |
| 1484 | } | 1486 | } |
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 1ae90ef2c74d..0a9882edf562 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
| @@ -283,7 +283,7 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg, | |||
| 283 | pg = virt_to_page(addr); | 283 | pg = virt_to_page(addr); |
| 284 | offset = offset_in_page(addr); | 284 | offset = offset_in_page(addr); |
| 285 | if (sg) { | 285 | if (sg) { |
| 286 | sg[i].page = pg; | 286 | sg_set_page(&sg[i], pg); |
| 287 | sg[i].offset = offset; | 287 | sg[i].offset = offset; |
| 288 | } | 288 | } |
| 289 | remainder_of_page = PAGE_CACHE_SIZE - offset; | 289 | remainder_of_page = PAGE_CACHE_SIZE - offset; |
| @@ -713,10 +713,13 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, | |||
| 713 | { | 713 | { |
| 714 | struct scatterlist src_sg, dst_sg; | 714 | struct scatterlist src_sg, dst_sg; |
| 715 | 715 | ||
| 716 | src_sg.page = src_page; | 716 | sg_init_table(&src_sg, 1); |
| 717 | sg_init_table(&dst_sg, 1); | ||
| 718 | |||
| 719 | sg_set_page(&src_sg, src_page); | ||
| 717 | src_sg.offset = src_offset; | 720 | src_sg.offset = src_offset; |
| 718 | src_sg.length = size; | 721 | src_sg.length = size; |
| 719 | dst_sg.page = dst_page; | 722 | sg_set_page(&dst_sg, dst_page); |
| 720 | dst_sg.offset = dst_offset; | 723 | dst_sg.offset = dst_offset; |
| 721 | dst_sg.length = size; | 724 | dst_sg.length = size; |
| 722 | return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); | 725 | return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); |
| @@ -742,10 +745,13 @@ ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, | |||
| 742 | { | 745 | { |
| 743 | struct scatterlist src_sg, dst_sg; | 746 | struct scatterlist src_sg, dst_sg; |
| 744 | 747 | ||
| 745 | src_sg.page = src_page; | 748 | sg_init_table(&src_sg, 1); |
| 749 | sg_init_table(&dst_sg, 1); | ||
| 750 | |||
| 751 | sg_set_page(&src_sg, src_page); | ||
| 746 | src_sg.offset = src_offset; | 752 | src_sg.offset = src_offset; |
| 747 | src_sg.length = size; | 753 | src_sg.length = size; |
| 748 | dst_sg.page = dst_page; | 754 | sg_set_page(&dst_sg, dst_page); |
| 749 | dst_sg.offset = dst_offset; | 755 | dst_sg.offset = dst_offset; |
| 750 | dst_sg.length = size; | 756 | dst_sg.length = size; |
| 751 | return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); | 757 | return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); |
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index 89d9710dd63d..263fed88c0ca 100644 --- a/fs/ecryptfs/keystore.c +++ b/fs/ecryptfs/keystore.c | |||
| @@ -1040,6 +1040,9 @@ decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok, | |||
| 1040 | }; | 1040 | }; |
| 1041 | int rc = 0; | 1041 | int rc = 0; |
| 1042 | 1042 | ||
| 1043 | sg_init_table(&dst_sg, 1); | ||
| 1044 | sg_init_table(&src_sg, 1); | ||
| 1045 | |||
| 1043 | if (unlikely(ecryptfs_verbosity > 0)) { | 1046 | if (unlikely(ecryptfs_verbosity > 0)) { |
| 1044 | ecryptfs_printk( | 1047 | ecryptfs_printk( |
| 1045 | KERN_DEBUG, "Session key encryption key (size [%d]):\n", | 1048 | KERN_DEBUG, "Session key encryption key (size [%d]):\n", |
diff --git a/fs/efs/namei.c b/fs/efs/namei.c index 5276b19423c1..f7f407075be1 100644 --- a/fs/efs/namei.c +++ b/fs/efs/namei.c | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | #include <linux/string.h> | 10 | #include <linux/string.h> |
| 11 | #include <linux/efs_fs.h> | 11 | #include <linux/efs_fs.h> |
| 12 | #include <linux/smp_lock.h> | 12 | #include <linux/smp_lock.h> |
| 13 | #include <linux/exportfs.h> | ||
| 14 | |||
| 13 | 15 | ||
| 14 | static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int len) { | 16 | static efs_ino_t efs_find_entry(struct inode *inode, const char *name, int len) { |
| 15 | struct buffer_head *bh; | 17 | struct buffer_head *bh; |
| @@ -75,13 +77,10 @@ struct dentry *efs_lookup(struct inode *dir, struct dentry *dentry, struct namei | |||
| 75 | return NULL; | 77 | return NULL; |
| 76 | } | 78 | } |
| 77 | 79 | ||
| 78 | struct dentry *efs_get_dentry(struct super_block *sb, void *vobjp) | 80 | static struct inode *efs_nfs_get_inode(struct super_block *sb, u64 ino, |
| 81 | u32 generation) | ||
| 79 | { | 82 | { |
| 80 | __u32 *objp = vobjp; | ||
| 81 | unsigned long ino = objp[0]; | ||
| 82 | __u32 generation = objp[1]; | ||
| 83 | struct inode *inode; | 83 | struct inode *inode; |
| 84 | struct dentry *result; | ||
| 85 | 84 | ||
| 86 | if (ino == 0) | 85 | if (ino == 0) |
| 87 | return ERR_PTR(-ESTALE); | 86 | return ERR_PTR(-ESTALE); |
| @@ -91,20 +90,25 @@ struct dentry *efs_get_dentry(struct super_block *sb, void *vobjp) | |||
| 91 | 90 | ||
| 92 | if (is_bad_inode(inode) || | 91 | if (is_bad_inode(inode) || |
| 93 | (generation && inode->i_generation != generation)) { | 92 | (generation && inode->i_generation != generation)) { |
| 94 | result = ERR_PTR(-ESTALE); | 93 | iput(inode); |
| 95 | goto out_iput; | 94 | return ERR_PTR(-ESTALE); |
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | result = d_alloc_anon(inode); | 97 | return inode; |
| 99 | if (!result) { | 98 | } |
| 100 | result = ERR_PTR(-ENOMEM); | ||
| 101 | goto out_iput; | ||
| 102 | } | ||
| 103 | return result; | ||
| 104 | 99 | ||
| 105 | out_iput: | 100 | struct dentry *efs_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 106 | iput(inode); | 101 | int fh_len, int fh_type) |
| 107 | return result; | 102 | { |
| 103 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, | ||
| 104 | efs_nfs_get_inode); | ||
| 105 | } | ||
| 106 | |||
| 107 | struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 108 | int fh_len, int fh_type) | ||
| 109 | { | ||
| 110 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, | ||
| 111 | efs_nfs_get_inode); | ||
| 108 | } | 112 | } |
| 109 | 113 | ||
| 110 | struct dentry *efs_get_parent(struct dentry *child) | 114 | struct dentry *efs_get_parent(struct dentry *child) |
diff --git a/fs/efs/super.c b/fs/efs/super.c index 25d0326c5f1c..c79bc627f107 100644 --- a/fs/efs/super.c +++ b/fs/efs/super.c | |||
| @@ -113,8 +113,9 @@ static const struct super_operations efs_superblock_operations = { | |||
| 113 | .remount_fs = efs_remount, | 113 | .remount_fs = efs_remount, |
| 114 | }; | 114 | }; |
| 115 | 115 | ||
| 116 | static struct export_operations efs_export_ops = { | 116 | static const struct export_operations efs_export_ops = { |
| 117 | .get_dentry = efs_get_dentry, | 117 | .fh_to_dentry = efs_fh_to_dentry, |
| 118 | .fh_to_parent = efs_fh_to_parent, | ||
| 118 | .get_parent = efs_get_parent, | 119 | .get_parent = efs_get_parent, |
| 119 | }; | 120 | }; |
| 120 | 121 | ||
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index 8adb32a9387a..109ab5e44eca 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c | |||
| @@ -1,4 +1,13 @@ | |||
| 1 | 1 | /* | |
| 2 | * Copyright (C) Neil Brown 2002 | ||
| 3 | * Copyright (C) Christoph Hellwig 2007 | ||
| 4 | * | ||
| 5 | * This file contains the code mapping from inodes to NFS file handles, | ||
| 6 | * and for mapping back from file handles to dentries. | ||
| 7 | * | ||
| 8 | * For details on why we do all the strange and hairy things in here | ||
| 9 | * take a look at Documentation/filesystems/Exporting. | ||
| 10 | */ | ||
| 2 | #include <linux/exportfs.h> | 11 | #include <linux/exportfs.h> |
| 3 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
| 4 | #include <linux/file.h> | 13 | #include <linux/file.h> |
| @@ -9,32 +18,19 @@ | |||
| 9 | #define dprintk(fmt, args...) do{}while(0) | 18 | #define dprintk(fmt, args...) do{}while(0) |
| 10 | 19 | ||
| 11 | 20 | ||
| 12 | static int get_name(struct dentry *dentry, char *name, | 21 | static int get_name(struct vfsmount *mnt, struct dentry *dentry, char *name, |
| 13 | struct dentry *child); | 22 | struct dentry *child); |
| 14 | 23 | ||
| 15 | 24 | ||
| 16 | static struct dentry *exportfs_get_dentry(struct super_block *sb, void *obj) | 25 | static int exportfs_get_name(struct vfsmount *mnt, struct dentry *dir, |
| 26 | char *name, struct dentry *child) | ||
| 17 | { | 27 | { |
| 18 | struct dentry *result = ERR_PTR(-ESTALE); | 28 | const struct export_operations *nop = dir->d_sb->s_export_op; |
| 19 | |||
| 20 | if (sb->s_export_op->get_dentry) { | ||
| 21 | result = sb->s_export_op->get_dentry(sb, obj); | ||
| 22 | if (!result) | ||
| 23 | result = ERR_PTR(-ESTALE); | ||
| 24 | } | ||
| 25 | |||
| 26 | return result; | ||
| 27 | } | ||
| 28 | |||
| 29 | static int exportfs_get_name(struct dentry *dir, char *name, | ||
| 30 | struct dentry *child) | ||
| 31 | { | ||
| 32 | struct export_operations *nop = dir->d_sb->s_export_op; | ||
| 33 | 29 | ||
| 34 | if (nop->get_name) | 30 | if (nop->get_name) |
| 35 | return nop->get_name(dir, name, child); | 31 | return nop->get_name(dir, name, child); |
| 36 | else | 32 | else |
| 37 | return get_name(dir, name, child); | 33 | return get_name(mnt, dir, name, child); |
| 38 | } | 34 | } |
| 39 | 35 | ||
| 40 | /* | 36 | /* |
| @@ -98,7 +94,7 @@ find_disconnected_root(struct dentry *dentry) | |||
| 98 | * It may already be, as the flag isn't always updated when connection happens. | 94 | * It may already be, as the flag isn't always updated when connection happens. |
| 99 | */ | 95 | */ |
| 100 | static int | 96 | static int |
| 101 | reconnect_path(struct super_block *sb, struct dentry *target_dir) | 97 | reconnect_path(struct vfsmount *mnt, struct dentry *target_dir) |
| 102 | { | 98 | { |
| 103 | char nbuf[NAME_MAX+1]; | 99 | char nbuf[NAME_MAX+1]; |
| 104 | int noprogress = 0; | 100 | int noprogress = 0; |
| @@ -121,7 +117,7 @@ reconnect_path(struct super_block *sb, struct dentry *target_dir) | |||
| 121 | pd->d_flags &= ~DCACHE_DISCONNECTED; | 117 | pd->d_flags &= ~DCACHE_DISCONNECTED; |
| 122 | spin_unlock(&pd->d_lock); | 118 | spin_unlock(&pd->d_lock); |
| 123 | noprogress = 0; | 119 | noprogress = 0; |
| 124 | } else if (pd == sb->s_root) { | 120 | } else if (pd == mnt->mnt_sb->s_root) { |
| 125 | printk(KERN_ERR "export: Eeek filesystem root is not connected, impossible\n"); | 121 | printk(KERN_ERR "export: Eeek filesystem root is not connected, impossible\n"); |
| 126 | spin_lock(&pd->d_lock); | 122 | spin_lock(&pd->d_lock); |
| 127 | pd->d_flags &= ~DCACHE_DISCONNECTED; | 123 | pd->d_flags &= ~DCACHE_DISCONNECTED; |
| @@ -147,8 +143,8 @@ reconnect_path(struct super_block *sb, struct dentry *target_dir) | |||
| 147 | struct dentry *npd; | 143 | struct dentry *npd; |
| 148 | 144 | ||
| 149 | mutex_lock(&pd->d_inode->i_mutex); | 145 | mutex_lock(&pd->d_inode->i_mutex); |
| 150 | if (sb->s_export_op->get_parent) | 146 | if (mnt->mnt_sb->s_export_op->get_parent) |
| 151 | ppd = sb->s_export_op->get_parent(pd); | 147 | ppd = mnt->mnt_sb->s_export_op->get_parent(pd); |
| 152 | mutex_unlock(&pd->d_inode->i_mutex); | 148 | mutex_unlock(&pd->d_inode->i_mutex); |
| 153 | 149 | ||
| 154 | if (IS_ERR(ppd)) { | 150 | if (IS_ERR(ppd)) { |
| @@ -161,7 +157,7 @@ reconnect_path(struct super_block *sb, struct dentry *target_dir) | |||
| 161 | 157 | ||
| 162 | dprintk("%s: find name of %lu in %lu\n", __FUNCTION__, | 158 | dprintk("%s: find name of %lu in %lu\n", __FUNCTION__, |
| 163 | pd->d_inode->i_ino, ppd->d_inode->i_ino); | 159 | pd->d_inode->i_ino, ppd->d_inode->i_ino); |
| 164 | err = exportfs_get_name(ppd, nbuf, pd); | 160 | err = exportfs_get_name(mnt, ppd, nbuf, pd); |
| 165 | if (err) { | 161 | if (err) { |
| 166 | dput(ppd); | 162 | dput(ppd); |
| 167 | dput(pd); | 163 | dput(pd); |
| @@ -214,125 +210,6 @@ reconnect_path(struct super_block *sb, struct dentry *target_dir) | |||
| 214 | return 0; | 210 | return 0; |
| 215 | } | 211 | } |
| 216 | 212 | ||
| 217 | /** | ||
| 218 | * find_exported_dentry - helper routine to implement export_operations->decode_fh | ||
| 219 | * @sb: The &super_block identifying the filesystem | ||
| 220 | * @obj: An opaque identifier of the object to be found - passed to | ||
| 221 | * get_inode | ||
| 222 | * @parent: An optional opqaue identifier of the parent of the object. | ||
| 223 | * @acceptable: A function used to test possible &dentries to see if they are | ||
| 224 | * acceptable | ||
| 225 | * @context: A parameter to @acceptable so that it knows on what basis to | ||
| 226 | * judge. | ||
| 227 | * | ||
| 228 | * find_exported_dentry is the central helper routine to enable file systems | ||
| 229 | * to provide the decode_fh() export_operation. It's main task is to take | ||
| 230 | * an &inode, find or create an appropriate &dentry structure, and possibly | ||
| 231 | * splice this into the dcache in the correct place. | ||
| 232 | * | ||
| 233 | * The decode_fh() operation provided by the filesystem should call | ||
| 234 | * find_exported_dentry() with the same parameters that it received except | ||
| 235 | * that instead of the file handle fragment, pointers to opaque identifiers | ||
| 236 | * for the object and optionally its parent are passed. The default decode_fh | ||
| 237 | * routine passes one pointer to the start of the filehandle fragment, and | ||
| 238 | * one 8 bytes into the fragment. It is expected that most filesystems will | ||
| 239 | * take this approach, though the offset to the parent identifier may well be | ||
| 240 | * different. | ||
| 241 | * | ||
| 242 | * find_exported_dentry() will call get_dentry to get an dentry pointer from | ||
| 243 | * the file system. If any &dentry in the d_alias list is acceptable, it will | ||
| 244 | * be returned. Otherwise find_exported_dentry() will attempt to splice a new | ||
| 245 | * &dentry into the dcache using get_name() and get_parent() to find the | ||
| 246 | * appropriate place. | ||
| 247 | */ | ||
| 248 | |||
| 249 | struct dentry * | ||
| 250 | find_exported_dentry(struct super_block *sb, void *obj, void *parent, | ||
| 251 | int (*acceptable)(void *context, struct dentry *de), | ||
| 252 | void *context) | ||
| 253 | { | ||
| 254 | struct dentry *result, *alias; | ||
| 255 | int err = -ESTALE; | ||
| 256 | |||
| 257 | /* | ||
| 258 | * Attempt to find the inode. | ||
| 259 | */ | ||
| 260 | result = exportfs_get_dentry(sb, obj); | ||
| 261 | if (IS_ERR(result)) | ||
| 262 | return result; | ||
| 263 | |||
| 264 | if (S_ISDIR(result->d_inode->i_mode)) { | ||
| 265 | if (!(result->d_flags & DCACHE_DISCONNECTED)) { | ||
| 266 | if (acceptable(context, result)) | ||
| 267 | return result; | ||
| 268 | err = -EACCES; | ||
| 269 | goto err_result; | ||
| 270 | } | ||
| 271 | |||
| 272 | err = reconnect_path(sb, result); | ||
| 273 | if (err) | ||
| 274 | goto err_result; | ||
| 275 | } else { | ||
| 276 | struct dentry *target_dir, *nresult; | ||
| 277 | char nbuf[NAME_MAX+1]; | ||
| 278 | |||
| 279 | alias = find_acceptable_alias(result, acceptable, context); | ||
| 280 | if (alias) | ||
| 281 | return alias; | ||
| 282 | |||
| 283 | if (parent == NULL) | ||
| 284 | goto err_result; | ||
| 285 | |||
| 286 | target_dir = exportfs_get_dentry(sb,parent); | ||
| 287 | if (IS_ERR(target_dir)) { | ||
| 288 | err = PTR_ERR(target_dir); | ||
| 289 | goto err_result; | ||
| 290 | } | ||
| 291 | |||
| 292 | err = reconnect_path(sb, target_dir); | ||
| 293 | if (err) { | ||
| 294 | dput(target_dir); | ||
| 295 | goto err_result; | ||
| 296 | } | ||
| 297 | |||
| 298 | /* | ||
| 299 | * As we weren't after a directory, have one more step to go. | ||
| 300 | */ | ||
| 301 | err = exportfs_get_name(target_dir, nbuf, result); | ||
| 302 | if (!err) { | ||
| 303 | mutex_lock(&target_dir->d_inode->i_mutex); | ||
| 304 | nresult = lookup_one_len(nbuf, target_dir, | ||
| 305 | strlen(nbuf)); | ||
| 306 | mutex_unlock(&target_dir->d_inode->i_mutex); | ||
| 307 | if (!IS_ERR(nresult)) { | ||
| 308 | if (nresult->d_inode) { | ||
| 309 | dput(result); | ||
| 310 | result = nresult; | ||
| 311 | } else | ||
| 312 | dput(nresult); | ||
| 313 | } | ||
| 314 | } | ||
| 315 | dput(target_dir); | ||
| 316 | } | ||
| 317 | |||
| 318 | alias = find_acceptable_alias(result, acceptable, context); | ||
| 319 | if (alias) | ||
| 320 | return alias; | ||
| 321 | |||
| 322 | /* drat - I just cannot find anything acceptable */ | ||
| 323 | dput(result); | ||
| 324 | /* It might be justifiable to return ESTALE here, | ||
| 325 | * but the filehandle at-least looks reasonable good | ||
| 326 | * and it may just be a permission problem, so returning | ||
| 327 | * -EACCESS is safer | ||
| 328 | */ | ||
| 329 | return ERR_PTR(-EACCES); | ||
| 330 | |||
| 331 | err_result: | ||
| 332 | dput(result); | ||
| 333 | return ERR_PTR(err); | ||
| 334 | } | ||
| 335 | |||
| 336 | struct getdents_callback { | 213 | struct getdents_callback { |
| 337 | char *name; /* name that was found. It already points to a | 214 | char *name; /* name that was found. It already points to a |
| 338 | buffer NAME_MAX+1 is size */ | 215 | buffer NAME_MAX+1 is size */ |
| @@ -370,8 +247,8 @@ static int filldir_one(void * __buf, const char * name, int len, | |||
| 370 | * calls readdir on the parent until it finds an entry with | 247 | * calls readdir on the parent until it finds an entry with |
| 371 | * the same inode number as the child, and returns that. | 248 | * the same inode number as the child, and returns that. |
| 372 | */ | 249 | */ |
| 373 | static int get_name(struct dentry *dentry, char *name, | 250 | static int get_name(struct vfsmount *mnt, struct dentry *dentry, |
| 374 | struct dentry *child) | 251 | char *name, struct dentry *child) |
| 375 | { | 252 | { |
| 376 | struct inode *dir = dentry->d_inode; | 253 | struct inode *dir = dentry->d_inode; |
| 377 | int error; | 254 | int error; |
| @@ -387,7 +264,7 @@ static int get_name(struct dentry *dentry, char *name, | |||
| 387 | /* | 264 | /* |
| 388 | * Open the directory ... | 265 | * Open the directory ... |
| 389 | */ | 266 | */ |
| 390 | file = dentry_open(dget(dentry), NULL, O_RDONLY); | 267 | file = dentry_open(dget(dentry), mntget(mnt), O_RDONLY); |
| 391 | error = PTR_ERR(file); | 268 | error = PTR_ERR(file); |
| 392 | if (IS_ERR(file)) | 269 | if (IS_ERR(file)) |
| 393 | goto out; | 270 | goto out; |
| @@ -434,100 +311,177 @@ out: | |||
| 434 | * can be used to check that it is still valid. It places them in the | 311 | * can be used to check that it is still valid. It places them in the |
| 435 | * filehandle fragment where export_decode_fh expects to find them. | 312 | * filehandle fragment where export_decode_fh expects to find them. |
| 436 | */ | 313 | */ |
| 437 | static int export_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len, | 314 | static int export_encode_fh(struct dentry *dentry, struct fid *fid, |
| 438 | int connectable) | 315 | int *max_len, int connectable) |
| 439 | { | 316 | { |
| 440 | struct inode * inode = dentry->d_inode; | 317 | struct inode * inode = dentry->d_inode; |
| 441 | int len = *max_len; | 318 | int len = *max_len; |
| 442 | int type = 1; | 319 | int type = FILEID_INO32_GEN; |
| 443 | 320 | ||
| 444 | if (len < 2 || (connectable && len < 4)) | 321 | if (len < 2 || (connectable && len < 4)) |
| 445 | return 255; | 322 | return 255; |
| 446 | 323 | ||
| 447 | len = 2; | 324 | len = 2; |
| 448 | fh[0] = inode->i_ino; | 325 | fid->i32.ino = inode->i_ino; |
| 449 | fh[1] = inode->i_generation; | 326 | fid->i32.gen = inode->i_generation; |
| 450 | if (connectable && !S_ISDIR(inode->i_mode)) { | 327 | if (connectable && !S_ISDIR(inode->i_mode)) { |
| 451 | struct inode *parent; | 328 | struct inode *parent; |
| 452 | 329 | ||
| 453 | spin_lock(&dentry->d_lock); | 330 | spin_lock(&dentry->d_lock); |
| 454 | parent = dentry->d_parent->d_inode; | 331 | parent = dentry->d_parent->d_inode; |
| 455 | fh[2] = parent->i_ino; | 332 | fid->i32.parent_ino = parent->i_ino; |
| 456 | fh[3] = parent->i_generation; | 333 | fid->i32.parent_gen = parent->i_generation; |
| 457 | spin_unlock(&dentry->d_lock); | 334 | spin_unlock(&dentry->d_lock); |
| 458 | len = 4; | 335 | len = 4; |
| 459 | type = 2; | 336 | type = FILEID_INO32_GEN_PARENT; |
| 460 | } | 337 | } |
| 461 | *max_len = len; | 338 | *max_len = len; |
| 462 | return type; | 339 | return type; |
| 463 | } | 340 | } |
| 464 | 341 | ||
| 465 | 342 | int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, | |
| 466 | /** | ||
| 467 | * export_decode_fh - default export_operations->decode_fh function | ||
| 468 | * @sb: The superblock | ||
| 469 | * @fh: pointer to the file handle fragment | ||
| 470 | * @fh_len: length of file handle fragment | ||
| 471 | * @acceptable: function for testing acceptability of dentrys | ||
| 472 | * @context: context for @acceptable | ||
| 473 | * | ||
| 474 | * This is the default decode_fh() function. | ||
| 475 | * a fileid_type of 1 indicates that the filehandlefragment | ||
| 476 | * just contains an object identifier understood by get_dentry. | ||
| 477 | * a fileid_type of 2 says that there is also a directory | ||
| 478 | * identifier 8 bytes in to the filehandlefragement. | ||
| 479 | */ | ||
| 480 | static struct dentry *export_decode_fh(struct super_block *sb, __u32 *fh, int fh_len, | ||
| 481 | int fileid_type, | ||
| 482 | int (*acceptable)(void *context, struct dentry *de), | ||
| 483 | void *context) | ||
| 484 | { | ||
| 485 | __u32 parent[2]; | ||
| 486 | parent[0] = parent[1] = 0; | ||
| 487 | if (fh_len < 2 || fileid_type > 2) | ||
| 488 | return NULL; | ||
| 489 | if (fileid_type == 2) { | ||
| 490 | if (fh_len > 2) parent[0] = fh[2]; | ||
| 491 | if (fh_len > 3) parent[1] = fh[3]; | ||
| 492 | } | ||
| 493 | return find_exported_dentry(sb, fh, parent, | ||
| 494 | acceptable, context); | ||
| 495 | } | ||
| 496 | |||
| 497 | int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len, | ||
| 498 | int connectable) | 343 | int connectable) |
| 499 | { | 344 | { |
| 500 | struct export_operations *nop = dentry->d_sb->s_export_op; | 345 | const struct export_operations *nop = dentry->d_sb->s_export_op; |
| 501 | int error; | 346 | int error; |
| 502 | 347 | ||
| 503 | if (nop->encode_fh) | 348 | if (nop->encode_fh) |
| 504 | error = nop->encode_fh(dentry, fh, max_len, connectable); | 349 | error = nop->encode_fh(dentry, fid->raw, max_len, connectable); |
| 505 | else | 350 | else |
| 506 | error = export_encode_fh(dentry, fh, max_len, connectable); | 351 | error = export_encode_fh(dentry, fid, max_len, connectable); |
| 507 | 352 | ||
| 508 | return error; | 353 | return error; |
| 509 | } | 354 | } |
| 510 | EXPORT_SYMBOL_GPL(exportfs_encode_fh); | 355 | EXPORT_SYMBOL_GPL(exportfs_encode_fh); |
| 511 | 356 | ||
| 512 | struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh, int fh_len, | 357 | struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, |
| 513 | int fileid_type, int (*acceptable)(void *, struct dentry *), | 358 | int fh_len, int fileid_type, |
| 514 | void *context) | 359 | int (*acceptable)(void *, struct dentry *), void *context) |
| 515 | { | 360 | { |
| 516 | struct export_operations *nop = mnt->mnt_sb->s_export_op; | 361 | const struct export_operations *nop = mnt->mnt_sb->s_export_op; |
| 517 | struct dentry *result; | 362 | struct dentry *result, *alias; |
| 363 | int err; | ||
| 518 | 364 | ||
| 519 | if (nop->decode_fh) { | 365 | /* |
| 520 | result = nop->decode_fh(mnt->mnt_sb, fh, fh_len, fileid_type, | 366 | * Try to get any dentry for the given file handle from the filesystem. |
| 521 | acceptable, context); | 367 | */ |
| 368 | result = nop->fh_to_dentry(mnt->mnt_sb, fid, fh_len, fileid_type); | ||
| 369 | if (!result) | ||
| 370 | result = ERR_PTR(-ESTALE); | ||
| 371 | if (IS_ERR(result)) | ||
| 372 | return result; | ||
| 373 | |||
| 374 | if (S_ISDIR(result->d_inode->i_mode)) { | ||
| 375 | /* | ||
| 376 | * This request is for a directory. | ||
| 377 | * | ||
| 378 | * On the positive side there is only one dentry for each | ||
| 379 | * directory inode. On the negative side this implies that we | ||
| 380 | * to ensure our dentry is connected all the way up to the | ||
| 381 | * filesystem root. | ||
| 382 | */ | ||
| 383 | if (result->d_flags & DCACHE_DISCONNECTED) { | ||
| 384 | err = reconnect_path(mnt, result); | ||
| 385 | if (err) | ||
| 386 | goto err_result; | ||
| 387 | } | ||
| 388 | |||
| 389 | if (!acceptable(context, result)) { | ||
| 390 | err = -EACCES; | ||
| 391 | goto err_result; | ||
| 392 | } | ||
| 393 | |||
| 394 | return result; | ||
| 522 | } else { | 395 | } else { |
| 523 | result = export_decode_fh(mnt->mnt_sb, fh, fh_len, fileid_type, | 396 | /* |
| 524 | acceptable, context); | 397 | * It's not a directory. Life is a little more complicated. |
| 398 | */ | ||
| 399 | struct dentry *target_dir, *nresult; | ||
| 400 | char nbuf[NAME_MAX+1]; | ||
| 401 | |||
| 402 | /* | ||
| 403 | * See if either the dentry we just got from the filesystem | ||
| 404 | * or any alias for it is acceptable. This is always true | ||
| 405 | * if this filesystem is exported without the subtreecheck | ||
| 406 | * option. If the filesystem is exported with the subtree | ||
| 407 | * check option there's a fair chance we need to look at | ||
| 408 | * the parent directory in the file handle and make sure | ||
| 409 | * it's connected to the filesystem root. | ||
| 410 | */ | ||
| 411 | alias = find_acceptable_alias(result, acceptable, context); | ||
| 412 | if (alias) | ||
| 413 | return alias; | ||
| 414 | |||
| 415 | /* | ||
| 416 | * Try to extract a dentry for the parent directory from the | ||
| 417 | * file handle. If this fails we'll have to give up. | ||
| 418 | */ | ||
| 419 | err = -ESTALE; | ||
| 420 | if (!nop->fh_to_parent) | ||
| 421 | goto err_result; | ||
| 422 | |||
| 423 | target_dir = nop->fh_to_parent(mnt->mnt_sb, fid, | ||
| 424 | fh_len, fileid_type); | ||
| 425 | if (!target_dir) | ||
| 426 | goto err_result; | ||
| 427 | err = PTR_ERR(target_dir); | ||
| 428 | if (IS_ERR(target_dir)) | ||
| 429 | goto err_result; | ||
| 430 | |||
| 431 | /* | ||
| 432 | * And as usual we need to make sure the parent directory is | ||
| 433 | * connected to the filesystem root. The VFS really doesn't | ||
| 434 | * like disconnected directories.. | ||
| 435 | */ | ||
| 436 | err = reconnect_path(mnt, target_dir); | ||
| 437 | if (err) { | ||
| 438 | dput(target_dir); | ||
| 439 | goto err_result; | ||
| 440 | } | ||
| 441 | |||
| 442 | /* | ||
| 443 | * Now that we've got both a well-connected parent and a | ||
| 444 | * dentry for the inode we're after, make sure that our | ||
| 445 | * inode is actually connected to the parent. | ||
| 446 | */ | ||
| 447 | err = exportfs_get_name(mnt, target_dir, nbuf, result); | ||
| 448 | if (!err) { | ||
| 449 | mutex_lock(&target_dir->d_inode->i_mutex); | ||
| 450 | nresult = lookup_one_len(nbuf, target_dir, | ||
| 451 | strlen(nbuf)); | ||
| 452 | mutex_unlock(&target_dir->d_inode->i_mutex); | ||
| 453 | if (!IS_ERR(nresult)) { | ||
| 454 | if (nresult->d_inode) { | ||
| 455 | dput(result); | ||
| 456 | result = nresult; | ||
| 457 | } else | ||
| 458 | dput(nresult); | ||
| 459 | } | ||
| 460 | } | ||
| 461 | |||
| 462 | /* | ||
| 463 | * At this point we are done with the parent, but it's pinned | ||
| 464 | * by the child dentry anyway. | ||
| 465 | */ | ||
| 466 | dput(target_dir); | ||
| 467 | |||
| 468 | /* | ||
| 469 | * And finally make sure the dentry is actually acceptable | ||
| 470 | * to NFSD. | ||
| 471 | */ | ||
| 472 | alias = find_acceptable_alias(result, acceptable, context); | ||
| 473 | if (!alias) { | ||
| 474 | err = -EACCES; | ||
| 475 | goto err_result; | ||
| 476 | } | ||
| 477 | |||
| 478 | return alias; | ||
| 525 | } | 479 | } |
| 526 | 480 | ||
| 527 | return result; | 481 | err_result: |
| 482 | dput(result); | ||
| 483 | return ERR_PTR(err); | ||
| 528 | } | 484 | } |
| 529 | EXPORT_SYMBOL_GPL(exportfs_decode_fh); | 485 | EXPORT_SYMBOL_GPL(exportfs_decode_fh); |
| 530 | 486 | ||
| 531 | EXPORT_SYMBOL(find_exported_dentry); | ||
| 532 | |||
| 533 | MODULE_LICENSE("GPL"); | 487 | MODULE_LICENSE("GPL"); |
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index 05d9342bb64e..d868e26c15eb 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c | |||
| @@ -28,6 +28,24 @@ | |||
| 28 | 28 | ||
| 29 | typedef struct ext2_dir_entry_2 ext2_dirent; | 29 | typedef struct ext2_dir_entry_2 ext2_dirent; |
| 30 | 30 | ||
| 31 | static inline unsigned ext2_rec_len_from_disk(__le16 dlen) | ||
| 32 | { | ||
| 33 | unsigned len = le16_to_cpu(dlen); | ||
| 34 | |||
| 35 | if (len == EXT2_MAX_REC_LEN) | ||
| 36 | return 1 << 16; | ||
| 37 | return len; | ||
| 38 | } | ||
| 39 | |||
| 40 | static inline __le16 ext2_rec_len_to_disk(unsigned len) | ||
| 41 | { | ||
| 42 | if (len == (1 << 16)) | ||
| 43 | return cpu_to_le16(EXT2_MAX_REC_LEN); | ||
| 44 | else if (len > (1 << 16)) | ||
| 45 | BUG(); | ||
| 46 | return cpu_to_le16(len); | ||
| 47 | } | ||
| 48 | |||
| 31 | /* | 49 | /* |
| 32 | * ext2 uses block-sized chunks. Arguably, sector-sized ones would be | 50 | * ext2 uses block-sized chunks. Arguably, sector-sized ones would be |
| 33 | * more robust, but we have what we have | 51 | * more robust, but we have what we have |
| @@ -106,7 +124,7 @@ static void ext2_check_page(struct page *page) | |||
| 106 | } | 124 | } |
| 107 | for (offs = 0; offs <= limit - EXT2_DIR_REC_LEN(1); offs += rec_len) { | 125 | for (offs = 0; offs <= limit - EXT2_DIR_REC_LEN(1); offs += rec_len) { |
| 108 | p = (ext2_dirent *)(kaddr + offs); | 126 | p = (ext2_dirent *)(kaddr + offs); |
| 109 | rec_len = le16_to_cpu(p->rec_len); | 127 | rec_len = ext2_rec_len_from_disk(p->rec_len); |
| 110 | 128 | ||
| 111 | if (rec_len < EXT2_DIR_REC_LEN(1)) | 129 | if (rec_len < EXT2_DIR_REC_LEN(1)) |
| 112 | goto Eshort; | 130 | goto Eshort; |
| @@ -204,7 +222,8 @@ static inline int ext2_match (int len, const char * const name, | |||
| 204 | */ | 222 | */ |
| 205 | static inline ext2_dirent *ext2_next_entry(ext2_dirent *p) | 223 | static inline ext2_dirent *ext2_next_entry(ext2_dirent *p) |
| 206 | { | 224 | { |
| 207 | return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len)); | 225 | return (ext2_dirent *)((char *)p + |
| 226 | ext2_rec_len_from_disk(p->rec_len)); | ||
| 208 | } | 227 | } |
| 209 | 228 | ||
| 210 | static inline unsigned | 229 | static inline unsigned |
| @@ -316,7 +335,7 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir) | |||
| 316 | return 0; | 335 | return 0; |
| 317 | } | 336 | } |
| 318 | } | 337 | } |
| 319 | filp->f_pos += le16_to_cpu(de->rec_len); | 338 | filp->f_pos += ext2_rec_len_from_disk(de->rec_len); |
| 320 | } | 339 | } |
| 321 | ext2_put_page(page); | 340 | ext2_put_page(page); |
| 322 | } | 341 | } |
| @@ -425,7 +444,7 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de, | |||
| 425 | { | 444 | { |
| 426 | loff_t pos = page_offset(page) + | 445 | loff_t pos = page_offset(page) + |
| 427 | (char *) de - (char *) page_address(page); | 446 | (char *) de - (char *) page_address(page); |
| 428 | unsigned len = le16_to_cpu(de->rec_len); | 447 | unsigned len = ext2_rec_len_from_disk(de->rec_len); |
| 429 | int err; | 448 | int err; |
| 430 | 449 | ||
| 431 | lock_page(page); | 450 | lock_page(page); |
| @@ -482,7 +501,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode) | |||
| 482 | /* We hit i_size */ | 501 | /* We hit i_size */ |
| 483 | name_len = 0; | 502 | name_len = 0; |
| 484 | rec_len = chunk_size; | 503 | rec_len = chunk_size; |
| 485 | de->rec_len = cpu_to_le16(chunk_size); | 504 | de->rec_len = ext2_rec_len_to_disk(chunk_size); |
| 486 | de->inode = 0; | 505 | de->inode = 0; |
| 487 | goto got_it; | 506 | goto got_it; |
| 488 | } | 507 | } |
| @@ -496,7 +515,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode) | |||
| 496 | if (ext2_match (namelen, name, de)) | 515 | if (ext2_match (namelen, name, de)) |
| 497 | goto out_unlock; | 516 | goto out_unlock; |
| 498 | name_len = EXT2_DIR_REC_LEN(de->name_len); | 517 | name_len = EXT2_DIR_REC_LEN(de->name_len); |
| 499 | rec_len = le16_to_cpu(de->rec_len); | 518 | rec_len = ext2_rec_len_from_disk(de->rec_len); |
| 500 | if (!de->inode && rec_len >= reclen) | 519 | if (!de->inode && rec_len >= reclen) |
| 501 | goto got_it; | 520 | goto got_it; |
| 502 | if (rec_len >= name_len + reclen) | 521 | if (rec_len >= name_len + reclen) |
| @@ -518,8 +537,8 @@ got_it: | |||
| 518 | goto out_unlock; | 537 | goto out_unlock; |
| 519 | if (de->inode) { | 538 | if (de->inode) { |
| 520 | ext2_dirent *de1 = (ext2_dirent *) ((char *) de + name_len); | 539 | ext2_dirent *de1 = (ext2_dirent *) ((char *) de + name_len); |
| 521 | de1->rec_len = cpu_to_le16(rec_len - name_len); | 540 | de1->rec_len = ext2_rec_len_to_disk(rec_len - name_len); |
| 522 | de->rec_len = cpu_to_le16(name_len); | 541 | de->rec_len = ext2_rec_len_to_disk(name_len); |
| 523 | de = de1; | 542 | de = de1; |
| 524 | } | 543 | } |
| 525 | de->name_len = namelen; | 544 | de->name_len = namelen; |
| @@ -550,7 +569,8 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) | |||
| 550 | struct inode *inode = mapping->host; | 569 | struct inode *inode = mapping->host; |
| 551 | char *kaddr = page_address(page); | 570 | char *kaddr = page_address(page); |
| 552 | unsigned from = ((char*)dir - kaddr) & ~(ext2_chunk_size(inode)-1); | 571 | unsigned from = ((char*)dir - kaddr) & ~(ext2_chunk_size(inode)-1); |
| 553 | unsigned to = ((char*)dir - kaddr) + le16_to_cpu(dir->rec_len); | 572 | unsigned to = ((char *)dir - kaddr) + |
| 573 | ext2_rec_len_from_disk(dir->rec_len); | ||
| 554 | loff_t pos; | 574 | loff_t pos; |
| 555 | ext2_dirent * pde = NULL; | 575 | ext2_dirent * pde = NULL; |
| 556 | ext2_dirent * de = (ext2_dirent *) (kaddr + from); | 576 | ext2_dirent * de = (ext2_dirent *) (kaddr + from); |
| @@ -574,7 +594,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) | |||
| 574 | &page, NULL); | 594 | &page, NULL); |
| 575 | BUG_ON(err); | 595 | BUG_ON(err); |
| 576 | if (pde) | 596 | if (pde) |
| 577 | pde->rec_len = cpu_to_le16(to - from); | 597 | pde->rec_len = ext2_rec_len_to_disk(to - from); |
| 578 | dir->inode = 0; | 598 | dir->inode = 0; |
| 579 | err = ext2_commit_chunk(page, pos, to - from); | 599 | err = ext2_commit_chunk(page, pos, to - from); |
| 580 | inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC; | 600 | inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC; |
| @@ -610,14 +630,14 @@ int ext2_make_empty(struct inode *inode, struct inode *parent) | |||
| 610 | memset(kaddr, 0, chunk_size); | 630 | memset(kaddr, 0, chunk_size); |
| 611 | de = (struct ext2_dir_entry_2 *)kaddr; | 631 | de = (struct ext2_dir_entry_2 *)kaddr; |
| 612 | de->name_len = 1; | 632 | de->name_len = 1; |
| 613 | de->rec_len = cpu_to_le16(EXT2_DIR_REC_LEN(1)); | 633 | de->rec_len = ext2_rec_len_to_disk(EXT2_DIR_REC_LEN(1)); |
| 614 | memcpy (de->name, ".\0\0", 4); | 634 | memcpy (de->name, ".\0\0", 4); |
| 615 | de->inode = cpu_to_le32(inode->i_ino); | 635 | de->inode = cpu_to_le32(inode->i_ino); |
| 616 | ext2_set_de_type (de, inode); | 636 | ext2_set_de_type (de, inode); |
| 617 | 637 | ||
| 618 | de = (struct ext2_dir_entry_2 *)(kaddr + EXT2_DIR_REC_LEN(1)); | 638 | de = (struct ext2_dir_entry_2 *)(kaddr + EXT2_DIR_REC_LEN(1)); |
| 619 | de->name_len = 2; | 639 | de->name_len = 2; |
| 620 | de->rec_len = cpu_to_le16(chunk_size - EXT2_DIR_REC_LEN(1)); | 640 | de->rec_len = ext2_rec_len_to_disk(chunk_size - EXT2_DIR_REC_LEN(1)); |
| 621 | de->inode = cpu_to_le32(parent->i_ino); | 641 | de->inode = cpu_to_le32(parent->i_ino); |
| 622 | memcpy (de->name, "..\0", 4); | 642 | memcpy (de->name, "..\0", 4); |
| 623 | ext2_set_de_type (de, inode); | 643 | ext2_set_de_type (de, inode); |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 77bd5f9262f9..154e25f13d77 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
| @@ -311,13 +311,10 @@ static const struct super_operations ext2_sops = { | |||
| 311 | #endif | 311 | #endif |
| 312 | }; | 312 | }; |
| 313 | 313 | ||
| 314 | static struct dentry *ext2_get_dentry(struct super_block *sb, void *vobjp) | 314 | static struct inode *ext2_nfs_get_inode(struct super_block *sb, |
| 315 | u64 ino, u32 generation) | ||
| 315 | { | 316 | { |
| 316 | __u32 *objp = vobjp; | ||
| 317 | unsigned long ino = objp[0]; | ||
| 318 | __u32 generation = objp[1]; | ||
| 319 | struct inode *inode; | 317 | struct inode *inode; |
| 320 | struct dentry *result; | ||
| 321 | 318 | ||
| 322 | if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO) | 319 | if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO) |
| 323 | return ERR_PTR(-ESTALE); | 320 | return ERR_PTR(-ESTALE); |
| @@ -338,15 +335,21 @@ static struct dentry *ext2_get_dentry(struct super_block *sb, void *vobjp) | |||
| 338 | iput(inode); | 335 | iput(inode); |
| 339 | return ERR_PTR(-ESTALE); | 336 | return ERR_PTR(-ESTALE); |
| 340 | } | 337 | } |
| 341 | /* now to find a dentry. | 338 | return inode; |
| 342 | * If possible, get a well-connected one | 339 | } |
| 343 | */ | 340 | |
| 344 | result = d_alloc_anon(inode); | 341 | static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 345 | if (!result) { | 342 | int fh_len, int fh_type) |
| 346 | iput(inode); | 343 | { |
| 347 | return ERR_PTR(-ENOMEM); | 344 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, |
| 348 | } | 345 | ext2_nfs_get_inode); |
| 349 | return result; | 346 | } |
| 347 | |||
| 348 | static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 349 | int fh_len, int fh_type) | ||
| 350 | { | ||
| 351 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, | ||
| 352 | ext2_nfs_get_inode); | ||
| 350 | } | 353 | } |
| 351 | 354 | ||
| 352 | /* Yes, most of these are left as NULL!! | 355 | /* Yes, most of these are left as NULL!! |
| @@ -354,9 +357,10 @@ static struct dentry *ext2_get_dentry(struct super_block *sb, void *vobjp) | |||
| 354 | * systems, but can be improved upon. | 357 | * systems, but can be improved upon. |
| 355 | * Currently only get_parent is required. | 358 | * Currently only get_parent is required. |
| 356 | */ | 359 | */ |
| 357 | static struct export_operations ext2_export_ops = { | 360 | static const struct export_operations ext2_export_ops = { |
| 361 | .fh_to_dentry = ext2_fh_to_dentry, | ||
| 362 | .fh_to_parent = ext2_fh_to_parent, | ||
| 358 | .get_parent = ext2_get_parent, | 363 | .get_parent = ext2_get_parent, |
| 359 | .get_dentry = ext2_get_dentry, | ||
| 360 | }; | 364 | }; |
| 361 | 365 | ||
| 362 | static unsigned long get_sb_block(void **data) | 366 | static unsigned long get_sb_block(void **data) |
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 81868c0bc40e..de55da9e28ba 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
| @@ -631,13 +631,10 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 631 | } | 631 | } |
| 632 | 632 | ||
| 633 | 633 | ||
| 634 | static struct dentry *ext3_get_dentry(struct super_block *sb, void *vobjp) | 634 | static struct inode *ext3_nfs_get_inode(struct super_block *sb, |
| 635 | u64 ino, u32 generation) | ||
| 635 | { | 636 | { |
| 636 | __u32 *objp = vobjp; | ||
| 637 | unsigned long ino = objp[0]; | ||
| 638 | __u32 generation = objp[1]; | ||
| 639 | struct inode *inode; | 637 | struct inode *inode; |
| 640 | struct dentry *result; | ||
| 641 | 638 | ||
| 642 | if (ino < EXT3_FIRST_INO(sb) && ino != EXT3_ROOT_INO) | 639 | if (ino < EXT3_FIRST_INO(sb) && ino != EXT3_ROOT_INO) |
| 643 | return ERR_PTR(-ESTALE); | 640 | return ERR_PTR(-ESTALE); |
| @@ -660,15 +657,22 @@ static struct dentry *ext3_get_dentry(struct super_block *sb, void *vobjp) | |||
| 660 | iput(inode); | 657 | iput(inode); |
| 661 | return ERR_PTR(-ESTALE); | 658 | return ERR_PTR(-ESTALE); |
| 662 | } | 659 | } |
| 663 | /* now to find a dentry. | 660 | |
| 664 | * If possible, get a well-connected one | 661 | return inode; |
| 665 | */ | 662 | } |
| 666 | result = d_alloc_anon(inode); | 663 | |
| 667 | if (!result) { | 664 | static struct dentry *ext3_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 668 | iput(inode); | 665 | int fh_len, int fh_type) |
| 669 | return ERR_PTR(-ENOMEM); | 666 | { |
| 670 | } | 667 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, |
| 671 | return result; | 668 | ext3_nfs_get_inode); |
| 669 | } | ||
| 670 | |||
| 671 | static struct dentry *ext3_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 672 | int fh_len, int fh_type) | ||
| 673 | { | ||
| 674 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, | ||
| 675 | ext3_nfs_get_inode); | ||
| 672 | } | 676 | } |
| 673 | 677 | ||
| 674 | #ifdef CONFIG_QUOTA | 678 | #ifdef CONFIG_QUOTA |
| @@ -737,9 +741,10 @@ static const struct super_operations ext3_sops = { | |||
| 737 | #endif | 741 | #endif |
| 738 | }; | 742 | }; |
| 739 | 743 | ||
| 740 | static struct export_operations ext3_export_ops = { | 744 | static const struct export_operations ext3_export_ops = { |
| 745 | .fh_to_dentry = ext3_fh_to_dentry, | ||
| 746 | .fh_to_parent = ext3_fh_to_parent, | ||
| 741 | .get_parent = ext3_get_parent, | 747 | .get_parent = ext3_get_parent, |
| 742 | .get_dentry = ext3_get_dentry, | ||
| 743 | }; | 748 | }; |
| 744 | 749 | ||
| 745 | enum { | 750 | enum { |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index b11e9e2bcd01..8031dc0e24e5 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -686,13 +686,10 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 686 | } | 686 | } |
| 687 | 687 | ||
| 688 | 688 | ||
| 689 | static struct dentry *ext4_get_dentry(struct super_block *sb, void *vobjp) | 689 | static struct inode *ext4_nfs_get_inode(struct super_block *sb, |
| 690 | u64 ino, u32 generation) | ||
| 690 | { | 691 | { |
| 691 | __u32 *objp = vobjp; | ||
| 692 | unsigned long ino = objp[0]; | ||
| 693 | __u32 generation = objp[1]; | ||
| 694 | struct inode *inode; | 692 | struct inode *inode; |
| 695 | struct dentry *result; | ||
| 696 | 693 | ||
| 697 | if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO) | 694 | if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO) |
| 698 | return ERR_PTR(-ESTALE); | 695 | return ERR_PTR(-ESTALE); |
| @@ -715,15 +712,22 @@ static struct dentry *ext4_get_dentry(struct super_block *sb, void *vobjp) | |||
| 715 | iput(inode); | 712 | iput(inode); |
| 716 | return ERR_PTR(-ESTALE); | 713 | return ERR_PTR(-ESTALE); |
| 717 | } | 714 | } |
| 718 | /* now to find a dentry. | 715 | |
| 719 | * If possible, get a well-connected one | 716 | return inode; |
| 720 | */ | 717 | } |
| 721 | result = d_alloc_anon(inode); | 718 | |
| 722 | if (!result) { | 719 | static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 723 | iput(inode); | 720 | int fh_len, int fh_type) |
| 724 | return ERR_PTR(-ENOMEM); | 721 | { |
| 725 | } | 722 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, |
| 726 | return result; | 723 | ext4_nfs_get_inode); |
| 724 | } | ||
| 725 | |||
| 726 | static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 727 | int fh_len, int fh_type) | ||
| 728 | { | ||
| 729 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, | ||
| 730 | ext4_nfs_get_inode); | ||
| 727 | } | 731 | } |
| 728 | 732 | ||
| 729 | #ifdef CONFIG_QUOTA | 733 | #ifdef CONFIG_QUOTA |
| @@ -792,9 +796,10 @@ static const struct super_operations ext4_sops = { | |||
| 792 | #endif | 796 | #endif |
| 793 | }; | 797 | }; |
| 794 | 798 | ||
| 795 | static struct export_operations ext4_export_ops = { | 799 | static const struct export_operations ext4_export_ops = { |
| 800 | .fh_to_dentry = ext4_fh_to_dentry, | ||
| 801 | .fh_to_parent = ext4_fh_to_parent, | ||
| 796 | .get_parent = ext4_get_parent, | 802 | .get_parent = ext4_get_parent, |
| 797 | .get_dentry = ext4_get_dentry, | ||
| 798 | }; | 803 | }; |
| 799 | 804 | ||
| 800 | enum { | 805 | enum { |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index c0c5e9c55b58..920a576e1c25 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
| @@ -653,24 +653,15 @@ static const struct super_operations fat_sops = { | |||
| 653 | * of i_logstart is used to store the directory entry offset. | 653 | * of i_logstart is used to store the directory entry offset. |
| 654 | */ | 654 | */ |
| 655 | 655 | ||
| 656 | static struct dentry * | 656 | static struct dentry *fat_fh_to_dentry(struct super_block *sb, |
| 657 | fat_decode_fh(struct super_block *sb, __u32 *fh, int len, int fhtype, | 657 | struct fid *fid, int fh_len, int fh_type) |
| 658 | int (*acceptable)(void *context, struct dentry *de), | ||
| 659 | void *context) | ||
| 660 | { | ||
| 661 | if (fhtype != 3) | ||
| 662 | return ERR_PTR(-ESTALE); | ||
| 663 | if (len < 5) | ||
| 664 | return ERR_PTR(-ESTALE); | ||
| 665 | |||
| 666 | return sb->s_export_op->find_exported_dentry(sb, fh, NULL, acceptable, context); | ||
| 667 | } | ||
| 668 | |||
| 669 | static struct dentry *fat_get_dentry(struct super_block *sb, void *inump) | ||
| 670 | { | 658 | { |
| 671 | struct inode *inode = NULL; | 659 | struct inode *inode = NULL; |
| 672 | struct dentry *result; | 660 | struct dentry *result; |
| 673 | __u32 *fh = inump; | 661 | u32 *fh = fid->raw; |
| 662 | |||
| 663 | if (fh_len < 5 || fh_type != 3) | ||
| 664 | return NULL; | ||
| 674 | 665 | ||
| 675 | inode = iget(sb, fh[0]); | 666 | inode = iget(sb, fh[0]); |
| 676 | if (!inode || is_bad_inode(inode) || inode->i_generation != fh[1]) { | 667 | if (!inode || is_bad_inode(inode) || inode->i_generation != fh[1]) { |
| @@ -783,10 +774,9 @@ out: | |||
| 783 | return parent; | 774 | return parent; |
| 784 | } | 775 | } |
| 785 | 776 | ||
| 786 | static struct export_operations fat_export_ops = { | 777 | static const struct export_operations fat_export_ops = { |
| 787 | .decode_fh = fat_decode_fh, | ||
| 788 | .encode_fh = fat_encode_fh, | 778 | .encode_fh = fat_encode_fh, |
| 789 | .get_dentry = fat_get_dentry, | 779 | .fh_to_dentry = fat_fh_to_dentry, |
| 790 | .get_parent = fat_get_parent, | 780 | .get_parent = fat_get_parent, |
| 791 | }; | 781 | }; |
| 792 | 782 | ||
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index e2d1347796a9..b9da62348a87 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c | |||
| @@ -31,40 +31,6 @@ | |||
| 31 | #define GFS2_LARGE_FH_SIZE 8 | 31 | #define GFS2_LARGE_FH_SIZE 8 |
| 32 | #define GFS2_OLD_FH_SIZE 10 | 32 | #define GFS2_OLD_FH_SIZE 10 |
| 33 | 33 | ||
| 34 | static struct dentry *gfs2_decode_fh(struct super_block *sb, | ||
| 35 | __u32 *p, | ||
| 36 | int fh_len, | ||
| 37 | int fh_type, | ||
| 38 | int (*acceptable)(void *context, | ||
| 39 | struct dentry *dentry), | ||
| 40 | void *context) | ||
| 41 | { | ||
| 42 | __be32 *fh = (__force __be32 *)p; | ||
| 43 | struct gfs2_inum_host inum, parent; | ||
| 44 | |||
| 45 | memset(&parent, 0, sizeof(struct gfs2_inum)); | ||
| 46 | |||
| 47 | switch (fh_len) { | ||
| 48 | case GFS2_LARGE_FH_SIZE: | ||
| 49 | case GFS2_OLD_FH_SIZE: | ||
| 50 | parent.no_formal_ino = ((u64)be32_to_cpu(fh[4])) << 32; | ||
| 51 | parent.no_formal_ino |= be32_to_cpu(fh[5]); | ||
| 52 | parent.no_addr = ((u64)be32_to_cpu(fh[6])) << 32; | ||
| 53 | parent.no_addr |= be32_to_cpu(fh[7]); | ||
| 54 | case GFS2_SMALL_FH_SIZE: | ||
| 55 | inum.no_formal_ino = ((u64)be32_to_cpu(fh[0])) << 32; | ||
| 56 | inum.no_formal_ino |= be32_to_cpu(fh[1]); | ||
| 57 | inum.no_addr = ((u64)be32_to_cpu(fh[2])) << 32; | ||
| 58 | inum.no_addr |= be32_to_cpu(fh[3]); | ||
| 59 | break; | ||
| 60 | default: | ||
| 61 | return NULL; | ||
| 62 | } | ||
| 63 | |||
| 64 | return gfs2_export_ops.find_exported_dentry(sb, &inum, &parent, | ||
| 65 | acceptable, context); | ||
| 66 | } | ||
| 67 | |||
| 68 | static int gfs2_encode_fh(struct dentry *dentry, __u32 *p, int *len, | 34 | static int gfs2_encode_fh(struct dentry *dentry, __u32 *p, int *len, |
| 69 | int connectable) | 35 | int connectable) |
| 70 | { | 36 | { |
| @@ -189,10 +155,10 @@ static struct dentry *gfs2_get_parent(struct dentry *child) | |||
| 189 | return dentry; | 155 | return dentry; |
| 190 | } | 156 | } |
| 191 | 157 | ||
| 192 | static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_obj) | 158 | static struct dentry *gfs2_get_dentry(struct super_block *sb, |
| 159 | struct gfs2_inum_host *inum) | ||
| 193 | { | 160 | { |
| 194 | struct gfs2_sbd *sdp = sb->s_fs_info; | 161 | struct gfs2_sbd *sdp = sb->s_fs_info; |
| 195 | struct gfs2_inum_host *inum = inum_obj; | ||
| 196 | struct gfs2_holder i_gh, ri_gh, rgd_gh; | 162 | struct gfs2_holder i_gh, ri_gh, rgd_gh; |
| 197 | struct gfs2_rgrpd *rgd; | 163 | struct gfs2_rgrpd *rgd; |
| 198 | struct inode *inode; | 164 | struct inode *inode; |
| @@ -289,11 +255,50 @@ fail: | |||
| 289 | return ERR_PTR(error); | 255 | return ERR_PTR(error); |
| 290 | } | 256 | } |
| 291 | 257 | ||
| 292 | struct export_operations gfs2_export_ops = { | 258 | static struct dentry *gfs2_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 293 | .decode_fh = gfs2_decode_fh, | 259 | int fh_len, int fh_type) |
| 260 | { | ||
| 261 | struct gfs2_inum_host this; | ||
| 262 | __be32 *fh = (__force __be32 *)fid->raw; | ||
| 263 | |||
| 264 | switch (fh_type) { | ||
| 265 | case GFS2_SMALL_FH_SIZE: | ||
| 266 | case GFS2_LARGE_FH_SIZE: | ||
| 267 | case GFS2_OLD_FH_SIZE: | ||
| 268 | this.no_formal_ino = ((u64)be32_to_cpu(fh[0])) << 32; | ||
| 269 | this.no_formal_ino |= be32_to_cpu(fh[1]); | ||
| 270 | this.no_addr = ((u64)be32_to_cpu(fh[2])) << 32; | ||
| 271 | this.no_addr |= be32_to_cpu(fh[3]); | ||
| 272 | return gfs2_get_dentry(sb, &this); | ||
| 273 | default: | ||
| 274 | return NULL; | ||
| 275 | } | ||
| 276 | } | ||
| 277 | |||
| 278 | static struct dentry *gfs2_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 279 | int fh_len, int fh_type) | ||
| 280 | { | ||
| 281 | struct gfs2_inum_host parent; | ||
| 282 | __be32 *fh = (__force __be32 *)fid->raw; | ||
| 283 | |||
| 284 | switch (fh_type) { | ||
| 285 | case GFS2_LARGE_FH_SIZE: | ||
| 286 | case GFS2_OLD_FH_SIZE: | ||
| 287 | parent.no_formal_ino = ((u64)be32_to_cpu(fh[4])) << 32; | ||
| 288 | parent.no_formal_ino |= be32_to_cpu(fh[5]); | ||
| 289 | parent.no_addr = ((u64)be32_to_cpu(fh[6])) << 32; | ||
| 290 | parent.no_addr |= be32_to_cpu(fh[7]); | ||
| 291 | return gfs2_get_dentry(sb, &parent); | ||
| 292 | default: | ||
| 293 | return NULL; | ||
| 294 | } | ||
| 295 | } | ||
| 296 | |||
| 297 | const struct export_operations gfs2_export_ops = { | ||
| 294 | .encode_fh = gfs2_encode_fh, | 298 | .encode_fh = gfs2_encode_fh, |
| 299 | .fh_to_dentry = gfs2_fh_to_dentry, | ||
| 300 | .fh_to_parent = gfs2_fh_to_parent, | ||
| 295 | .get_name = gfs2_get_name, | 301 | .get_name = gfs2_get_name, |
| 296 | .get_parent = gfs2_get_parent, | 302 | .get_parent = gfs2_get_parent, |
| 297 | .get_dentry = gfs2_get_dentry, | ||
| 298 | }; | 303 | }; |
| 299 | 304 | ||
diff --git a/fs/gfs2/ops_fstype.h b/fs/gfs2/ops_fstype.h index 407029b3b2b3..da8490511836 100644 --- a/fs/gfs2/ops_fstype.h +++ b/fs/gfs2/ops_fstype.h | |||
| @@ -14,6 +14,6 @@ | |||
| 14 | 14 | ||
| 15 | extern struct file_system_type gfs2_fs_type; | 15 | extern struct file_system_type gfs2_fs_type; |
| 16 | extern struct file_system_type gfs2meta_fs_type; | 16 | extern struct file_system_type gfs2meta_fs_type; |
| 17 | extern struct export_operations gfs2_export_ops; | 17 | extern const struct export_operations gfs2_export_ops; |
| 18 | 18 | ||
| 19 | #endif /* __OPS_FSTYPE_DOT_H__ */ | 19 | #endif /* __OPS_FSTYPE_DOT_H__ */ |
diff --git a/fs/isofs/export.c b/fs/isofs/export.c index 4af856a7fda7..29f9753ae5e5 100644 --- a/fs/isofs/export.c +++ b/fs/isofs/export.c | |||
| @@ -42,16 +42,6 @@ isofs_export_iget(struct super_block *sb, | |||
| 42 | return result; | 42 | return result; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | static struct dentry * | ||
| 46 | isofs_export_get_dentry(struct super_block *sb, void *vobjp) | ||
| 47 | { | ||
| 48 | __u32 *objp = vobjp; | ||
| 49 | unsigned long block = objp[0]; | ||
| 50 | unsigned long offset = objp[1]; | ||
| 51 | __u32 generation = objp[2]; | ||
| 52 | return isofs_export_iget(sb, block, offset, generation); | ||
| 53 | } | ||
| 54 | |||
| 55 | /* This function is surprisingly simple. The trick is understanding | 45 | /* This function is surprisingly simple. The trick is understanding |
| 56 | * that "child" is always a directory. So, to find its parent, you | 46 | * that "child" is always a directory. So, to find its parent, you |
| 57 | * simply need to find its ".." entry, normalize its block and offset, | 47 | * simply need to find its ".." entry, normalize its block and offset, |
| @@ -182,43 +172,44 @@ isofs_export_encode_fh(struct dentry *dentry, | |||
| 182 | return type; | 172 | return type; |
| 183 | } | 173 | } |
| 184 | 174 | ||
| 175 | struct isofs_fid { | ||
| 176 | u32 block; | ||
| 177 | u16 offset; | ||
| 178 | u16 parent_offset; | ||
| 179 | u32 generation; | ||
| 180 | u32 parent_block; | ||
| 181 | u32 parent_generation; | ||
| 182 | }; | ||
| 185 | 183 | ||
| 186 | static struct dentry * | 184 | static struct dentry *isofs_fh_to_dentry(struct super_block *sb, |
| 187 | isofs_export_decode_fh(struct super_block *sb, | 185 | struct fid *fid, int fh_len, int fh_type) |
| 188 | __u32 *fh32, | ||
| 189 | int fh_len, | ||
| 190 | int fileid_type, | ||
| 191 | int (*acceptable)(void *context, struct dentry *de), | ||
| 192 | void *context) | ||
| 193 | { | 186 | { |
| 194 | __u16 *fh16 = (__u16*)fh32; | 187 | struct isofs_fid *ifid = (struct isofs_fid *)fid; |
| 195 | __u32 child[3]; /* The child is what triggered all this. */ | ||
| 196 | __u32 parent[3]; /* The parent is just along for the ride. */ | ||
| 197 | 188 | ||
| 198 | if (fh_len < 3 || fileid_type > 2) | 189 | if (fh_len < 3 || fh_type > 2) |
| 199 | return NULL; | 190 | return NULL; |
| 200 | 191 | ||
| 201 | child[0] = fh32[0]; | 192 | return isofs_export_iget(sb, ifid->block, ifid->offset, |
| 202 | child[1] = fh16[2]; /* fh16 [sic] */ | 193 | ifid->generation); |
| 203 | child[2] = fh32[2]; | ||
| 204 | |||
| 205 | parent[0] = 0; | ||
| 206 | parent[1] = 0; | ||
| 207 | parent[2] = 0; | ||
| 208 | if (fileid_type == 2) { | ||
| 209 | if (fh_len > 2) parent[0] = fh32[3]; | ||
| 210 | parent[1] = fh16[3]; /* fh16 [sic] */ | ||
| 211 | if (fh_len > 4) parent[2] = fh32[4]; | ||
| 212 | } | ||
| 213 | |||
| 214 | return sb->s_export_op->find_exported_dentry(sb, child, parent, | ||
| 215 | acceptable, context); | ||
| 216 | } | 194 | } |
| 217 | 195 | ||
| 196 | static struct dentry *isofs_fh_to_parent(struct super_block *sb, | ||
| 197 | struct fid *fid, int fh_len, int fh_type) | ||
| 198 | { | ||
| 199 | struct isofs_fid *ifid = (struct isofs_fid *)fid; | ||
| 200 | |||
| 201 | if (fh_type != 2) | ||
| 202 | return NULL; | ||
| 203 | |||
| 204 | return isofs_export_iget(sb, | ||
| 205 | fh_len > 2 ? ifid->parent_block : 0, | ||
| 206 | ifid->parent_offset, | ||
| 207 | fh_len > 4 ? ifid->parent_generation : 0); | ||
| 208 | } | ||
| 218 | 209 | ||
| 219 | struct export_operations isofs_export_ops = { | 210 | const struct export_operations isofs_export_ops = { |
| 220 | .decode_fh = isofs_export_decode_fh, | ||
| 221 | .encode_fh = isofs_export_encode_fh, | 211 | .encode_fh = isofs_export_encode_fh, |
| 222 | .get_dentry = isofs_export_get_dentry, | 212 | .fh_to_dentry = isofs_fh_to_dentry, |
| 213 | .fh_to_parent = isofs_fh_to_parent, | ||
| 223 | .get_parent = isofs_export_get_parent, | 214 | .get_parent = isofs_export_get_parent, |
| 224 | }; | 215 | }; |
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h index a07e67b1ea7f..f3213f9f89af 100644 --- a/fs/isofs/isofs.h +++ b/fs/isofs/isofs.h | |||
| @@ -178,4 +178,4 @@ isofs_normalize_block_and_offset(struct iso_directory_record* de, | |||
| 178 | extern const struct inode_operations isofs_dir_inode_operations; | 178 | extern const struct inode_operations isofs_dir_inode_operations; |
| 179 | extern const struct file_operations isofs_dir_operations; | 179 | extern const struct file_operations isofs_dir_operations; |
| 180 | extern const struct address_space_operations isofs_symlink_aops; | 180 | extern const struct address_space_operations isofs_symlink_aops; |
| 181 | extern struct export_operations isofs_export_ops; | 181 | extern const struct export_operations isofs_export_ops; |
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h index f0ec72b263f1..8e2cf2cde185 100644 --- a/fs/jfs/jfs_inode.h +++ b/fs/jfs/jfs_inode.h | |||
| @@ -18,6 +18,8 @@ | |||
| 18 | #ifndef _H_JFS_INODE | 18 | #ifndef _H_JFS_INODE |
| 19 | #define _H_JFS_INODE | 19 | #define _H_JFS_INODE |
| 20 | 20 | ||
| 21 | struct fid; | ||
| 22 | |||
| 21 | extern struct inode *ialloc(struct inode *, umode_t); | 23 | extern struct inode *ialloc(struct inode *, umode_t); |
| 22 | extern int jfs_fsync(struct file *, struct dentry *, int); | 24 | extern int jfs_fsync(struct file *, struct dentry *, int); |
| 23 | extern int jfs_ioctl(struct inode *, struct file *, | 25 | extern int jfs_ioctl(struct inode *, struct file *, |
| @@ -32,7 +34,10 @@ extern void jfs_truncate_nolock(struct inode *, loff_t); | |||
| 32 | extern void jfs_free_zero_link(struct inode *); | 34 | extern void jfs_free_zero_link(struct inode *); |
| 33 | extern struct dentry *jfs_get_parent(struct dentry *dentry); | 35 | extern struct dentry *jfs_get_parent(struct dentry *dentry); |
| 34 | extern void jfs_get_inode_flags(struct jfs_inode_info *); | 36 | extern void jfs_get_inode_flags(struct jfs_inode_info *); |
| 35 | extern struct dentry *jfs_get_dentry(struct super_block *sb, void *vobjp); | 37 | extern struct dentry *jfs_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 38 | int fh_len, int fh_type); | ||
| 39 | extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 40 | int fh_len, int fh_type); | ||
| 36 | extern void jfs_set_inode_flags(struct inode *); | 41 | extern void jfs_set_inode_flags(struct inode *); |
| 37 | extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int); | 42 | extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int); |
| 38 | 43 | ||
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 932797ba433b..4e0a8493cef6 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/fs.h> | 20 | #include <linux/fs.h> |
| 21 | #include <linux/ctype.h> | 21 | #include <linux/ctype.h> |
| 22 | #include <linux/quotaops.h> | 22 | #include <linux/quotaops.h> |
| 23 | #include <linux/exportfs.h> | ||
| 23 | #include "jfs_incore.h" | 24 | #include "jfs_incore.h" |
| 24 | #include "jfs_superblock.h" | 25 | #include "jfs_superblock.h" |
| 25 | #include "jfs_inode.h" | 26 | #include "jfs_inode.h" |
| @@ -1477,13 +1478,10 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc | |||
| 1477 | return dentry; | 1478 | return dentry; |
| 1478 | } | 1479 | } |
| 1479 | 1480 | ||
| 1480 | struct dentry *jfs_get_dentry(struct super_block *sb, void *vobjp) | 1481 | static struct inode *jfs_nfs_get_inode(struct super_block *sb, |
| 1482 | u64 ino, u32 generation) | ||
| 1481 | { | 1483 | { |
| 1482 | __u32 *objp = vobjp; | ||
| 1483 | unsigned long ino = objp[0]; | ||
| 1484 | __u32 generation = objp[1]; | ||
| 1485 | struct inode *inode; | 1484 | struct inode *inode; |
| 1486 | struct dentry *result; | ||
| 1487 | 1485 | ||
| 1488 | if (ino == 0) | 1486 | if (ino == 0) |
| 1489 | return ERR_PTR(-ESTALE); | 1487 | return ERR_PTR(-ESTALE); |
| @@ -1493,20 +1491,25 @@ struct dentry *jfs_get_dentry(struct super_block *sb, void *vobjp) | |||
| 1493 | 1491 | ||
| 1494 | if (is_bad_inode(inode) || | 1492 | if (is_bad_inode(inode) || |
| 1495 | (generation && inode->i_generation != generation)) { | 1493 | (generation && inode->i_generation != generation)) { |
| 1496 | result = ERR_PTR(-ESTALE); | 1494 | iput(inode); |
| 1497 | goto out_iput; | 1495 | return ERR_PTR(-ESTALE); |
| 1498 | } | 1496 | } |
| 1499 | 1497 | ||
| 1500 | result = d_alloc_anon(inode); | 1498 | return inode; |
| 1501 | if (!result) { | 1499 | } |
| 1502 | result = ERR_PTR(-ENOMEM); | ||
| 1503 | goto out_iput; | ||
| 1504 | } | ||
| 1505 | return result; | ||
| 1506 | 1500 | ||
| 1507 | out_iput: | 1501 | struct dentry *jfs_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 1508 | iput(inode); | 1502 | int fh_len, int fh_type) |
| 1509 | return result; | 1503 | { |
| 1504 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, | ||
| 1505 | jfs_nfs_get_inode); | ||
| 1506 | } | ||
| 1507 | |||
| 1508 | struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 1509 | int fh_len, int fh_type) | ||
| 1510 | { | ||
| 1511 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, | ||
| 1512 | jfs_nfs_get_inode); | ||
| 1510 | } | 1513 | } |
| 1511 | 1514 | ||
| 1512 | struct dentry *jfs_get_parent(struct dentry *dentry) | 1515 | struct dentry *jfs_get_parent(struct dentry *dentry) |
diff --git a/fs/jfs/super.c b/fs/jfs/super.c index cff60c171943..314bb4ff1ba8 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c | |||
| @@ -48,7 +48,7 @@ MODULE_LICENSE("GPL"); | |||
| 48 | static struct kmem_cache * jfs_inode_cachep; | 48 | static struct kmem_cache * jfs_inode_cachep; |
| 49 | 49 | ||
| 50 | static const struct super_operations jfs_super_operations; | 50 | static const struct super_operations jfs_super_operations; |
| 51 | static struct export_operations jfs_export_operations; | 51 | static const struct export_operations jfs_export_operations; |
| 52 | static struct file_system_type jfs_fs_type; | 52 | static struct file_system_type jfs_fs_type; |
| 53 | 53 | ||
| 54 | #define MAX_COMMIT_THREADS 64 | 54 | #define MAX_COMMIT_THREADS 64 |
| @@ -737,8 +737,9 @@ static const struct super_operations jfs_super_operations = { | |||
| 737 | #endif | 737 | #endif |
| 738 | }; | 738 | }; |
| 739 | 739 | ||
| 740 | static struct export_operations jfs_export_operations = { | 740 | static const struct export_operations jfs_export_operations = { |
| 741 | .get_dentry = jfs_get_dentry, | 741 | .fh_to_dentry = jfs_fh_to_dentry, |
| 742 | .fh_to_parent = jfs_fh_to_parent, | ||
| 742 | .get_parent = jfs_get_parent, | 743 | .get_parent = jfs_get_parent, |
| 743 | }; | 744 | }; |
| 744 | 745 | ||
diff --git a/fs/libfs.c b/fs/libfs.c index ae51481e45e5..6e68b700958d 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <linux/mount.h> | 8 | #include <linux/mount.h> |
| 9 | #include <linux/vfs.h> | 9 | #include <linux/vfs.h> |
| 10 | #include <linux/mutex.h> | 10 | #include <linux/mutex.h> |
| 11 | #include <linux/exportfs.h> | ||
| 11 | 12 | ||
| 12 | #include <asm/uaccess.h> | 13 | #include <asm/uaccess.h> |
| 13 | 14 | ||
| @@ -678,6 +679,93 @@ out: | |||
| 678 | return ret; | 679 | return ret; |
| 679 | } | 680 | } |
| 680 | 681 | ||
| 682 | /* | ||
| 683 | * This is what d_alloc_anon should have been. Once the exportfs | ||
| 684 | * argument transition has been finished I will update d_alloc_anon | ||
| 685 | * to this prototype and this wrapper will go away. --hch | ||
| 686 | */ | ||
| 687 | static struct dentry *exportfs_d_alloc(struct inode *inode) | ||
| 688 | { | ||
| 689 | struct dentry *dentry; | ||
| 690 | |||
| 691 | if (!inode) | ||
| 692 | return NULL; | ||
| 693 | if (IS_ERR(inode)) | ||
| 694 | return ERR_PTR(PTR_ERR(inode)); | ||
| 695 | |||
| 696 | dentry = d_alloc_anon(inode); | ||
| 697 | if (!dentry) { | ||
| 698 | iput(inode); | ||
| 699 | dentry = ERR_PTR(-ENOMEM); | ||
| 700 | } | ||
| 701 | return dentry; | ||
| 702 | } | ||
| 703 | |||
| 704 | /** | ||
| 705 | * generic_fh_to_dentry - generic helper for the fh_to_dentry export operation | ||
| 706 | * @sb: filesystem to do the file handle conversion on | ||
| 707 | * @fid: file handle to convert | ||
| 708 | * @fh_len: length of the file handle in bytes | ||
| 709 | * @fh_type: type of file handle | ||
| 710 | * @get_inode: filesystem callback to retrieve inode | ||
| 711 | * | ||
| 712 | * This function decodes @fid as long as it has one of the well-known | ||
| 713 | * Linux filehandle types and calls @get_inode on it to retrieve the | ||
| 714 | * inode for the object specified in the file handle. | ||
| 715 | */ | ||
| 716 | struct dentry *generic_fh_to_dentry(struct super_block *sb, struct fid *fid, | ||
| 717 | int fh_len, int fh_type, struct inode *(*get_inode) | ||
| 718 | (struct super_block *sb, u64 ino, u32 gen)) | ||
| 719 | { | ||
| 720 | struct inode *inode = NULL; | ||
| 721 | |||
| 722 | if (fh_len < 2) | ||
| 723 | return NULL; | ||
| 724 | |||
| 725 | switch (fh_type) { | ||
| 726 | case FILEID_INO32_GEN: | ||
| 727 | case FILEID_INO32_GEN_PARENT: | ||
| 728 | inode = get_inode(sb, fid->i32.ino, fid->i32.gen); | ||
| 729 | break; | ||
| 730 | } | ||
| 731 | |||
| 732 | return exportfs_d_alloc(inode); | ||
| 733 | } | ||
| 734 | EXPORT_SYMBOL_GPL(generic_fh_to_dentry); | ||
| 735 | |||
| 736 | /** | ||
| 737 | * generic_fh_to_dentry - generic helper for the fh_to_parent export operation | ||
| 738 | * @sb: filesystem to do the file handle conversion on | ||
| 739 | * @fid: file handle to convert | ||
| 740 | * @fh_len: length of the file handle in bytes | ||
| 741 | * @fh_type: type of file handle | ||
| 742 | * @get_inode: filesystem callback to retrieve inode | ||
| 743 | * | ||
| 744 | * This function decodes @fid as long as it has one of the well-known | ||
| 745 | * Linux filehandle types and calls @get_inode on it to retrieve the | ||
| 746 | * inode for the _parent_ object specified in the file handle if it | ||
| 747 | * is specified in the file handle, or NULL otherwise. | ||
| 748 | */ | ||
| 749 | struct dentry *generic_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 750 | int fh_len, int fh_type, struct inode *(*get_inode) | ||
| 751 | (struct super_block *sb, u64 ino, u32 gen)) | ||
| 752 | { | ||
| 753 | struct inode *inode = NULL; | ||
| 754 | |||
| 755 | if (fh_len <= 2) | ||
| 756 | return NULL; | ||
| 757 | |||
| 758 | switch (fh_type) { | ||
| 759 | case FILEID_INO32_GEN_PARENT: | ||
| 760 | inode = get_inode(sb, fid->i32.parent_ino, | ||
| 761 | (fh_len > 3 ? fid->i32.parent_gen : 0)); | ||
| 762 | break; | ||
| 763 | } | ||
| 764 | |||
| 765 | return exportfs_d_alloc(inode); | ||
| 766 | } | ||
| 767 | EXPORT_SYMBOL_GPL(generic_fh_to_parent); | ||
| 768 | |||
| 681 | EXPORT_SYMBOL(dcache_dir_close); | 769 | EXPORT_SYMBOL(dcache_dir_close); |
| 682 | EXPORT_SYMBOL(dcache_dir_lseek); | 770 | EXPORT_SYMBOL(dcache_dir_lseek); |
| 683 | EXPORT_SYMBOL(dcache_dir_open); | 771 | EXPORT_SYMBOL(dcache_dir_open); |
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 04b266729802..66d0aeb32a47 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
| @@ -386,15 +386,13 @@ static int check_export(struct inode *inode, int flags, unsigned char *uuid) | |||
| 386 | dprintk("exp_export: export of non-dev fs without fsid\n"); | 386 | dprintk("exp_export: export of non-dev fs without fsid\n"); |
| 387 | return -EINVAL; | 387 | return -EINVAL; |
| 388 | } | 388 | } |
| 389 | if (!inode->i_sb->s_export_op) { | 389 | |
| 390 | if (!inode->i_sb->s_export_op || | ||
| 391 | !inode->i_sb->s_export_op->fh_to_dentry) { | ||
| 390 | dprintk("exp_export: export of invalid fs type.\n"); | 392 | dprintk("exp_export: export of invalid fs type.\n"); |
| 391 | return -EINVAL; | 393 | return -EINVAL; |
| 392 | } | 394 | } |
| 393 | 395 | ||
| 394 | /* Ok, we can export it */; | ||
| 395 | if (!inode->i_sb->s_export_op->find_exported_dentry) | ||
| 396 | inode->i_sb->s_export_op->find_exported_dentry = | ||
| 397 | find_exported_dentry; | ||
| 398 | return 0; | 396 | return 0; |
| 399 | 397 | ||
| 400 | } | 398 | } |
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index ebd03cc07479..6f03918018a3 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c | |||
| @@ -88,7 +88,7 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname) | |||
| 88 | { | 88 | { |
| 89 | struct xdr_netobj cksum; | 89 | struct xdr_netobj cksum; |
| 90 | struct hash_desc desc; | 90 | struct hash_desc desc; |
| 91 | struct scatterlist sg[1]; | 91 | struct scatterlist sg; |
| 92 | __be32 status = nfserr_resource; | 92 | __be32 status = nfserr_resource; |
| 93 | 93 | ||
| 94 | dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n", | 94 | dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n", |
| @@ -102,11 +102,9 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname) | |||
| 102 | if (cksum.data == NULL) | 102 | if (cksum.data == NULL) |
| 103 | goto out; | 103 | goto out; |
| 104 | 104 | ||
| 105 | sg[0].page = virt_to_page(clname->data); | 105 | sg_init_one(&sg, clname->data, clname->len); |
| 106 | sg[0].offset = offset_in_page(clname->data); | ||
| 107 | sg[0].length = clname->len; | ||
| 108 | 106 | ||
| 109 | if (crypto_hash_digest(&desc, sg, sg->length, cksum.data)) | 107 | if (crypto_hash_digest(&desc, &sg, sg.length, cksum.data)) |
| 110 | goto out; | 108 | goto out; |
| 111 | 109 | ||
| 112 | md5_to_hex(dname, cksum.data); | 110 | md5_to_hex(dname, cksum.data); |
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 7011d62acfc8..4f712e970584 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c | |||
| @@ -115,8 +115,7 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) | |||
| 115 | dprintk("nfsd: fh_verify(%s)\n", SVCFH_fmt(fhp)); | 115 | dprintk("nfsd: fh_verify(%s)\n", SVCFH_fmt(fhp)); |
| 116 | 116 | ||
| 117 | if (!fhp->fh_dentry) { | 117 | if (!fhp->fh_dentry) { |
| 118 | __u32 *datap=NULL; | 118 | struct fid *fid = NULL, sfid; |
| 119 | __u32 tfh[3]; /* filehandle fragment for oldstyle filehandles */ | ||
| 120 | int fileid_type; | 119 | int fileid_type; |
| 121 | int data_left = fh->fh_size/4; | 120 | int data_left = fh->fh_size/4; |
| 122 | 121 | ||
| @@ -128,7 +127,6 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) | |||
| 128 | 127 | ||
| 129 | if (fh->fh_version == 1) { | 128 | if (fh->fh_version == 1) { |
| 130 | int len; | 129 | int len; |
| 131 | datap = fh->fh_auth; | ||
| 132 | if (--data_left<0) goto out; | 130 | if (--data_left<0) goto out; |
| 133 | switch (fh->fh_auth_type) { | 131 | switch (fh->fh_auth_type) { |
| 134 | case 0: break; | 132 | case 0: break; |
| @@ -144,9 +142,11 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) | |||
| 144 | fh->fh_fsid[1] = fh->fh_fsid[2]; | 142 | fh->fh_fsid[1] = fh->fh_fsid[2]; |
| 145 | } | 143 | } |
| 146 | if ((data_left -= len)<0) goto out; | 144 | if ((data_left -= len)<0) goto out; |
| 147 | exp = rqst_exp_find(rqstp, fh->fh_fsid_type, datap); | 145 | exp = rqst_exp_find(rqstp, fh->fh_fsid_type, |
| 148 | datap += len; | 146 | fh->fh_auth); |
| 147 | fid = (struct fid *)(fh->fh_auth + len); | ||
| 149 | } else { | 148 | } else { |
| 149 | __u32 tfh[2]; | ||
| 150 | dev_t xdev; | 150 | dev_t xdev; |
| 151 | ino_t xino; | 151 | ino_t xino; |
| 152 | if (fh->fh_size != NFS_FHSIZE) | 152 | if (fh->fh_size != NFS_FHSIZE) |
| @@ -190,22 +190,22 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) | |||
| 190 | error = nfserr_badhandle; | 190 | error = nfserr_badhandle; |
| 191 | 191 | ||
| 192 | if (fh->fh_version != 1) { | 192 | if (fh->fh_version != 1) { |
| 193 | tfh[0] = fh->ofh_ino; | 193 | sfid.i32.ino = fh->ofh_ino; |
| 194 | tfh[1] = fh->ofh_generation; | 194 | sfid.i32.gen = fh->ofh_generation; |
| 195 | tfh[2] = fh->ofh_dirino; | 195 | sfid.i32.parent_ino = fh->ofh_dirino; |
| 196 | datap = tfh; | 196 | fid = &sfid; |
| 197 | data_left = 3; | 197 | data_left = 3; |
| 198 | if (fh->ofh_dirino == 0) | 198 | if (fh->ofh_dirino == 0) |
| 199 | fileid_type = 1; | 199 | fileid_type = FILEID_INO32_GEN; |
| 200 | else | 200 | else |
| 201 | fileid_type = 2; | 201 | fileid_type = FILEID_INO32_GEN_PARENT; |
| 202 | } else | 202 | } else |
| 203 | fileid_type = fh->fh_fileid_type; | 203 | fileid_type = fh->fh_fileid_type; |
| 204 | 204 | ||
| 205 | if (fileid_type == 0) | 205 | if (fileid_type == FILEID_ROOT) |
| 206 | dentry = dget(exp->ex_dentry); | 206 | dentry = dget(exp->ex_dentry); |
| 207 | else { | 207 | else { |
| 208 | dentry = exportfs_decode_fh(exp->ex_mnt, datap, | 208 | dentry = exportfs_decode_fh(exp->ex_mnt, fid, |
| 209 | data_left, fileid_type, | 209 | data_left, fileid_type, |
| 210 | nfsd_acceptable, exp); | 210 | nfsd_acceptable, exp); |
| 211 | } | 211 | } |
| @@ -286,16 +286,21 @@ out: | |||
| 286 | * an inode. In this case a call to fh_update should be made | 286 | * an inode. In this case a call to fh_update should be made |
| 287 | * before the fh goes out on the wire ... | 287 | * before the fh goes out on the wire ... |
| 288 | */ | 288 | */ |
| 289 | static inline int _fh_update(struct dentry *dentry, struct svc_export *exp, | 289 | static void _fh_update(struct svc_fh *fhp, struct svc_export *exp, |
| 290 | __u32 *datap, int *maxsize) | 290 | struct dentry *dentry) |
| 291 | { | 291 | { |
| 292 | if (dentry == exp->ex_dentry) { | 292 | if (dentry != exp->ex_dentry) { |
| 293 | *maxsize = 0; | 293 | struct fid *fid = (struct fid *) |
| 294 | return 0; | 294 | (fhp->fh_handle.fh_auth + fhp->fh_handle.fh_size/4 - 1); |
| 295 | } | 295 | int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; |
| 296 | int subtreecheck = !(exp->ex_flags & NFSEXP_NOSUBTREECHECK); | ||
| 296 | 297 | ||
| 297 | return exportfs_encode_fh(dentry, datap, maxsize, | 298 | fhp->fh_handle.fh_fileid_type = |
| 298 | !(exp->ex_flags & NFSEXP_NOSUBTREECHECK)); | 299 | exportfs_encode_fh(dentry, fid, &maxsize, subtreecheck); |
| 300 | fhp->fh_handle.fh_size += maxsize * 4; | ||
| 301 | } else { | ||
| 302 | fhp->fh_handle.fh_fileid_type = FILEID_ROOT; | ||
| 303 | } | ||
| 299 | } | 304 | } |
| 300 | 305 | ||
| 301 | /* | 306 | /* |
| @@ -457,12 +462,8 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, | |||
| 457 | datap += len/4; | 462 | datap += len/4; |
| 458 | fhp->fh_handle.fh_size = 4 + len; | 463 | fhp->fh_handle.fh_size = 4 + len; |
| 459 | 464 | ||
| 460 | if (inode) { | 465 | if (inode) |
| 461 | int size = (fhp->fh_maxsize-len-4)/4; | 466 | _fh_update(fhp, exp, dentry); |
| 462 | fhp->fh_handle.fh_fileid_type = | ||
| 463 | _fh_update(dentry, exp, datap, &size); | ||
| 464 | fhp->fh_handle.fh_size += size*4; | ||
| 465 | } | ||
| 466 | if (fhp->fh_handle.fh_fileid_type == 255) | 467 | if (fhp->fh_handle.fh_fileid_type == 255) |
| 467 | return nfserr_opnotsupp; | 468 | return nfserr_opnotsupp; |
| 468 | } | 469 | } |
| @@ -479,7 +480,6 @@ __be32 | |||
| 479 | fh_update(struct svc_fh *fhp) | 480 | fh_update(struct svc_fh *fhp) |
| 480 | { | 481 | { |
| 481 | struct dentry *dentry; | 482 | struct dentry *dentry; |
| 482 | __u32 *datap; | ||
| 483 | 483 | ||
| 484 | if (!fhp->fh_dentry) | 484 | if (!fhp->fh_dentry) |
| 485 | goto out_bad; | 485 | goto out_bad; |
| @@ -490,15 +490,10 @@ fh_update(struct svc_fh *fhp) | |||
| 490 | if (fhp->fh_handle.fh_version != 1) { | 490 | if (fhp->fh_handle.fh_version != 1) { |
| 491 | _fh_update_old(dentry, fhp->fh_export, &fhp->fh_handle); | 491 | _fh_update_old(dentry, fhp->fh_export, &fhp->fh_handle); |
| 492 | } else { | 492 | } else { |
| 493 | int size; | 493 | if (fhp->fh_handle.fh_fileid_type != FILEID_ROOT) |
| 494 | if (fhp->fh_handle.fh_fileid_type != 0) | ||
| 495 | goto out; | 494 | goto out; |
| 496 | datap = fhp->fh_handle.fh_auth+ | 495 | |
| 497 | fhp->fh_handle.fh_size/4 -1; | 496 | _fh_update(fhp, fhp->fh_export, dentry); |
| 498 | size = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; | ||
| 499 | fhp->fh_handle.fh_fileid_type = | ||
| 500 | _fh_update(dentry, fhp->fh_export, datap, &size); | ||
| 501 | fhp->fh_handle.fh_size += size*4; | ||
| 502 | if (fhp->fh_handle.fh_fileid_type == 255) | 497 | if (fhp->fh_handle.fh_fileid_type == 255) |
| 503 | return nfserr_opnotsupp; | 498 | return nfserr_opnotsupp; |
| 504 | } | 499 | } |
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c index e93c6142b23c..e1781c8b1650 100644 --- a/fs/ntfs/namei.c +++ b/fs/ntfs/namei.c | |||
| @@ -450,58 +450,40 @@ try_next: | |||
| 450 | return parent_dent; | 450 | return parent_dent; |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | /** | 453 | static struct inode *ntfs_nfs_get_inode(struct super_block *sb, |
| 454 | * ntfs_get_dentry - find a dentry for the inode from a file handle sub-fragment | 454 | u64 ino, u32 generation) |
| 455 | * @sb: super block identifying the mounted ntfs volume | ||
| 456 | * @fh: the file handle sub-fragment | ||
| 457 | * | ||
| 458 | * Find a dentry for the inode given a file handle sub-fragment. This function | ||
| 459 | * is called from fs/exportfs/expfs.c::find_exported_dentry() which in turn is | ||
| 460 | * called from the default ->decode_fh() which is export_decode_fh() in the | ||
| 461 | * same file. The code is closely based on the default ->get_dentry() helper | ||
| 462 | * fs/exportfs/expfs.c::get_object(). | ||
| 463 | * | ||
| 464 | * The @fh contains two 32-bit unsigned values, the first one is the inode | ||
| 465 | * number and the second one is the inode generation. | ||
| 466 | * | ||
| 467 | * Return the dentry on success or the error code on error (IS_ERR() is true). | ||
| 468 | */ | ||
| 469 | static struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh) | ||
| 470 | { | 455 | { |
| 471 | struct inode *vi; | 456 | struct inode *inode; |
| 472 | struct dentry *dent; | ||
| 473 | unsigned long ino = ((u32 *)fh)[0]; | ||
| 474 | u32 gen = ((u32 *)fh)[1]; | ||
| 475 | 457 | ||
| 476 | ntfs_debug("Entering for inode 0x%lx, generation 0x%x.", ino, gen); | 458 | inode = ntfs_iget(sb, ino); |
| 477 | vi = ntfs_iget(sb, ino); | 459 | if (!IS_ERR(inode)) { |
| 478 | if (IS_ERR(vi)) { | 460 | if (is_bad_inode(inode) || inode->i_generation != generation) { |
| 479 | ntfs_error(sb, "Failed to get inode 0x%lx.", ino); | 461 | iput(inode); |
| 480 | return (struct dentry *)vi; | 462 | inode = ERR_PTR(-ESTALE); |
| 481 | } | 463 | } |
| 482 | if (unlikely(is_bad_inode(vi) || vi->i_generation != gen)) { | ||
| 483 | /* We didn't find the right inode. */ | ||
| 484 | ntfs_error(sb, "Inode 0x%lx, bad count: %d %d or version 0x%x " | ||
| 485 | "0x%x.", vi->i_ino, vi->i_nlink, | ||
| 486 | atomic_read(&vi->i_count), vi->i_generation, | ||
| 487 | gen); | ||
| 488 | iput(vi); | ||
| 489 | return ERR_PTR(-ESTALE); | ||
| 490 | } | ||
| 491 | /* Now find a dentry. If possible, get a well-connected one. */ | ||
| 492 | dent = d_alloc_anon(vi); | ||
| 493 | if (unlikely(!dent)) { | ||
| 494 | iput(vi); | ||
| 495 | return ERR_PTR(-ENOMEM); | ||
| 496 | } | 464 | } |
| 497 | ntfs_debug("Done for inode 0x%lx, generation 0x%x.", ino, gen); | 465 | |
| 498 | return dent; | 466 | return inode; |
| 467 | } | ||
| 468 | |||
| 469 | static struct dentry *ntfs_fh_to_dentry(struct super_block *sb, struct fid *fid, | ||
| 470 | int fh_len, int fh_type) | ||
| 471 | { | ||
| 472 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, | ||
| 473 | ntfs_nfs_get_inode); | ||
| 474 | } | ||
| 475 | |||
| 476 | static struct dentry *ntfs_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 477 | int fh_len, int fh_type) | ||
| 478 | { | ||
| 479 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, | ||
| 480 | ntfs_nfs_get_inode); | ||
| 499 | } | 481 | } |
| 500 | 482 | ||
| 501 | /** | 483 | /** |
| 502 | * Export operations allowing NFS exporting of mounted NTFS partitions. | 484 | * Export operations allowing NFS exporting of mounted NTFS partitions. |
| 503 | * | 485 | * |
| 504 | * We use the default ->decode_fh() and ->encode_fh() for now. Note that they | 486 | * We use the default ->encode_fh() for now. Note that they |
| 505 | * use 32 bits to store the inode number which is an unsigned long so on 64-bit | 487 | * use 32 bits to store the inode number which is an unsigned long so on 64-bit |
| 506 | * architectures is usually 64 bits so it would all fail horribly on huge | 488 | * architectures is usually 64 bits so it would all fail horribly on huge |
| 507 | * volumes. I guess we need to define our own encode and decode fh functions | 489 | * volumes. I guess we need to define our own encode and decode fh functions |
| @@ -517,10 +499,9 @@ static struct dentry *ntfs_get_dentry(struct super_block *sb, void *fh) | |||
| 517 | * allowing the inode number 0 which is used in NTFS for the system file $MFT | 499 | * allowing the inode number 0 which is used in NTFS for the system file $MFT |
| 518 | * and due to using iget() whereas NTFS needs ntfs_iget(). | 500 | * and due to using iget() whereas NTFS needs ntfs_iget(). |
| 519 | */ | 501 | */ |
| 520 | struct export_operations ntfs_export_ops = { | 502 | const struct export_operations ntfs_export_ops = { |
| 521 | .get_parent = ntfs_get_parent, /* Find the parent of a given | 503 | .get_parent = ntfs_get_parent, /* Find the parent of a given |
| 522 | directory. */ | 504 | directory. */ |
| 523 | .get_dentry = ntfs_get_dentry, /* Find a dentry for the inode | 505 | .fh_to_dentry = ntfs_fh_to_dentry, |
| 524 | given a file handle | 506 | .fh_to_parent = ntfs_fh_to_parent, |
| 525 | sub-fragment. */ | ||
| 526 | }; | 507 | }; |
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h index d73f5a9ac341..d6a340bf80fc 100644 --- a/fs/ntfs/ntfs.h +++ b/fs/ntfs/ntfs.h | |||
| @@ -69,7 +69,7 @@ extern const struct inode_operations ntfs_dir_inode_ops; | |||
| 69 | extern const struct file_operations ntfs_empty_file_ops; | 69 | extern const struct file_operations ntfs_empty_file_ops; |
| 70 | extern const struct inode_operations ntfs_empty_inode_ops; | 70 | extern const struct inode_operations ntfs_empty_inode_ops; |
| 71 | 71 | ||
| 72 | extern struct export_operations ntfs_export_ops; | 72 | extern const struct export_operations ntfs_export_ops; |
| 73 | 73 | ||
| 74 | /** | 74 | /** |
| 75 | * NTFS_SB - return the ntfs volume given a vfs super block | 75 | * NTFS_SB - return the ntfs volume given a vfs super block |
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c index c3bbc198f9ce..535bfa9568a4 100644 --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c | |||
| @@ -45,9 +45,9 @@ struct ocfs2_inode_handle | |||
| 45 | u32 ih_generation; | 45 | u32 ih_generation; |
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | static struct dentry *ocfs2_get_dentry(struct super_block *sb, void *vobjp) | 48 | static struct dentry *ocfs2_get_dentry(struct super_block *sb, |
| 49 | struct ocfs2_inode_handle *handle) | ||
| 49 | { | 50 | { |
| 50 | struct ocfs2_inode_handle *handle = vobjp; | ||
| 51 | struct inode *inode; | 51 | struct inode *inode; |
| 52 | struct dentry *result; | 52 | struct dentry *result; |
| 53 | 53 | ||
| @@ -194,54 +194,37 @@ bail: | |||
| 194 | return type; | 194 | return type; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | static struct dentry *ocfs2_decode_fh(struct super_block *sb, u32 *fh_in, | 197 | static struct dentry *ocfs2_fh_to_dentry(struct super_block *sb, |
| 198 | int fh_len, int fileid_type, | 198 | struct fid *fid, int fh_len, int fh_type) |
| 199 | int (*acceptable)(void *context, | ||
| 200 | struct dentry *de), | ||
| 201 | void *context) | ||
| 202 | { | 199 | { |
| 203 | struct ocfs2_inode_handle handle, parent; | 200 | struct ocfs2_inode_handle handle; |
| 204 | struct dentry *ret = NULL; | ||
| 205 | __le32 *fh = (__force __le32 *) fh_in; | ||
| 206 | |||
| 207 | mlog_entry("(0x%p, 0x%p, %d, %d, 0x%p, 0x%p)\n", | ||
| 208 | sb, fh, fh_len, fileid_type, acceptable, context); | ||
| 209 | |||
| 210 | if (fh_len < 3 || fileid_type > 2) | ||
| 211 | goto bail; | ||
| 212 | |||
| 213 | if (fileid_type == 2) { | ||
| 214 | if (fh_len < 6) | ||
| 215 | goto bail; | ||
| 216 | |||
| 217 | parent.ih_blkno = (u64)le32_to_cpu(fh[3]) << 32; | ||
| 218 | parent.ih_blkno |= (u64)le32_to_cpu(fh[4]); | ||
| 219 | parent.ih_generation = le32_to_cpu(fh[5]); | ||
| 220 | 201 | ||
| 221 | mlog(0, "Decoding parent: blkno: %llu, generation: %u\n", | 202 | if (fh_len < 3 || fh_type > 2) |
| 222 | (unsigned long long)parent.ih_blkno, | 203 | return NULL; |
| 223 | parent.ih_generation); | ||
| 224 | } | ||
| 225 | 204 | ||
| 226 | handle.ih_blkno = (u64)le32_to_cpu(fh[0]) << 32; | 205 | handle.ih_blkno = (u64)le32_to_cpu(fid->raw[0]) << 32; |
| 227 | handle.ih_blkno |= (u64)le32_to_cpu(fh[1]); | 206 | handle.ih_blkno |= (u64)le32_to_cpu(fid->raw[1]); |
| 228 | handle.ih_generation = le32_to_cpu(fh[2]); | 207 | handle.ih_generation = le32_to_cpu(fid->raw[2]); |
| 208 | return ocfs2_get_dentry(sb, &handle); | ||
| 209 | } | ||
| 229 | 210 | ||
| 230 | mlog(0, "Encoding fh: blkno: %llu, generation: %u\n", | 211 | static struct dentry *ocfs2_fh_to_parent(struct super_block *sb, |
| 231 | (unsigned long long)handle.ih_blkno, handle.ih_generation); | 212 | struct fid *fid, int fh_len, int fh_type) |
| 213 | { | ||
| 214 | struct ocfs2_inode_handle parent; | ||
| 232 | 215 | ||
| 233 | ret = ocfs2_export_ops.find_exported_dentry(sb, &handle, &parent, | 216 | if (fh_type != 2 || fh_len < 6) |
| 234 | acceptable, context); | 217 | return NULL; |
| 235 | 218 | ||
| 236 | bail: | 219 | parent.ih_blkno = (u64)le32_to_cpu(fid->raw[3]) << 32; |
| 237 | mlog_exit_ptr(ret); | 220 | parent.ih_blkno |= (u64)le32_to_cpu(fid->raw[4]); |
| 238 | return ret; | 221 | parent.ih_generation = le32_to_cpu(fid->raw[5]); |
| 222 | return ocfs2_get_dentry(sb, &parent); | ||
| 239 | } | 223 | } |
| 240 | 224 | ||
| 241 | struct export_operations ocfs2_export_ops = { | 225 | const struct export_operations ocfs2_export_ops = { |
| 242 | .decode_fh = ocfs2_decode_fh, | ||
| 243 | .encode_fh = ocfs2_encode_fh, | 226 | .encode_fh = ocfs2_encode_fh, |
| 244 | 227 | .fh_to_dentry = ocfs2_fh_to_dentry, | |
| 228 | .fh_to_parent = ocfs2_fh_to_parent, | ||
| 245 | .get_parent = ocfs2_get_parent, | 229 | .get_parent = ocfs2_get_parent, |
| 246 | .get_dentry = ocfs2_get_dentry, | ||
| 247 | }; | 230 | }; |
diff --git a/fs/ocfs2/export.h b/fs/ocfs2/export.h index e08bed9e45a0..41a738678c37 100644 --- a/fs/ocfs2/export.h +++ b/fs/ocfs2/export.h | |||
| @@ -28,6 +28,6 @@ | |||
| 28 | 28 | ||
| 29 | #include <linux/exportfs.h> | 29 | #include <linux/exportfs.h> |
| 30 | 30 | ||
| 31 | extern struct export_operations ocfs2_export_ops; | 31 | extern const struct export_operations ocfs2_export_ops; |
| 32 | 32 | ||
| 33 | #endif /* OCFS2_EXPORT_H */ | 33 | #endif /* OCFS2_EXPORT_H */ |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index a991af96f3f0..231fd5ccadc5 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
| @@ -1515,19 +1515,20 @@ struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key) | |||
| 1515 | return inode; | 1515 | return inode; |
| 1516 | } | 1516 | } |
| 1517 | 1517 | ||
| 1518 | struct dentry *reiserfs_get_dentry(struct super_block *sb, void *vobjp) | 1518 | static struct dentry *reiserfs_get_dentry(struct super_block *sb, |
| 1519 | u32 objectid, u32 dir_id, u32 generation) | ||
| 1520 | |||
| 1519 | { | 1521 | { |
| 1520 | __u32 *data = vobjp; | ||
| 1521 | struct cpu_key key; | 1522 | struct cpu_key key; |
| 1522 | struct dentry *result; | 1523 | struct dentry *result; |
| 1523 | struct inode *inode; | 1524 | struct inode *inode; |
| 1524 | 1525 | ||
| 1525 | key.on_disk_key.k_objectid = data[0]; | 1526 | key.on_disk_key.k_objectid = objectid; |
| 1526 | key.on_disk_key.k_dir_id = data[1]; | 1527 | key.on_disk_key.k_dir_id = dir_id; |
| 1527 | reiserfs_write_lock(sb); | 1528 | reiserfs_write_lock(sb); |
| 1528 | inode = reiserfs_iget(sb, &key); | 1529 | inode = reiserfs_iget(sb, &key); |
| 1529 | if (inode && !IS_ERR(inode) && data[2] != 0 && | 1530 | if (inode && !IS_ERR(inode) && generation != 0 && |
| 1530 | data[2] != inode->i_generation) { | 1531 | generation != inode->i_generation) { |
| 1531 | iput(inode); | 1532 | iput(inode); |
| 1532 | inode = NULL; | 1533 | inode = NULL; |
| 1533 | } | 1534 | } |
| @@ -1544,14 +1545,9 @@ struct dentry *reiserfs_get_dentry(struct super_block *sb, void *vobjp) | |||
| 1544 | return result; | 1545 | return result; |
| 1545 | } | 1546 | } |
| 1546 | 1547 | ||
| 1547 | struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data, | 1548 | struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 1548 | int len, int fhtype, | 1549 | int fh_len, int fh_type) |
| 1549 | int (*acceptable) (void *contect, | ||
| 1550 | struct dentry * de), | ||
| 1551 | void *context) | ||
| 1552 | { | 1550 | { |
| 1553 | __u32 obj[3], parent[3]; | ||
| 1554 | |||
| 1555 | /* fhtype happens to reflect the number of u32s encoded. | 1551 | /* fhtype happens to reflect the number of u32s encoded. |
| 1556 | * due to a bug in earlier code, fhtype might indicate there | 1552 | * due to a bug in earlier code, fhtype might indicate there |
| 1557 | * are more u32s then actually fitted. | 1553 | * are more u32s then actually fitted. |
| @@ -1564,32 +1560,28 @@ struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data, | |||
| 1564 | * 6 - as above plus generation of directory | 1560 | * 6 - as above plus generation of directory |
| 1565 | * 6 does not fit in NFSv2 handles | 1561 | * 6 does not fit in NFSv2 handles |
| 1566 | */ | 1562 | */ |
| 1567 | if (fhtype > len) { | 1563 | if (fh_type > fh_len) { |
| 1568 | if (fhtype != 6 || len != 5) | 1564 | if (fh_type != 6 || fh_len != 5) |
| 1569 | reiserfs_warning(sb, | 1565 | reiserfs_warning(sb, |
| 1570 | "nfsd/reiserfs, fhtype=%d, len=%d - odd", | 1566 | "nfsd/reiserfs, fhtype=%d, len=%d - odd", |
| 1571 | fhtype, len); | 1567 | fh_type, fh_len); |
| 1572 | fhtype = 5; | 1568 | fh_type = 5; |
| 1573 | } | 1569 | } |
| 1574 | 1570 | ||
| 1575 | obj[0] = data[0]; | 1571 | return reiserfs_get_dentry(sb, fid->raw[0], fid->raw[1], |
| 1576 | obj[1] = data[1]; | 1572 | (fh_type == 3 || fh_type >= 5) ? fid->raw[2] : 0); |
| 1577 | if (fhtype == 3 || fhtype >= 5) | 1573 | } |
| 1578 | obj[2] = data[2]; | ||
| 1579 | else | ||
| 1580 | obj[2] = 0; /* generation number */ | ||
| 1581 | 1574 | ||
| 1582 | if (fhtype >= 4) { | 1575 | struct dentry *reiserfs_fh_to_parent(struct super_block *sb, struct fid *fid, |
| 1583 | parent[0] = data[fhtype >= 5 ? 3 : 2]; | 1576 | int fh_len, int fh_type) |
| 1584 | parent[1] = data[fhtype >= 5 ? 4 : 3]; | 1577 | { |
| 1585 | if (fhtype == 6) | 1578 | if (fh_type < 4) |
| 1586 | parent[2] = data[5]; | 1579 | return NULL; |
| 1587 | else | 1580 | |
| 1588 | parent[2] = 0; | 1581 | return reiserfs_get_dentry(sb, |
| 1589 | } | 1582 | (fh_type >= 5) ? fid->raw[3] : fid->raw[2], |
| 1590 | return sb->s_export_op->find_exported_dentry(sb, obj, | 1583 | (fh_type >= 5) ? fid->raw[4] : fid->raw[3], |
| 1591 | fhtype < 4 ? NULL : parent, | 1584 | (fh_type == 6) ? fid->raw[5] : 0); |
| 1592 | acceptable, context); | ||
| 1593 | } | 1585 | } |
| 1594 | 1586 | ||
| 1595 | int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp, | 1587 | int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp, |
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 98c3781bc069..5cd85fe5df5d 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
| @@ -661,11 +661,11 @@ static struct quotactl_ops reiserfs_qctl_operations = { | |||
| 661 | }; | 661 | }; |
| 662 | #endif | 662 | #endif |
| 663 | 663 | ||
| 664 | static struct export_operations reiserfs_export_ops = { | 664 | static const struct export_operations reiserfs_export_ops = { |
| 665 | .encode_fh = reiserfs_encode_fh, | 665 | .encode_fh = reiserfs_encode_fh, |
| 666 | .decode_fh = reiserfs_decode_fh, | 666 | .fh_to_dentry = reiserfs_fh_to_dentry, |
| 667 | .fh_to_parent = reiserfs_fh_to_parent, | ||
| 667 | .get_parent = reiserfs_get_parent, | 668 | .get_parent = reiserfs_get_parent, |
| 668 | .get_dentry = reiserfs_get_dentry, | ||
| 669 | }; | 669 | }; |
| 670 | 670 | ||
| 671 | /* this struct is used in reiserfs_getopt () for containing the value for those | 671 | /* this struct is used in reiserfs_getopt () for containing the value for those |
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c index 3586c7a28d2c..15bd4948832c 100644 --- a/fs/xfs/linux-2.6/xfs_export.c +++ b/fs/xfs/linux-2.6/xfs_export.c | |||
| @@ -33,62 +33,25 @@ | |||
| 33 | static struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, }; | 33 | static struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, }; |
| 34 | 34 | ||
| 35 | /* | 35 | /* |
| 36 | * XFS encodes and decodes the fileid portion of NFS filehandles | 36 | * Note that we only accept fileids which are long enough rather than allow |
| 37 | * itself instead of letting the generic NFS code do it. This | 37 | * the parent generation number to default to zero. XFS considers zero a |
| 38 | * allows filesystems with 64 bit inode numbers to be exported. | 38 | * valid generation number not an invalid/wildcard value. |
| 39 | * | ||
| 40 | * Note that a side effect is that xfs_vget() won't be passed a | ||
| 41 | * zero inode/generation pair under normal circumstances. As | ||
| 42 | * however a malicious client could send us such data, the check | ||
| 43 | * remains in that code. | ||
| 44 | */ | 39 | */ |
| 45 | 40 | static int xfs_fileid_length(int fileid_type) | |
| 46 | STATIC struct dentry * | ||
| 47 | xfs_fs_decode_fh( | ||
| 48 | struct super_block *sb, | ||
| 49 | __u32 *fh, | ||
| 50 | int fh_len, | ||
| 51 | int fileid_type, | ||
| 52 | int (*acceptable)( | ||
| 53 | void *context, | ||
| 54 | struct dentry *de), | ||
| 55 | void *context) | ||
| 56 | { | 41 | { |
| 57 | xfs_fid_t ifid; | 42 | switch (fileid_type) { |
| 58 | xfs_fid_t pfid; | 43 | case FILEID_INO32_GEN: |
| 59 | void *parent = NULL; | 44 | return 2; |
| 60 | int is64 = 0; | 45 | case FILEID_INO32_GEN_PARENT: |
| 61 | __u32 *p = fh; | 46 | return 4; |
| 62 | 47 | case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG: | |
| 63 | #if XFS_BIG_INUMS | 48 | return 3; |
| 64 | is64 = (fileid_type & XFS_FILEID_TYPE_64FLAG); | 49 | case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: |
| 65 | fileid_type &= ~XFS_FILEID_TYPE_64FLAG; | 50 | return 6; |
| 66 | #endif | ||
| 67 | |||
| 68 | /* | ||
| 69 | * Note that we only accept fileids which are long enough | ||
| 70 | * rather than allow the parent generation number to default | ||
| 71 | * to zero. XFS considers zero a valid generation number not | ||
| 72 | * an invalid/wildcard value. There's little point printk'ing | ||
| 73 | * a warning here as we don't have the client information | ||
| 74 | * which would make such a warning useful. | ||
| 75 | */ | ||
| 76 | if (fileid_type > 2 || | ||
| 77 | fh_len < xfs_fileid_length((fileid_type == 2), is64)) | ||
| 78 | return NULL; | ||
| 79 | |||
| 80 | p = xfs_fileid_decode_fid2(p, &ifid, is64); | ||
| 81 | |||
| 82 | if (fileid_type == 2) { | ||
| 83 | p = xfs_fileid_decode_fid2(p, &pfid, is64); | ||
| 84 | parent = &pfid; | ||
| 85 | } | 51 | } |
| 86 | 52 | return 255; /* invalid */ | |
| 87 | fh = (__u32 *)&ifid; | ||
| 88 | return sb->s_export_op->find_exported_dentry(sb, fh, parent, acceptable, context); | ||
| 89 | } | 53 | } |
| 90 | 54 | ||
| 91 | |||
| 92 | STATIC int | 55 | STATIC int |
| 93 | xfs_fs_encode_fh( | 56 | xfs_fs_encode_fh( |
| 94 | struct dentry *dentry, | 57 | struct dentry *dentry, |
| @@ -96,21 +59,21 @@ xfs_fs_encode_fh( | |||
| 96 | int *max_len, | 59 | int *max_len, |
| 97 | int connectable) | 60 | int connectable) |
| 98 | { | 61 | { |
| 62 | struct fid *fid = (struct fid *)fh; | ||
| 63 | struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fh; | ||
| 99 | struct inode *inode = dentry->d_inode; | 64 | struct inode *inode = dentry->d_inode; |
| 100 | int type = 1; | 65 | int fileid_type; |
| 101 | __u32 *p = fh; | ||
| 102 | int len; | 66 | int len; |
| 103 | int is64 = 0; | ||
| 104 | #if XFS_BIG_INUMS | ||
| 105 | if (!(XFS_M(inode->i_sb)->m_flags & XFS_MOUNT_SMALL_INUMS)) { | ||
| 106 | /* filesystem may contain 64bit inode numbers */ | ||
| 107 | is64 = XFS_FILEID_TYPE_64FLAG; | ||
| 108 | } | ||
| 109 | #endif | ||
| 110 | 67 | ||
| 111 | /* Directories don't need their parent encoded, they have ".." */ | 68 | /* Directories don't need their parent encoded, they have ".." */ |
| 112 | if (S_ISDIR(inode->i_mode)) | 69 | if (S_ISDIR(inode->i_mode)) |
| 113 | connectable = 0; | 70 | fileid_type = FILEID_INO32_GEN; |
| 71 | else | ||
| 72 | fileid_type = FILEID_INO32_GEN_PARENT; | ||
| 73 | |||
| 74 | /* filesystem may contain 64bit inode numbers */ | ||
| 75 | if (!(XFS_M(inode->i_sb)->m_flags & XFS_MOUNT_SMALL_INUMS)) | ||
| 76 | fileid_type |= XFS_FILEID_TYPE_64FLAG; | ||
| 114 | 77 | ||
| 115 | /* | 78 | /* |
| 116 | * Only encode if there is enough space given. In practice | 79 | * Only encode if there is enough space given. In practice |
| @@ -118,39 +81,118 @@ xfs_fs_encode_fh( | |||
| 118 | * over NFSv2 with the subtree_check export option; the other | 81 | * over NFSv2 with the subtree_check export option; the other |
| 119 | * seven combinations work. The real answer is "don't use v2". | 82 | * seven combinations work. The real answer is "don't use v2". |
| 120 | */ | 83 | */ |
| 121 | len = xfs_fileid_length(connectable, is64); | 84 | len = xfs_fileid_length(fileid_type); |
| 122 | if (*max_len < len) | 85 | if (*max_len < len) |
| 123 | return 255; | 86 | return 255; |
| 124 | *max_len = len; | 87 | *max_len = len; |
| 125 | 88 | ||
| 126 | p = xfs_fileid_encode_inode(p, inode, is64); | 89 | switch (fileid_type) { |
| 127 | if (connectable) { | 90 | case FILEID_INO32_GEN_PARENT: |
| 128 | spin_lock(&dentry->d_lock); | 91 | spin_lock(&dentry->d_lock); |
| 129 | p = xfs_fileid_encode_inode(p, dentry->d_parent->d_inode, is64); | 92 | fid->i32.parent_ino = dentry->d_parent->d_inode->i_ino; |
| 93 | fid->i32.parent_gen = dentry->d_parent->d_inode->i_generation; | ||
| 130 | spin_unlock(&dentry->d_lock); | 94 | spin_unlock(&dentry->d_lock); |
| 131 | type = 2; | 95 | /*FALLTHRU*/ |
| 96 | case FILEID_INO32_GEN: | ||
| 97 | fid->i32.ino = inode->i_ino; | ||
| 98 | fid->i32.gen = inode->i_generation; | ||
| 99 | break; | ||
| 100 | case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: | ||
| 101 | spin_lock(&dentry->d_lock); | ||
| 102 | fid64->parent_ino = dentry->d_parent->d_inode->i_ino; | ||
| 103 | fid64->parent_gen = dentry->d_parent->d_inode->i_generation; | ||
| 104 | spin_unlock(&dentry->d_lock); | ||
| 105 | /*FALLTHRU*/ | ||
| 106 | case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG: | ||
| 107 | fid64->ino = inode->i_ino; | ||
| 108 | fid64->gen = inode->i_generation; | ||
| 109 | break; | ||
| 132 | } | 110 | } |
| 133 | BUG_ON((p - fh) != len); | 111 | |
| 134 | return type | is64; | 112 | return fileid_type; |
| 135 | } | 113 | } |
| 136 | 114 | ||
| 137 | STATIC struct dentry * | 115 | STATIC struct inode * |
| 138 | xfs_fs_get_dentry( | 116 | xfs_nfs_get_inode( |
| 139 | struct super_block *sb, | 117 | struct super_block *sb, |
| 140 | void *data) | 118 | u64 ino, |
| 141 | { | 119 | u32 generation) |
| 120 | { | ||
| 121 | xfs_fid_t xfid; | ||
| 142 | bhv_vnode_t *vp; | 122 | bhv_vnode_t *vp; |
| 143 | struct inode *inode; | ||
| 144 | struct dentry *result; | ||
| 145 | int error; | 123 | int error; |
| 146 | 124 | ||
| 147 | error = xfs_vget(XFS_M(sb), &vp, data); | 125 | xfid.fid_len = sizeof(xfs_fid_t) - sizeof(xfid.fid_len); |
| 148 | if (error || vp == NULL) | 126 | xfid.fid_pad = 0; |
| 149 | return ERR_PTR(-ESTALE) ; | 127 | xfid.fid_ino = ino; |
| 128 | xfid.fid_gen = generation; | ||
| 150 | 129 | ||
| 151 | inode = vn_to_inode(vp); | 130 | error = xfs_vget(XFS_M(sb), &vp, &xfid); |
| 131 | if (error) | ||
| 132 | return ERR_PTR(-error); | ||
| 133 | |||
| 134 | return vp ? vn_to_inode(vp) : NULL; | ||
| 135 | } | ||
| 136 | |||
| 137 | STATIC struct dentry * | ||
| 138 | xfs_fs_fh_to_dentry(struct super_block *sb, struct fid *fid, | ||
| 139 | int fh_len, int fileid_type) | ||
| 140 | { | ||
| 141 | struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fid; | ||
| 142 | struct inode *inode = NULL; | ||
| 143 | struct dentry *result; | ||
| 144 | |||
| 145 | if (fh_len < xfs_fileid_length(fileid_type)) | ||
| 146 | return NULL; | ||
| 147 | |||
| 148 | switch (fileid_type) { | ||
| 149 | case FILEID_INO32_GEN_PARENT: | ||
| 150 | case FILEID_INO32_GEN: | ||
| 151 | inode = xfs_nfs_get_inode(sb, fid->i32.ino, fid->i32.gen); | ||
| 152 | break; | ||
| 153 | case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: | ||
| 154 | case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG: | ||
| 155 | inode = xfs_nfs_get_inode(sb, fid64->ino, fid64->gen); | ||
| 156 | break; | ||
| 157 | } | ||
| 158 | |||
| 159 | if (!inode) | ||
| 160 | return NULL; | ||
| 161 | if (IS_ERR(inode)) | ||
| 162 | return ERR_PTR(PTR_ERR(inode)); | ||
| 163 | result = d_alloc_anon(inode); | ||
| 164 | if (!result) { | ||
| 165 | iput(inode); | ||
| 166 | return ERR_PTR(-ENOMEM); | ||
| 167 | } | ||
| 168 | return result; | ||
| 169 | } | ||
| 170 | |||
| 171 | STATIC struct dentry * | ||
| 172 | xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 173 | int fh_len, int fileid_type) | ||
| 174 | { | ||
| 175 | struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fid; | ||
| 176 | struct inode *inode = NULL; | ||
| 177 | struct dentry *result; | ||
| 178 | |||
| 179 | switch (fileid_type) { | ||
| 180 | case FILEID_INO32_GEN_PARENT: | ||
| 181 | inode = xfs_nfs_get_inode(sb, fid->i32.parent_ino, | ||
| 182 | fid->i32.parent_gen); | ||
| 183 | break; | ||
| 184 | case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: | ||
| 185 | inode = xfs_nfs_get_inode(sb, fid64->parent_ino, | ||
| 186 | fid64->parent_gen); | ||
| 187 | break; | ||
| 188 | } | ||
| 189 | |||
| 190 | if (!inode) | ||
| 191 | return NULL; | ||
| 192 | if (IS_ERR(inode)) | ||
| 193 | return ERR_PTR(PTR_ERR(inode)); | ||
| 152 | result = d_alloc_anon(inode); | 194 | result = d_alloc_anon(inode); |
| 153 | if (!result) { | 195 | if (!result) { |
| 154 | iput(inode); | 196 | iput(inode); |
| 155 | return ERR_PTR(-ENOMEM); | 197 | return ERR_PTR(-ENOMEM); |
| 156 | } | 198 | } |
| @@ -178,9 +220,9 @@ xfs_fs_get_parent( | |||
| 178 | return parent; | 220 | return parent; |
| 179 | } | 221 | } |
| 180 | 222 | ||
| 181 | struct export_operations xfs_export_operations = { | 223 | const struct export_operations xfs_export_operations = { |
| 182 | .decode_fh = xfs_fs_decode_fh, | ||
| 183 | .encode_fh = xfs_fs_encode_fh, | 224 | .encode_fh = xfs_fs_encode_fh, |
| 225 | .fh_to_dentry = xfs_fs_fh_to_dentry, | ||
| 226 | .fh_to_parent = xfs_fs_fh_to_parent, | ||
| 184 | .get_parent = xfs_fs_get_parent, | 227 | .get_parent = xfs_fs_get_parent, |
| 185 | .get_dentry = xfs_fs_get_dentry, | ||
| 186 | }; | 228 | }; |
diff --git a/fs/xfs/linux-2.6/xfs_export.h b/fs/xfs/linux-2.6/xfs_export.h index 2f36071a86f7..3272b6ae7a35 100644 --- a/fs/xfs/linux-2.6/xfs_export.h +++ b/fs/xfs/linux-2.6/xfs_export.h | |||
| @@ -59,50 +59,14 @@ | |||
| 59 | * a subdirectory) or use the "fsid" export option. | 59 | * a subdirectory) or use the "fsid" export option. |
| 60 | */ | 60 | */ |
| 61 | 61 | ||
| 62 | struct xfs_fid64 { | ||
| 63 | u64 ino; | ||
| 64 | u32 gen; | ||
| 65 | u64 parent_ino; | ||
| 66 | u32 parent_gen; | ||
| 67 | } __attribute__((packed)); | ||
| 68 | |||
| 62 | /* This flag goes on the wire. Don't play with it. */ | 69 | /* This flag goes on the wire. Don't play with it. */ |
| 63 | #define XFS_FILEID_TYPE_64FLAG 0x80 /* NFS fileid has 64bit inodes */ | 70 | #define XFS_FILEID_TYPE_64FLAG 0x80 /* NFS fileid has 64bit inodes */ |
| 64 | 71 | ||
| 65 | /* Calculate the length in u32 units of the fileid data */ | ||
| 66 | static inline int | ||
| 67 | xfs_fileid_length(int hasparent, int is64) | ||
| 68 | { | ||
| 69 | return hasparent ? (is64 ? 6 : 4) : (is64 ? 3 : 2); | ||
| 70 | } | ||
| 71 | |||
| 72 | /* | ||
| 73 | * Decode encoded inode information (either for the inode itself | ||
| 74 | * or the parent) into an xfs_fid_t structure. Advances and | ||
| 75 | * returns the new data pointer | ||
| 76 | */ | ||
| 77 | static inline __u32 * | ||
| 78 | xfs_fileid_decode_fid2(__u32 *p, xfs_fid_t *fid, int is64) | ||
| 79 | { | ||
| 80 | fid->fid_len = sizeof(xfs_fid_t) - sizeof(fid->fid_len); | ||
| 81 | fid->fid_pad = 0; | ||
| 82 | fid->fid_ino = *p++; | ||
| 83 | #if XFS_BIG_INUMS | ||
| 84 | if (is64) | ||
| 85 | fid->fid_ino |= (((__u64)(*p++)) << 32); | ||
| 86 | #endif | ||
| 87 | fid->fid_gen = *p++; | ||
| 88 | return p; | ||
| 89 | } | ||
| 90 | |||
| 91 | /* | ||
| 92 | * Encode inode information (either for the inode itself or the | ||
| 93 | * parent) into a fileid buffer. Advances and returns the new | ||
| 94 | * data pointer. | ||
| 95 | */ | ||
| 96 | static inline __u32 * | ||
| 97 | xfs_fileid_encode_inode(__u32 *p, struct inode *inode, int is64) | ||
| 98 | { | ||
| 99 | *p++ = (__u32)inode->i_ino; | ||
| 100 | #if XFS_BIG_INUMS | ||
| 101 | if (is64) | ||
| 102 | *p++ = (__u32)(inode->i_ino >> 32); | ||
| 103 | #endif | ||
| 104 | *p++ = inode->i_generation; | ||
| 105 | return p; | ||
| 106 | } | ||
| 107 | |||
| 108 | #endif /* __XFS_EXPORT_H__ */ | 72 | #endif /* __XFS_EXPORT_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h index c78c23310fe8..3efcf45b14ab 100644 --- a/fs/xfs/linux-2.6/xfs_super.h +++ b/fs/xfs/linux-2.6/xfs_super.h | |||
| @@ -118,7 +118,7 @@ extern int xfs_blkdev_get(struct xfs_mount *, const char *, | |||
| 118 | extern void xfs_blkdev_put(struct block_device *); | 118 | extern void xfs_blkdev_put(struct block_device *); |
| 119 | extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); | 119 | extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); |
| 120 | 120 | ||
| 121 | extern struct export_operations xfs_export_operations; | 121 | extern const struct export_operations xfs_export_operations; |
| 122 | 122 | ||
| 123 | #define XFS_M(sb) ((struct xfs_mount *)((sb)->s_fs_info)) | 123 | #define XFS_M(sb) ((struct xfs_mount *)((sb)->s_fs_info)) |
| 124 | 124 | ||
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index 4e5d3ca53a8e..a1b1b2ee3e51 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi/actbl1.h | |||
| @@ -257,7 +257,8 @@ struct acpi_table_dbgp { | |||
| 257 | struct acpi_table_dmar { | 257 | struct acpi_table_dmar { |
| 258 | struct acpi_table_header header; /* Common ACPI table header */ | 258 | struct acpi_table_header header; /* Common ACPI table header */ |
| 259 | u8 width; /* Host Address Width */ | 259 | u8 width; /* Host Address Width */ |
| 260 | u8 reserved[11]; | 260 | u8 flags; |
| 261 | u8 reserved[10]; | ||
| 261 | }; | 262 | }; |
| 262 | 263 | ||
| 263 | /* DMAR subtable header */ | 264 | /* DMAR subtable header */ |
| @@ -265,8 +266,6 @@ struct acpi_table_dmar { | |||
| 265 | struct acpi_dmar_header { | 266 | struct acpi_dmar_header { |
| 266 | u16 type; | 267 | u16 type; |
| 267 | u16 length; | 268 | u16 length; |
| 268 | u8 flags; | ||
| 269 | u8 reserved[3]; | ||
| 270 | }; | 269 | }; |
| 271 | 270 | ||
| 272 | /* Values for subtable type in struct acpi_dmar_header */ | 271 | /* Values for subtable type in struct acpi_dmar_header */ |
| @@ -274,13 +273,15 @@ struct acpi_dmar_header { | |||
| 274 | enum acpi_dmar_type { | 273 | enum acpi_dmar_type { |
| 275 | ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, | 274 | ACPI_DMAR_TYPE_HARDWARE_UNIT = 0, |
| 276 | ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, | 275 | ACPI_DMAR_TYPE_RESERVED_MEMORY = 1, |
| 277 | ACPI_DMAR_TYPE_RESERVED = 2 /* 2 and greater are reserved */ | 276 | ACPI_DMAR_TYPE_ATSR = 2, |
| 277 | ACPI_DMAR_TYPE_RESERVED = 3 /* 3 and greater are reserved */ | ||
| 278 | }; | 278 | }; |
| 279 | 279 | ||
| 280 | struct acpi_dmar_device_scope { | 280 | struct acpi_dmar_device_scope { |
| 281 | u8 entry_type; | 281 | u8 entry_type; |
| 282 | u8 length; | 282 | u8 length; |
| 283 | u8 segment; | 283 | u16 reserved; |
| 284 | u8 enumeration_id; | ||
| 284 | u8 bus; | 285 | u8 bus; |
| 285 | }; | 286 | }; |
| 286 | 287 | ||
| @@ -290,7 +291,14 @@ enum acpi_dmar_scope_type { | |||
| 290 | ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, | 291 | ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, |
| 291 | ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, | 292 | ACPI_DMAR_SCOPE_TYPE_ENDPOINT = 1, |
| 292 | ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, | 293 | ACPI_DMAR_SCOPE_TYPE_BRIDGE = 2, |
| 293 | ACPI_DMAR_SCOPE_TYPE_RESERVED = 3 /* 3 and greater are reserved */ | 294 | ACPI_DMAR_SCOPE_TYPE_IOAPIC = 3, |
| 295 | ACPI_DMAR_SCOPE_TYPE_HPET = 4, | ||
| 296 | ACPI_DMAR_SCOPE_TYPE_RESERVED = 5 /* 5 and greater are reserved */ | ||
| 297 | }; | ||
| 298 | |||
| 299 | struct acpi_dmar_pci_path { | ||
| 300 | u8 dev; | ||
| 301 | u8 fn; | ||
| 294 | }; | 302 | }; |
| 295 | 303 | ||
| 296 | /* | 304 | /* |
| @@ -301,6 +309,9 @@ enum acpi_dmar_scope_type { | |||
| 301 | 309 | ||
| 302 | struct acpi_dmar_hardware_unit { | 310 | struct acpi_dmar_hardware_unit { |
| 303 | struct acpi_dmar_header header; | 311 | struct acpi_dmar_header header; |
| 312 | u8 flags; | ||
| 313 | u8 reserved; | ||
| 314 | u16 segment; | ||
| 304 | u64 address; /* Register Base Address */ | 315 | u64 address; /* Register Base Address */ |
| 305 | }; | 316 | }; |
| 306 | 317 | ||
| @@ -312,7 +323,9 @@ struct acpi_dmar_hardware_unit { | |||
| 312 | 323 | ||
| 313 | struct acpi_dmar_reserved_memory { | 324 | struct acpi_dmar_reserved_memory { |
| 314 | struct acpi_dmar_header header; | 325 | struct acpi_dmar_header header; |
| 315 | u64 address; /* 4_k aligned base address */ | 326 | u16 reserved; |
| 327 | u16 segment; | ||
| 328 | u64 base_address; /* 4_k aligned base address */ | ||
| 316 | u64 end_address; /* 4_k aligned limit address */ | 329 | u64 end_address; /* 4_k aligned limit address */ |
| 317 | }; | 330 | }; |
| 318 | 331 | ||
diff --git a/include/asm-alpha/scatterlist.h b/include/asm-alpha/scatterlist.h index 917365405e83..440747ca6349 100644 --- a/include/asm-alpha/scatterlist.h +++ b/include/asm-alpha/scatterlist.h | |||
| @@ -5,7 +5,10 @@ | |||
| 5 | #include <asm/types.h> | 5 | #include <asm/types.h> |
| 6 | 6 | ||
| 7 | struct scatterlist { | 7 | struct scatterlist { |
| 8 | struct page *page; | 8 | #ifdef CONFIG_DEBUG_SG |
| 9 | unsigned long sg_magic; | ||
| 10 | #endif | ||
| 11 | unsigned long page_link; | ||
| 9 | unsigned int offset; | 12 | unsigned int offset; |
| 10 | 13 | ||
| 11 | unsigned int length; | 14 | unsigned int length; |
diff --git a/include/asm-arm/scatterlist.h b/include/asm-arm/scatterlist.h index de2f65eb42ed..ca0a37d03400 100644 --- a/include/asm-arm/scatterlist.h +++ b/include/asm-arm/scatterlist.h | |||
| @@ -5,7 +5,10 @@ | |||
| 5 | #include <asm/types.h> | 5 | #include <asm/types.h> |
| 6 | 6 | ||
| 7 | struct scatterlist { | 7 | struct scatterlist { |
| 8 | struct page *page; /* buffer page */ | 8 | #ifdef CONFIG_DEBUG_SG |
| 9 | unsigned long sg_magic; | ||
| 10 | #endif | ||
| 11 | unsigned long page_link; | ||
| 9 | unsigned int offset; /* buffer offset */ | 12 | unsigned int offset; /* buffer offset */ |
| 10 | dma_addr_t dma_address; /* dma address */ | 13 | dma_addr_t dma_address; /* dma address */ |
| 11 | unsigned int length; /* length */ | 14 | unsigned int length; /* length */ |
diff --git a/include/asm-avr32/scatterlist.h b/include/asm-avr32/scatterlist.h index c6d5ce3b3a25..377320e3bd17 100644 --- a/include/asm-avr32/scatterlist.h +++ b/include/asm-avr32/scatterlist.h | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
| 5 | 5 | ||
| 6 | struct scatterlist { | 6 | struct scatterlist { |
| 7 | struct page *page; | 7 | #ifdef CONFIG_DEBUG_SG |
| 8 | unsigned long sg_magic; | ||
| 9 | #endif | ||
| 10 | unsigned long page_link; | ||
| 8 | unsigned int offset; | 11 | unsigned int offset; |
| 9 | dma_addr_t dma_address; | 12 | dma_addr_t dma_address; |
| 10 | unsigned int length; | 13 | unsigned int length; |
diff --git a/include/asm-blackfin/scatterlist.h b/include/asm-blackfin/scatterlist.h index 60e07b92044c..32128d53469b 100644 --- a/include/asm-blackfin/scatterlist.h +++ b/include/asm-blackfin/scatterlist.h | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | #include <linux/mm.h> | 4 | #include <linux/mm.h> |
| 5 | 5 | ||
| 6 | struct scatterlist { | 6 | struct scatterlist { |
| 7 | struct page *page; | 7 | #ifdef CONFIG_DEBUG_SG |
| 8 | unsigned long sg_magic; | ||
| 9 | #endif | ||
| 10 | unsigned long page_link; | ||
| 8 | unsigned int offset; | 11 | unsigned int offset; |
| 9 | dma_addr_t dma_address; | 12 | dma_addr_t dma_address; |
| 10 | unsigned int length; | 13 | unsigned int length; |
diff --git a/include/asm-cris/scatterlist.h b/include/asm-cris/scatterlist.h index 4bdc44c4ac3d..faff53ad1f96 100644 --- a/include/asm-cris/scatterlist.h +++ b/include/asm-cris/scatterlist.h | |||
| @@ -2,11 +2,14 @@ | |||
| 2 | #define __ASM_CRIS_SCATTERLIST_H | 2 | #define __ASM_CRIS_SCATTERLIST_H |
| 3 | 3 | ||
| 4 | struct scatterlist { | 4 | struct scatterlist { |
| 5 | #ifdef CONFIG_DEBUG_SG | ||
| 6 | unsigned long sg_magic; | ||
| 7 | #endif | ||
| 5 | char * address; /* Location data is to be transferred to */ | 8 | char * address; /* Location data is to be transferred to */ |
| 6 | unsigned int length; | 9 | unsigned int length; |
| 7 | 10 | ||
| 8 | /* The following is i386 highmem junk - not used by us */ | 11 | /* The following is i386 highmem junk - not used by us */ |
| 9 | struct page * page; /* Location for highmem page, if any */ | 12 | unsigned long page_link; |
| 10 | unsigned int offset;/* for highmem, page offset */ | 13 | unsigned int offset;/* for highmem, page offset */ |
| 11 | 14 | ||
| 12 | }; | 15 | }; |
diff --git a/include/asm-frv/scatterlist.h b/include/asm-frv/scatterlist.h index 8e827fa853f1..f7da007b763c 100644 --- a/include/asm-frv/scatterlist.h +++ b/include/asm-frv/scatterlist.h | |||
| @@ -22,7 +22,10 @@ | |||
| 22 | * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens | 22 | * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens |
| 23 | */ | 23 | */ |
| 24 | struct scatterlist { | 24 | struct scatterlist { |
| 25 | struct page *page; /* Location for highmem page, if any */ | 25 | #ifdef CONFIG_DEBUG_SG |
| 26 | unsigned long sg_magic; | ||
| 27 | #endif | ||
| 28 | unsigned long page_link; | ||
| 26 | unsigned int offset; /* for highmem, page offset */ | 29 | unsigned int offset; /* for highmem, page offset */ |
| 27 | 30 | ||
| 28 | dma_addr_t dma_address; | 31 | dma_addr_t dma_address; |
diff --git a/include/asm-h8300/scatterlist.h b/include/asm-h8300/scatterlist.h index 985fdf54eaca..d3ecdd87ac90 100644 --- a/include/asm-h8300/scatterlist.h +++ b/include/asm-h8300/scatterlist.h | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
| 5 | 5 | ||
| 6 | struct scatterlist { | 6 | struct scatterlist { |
| 7 | struct page *page; | 7 | #ifdef CONFIG_DEBUG_SG |
| 8 | unsigned long sg_magic; | ||
| 9 | #endif | ||
| 10 | unsigned long page_link; | ||
| 8 | unsigned int offset; | 11 | unsigned int offset; |
| 9 | dma_addr_t dma_address; | 12 | dma_addr_t dma_address; |
| 10 | unsigned int length; | 13 | unsigned int length; |
diff --git a/include/asm-ia64/scatterlist.h b/include/asm-ia64/scatterlist.h index 7d5234d50312..d6f57874041d 100644 --- a/include/asm-ia64/scatterlist.h +++ b/include/asm-ia64/scatterlist.h | |||
| @@ -9,7 +9,10 @@ | |||
| 9 | #include <asm/types.h> | 9 | #include <asm/types.h> |
| 10 | 10 | ||
| 11 | struct scatterlist { | 11 | struct scatterlist { |
| 12 | struct page *page; | 12 | #ifdef CONFIG_DEBUG_SG |
| 13 | unsigned long sg_magic; | ||
| 14 | #endif | ||
| 15 | unsigned long page_link; | ||
| 13 | unsigned int offset; | 16 | unsigned int offset; |
| 14 | unsigned int length; /* buffer length */ | 17 | unsigned int length; /* buffer length */ |
| 15 | 18 | ||
diff --git a/include/asm-m32r/scatterlist.h b/include/asm-m32r/scatterlist.h index 352415ff5eb9..1ed372c73d0b 100644 --- a/include/asm-m32r/scatterlist.h +++ b/include/asm-m32r/scatterlist.h | |||
| @@ -4,9 +4,12 @@ | |||
| 4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
| 5 | 5 | ||
| 6 | struct scatterlist { | 6 | struct scatterlist { |
| 7 | #ifdef CONFIG_DEBUG_SG | ||
| 8 | unsigned long sg_magic; | ||
| 9 | #endif | ||
| 7 | char * address; /* Location data is to be transferred to, NULL for | 10 | char * address; /* Location data is to be transferred to, NULL for |
| 8 | * highmem page */ | 11 | * highmem page */ |
| 9 | struct page * page; /* Location for highmem page, if any */ | 12 | unsigned long page_link; |
| 10 | unsigned int offset;/* for highmem, page offset */ | 13 | unsigned int offset;/* for highmem, page offset */ |
| 11 | 14 | ||
| 12 | dma_addr_t dma_address; | 15 | dma_addr_t dma_address; |
diff --git a/include/asm-m68k/scatterlist.h b/include/asm-m68k/scatterlist.h index 24887a2d9c7b..d3a7a0edfeca 100644 --- a/include/asm-m68k/scatterlist.h +++ b/include/asm-m68k/scatterlist.h | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
| 5 | 5 | ||
| 6 | struct scatterlist { | 6 | struct scatterlist { |
| 7 | struct page *page; | 7 | #ifdef CONFIG_DEBUG_SG |
| 8 | unsigned long sg_magic; | ||
| 9 | #endif | ||
| 10 | unsigned long page_link; | ||
| 8 | unsigned int offset; | 11 | unsigned int offset; |
| 9 | unsigned int length; | 12 | unsigned int length; |
| 10 | 13 | ||
diff --git a/include/asm-m68knommu/scatterlist.h b/include/asm-m68knommu/scatterlist.h index 4da79d3d3f34..10942840e88f 100644 --- a/include/asm-m68knommu/scatterlist.h +++ b/include/asm-m68knommu/scatterlist.h | |||
| @@ -5,7 +5,10 @@ | |||
| 5 | #include <asm/types.h> | 5 | #include <asm/types.h> |
| 6 | 6 | ||
| 7 | struct scatterlist { | 7 | struct scatterlist { |
| 8 | struct page *page; | 8 | #ifdef CONFIG_DEBUG_SG |
| 9 | unsigned long sg_magic; | ||
| 10 | #endif | ||
| 11 | unsigned long page_link; | ||
| 9 | unsigned int offset; | 12 | unsigned int offset; |
| 10 | dma_addr_t dma_address; | 13 | dma_addr_t dma_address; |
| 11 | unsigned int length; | 14 | unsigned int length; |
diff --git a/include/asm-mips/scatterlist.h b/include/asm-mips/scatterlist.h index 7af104c95b20..83d69fe17c9f 100644 --- a/include/asm-mips/scatterlist.h +++ b/include/asm-mips/scatterlist.h | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
| 5 | 5 | ||
| 6 | struct scatterlist { | 6 | struct scatterlist { |
| 7 | struct page * page; | 7 | #ifdef CONFIG_DEBUG_SG |
| 8 | unsigned long sg_magic; | ||
| 9 | #endif | ||
| 10 | unsigned long page_link; | ||
| 8 | unsigned int offset; | 11 | unsigned int offset; |
| 9 | dma_addr_t dma_address; | 12 | dma_addr_t dma_address; |
| 10 | unsigned int length; | 13 | unsigned int length; |
diff --git a/include/asm-parisc/scatterlist.h b/include/asm-parisc/scatterlist.h index e7211c748446..cd3cfdf82289 100644 --- a/include/asm-parisc/scatterlist.h +++ b/include/asm-parisc/scatterlist.h | |||
| @@ -5,7 +5,10 @@ | |||
| 5 | #include <asm/types.h> | 5 | #include <asm/types.h> |
| 6 | 6 | ||
| 7 | struct scatterlist { | 7 | struct scatterlist { |
| 8 | struct page *page; | 8 | #ifdef CONFIG_DEBUG_SG |
| 9 | unsigned long sg_magic; | ||
| 10 | #endif | ||
| 11 | unsigned long page_link; | ||
| 9 | unsigned int offset; | 12 | unsigned int offset; |
| 10 | 13 | ||
| 11 | unsigned int length; | 14 | unsigned int length; |
diff --git a/include/asm-powerpc/scatterlist.h b/include/asm-powerpc/scatterlist.h index b075f619c3b7..fcf7d55afe45 100644 --- a/include/asm-powerpc/scatterlist.h +++ b/include/asm-powerpc/scatterlist.h | |||
| @@ -14,7 +14,10 @@ | |||
| 14 | #include <asm/dma.h> | 14 | #include <asm/dma.h> |
| 15 | 15 | ||
| 16 | struct scatterlist { | 16 | struct scatterlist { |
| 17 | struct page *page; | 17 | #ifdef CONFIG_DEBUG_SG |
| 18 | unsigned long sg_magic; | ||
| 19 | #endif | ||
| 20 | unsigned long page_link; | ||
| 18 | unsigned int offset; | 21 | unsigned int offset; |
| 19 | unsigned int length; | 22 | unsigned int length; |
| 20 | 23 | ||
diff --git a/include/asm-ppc/system.h b/include/asm-ppc/system.h index cc45780421ca..51df94c73846 100644 --- a/include/asm-ppc/system.h +++ b/include/asm-ppc/system.h | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | 33 | ||
| 34 | #define set_mb(var, value) do { var = value; mb(); } while (0) | 34 | #define set_mb(var, value) do { var = value; mb(); } while (0) |
| 35 | 35 | ||
| 36 | #define AT_VECTOR_SIZE_ARCH 6 /* entries in ARCH_DLINFO */ | ||
| 36 | #ifdef CONFIG_SMP | 37 | #ifdef CONFIG_SMP |
| 37 | #define smp_mb() mb() | 38 | #define smp_mb() mb() |
| 38 | #define smp_rmb() rmb() | 39 | #define smp_rmb() rmb() |
diff --git a/include/asm-s390/scatterlist.h b/include/asm-s390/scatterlist.h index a43b3afc5e2d..29ec8e28c8df 100644 --- a/include/asm-s390/scatterlist.h +++ b/include/asm-s390/scatterlist.h | |||
| @@ -2,7 +2,10 @@ | |||
| 2 | #define _ASMS390_SCATTERLIST_H | 2 | #define _ASMS390_SCATTERLIST_H |
| 3 | 3 | ||
| 4 | struct scatterlist { | 4 | struct scatterlist { |
| 5 | struct page *page; | 5 | #ifdef CONFIG_DEBUG_SG |
| 6 | unsigned long sg_magic; | ||
| 7 | #endif | ||
| 8 | unsigned long page_link; | ||
| 6 | unsigned int offset; | 9 | unsigned int offset; |
| 7 | unsigned int length; | 10 | unsigned int length; |
| 8 | }; | 11 | }; |
diff --git a/include/asm-sh/scatterlist.h b/include/asm-sh/scatterlist.h index b9ae53c38365..a7d0d1856a99 100644 --- a/include/asm-sh/scatterlist.h +++ b/include/asm-sh/scatterlist.h | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
| 5 | 5 | ||
| 6 | struct scatterlist { | 6 | struct scatterlist { |
| 7 | struct page * page; /* Location for highmem page, if any */ | 7 | #ifdef CONFIG_DEBUG_SG |
| 8 | unsigned long sg_magic; | ||
| 9 | #endif | ||
| 10 | unsigned long page_link; | ||
| 8 | unsigned int offset;/* for highmem, page offset */ | 11 | unsigned int offset;/* for highmem, page offset */ |
| 9 | dma_addr_t dma_address; | 12 | dma_addr_t dma_address; |
| 10 | unsigned int length; | 13 | unsigned int length; |
diff --git a/include/asm-sh64/scatterlist.h b/include/asm-sh64/scatterlist.h index 1c723f2d7a95..5109251970e7 100644 --- a/include/asm-sh64/scatterlist.h +++ b/include/asm-sh64/scatterlist.h | |||
| @@ -14,7 +14,10 @@ | |||
| 14 | #include <asm/types.h> | 14 | #include <asm/types.h> |
| 15 | 15 | ||
| 16 | struct scatterlist { | 16 | struct scatterlist { |
| 17 | struct page * page; /* Location for highmem page, if any */ | 17 | #ifdef CONFIG_DEBUG_SG |
| 18 | unsigned long sg_magic; | ||
| 19 | #endif | ||
| 20 | unsigned long page_link; | ||
| 18 | unsigned int offset;/* for highmem, page offset */ | 21 | unsigned int offset;/* for highmem, page offset */ |
| 19 | dma_addr_t dma_address; | 22 | dma_addr_t dma_address; |
| 20 | unsigned int length; | 23 | unsigned int length; |
diff --git a/include/asm-sparc/scatterlist.h b/include/asm-sparc/scatterlist.h index 4055af90ad7e..e08d3d775b08 100644 --- a/include/asm-sparc/scatterlist.h +++ b/include/asm-sparc/scatterlist.h | |||
| @@ -5,7 +5,10 @@ | |||
| 5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
| 6 | 6 | ||
| 7 | struct scatterlist { | 7 | struct scatterlist { |
| 8 | struct page *page; | 8 | #ifdef CONFIG_DEBUG_SG |
| 9 | unsigned long sg_magic; | ||
| 10 | #endif | ||
| 11 | unsigned long page_link; | ||
| 9 | unsigned int offset; | 12 | unsigned int offset; |
| 10 | 13 | ||
| 11 | unsigned int length; | 14 | unsigned int length; |
diff --git a/include/asm-sparc64/scatterlist.h b/include/asm-sparc64/scatterlist.h index 703c5bbe6c8c..6df23f070b1a 100644 --- a/include/asm-sparc64/scatterlist.h +++ b/include/asm-sparc64/scatterlist.h | |||
| @@ -6,7 +6,10 @@ | |||
| 6 | #include <asm/types.h> | 6 | #include <asm/types.h> |
| 7 | 7 | ||
| 8 | struct scatterlist { | 8 | struct scatterlist { |
| 9 | struct page *page; | 9 | #ifdef CONFIG_DEBUG_SG |
| 10 | unsigned long sg_magic; | ||
| 11 | #endif | ||
| 12 | unsigned long page_link; | ||
| 10 | unsigned int offset; | 13 | unsigned int offset; |
| 11 | 14 | ||
| 12 | unsigned int length; | 15 | unsigned int length; |
diff --git a/include/asm-v850/scatterlist.h b/include/asm-v850/scatterlist.h index 56f402920db9..02d27b3fb061 100644 --- a/include/asm-v850/scatterlist.h +++ b/include/asm-v850/scatterlist.h | |||
| @@ -17,7 +17,10 @@ | |||
| 17 | #include <asm/types.h> | 17 | #include <asm/types.h> |
| 18 | 18 | ||
| 19 | struct scatterlist { | 19 | struct scatterlist { |
| 20 | struct page *page; | 20 | #ifdef CONFIG_DEBUG_SG |
| 21 | unsigned long sg_magic; | ||
| 22 | #endif | ||
| 23 | unsigned long page_link; | ||
| 21 | unsigned offset; | 24 | unsigned offset; |
| 22 | dma_addr_t dma_address; | 25 | dma_addr_t dma_address; |
| 23 | unsigned length; | 26 | unsigned length; |
diff --git a/include/asm-x86/bootparam.h b/include/asm-x86/bootparam.h index ef67b59dbdb9..dc031cf44633 100644 --- a/include/asm-x86/bootparam.h +++ b/include/asm-x86/bootparam.h | |||
| @@ -28,8 +28,9 @@ struct setup_header { | |||
| 28 | u16 kernel_version; | 28 | u16 kernel_version; |
| 29 | u8 type_of_loader; | 29 | u8 type_of_loader; |
| 30 | u8 loadflags; | 30 | u8 loadflags; |
| 31 | #define LOADED_HIGH 0x01 | 31 | #define LOADED_HIGH (1<<0) |
| 32 | #define CAN_USE_HEAP 0x80 | 32 | #define KEEP_SEGMENTS (1<<6) |
| 33 | #define CAN_USE_HEAP (1<<7) | ||
| 33 | u16 setup_move_size; | 34 | u16 setup_move_size; |
| 34 | u32 code32_start; | 35 | u32 code32_start; |
| 35 | u32 ramdisk_image; | 36 | u32 ramdisk_image; |
| @@ -41,6 +42,10 @@ struct setup_header { | |||
| 41 | u32 initrd_addr_max; | 42 | u32 initrd_addr_max; |
| 42 | u32 kernel_alignment; | 43 | u32 kernel_alignment; |
| 43 | u8 relocatable_kernel; | 44 | u8 relocatable_kernel; |
| 45 | u8 _pad2[3]; | ||
| 46 | u32 cmdline_size; | ||
| 47 | u32 hardware_subarch; | ||
| 48 | u64 hardware_subarch_data; | ||
| 44 | } __attribute__((packed)); | 49 | } __attribute__((packed)); |
| 45 | 50 | ||
| 46 | struct sys_desc_table { | 51 | struct sys_desc_table { |
diff --git a/include/asm-x86/cacheflush.h b/include/asm-x86/cacheflush.h index b3d43de44c59..9411a2d3f19c 100644 --- a/include/asm-x86/cacheflush.h +++ b/include/asm-x86/cacheflush.h | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | void global_flush_tlb(void); | 27 | void global_flush_tlb(void); |
| 28 | int change_page_attr(struct page *page, int numpages, pgprot_t prot); | 28 | int change_page_attr(struct page *page, int numpages, pgprot_t prot); |
| 29 | int change_page_attr_addr(unsigned long addr, int numpages, pgprot_t prot); | 29 | int change_page_attr_addr(unsigned long addr, int numpages, pgprot_t prot); |
| 30 | void clflush_cache_range(void *addr, int size); | ||
| 30 | 31 | ||
| 31 | #ifdef CONFIG_DEBUG_PAGEALLOC | 32 | #ifdef CONFIG_DEBUG_PAGEALLOC |
| 32 | /* internal debugging function */ | 33 | /* internal debugging function */ |
diff --git a/include/asm-x86/device.h b/include/asm-x86/device.h index d9ee5e52e91b..87a715367a1b 100644 --- a/include/asm-x86/device.h +++ b/include/asm-x86/device.h | |||
| @@ -5,6 +5,9 @@ struct dev_archdata { | |||
| 5 | #ifdef CONFIG_ACPI | 5 | #ifdef CONFIG_ACPI |
| 6 | void *acpi_handle; | 6 | void *acpi_handle; |
| 7 | #endif | 7 | #endif |
| 8 | #ifdef CONFIG_DMAR | ||
| 9 | void *iommu; /* hook for IOMMU specific extension */ | ||
| 10 | #endif | ||
| 8 | }; | 11 | }; |
| 9 | 12 | ||
| 10 | #endif /* _ASM_X86_DEVICE_H */ | 13 | #endif /* _ASM_X86_DEVICE_H */ |
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h index 6a2d26cb5da6..55f01bd9e556 100644 --- a/include/asm-x86/dma-mapping_32.h +++ b/include/asm-x86/dma-mapping_32.h | |||
| @@ -45,9 +45,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, | |||
| 45 | WARN_ON(nents == 0 || sglist[0].length == 0); | 45 | WARN_ON(nents == 0 || sglist[0].length == 0); |
| 46 | 46 | ||
| 47 | for_each_sg(sglist, sg, nents, i) { | 47 | for_each_sg(sglist, sg, nents, i) { |
| 48 | BUG_ON(!sg->page); | 48 | BUG_ON(!sg_page(sg)); |
| 49 | 49 | ||
| 50 | sg->dma_address = page_to_phys(sg->page) + sg->offset; | 50 | sg->dma_address = sg_phys(sg); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | flush_write_buffers(); | 53 | flush_write_buffers(); |
diff --git a/include/asm-x86/scatterlist_32.h b/include/asm-x86/scatterlist_32.h index bd5164aa8f63..0e7d997a34be 100644 --- a/include/asm-x86/scatterlist_32.h +++ b/include/asm-x86/scatterlist_32.h | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
| 5 | 5 | ||
| 6 | struct scatterlist { | 6 | struct scatterlist { |
| 7 | struct page *page; | 7 | #ifdef CONFIG_DEBUG_SG |
| 8 | unsigned long sg_magic; | ||
| 9 | #endif | ||
| 10 | unsigned long page_link; | ||
| 8 | unsigned int offset; | 11 | unsigned int offset; |
| 9 | dma_addr_t dma_address; | 12 | dma_addr_t dma_address; |
| 10 | unsigned int length; | 13 | unsigned int length; |
diff --git a/include/asm-x86/scatterlist_64.h b/include/asm-x86/scatterlist_64.h index ef3986ba4b79..1847c72befeb 100644 --- a/include/asm-x86/scatterlist_64.h +++ b/include/asm-x86/scatterlist_64.h | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | #include <asm/types.h> | 4 | #include <asm/types.h> |
| 5 | 5 | ||
| 6 | struct scatterlist { | 6 | struct scatterlist { |
| 7 | struct page *page; | 7 | #ifdef CONFIG_DEBUG_SG |
| 8 | unsigned long sg_magic; | ||
| 9 | #endif | ||
| 10 | unsigned long page_link; | ||
| 8 | unsigned int offset; | 11 | unsigned int offset; |
| 9 | unsigned int length; | 12 | unsigned int length; |
| 10 | dma_addr_t dma_address; | 13 | dma_addr_t dma_address; |
diff --git a/include/asm-xtensa/scatterlist.h b/include/asm-xtensa/scatterlist.h index ca337a294290..810080bb0a2b 100644 --- a/include/asm-xtensa/scatterlist.h +++ b/include/asm-xtensa/scatterlist.h | |||
| @@ -14,7 +14,10 @@ | |||
| 14 | #include <asm/types.h> | 14 | #include <asm/types.h> |
| 15 | 15 | ||
| 16 | struct scatterlist { | 16 | struct scatterlist { |
| 17 | struct page *page; | 17 | #ifdef CONFIG_DEBUG_SG |
| 18 | unsigned long sg_magic; | ||
| 19 | #endif | ||
| 20 | unsigned long page_link; | ||
| 18 | unsigned int offset; | 21 | unsigned int offset; |
| 19 | dma_addr_t dma_address; | 22 | dma_addr_t dma_address; |
| 20 | unsigned int length; | 23 | unsigned int length; |
diff --git a/include/linux/capability.h b/include/linux/capability.h index 7a8d7ade28a0..bb017edffd56 100644 --- a/include/linux/capability.h +++ b/include/linux/capability.h | |||
| @@ -56,10 +56,8 @@ typedef struct __user_cap_data_struct { | |||
| 56 | 56 | ||
| 57 | struct vfs_cap_data { | 57 | struct vfs_cap_data { |
| 58 | __u32 magic_etc; /* Little endian */ | 58 | __u32 magic_etc; /* Little endian */ |
| 59 | struct { | 59 | __u32 permitted; /* Little endian */ |
| 60 | __u32 permitted; /* Little endian */ | 60 | __u32 inheritable; /* Little endian */ |
| 61 | __u32 inheritable; /* Little endian */ | ||
| 62 | } data[1]; | ||
| 63 | }; | 61 | }; |
| 64 | 62 | ||
| 65 | #ifdef __KERNEL__ | 63 | #ifdef __KERNEL__ |
diff --git a/include/linux/dmar.h b/include/linux/dmar.h new file mode 100644 index 000000000000..ffb6439cb5e6 --- /dev/null +++ b/include/linux/dmar.h | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2006, Intel Corporation. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License along with | ||
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
| 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. | ||
| 16 | * | ||
| 17 | * Copyright (C) Ashok Raj <ashok.raj@intel.com> | ||
| 18 | * Copyright (C) Shaohua Li <shaohua.li@intel.com> | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef __DMAR_H__ | ||
| 22 | #define __DMAR_H__ | ||
| 23 | |||
| 24 | #include <linux/acpi.h> | ||
| 25 | #include <linux/types.h> | ||
| 26 | #include <linux/msi.h> | ||
| 27 | |||
| 28 | #ifdef CONFIG_DMAR | ||
| 29 | struct intel_iommu; | ||
| 30 | |||
| 31 | extern char *dmar_get_fault_reason(u8 fault_reason); | ||
| 32 | |||
| 33 | /* Can't use the common MSI interrupt functions | ||
| 34 | * since DMAR is not a pci device | ||
| 35 | */ | ||
| 36 | extern void dmar_msi_unmask(unsigned int irq); | ||
| 37 | extern void dmar_msi_mask(unsigned int irq); | ||
| 38 | extern void dmar_msi_read(int irq, struct msi_msg *msg); | ||
| 39 | extern void dmar_msi_write(int irq, struct msi_msg *msg); | ||
| 40 | extern int dmar_set_interrupt(struct intel_iommu *iommu); | ||
| 41 | extern int arch_setup_dmar_msi(unsigned int irq); | ||
| 42 | |||
| 43 | /* Intel IOMMU detection and initialization functions */ | ||
| 44 | extern void detect_intel_iommu(void); | ||
| 45 | extern int intel_iommu_init(void); | ||
| 46 | |||
| 47 | extern int dmar_table_init(void); | ||
| 48 | extern int early_dmar_detect(void); | ||
| 49 | |||
| 50 | extern struct list_head dmar_drhd_units; | ||
| 51 | extern struct list_head dmar_rmrr_units; | ||
| 52 | |||
| 53 | struct dmar_drhd_unit { | ||
| 54 | struct list_head list; /* list of drhd units */ | ||
| 55 | u64 reg_base_addr; /* register base address*/ | ||
| 56 | struct pci_dev **devices; /* target device array */ | ||
| 57 | int devices_cnt; /* target device count */ | ||
| 58 | u8 ignored:1; /* ignore drhd */ | ||
| 59 | u8 include_all:1; | ||
| 60 | struct intel_iommu *iommu; | ||
| 61 | }; | ||
| 62 | |||
| 63 | struct dmar_rmrr_unit { | ||
| 64 | struct list_head list; /* list of rmrr units */ | ||
| 65 | u64 base_address; /* reserved base address*/ | ||
| 66 | u64 end_address; /* reserved end address */ | ||
| 67 | struct pci_dev **devices; /* target devices */ | ||
| 68 | int devices_cnt; /* target device count */ | ||
| 69 | }; | ||
| 70 | |||
| 71 | #define for_each_drhd_unit(drhd) \ | ||
| 72 | list_for_each_entry(drhd, &dmar_drhd_units, list) | ||
| 73 | #define for_each_rmrr_units(rmrr) \ | ||
| 74 | list_for_each_entry(rmrr, &dmar_rmrr_units, list) | ||
| 75 | #else | ||
| 76 | static inline void detect_intel_iommu(void) | ||
| 77 | { | ||
| 78 | return; | ||
| 79 | } | ||
| 80 | static inline int intel_iommu_init(void) | ||
| 81 | { | ||
| 82 | return -ENODEV; | ||
| 83 | } | ||
| 84 | |||
| 85 | #endif /* !CONFIG_DMAR */ | ||
| 86 | #endif /* __DMAR_H__ */ | ||
diff --git a/include/linux/efi.h b/include/linux/efi.h index 0b9579a4cd42..14813b595802 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h | |||
| @@ -298,7 +298,7 @@ extern int efi_mem_attribute_range (unsigned long phys_addr, unsigned long size, | |||
| 298 | u64 attr); | 298 | u64 attr); |
| 299 | extern int __init efi_uart_console_only (void); | 299 | extern int __init efi_uart_console_only (void); |
| 300 | extern void efi_initialize_iomem_resources(struct resource *code_resource, | 300 | extern void efi_initialize_iomem_resources(struct resource *code_resource, |
| 301 | struct resource *data_resource); | 301 | struct resource *data_resource, struct resource *bss_resource); |
| 302 | extern unsigned long efi_get_time(void); | 302 | extern unsigned long efi_get_time(void); |
| 303 | extern int efi_set_rtc_mmss(unsigned long nowtime); | 303 | extern int efi_set_rtc_mmss(unsigned long nowtime); |
| 304 | extern int is_available_memory(efi_memory_desc_t * md); | 304 | extern int is_available_memory(efi_memory_desc_t * md); |
diff --git a/include/linux/efs_fs.h b/include/linux/efs_fs.h index 16cb25cbf7c5..dd57fe523e97 100644 --- a/include/linux/efs_fs.h +++ b/include/linux/efs_fs.h | |||
| @@ -35,6 +35,7 @@ static inline struct efs_sb_info *SUPER_INFO(struct super_block *sb) | |||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | struct statfs; | 37 | struct statfs; |
| 38 | struct fid; | ||
| 38 | 39 | ||
| 39 | extern const struct inode_operations efs_dir_inode_operations; | 40 | extern const struct inode_operations efs_dir_inode_operations; |
| 40 | extern const struct file_operations efs_dir_operations; | 41 | extern const struct file_operations efs_dir_operations; |
| @@ -45,7 +46,10 @@ extern efs_block_t efs_map_block(struct inode *, efs_block_t); | |||
| 45 | extern int efs_get_block(struct inode *, sector_t, struct buffer_head *, int); | 46 | extern int efs_get_block(struct inode *, sector_t, struct buffer_head *, int); |
| 46 | 47 | ||
| 47 | extern struct dentry *efs_lookup(struct inode *, struct dentry *, struct nameidata *); | 48 | extern struct dentry *efs_lookup(struct inode *, struct dentry *, struct nameidata *); |
| 48 | extern struct dentry *efs_get_dentry(struct super_block *sb, void *vobjp); | 49 | extern struct dentry *efs_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 50 | int fh_len, int fh_type); | ||
| 51 | extern struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 52 | int fh_len, int fh_type); | ||
| 49 | extern struct dentry *efs_get_parent(struct dentry *); | 53 | extern struct dentry *efs_get_parent(struct dentry *); |
| 50 | extern int efs_bmap(struct inode *, int); | 54 | extern int efs_bmap(struct inode *, int); |
| 51 | 55 | ||
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h index 8872fe8392d6..51d214138814 100644 --- a/include/linux/exportfs.h +++ b/include/linux/exportfs.h | |||
| @@ -4,9 +4,48 @@ | |||
| 4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
| 5 | 5 | ||
| 6 | struct dentry; | 6 | struct dentry; |
| 7 | struct inode; | ||
| 7 | struct super_block; | 8 | struct super_block; |
| 8 | struct vfsmount; | 9 | struct vfsmount; |
| 9 | 10 | ||
| 11 | /* | ||
| 12 | * The fileid_type identifies how the file within the filesystem is encoded. | ||
| 13 | * In theory this is freely set and parsed by the filesystem, but we try to | ||
| 14 | * stick to conventions so we can share some generic code and don't confuse | ||
| 15 | * sniffers like ethereal/wireshark. | ||
| 16 | * | ||
| 17 | * The filesystem must not use the value '0' or '0xff'. | ||
| 18 | */ | ||
| 19 | enum fid_type { | ||
| 20 | /* | ||
| 21 | * The root, or export point, of the filesystem. | ||
| 22 | * (Never actually passed down to the filesystem. | ||
| 23 | */ | ||
| 24 | FILEID_ROOT = 0, | ||
| 25 | |||
| 26 | /* | ||
| 27 | * 32bit inode number, 32 bit generation number. | ||
| 28 | */ | ||
| 29 | FILEID_INO32_GEN = 1, | ||
| 30 | |||
| 31 | /* | ||
| 32 | * 32bit inode number, 32 bit generation number, | ||
| 33 | * 32 bit parent directory inode number. | ||
| 34 | */ | ||
| 35 | FILEID_INO32_GEN_PARENT = 2, | ||
| 36 | }; | ||
| 37 | |||
| 38 | struct fid { | ||
| 39 | union { | ||
| 40 | struct { | ||
| 41 | u32 ino; | ||
| 42 | u32 gen; | ||
| 43 | u32 parent_ino; | ||
| 44 | u32 parent_gen; | ||
| 45 | } i32; | ||
| 46 | __u32 raw[6]; | ||
| 47 | }; | ||
| 48 | }; | ||
| 10 | 49 | ||
| 11 | /** | 50 | /** |
| 12 | * struct export_operations - for nfsd to communicate with file systems | 51 | * struct export_operations - for nfsd to communicate with file systems |
| @@ -15,43 +54,9 @@ struct vfsmount; | |||
| 15 | * @get_name: find the name for a given inode in a given directory | 54 | * @get_name: find the name for a given inode in a given directory |
| 16 | * @get_parent: find the parent of a given directory | 55 | * @get_parent: find the parent of a given directory |
| 17 | * @get_dentry: find a dentry for the inode given a file handle sub-fragment | 56 | * @get_dentry: find a dentry for the inode given a file handle sub-fragment |
| 18 | * @find_exported_dentry: | ||
| 19 | * set by the exporting module to a standard helper function. | ||
| 20 | * | ||
| 21 | * Description: | ||
| 22 | * The export_operations structure provides a means for nfsd to communicate | ||
| 23 | * with a particular exported file system - particularly enabling nfsd and | ||
| 24 | * the filesystem to co-operate when dealing with file handles. | ||
| 25 | * | ||
| 26 | * export_operations contains two basic operation for dealing with file | ||
| 27 | * handles, decode_fh() and encode_fh(), and allows for some other | ||
| 28 | * operations to be defined which standard helper routines use to get | ||
| 29 | * specific information from the filesystem. | ||
| 30 | * | ||
| 31 | * nfsd encodes information use to determine which filesystem a filehandle | ||
| 32 | * applies to in the initial part of the file handle. The remainder, termed | ||
| 33 | * a file handle fragment, is controlled completely by the filesystem. The | ||
| 34 | * standard helper routines assume that this fragment will contain one or | ||
| 35 | * two sub-fragments, one which identifies the file, and one which may be | ||
| 36 | * used to identify the (a) directory containing the file. | ||
| 37 | * | 57 | * |
| 38 | * In some situations, nfsd needs to get a dentry which is connected into a | 58 | * See Documentation/filesystems/Exporting for details on how to use |
| 39 | * specific part of the file tree. To allow for this, it passes the | 59 | * this interface correctly. |
| 40 | * function acceptable() together with a @context which can be used to see | ||
| 41 | * if the dentry is acceptable. As there can be multiple dentrys for a | ||
| 42 | * given file, the filesystem should check each one for acceptability before | ||
| 43 | * looking for the next. As soon as an acceptable one is found, it should | ||
| 44 | * be returned. | ||
| 45 | * | ||
| 46 | * decode_fh: | ||
| 47 | * @decode_fh is given a &struct super_block (@sb), a file handle fragment | ||
| 48 | * (@fh, @fh_len) and an acceptability testing function (@acceptable, | ||
| 49 | * @context). It should return a &struct dentry which refers to the same | ||
| 50 | * file that the file handle fragment refers to, and which passes the | ||
| 51 | * acceptability test. If it cannot, it should return a %NULL pointer if | ||
| 52 | * the file was found but no acceptable &dentries were available, or a | ||
| 53 | * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or | ||
| 54 | * %ENOMEM). | ||
| 55 | * | 60 | * |
| 56 | * encode_fh: | 61 | * encode_fh: |
| 57 | * @encode_fh should store in the file handle fragment @fh (using at most | 62 | * @encode_fh should store in the file handle fragment @fh (using at most |
| @@ -63,6 +68,21 @@ struct vfsmount; | |||
| 63 | * the filehandle fragment. encode_fh() should return the number of bytes | 68 | * the filehandle fragment. encode_fh() should return the number of bytes |
| 64 | * stored or a negative error code such as %-ENOSPC | 69 | * stored or a negative error code such as %-ENOSPC |
| 65 | * | 70 | * |
| 71 | * fh_to_dentry: | ||
| 72 | * @fh_to_dentry is given a &struct super_block (@sb) and a file handle | ||
| 73 | * fragment (@fh, @fh_len). It should return a &struct dentry which refers | ||
| 74 | * to the same file that the file handle fragment refers to. If it cannot, | ||
| 75 | * it should return a %NULL pointer if the file was found but no acceptable | ||
| 76 | * &dentries were available, or an %ERR_PTR error code indicating why it | ||
| 77 | * couldn't be found (e.g. %ENOENT or %ENOMEM). Any suitable dentry can be | ||
| 78 | * returned including, if necessary, a new dentry created with d_alloc_root. | ||
| 79 | * The caller can then find any other extant dentries by following the | ||
| 80 | * d_alias links. | ||
| 81 | * | ||
| 82 | * fh_to_parent: | ||
| 83 | * Same as @fh_to_dentry, except that it returns a pointer to the parent | ||
| 84 | * dentry if it was encoded into the filehandle fragment by @encode_fh. | ||
| 85 | * | ||
| 66 | * get_name: | 86 | * get_name: |
| 67 | * @get_name should find a name for the given @child in the given @parent | 87 | * @get_name should find a name for the given @child in the given @parent |
| 68 | * directory. The name should be stored in the @name (with the | 88 | * directory. The name should be stored in the @name (with the |
| @@ -75,52 +95,37 @@ struct vfsmount; | |||
| 75 | * is also a directory. In the event that it cannot be found, or storage | 95 | * is also a directory. In the event that it cannot be found, or storage |
| 76 | * space cannot be allocated, a %ERR_PTR should be returned. | 96 | * space cannot be allocated, a %ERR_PTR should be returned. |
| 77 | * | 97 | * |
| 78 | * get_dentry: | ||
| 79 | * Given a &super_block (@sb) and a pointer to a file-system specific inode | ||
| 80 | * identifier, possibly an inode number, (@inump) get_dentry() should find | ||
| 81 | * the identified inode and return a dentry for that inode. Any suitable | ||
| 82 | * dentry can be returned including, if necessary, a new dentry created with | ||
| 83 | * d_alloc_root. The caller can then find any other extant dentrys by | ||
| 84 | * following the d_alias links. If a new dentry was created using | ||
| 85 | * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry | ||
| 86 | * should be d_rehash()ed. | ||
| 87 | * | ||
| 88 | * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code | ||
| 89 | * can be returned. The @inump will be whatever was passed to | ||
| 90 | * nfsd_find_fh_dentry() in either the @obj or @parent parameters. | ||
| 91 | * | ||
| 92 | * Locking rules: | 98 | * Locking rules: |
| 93 | * get_parent is called with child->d_inode->i_mutex down | 99 | * get_parent is called with child->d_inode->i_mutex down |
| 94 | * get_name is not (which is possibly inconsistent) | 100 | * get_name is not (which is possibly inconsistent) |
| 95 | */ | 101 | */ |
| 96 | 102 | ||
| 97 | struct export_operations { | 103 | struct export_operations { |
| 98 | struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, | ||
| 99 | int fh_len, int fh_type, | ||
| 100 | int (*acceptable)(void *context, struct dentry *de), | ||
| 101 | void *context); | ||
| 102 | int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, | 104 | int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, |
| 103 | int connectable); | 105 | int connectable); |
| 106 | struct dentry * (*fh_to_dentry)(struct super_block *sb, struct fid *fid, | ||
| 107 | int fh_len, int fh_type); | ||
| 108 | struct dentry * (*fh_to_parent)(struct super_block *sb, struct fid *fid, | ||
| 109 | int fh_len, int fh_type); | ||
| 104 | int (*get_name)(struct dentry *parent, char *name, | 110 | int (*get_name)(struct dentry *parent, char *name, |
| 105 | struct dentry *child); | 111 | struct dentry *child); |
| 106 | struct dentry * (*get_parent)(struct dentry *child); | 112 | struct dentry * (*get_parent)(struct dentry *child); |
| 107 | struct dentry * (*get_dentry)(struct super_block *sb, void *inump); | ||
| 108 | |||
| 109 | /* This is set by the exporting module to a standard helper */ | ||
| 110 | struct dentry * (*find_exported_dentry)( | ||
| 111 | struct super_block *sb, void *obj, void *parent, | ||
| 112 | int (*acceptable)(void *context, struct dentry *de), | ||
| 113 | void *context); | ||
| 114 | }; | 113 | }; |
| 115 | 114 | ||
| 116 | extern struct dentry *find_exported_dentry(struct super_block *sb, void *obj, | 115 | extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, |
| 117 | void *parent, int (*acceptable)(void *context, struct dentry *de), | 116 | int *max_len, int connectable); |
| 118 | void *context); | 117 | extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, |
| 119 | |||
| 120 | extern int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len, | ||
| 121 | int connectable); | ||
| 122 | extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh, | ||
| 123 | int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *), | 118 | int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *), |
| 124 | void *context); | 119 | void *context); |
| 125 | 120 | ||
| 121 | /* | ||
| 122 | * Generic helpers for filesystems. | ||
| 123 | */ | ||
| 124 | extern struct dentry *generic_fh_to_dentry(struct super_block *sb, | ||
| 125 | struct fid *fid, int fh_len, int fh_type, | ||
| 126 | struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen)); | ||
| 127 | extern struct dentry *generic_fh_to_parent(struct super_block *sb, | ||
| 128 | struct fid *fid, int fh_len, int fh_type, | ||
| 129 | struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen)); | ||
| 130 | |||
| 126 | #endif /* LINUX_EXPORTFS_H */ | 131 | #endif /* LINUX_EXPORTFS_H */ |
diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h index c77c3bbfe4bb..0f6c86c634fd 100644 --- a/include/linux/ext2_fs.h +++ b/include/linux/ext2_fs.h | |||
| @@ -561,6 +561,7 @@ enum { | |||
| 561 | #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) | 561 | #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) |
| 562 | #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ | 562 | #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ |
| 563 | ~EXT2_DIR_ROUND) | 563 | ~EXT2_DIR_ROUND) |
| 564 | #define EXT2_MAX_REC_LEN ((1<<16)-1) | ||
| 564 | 565 | ||
| 565 | static inline ext2_fsblk_t | 566 | static inline ext2_fsblk_t |
| 566 | ext2_group_first_block_no(struct super_block *sb, unsigned long group_no) | 567 | ext2_group_first_block_no(struct super_block *sb, unsigned long group_no) |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 50078bb30a1c..b3ec4a496d64 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -987,7 +987,7 @@ struct super_block { | |||
| 987 | const struct super_operations *s_op; | 987 | const struct super_operations *s_op; |
| 988 | struct dquot_operations *dq_op; | 988 | struct dquot_operations *dq_op; |
| 989 | struct quotactl_ops *s_qcop; | 989 | struct quotactl_ops *s_qcop; |
| 990 | struct export_operations *s_export_op; | 990 | const struct export_operations *s_export_op; |
| 991 | unsigned long s_flags; | 991 | unsigned long s_flags; |
| 992 | unsigned long s_magic; | 992 | unsigned long s_magic; |
| 993 | struct dentry *s_root; | 993 | struct dentry *s_root; |
diff --git a/include/linux/linkage.h b/include/linux/linkage.h index 6c9873f88287..ff203dd02919 100644 --- a/include/linux/linkage.h +++ b/include/linux/linkage.h | |||
| @@ -34,6 +34,12 @@ | |||
| 34 | name: | 34 | name: |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | #ifndef WEAK | ||
| 38 | #define WEAK(name) \ | ||
| 39 | .weak name; \ | ||
| 40 | name: | ||
| 41 | #endif | ||
| 42 | |||
| 37 | #define KPROBE_ENTRY(name) \ | 43 | #define KPROBE_ENTRY(name) \ |
| 38 | .pushsection .kprobes.text, "ax"; \ | 44 | .pushsection .kprobes.text, "ax"; \ |
| 39 | ENTRY(name) | 45 | ENTRY(name) |
diff --git a/include/linux/memory.h b/include/linux/memory.h index 654ef5544878..33f0ff0cf634 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h | |||
| @@ -41,18 +41,15 @@ struct memory_block { | |||
| 41 | #define MEM_ONLINE (1<<0) /* exposed to userspace */ | 41 | #define MEM_ONLINE (1<<0) /* exposed to userspace */ |
| 42 | #define MEM_GOING_OFFLINE (1<<1) /* exposed to userspace */ | 42 | #define MEM_GOING_OFFLINE (1<<1) /* exposed to userspace */ |
| 43 | #define MEM_OFFLINE (1<<2) /* exposed to userspace */ | 43 | #define MEM_OFFLINE (1<<2) /* exposed to userspace */ |
| 44 | #define MEM_GOING_ONLINE (1<<3) | ||
| 45 | #define MEM_CANCEL_ONLINE (1<<4) | ||
| 46 | #define MEM_CANCEL_OFFLINE (1<<5) | ||
| 44 | 47 | ||
| 45 | /* | 48 | struct memory_notify { |
| 46 | * All of these states are currently kernel-internal for notifying | 49 | unsigned long start_pfn; |
| 47 | * kernel components and architectures. | 50 | unsigned long nr_pages; |
| 48 | * | 51 | int status_change_nid; |
| 49 | * For MEM_MAPPING_INVALID, all notifier chains with priority >0 | 52 | }; |
| 50 | * are called before pfn_to_page() becomes invalid. The priority=0 | ||
| 51 | * entry is reserved for the function that actually makes | ||
| 52 | * pfn_to_page() stop working. Any notifiers that want to be called | ||
| 53 | * after that should have priority <0. | ||
| 54 | */ | ||
| 55 | #define MEM_MAPPING_INVALID (1<<3) | ||
| 56 | 53 | ||
| 57 | struct notifier_block; | 54 | struct notifier_block; |
| 58 | struct mem_section; | 55 | struct mem_section; |
| @@ -69,21 +66,31 @@ static inline int register_memory_notifier(struct notifier_block *nb) | |||
| 69 | static inline void unregister_memory_notifier(struct notifier_block *nb) | 66 | static inline void unregister_memory_notifier(struct notifier_block *nb) |
| 70 | { | 67 | { |
| 71 | } | 68 | } |
| 69 | static inline int memory_notify(unsigned long val, void *v) | ||
| 70 | { | ||
| 71 | return 0; | ||
| 72 | } | ||
| 72 | #else | 73 | #else |
| 74 | extern int register_memory_notifier(struct notifier_block *nb); | ||
| 75 | extern void unregister_memory_notifier(struct notifier_block *nb); | ||
| 73 | extern int register_new_memory(struct mem_section *); | 76 | extern int register_new_memory(struct mem_section *); |
| 74 | extern int unregister_memory_section(struct mem_section *); | 77 | extern int unregister_memory_section(struct mem_section *); |
| 75 | extern int memory_dev_init(void); | 78 | extern int memory_dev_init(void); |
| 76 | extern int remove_memory_block(unsigned long, struct mem_section *, int); | 79 | extern int remove_memory_block(unsigned long, struct mem_section *, int); |
| 77 | 80 | extern int memory_notify(unsigned long val, void *v); | |
| 78 | #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT) | 81 | #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT) |
| 79 | 82 | ||
| 80 | 83 | ||
| 81 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ | 84 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ |
| 82 | 85 | ||
| 86 | #ifdef CONFIG_MEMORY_HOTPLUG | ||
| 83 | #define hotplug_memory_notifier(fn, pri) { \ | 87 | #define hotplug_memory_notifier(fn, pri) { \ |
| 84 | static struct notifier_block fn##_mem_nb = \ | 88 | static struct notifier_block fn##_mem_nb = \ |
| 85 | { .notifier_call = fn, .priority = pri }; \ | 89 | { .notifier_call = fn, .priority = pri }; \ |
| 86 | register_memory_notifier(&fn##_mem_nb); \ | 90 | register_memory_notifier(&fn##_mem_nb); \ |
| 87 | } | 91 | } |
| 92 | #else | ||
| 93 | #define hotplug_memory_notifier(fn, pri) do { } while (0) | ||
| 94 | #endif | ||
| 88 | 95 | ||
| 89 | #endif /* _LINUX_MEMORY_H_ */ | 96 | #endif /* _LINUX_MEMORY_H_ */ |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 768b93359f90..5d2281f661f7 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -141,6 +141,7 @@ struct pci_dev { | |||
| 141 | unsigned int class; /* 3 bytes: (base,sub,prog-if) */ | 141 | unsigned int class; /* 3 bytes: (base,sub,prog-if) */ |
| 142 | u8 revision; /* PCI revision, low byte of class word */ | 142 | u8 revision; /* PCI revision, low byte of class word */ |
| 143 | u8 hdr_type; /* PCI header type (`multi' flag masked out) */ | 143 | u8 hdr_type; /* PCI header type (`multi' flag masked out) */ |
| 144 | u8 pcie_type; /* PCI-E device/port type */ | ||
| 144 | u8 rom_base_reg; /* which config register controls the ROM */ | 145 | u8 rom_base_reg; /* which config register controls the ROM */ |
| 145 | u8 pin; /* which interrupt pin this device uses */ | 146 | u8 pin; /* which interrupt pin this device uses */ |
| 146 | 147 | ||
| @@ -183,6 +184,7 @@ struct pci_dev { | |||
| 183 | unsigned int msi_enabled:1; | 184 | unsigned int msi_enabled:1; |
| 184 | unsigned int msix_enabled:1; | 185 | unsigned int msix_enabled:1; |
| 185 | unsigned int is_managed:1; | 186 | unsigned int is_managed:1; |
| 187 | unsigned int is_pcie:1; | ||
| 186 | atomic_t enable_cnt; /* pci_enable_device has been called */ | 188 | atomic_t enable_cnt; /* pci_enable_device has been called */ |
| 187 | 189 | ||
| 188 | u32 saved_config_space[16]; /* config space saved at suspend time */ | 190 | u32 saved_config_space[16]; /* config space saved at suspend time */ |
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h index 72bfccd3da22..422eab4958a6 100644 --- a/include/linux/reiserfs_fs.h +++ b/include/linux/reiserfs_fs.h | |||
| @@ -28,6 +28,8 @@ | |||
| 28 | #include <linux/reiserfs_fs_sb.h> | 28 | #include <linux/reiserfs_fs_sb.h> |
| 29 | #endif | 29 | #endif |
| 30 | 30 | ||
| 31 | struct fid; | ||
| 32 | |||
| 31 | /* | 33 | /* |
| 32 | * include/linux/reiser_fs.h | 34 | * include/linux/reiser_fs.h |
| 33 | * | 35 | * |
| @@ -1877,12 +1879,10 @@ void reiserfs_delete_inode(struct inode *inode); | |||
| 1877 | int reiserfs_write_inode(struct inode *inode, int); | 1879 | int reiserfs_write_inode(struct inode *inode, int); |
| 1878 | int reiserfs_get_block(struct inode *inode, sector_t block, | 1880 | int reiserfs_get_block(struct inode *inode, sector_t block, |
| 1879 | struct buffer_head *bh_result, int create); | 1881 | struct buffer_head *bh_result, int create); |
| 1880 | struct dentry *reiserfs_get_dentry(struct super_block *, void *); | 1882 | struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, struct fid *fid, |
| 1881 | struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data, | 1883 | int fh_len, int fh_type); |
| 1882 | int len, int fhtype, | 1884 | struct dentry *reiserfs_fh_to_parent(struct super_block *sb, struct fid *fid, |
| 1883 | int (*acceptable) (void *contect, | 1885 | int fh_len, int fh_type); |
| 1884 | struct dentry * de), | ||
| 1885 | void *context); | ||
| 1886 | int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp, | 1886 | int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp, |
| 1887 | int connectable); | 1887 | int connectable); |
| 1888 | 1888 | ||
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 2dc7464cce52..42daf5e15265 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h | |||
| @@ -4,47 +4,95 @@ | |||
| 4 | #include <asm/scatterlist.h> | 4 | #include <asm/scatterlist.h> |
| 5 | #include <linux/mm.h> | 5 | #include <linux/mm.h> |
| 6 | #include <linux/string.h> | 6 | #include <linux/string.h> |
| 7 | #include <asm/io.h> | ||
| 7 | 8 | ||
| 9 | /* | ||
| 10 | * Notes on SG table design. | ||
| 11 | * | ||
| 12 | * Architectures must provide an unsigned long page_link field in the | ||
| 13 | * scatterlist struct. We use that to place the page pointer AND encode | ||
| 14 | * information about the sg table as well. The two lower bits are reserved | ||
| 15 | * for this information. | ||
| 16 | * | ||
| 17 | * If bit 0 is set, then the page_link contains a pointer to the next sg | ||
| 18 | * table list. Otherwise the next entry is at sg + 1. | ||
| 19 | * | ||
| 20 | * If bit 1 is set, then this sg entry is the last element in a list. | ||
| 21 | * | ||
| 22 | * See sg_next(). | ||
| 23 | * | ||
| 24 | */ | ||
| 25 | |||
| 26 | #define SG_MAGIC 0x87654321 | ||
| 27 | |||
| 28 | /** | ||
| 29 | * sg_set_page - Set sg entry to point at given page | ||
| 30 | * @sg: SG entry | ||
| 31 | * @page: The page | ||
| 32 | * | ||
| 33 | * Description: | ||
| 34 | * Use this function to set an sg entry pointing at a page, never assign | ||
| 35 | * the page directly. We encode sg table information in the lower bits | ||
| 36 | * of the page pointer. See sg_page() for looking up the page belonging | ||
| 37 | * to an sg entry. | ||
| 38 | * | ||
| 39 | **/ | ||
| 40 | static inline void sg_set_page(struct scatterlist *sg, struct page *page) | ||
| 41 | { | ||
| 42 | unsigned long page_link = sg->page_link & 0x3; | ||
| 43 | |||
| 44 | #ifdef CONFIG_DEBUG_SG | ||
| 45 | BUG_ON(sg->sg_magic != SG_MAGIC); | ||
| 46 | #endif | ||
| 47 | sg->page_link = page_link | (unsigned long) page; | ||
| 48 | } | ||
| 49 | |||
| 50 | #define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3)) | ||
| 51 | |||
| 52 | /** | ||
| 53 | * sg_set_buf - Set sg entry to point at given data | ||
| 54 | * @sg: SG entry | ||
| 55 | * @buf: Data | ||
| 56 | * @buflen: Data length | ||
| 57 | * | ||
| 58 | **/ | ||
| 8 | static inline void sg_set_buf(struct scatterlist *sg, const void *buf, | 59 | static inline void sg_set_buf(struct scatterlist *sg, const void *buf, |
| 9 | unsigned int buflen) | 60 | unsigned int buflen) |
| 10 | { | 61 | { |
| 11 | sg->page = virt_to_page(buf); | 62 | sg_set_page(sg, virt_to_page(buf)); |
| 12 | sg->offset = offset_in_page(buf); | 63 | sg->offset = offset_in_page(buf); |
| 13 | sg->length = buflen; | 64 | sg->length = buflen; |
| 14 | } | 65 | } |
| 15 | 66 | ||
| 16 | static inline void sg_init_one(struct scatterlist *sg, const void *buf, | ||
| 17 | unsigned int buflen) | ||
| 18 | { | ||
| 19 | memset(sg, 0, sizeof(*sg)); | ||
| 20 | sg_set_buf(sg, buf, buflen); | ||
| 21 | } | ||
| 22 | |||
| 23 | /* | 67 | /* |
| 24 | * We overload the LSB of the page pointer to indicate whether it's | 68 | * We overload the LSB of the page pointer to indicate whether it's |
| 25 | * a valid sg entry, or whether it points to the start of a new scatterlist. | 69 | * a valid sg entry, or whether it points to the start of a new scatterlist. |
| 26 | * Those low bits are there for everyone! (thanks mason :-) | 70 | * Those low bits are there for everyone! (thanks mason :-) |
| 27 | */ | 71 | */ |
| 28 | #define sg_is_chain(sg) ((unsigned long) (sg)->page & 0x01) | 72 | #define sg_is_chain(sg) ((sg)->page_link & 0x01) |
| 73 | #define sg_is_last(sg) ((sg)->page_link & 0x02) | ||
| 29 | #define sg_chain_ptr(sg) \ | 74 | #define sg_chain_ptr(sg) \ |
| 30 | ((struct scatterlist *) ((unsigned long) (sg)->page & ~0x01)) | 75 | ((struct scatterlist *) ((sg)->page_link & ~0x03)) |
| 31 | 76 | ||
| 32 | /** | 77 | /** |
| 33 | * sg_next - return the next scatterlist entry in a list | 78 | * sg_next - return the next scatterlist entry in a list |
| 34 | * @sg: The current sg entry | 79 | * @sg: The current sg entry |
| 35 | * | 80 | * |
| 36 | * Usually the next entry will be @sg@ + 1, but if this sg element is part | 81 | * Description: |
| 37 | * of a chained scatterlist, it could jump to the start of a new | 82 | * Usually the next entry will be @sg@ + 1, but if this sg element is part |
| 38 | * scatterlist array. | 83 | * of a chained scatterlist, it could jump to the start of a new |
| 39 | * | 84 | * scatterlist array. |
| 40 | * Note that the caller must ensure that there are further entries after | ||
| 41 | * the current entry, this function will NOT return NULL for an end-of-list. | ||
| 42 | * | 85 | * |
| 43 | */ | 86 | **/ |
| 44 | static inline struct scatterlist *sg_next(struct scatterlist *sg) | 87 | static inline struct scatterlist *sg_next(struct scatterlist *sg) |
| 45 | { | 88 | { |
| 46 | sg++; | 89 | #ifdef CONFIG_DEBUG_SG |
| 90 | BUG_ON(sg->sg_magic != SG_MAGIC); | ||
| 91 | #endif | ||
| 92 | if (sg_is_last(sg)) | ||
| 93 | return NULL; | ||
| 47 | 94 | ||
| 95 | sg++; | ||
| 48 | if (unlikely(sg_is_chain(sg))) | 96 | if (unlikely(sg_is_chain(sg))) |
| 49 | sg = sg_chain_ptr(sg); | 97 | sg = sg_chain_ptr(sg); |
| 50 | 98 | ||
| @@ -62,14 +110,15 @@ static inline struct scatterlist *sg_next(struct scatterlist *sg) | |||
| 62 | * @sgl: First entry in the scatterlist | 110 | * @sgl: First entry in the scatterlist |
| 63 | * @nents: Number of entries in the scatterlist | 111 | * @nents: Number of entries in the scatterlist |
| 64 | * | 112 | * |
| 65 | * Should only be used casually, it (currently) scan the entire list | 113 | * Description: |
| 66 | * to get the last entry. | 114 | * Should only be used casually, it (currently) scan the entire list |
| 115 | * to get the last entry. | ||
| 67 | * | 116 | * |
| 68 | * Note that the @sgl@ pointer passed in need not be the first one, | 117 | * Note that the @sgl@ pointer passed in need not be the first one, |
| 69 | * the important bit is that @nents@ denotes the number of entries that | 118 | * the important bit is that @nents@ denotes the number of entries that |
| 70 | * exist from @sgl@. | 119 | * exist from @sgl@. |
| 71 | * | 120 | * |
| 72 | */ | 121 | **/ |
| 73 | static inline struct scatterlist *sg_last(struct scatterlist *sgl, | 122 | static inline struct scatterlist *sg_last(struct scatterlist *sgl, |
| 74 | unsigned int nents) | 123 | unsigned int nents) |
| 75 | { | 124 | { |
| @@ -83,6 +132,10 @@ static inline struct scatterlist *sg_last(struct scatterlist *sgl, | |||
| 83 | ret = sg; | 132 | ret = sg; |
| 84 | 133 | ||
| 85 | #endif | 134 | #endif |
| 135 | #ifdef CONFIG_DEBUG_SG | ||
| 136 | BUG_ON(sgl[0].sg_magic != SG_MAGIC); | ||
| 137 | BUG_ON(!sg_is_last(ret)); | ||
| 138 | #endif | ||
| 86 | return ret; | 139 | return ret; |
| 87 | } | 140 | } |
| 88 | 141 | ||
| @@ -92,16 +145,111 @@ static inline struct scatterlist *sg_last(struct scatterlist *sgl, | |||
| 92 | * @prv_nents: Number of entries in prv | 145 | * @prv_nents: Number of entries in prv |
| 93 | * @sgl: Second scatterlist | 146 | * @sgl: Second scatterlist |
| 94 | * | 147 | * |
| 95 | * Links @prv@ and @sgl@ together, to form a longer scatterlist. | 148 | * Description: |
| 149 | * Links @prv@ and @sgl@ together, to form a longer scatterlist. | ||
| 96 | * | 150 | * |
| 97 | */ | 151 | **/ |
| 98 | static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, | 152 | static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, |
| 99 | struct scatterlist *sgl) | 153 | struct scatterlist *sgl) |
| 100 | { | 154 | { |
| 101 | #ifndef ARCH_HAS_SG_CHAIN | 155 | #ifndef ARCH_HAS_SG_CHAIN |
| 102 | BUG(); | 156 | BUG(); |
| 103 | #endif | 157 | #endif |
| 104 | prv[prv_nents - 1].page = (struct page *) ((unsigned long) sgl | 0x01); | 158 | prv[prv_nents - 1].page_link = (unsigned long) sgl | 0x01; |
| 159 | } | ||
| 160 | |||
| 161 | /** | ||
| 162 | * sg_mark_end - Mark the end of the scatterlist | ||
| 163 | * @sgl: Scatterlist | ||
| 164 | * @nents: Number of entries in sgl | ||
| 165 | * | ||
| 166 | * Description: | ||
| 167 | * Marks the last entry as the termination point for sg_next() | ||
| 168 | * | ||
| 169 | **/ | ||
| 170 | static inline void sg_mark_end(struct scatterlist *sgl, unsigned int nents) | ||
| 171 | { | ||
| 172 | sgl[nents - 1].page_link = 0x02; | ||
| 173 | } | ||
| 174 | |||
| 175 | static inline void __sg_mark_end(struct scatterlist *sg) | ||
| 176 | { | ||
| 177 | sg->page_link |= 0x02; | ||
| 178 | } | ||
| 179 | |||
| 180 | /** | ||
| 181 | * sg_init_one - Initialize a single entry sg list | ||
| 182 | * @sg: SG entry | ||
| 183 | * @buf: Virtual address for IO | ||
| 184 | * @buflen: IO length | ||
| 185 | * | ||
| 186 | * Notes: | ||
| 187 | * This should not be used on a single entry that is part of a larger | ||
| 188 | * table. Use sg_init_table() for that. | ||
| 189 | * | ||
| 190 | **/ | ||
| 191 | static inline void sg_init_one(struct scatterlist *sg, const void *buf, | ||
| 192 | unsigned int buflen) | ||
| 193 | { | ||
| 194 | memset(sg, 0, sizeof(*sg)); | ||
| 195 | #ifdef CONFIG_DEBUG_SG | ||
| 196 | sg->sg_magic = SG_MAGIC; | ||
| 197 | #endif | ||
| 198 | sg_mark_end(sg, 1); | ||
| 199 | sg_set_buf(sg, buf, buflen); | ||
| 200 | } | ||
| 201 | |||
| 202 | /** | ||
| 203 | * sg_init_table - Initialize SG table | ||
| 204 | * @sgl: The SG table | ||
| 205 | * @nents: Number of entries in table | ||
| 206 | * | ||
| 207 | * Notes: | ||
| 208 | * If this is part of a chained sg table, sg_mark_end() should be | ||
| 209 | * used only on the last table part. | ||
| 210 | * | ||
| 211 | **/ | ||
| 212 | static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) | ||
| 213 | { | ||
| 214 | memset(sgl, 0, sizeof(*sgl) * nents); | ||
| 215 | sg_mark_end(sgl, nents); | ||
| 216 | #ifdef CONFIG_DEBUG_SG | ||
| 217 | { | ||
| 218 | int i; | ||
| 219 | for (i = 0; i < nents; i++) | ||
| 220 | sgl[i].sg_magic = SG_MAGIC; | ||
| 221 | } | ||
| 222 | #endif | ||
| 223 | } | ||
| 224 | |||
| 225 | /** | ||
| 226 | * sg_phys - Return physical address of an sg entry | ||
| 227 | * @sg: SG entry | ||
| 228 | * | ||
| 229 | * Description: | ||
| 230 | * This calls page_to_phys() on the page in this sg entry, and adds the | ||
| 231 | * sg offset. The caller must know that it is legal to call page_to_phys() | ||
| 232 | * on the sg page. | ||
| 233 | * | ||
| 234 | **/ | ||
| 235 | static inline unsigned long sg_phys(struct scatterlist *sg) | ||
| 236 | { | ||
| 237 | return page_to_phys(sg_page(sg)) + sg->offset; | ||
| 238 | } | ||
| 239 | |||
| 240 | /** | ||
| 241 | * sg_virt - Return virtual address of an sg entry | ||
| 242 | * @sg: SG entry | ||
| 243 | * | ||
| 244 | * Description: | ||
| 245 | * This calls page_address() on the page in this sg entry, and adds the | ||
| 246 | * sg offset. The caller must know that the sg page has a valid virtual | ||
| 247 | * mapping. | ||
| 248 | * | ||
| 249 | **/ | ||
| 250 | static inline void *sg_virt(struct scatterlist *sg) | ||
| 251 | { | ||
| 252 | return page_address(sg_page(sg)) + sg->offset; | ||
| 105 | } | 253 | } |
| 106 | 254 | ||
| 107 | #endif /* _LINUX_SCATTERLIST_H */ | 255 | #endif /* _LINUX_SCATTERLIST_H */ |
diff --git a/include/linux/videodev.h b/include/linux/videodev.h index 8dba97a291f6..52e3d5fd5be4 100644 --- a/include/linux/videodev.h +++ b/include/linux/videodev.h | |||
| @@ -294,48 +294,6 @@ struct video_code | |||
| 294 | #define VID_PLAY_RESET 13 | 294 | #define VID_PLAY_RESET 13 |
| 295 | #define VID_PLAY_END_MARK 14 | 295 | #define VID_PLAY_END_MARK 14 |
| 296 | 296 | ||
| 297 | |||
| 298 | |||
| 299 | #define VID_HARDWARE_BT848 1 | ||
| 300 | #define VID_HARDWARE_QCAM_BW 2 | ||
| 301 | #define VID_HARDWARE_PMS 3 | ||
| 302 | #define VID_HARDWARE_QCAM_C 4 | ||
| 303 | #define VID_HARDWARE_PSEUDO 5 | ||
| 304 | #define VID_HARDWARE_SAA5249 6 | ||
| 305 | #define VID_HARDWARE_AZTECH 7 | ||
| 306 | #define VID_HARDWARE_SF16MI 8 | ||
| 307 | #define VID_HARDWARE_RTRACK 9 | ||
| 308 | #define VID_HARDWARE_ZOLTRIX 10 | ||
| 309 | #define VID_HARDWARE_SAA7146 11 | ||
| 310 | #define VID_HARDWARE_VIDEUM 12 /* Reserved for Winnov videum */ | ||
| 311 | #define VID_HARDWARE_RTRACK2 13 | ||
| 312 | #define VID_HARDWARE_PERMEDIA2 14 /* Reserved for Permedia2 */ | ||
| 313 | #define VID_HARDWARE_RIVA128 15 /* Reserved for RIVA 128 */ | ||
| 314 | #define VID_HARDWARE_PLANB 16 /* PowerMac motherboard video-in */ | ||
| 315 | #define VID_HARDWARE_BROADWAY 17 /* Broadway project */ | ||
| 316 | #define VID_HARDWARE_GEMTEK 18 | ||
| 317 | #define VID_HARDWARE_TYPHOON 19 | ||
| 318 | #define VID_HARDWARE_VINO 20 /* SGI Indy Vino */ | ||
| 319 | #define VID_HARDWARE_CADET 21 /* Cadet radio */ | ||
| 320 | #define VID_HARDWARE_TRUST 22 /* Trust FM Radio */ | ||
| 321 | #define VID_HARDWARE_TERRATEC 23 /* TerraTec ActiveRadio */ | ||
| 322 | #define VID_HARDWARE_CPIA 24 | ||
| 323 | #define VID_HARDWARE_ZR36120 25 /* Zoran ZR36120/ZR36125 */ | ||
| 324 | #define VID_HARDWARE_ZR36067 26 /* Zoran ZR36067/36060 */ | ||
| 325 | #define VID_HARDWARE_OV511 27 | ||
| 326 | #define VID_HARDWARE_ZR356700 28 /* Zoran 36700 series */ | ||
| 327 | #define VID_HARDWARE_W9966 29 | ||
| 328 | #define VID_HARDWARE_SE401 30 /* SE401 USB webcams */ | ||
| 329 | #define VID_HARDWARE_PWC 31 /* Philips webcams */ | ||
| 330 | #define VID_HARDWARE_MEYE 32 /* Sony Vaio MotionEye cameras */ | ||
| 331 | #define VID_HARDWARE_CPIA2 33 | ||
| 332 | #define VID_HARDWARE_VICAM 34 | ||
| 333 | #define VID_HARDWARE_SF16FMR2 35 | ||
| 334 | #define VID_HARDWARE_W9968CF 36 | ||
| 335 | #define VID_HARDWARE_SAA7114H 37 | ||
| 336 | #define VID_HARDWARE_SN9C102 38 | ||
| 337 | #define VID_HARDWARE_ARV 39 | ||
| 338 | |||
| 339 | #endif /* CONFIG_VIDEO_V4L1_COMPAT */ | 297 | #endif /* CONFIG_VIDEO_V4L1_COMPAT */ |
| 340 | 298 | ||
| 341 | #endif /* __LINUX_VIDEODEV_H */ | 299 | #endif /* __LINUX_VIDEODEV_H */ |
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 1f503e94eff1..439474f24e34 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h | |||
| @@ -441,94 +441,6 @@ struct v4l2_timecode | |||
| 441 | #define V4L2_TC_USERBITS_8BITCHARS 0x0008 | 441 | #define V4L2_TC_USERBITS_8BITCHARS 0x0008 |
| 442 | /* The above is based on SMPTE timecodes */ | 442 | /* The above is based on SMPTE timecodes */ |
| 443 | 443 | ||
| 444 | #ifdef __KERNEL__ | ||
| 445 | /* | ||
| 446 | * M P E G C O M P R E S S I O N P A R A M E T E R S | ||
| 447 | * | ||
| 448 | * ### WARNING: This experimental MPEG compression API is obsolete. | ||
| 449 | * ### It is replaced by the MPEG controls API. | ||
| 450 | * ### This old API will disappear in the near future! | ||
| 451 | * | ||
| 452 | */ | ||
| 453 | enum v4l2_bitrate_mode { | ||
| 454 | V4L2_BITRATE_NONE = 0, /* not specified */ | ||
| 455 | V4L2_BITRATE_CBR, /* constant bitrate */ | ||
| 456 | V4L2_BITRATE_VBR, /* variable bitrate */ | ||
| 457 | }; | ||
| 458 | struct v4l2_bitrate { | ||
| 459 | /* rates are specified in kbit/sec */ | ||
| 460 | enum v4l2_bitrate_mode mode; | ||
| 461 | __u32 min; | ||
| 462 | __u32 target; /* use this one for CBR */ | ||
| 463 | __u32 max; | ||
| 464 | }; | ||
| 465 | |||
| 466 | enum v4l2_mpeg_streamtype { | ||
| 467 | V4L2_MPEG_SS_1, /* MPEG-1 system stream */ | ||
| 468 | V4L2_MPEG_PS_2, /* MPEG-2 program stream */ | ||
| 469 | V4L2_MPEG_TS_2, /* MPEG-2 transport stream */ | ||
| 470 | V4L2_MPEG_PS_DVD, /* MPEG-2 program stream with DVD header fixups */ | ||
| 471 | }; | ||
| 472 | enum v4l2_mpeg_audiotype { | ||
| 473 | V4L2_MPEG_AU_2_I, /* MPEG-2 layer 1 */ | ||
| 474 | V4L2_MPEG_AU_2_II, /* MPEG-2 layer 2 */ | ||
| 475 | V4L2_MPEG_AU_2_III, /* MPEG-2 layer 3 */ | ||
| 476 | V4L2_MPEG_AC3, /* AC3 */ | ||
| 477 | V4L2_MPEG_LPCM, /* LPCM */ | ||
| 478 | }; | ||
| 479 | enum v4l2_mpeg_videotype { | ||
| 480 | V4L2_MPEG_VI_1, /* MPEG-1 */ | ||
| 481 | V4L2_MPEG_VI_2, /* MPEG-2 */ | ||
| 482 | }; | ||
| 483 | enum v4l2_mpeg_aspectratio { | ||
| 484 | V4L2_MPEG_ASPECT_SQUARE = 1, /* square pixel */ | ||
| 485 | V4L2_MPEG_ASPECT_4_3 = 2, /* 4 : 3 */ | ||
| 486 | V4L2_MPEG_ASPECT_16_9 = 3, /* 16 : 9 */ | ||
| 487 | V4L2_MPEG_ASPECT_1_221 = 4, /* 1 : 2,21 */ | ||
| 488 | }; | ||
| 489 | |||
| 490 | struct v4l2_mpeg_compression { | ||
| 491 | /* general */ | ||
| 492 | enum v4l2_mpeg_streamtype st_type; | ||
| 493 | struct v4l2_bitrate st_bitrate; | ||
| 494 | |||
| 495 | /* transport streams */ | ||
| 496 | __u16 ts_pid_pmt; | ||
| 497 | __u16 ts_pid_audio; | ||
| 498 | __u16 ts_pid_video; | ||
| 499 | __u16 ts_pid_pcr; | ||
| 500 | |||
| 501 | /* program stream */ | ||
| 502 | __u16 ps_size; | ||
| 503 | __u16 reserved_1; /* align */ | ||
| 504 | |||
| 505 | /* audio */ | ||
| 506 | enum v4l2_mpeg_audiotype au_type; | ||
| 507 | struct v4l2_bitrate au_bitrate; | ||
| 508 | __u32 au_sample_rate; | ||
| 509 | __u8 au_pesid; | ||
| 510 | __u8 reserved_2[3]; /* align */ | ||
| 511 | |||
| 512 | /* video */ | ||
| 513 | enum v4l2_mpeg_videotype vi_type; | ||
| 514 | enum v4l2_mpeg_aspectratio vi_aspect_ratio; | ||
| 515 | struct v4l2_bitrate vi_bitrate; | ||
| 516 | __u32 vi_frame_rate; | ||
| 517 | __u16 vi_frames_per_gop; | ||
| 518 | __u16 vi_bframes_count; | ||
| 519 | __u8 vi_pesid; | ||
| 520 | __u8 reserved_3[3]; /* align */ | ||
| 521 | |||
| 522 | /* misc flags */ | ||
| 523 | __u32 closed_gops:1; | ||
| 524 | __u32 pulldown:1; | ||
| 525 | __u32 reserved_4:30; /* align */ | ||
| 526 | |||
| 527 | /* I don't expect the above being perfect yet ;) */ | ||
| 528 | __u32 reserved_5[8]; | ||
| 529 | }; | ||
| 530 | #endif | ||
| 531 | |||
| 532 | struct v4l2_jpegcompression | 444 | struct v4l2_jpegcompression |
| 533 | { | 445 | { |
| 534 | int quality; | 446 | int quality; |
| @@ -1420,10 +1332,6 @@ struct v4l2_chip_ident { | |||
| 1420 | #define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) | 1332 | #define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) |
| 1421 | #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) | 1333 | #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) |
| 1422 | #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) | 1334 | #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) |
| 1423 | #ifdef __KERNEL__ | ||
| 1424 | #define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression) | ||
| 1425 | #define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression) | ||
| 1426 | #endif | ||
| 1427 | #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) | 1335 | #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) |
| 1428 | #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) | 1336 | #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) |
| 1429 | #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) | 1337 | #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) |
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index e75d5e6c4cea..c544c6f90893 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h | |||
| @@ -94,7 +94,6 @@ struct video_device | |||
| 94 | char name[32]; | 94 | char name[32]; |
| 95 | int type; /* v4l1 */ | 95 | int type; /* v4l1 */ |
| 96 | int type2; /* v4l2 */ | 96 | int type2; /* v4l2 */ |
| 97 | int hardware; | ||
| 98 | int minor; | 97 | int minor; |
| 99 | 98 | ||
| 100 | int debug; /* Activates debug level*/ | 99 | int debug; /* Activates debug level*/ |
| @@ -272,10 +271,6 @@ struct video_device | |||
| 272 | int (*vidioc_s_crop) (struct file *file, void *fh, | 271 | int (*vidioc_s_crop) (struct file *file, void *fh, |
| 273 | struct v4l2_crop *a); | 272 | struct v4l2_crop *a); |
| 274 | /* Compression ioctls */ | 273 | /* Compression ioctls */ |
| 275 | int (*vidioc_g_mpegcomp) (struct file *file, void *fh, | ||
| 276 | struct v4l2_mpeg_compression *a); | ||
| 277 | int (*vidioc_s_mpegcomp) (struct file *file, void *fh, | ||
| 278 | struct v4l2_mpeg_compression *a); | ||
| 279 | int (*vidioc_g_jpegcomp) (struct file *file, void *fh, | 274 | int (*vidioc_g_jpegcomp) (struct file *file, void *fh, |
| 280 | struct v4l2_jpegcompression *a); | 275 | struct v4l2_jpegcompression *a); |
| 281 | int (*vidioc_s_jpegcomp) (struct file *file, void *fh, | 276 | int (*vidioc_s_jpegcomp) (struct file *file, void *fh, |
diff --git a/kernel/sysctl_check.c b/kernel/sysctl_check.c index 3c9ef5a7d575..ed6fe51df77a 100644 --- a/kernel/sysctl_check.c +++ b/kernel/sysctl_check.c | |||
| @@ -731,7 +731,7 @@ static struct trans_ctl_table trans_net_table[] = { | |||
| 731 | { NET_UNIX, "unix", trans_net_unix_table }, | 731 | { NET_UNIX, "unix", trans_net_unix_table }, |
| 732 | { NET_IPV4, "ipv4", trans_net_ipv4_table }, | 732 | { NET_IPV4, "ipv4", trans_net_ipv4_table }, |
| 733 | { NET_IPX, "ipx", trans_net_ipx_table }, | 733 | { NET_IPX, "ipx", trans_net_ipx_table }, |
| 734 | { NET_ATALK, "atalk", trans_net_atalk_table }, | 734 | { NET_ATALK, "appletalk", trans_net_atalk_table }, |
| 735 | { NET_NETROM, "netrom", trans_net_netrom_table }, | 735 | { NET_NETROM, "netrom", trans_net_netrom_table }, |
| 736 | { NET_AX25, "ax25", trans_net_ax25_table }, | 736 | { NET_AX25, "ax25", trans_net_ax25_table }, |
| 737 | { NET_BRIDGE, "bridge", trans_net_bridge_table }, | 737 | { NET_BRIDGE, "bridge", trans_net_bridge_table }, |
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index c567f219191d..1faa5087dc86 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -389,6 +389,16 @@ config DEBUG_LIST | |||
| 389 | 389 | ||
| 390 | If unsure, say N. | 390 | If unsure, say N. |
| 391 | 391 | ||
| 392 | config DEBUG_SG | ||
| 393 | bool "Debug SG table operations" | ||
| 394 | depends on DEBUG_KERNEL | ||
| 395 | help | ||
| 396 | Enable this to turn on checks on scatter-gather tables. This can | ||
| 397 | help find problems with drivers that do not properly initialize | ||
| 398 | their sg tables. | ||
| 399 | |||
| 400 | If unsure, say N. | ||
| 401 | |||
| 392 | config FRAME_POINTER | 402 | config FRAME_POINTER |
| 393 | bool "Compile the kernel with frame pointers" | 403 | bool "Compile the kernel with frame pointers" |
| 394 | depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || AVR32 || SUPERH || BFIN) | 404 | depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || AVR32 || SUPERH || BFIN) |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 752fd95323f3..1a8050ade861 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | #define OFFSET(val,align) ((unsigned long) \ | 35 | #define OFFSET(val,align) ((unsigned long) \ |
| 36 | ( (val) & ( (align) - 1))) | 36 | ( (val) & ( (align) - 1))) |
| 37 | 37 | ||
| 38 | #define SG_ENT_VIRT_ADDRESS(sg) (page_address((sg)->page) + (sg)->offset) | 38 | #define SG_ENT_VIRT_ADDRESS(sg) (sg_virt((sg))) |
| 39 | #define SG_ENT_PHYS_ADDRESS(sg) virt_to_bus(SG_ENT_VIRT_ADDRESS(sg)) | 39 | #define SG_ENT_PHYS_ADDRESS(sg) virt_to_bus(SG_ENT_VIRT_ADDRESS(sg)) |
| 40 | 40 | ||
| 41 | /* | 41 | /* |
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 1833879f8438..3a47871a29d9 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c | |||
| @@ -187,7 +187,24 @@ int online_pages(unsigned long pfn, unsigned long nr_pages) | |||
| 187 | unsigned long onlined_pages = 0; | 187 | unsigned long onlined_pages = 0; |
| 188 | struct zone *zone; | 188 | struct zone *zone; |
| 189 | int need_zonelists_rebuild = 0; | 189 | int need_zonelists_rebuild = 0; |
| 190 | int nid; | ||
| 191 | int ret; | ||
| 192 | struct memory_notify arg; | ||
| 193 | |||
| 194 | arg.start_pfn = pfn; | ||
| 195 | arg.nr_pages = nr_pages; | ||
| 196 | arg.status_change_nid = -1; | ||
| 197 | |||
| 198 | nid = page_to_nid(pfn_to_page(pfn)); | ||
| 199 | if (node_present_pages(nid) == 0) | ||
| 200 | arg.status_change_nid = nid; | ||
| 190 | 201 | ||
| 202 | ret = memory_notify(MEM_GOING_ONLINE, &arg); | ||
| 203 | ret = notifier_to_errno(ret); | ||
| 204 | if (ret) { | ||
| 205 | memory_notify(MEM_CANCEL_ONLINE, &arg); | ||
| 206 | return ret; | ||
| 207 | } | ||
| 191 | /* | 208 | /* |
| 192 | * This doesn't need a lock to do pfn_to_page(). | 209 | * This doesn't need a lock to do pfn_to_page(). |
| 193 | * The section can't be removed here because of the | 210 | * The section can't be removed here because of the |
| @@ -222,6 +239,10 @@ int online_pages(unsigned long pfn, unsigned long nr_pages) | |||
| 222 | build_all_zonelists(); | 239 | build_all_zonelists(); |
| 223 | vm_total_pages = nr_free_pagecache_pages(); | 240 | vm_total_pages = nr_free_pagecache_pages(); |
| 224 | writeback_set_ratelimit(); | 241 | writeback_set_ratelimit(); |
| 242 | |||
| 243 | if (onlined_pages) | ||
| 244 | memory_notify(MEM_ONLINE, &arg); | ||
| 245 | |||
| 225 | return 0; | 246 | return 0; |
| 226 | } | 247 | } |
| 227 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ | 248 | #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ |
| @@ -467,8 +488,9 @@ int offline_pages(unsigned long start_pfn, | |||
| 467 | { | 488 | { |
| 468 | unsigned long pfn, nr_pages, expire; | 489 | unsigned long pfn, nr_pages, expire; |
| 469 | long offlined_pages; | 490 | long offlined_pages; |
| 470 | int ret, drain, retry_max; | 491 | int ret, drain, retry_max, node; |
| 471 | struct zone *zone; | 492 | struct zone *zone; |
| 493 | struct memory_notify arg; | ||
| 472 | 494 | ||
| 473 | BUG_ON(start_pfn >= end_pfn); | 495 | BUG_ON(start_pfn >= end_pfn); |
| 474 | /* at least, alignment against pageblock is necessary */ | 496 | /* at least, alignment against pageblock is necessary */ |
| @@ -480,11 +502,27 @@ int offline_pages(unsigned long start_pfn, | |||
| 480 | we assume this for now. .*/ | 502 | we assume this for now. .*/ |
| 481 | if (!test_pages_in_a_zone(start_pfn, end_pfn)) | 503 | if (!test_pages_in_a_zone(start_pfn, end_pfn)) |
| 482 | return -EINVAL; | 504 | return -EINVAL; |
| 505 | |||
| 506 | zone = page_zone(pfn_to_page(start_pfn)); | ||
| 507 | node = zone_to_nid(zone); | ||
| 508 | nr_pages = end_pfn - start_pfn; | ||
| 509 | |||
| 483 | /* set above range as isolated */ | 510 | /* set above range as isolated */ |
| 484 | ret = start_isolate_page_range(start_pfn, end_pfn); | 511 | ret = start_isolate_page_range(start_pfn, end_pfn); |
| 485 | if (ret) | 512 | if (ret) |
| 486 | return ret; | 513 | return ret; |
| 487 | nr_pages = end_pfn - start_pfn; | 514 | |
| 515 | arg.start_pfn = start_pfn; | ||
| 516 | arg.nr_pages = nr_pages; | ||
| 517 | arg.status_change_nid = -1; | ||
| 518 | if (nr_pages >= node_present_pages(node)) | ||
| 519 | arg.status_change_nid = node; | ||
| 520 | |||
| 521 | ret = memory_notify(MEM_GOING_OFFLINE, &arg); | ||
| 522 | ret = notifier_to_errno(ret); | ||
| 523 | if (ret) | ||
| 524 | goto failed_removal; | ||
| 525 | |||
| 488 | pfn = start_pfn; | 526 | pfn = start_pfn; |
| 489 | expire = jiffies + timeout; | 527 | expire = jiffies + timeout; |
| 490 | drain = 0; | 528 | drain = 0; |
| @@ -539,20 +577,24 @@ repeat: | |||
| 539 | /* reset pagetype flags */ | 577 | /* reset pagetype flags */ |
| 540 | start_isolate_page_range(start_pfn, end_pfn); | 578 | start_isolate_page_range(start_pfn, end_pfn); |
| 541 | /* removal success */ | 579 | /* removal success */ |
| 542 | zone = page_zone(pfn_to_page(start_pfn)); | ||
| 543 | zone->present_pages -= offlined_pages; | 580 | zone->present_pages -= offlined_pages; |
| 544 | zone->zone_pgdat->node_present_pages -= offlined_pages; | 581 | zone->zone_pgdat->node_present_pages -= offlined_pages; |
| 545 | totalram_pages -= offlined_pages; | 582 | totalram_pages -= offlined_pages; |
| 546 | num_physpages -= offlined_pages; | 583 | num_physpages -= offlined_pages; |
| 584 | |||
| 547 | vm_total_pages = nr_free_pagecache_pages(); | 585 | vm_total_pages = nr_free_pagecache_pages(); |
| 548 | writeback_set_ratelimit(); | 586 | writeback_set_ratelimit(); |
| 587 | |||
| 588 | memory_notify(MEM_OFFLINE, &arg); | ||
| 549 | return 0; | 589 | return 0; |
| 550 | 590 | ||
| 551 | failed_removal: | 591 | failed_removal: |
| 552 | printk(KERN_INFO "memory offlining %lx to %lx failed\n", | 592 | printk(KERN_INFO "memory offlining %lx to %lx failed\n", |
| 553 | start_pfn, end_pfn); | 593 | start_pfn, end_pfn); |
| 594 | memory_notify(MEM_CANCEL_OFFLINE, &arg); | ||
| 554 | /* pushback to free area */ | 595 | /* pushback to free area */ |
| 555 | undo_isolate_page_range(start_pfn, end_pfn); | 596 | undo_isolate_page_range(start_pfn, end_pfn); |
| 597 | |||
| 556 | return ret; | 598 | return ret; |
| 557 | } | 599 | } |
| 558 | #else | 600 | #else |
diff --git a/mm/shmem.c b/mm/shmem.c index 289dbb0a6fd6..404e53bb2127 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
| @@ -2020,33 +2020,25 @@ static int shmem_match(struct inode *ino, void *vfh) | |||
| 2020 | return ino->i_ino == inum && fh[0] == ino->i_generation; | 2020 | return ino->i_ino == inum && fh[0] == ino->i_generation; |
| 2021 | } | 2021 | } |
| 2022 | 2022 | ||
| 2023 | static struct dentry *shmem_get_dentry(struct super_block *sb, void *vfh) | 2023 | static struct dentry *shmem_fh_to_dentry(struct super_block *sb, |
| 2024 | struct fid *fid, int fh_len, int fh_type) | ||
| 2024 | { | 2025 | { |
| 2025 | struct dentry *de = NULL; | ||
| 2026 | struct inode *inode; | 2026 | struct inode *inode; |
| 2027 | __u32 *fh = vfh; | 2027 | struct dentry *dentry = NULL; |
| 2028 | __u64 inum = fh[2]; | 2028 | u64 inum = fid->raw[2]; |
| 2029 | inum = (inum << 32) | fh[1]; | 2029 | inum = (inum << 32) | fid->raw[1]; |
| 2030 | |||
| 2031 | if (fh_len < 3) | ||
| 2032 | return NULL; | ||
| 2030 | 2033 | ||
| 2031 | inode = ilookup5(sb, (unsigned long)(inum+fh[0]), shmem_match, vfh); | 2034 | inode = ilookup5(sb, (unsigned long)(inum + fid->raw[0]), |
| 2035 | shmem_match, fid->raw); | ||
| 2032 | if (inode) { | 2036 | if (inode) { |
| 2033 | de = d_find_alias(inode); | 2037 | dentry = d_find_alias(inode); |
| 2034 | iput(inode); | 2038 | iput(inode); |
| 2035 | } | 2039 | } |
| 2036 | 2040 | ||
| 2037 | return de? de: ERR_PTR(-ESTALE); | 2041 | return dentry; |
| 2038 | } | ||
| 2039 | |||
| 2040 | static struct dentry *shmem_decode_fh(struct super_block *sb, __u32 *fh, | ||
| 2041 | int len, int type, | ||
| 2042 | int (*acceptable)(void *context, struct dentry *de), | ||
| 2043 | void *context) | ||
| 2044 | { | ||
| 2045 | if (len < 3) | ||
| 2046 | return ERR_PTR(-ESTALE); | ||
| 2047 | |||
| 2048 | return sb->s_export_op->find_exported_dentry(sb, fh, NULL, acceptable, | ||
| 2049 | context); | ||
| 2050 | } | 2042 | } |
| 2051 | 2043 | ||
| 2052 | static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len, | 2044 | static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len, |
| @@ -2079,11 +2071,10 @@ static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len, | |||
| 2079 | return 1; | 2071 | return 1; |
| 2080 | } | 2072 | } |
| 2081 | 2073 | ||
| 2082 | static struct export_operations shmem_export_ops = { | 2074 | static const struct export_operations shmem_export_ops = { |
| 2083 | .get_parent = shmem_get_parent, | 2075 | .get_parent = shmem_get_parent, |
| 2084 | .get_dentry = shmem_get_dentry, | ||
| 2085 | .encode_fh = shmem_encode_fh, | 2076 | .encode_fh = shmem_encode_fh, |
| 2086 | .decode_fh = shmem_decode_fh, | 2077 | .fh_to_dentry = shmem_fh_to_dentry, |
| 2087 | }; | 2078 | }; |
| 2088 | 2079 | ||
| 2089 | static int shmem_parse_options(char *options, int *mode, uid_t *uid, | 2080 | static int shmem_parse_options(char *options, int *mode, uid_t *uid, |
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/mempolicy.h> | 20 | #include <linux/mempolicy.h> |
| 21 | #include <linux/ctype.h> | 21 | #include <linux/ctype.h> |
| 22 | #include <linux/kallsyms.h> | 22 | #include <linux/kallsyms.h> |
| 23 | #include <linux/memory.h> | ||
| 23 | 24 | ||
| 24 | /* | 25 | /* |
| 25 | * Lock order: | 26 | * Lock order: |
| @@ -2694,6 +2695,121 @@ int kmem_cache_shrink(struct kmem_cache *s) | |||
| 2694 | } | 2695 | } |
| 2695 | EXPORT_SYMBOL(kmem_cache_shrink); | 2696 | EXPORT_SYMBOL(kmem_cache_shrink); |
| 2696 | 2697 | ||
| 2698 | #if defined(CONFIG_NUMA) && defined(CONFIG_MEMORY_HOTPLUG) | ||
| 2699 | static int slab_mem_going_offline_callback(void *arg) | ||
| 2700 | { | ||
| 2701 | struct kmem_cache *s; | ||
| 2702 | |||
| 2703 | down_read(&slub_lock); | ||
| 2704 | list_for_each_entry(s, &slab_caches, list) | ||
| 2705 | kmem_cache_shrink(s); | ||
| 2706 | up_read(&slub_lock); | ||
| 2707 | |||
| 2708 | return 0; | ||
| 2709 | } | ||
| 2710 | |||
| 2711 | static void slab_mem_offline_callback(void *arg) | ||
| 2712 | { | ||
| 2713 | struct kmem_cache_node *n; | ||
| 2714 | struct kmem_cache *s; | ||
| 2715 | struct memory_notify *marg = arg; | ||
| 2716 | int offline_node; | ||
| 2717 | |||
| 2718 | offline_node = marg->status_change_nid; | ||
| 2719 | |||
| 2720 | /* | ||
| 2721 | * If the node still has available memory. we need kmem_cache_node | ||
| 2722 | * for it yet. | ||
| 2723 | */ | ||
| 2724 | if (offline_node < 0) | ||
| 2725 | return; | ||
| 2726 | |||
| 2727 | down_read(&slub_lock); | ||
| 2728 | list_for_each_entry(s, &slab_caches, list) { | ||
| 2729 | n = get_node(s, offline_node); | ||
| 2730 | if (n) { | ||
| 2731 | /* | ||
| 2732 | * if n->nr_slabs > 0, slabs still exist on the node | ||
| 2733 | * that is going down. We were unable to free them, | ||
| 2734 | * and offline_pages() function shoudn't call this | ||
| 2735 | * callback. So, we must fail. | ||
| 2736 | */ | ||
| 2737 | BUG_ON(atomic_read(&n->nr_slabs)); | ||
| 2738 | |||
| 2739 | s->node[offline_node] = NULL; | ||
| 2740 | kmem_cache_free(kmalloc_caches, n); | ||
| 2741 | } | ||
| 2742 | } | ||
| 2743 | up_read(&slub_lock); | ||
| 2744 | } | ||
| 2745 | |||
| 2746 | static int slab_mem_going_online_callback(void *arg) | ||
| 2747 | { | ||
| 2748 | struct kmem_cache_node *n; | ||
| 2749 | struct kmem_cache *s; | ||
| 2750 | struct memory_notify *marg = arg; | ||
| 2751 | int nid = marg->status_change_nid; | ||
| 2752 | int ret = 0; | ||
| 2753 | |||
| 2754 | /* | ||
| 2755 | * If the node's memory is already available, then kmem_cache_node is | ||
| 2756 | * already created. Nothing to do. | ||
| 2757 | */ | ||
| 2758 | if (nid < 0) | ||
| 2759 | return 0; | ||
| 2760 | |||
| 2761 | /* | ||
| 2762 | * We are bringing a node online. No memory is availabe yet. We must | ||
| 2763 | * allocate a kmem_cache_node structure in order to bring the node | ||
| 2764 | * online. | ||
| 2765 | */ | ||
| 2766 | down_read(&slub_lock); | ||
| 2767 | list_for_each_entry(s, &slab_caches, list) { | ||
| 2768 | /* | ||
| 2769 | * XXX: kmem_cache_alloc_node will fallback to other nodes | ||
| 2770 | * since memory is not yet available from the node that | ||
| 2771 | * is brought up. | ||
| 2772 | */ | ||
| 2773 | n = kmem_cache_alloc(kmalloc_caches, GFP_KERNEL); | ||
| 2774 | if (!n) { | ||
| 2775 | ret = -ENOMEM; | ||
| 2776 | goto out; | ||
| 2777 | } | ||
| 2778 | init_kmem_cache_node(n); | ||
| 2779 | s->node[nid] = n; | ||
| 2780 | } | ||
| 2781 | out: | ||
| 2782 | up_read(&slub_lock); | ||
| 2783 | return ret; | ||
| 2784 | } | ||
| 2785 | |||
| 2786 | static int slab_memory_callback(struct notifier_block *self, | ||
| 2787 | unsigned long action, void *arg) | ||
| 2788 | { | ||
| 2789 | int ret = 0; | ||
| 2790 | |||
| 2791 | switch (action) { | ||
| 2792 | case MEM_GOING_ONLINE: | ||
| 2793 | ret = slab_mem_going_online_callback(arg); | ||
| 2794 | break; | ||
| 2795 | case MEM_GOING_OFFLINE: | ||
| 2796 | ret = slab_mem_going_offline_callback(arg); | ||
| 2797 | break; | ||
| 2798 | case MEM_OFFLINE: | ||
| 2799 | case MEM_CANCEL_ONLINE: | ||
| 2800 | slab_mem_offline_callback(arg); | ||
| 2801 | break; | ||
| 2802 | case MEM_ONLINE: | ||
| 2803 | case MEM_CANCEL_OFFLINE: | ||
| 2804 | break; | ||
| 2805 | } | ||
| 2806 | |||
| 2807 | ret = notifier_from_errno(ret); | ||
| 2808 | return ret; | ||
| 2809 | } | ||
| 2810 | |||
| 2811 | #endif /* CONFIG_MEMORY_HOTPLUG */ | ||
| 2812 | |||
| 2697 | /******************************************************************** | 2813 | /******************************************************************** |
| 2698 | * Basic setup of slabs | 2814 | * Basic setup of slabs |
| 2699 | *******************************************************************/ | 2815 | *******************************************************************/ |
| @@ -2715,6 +2831,8 @@ void __init kmem_cache_init(void) | |||
| 2715 | sizeof(struct kmem_cache_node), GFP_KERNEL); | 2831 | sizeof(struct kmem_cache_node), GFP_KERNEL); |
| 2716 | kmalloc_caches[0].refcount = -1; | 2832 | kmalloc_caches[0].refcount = -1; |
| 2717 | caches++; | 2833 | caches++; |
| 2834 | |||
| 2835 | hotplug_memory_notifier(slab_memory_callback, 1); | ||
| 2718 | #endif | 2836 | #endif |
| 2719 | 2837 | ||
| 2720 | /* Able to allocate the per node structures */ | 2838 | /* Able to allocate the per node structures */ |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 70d9b5da96ae..4e2c84fcf276 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
| @@ -2045,7 +2045,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) | |||
| 2045 | if (copy > 0) { | 2045 | if (copy > 0) { |
| 2046 | if (copy > len) | 2046 | if (copy > len) |
| 2047 | copy = len; | 2047 | copy = len; |
| 2048 | sg[elt].page = virt_to_page(skb->data + offset); | 2048 | sg_set_page(&sg[elt], virt_to_page(skb->data + offset)); |
| 2049 | sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; | 2049 | sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; |
| 2050 | sg[elt].length = copy; | 2050 | sg[elt].length = copy; |
| 2051 | elt++; | 2051 | elt++; |
| @@ -2065,7 +2065,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len) | |||
| 2065 | 2065 | ||
| 2066 | if (copy > len) | 2066 | if (copy > len) |
| 2067 | copy = len; | 2067 | copy = len; |
| 2068 | sg[elt].page = frag->page; | 2068 | sg_set_page(&sg[elt], frag->page); |
| 2069 | sg[elt].offset = frag->page_offset+offset-start; | 2069 | sg[elt].offset = frag->page_offset+offset-start; |
| 2070 | sg[elt].length = copy; | 2070 | sg[elt].length = copy; |
| 2071 | elt++; | 2071 | elt++; |
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c index 72e6ab66834f..c796661a021b 100644 --- a/net/ieee80211/ieee80211_crypt_tkip.c +++ b/net/ieee80211/ieee80211_crypt_tkip.c | |||
| @@ -390,9 +390,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
| 390 | icv[3] = crc >> 24; | 390 | icv[3] = crc >> 24; |
| 391 | 391 | ||
| 392 | crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); | 392 | crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); |
| 393 | sg.page = virt_to_page(pos); | 393 | sg_init_one(&sg, pos, len + 4); |
| 394 | sg.offset = offset_in_page(pos); | ||
| 395 | sg.length = len + 4; | ||
| 396 | return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); | 394 | return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); |
| 397 | } | 395 | } |
| 398 | 396 | ||
| @@ -485,9 +483,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
| 485 | plen = skb->len - hdr_len - 12; | 483 | plen = skb->len - hdr_len - 12; |
| 486 | 484 | ||
| 487 | crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); | 485 | crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16); |
| 488 | sg.page = virt_to_page(pos); | 486 | sg_init_one(&sg, pos, plen + 4); |
| 489 | sg.offset = offset_in_page(pos); | ||
| 490 | sg.length = plen + 4; | ||
| 491 | if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { | 487 | if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { |
| 492 | if (net_ratelimit()) { | 488 | if (net_ratelimit()) { |
| 493 | printk(KERN_DEBUG ": TKIP: failed to decrypt " | 489 | printk(KERN_DEBUG ": TKIP: failed to decrypt " |
| @@ -539,11 +535,12 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr, | |||
| 539 | printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); | 535 | printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); |
| 540 | return -1; | 536 | return -1; |
| 541 | } | 537 | } |
| 542 | sg[0].page = virt_to_page(hdr); | 538 | sg_init_table(sg, 2); |
| 539 | sg_set_page(&sg[0], virt_to_page(hdr)); | ||
| 543 | sg[0].offset = offset_in_page(hdr); | 540 | sg[0].offset = offset_in_page(hdr); |
| 544 | sg[0].length = 16; | 541 | sg[0].length = 16; |
| 545 | 542 | ||
| 546 | sg[1].page = virt_to_page(data); | 543 | sg_set_page(&sg[1], virt_to_page(data)); |
| 547 | sg[1].offset = offset_in_page(data); | 544 | sg[1].offset = offset_in_page(data); |
| 548 | sg[1].length = data_len; | 545 | sg[1].length = data_len; |
| 549 | 546 | ||
diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c index 8d182459344e..0af6103d715c 100644 --- a/net/ieee80211/ieee80211_crypt_wep.c +++ b/net/ieee80211/ieee80211_crypt_wep.c | |||
| @@ -170,9 +170,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
| 170 | icv[3] = crc >> 24; | 170 | icv[3] = crc >> 24; |
| 171 | 171 | ||
| 172 | crypto_blkcipher_setkey(wep->tx_tfm, key, klen); | 172 | crypto_blkcipher_setkey(wep->tx_tfm, key, klen); |
| 173 | sg.page = virt_to_page(pos); | 173 | sg_init_one(&sg, pos, len + 4); |
| 174 | sg.offset = offset_in_page(pos); | ||
| 175 | sg.length = len + 4; | ||
| 176 | return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); | 174 | return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); |
| 177 | } | 175 | } |
| 178 | 176 | ||
| @@ -212,9 +210,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) | |||
| 212 | plen = skb->len - hdr_len - 8; | 210 | plen = skb->len - hdr_len - 8; |
| 213 | 211 | ||
| 214 | crypto_blkcipher_setkey(wep->rx_tfm, key, klen); | 212 | crypto_blkcipher_setkey(wep->rx_tfm, key, klen); |
| 215 | sg.page = virt_to_page(pos); | 213 | sg_init_one(&sg, pos, plen + 4); |
| 216 | sg.offset = offset_in_page(pos); | ||
| 217 | sg.length = plen + 4; | ||
| 218 | if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) | 214 | if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) |
| 219 | return -7; | 215 | return -7; |
| 220 | 216 | ||
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index 6675261e958f..cc806d640f7a 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c | |||
| @@ -138,9 +138,7 @@ void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key, | |||
| 138 | *icv = cpu_to_le32(~crc32_le(~0, data, data_len)); | 138 | *icv = cpu_to_le32(~crc32_le(~0, data, data_len)); |
| 139 | 139 | ||
| 140 | crypto_blkcipher_setkey(tfm, rc4key, klen); | 140 | crypto_blkcipher_setkey(tfm, rc4key, klen); |
| 141 | sg.page = virt_to_page(data); | 141 | sg_init_one(&sg, data, data_len + WEP_ICV_LEN); |
| 142 | sg.offset = offset_in_page(data); | ||
| 143 | sg.length = data_len + WEP_ICV_LEN; | ||
| 144 | crypto_blkcipher_encrypt(&desc, &sg, &sg, sg.length); | 142 | crypto_blkcipher_encrypt(&desc, &sg, &sg, sg.length); |
| 145 | } | 143 | } |
| 146 | 144 | ||
| @@ -204,9 +202,7 @@ int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key, | |||
| 204 | __le32 crc; | 202 | __le32 crc; |
| 205 | 203 | ||
| 206 | crypto_blkcipher_setkey(tfm, rc4key, klen); | 204 | crypto_blkcipher_setkey(tfm, rc4key, klen); |
| 207 | sg.page = virt_to_page(data); | 205 | sg_init_one(&sg, data, data_len + WEP_ICV_LEN); |
| 208 | sg.offset = offset_in_page(data); | ||
| 209 | sg.length = data_len + WEP_ICV_LEN; | ||
| 210 | crypto_blkcipher_decrypt(&desc, &sg, &sg, sg.length); | 206 | crypto_blkcipher_decrypt(&desc, &sg, &sg, sg.length); |
| 211 | 207 | ||
| 212 | crc = cpu_to_le32(~crc32_le(~0, data, data_len)); | 208 | crc = cpu_to_le32(~crc32_le(~0, data, data_len)); |
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 781810724714..cbd64b216cce 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c | |||
| @@ -726,7 +726,8 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc, | |||
| 726 | 726 | ||
| 727 | /* set up scatter list */ | 727 | /* set up scatter list */ |
| 728 | end = skb_tail_pointer(skb); | 728 | end = skb_tail_pointer(skb); |
| 729 | sg.page = virt_to_page(auth); | 729 | sg_init_table(&sg, 1); |
| 730 | sg_set_page(&sg, virt_to_page(auth)); | ||
| 730 | sg.offset = (unsigned long)(auth) % PAGE_SIZE; | 731 | sg.offset = (unsigned long)(auth) % PAGE_SIZE; |
| 731 | sg.length = end - (unsigned char *)auth; | 732 | sg.length = end - (unsigned char *)auth; |
| 732 | 733 | ||
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index f983a369d4e2..d5a9785a158b 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
| @@ -1513,7 +1513,8 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep, | |||
| 1513 | struct hash_desc desc; | 1513 | struct hash_desc desc; |
| 1514 | 1514 | ||
| 1515 | /* Sign the message. */ | 1515 | /* Sign the message. */ |
| 1516 | sg.page = virt_to_page(&cookie->c); | 1516 | sg_init_table(&sg, 1); |
| 1517 | sg_set_page(&sg, virt_to_page(&cookie->c)); | ||
| 1517 | sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE; | 1518 | sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE; |
| 1518 | sg.length = bodysize; | 1519 | sg.length = bodysize; |
| 1519 | keylen = SCTP_SECRET_SIZE; | 1520 | keylen = SCTP_SECRET_SIZE; |
| @@ -1585,7 +1586,8 @@ struct sctp_association *sctp_unpack_cookie( | |||
| 1585 | 1586 | ||
| 1586 | /* Check the signature. */ | 1587 | /* Check the signature. */ |
| 1587 | keylen = SCTP_SECRET_SIZE; | 1588 | keylen = SCTP_SECRET_SIZE; |
| 1588 | sg.page = virt_to_page(bear_cookie); | 1589 | sg_init_table(&sg, 1); |
| 1590 | sg_set_page(&sg, virt_to_page(bear_cookie)); | ||
| 1589 | sg.offset = (unsigned long)(bear_cookie) % PAGE_SIZE; | 1591 | sg.offset = (unsigned long)(bear_cookie) % PAGE_SIZE; |
| 1590 | sg.length = bodysize; | 1592 | sg.length = bodysize; |
| 1591 | key = (char *)ep->secret_key[ep->current_key]; | 1593 | key = (char *)ep->secret_key[ep->current_key]; |
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c index bfb6a29633dd..32be431affcf 100644 --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c | |||
| @@ -197,9 +197,9 @@ encryptor(struct scatterlist *sg, void *data) | |||
| 197 | int i = (page_pos + outbuf->page_base) >> PAGE_CACHE_SHIFT; | 197 | int i = (page_pos + outbuf->page_base) >> PAGE_CACHE_SHIFT; |
| 198 | in_page = desc->pages[i]; | 198 | in_page = desc->pages[i]; |
| 199 | } else { | 199 | } else { |
| 200 | in_page = sg->page; | 200 | in_page = sg_page(sg); |
| 201 | } | 201 | } |
| 202 | desc->infrags[desc->fragno].page = in_page; | 202 | sg_set_page(&desc->infrags[desc->fragno], in_page); |
| 203 | desc->fragno++; | 203 | desc->fragno++; |
| 204 | desc->fraglen += sg->length; | 204 | desc->fraglen += sg->length; |
| 205 | desc->pos += sg->length; | 205 | desc->pos += sg->length; |
| @@ -215,11 +215,11 @@ encryptor(struct scatterlist *sg, void *data) | |||
| 215 | if (ret) | 215 | if (ret) |
| 216 | return ret; | 216 | return ret; |
| 217 | if (fraglen) { | 217 | if (fraglen) { |
| 218 | desc->outfrags[0].page = sg->page; | 218 | sg_set_page(&desc->outfrags[0], sg_page(sg)); |
| 219 | desc->outfrags[0].offset = sg->offset + sg->length - fraglen; | 219 | desc->outfrags[0].offset = sg->offset + sg->length - fraglen; |
| 220 | desc->outfrags[0].length = fraglen; | 220 | desc->outfrags[0].length = fraglen; |
| 221 | desc->infrags[0] = desc->outfrags[0]; | 221 | desc->infrags[0] = desc->outfrags[0]; |
| 222 | desc->infrags[0].page = in_page; | 222 | sg_set_page(&desc->infrags[0], in_page); |
| 223 | desc->fragno = 1; | 223 | desc->fragno = 1; |
| 224 | desc->fraglen = fraglen; | 224 | desc->fraglen = fraglen; |
| 225 | } else { | 225 | } else { |
| @@ -287,7 +287,7 @@ decryptor(struct scatterlist *sg, void *data) | |||
| 287 | if (ret) | 287 | if (ret) |
| 288 | return ret; | 288 | return ret; |
| 289 | if (fraglen) { | 289 | if (fraglen) { |
| 290 | desc->frags[0].page = sg->page; | 290 | sg_set_page(&desc->frags[0], sg_page(sg)); |
| 291 | desc->frags[0].offset = sg->offset + sg->length - fraglen; | 291 | desc->frags[0].offset = sg->offset + sg->length - fraglen; |
| 292 | desc->frags[0].length = fraglen; | 292 | desc->frags[0].length = fraglen; |
| 293 | desc->fragno = 1; | 293 | desc->fragno = 1; |
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 6a59180e1667..3d1f7cdf9dd0 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c | |||
| @@ -1059,7 +1059,7 @@ xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, | |||
| 1059 | do { | 1059 | do { |
| 1060 | if (thislen > page_len) | 1060 | if (thislen > page_len) |
| 1061 | thislen = page_len; | 1061 | thislen = page_len; |
| 1062 | sg->page = buf->pages[i]; | 1062 | sg_set_page(sg, buf->pages[i]); |
| 1063 | sg->offset = page_offset; | 1063 | sg->offset = page_offset; |
| 1064 | sg->length = thislen; | 1064 | sg->length = thislen; |
| 1065 | ret = actor(sg, data); | 1065 | ret = actor(sg, data); |
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c index 5ced62c19c63..fb2220a719bd 100644 --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c | |||
| @@ -552,7 +552,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc, | |||
| 552 | if (copy > len) | 552 | if (copy > len) |
| 553 | copy = len; | 553 | copy = len; |
| 554 | 554 | ||
| 555 | sg.page = virt_to_page(skb->data + offset); | 555 | sg_set_page(&sg, virt_to_page(skb->data + offset)); |
| 556 | sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; | 556 | sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE; |
| 557 | sg.length = copy; | 557 | sg.length = copy; |
| 558 | 558 | ||
| @@ -577,7 +577,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc, | |||
| 577 | if (copy > len) | 577 | if (copy > len) |
| 578 | copy = len; | 578 | copy = len; |
| 579 | 579 | ||
| 580 | sg.page = frag->page; | 580 | sg_set_page(&sg, frag->page); |
| 581 | sg.offset = frag->page_offset + offset-start; | 581 | sg.offset = frag->page_offset + offset-start; |
| 582 | sg.length = copy; | 582 | sg.length = copy; |
| 583 | 583 | ||
diff --git a/security/commoncap.c b/security/commoncap.c index 43f902750a1b..bf67871173ef 100644 --- a/security/commoncap.c +++ b/security/commoncap.c | |||
| @@ -190,7 +190,8 @@ int cap_inode_killpriv(struct dentry *dentry) | |||
| 190 | return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS); | 190 | return inode->i_op->removexattr(dentry, XATTR_NAME_CAPS); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | static inline int cap_from_disk(__le32 *caps, struct linux_binprm *bprm, | 193 | static inline int cap_from_disk(struct vfs_cap_data *caps, |
| 194 | struct linux_binprm *bprm, | ||
| 194 | int size) | 195 | int size) |
| 195 | { | 196 | { |
| 196 | __u32 magic_etc; | 197 | __u32 magic_etc; |
| @@ -198,7 +199,7 @@ static inline int cap_from_disk(__le32 *caps, struct linux_binprm *bprm, | |||
| 198 | if (size != XATTR_CAPS_SZ) | 199 | if (size != XATTR_CAPS_SZ) |
| 199 | return -EINVAL; | 200 | return -EINVAL; |
| 200 | 201 | ||
| 201 | magic_etc = le32_to_cpu(caps[0]); | 202 | magic_etc = le32_to_cpu(caps->magic_etc); |
| 202 | 203 | ||
| 203 | switch ((magic_etc & VFS_CAP_REVISION_MASK)) { | 204 | switch ((magic_etc & VFS_CAP_REVISION_MASK)) { |
| 204 | case VFS_CAP_REVISION: | 205 | case VFS_CAP_REVISION: |
| @@ -206,8 +207,8 @@ static inline int cap_from_disk(__le32 *caps, struct linux_binprm *bprm, | |||
| 206 | bprm->cap_effective = true; | 207 | bprm->cap_effective = true; |
| 207 | else | 208 | else |
| 208 | bprm->cap_effective = false; | 209 | bprm->cap_effective = false; |
| 209 | bprm->cap_permitted = to_cap_t( le32_to_cpu(caps[1]) ); | 210 | bprm->cap_permitted = to_cap_t(le32_to_cpu(caps->permitted)); |
| 210 | bprm->cap_inheritable = to_cap_t( le32_to_cpu(caps[2]) ); | 211 | bprm->cap_inheritable = to_cap_t(le32_to_cpu(caps->inheritable)); |
| 211 | return 0; | 212 | return 0; |
| 212 | default: | 213 | default: |
| 213 | return -EINVAL; | 214 | return -EINVAL; |
| @@ -219,7 +220,7 @@ static int get_file_caps(struct linux_binprm *bprm) | |||
| 219 | { | 220 | { |
| 220 | struct dentry *dentry; | 221 | struct dentry *dentry; |
| 221 | int rc = 0; | 222 | int rc = 0; |
| 222 | __le32 v1caps[XATTR_CAPS_SZ]; | 223 | struct vfs_cap_data incaps; |
| 223 | struct inode *inode; | 224 | struct inode *inode; |
| 224 | 225 | ||
| 225 | if (bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID) { | 226 | if (bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID) { |
| @@ -232,8 +233,14 @@ static int get_file_caps(struct linux_binprm *bprm) | |||
| 232 | if (!inode->i_op || !inode->i_op->getxattr) | 233 | if (!inode->i_op || !inode->i_op->getxattr) |
| 233 | goto out; | 234 | goto out; |
| 234 | 235 | ||
| 235 | rc = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, &v1caps, | 236 | rc = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, NULL, 0); |
| 236 | XATTR_CAPS_SZ); | 237 | if (rc > 0) { |
| 238 | if (rc == XATTR_CAPS_SZ) | ||
| 239 | rc = inode->i_op->getxattr(dentry, XATTR_NAME_CAPS, | ||
| 240 | &incaps, XATTR_CAPS_SZ); | ||
| 241 | else | ||
| 242 | rc = -EINVAL; | ||
| 243 | } | ||
| 237 | if (rc == -ENODATA || rc == -EOPNOTSUPP) { | 244 | if (rc == -ENODATA || rc == -EOPNOTSUPP) { |
| 238 | /* no data, that's ok */ | 245 | /* no data, that's ok */ |
| 239 | rc = 0; | 246 | rc = 0; |
| @@ -242,7 +249,7 @@ static int get_file_caps(struct linux_binprm *bprm) | |||
| 242 | if (rc < 0) | 249 | if (rc < 0) |
| 243 | goto out; | 250 | goto out; |
| 244 | 251 | ||
| 245 | rc = cap_from_disk(v1caps, bprm, rc); | 252 | rc = cap_from_disk(&incaps, bprm, rc); |
| 246 | if (rc) | 253 | if (rc) |
| 247 | printk(KERN_NOTICE "%s: cap_from_disk returned %d for %s\n", | 254 | printk(KERN_NOTICE "%s: cap_from_disk returned %d for %s\n", |
| 248 | __FUNCTION__, rc, bprm->filename); | 255 | __FUNCTION__, rc, bprm->filename); |
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c index fe31bb5cffb8..37c47fb95aca 100644 --- a/sound/i2c/other/tea575x-tuner.c +++ b/sound/i2c/other/tea575x-tuner.c | |||
| @@ -189,7 +189,6 @@ void snd_tea575x_init(struct snd_tea575x *tea) | |||
| 189 | tea->vd.owner = tea->card->module; | 189 | tea->vd.owner = tea->card->module; |
| 190 | strcpy(tea->vd.name, tea->tea5759 ? "TEA5759 radio" : "TEA5757 radio"); | 190 | strcpy(tea->vd.name, tea->tea5759 ? "TEA5759 radio" : "TEA5757 radio"); |
| 191 | tea->vd.type = VID_TYPE_TUNER; | 191 | tea->vd.type = VID_TYPE_TUNER; |
| 192 | tea->vd.hardware = VID_HARDWARE_RTRACK; /* FIXME: assign new number */ | ||
| 193 | tea->vd.release = snd_tea575x_release; | 192 | tea->vd.release = snd_tea575x_release; |
| 194 | video_set_drvdata(&tea->vd, tea); | 193 | video_set_drvdata(&tea->vd, tea); |
| 195 | tea->vd.fops = &tea->fops; | 194 | tea->vd.fops = &tea->fops; |
