From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B7B1C433DB for ; Wed, 17 Feb 2021 17:48:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 595FB64E42 for ; Wed, 17 Feb 2021 17:48:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232216AbhBQRsf (ORCPT ); Wed, 17 Feb 2021 12:48:35 -0500 Received: from foss.arm.com ([217.140.110.172]:35028 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232784AbhBQRsb (ORCPT ); Wed, 17 Feb 2021 12:48:31 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 664391FB; Wed, 17 Feb 2021 09:47:45 -0800 (PST) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 29C803F73D; Wed, 17 Feb 2021 09:47:44 -0800 (PST) Date: Wed, 17 Feb 2021 17:46:32 +0000 From: Andre Przywara To: Alexandru Elisei Cc: Will Deacon , Julien Thierry , kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Marc Zyngier Subject: Re: [PATCH kvmtool 05/21] hw/i8042: Clean up data types Message-ID: <20210217174632.660934f7@slackpad.fritz.box> In-Reply-To: <04b5f537-1594-61b9-b7ef-4062e732e380@arm.com> References: <20201210142908.169597-1-andre.przywara@arm.com> <20201210142908.169597-6-andre.przywara@arm.com> <04b5f537-1594-61b9-b7ef-4062e732e380@arm.com> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, 11 Feb 2021 16:55:43 +0000 Alexandru Elisei wrote: Hi, > On 12/10/20 2:28 PM, Andre Przywara wrote: > > > The i8042 is clearly an 8-bit era device, so there is little room for > > 32-bit registers. > > Clean up the data types used. > > > > Signed-off-by: Andre Przywara > > --- > > hw/i8042.c | 20 ++++++++++---------- > > 1 file changed, 10 insertions(+), 10 deletions(-) > > > > diff --git a/hw/i8042.c b/hw/i8042.c > > index 37a99a2d..36ee183f 100644 > > --- a/hw/i8042.c > > +++ b/hw/i8042.c > > @@ -64,11 +64,11 @@ > > struct kbd_state { > > struct kvm *kvm; > > > > - char kq[QUEUE_SIZE]; /* Keyboard queue */ > > + u8 kq[QUEUE_SIZE]; /* Keyboard queue */ > > int kread, kwrite; /* Indexes into the queue */ > > int kcount; /* number of elements in queue */ > > > > - char mq[QUEUE_SIZE]; > > + u8 mq[QUEUE_SIZE]; > > int mread, mwrite; > > int mcount; > > I think the write_cmd field further down should also be u8 because it stores the > first byte of a command (and it's set only to an 8 bit value in kbd_write_command()). Yes, looks like it, will change it on the way. I guess I wanted to suppress my rewrite-everything complex ;-) If you allow, I will also fix the confusing indentation bug in the big switch statement on the way. > Otherwise, it looks ok to me. osdev wiki seems to confirm that the device is > indeed 8 bit only, and all the registers are 8 bit now: > > Reviewed-by: Alexandru Elisei Thanks! Andre > > > > > @@ -173,9 +173,9 @@ static void kbd_write_command(struct kvm *kvm, u8 val) > > /* > > * Called when the OS reads from port 0x60 (PS/2 data) > > */ > > -static u32 kbd_read_data(void) > > +static u8 kbd_read_data(void) > > { > > - u32 ret; > > + u8 ret; > > int i; > > > > if (state.kcount != 0) { > > @@ -202,9 +202,9 @@ static u32 kbd_read_data(void) > > /* > > * Called when the OS read from port 0x64, the command port > > */ > > -static u32 kbd_read_status(void) > > +static u8 kbd_read_status(void) > > { > > - return (u32)state.status; > > + return state.status; > > } > > > > /* > > @@ -212,7 +212,7 @@ static u32 kbd_read_status(void) > > * Things written here are generally arguments to commands previously > > * written to port 0x64 and stored in state.write_cmd > > */ > > -static void kbd_write_data(u32 val) > > +static void kbd_write_data(u8 val) > > { > > switch (state.write_cmd) { > > case I8042_CMD_CTL_WCTR: > > @@ -304,8 +304,8 @@ static bool kbd_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void * > > break; > > } > > case I8042_DATA_REG: { > > - u32 value = kbd_read_data(); > > - ioport__write32(data, value); > > + u8 value = kbd_read_data(); > > + ioport__write8(data, value); > > break; > > } > > case I8042_PORT_B_REG: { > > @@ -328,7 +328,7 @@ static bool kbd_out(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void > > break; > > } > > case I8042_DATA_REG: { > > - u32 value = ioport__read32(data); > > + u8 value = ioport__read8(data); > > kbd_write_data(value); > > break; > > } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35552C433DB for ; Wed, 17 Feb 2021 17:47:51 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 93C3764E4A for ; Wed, 17 Feb 2021 17:47:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93C3764E4A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 22EF74B4C1; Wed, 17 Feb 2021 12:47:50 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DrZqVnxx46EW; Wed, 17 Feb 2021 12:47:48 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BD7CD4B393; Wed, 17 Feb 2021 12:47:48 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 6148A4B17C for ; Wed, 17 Feb 2021 12:47:47 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ORGm7R4aPAXF for ; Wed, 17 Feb 2021 12:47:45 -0500 (EST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D0A664B2B4 for ; Wed, 17 Feb 2021 12:47:45 -0500 (EST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 664391FB; Wed, 17 Feb 2021 09:47:45 -0800 (PST) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 29C803F73D; Wed, 17 Feb 2021 09:47:44 -0800 (PST) Date: Wed, 17 Feb 2021 17:46:32 +0000 From: Andre Przywara To: Alexandru Elisei Subject: Re: [PATCH kvmtool 05/21] hw/i8042: Clean up data types Message-ID: <20210217174632.660934f7@slackpad.fritz.box> In-Reply-To: <04b5f537-1594-61b9-b7ef-4062e732e380@arm.com> References: <20201210142908.169597-1-andre.przywara@arm.com> <20201210142908.169597-6-andre.przywara@arm.com> <04b5f537-1594-61b9-b7ef-4062e732e380@arm.com> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 Cc: kvm@vger.kernel.org, Marc Zyngier , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Thu, 11 Feb 2021 16:55:43 +0000 Alexandru Elisei wrote: Hi, > On 12/10/20 2:28 PM, Andre Przywara wrote: > > > The i8042 is clearly an 8-bit era device, so there is little room for > > 32-bit registers. > > Clean up the data types used. > > > > Signed-off-by: Andre Przywara > > --- > > hw/i8042.c | 20 ++++++++++---------- > > 1 file changed, 10 insertions(+), 10 deletions(-) > > > > diff --git a/hw/i8042.c b/hw/i8042.c > > index 37a99a2d..36ee183f 100644 > > --- a/hw/i8042.c > > +++ b/hw/i8042.c > > @@ -64,11 +64,11 @@ > > struct kbd_state { > > struct kvm *kvm; > > > > - char kq[QUEUE_SIZE]; /* Keyboard queue */ > > + u8 kq[QUEUE_SIZE]; /* Keyboard queue */ > > int kread, kwrite; /* Indexes into the queue */ > > int kcount; /* number of elements in queue */ > > > > - char mq[QUEUE_SIZE]; > > + u8 mq[QUEUE_SIZE]; > > int mread, mwrite; > > int mcount; > > I think the write_cmd field further down should also be u8 because it stores the > first byte of a command (and it's set only to an 8 bit value in kbd_write_command()). Yes, looks like it, will change it on the way. I guess I wanted to suppress my rewrite-everything complex ;-) If you allow, I will also fix the confusing indentation bug in the big switch statement on the way. > Otherwise, it looks ok to me. osdev wiki seems to confirm that the device is > indeed 8 bit only, and all the registers are 8 bit now: > > Reviewed-by: Alexandru Elisei Thanks! Andre > > > > > @@ -173,9 +173,9 @@ static void kbd_write_command(struct kvm *kvm, u8 val) > > /* > > * Called when the OS reads from port 0x60 (PS/2 data) > > */ > > -static u32 kbd_read_data(void) > > +static u8 kbd_read_data(void) > > { > > - u32 ret; > > + u8 ret; > > int i; > > > > if (state.kcount != 0) { > > @@ -202,9 +202,9 @@ static u32 kbd_read_data(void) > > /* > > * Called when the OS read from port 0x64, the command port > > */ > > -static u32 kbd_read_status(void) > > +static u8 kbd_read_status(void) > > { > > - return (u32)state.status; > > + return state.status; > > } > > > > /* > > @@ -212,7 +212,7 @@ static u32 kbd_read_status(void) > > * Things written here are generally arguments to commands previously > > * written to port 0x64 and stored in state.write_cmd > > */ > > -static void kbd_write_data(u32 val) > > +static void kbd_write_data(u8 val) > > { > > switch (state.write_cmd) { > > case I8042_CMD_CTL_WCTR: > > @@ -304,8 +304,8 @@ static bool kbd_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void * > > break; > > } > > case I8042_DATA_REG: { > > - u32 value = kbd_read_data(); > > - ioport__write32(data, value); > > + u8 value = kbd_read_data(); > > + ioport__write8(data, value); > > break; > > } > > case I8042_PORT_B_REG: { > > @@ -328,7 +328,7 @@ static bool kbd_out(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void > > break; > > } > > case I8042_DATA_REG: { > > - u32 value = ioport__read32(data); > > + u8 value = ioport__read8(data); > > kbd_write_data(value); > > break; > > } _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33A28C433E6 for ; Wed, 17 Feb 2021 17:49:14 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E864B64DF3 for ; Wed, 17 Feb 2021 17:49:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E864B64DF3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HV3NOr1Q8KqBrgN81tEAtZaGVnsXuOPnJsiAEj7GvBw=; b=JkzHZYPIgkvcPFxhqeYML0kTP 5Tty506QkKlWR7QvnviPfgPZgnXMQvM8YhkarhSHOPGgZAI1/eyO0M4maELHQM/6W4LkEmm4t/7A3 bwLtPzP5PovEX1XmRGTKL/bKs3qtMqQXR5+DnwR75l88Z0s5Uo5j65QjeQ6sU9Hmhz9p9PpspBg5d kSLDN1hkjoHly7gyWz45MY6nXHOApfYeyumZqTsHm67h3WEY0ds7HSj+MtQxMFj4mhjtt70gqMbpG xmGCdjp0XwIuxXpSG3TVHFK50BvQRkZ8oC2NRzAMoYWbo6scaDIAPgyAuxEwOMHKucvukrtsR0df4 zrl8tLo2w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lCQva-0005DR-4m; Wed, 17 Feb 2021 17:47:54 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lCQvX-0005D2-Nv for linux-arm-kernel@lists.infradead.org; Wed, 17 Feb 2021 17:47:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 664391FB; Wed, 17 Feb 2021 09:47:45 -0800 (PST) Received: from slackpad.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 29C803F73D; Wed, 17 Feb 2021 09:47:44 -0800 (PST) Date: Wed, 17 Feb 2021 17:46:32 +0000 From: Andre Przywara To: Alexandru Elisei Subject: Re: [PATCH kvmtool 05/21] hw/i8042: Clean up data types Message-ID: <20210217174632.660934f7@slackpad.fritz.box> In-Reply-To: <04b5f537-1594-61b9-b7ef-4062e732e380@arm.com> References: <20201210142908.169597-1-andre.przywara@arm.com> <20201210142908.169597-6-andre.przywara@arm.com> <04b5f537-1594-61b9-b7ef-4062e732e380@arm.com> Organization: Arm Ltd. X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.31; x86_64-slackware-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210217_124751_888804_CEC39815 X-CRM114-Status: GOOD ( 25.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Marc Zyngier , Julien Thierry , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 11 Feb 2021 16:55:43 +0000 Alexandru Elisei wrote: Hi, > On 12/10/20 2:28 PM, Andre Przywara wrote: > > > The i8042 is clearly an 8-bit era device, so there is little room for > > 32-bit registers. > > Clean up the data types used. > > > > Signed-off-by: Andre Przywara > > --- > > hw/i8042.c | 20 ++++++++++---------- > > 1 file changed, 10 insertions(+), 10 deletions(-) > > > > diff --git a/hw/i8042.c b/hw/i8042.c > > index 37a99a2d..36ee183f 100644 > > --- a/hw/i8042.c > > +++ b/hw/i8042.c > > @@ -64,11 +64,11 @@ > > struct kbd_state { > > struct kvm *kvm; > > > > - char kq[QUEUE_SIZE]; /* Keyboard queue */ > > + u8 kq[QUEUE_SIZE]; /* Keyboard queue */ > > int kread, kwrite; /* Indexes into the queue */ > > int kcount; /* number of elements in queue */ > > > > - char mq[QUEUE_SIZE]; > > + u8 mq[QUEUE_SIZE]; > > int mread, mwrite; > > int mcount; > > I think the write_cmd field further down should also be u8 because it stores the > first byte of a command (and it's set only to an 8 bit value in kbd_write_command()). Yes, looks like it, will change it on the way. I guess I wanted to suppress my rewrite-everything complex ;-) If you allow, I will also fix the confusing indentation bug in the big switch statement on the way. > Otherwise, it looks ok to me. osdev wiki seems to confirm that the device is > indeed 8 bit only, and all the registers are 8 bit now: > > Reviewed-by: Alexandru Elisei Thanks! Andre > > > > > @@ -173,9 +173,9 @@ static void kbd_write_command(struct kvm *kvm, u8 val) > > /* > > * Called when the OS reads from port 0x60 (PS/2 data) > > */ > > -static u32 kbd_read_data(void) > > +static u8 kbd_read_data(void) > > { > > - u32 ret; > > + u8 ret; > > int i; > > > > if (state.kcount != 0) { > > @@ -202,9 +202,9 @@ static u32 kbd_read_data(void) > > /* > > * Called when the OS read from port 0x64, the command port > > */ > > -static u32 kbd_read_status(void) > > +static u8 kbd_read_status(void) > > { > > - return (u32)state.status; > > + return state.status; > > } > > > > /* > > @@ -212,7 +212,7 @@ static u32 kbd_read_status(void) > > * Things written here are generally arguments to commands previously > > * written to port 0x64 and stored in state.write_cmd > > */ > > -static void kbd_write_data(u32 val) > > +static void kbd_write_data(u8 val) > > { > > switch (state.write_cmd) { > > case I8042_CMD_CTL_WCTR: > > @@ -304,8 +304,8 @@ static bool kbd_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void * > > break; > > } > > case I8042_DATA_REG: { > > - u32 value = kbd_read_data(); > > - ioport__write32(data, value); > > + u8 value = kbd_read_data(); > > + ioport__write8(data, value); > > break; > > } > > case I8042_PORT_B_REG: { > > @@ -328,7 +328,7 @@ static bool kbd_out(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void > > break; > > } > > case I8042_DATA_REG: { > > - u32 value = ioport__read32(data); > > + u8 value = ioport__read8(data); > > kbd_write_data(value); > > break; > > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel