From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuN82-000741-TK for qemu-devel@nongnu.org; Thu, 05 Nov 2015 11:11:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuN7y-00078s-PQ for qemu-devel@nongnu.org; Thu, 05 Nov 2015 11:11:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuN7y-00078o-IK for qemu-devel@nongnu.org; Thu, 05 Nov 2015 11:11:06 -0500 References: <1446733972-1602-1-git-send-email-somlo@cmu.edu> <1446733972-1602-7-git-send-email-somlo@cmu.edu> From: Laszlo Ersek Message-ID: <563B7F97.1070504@redhat.com> Date: Thu, 5 Nov 2015 17:11:03 +0100 MIME-Version: 1.0 In-Reply-To: <1446733972-1602-7-git-send-email-somlo@cmu.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v5 6/6] fw_cfg: replace ioport data read with generic method List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gabriel L. Somlo" , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, jordan.l.justen@intel.com, armbru@redhat.com, kraxel@redhat.com, pbonzini@redhat.com, markmb@redhat.com On 11/05/15 15:32, Gabriel L. Somlo wrote: > IOPort read access is limited to one byte at a time by > fw_cfg_comb_valid(). As such, fw_cfg_comb_read() may safely > ignore its size argument (which will always be 1), and simply > call its fw_cfg_read() helper function once, returning 8 bits > via the least significant byte of a 64-bit return value. >=20 > This patch replaces fw_cfg_comb_read() with the generic method > fw_cfg_data_read(), and removes the unused fw_cfg_read() helper. >=20 > When called with size =3D 1, fw_cfg_data_read() acts exactly like > fw_cfg_read(), performing the same set of sanity checks, and > executing the while loop at most once (subject to the current > read offset being within range). >=20 > Cc: Laszlo Ersek > Cc: Gerd Hoffmann > Cc: Marc Mar=C3=AD > Signed-off-by: Gabriel Somlo > Reviewd-by: Laszlo Ersek Not sure who will pick up this series, but he please fix the typo in the last tag above, at commit time. Thanks! Laszlo > --- > hw/nvram/fw_cfg.c | 25 +------------------------ > 1 file changed, 1 insertion(+), 24 deletions(-) >=20 > diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c > index 8f566f6..a1d650d 100644 > --- a/hw/nvram/fw_cfg.c > +++ b/hw/nvram/fw_cfg.c > @@ -304,23 +304,6 @@ static uint64_t fw_cfg_data_read(void *opaque, hwa= ddr addr, unsigned size) > return value; > } > =20 > -static uint8_t fw_cfg_read(FWCfgState *s) > -{ > - int arch =3D !!(s->cur_entry & FW_CFG_ARCH_LOCAL); > - FWCfgEntry *e =3D (s->cur_entry =3D=3D FW_CFG_INVALID) ? NULL : > - &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK= ]; > - uint8_t ret; > - > - if (s->cur_entry =3D=3D FW_CFG_INVALID || !e->data || s->cur_offse= t >=3D e->len) > - ret =3D 0; > - else { > - ret =3D e->data[s->cur_offset++]; > - } > - > - trace_fw_cfg_read(s, ret); > - return ret; > -} > - > static void fw_cfg_data_mem_write(void *opaque, hwaddr addr, > uint64_t value, unsigned size) > { > @@ -470,12 +453,6 @@ static bool fw_cfg_ctl_mem_valid(void *opaque, hwa= ddr addr, > return is_write && size =3D=3D 2; > } > =20 > -static uint64_t fw_cfg_comb_read(void *opaque, hwaddr addr, > - unsigned size) > -{ > - return fw_cfg_read(opaque); > -} > - > static void fw_cfg_comb_write(void *opaque, hwaddr addr, > uint64_t value, unsigned size) > { > @@ -513,7 +490,7 @@ static const MemoryRegionOps fw_cfg_data_mem_ops =3D= { > }; > =20 > static const MemoryRegionOps fw_cfg_comb_mem_ops =3D { > - .read =3D fw_cfg_comb_read, > + .read =3D fw_cfg_data_read, > .write =3D fw_cfg_comb_write, > .endianness =3D DEVICE_LITTLE_ENDIAN, > .valid.accepts =3D fw_cfg_comb_valid, >=20