{"id":819454,"url":"http://patchwork.ozlabs.org/api/patches/819454/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1506590409-28857-7-git-send-email-amarnath.valluri@intel.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1506590409-28857-7-git-send-email-amarnath.valluri@intel.com>","list_archive_url":null,"date":"2017-09-28T09:20:07","name":"[v9,6/8] tpm-backend: Move realloc_buffer() implementation to tpm-tis model","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"4f6196c6cea85ff2e72a90fba12565dec8dc218f","submitter":{"id":71320,"url":"http://patchwork.ozlabs.org/api/people/71320/?format=json","name":"Valluri, Amarnath","email":"amarnath.valluri@intel.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1506590409-28857-7-git-send-email-amarnath.valluri@intel.com/mbox/","series":[{"id":5516,"url":"http://patchwork.ozlabs.org/api/series/5516/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=5516","date":"2017-09-28T09:20:02","name":"Provide support for the software TPM","version":9,"mbox":"http://patchwork.ozlabs.org/series/5516/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/819454/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/819454/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y2q2k25Cvz9t2c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 28 Sep 2017 19:22:06 +1000 (AEST)","from localhost ([::1]:58106 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dxV1A-0002i5-8G\n\tfor incoming@patchwork.ozlabs.org; Thu, 28 Sep 2017 05:22:04 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:59245)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <amarnath.valluri@intel.com>) id 1dxUyQ-0000vQ-7U\n\tfor qemu-devel@nongnu.org; Thu, 28 Sep 2017 05:19:15 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <amarnath.valluri@intel.com>) id 1dxUyK-0000tD-B8\n\tfor qemu-devel@nongnu.org; Thu, 28 Sep 2017 05:19:14 -0400","from mga11.intel.com ([192.55.52.93]:13925)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <amarnath.valluri@intel.com>)\n\tid 1dxUyJ-0000bz-Uc\n\tfor qemu-devel@nongnu.org; Thu, 28 Sep 2017 05:19:08 -0400","from orsmga005.jf.intel.com ([10.7.209.41])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t28 Sep 2017 02:19:07 -0700","from avallurigigabyte.fi.intel.com ([10.237.68.147])\n\tby orsmga005.jf.intel.com with ESMTP; 28 Sep 2017 02:19:06 -0700"],"X-ExtLoop1":"1","X-IronPort-AV":"E=Sophos;i=\"5.42,449,1500966000\"; d=\"scan'208\";a=\"154306607\"","From":"Amarnath Valluri <amarnath.valluri@intel.com>","To":"qemu-devel@nongnu.org","Date":"Thu, 28 Sep 2017 12:20:07 +0300","Message-Id":"<1506590409-28857-7-git-send-email-amarnath.valluri@intel.com>","X-Mailer":"git-send-email 2.7.4","In-Reply-To":"<1506590409-28857-1-git-send-email-amarnath.valluri@intel.com>","References":"<1506590409-28857-1-git-send-email-amarnath.valluri@intel.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"192.55.52.93","Subject":"[Qemu-devel] [PATCH v9 6/8] tpm-backend: Move realloc_buffer()\n\timplementation to tpm-tis model","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Amarnath Valluri <amarnath.valluri@intel.com>, =?utf-8?q?Marc-Andr?=\n\t=?utf-8?b?w6kgTHVyZWF1?= <marcandre.lureau@gmail.com>,\n\tStefan Berger <stefanb@linux.vnet.ibm.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"buffer reallocation is very unlikely to be backend specific. Hence move inside\nthe tis.\n\nSigned-off-by: Amarnath Valluri <amarnath.valluri@intel.com>\nReviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>\nReviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>\n---\n backends/tpm.c               |  9 ---------\n hw/tpm/tpm_passthrough.c     | 12 ------------\n hw/tpm/tpm_tis.c             | 14 ++++++++++++--\n include/sysemu/tpm_backend.h | 12 ------------\n 4 files changed, 12 insertions(+), 35 deletions(-)","diff":"diff --git a/backends/tpm.c b/backends/tpm.c\nindex de313c9..37c84b7 100644\n--- a/backends/tpm.c\n+++ b/backends/tpm.c\n@@ -80,15 +80,6 @@ bool tpm_backend_had_startup_error(TPMBackend *s)\n     return s->had_startup_error;\n }\n \n-size_t tpm_backend_realloc_buffer(TPMBackend *s, TPMSizedBuffer *sb)\n-{\n-    TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);\n-\n-    assert(k->ops->realloc_buffer);\n-\n-    return k->ops->realloc_buffer(sb);\n-}\n-\n void tpm_backend_deliver_request(TPMBackend *s)\n {\n     g_thread_pool_push(s->thread_pool, (gpointer)TPM_BACKEND_CMD_PROCESS_CMD,\ndiff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c\nindex 84fc49a..22d3460 100644\n--- a/hw/tpm/tpm_passthrough.c\n+++ b/hw/tpm/tpm_passthrough.c\n@@ -247,17 +247,6 @@ static int tpm_passthrough_reset_tpm_established_flag(TPMBackend *tb,\n     return 0;\n }\n \n-static size_t tpm_passthrough_realloc_buffer(TPMSizedBuffer *sb)\n-{\n-    size_t wanted_size = 4096; /* Linux tpm.c buffer size */\n-\n-    if (sb->size != wanted_size) {\n-        sb->buffer = g_realloc(sb->buffer, wanted_size);\n-        sb->size = wanted_size;\n-    }\n-    return sb->size;\n-}\n-\n static void tpm_passthrough_cancel_cmd(TPMBackend *tb)\n {\n     TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);\n@@ -435,7 +424,6 @@ static const TPMDriverOps tpm_passthrough_driver = {\n     .opts                     = tpm_passthrough_cmdline_opts,\n     .desc                     = \"Passthrough TPM backend driver\",\n     .create                   = tpm_passthrough_create,\n-    .realloc_buffer           = tpm_passthrough_realloc_buffer,\n     .reset                    = tpm_passthrough_reset,\n     .cancel_cmd               = tpm_passthrough_cancel_cmd,\n     .get_tpm_established_flag = tpm_passthrough_get_tpm_established_flag,\ndiff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c\nindex a6440fe..d5118e7 100644\n--- a/hw/tpm/tpm_tis.c\n+++ b/hw/tpm/tpm_tis.c\n@@ -963,6 +963,16 @@ static int tpm_tis_do_startup_tpm(TPMState *s)\n     return tpm_backend_startup_tpm(s->be_driver);\n }\n \n+static void tpm_tis_realloc_buffer(TPMSizedBuffer *sb)\n+{\n+    size_t wanted_size = 4096; /* Linux tpm.c buffer size */\n+\n+    if (sb->size != wanted_size) {\n+        sb->buffer = g_realloc(sb->buffer, wanted_size);\n+        sb->size = wanted_size;\n+    }\n+}\n+\n /*\n  * Get the TPMVersion of the backend device being used\n  */\n@@ -1010,9 +1020,9 @@ static void tpm_tis_reset(DeviceState *dev)\n         tis->loc[c].state = TPM_TIS_STATE_IDLE;\n \n         tis->loc[c].w_offset = 0;\n-        tpm_backend_realloc_buffer(s->be_driver, &tis->loc[c].w_buffer);\n+        tpm_tis_realloc_buffer(&tis->loc[c].w_buffer);\n         tis->loc[c].r_offset = 0;\n-        tpm_backend_realloc_buffer(s->be_driver, &tis->loc[c].r_buffer);\n+        tpm_tis_realloc_buffer(&tis->loc[c].r_buffer);\n     }\n \n     tpm_tis_do_startup_tpm(s);\ndiff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h\nindex e96c191..2c798a1 100644\n--- a/include/sysemu/tpm_backend.h\n+++ b/include/sysemu/tpm_backend.h\n@@ -84,8 +84,6 @@ struct TPMDriverOps {\n     /* start up the TPM on the backend */\n     int (*startup_tpm)(TPMBackend *t);\n \n-    size_t (*realloc_buffer)(TPMSizedBuffer *sb);\n-\n     void (*reset)(TPMBackend *t);\n \n     void (*cancel_cmd)(TPMBackend *t);\n@@ -140,16 +138,6 @@ int tpm_backend_startup_tpm(TPMBackend *s);\n bool tpm_backend_had_startup_error(TPMBackend *s);\n \n /**\n- * tpm_backend_realloc_buffer:\n- * @s: the backend\n- * @sb: the TPMSizedBuffer to re-allocated to the size suitable for the\n- *      backend.\n- *\n- * This function returns the size of the allocated buffer\n- */\n-size_t tpm_backend_realloc_buffer(TPMBackend *s, TPMSizedBuffer *sb);\n-\n-/**\n  * tpm_backend_deliver_request:\n  * @s: the backend to send the request to\n  *\n","prefixes":["v9","6/8"]}