From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8Mmi-00083Q-7q for qemu-devel@nongnu.org; Mon, 26 Sep 2011 21:48:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8Mmh-0006Md-53 for qemu-devel@nongnu.org; Mon, 26 Sep 2011 21:48:36 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:49841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8Mmh-0006MS-1J for qemu-devel@nongnu.org; Mon, 26 Sep 2011 21:48:35 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e6.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p8R1OM1C025314 for ; Mon, 26 Sep 2011 21:24:22 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8R1mWW43113068 for ; Mon, 26 Sep 2011 21:48:33 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8R1mWDt014945 for ; Mon, 26 Sep 2011 21:48:32 -0400 Message-ID: <4E812B6F.4030905@linux.vnet.ibm.com> Date: Mon, 26 Sep 2011 21:48:31 -0400 From: Stefan Berger MIME-Version: 1.0 References: <20110926163509.020984459@linux.vnet.ibm.com> <20110926163729.645611239@linux.vnet.ibm.com> <20110926190905.GD22278@redhat.com> In-Reply-To: <20110926190905.GD22278@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V9 2/5] Add TPM (frontend) hardware interface (TPM TIS) to Qemu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: avi@redhat.com, serge@hallyn.com, qemu-devel@nongnu.org, anbang.ruan@cs.ox.ac.uk, andreas.niederl@iaik.tugraz.at On 09/26/2011 03:09 PM, Michael S. Tsirkin wrote: > On Mon, Sep 26, 2011 at 12:35:11PM -0400, Stefan Berger wrote: >> +static int tpm_tis_init(ISADevice *dev) >> +{ >> + TPMState *s = DO_UPCAST(TPMState, busdev, dev); >> + TPMTISState *tis =&s->s.tis; >> + int iomemtype, rc; >> + >> + qemu_mutex_init(&s->state_lock); >> + qemu_cond_init(&s->from_tpm_cond); >> + qemu_cond_init(&s->to_tpm_cond); >> + >> + s->be_driver = qemu_find_tpm(s->backend); >> + if (!s->be_driver) { >> + fprintf(stderr, >> + "tpm_tis: backend driver with id %s could not be found.n\n", >> + s->backend); > error_report? Fixed. >> + return -1; >> + } >> + >> + if (s->be_driver->ops->init(s->be_driver, s, tpm_tis_receive_cb)) { >> + goto err_exit; >> + } >> + >> + isa_init_irq(dev,&tis->irq, tis->irq_num); >> + >> + iomemtype = cpu_register_io_memory(tpm_tis_readfn, tpm_tis_writefn, s, >> + DEVICE_LITTLE_ENDIAN); > A bit of a strange name for a var - it's not a type, is it? > >> + cpu_register_physical_memory(TPM_TIS_ADDR_BASE, >> + 0x1000 * TPM_TIS_NUM_LOCALITIES, >> + iomemtype); > I think memory_region_init_io are supposed to be used for new devices > from now on... Right, Avi? I fixed that now also to use memory_region_init_io(&s->mmio, &tpm_tis_memory_ops, s, "tpm-tis-mmio", 0x1000 * TPM_TIS_NUM_LOCALITIES); memory_region_add_subregion(get_system_memory(), TPM_TIS_ADDR_BASE, &s->mmio); >> + >> + rc = tpm_tis_do_startup_tpm(s); >> + if (rc != 0) { >> + goto err_exit; >> + } >> + >> + return 0; >> + >> + err_exit: > Missing cleanup? > True. Fixed. I had previously looked around in other devices how they were doing it and had often seen them not cleaning up, either. Stefan