Print this page
5253 kmem_alloc/kmem_zalloc won't fail with KM_SLEEP
5254 getrbuf won't fail with KM_SLEEP
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/i86pc/io/gfx_private/gfxp_devmap.c
+++ new/usr/src/uts/i86pc/io/gfx_private/gfxp_devmap.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 -#pragma ident "%Z%%M% %I% %E% SMI"
28 -
29 27 #include <sys/debug.h>
30 28 #include <sys/types.h>
31 29 #include <sys/param.h>
32 30 #include <sys/time.h>
33 31 #include <sys/buf.h>
34 32 #include <sys/errno.h>
35 33 #include <sys/systm.h>
36 34 #include <sys/conf.h>
37 35 #include <sys/signal.h>
38 36 #include <vm/page.h>
39 37 #include <vm/as.h>
40 38 #include <vm/hat.h>
41 39 #include <vm/seg.h>
42 40 #include <vm/seg_dev.h>
43 41 #include <vm/hat_i86.h>
44 42 #include <sys/ddi.h>
45 43 #include <sys/devops.h>
46 44 #include <sys/sunddi.h>
47 45 #include <sys/ddi_impldefs.h>
48 46 #include <sys/fs/snode.h>
49 47 #include <sys/pci.h>
50 48 #include <sys/vmsystm.h>
51 49 #include <sys/int_fmtio.h>
52 50 #include "gfx_private.h"
53 51
54 52 #ifdef __xpv
55 53 #include <sys/hypervisor.h>
56 54 #endif
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
57 55
58 56 /*
59 57 * Create a dummy ddi_umem_cookie given to gfxp_devmap_umem_setup().
60 58 */
61 59 ddi_umem_cookie_t
62 60 gfxp_umem_cookie_init(caddr_t kva, size_t size)
63 61 {
64 62 struct ddi_umem_cookie *umem_cookie;
65 63
66 64 umem_cookie = kmem_zalloc(sizeof (struct ddi_umem_cookie), KM_SLEEP);
67 -
68 - if (umem_cookie == NULL)
69 - return (NULL);
70 65
71 66 umem_cookie->cvaddr = kva;
72 67 umem_cookie->type = KMEM_NON_PAGEABLE;
73 68 umem_cookie->size = size;
74 69
75 70 return ((ddi_umem_cookie_t *)umem_cookie);
76 71 }
77 72
78 73 void
79 74 gfxp_umem_cookie_destroy(ddi_umem_cookie_t cookie)
80 75 {
81 76 kmem_free(cookie, sizeof (struct ddi_umem_cookie));
82 77 }
83 78
84 79 /*
85 80 * called by driver devmap routine to pass kernel virtual address mapping
86 81 * info to the framework.
87 82 */
88 83 /*ARGSUSED*/
89 84 int
90 85 gfxp_devmap_umem_setup(devmap_cookie_t dhc, dev_info_t *dip,
91 86 struct devmap_callback_ctl *callbackops, ddi_umem_cookie_t cookie,
92 87 offset_t off, size_t len, uint_t maxprot, uint_t flags,
93 88 ddi_device_acc_attr_t *accattrp)
94 89 {
95 90 uint_t l_flags = flags & ~IOMEM_DATA_MASK; /* clear cache attrs */
96 91 int e;
97 92
98 93 /*
99 94 * Set an appropriate attribute from devacc_attr_dataorder
100 95 * to keep compatibility. The cache attributes are igonred
101 96 * if specified.
102 97 */
103 98 if (accattrp != NULL) {
104 99 if (accattrp->devacc_attr_dataorder == DDI_STRICTORDER_ACC) {
105 100 l_flags |= IOMEM_DATA_UNCACHED;
106 101 } else if (accattrp->devacc_attr_dataorder ==
107 102 DDI_MERGING_OK_ACC) {
108 103 l_flags |= IOMEM_DATA_UC_WR_COMBINE;
109 104 } else {
110 105 l_flags |= IOMEM_DATA_CACHED;
111 106 }
112 107 }
113 108
114 109 e = devmap_umem_setup(dhc, dip, callbackops, cookie, off, len, maxprot,
115 110 l_flags, accattrp);
116 111 return (e);
117 112 }
118 113
119 114 /*
120 115 * Replacement for devmap_devmem_setup() which will map a machine address
121 116 * instead of a register set/offset.
122 117 */
123 118 void
124 119 gfxp_map_devmem(devmap_cookie_t dhc, gfx_maddr_t maddr, size_t length,
125 120 ddi_device_acc_attr_t *attrp)
126 121 {
127 122 devmap_handle_t *dhp = (devmap_handle_t *)dhc;
128 123 pfn_t pfn;
129 124
130 125
131 126 #ifdef __xpv
132 127 ASSERT(DOMAIN_IS_INITDOMAIN(xen_info));
133 128 pfn = xen_assign_pfn(mmu_btop(maddr));
134 129 #else
135 130 pfn = mmu_btop(maddr);
136 131 #endif
137 132
138 133 dhp->dh_pfn = pfn;
139 134 dhp->dh_len = mmu_ptob(mmu_btopr(length));
140 135 dhp->dh_roff = 0;
141 136
142 137 #ifndef DEVMAP_DEVMEM_COOKIE
143 138 #define DEVMAP_DEVMEM_COOKIE ((ddi_umem_cookie_t)0x1) /* XXPV */
144 139 #endif /* DEVMAP_DEVMEM_COOKIE */
145 140 dhp->dh_cookie = DEVMAP_DEVMEM_COOKIE;
146 141 /*LINTED: E_EXPR_NULL_EFFECT*/
147 142 dhp->dh_flags |= DEVMAP_DEFAULTS;
148 143 dhp->dh_maxprot = PROT_ALL & dhp->dh_orig_maxprot;
149 144
150 145 /* no callbacks needed */
151 146 bzero(&dhp->dh_callbackops, sizeof (struct devmap_callback_ctl));
152 147
153 148 switch (attrp->devacc_attr_dataorder) {
154 149 case DDI_UNORDERED_OK_ACC:
155 150 dhp->dh_hat_attr = HAT_UNORDERED_OK;
156 151 break;
157 152 case DDI_MERGING_OK_ACC:
158 153 dhp->dh_hat_attr = HAT_MERGING_OK;
159 154 break;
160 155 case DDI_LOADCACHING_OK_ACC:
161 156 dhp->dh_hat_attr = HAT_LOADCACHING_OK;
162 157 break;
163 158 case DDI_STORECACHING_OK_ACC:
164 159 dhp->dh_hat_attr = HAT_STORECACHING_OK;
165 160 break;
166 161 case DDI_STRICTORDER_ACC:
167 162 default:
168 163 dhp->dh_hat_attr = HAT_STRICTORDER;
169 164 }
170 165
171 166 /* don't use large pages */
172 167 dhp->dh_mmulevel = 0;
173 168 dhp->dh_flags &= ~DEVMAP_FLAG_LARGE;
174 169
175 170 dhp->dh_flags |= DEVMAP_SETUP_DONE;
176 171 }
↓ open down ↓ |
97 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX