Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/244/?format=api
{ "id": 244, "url": "http://patchwork.ozlabs.org/api/patches/244/?format=api", "web_url": "http://patchwork.ozlabs.org/project/cbe-oss-dev/patch/48C972DF.4080409@am.sony.com/", "project": { "id": 1, "url": "http://patchwork.ozlabs.org/api/projects/1/?format=api", "name": "Cell Broadband Engine development", "link_name": "cbe-oss-dev", "list_id": "cbe-oss-dev.ozlabs.org", "list_email": "cbe-oss-dev@ozlabs.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<48C972DF.4080409@am.sony.com>", "list_archive_url": null, "date": "2008-09-11T19:34:55", "name": "MARS: Remove api argument params structs", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "9a867d757401f1a6c41a3d0df31cc6459fef4d4c", "submitter": { "id": 127, "url": "http://patchwork.ozlabs.org/api/people/127/?format=api", "name": "Yuji Mano", "email": "yuji.mano@am.sony.com" }, "delegate": { "id": 26, "url": "http://patchwork.ozlabs.org/api/users/26/?format=api", "username": "ymano", "first_name": "Yuji", "last_name": "Mano", "email": "yuji.mano@am.sony.com" }, "mbox": "http://patchwork.ozlabs.org/project/cbe-oss-dev/patch/48C972DF.4080409@am.sony.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/244/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/244/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org>", "X-Original-To": [ "patchwork@ozlabs.org", "cbe-oss-dev@ozlabs.org" ], "Delivered-To": [ "patchwork@ozlabs.org", "cbe-oss-dev@ozlabs.org" ], "Received": [ "from ozlabs.org (localhost [127.0.0.1])\n\tby ozlabs.org (Postfix) with ESMTP id D6E1F47634\n\tfor <patchwork@ozlabs.org>; Fri, 12 Sep 2008 06:38:57 +1000 (EST)", "from SG2EHSOBE002.bigfish.com (outbound-sin.frontbridge.com\n\t[207.46.51.80]) by ozlabs.org (Postfix) with ESMTP id 444A6DE38A\n\tfor <cbe-oss-dev@ozlabs.org>; Fri, 12 Sep 2008 06:37:22 +1000 (EST)", "from mail3-sin-R.bigfish.com (10.3.40.3) by\n\tSG2EHSOBE002.bigfish.com\n\t(10.3.40.22) with Microsoft SMTP Server id 8.1.291.1;\n\tThu, 11 Sep 2008 20:37:17 +0000", "from mail3-sin (localhost.localdomain [127.0.0.1])\tby\n\tmail3-sin-R.bigfish.com (Postfix) with ESMTP id DB167B20230\tfor\n\t<cbe-oss-dev@ozlabs.org>; Thu, 11 Sep 2008 20:37:16 +0000 (UTC)", "by mail3-sin (MessageSwitch) id 1221165432217053_15849; Thu, 11 Sep\n\t2008 20:37:12 +0000 (UCT)", "from mail8.fw-bc.sony.com (mail8.fw-bc.sony.com [160.33.98.75])\tby\n\tmail3-sin.bigfish.com (Postfix) with ESMTP id 4F1933C006F\tfor\n\t<cbe-oss-dev@ozlabs.org>; Thu, 11 Sep 2008 20:37:11 +0000 (UTC)", "from mail3.sjc.in.sel.sony.com (mail3.sjc.in.sel.sony.com\n\t[43.134.1.211])\tby mail8.fw-bc.sony.com (8.14.2/8.14.2) with ESMTP id\n\tm8BKb9ti025075\tfor <cbe-oss-dev@ozlabs.org>;\n\tThu, 11 Sep 2008 20:37:09 GMT", "from USSDIXIM02.am.sony.com (ussdixim02.am.sony.com\n\t[43.130.140.34])\n\tby mail3.sjc.in.sel.sony.com (8.12.11/8.12.11) with ESMTP id\n\tm8BKb7tD021726\n\tfor <cbe-oss-dev@ozlabs.org>; Thu, 11 Sep 2008 20:37:09 GMT", "from ussdixms03.am.sony.com ([43.130.140.23]) by\n\tUSSDIXIM02.am.sony.com with Microsoft SMTPSVC(5.0.2195.6713);\n\tThu, 11 Sep 2008 13:37:08 -0700", "from [43.135.148.175] ([43.135.148.175]) by ussdixms03.am.sony.com\n\twith Microsoft SMTPSVC(5.0.2195.6713);\n\tThu, 11 Sep 2008 13:37:08 -0700" ], "X-BigFish": "VS2(zz936fQzz10c0j10d3izz1497iz2dh6bh68o)", "X-Spam-TCS-SCL": "7:0", "Message-ID": "<48C972DF.4080409@am.sony.com>", "Date": "Thu, 11 Sep 2008 12:34:55 -0700", "From": "Yuji Mano <yuji.mano@am.sony.com>", "User-Agent": "Thunderbird 2.0.0.5 (X11/20070719)", "MIME-Version": "1.0", "To": "CBE Development <cbe-oss-dev@ozlabs.org>", "X-Enigmail-Version": "0.95.7", "X-OriginalArrivalTime": "11 Sep 2008 20:37:08.0522 (UTC)\n\tFILETIME=[2908D8A0:01C9144E]", "X-SEL-encryption-scan": "scanned", "Subject": "[Cbe-oss-dev] [PATCH 07/11]MARS: Remove api argument params structs", "X-BeenThere": "cbe-oss-dev@ozlabs.org", "X-Mailman-Version": "2.1.11", "Precedence": "list", "List-Id": "Discussion about Open Source Software for the Cell Broadband Engine\n\t<cbe-oss-dev.ozlabs.org>", "List-Unsubscribe": "<https://ozlabs.org/mailman/options/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://ozlabs.org/pipermail/cbe-oss-dev>", "List-Post": "<mailto:cbe-oss-dev@ozlabs.org>", "List-Help": "<mailto:cbe-oss-dev-request@ozlabs.org?subject=help>", "List-Subscribe": "<https://ozlabs.org/mailman/listinfo/cbe-oss-dev>,\n\t<mailto:cbe-oss-dev-request@ozlabs.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org", "Errors-To": "cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org" }, "content": "This removes the mars_params and mars_task_params structure previously passed\ninto the mars context and mars task APIs.\n\nParameter arguments are now passed in directly.\n\nSigned-off-by: Yuji Mano <yuji.mano@am.sony.com>", "diff": "--- a/include/host/mars/mars_context.h\n+++ b/include/host/mars/mars_context.h\n@@ -44,32 +44,17 @@\n * \\brief [host] MARS Context API\n */\n \n+#include <stdint.h>\n #include <pthread.h>\n \n /**\n * \\ingroup group_mars_context\n- * \\brief MARS params structure\n- *\n- * This structure is initialized by the user and passed into\n- * \\ref mars_initialize for MARS context initialization.\n- */\n-struct mars_params {\n-\t/** number of mpus utilized by each MARS context\n-\t * [between 0 and maximum available physical MPUs]\n-\t */\n-\tunsigned int num_mpus;\n-};\n-\n-/**\n- * \\ingroup group_mars_context\n * \\brief MARS context structure\n *\n * An instance of this structure must be created and initialized before\n * using any of the MARS API.\n */\n struct mars_context {\n-\t/* parameters for the MARS context */\n-\tstruct mars_params *params;\n \t/* parameters for the MARS kernel */\n \tstruct mars_kernel_params *kernel_params;\n \t/* process queue where process requests are added */\n@@ -77,7 +62,7 @@ struct mars_context {\n \t/* array of mpu context threads */\n \tpthread_t *mpu_context_threads;\n \t/* num of mpu context threads */\n-\tunsigned int mpu_context_count;\n+\tuint32_t mpu_context_count;\n };\n \n #if defined(__cplusplus)\n@@ -98,7 +83,7 @@ extern \"C\" {\n * each MARS context will suffer the large over head of MPU context switches.\n *\n * \\param[out] ctx\t\t- address of context instance to initialize\n- * \\param[in] params\t\t- pointer to MARS parameters structure\n+ * \\param[in] num_mpus\t\t- number of mpus utilized by MARS context\n * \\return\n *\tMARS_SUCCESS\t\t- successfully initialized MARS context\n * \\n\tMARS_ERROR_NULL\t\t- null pointer specified\n@@ -106,7 +91,7 @@ extern \"C\" {\n * \\n\tMARS_ERROR_MEMORY\t- not enough memory\n * \\n\tMARS_ERROR_INTERNAL\t- some internal error occurred\n */\n-int mars_initialize(struct mars_context *ctx, struct mars_params *params);\n+int mars_initialize(struct mars_context *ctx, uint32_t num_mpus);\n \n /**\n * \\ingroup group_mars_context\n--- a/include/host/mars/mars_task.h\n+++ b/include/host/mars/mars_task.h\n@@ -55,24 +55,6 @@ extern \"C\" {\n #include \"mars/mars_task_signal.h\"\n #include \"mars/mars_task_types.h\"\n \n-struct mars_context;\n-struct mars_exec_context;\n-\n-/**\n- * \\ingroup group_mars_task\n- * \\brief MARS task params structure\n- *\n- * This structure is initialized by the user and passed into\n- * \\ref mars_task_initialize for MARS task initialization.\n- */\n-struct mars_task_params {\n-\t/** name of task */\n-\tconst char *name;\n-\t/** address of MPU program elf image */\n-\tconst void *elf_image;\n-\t/** size of context save area allocated for task */\n-\tuint32_t context_save_size;\n-};\n \n /**\n * \\ingroup group_mars_task\n@@ -87,8 +69,7 @@ struct mars_task_params {\n * The task is in the finished state upon creation and may be finalized by\n * \\ref mars_task_finalize without ever being scheduled for execution.\n *\n- * When initializing a MARS task, you must specify its parameters through the\n- * \\ref mars_task_params structure:\n+ * When initializing a MARS task, you must specify its parameters:\n * \\n\n * - \\e name: The name is optional, but if specified to other than NULL its\n *\tlength must not exceed \\ref MARS_TASK_NAME_LEN_MAX.\n@@ -107,7 +88,9 @@ struct mars_task_params {\n *\n * \\param[in] mars\t\t- pointer to initialized MARS context\n * \\param[out] id\t\t- pointer to task id to be initialized\n- * \\param[in] params\t\t- pointer to task params of this task\n+ * \\param[in] name\t\t- name of task\n+ * \\param[in] elf_image\t\t- address of MPU program elf image\n+ * \\param[in] context_save_size - size of context save area allocated for task\n * \\return\n *\tMARS_SUCCESS\t\t- successfully initialized MARS task\n * \\n\tMARS_ERROR_NULL\t\t- null pointer specified\n@@ -115,8 +98,11 @@ struct mars_task_params {\n * \\n\tMARS_ERROR_MEMORY\t- not enough memory\n * \\n\tMARS_ERROR_LIMIT\t- task queue is currently full\n */\n-int mars_task_initialize(struct mars_context *mars, struct mars_task_id *id,\n-\t\t\tstruct mars_task_params *params);\n+int mars_task_initialize(struct mars_context *mars,\n+\t\t\tstruct mars_task_id *id,\n+\t\t\tconst char *name,\n+\t\t\tconst void *elf_image,\n+\t\t\tuint32_t context_save_size);\n \n /**\n * \\ingroup group_mars_task\n--- a/src/host/lib/mars_context.c\n+++ b/src/host/lib/mars_context.c\n@@ -48,9 +48,14 @@\n \n extern struct spe_program_handle mars_kernel_entry;\n \n-static int num_mpus_max(void)\n+static uint32_t num_mpus_max(void)\n {\n-\treturn spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n+\tint ret;\n+\n+\tret = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);\n+\tMARS_CHECK_RET(ret >= 0, 0);\n+\n+\treturn ret;\n }\n \n static void *mpu_context_thread(void *arg)\n@@ -77,7 +82,7 @@ static void *mpu_context_thread(void *ar\n \treturn (void *)MARS_SUCCESS;\n }\n \n-static int create_mpu_contexts(struct mars_context *mars, int num_mpu_contexts)\n+static int create_mpu_contexts(struct mars_context *mars, uint32_t num_mpus)\n {\n \tMARS_ASSERT(mars);\n \n@@ -85,7 +90,7 @@ static int create_mpu_contexts(struct ma\n \tunsigned int i;\n \n \t/* create threads for each mpu context */\n-\tfor (i = 0; i < num_mpu_contexts; i++) {\n+\tfor (i = 0; i < num_mpus; i++) {\n \t\tstruct mars_kernel_params *params = &mars->kernel_params[i];\n \t\tparams->id = i;\n \t\tparams->mars_context_ea =\n@@ -120,39 +125,27 @@ static int destroy_mpu_contexts(struct m\n \treturn MARS_SUCCESS;\n }\n \n-int mars_initialize(struct mars_context *mars, struct mars_params *params)\n+int mars_initialize(struct mars_context *mars, uint32_t num_mpus)\n {\n \tMARS_CHECK_RET(mars, MARS_ERROR_NULL);\n+\tMARS_CHECK_RET(num_mpus_max() > 0, MARS_ERROR_INTERNAL);\n+\tMARS_CHECK_RET(num_mpus_max() >= num_mpus, MARS_ERROR_PARAMS);\n \n \tMARS_PRINT(\"Initialize MARS Context (%p)\\n\", mars);\n \n \tint ret;\n-\tunsigned int num_mpu_contexts;\n \n \t/* zero context */\n \tmemset(mars, 0, sizeof(struct mars_context));\n \n-\t/* allocate and initialize params */\n-\tif (params) {\n-\t\tMARS_CHECK_RET(params->num_mpus <= num_mpus_max(),\n-\t\t\t\tMARS_ERROR_PARAMS);\n-\n-\t\tmars->params = (struct mars_params *)\n-\t\t\tmalloc(sizeof(struct mars_params));\n-\t\tMARS_CHECK_RET(mars->params, MARS_ERROR_MEMORY);\n-\t\tmemcpy(mars->params, params, sizeof(struct mars_params));\n-\n-\t\tnum_mpu_contexts = mars->params->num_mpus;\n-\t} else {\n-\t\tmars->params = NULL;\n-\n-\t\tnum_mpu_contexts = num_mpus_max();\n-\t}\n+\t/* num mpus specified is default max */\n+\tif (!num_mpus)\n+\t\tnum_mpus = num_mpus_max();\n \n \t/* allocate kernel params */\n \tmars->kernel_params = (struct mars_kernel_params *)\n \t\tmemalign(MARS_KERNEL_PARAMS_ALIGN,\n-\t\t\tsizeof(struct mars_kernel_params) * num_mpu_contexts);\n+\t\t\tsizeof(struct mars_kernel_params) * num_mpus);\n \tMARS_CHECK_CLEANUP_RET(mars->kernel_params, mars_finalize(mars),\n \t\t\t\tMARS_ERROR_MEMORY);\n \n@@ -169,12 +162,12 @@ int mars_initialize(struct mars_context \n \n \t/* allocate mpu context thread array */\n \tmars->mpu_context_threads = (pthread_t *)\n-\t\tmalloc(sizeof(pthread_t) * num_mpu_contexts);\n+\t\tmalloc(sizeof(pthread_t) * num_mpus);\n \tMARS_CHECK_CLEANUP_RET(mars->mpu_context_threads, mars_finalize(mars),\n \t\t\t\tMARS_ERROR_MEMORY);\n \n \t/* create contexts */\n-\tret = create_mpu_contexts(mars, num_mpu_contexts);\n+\tret = create_mpu_contexts(mars, num_mpus);\n \tMARS_CHECK_CLEANUP_RET(ret == MARS_SUCCESS, mars_finalize(mars), ret);\n \n \treturn MARS_SUCCESS;\n@@ -199,7 +192,6 @@ int mars_finalize(struct mars_context *m\n \t}\n \n \t/* free allocated memory */\n-\tfree(mars->params);\n \tfree(mars->kernel_params);\n \tfree(mars->workload_queue);\n \tfree(mars->mpu_context_threads);\n--- a/src/host/lib/mars_task.c\n+++ b/src/host/lib/mars_task.c\n@@ -45,17 +45,23 @@\n #include \"mars/mars_error.h\"\n #include \"mars/mars_debug.h\"\n \n-int mars_task_initialize(struct mars_context *mars, struct mars_task_id *id,\n-\t\t\tstruct mars_task_params *params)\n+int mars_task_initialize(struct mars_context *mars,\n+\t\t\tstruct mars_task_id *id,\n+\t\t\tconst char *name,\n+\t\t\tconst void *elf_image,\n+\t\t\tuint32_t context_save_size)\n {\n \tMARS_CHECK_RET(mars, MARS_ERROR_NULL);\n \tMARS_CHECK_RET(id, MARS_ERROR_NULL);\n-\tMARS_CHECK_RET(params, MARS_ERROR_NULL);\n-\tMARS_CHECK_RET(params->elf_image, MARS_ERROR_PARAMS);\n+\tMARS_CHECK_RET(elf_image, MARS_ERROR_NULL);\n+\tMARS_CHECK_RET(!name || strlen(name) < MARS_TASK_NAME_LEN_MAX,\n+\t\t\tMARS_ERROR_PARAMS);\n+\tMARS_CHECK_RET(context_save_size <= MARS_TASK_CONTEXT_SAVE_SIZE_MAX,\n+\t\t\tMARS_ERROR_PARAMS);\n \n \tint ret;\n \tstruct mars_task_context *task;\n-\tElf32_Ehdr *ehdr = (Elf32_Ehdr *)params->elf_image;\n+\tElf32_Ehdr *ehdr = (Elf32_Ehdr *)elf_image;\n \tElf32_Phdr *phdr = (Elf32_Phdr *)((void *)ehdr + ehdr->e_phoff);\n \n \t//MARS_CHECK_RET(ehdr->e_phnum == 1, MARS_ERROR_FORMAT);\n@@ -67,11 +73,8 @@ int mars_task_initialize(struct mars_con\n \tid->mars_context_ea = (uint64_t)(uintptr_t)mars;\n \n \t/* copy the task name into task id */\n-\tif (params->name) {\n-\t\tMARS_CHECK_RET(strlen(params->name) < MARS_TASK_NAME_LEN_MAX,\n-\t\t\t\tMARS_ERROR_PARAMS);\n-\t\tstrcpy((char *)&id->name, params->name);\n-\t}\n+\tif (name)\n+\t\tstrcpy((char *)&id->name, name);\n \n \t/* begin process to add the task to the workload queue */\n \tret = workload_queue_add_begin(mars->workload_queue, &id->workload_id,\n@@ -90,15 +93,8 @@ int mars_task_initialize(struct mars_con\n \ttask->entry = ehdr->e_entry;\n \n \t/* allocate the task context area if specified */\n-\tif (params->context_save_size) {\n-\t\tMARS_CHECK_CLEANUP_RET(params->context_save_size <=\n-\t\t\tMARS_TASK_CONTEXT_SAVE_SIZE_MAX,\n-\t\t\tworkload_queue_add_cancel(mars->workload_queue,\n-\t\t\t\tid->workload_id),\n-\t\t\tMARS_ERROR_PARAMS);\n-\n-\t\ttask->context_save_size =\n-\t\t\tparams->context_save_size;\n+\tif (context_save_size) {\n+\t\ttask->context_save_size = context_save_size;\n \t\ttask->context_save_area = (uint64_t)(uintptr_t)\n \t\t\tmemalign(MARS_TASK_CONTEXT_SAVE_ALIGN,\n \t\t\t\ttask->context_save_size);\n", "prefixes": [] }