{"action":"created","comment":{"url":"https://api.github.com/repos/aanisov/xen/pulls/comments/90080172","pull_request_review_id":10605125,"id":90080172,"diff_hunk":"@@ -0,0 +1,381 @@\n+/*\n+ * xen/arch/arm/coproc/coproc.c\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ */\n+\n+#include <xen/init.h>\n+#include <xen/err.h>\n+#include <xen/guest_access.h>\n+\n+#include \"coproc.h\"\n+\n+/* dom0_coprocs: comma-separated list of coprocs for domain 0. */\n+static char __initdata opt_dom0_coprocs[128] = \"\";\n+string_param(\"dom0_coprocs\", opt_dom0_coprocs);\n+\n+/* The \"framework's\" global coprocs list is used to keep track\n+ * of all coproc instances that have been registered in the framework */\n+static LIST_HEAD(coprocs);\n+static DEFINE_SPINLOCK(coprocs_lock);\n+static int num_coprocs;\n+\n+int vcoproc_context_switch(struct vcoproc_instance *curr, struct vcoproc_instance *next)\n+{\n+    struct coproc_device *coproc;\n+    int ret = 0;\n+\n+    if ( unlikely(curr == next) )\n+        return 0;\n+\n+    /* It is no matter who will provide coproc */\n+    coproc = next ? next->coproc : curr->coproc;\n+\n+    ret = coproc->ops->ctx_switch_from(curr);\n+    if ( ret )\n+        return ret;\n+\n+    ret = coproc->ops->ctx_switch_to(next);\n+    if ( ret )\n+        panic(\"Failed to switch context to vcoproc \\\"%s\\\" (%d)\\n\",\n+              dev_path(coproc->dev), ret);\n+\n+    return ret;\n+}\n+\n+void vcoproc_continue_running(struct vcoproc_instance *same)\n+{\n+    /* nothing to do */\n+}\n+\n+static struct coproc_device *coproc_find_by_path(const char *path)\n+{\n+    struct coproc_device *coproc;\n+    bool_t found = false;\n+\n+    if ( !path )\n+        return NULL;\n+\n+    spin_lock(&coprocs_lock);\n+\n+    if ( list_empty(&coprocs) )\n+        goto out;\n+\n+    list_for_each_entry(coproc, &coprocs, coproc_elem)\n+    {\n+        if ( !strcmp(dev_path(coproc->dev), path) )\n+        {\n+            found = true;\n+            break;\n+        }\n+    }\n+\n+out:\n+    spin_unlock(&coprocs_lock);\n+\n+    return found ? coproc : NULL;\n+}\n+\n+static int coproc_attach_to_domain(struct domain *d, struct coproc_device *coproc)\n+{\n+    struct vcoproc *vcoproc_d = &d->arch.vcoproc;\n+    struct vcoproc_instance *vcoproc;\n+    int ret;\n+\n+    if ( !coproc )\n+        return -EINVAL;\n+\n+    spin_lock(&coprocs_lock);\n+\n+    if ( coproc->ops->vcoproc_is_created(d, coproc) )\n+    {\n+        ret = -EEXIST;\n+        goto out;\n+    }\n+\n+    vcoproc = coproc->ops->vcoproc_init(d, coproc);\n+    if ( IS_ERR(vcoproc) )\n+    {\n+        ret = PTR_ERR(vcoproc);\n+        goto out;\n+    }\n+\n+    ret = vcoproc_scheduler_vcoproc_init(coproc->sched, vcoproc);\n+    if ( ret )\n+    {\n+        coproc->ops->vcoproc_free(d, vcoproc);\n+        goto out;\n+    }\n+\n+    spin_lock(&vcoproc_d->lock);\n+    BUG_ON(vcoproc_d->num_instances >= num_coprocs);\n+    list_add_tail(&vcoproc->instance_elem, &vcoproc_d->instances);\n+    vcoproc_d->num_instances++;\n+    spin_unlock(&vcoproc_d->lock);\n+\n+    printk(\"Created vcoproc \\\"%s\\\" for dom%u\\n\",\n+           dev_path(coproc->dev), d->domain_id);\n+\n+out:\n+    spin_unlock(&coprocs_lock);\n+\n+    return ret;\n+}\n+\n+static int coproc_find_and_attach_to_domain(struct domain *d, const char *path)\n+{\n+    struct coproc_device *coproc;\n+\n+    coproc = coproc_find_by_path(path);\n+    if ( !coproc )\n+        return -ENODEV;\n+\n+    return coproc_attach_to_domain(d, coproc);\n+}\n+\n+static int coproc_detach_from_domain(struct domain *d, struct vcoproc_instance *vcoproc)\n+{\n+    struct vcoproc *vcoproc_d = &d->arch.vcoproc;\n+    struct coproc_device *coproc;\n+    int ret;\n+\n+    if ( !vcoproc )\n+        return 0;\n+\n+    coproc = vcoproc->coproc;\n+\n+    spin_lock(&coprocs_lock);\n+\n+    ret = vcoproc_scheduler_vcoproc_destroy(coproc->sched, vcoproc);\n+    if ( ret )\n+    {\n+        if ( ret == -EBUSY )\n+            ret = -ERESTART;\n+        goto out;\n+    }\n+\n+    spin_lock(&vcoproc_d->lock);\n+    BUG_ON(!vcoproc_d->num_instances);\n+    list_del_init(&vcoproc->instance_elem);\n+    vcoproc_d->num_instances--;\n+    spin_unlock(&vcoproc_d->lock);\n+\n+    coproc->ops->vcoproc_free(d, vcoproc);\n+\n+    printk(\"Destroyed vcoproc \\\"%s\\\" for dom%u\\n\",\n+            dev_path(coproc->dev), d->domain_id);\n+\n+out:\n+    spin_unlock(&coprocs_lock);\n+\n+    return ret;\n+}\n+\n+bool_t coproc_is_attached_to_domain(struct domain *d, const char *path)\n+{\n+    struct coproc_device *coproc;\n+\n+    coproc = coproc_find_by_path(path);\n+    if ( !coproc )\n+        return false;\n+\n+    return coproc->ops->vcoproc_is_created(d, coproc);\n+}\n+\n+static int vcoproc_dom0_init(struct domain *d)","path":"xen/arch/arm/coproc/coproc.c","position":193,"original_position":193,"commit_id":"eaa0b1eeb8586e5090ce0bfddbf1a87099ba1fb5","original_commit_id":"b95d4f54d5de0b42c50f67f4588412a14751979a","user":{"login":"otyshchenko1","id":22071282,"avatar_url":"https://avatars.githubusercontent.com/u/22071282?v=3","gravatar_id":"","url":"https://api.github.com/users/otyshchenko1","html_url":"https://github.com/otyshchenko1","followers_url":"https://api.github.com/users/otyshchenko1/followers","following_url":"https://api.github.com/users/otyshchenko1/following{/other_user}","gists_url":"https://api.github.com/users/otyshchenko1/gists{/gist_id}","starred_url":"https://api.github.com/users/otyshchenko1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otyshchenko1/subscriptions","organizations_url":"https://api.github.com/users/otyshchenko1/orgs","repos_url":"https://api.github.com/users/otyshchenko1/repos","events_url":"https://api.github.com/users/otyshchenko1/events{/privacy}","received_events_url":"https://api.github.com/users/otyshchenko1/received_events","type":"User","site_admin":false},"body":"Agree. Will do","created_at":"2016-11-29T18:54:18Z","updated_at":"2016-11-29T18:54:18Z","html_url":"https://github.com/aanisov/xen/pull/6#discussion_r90080172","pull_request_url":"https://api.github.com/repos/aanisov/xen/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/aanisov/xen/pulls/comments/90080172"},"html":{"href":"https://github.com/aanisov/xen/pull/6#discussion_r90080172"},"pull_request":{"href":"https://api.github.com/repos/aanisov/xen/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/aanisov/xen/pulls/6","id":94998020,"html_url":"https://github.com/aanisov/xen/pull/6","diff_url":"https://github.com/aanisov/xen/pull/6.diff","patch_url":"https://github.com/aanisov/xen/pull/6.patch","issue_url":"https://api.github.com/repos/aanisov/xen/issues/6","number":6,"state":"open","locked":false,"title":"[WIP] Coproc stuff3","user":{"login":"otyshchenko1","id":22071282,"avatar_url":"https://avatars.githubusercontent.com/u/22071282?v=3","gravatar_id":"","url":"https://api.github.com/users/otyshchenko1","html_url":"https://github.com/otyshchenko1","followers_url":"https://api.github.com/users/otyshchenko1/followers","following_url":"https://api.github.com/users/otyshchenko1/following{/other_user}","gists_url":"https://api.github.com/users/otyshchenko1/gists{/gist_id}","starred_url":"https://api.github.com/users/otyshchenko1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otyshchenko1/subscriptions","organizations_url":"https://api.github.com/users/otyshchenko1/orgs","repos_url":"https://api.github.com/users/otyshchenko1/repos","events_url":"https://api.github.com/users/otyshchenko1/events{/privacy}","received_events_url":"https://api.github.com/users/otyshchenko1/received_events","type":"User","site_admin":false},"body":"Please find free time to review patch series.","created_at":"2016-11-23T12:56:32Z","updated_at":"2016-11-29T18:54:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7653e98bb8795f53475e352a8378872ff1e09451","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/aanisov/xen/pulls/6/commits","review_comments_url":"https://api.github.com/repos/aanisov/xen/pulls/6/comments","review_comment_url":"https://api.github.com/repos/aanisov/xen/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aanisov/xen/issues/6/comments","statuses_url":"https://api.github.com/repos/aanisov/xen/statuses/eaa0b1eeb8586e5090ce0bfddbf1a87099ba1fb5","head":{"label":"otyshchenko1:coproc_stuff3","ref":"coproc_stuff3","sha":"eaa0b1eeb8586e5090ce0bfddbf1a87099ba1fb5","user":{"login":"otyshchenko1","id":22071282,"avatar_url":"https://avatars.githubusercontent.com/u/22071282?v=3","gravatar_id":"","url":"https://api.github.com/users/otyshchenko1","html_url":"https://github.com/otyshchenko1","followers_url":"https://api.github.com/users/otyshchenko1/followers","following_url":"https://api.github.com/users/otyshchenko1/following{/other_user}","gists_url":"https://api.github.com/users/otyshchenko1/gists{/gist_id}","starred_url":"https://api.github.com/users/otyshchenko1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otyshchenko1/subscriptions","organizations_url":"https://api.github.com/users/otyshchenko1/orgs","repos_url":"https://api.github.com/users/otyshchenko1/repos","events_url":"https://api.github.com/users/otyshchenko1/events{/privacy}","received_events_url":"https://api.github.com/users/otyshchenko1/received_events","type":"User","site_admin":false},"repo":{"id":70487851,"name":"xen","full_name":"otyshchenko1/xen","owner":{"login":"otyshchenko1","id":22071282,"avatar_url":"https://avatars.githubusercontent.com/u/22071282?v=3","gravatar_id":"","url":"https://api.github.com/users/otyshchenko1","html_url":"https://github.com/otyshchenko1","followers_url":"https://api.github.com/users/otyshchenko1/followers","following_url":"https://api.github.com/users/otyshchenko1/following{/other_user}","gists_url":"https://api.github.com/users/otyshchenko1/gists{/gist_id}","starred_url":"https://api.github.com/users/otyshchenko1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otyshchenko1/subscriptions","organizations_url":"https://api.github.com/users/otyshchenko1/orgs","repos_url":"https://api.github.com/users/otyshchenko1/repos","events_url":"https://api.github.com/users/otyshchenko1/events{/privacy}","received_events_url":"https://api.github.com/users/otyshchenko1/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/otyshchenko1/xen","description":"Mirror of the Xen Repository","fork":true,"url":"https://api.github.com/repos/otyshchenko1/xen","forks_url":"https://api.github.com/repos/otyshchenko1/xen/forks","keys_url":"https://api.github.com/repos/otyshchenko1/xen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/otyshchenko1/xen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/otyshchenko1/xen/teams","hooks_url":"https://api.github.com/repos/otyshchenko1/xen/hooks","issue_events_url":"https://api.github.com/repos/otyshchenko1/xen/issues/events{/number}","events_url":"https://api.github.com/repos/otyshchenko1/xen/events","assignees_url":"https://api.github.com/repos/otyshchenko1/xen/assignees{/user}","branches_url":"https://api.github.com/repos/otyshchenko1/xen/branches{/branch}","tags_url":"https://api.github.com/repos/otyshchenko1/xen/tags","blobs_url":"https://api.github.com/repos/otyshchenko1/xen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/otyshchenko1/xen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/otyshchenko1/xen/git/refs{/sha}","trees_url":"https://api.github.com/repos/otyshchenko1/xen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/otyshchenko1/xen/statuses/{sha}","languages_url":"https://api.github.com/repos/otyshchenko1/xen/languages","stargazers_url":"https://api.github.com/repos/otyshchenko1/xen/stargazers","contributors_url":"https://api.github.com/repos/otyshchenko1/xen/contributors","subscribers_url":"https://api.github.com/repos/otyshchenko1/xen/subscribers","subscription_url":"https://api.github.com/repos/otyshchenko1/xen/subscription","commits_url":"https://api.github.com/repos/otyshchenko1/xen/commits{/sha}","git_commits_url":"https://api.github.com/repos/otyshchenko1/xen/git/commits{/sha}","comments_url":"https://api.github.com/repos/otyshchenko1/xen/comments{/number}","issue_comment_url":"https://api.github.com/repos/otyshchenko1/xen/issues/comments{/number}","contents_url":"https://api.github.com/repos/otyshchenko1/xen/contents/{+path}","compare_url":"https://api.github.com/repos/otyshchenko1/xen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/otyshchenko1/xen/merges","archive_url":"https://api.github.com/repos/otyshchenko1/xen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/otyshchenko1/xen/downloads","issues_url":"https://api.github.com/repos/otyshchenko1/xen/issues{/number}","pulls_url":"https://api.github.com/repos/otyshchenko1/xen/pulls{/number}","milestones_url":"https://api.github.com/repos/otyshchenko1/xen/milestones{/number}","notifications_url":"https://api.github.com/repos/otyshchenko1/xen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/otyshchenko1/xen/labels{/name}","releases_url":"https://api.github.com/repos/otyshchenko1/xen/releases{/id}","deployments_url":"https://api.github.com/repos/otyshchenko1/xen/deployments","created_at":"2016-10-10T12:58:40Z","updated_at":"2016-10-10T12:58:48Z","pushed_at":"2016-11-29T18:04:04Z","git_url":"git://github.com/otyshchenko1/xen.git","ssh_url":"git@github.com:otyshchenko1/xen.git","clone_url":"https://github.com/otyshchenko1/xen.git","svn_url":"https://github.com/otyshchenko1/xen","homepage":"http://xenproject.org","size":71672,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"staging"}},"base":{"label":"aanisov:vcoproc-debug-base","ref":"vcoproc-debug-base","sha":"a26e515fce60e4eceb1c1f10cd6790b18e6f59d5","user":{"login":"aanisov","id":22134267,"avatar_url":"https://avatars.githubusercontent.com/u/22134267?v=3","gravatar_id":"","url":"https://api.github.com/users/aanisov","html_url":"https://github.com/aanisov","followers_url":"https://api.github.com/users/aanisov/followers","following_url":"https://api.github.com/users/aanisov/following{/other_user}","gists_url":"https://api.github.com/users/aanisov/gists{/gist_id}","starred_url":"https://api.github.com/users/aanisov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aanisov/subscriptions","organizations_url":"https://api.github.com/users/aanisov/orgs","repos_url":"https://api.github.com/users/aanisov/repos","events_url":"https://api.github.com/users/aanisov/events{/privacy}","received_events_url":"https://api.github.com/users/aanisov/received_events","type":"User","site_admin":false},"repo":{"id":70248425,"name":"xen","full_name":"aanisov/xen","owner":{"login":"aanisov","id":22134267,"avatar_url":"https://avatars.githubusercontent.com/u/22134267?v=3","gravatar_id":"","url":"https://api.github.com/users/aanisov","html_url":"https://github.com/aanisov","followers_url":"https://api.github.com/users/aanisov/followers","following_url":"https://api.github.com/users/aanisov/following{/other_user}","gists_url":"https://api.github.com/users/aanisov/gists{/gist_id}","starred_url":"https://api.github.com/users/aanisov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aanisov/subscriptions","organizations_url":"https://api.github.com/users/aanisov/orgs","repos_url":"https://api.github.com/users/aanisov/repos","events_url":"https://api.github.com/users/aanisov/events{/privacy}","received_events_url":"https://api.github.com/users/aanisov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aanisov/xen","description":"Mirror of the Xen Repository","fork":true,"url":"https://api.github.com/repos/aanisov/xen","forks_url":"https://api.github.com/repos/aanisov/xen/forks","keys_url":"https://api.github.com/repos/aanisov/xen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aanisov/xen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aanisov/xen/teams","hooks_url":"https://api.github.com/repos/aanisov/xen/hooks","issue_events_url":"https://api.github.com/repos/aanisov/xen/issues/events{/number}","events_url":"https://api.github.com/repos/aanisov/xen/events","assignees_url":"https://api.github.com/repos/aanisov/xen/assignees{/user}","branches_url":"https://api.github.com/repos/aanisov/xen/branches{/branch}","tags_url":"https://api.github.com/repos/aanisov/xen/tags","blobs_url":"https://api.github.com/repos/aanisov/xen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aanisov/xen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aanisov/xen/git/refs{/sha}","trees_url":"https://api.github.com/repos/aanisov/xen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aanisov/xen/statuses/{sha}","languages_url":"https://api.github.com/repos/aanisov/xen/languages","stargazers_url":"https://api.github.com/repos/aanisov/xen/stargazers","contributors_url":"https://api.github.com/repos/aanisov/xen/contributors","subscribers_url":"https://api.github.com/repos/aanisov/xen/subscribers","subscription_url":"https://api.github.com/repos/aanisov/xen/subscription","commits_url":"https://api.github.com/repos/aanisov/xen/commits{/sha}","git_commits_url":"https://api.github.com/repos/aanisov/xen/git/commits{/sha}","comments_url":"https://api.github.com/repos/aanisov/xen/comments{/number}","issue_comment_url":"https://api.github.com/repos/aanisov/xen/issues/comments{/number}","contents_url":"https://api.github.com/repos/aanisov/xen/contents/{+path}","compare_url":"https://api.github.com/repos/aanisov/xen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aanisov/xen/merges","archive_url":"https://api.github.com/repos/aanisov/xen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aanisov/xen/downloads","issues_url":"https://api.github.com/repos/aanisov/xen/issues{/number}","pulls_url":"https://api.github.com/repos/aanisov/xen/pulls{/number}","milestones_url":"https://api.github.com/repos/aanisov/xen/milestones{/number}","notifications_url":"https://api.github.com/repos/aanisov/xen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aanisov/xen/labels{/name}","releases_url":"https://api.github.com/repos/aanisov/xen/releases{/id}","deployments_url":"https://api.github.com/repos/aanisov/xen/deployments","created_at":"2016-10-07T13:20:43Z","updated_at":"2016-10-07T13:20:51Z","pushed_at":"2016-11-29T18:04:05Z","git_url":"git://github.com/aanisov/xen.git","ssh_url":"git@github.com:aanisov/xen.git","clone_url":"https://github.com/aanisov/xen.git","svn_url":"https://github.com/aanisov/xen","homepage":"http://xenproject.org","size":71715,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/aanisov/xen/pulls/6"},"html":{"href":"https://github.com/aanisov/xen/pull/6"},"issue":{"href":"https://api.github.com/repos/aanisov/xen/issues/6"},"comments":{"href":"https://api.github.com/repos/aanisov/xen/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/aanisov/xen/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/aanisov/xen/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aanisov/xen/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/aanisov/xen/statuses/eaa0b1eeb8586e5090ce0bfddbf1a87099ba1fb5"}}}}
{"actor":{"display_login":"otyshchenko1"}}