~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/staging/tidspbridge/rmgr/nldr.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
 *   uuuuuuuu|fueeeeee|fudddddd|fucccccc|
58
58
 *  where
59
59
 *      u = unused
60
 
 *      cccccc = prefered/required dynamic mem segid for create phase data/code
61
 
 *      dddddd = prefered/required dynamic mem segid for delete phase data/code
62
 
 *      eeeeee = prefered/req. dynamic mem segid for execute phase data/code
 
60
 *      cccccc = preferred/required dynamic mem segid for create phase data/code
 
61
 *      dddddd = preferred/required dynamic mem segid for delete phase data/code
 
62
 *      eeeeee = preferred/req. dynamic mem segid for execute phase data/code
63
63
 *      f = flag indicating if memory is preferred or required:
64
64
 *        f = 1 if required, f = 0 if preferred.
65
65
 *
190
190
 *  Overlay loader object.
191
191
 */
192
192
struct nldr_object {
193
 
        struct dev_object *hdev_obj;    /* Device object */
194
 
        struct dcd_manager *hdcd_mgr;   /* Proc/Node data manager */
 
193
        struct dev_object *dev_obj;     /* Device object */
 
194
        struct dcd_manager *dcd_mgr;    /* Proc/Node data manager */
195
195
        struct dbll_tar_obj *dbll;      /* The DBL loader */
196
196
        struct dbll_library_obj *base_lib;      /* Base image library */
197
197
        struct rmm_target_obj *rmm;     /* Remote memory manager for DSP */
206
206
        u32 *seg_table;         /* memtypes of dynamic memory segs
207
207
                                 * indexed by segid
208
208
                                 */
209
 
        u16 us_dsp_mau_size;    /* Size of DSP MAU */
210
 
        u16 us_dsp_word_size;   /* Size of DSP word */
 
209
        u16 dsp_mau_size;       /* Size of DSP MAU */
 
210
        u16 dsp_word_size;      /* Size of DSP word */
211
211
};
212
212
 
213
213
/*
220
220
        struct dsp_uuid uuid;   /* Node's UUID */
221
221
        bool dynamic;           /* Dynamically loaded node? */
222
222
        bool overlay;           /* Overlay node? */
223
 
        bool *pf_phase_split;   /* Multiple phase libraries? */
 
223
        bool *phase_split;      /* Multiple phase libraries? */
224
224
        struct lib_node root;   /* Library containing node phase */
225
225
        struct lib_node create_lib;     /* Library with create phase lib */
226
226
        struct lib_node execute_lib;    /* Library with execute phase lib */
260
260
        (dbll_get_sect_fxn) dbll_get_sect,
261
261
        (dbll_init_fxn) dbll_init,
262
262
        (dbll_load_fxn) dbll_load,
263
 
        (dbll_load_sect_fxn) dbll_load_sect,
264
263
        (dbll_open_fxn) dbll_open,
265
264
        (dbll_read_sect_fxn) dbll_read_sect,
266
 
        (dbll_set_attrs_fxn) dbll_set_attrs,
267
265
        (dbll_unload_fxn) dbll_unload,
268
 
        (dbll_unload_sect_fxn) dbll_unload_sect,
269
266
};
270
267
 
