From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mL2-00053R-Ag for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:55:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mL1-0003MF-G2 for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:55:52 -0400 Received: from mail-wr0-x235.google.com ([2a00:1450:400c:c0c::235]:33424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d0mL0-0003Lt-Rn for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:55:51 -0400 Received: by mail-wr0-x235.google.com with SMTP id l28so11775754wre.0 for ; Wed, 19 Apr 2017 02:55:50 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Peter Maydell Date: Wed, 19 Apr 2017 10:55:29 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] Hight Processor time of Socket communciation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jiahuan Zhang Cc: QEMU Developers On 19 April 2017 at 10:25, Jiahuan Zhang wrote: > On 19 April 2017 at 11:15, Peter Maydell wrote: >> What is happening is that the guest kernel's serial driver >> has a loop that (simplified) looks like this: >> >> do { >> if (pl011_read(REG_FR) & FR_TXFF) >> break; /* fifo full, try again later */ >> pl011_write(buffer[x], REG_DR); /* send one byte */ >> x++; >> } while (x != len); >> >> This is a lot of guest CPU instructions (and two callouts >> to QEMU's device emulation) for every single byte. >> > Hi, no, I am not using any kernel driver and I only test the guest to host > data transfer. OK, then the equivalent loop is this one: > /* > * write_to_uart(): write data to serial port > */ > void write_to_uart(char* out, uint32_t writeSize){ > int i; > for(i=0; i *UART1 =(unsigned char)(*(out+i)); > } > } except that your code is broken because it's not checking that the FIFO is ready to receive the character so it will drop data sometimes. The point is the same -- you're feeding the data to the UART byte-at-a-time. thanks -- PMM