From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzbJG-000237-Ak for qemu-devel@nongnu.org; Mon, 20 Feb 2012 17:02:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzbJF-0005Cx-1j for qemu-devel@nongnu.org; Mon, 20 Feb 2012 17:02:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzbJE-0005Cl-P6 for qemu-devel@nongnu.org; Mon, 20 Feb 2012 17:02:13 -0500 Date: Tue, 21 Feb 2012 00:02:01 +0200 From: "Michael S. Tsirkin" Message-ID: <20120220220201.GD19278@redhat.com> References: <1323870202-25742-1-git-send-email-stefanb@linux.vnet.ibm.com> <1323870202-25742-3-git-send-email-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1323870202-25742-3-git-send-email-stefanb@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH V14 2/7] Add TPM (frontend) hardware interface (TPM TIS) to Qemu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Berger Cc: qemu-devel@nongnu.org, andreas.niederl@iaik.tugraz.at On Wed, Dec 14, 2011 at 08:43:17AM -0500, Stefan Berger wrote: > +/* > + * Send a TPM request. > + * Call this with the state_lock held so we can sync with the receive > + * callback. > + */ > +static void tpm_tis_tpm_send(TPMState *s, uint8_t locty) > +{ > + TPMTISState *tis = &s->s.tis; > + > + tpm_tis_show_buffer(&tis->loc[locty].w_buffer, "tpm_tis: To TPM"); > + > + s->command_locty = locty; > + s->cmd_locty = &tis->loc[locty]; > + > + /* w_offset serves as length indicator for length of data; > + it's reset when the response comes back */ > + tis->loc[locty].status = TPM_TIS_STATUS_EXECUTION; > + tis->loc[locty].sts &= ~TPM_TIS_STS_EXPECT; > + > + s->to_tpm_execute = true; > + qemu_cond_signal(&s->to_tpm_cond); > +} What happens IIUC is that frondend sets to_tpm_execute and signals a condition, and backend clears it and waits on a condition. So how about moving all the signalling and locking out to backend, and have frontend invoke a callback to signal it? The whole threading thing then becomes a work-around for a backend that does not support select, instead of spilling out into frontend? -- MST