271
268
static u32 refs;                /* module reference count */
329
326
        if (nldr_node_obj == NULL) {
330
327
                status = -ENOMEM;
331
328
        } else {
332
 
                nldr_node_obj->pf_phase_split = pf_phase_split;
 
329
                nldr_node_obj->phase_split = pf_phase_split;
333
330
                nldr_node_obj->pers_libs = 0;
334
331
                nldr_node_obj->nldr_obj = nldr_obj;
335
332
                nldr_node_obj->priv_ref = priv_ref;
339
336
                 *  Determine if node is a dynamically loaded node from
340
337
                 *  ndb_props.
341
338
                 */
342
 
                if (node_props->us_load_type == NLDR_DYNAMICLOAD) {
 
339
                if (node_props->load_type == NLDR_DYNAMICLOAD) {
343
340
                        /* Dynamic node */
344
341
                        nldr_node_obj->dynamic = true;
345
342
                        /*
347
344
                         */
348
345
                        /* Create phase */
349
346
                        nldr_node_obj->seg_id[CREATEDATAFLAGBIT] = (u16)
350
 
                            (node_props->ul_data_mem_seg_mask >> CREATEBIT) &
 
347
                            (node_props->data_mem_seg_mask >> CREATEBIT) &
351
348
                            SEGMASK;
352
349
                        nldr_node_obj->code_data_flag_mask |=
353
 
                            ((node_props->ul_data_mem_seg_mask >>
 
350
                            ((node_props->data_mem_seg_mask >>
354
351
                              (CREATEBIT + FLAGBIT)) & 1) << CREATEDATAFLAGBIT;
355
352
                        nldr_node_obj->seg_id[CREATECODEFLAGBIT] = (u16)
356
 
                            (node_props->ul_code_mem_seg_mask >>
 
353
                            (node_props->code_mem_seg_mask >>
357
354
                             CREATEBIT) & SEGMASK;
358
355
                        nldr_node_obj->code_data_flag_mask |=
359
 
                            ((node_props->ul_code_mem_seg_mask >>
 
356
                            ((node_props->code_mem_seg_mask >>
360
357
                              (CREATEBIT + FLAGBIT)) & 1) << CREATECODEFLAGBIT;
361
358
                        /* Execute phase */
362
359
                        nldr_node_obj->seg_id[EXECUTEDATAFLAGBIT] = (u16)
363
 
                            (node_props->ul_data_mem_seg_mask >>
 
360
                            (node_props->data_mem_seg_mask >>
364
361
                             EXECUTEBIT) & SEGMASK;
365
362
                        nldr_node_obj->code_data_flag_mask |=
366
 
                            ((node_props->ul_data_mem_seg_mask >>
 
363
                            ((node_props->data_mem_seg_mask >>
367
364
                              (EXECUTEBIT + FLAGBIT)) & 1) <<
368
365
                            EXECUTEDATAFLAGBIT;
369
366
                        nldr_node_obj->seg_id[EXECUTECODEFLAGBIT] = (u16)
370
 
                            (node_props->ul_code_mem_seg_mask >>
 
367
                            (node_props->code_mem_seg_mask >>
371
368
                             EXECUTEBIT) & SEGMASK;
372
369
                        nldr_node_obj->code_data_flag_mask |=
373
 
                            ((node_props->ul_code_mem_seg_mask >>
 
370
                            ((node_props->code_mem_seg_mask >>
374
371
                              (EXECUTEBIT + FLAGBIT)) & 1) <<
375
372
                            EXECUTECODEFLAGBIT;
376
373
                        /* Delete phase */
377
374
                        nldr_node_obj->seg_id[DELETEDATAFLAGBIT] = (u16)
378
 
                            (node_props->ul_data_mem_seg_mask >> DELETEBIT) &
 
375
                            (node_props->data_mem_seg_mask >> DELETEBIT) &
379
376
                            SEGMASK;
380
377
                        nldr_node_obj->code_data_flag_mask |=
381
 
                            ((node_props->ul_data_mem_seg_mask >>
 
378
                            ((node_props->data_mem_seg_mask >>
382
379
                              (DELETEBIT + FLAGBIT)) & 1) << DELETEDATAFLAGBIT;
383
380
                        nldr_node_obj->seg_id[DELETECODEFLAGBIT] = (u16)
384
 
                            (node_props->ul_code_mem_seg_mask >>
 
381
                            (node_props->code_mem_seg_mask >>
385
382
                             DELETEBIT) & SEGMASK;
386
383
                        nldr_node_obj->code_data_flag_mask |=
387
 
                            ((node_props->ul_code_mem_seg_mask >>
 
384
                            ((node_props->code_mem_seg_mask >>
388
385
                              (DELETEBIT + FLAGBIT)) & 1) << DELETECODEFLAGBIT;
389
386
                } else {
390
387
                        /* Non-dynamically loaded nodes are part of the
391
388
                         * base image */
392
389
                        nldr_node_obj->root.lib = nldr_obj->base_lib;
393
390
                        /* Check for overlay node */
394
 
                        if (node_props->us_load_type == NLDR_OVLYLOAD)
 
391
                        if (node_props->load_type == NLDR_OVLYLOAD)
395
392
                                nldr_node_obj->overlay = true;
396
393
 
397
394
                }
432
429
        DBC_REQUIRE(nldr != NULL);
433
430
        DBC_REQUIRE(hdev_obj != NULL);
434
431
        DBC_REQUIRE(pattrs != NULL);
435
 
        DBC_REQUIRE(pattrs->pfn_ovly != NULL);
436
 
        DBC_REQUIRE(pattrs->pfn_write != NULL);
 
432
        DBC_REQUIRE(pattrs->ovly != NULL);
 
433
        DBC_REQUIRE(pattrs->write != NULL);
437
434
 
438
435
        /* Allocate dynamic loader object */
439
436
        nldr_obj = kzalloc(sizeof(struct nldr_object), GFP_KERNEL);
440
437
        if (nldr_obj) {
441
 
                nldr_obj->hdev_obj = hdev_obj;
 
438
                nldr_obj->dev_obj = hdev_obj;
442
439
                /* warning, lazy status checking alert! */
443
440
                dev_get_cod_mgr(hdev_obj, &cod_mgr);
444
441
                if (cod_mgr) {
453
450
                }
454
451
                status = 0;
455
452
                /* end lazy status checking */
456
 
                nldr_obj->us_dsp_mau_size = pattrs->us_dsp_mau_size;
457
 
                nldr_obj->us_dsp_word_size = pattrs->us_dsp_word_size;
 
453
                nldr_obj->dsp_mau_size = pattrs->dsp_mau_size;
 
454
                nldr_obj->dsp_word_size = pattrs->dsp_word_size;
458
455
                nldr_obj->ldr_fxns = ldr_fxns;
459
456
                if (!(nldr_obj->ldr_fxns.init_fxn()))
460
457
                        status = -ENOMEM;
464
461
        }
465
462
        /* Create the DCD Manager */
466
463
        if (!status)
467
 
                status = dcd_create_manager(NULL, &nldr_obj->hdcd_mgr);
 
464
                status = dcd_create_manager(NULL, &nldr_obj->dcd_mgr);
468
465
 
469
466
        /* Get dynamic loading memory sections from base lib */
470
467
        if (!status) {
474
471
                                                    &ul_len);
475
472
                if (!status) {
476
473
                        psz_coff_buf =
477
 
                                kzalloc(ul_len * nldr_obj->us_dsp_mau_size,
 
474
                                kzalloc(ul_len * nldr_obj->dsp_mau_size,
478
475
                                                                GFP_KERNEL);
479
476
                        if (!psz_coff_buf)
480
477
                                status = -ENOMEM;
536
533
                new_attrs.free = (dbll_free_fxn) remote_free;
537
534
                new_attrs.sym_lookup = (dbll_sym_lookup) get_symbol_value;
538
535
                new_attrs.sym_handle = nldr_obj;
539
 
                new_attrs.write = (dbll_write_fxn) pattrs->pfn_write;
540
 
                nldr_obj->ovly_fxn = pattrs->pfn_ovly;
541
 
                nldr_obj->write_fxn = pattrs->pfn_write;
 
536
                new_attrs.write = (dbll_write_fxn) pattrs->write;
 
537
                nldr_obj->ovly_fxn = pattrs->ovly;
 
538
                nldr_obj->write_fxn = pattrs->write;
542
539
                nldr_obj->ldr_attrs = new_attrs;
543
540
        }
544
541
        kfree(rmm_segs);
553
550
                DBC_ASSERT(!status);
554
551
                /* First count number of overlay nodes */
555
552
                status =
556
 
                    dcd_get_objects(nldr_obj->hdcd_mgr, sz_zl_file,
 
553
                    dcd_get_objects(nldr_obj->dcd_mgr, sz_zl_file,
557
554
                                    add_ovly_node, (void *)nldr_obj);
558
555
                /* Now build table of overlay nodes */
559
556
                if (!status && nldr_obj->ovly_nodes > 0) {
563
560
                                        nldr_obj->ovly_nodes, GFP_KERNEL);
564
561
                        /* Put overlay nodes in the table */
565
562
                        nldr_obj->ovly_nid = 0;
566
 
                        status = dcd_get_objects(nldr_obj->hdcd_mgr, sz_zl_file,
 
563
                        status = dcd_get_objects(nldr_obj->dcd_mgr, sz_zl_file,
567
564
                                                 add_ovly_node,
568
565
                                                 (void *)nldr_obj);
569
566
                }
607
604
 
608
605
        kfree(nldr_obj->seg_table);
609
606
 
610
 
        if (nldr_obj->hdcd_mgr)
611
 
                dcd_destroy_manager(nldr_obj->hdcd_mgr);
 
607
        if (nldr_obj->dcd_mgr)
 
608
                dcd_destroy_manager(nldr_obj->dcd_mgr);
612
609
 
613
610
        /* Free overlay node information */
614
611
        if (nldr_obj->ovly_table) {
681
678
 
682
679
        nldr_obj = nldr_node_obj->nldr_obj;
683
680
        /* Called from node_create(), node_delete(), or node_run(). */
684
 
        if (nldr_node_obj->dynamic && *nldr_node_obj->pf_phase_split) {
 
681
        if (nldr_node_obj->dynamic && *nldr_node_obj->phase_split) {
685
682
                switch (nldr_node_obj->phase) {
686
683
                case NLDR_CREATE:
687
684
                        root = nldr_node_obj->create_lib;
824
821
                             false, nldr_node_obj->lib_path, phase, 0);
825
822
 
826
823
                if (!status) {
827
 
                        if (*nldr_node_obj->pf_phase_split) {
 
824
                        if (*nldr_node_obj->phase_split) {
828
825
                                switch (phase) {
829
826
                                case NLDR_CREATE:
830
827
                                        nldr_node_obj->create_lib =
871
868
 
872
869
        if (nldr_node_obj != NULL) {
873
870
                if (nldr_node_obj->dynamic) {
874
 
                        if (*nldr_node_obj->pf_phase_split) {
 
871
                        if (*nldr_node_obj->phase_split) {
875
872
                                switch (phase) {
876
873
                                case NLDR_CREATE:
877
874
                                        root_lib = &nldr_node_obj->create_lib;
1008
1005
                goto func_end;
1009
1006
 
1010
1007
        status =
1011
 
            dcd_get_object_def(nldr_obj->hdcd_mgr, uuid_obj, obj_type,
 
1008
            dcd_get_object_def(nldr_obj->dcd_mgr, uuid_obj, obj_type,
1012
1009
                               &obj_def);
1013
1010
        if (status)
1014
1011
                goto func_end;
1015
1012
 
1016
1013
        /* If overlay node, add to the list */
1017
 
        if (obj_def.obj_data.node_obj.us_load_type == NLDR_OVLYLOAD) {
 
1014
        if (obj_def.obj_data.node_obj.load_type == NLDR_OVLYLOAD) {
1018
1015
                if (nldr_obj->ovly_table == NULL) {
1019
1016
                        nldr_obj->ovly_nodes++;
1020
1017
                } else {
1038
1035
                }
1039
1036
        }
1040
1037
        /* These were allocated in dcd_get_object_def */
1041
 
        kfree(obj_def.obj_data.node_obj.pstr_create_phase_fxn);
1042
 
 
1043
 
        kfree(obj_def.obj_data.node_obj.pstr_execute_phase_fxn);
1044
 
 
1045
 
        kfree(obj_def.obj_data.node_obj.pstr_delete_phase_fxn);
1046
 
 
1047
 
        kfree(obj_def.obj_data.node_obj.pstr_i_alg_name);
 
1038
        kfree(obj_def.obj_data.node_obj.str_create_phase_fxn);
 
1039
 
 
1040
        kfree(obj_def.obj_data.node_obj.str_execute_phase_fxn);
 
1041
 
 
1042
        kfree(obj_def.obj_data.node_obj.str_delete_phase_fxn);
 
1043
 
 
1044
        kfree(obj_def.obj_data.node_obj.str_i_alg_name);
1048
1045
 
1049
1046
func_end:
1050
1047
        return status;
1265
1262
                if (depth == 0) {
1266
1263
                        status =
1267
1264
                            dcd_get_library_name(nldr_node_obj->nldr_obj->
1268
 
                                                 hdcd_mgr, &uuid, psz_file_name,
 
1265
                                                 dcd_mgr, &uuid, psz_file_name,
1269
1266
                                                 &dw_buf_size, phase,
1270
 
                                                 nldr_node_obj->pf_phase_split);
 
1267
                                                 nldr_node_obj->phase_split);
1271
1268
                } else {
1272
1269
                        /* Dependent libraries are registered with a phase */
1273
1270
                        status =
1274
1271
                            dcd_get_library_name(nldr_node_obj->nldr_obj->
1275
 
                                                 hdcd_mgr, &uuid, psz_file_name,
 
1272
                                                 dcd_mgr, &uuid, psz_file_name,
1276
1273
                                                 &dw_buf_size, NLDR_NOPHASE,
1277
1274
                                                 NULL);
1278
1275
                }
1312
1309
                depth++;
1313
1310
                /* Get number of dependent libraries */
1314
1311
                status =
1315
 
                    dcd_get_num_dep_libs(nldr_node_obj->nldr_obj->hdcd_mgr,
 
1312
                    dcd_get_num_dep_libs(nldr_node_obj->nldr_obj->dcd_mgr,
1316
1313
                                         &uuid, &nd_libs, &np_libs, phase);
1317
1314
        }
1318
1315
        DBC_ASSERT(nd_libs >= np_libs);
1319
1316
        if (!status) {
1320
 
                if (!(*nldr_node_obj->pf_phase_split))
 
1317
                if (!(*nldr_node_obj->phase_split))
1321
1318
                        np_libs = 0;
1322
1319
 
1323
1320
                /* nd_libs = #of dependent libraries */
1345
1342
                                /* Get the dependent library UUIDs */
1346
1343
                                status =
1347
1344
                                    dcd_get_dep_libs(nldr_node_obj->
1348
 
                                                     nldr_obj->hdcd_mgr, &uuid,
 
1345
                                                     nldr_obj->dcd_mgr, &uuid,
1349
1346
                                                     nd_libs, dep_lib_uui_ds,
1350
1347
                                                     persistent_dep_libs,
1351
1348
                                                     phase);
1362
1359
                         * is, then record it.  If root library IS persistent,
1363
1360
                         * the deplib is already included */
1364
1361
                        if (!root_prstnt && persistent_dep_libs[i] &&
1365
 
                            *nldr_node_obj->pf_phase_split) {
 
1362
                            *nldr_node_obj->phase_split) {
1366
1363
                                if ((nldr_node_obj->pers_libs) >= MAXLIBS) {
1367
1364
                                        status = -EILSEQ;
1368
1365
                                        break;
1388
1385
                        if (!status) {
1389
1386
                                if ((status != 0) &&
1390
1387
                                    !root_prstnt && persistent_dep_libs[i] &&
1391
 
                                    *nldr_node_obj->pf_phase_split) {
 
1388
                                    *nldr_node_obj->phase_split) {
1392
1389
                                        (nldr_node_obj->pers_libs)++;
1393
1390
                                } else {
1394
1391
                                        if (!persistent_dep_libs[i] ||
1395
 
                                            !(*nldr_node_obj->pf_phase_split)) {
 
1392
                                            !(*nldr_node_obj->phase_split)) {
1396
1393
                                                nd_libs_loaded++;
1397
1394
                                        }
1398
1395
                                }
1633
1630
        rmm = nldr_obj->rmm;
1634
1631
        /* Convert size to DSP words */
1635
1632
        word_size =
1636
 
            (size + nldr_obj->us_dsp_word_size -
1637
 
             1) / nldr_obj->us_dsp_word_size;
 
1633
            (size + nldr_obj->dsp_word_size -
 
1634
             1) / nldr_obj->dsp_word_size;
1638
1635
        /* Modify memory 'align' to account for DSP cache line size */
1639
1636
        align = lcm(GEM_CACHE_LINE_SIZE, align);
1640
1637
        dev_dbg(bridge, "%s: memory align to 0x%x\n", __func__, align);
1745
1742
 
1746
1743
        /* Convert size to DSP words */
1747
1744
        word_size =
1748
 
            (size + nldr_obj->us_dsp_word_size -
1749
 
             1) / nldr_obj->us_dsp_word_size;
 
1745
            (size + nldr_obj->dsp_word_size -
 
1746
             1) / nldr_obj->dsp_word_size;
1750
1747
 
1751
1748
        if (rmm_free(rmm, space, dsp_address, word_size, reserve))
1752
1749
                status = 0;
1906
1903
        pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x,  %s)\n", __func__, (u32) nldr_node,
1907
1904
                        sym_addr, offset_range, (u32) offset_output, sym_name);
1908
1905
 
1909
 
        if (nldr_node->dynamic && *nldr_node->pf_phase_split) {
 
1906
        if (nldr_node->dynamic && *nldr_node->phase_split) {
1910
1907
                switch (nldr_node->phase) {
1911
1908
                case NLDR_CREATE:
1912
1909
                        root = nldr_node->create_lib;