Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5143DC7618E for ; Sat, 22 Apr 2023 21:28:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqKlk-0005jc-1R; Sat, 22 Apr 2023 17:27:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqKli-0005fe-2Y; Sat, 22 Apr 2023 17:27:42 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqKle-0000JV-DR; Sat, 22 Apr 2023 17:27:41 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 902217462DB; Sat, 22 Apr 2023 23:26:00 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 46A81745720; Sat, 22 Apr 2023 23:26:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 44D8A7456E3; Sat, 22 Apr 2023 23:26:00 +0200 (CEST) Date: Sat, 22 Apr 2023 23:26:00 +0200 (CEST) From: BALATON Zoltan To: Bernhard Beschow cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Jiaxun Yang , John Snow , Huacai Chen , =?ISO-8859-15?Q?Philippe_Mathieu-Daud=E9?= , qemu-ppc@nongnu.org Subject: Re: [PATCH 13/13] hw/ide: Extract bmdma_clear_status() In-Reply-To: <20230422150728.176512-14-shentey@gmail.com> Message-ID: References: <20230422150728.176512-1-shentey@gmail.com> <20230422150728.176512-14-shentey@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Sat, 22 Apr 2023, Bernhard Beschow wrote: > Extract bmdma_clear_status() mirroring bmdma_cmd_writeb(). Is adding a trace point useful? This is called from places that already have traces so I don't think we need another separate trace point here. Also the names don't match but maybe rename function to bmdma_update_status instead as it is more what it does. Regards, BALATON Zoltan > Signed-off-by: Bernhard Beschow > --- > include/hw/ide/pci.h | 1 + > hw/ide/cmd646.c | 2 +- > hw/ide/pci.c | 7 +++++++ > hw/ide/piix.c | 2 +- > hw/ide/sii3112.c | 12 +++++------- > hw/ide/via.c | 2 +- > hw/ide/trace-events | 1 + > 7 files changed, 17 insertions(+), 10 deletions(-) > > diff --git a/include/hw/ide/pci.h b/include/hw/ide/pci.h > index 81e0370202..6a286ad307 100644 > --- a/include/hw/ide/pci.h > +++ b/include/hw/ide/pci.h > @@ -59,6 +59,7 @@ struct PCIIDEState { > void bmdma_init(IDEBus *bus, BMDMAState *bm, PCIIDEState *d); > void bmdma_init_ops(PCIIDEState *d, const MemoryRegionOps *bmdma_ops); > void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val); > +void bmdma_clear_status(BMDMAState *bm, uint32_t val); > void pci_ide_create_devs(PCIDevice *dev); > > #endif > diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c > index b9d005a357..973c3ff0dc 100644 > --- a/hw/ide/cmd646.c > +++ b/hw/ide/cmd646.c > @@ -144,7 +144,7 @@ static void bmdma_write(void *opaque, hwaddr addr, > cmd646_update_irq(pci_dev); > break; > case 2: > - bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06); > + bmdma_clear_status(bm, val); > break; > case 3: > if (bm == &bm->pci_dev->bmdma[0]) { > diff --git a/hw/ide/pci.c b/hw/ide/pci.c > index 3539b162b7..4aa06be7c6 100644 > --- a/hw/ide/pci.c > +++ b/hw/ide/pci.c > @@ -318,6 +318,13 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) > bm->cmd = val & 0x09; > } > > +void bmdma_clear_status(BMDMAState *bm, uint32_t val) > +{ > + trace_bmdma_update_status(val); > + > + bm->status = (val & 0x60) | (bm->status & BM_STATUS_DMAING) | (bm->status & ~val & 0x06); > +} > + > static uint64_t bmdma_addr_read(void *opaque, hwaddr addr, > unsigned width) > { > diff --git a/hw/ide/piix.c b/hw/ide/piix.c > index 406a67fa0f..9eab615e35 100644 > --- a/hw/ide/piix.c > +++ b/hw/ide/piix.c > @@ -76,7 +76,7 @@ static void bmdma_write(void *opaque, hwaddr addr, > bmdma_cmd_writeb(bm, val); > break; > case 2: > - bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06); > + bmdma_clear_status(bm, val); > break; > } > } > diff --git a/hw/ide/sii3112.c b/hw/ide/sii3112.c > index 373c0dd1ee..1180ff55e7 100644 > --- a/hw/ide/sii3112.c > +++ b/hw/ide/sii3112.c > @@ -66,7 +66,7 @@ static void sii3112_bmdma_write(void *opaque, hwaddr addr, > uint64_t val, unsigned int size) > { > BMDMAState *bm = opaque; > - SiI3112PCIState *d = SII3112_PCI(bm->pci_dev); > + SiI3112PCIState *s = SII3112_PCI(bm->pci_dev); > int i = (bm == &bm->pci_dev->bmdma[0]) ? 0 : 1; > > trace_sii3112_bmdma_write(size, addr, val); > @@ -75,10 +75,10 @@ static void sii3112_bmdma_write(void *opaque, hwaddr addr, > bmdma_cmd_writeb(bm, val); > break; > case 0x01: > - d->regs[i].swdata = val & 0x3f; > + s->regs[i].swdata = val & 0x3f; > break; > case 0x02: > - bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 6); > + bmdma_clear_status(bm, val); > break; > default: > break; > @@ -160,8 +160,7 @@ static void sii3112_reg_write(void *opaque, hwaddr addr, > d->regs[0].swdata = val & 0x3f; > break; > case 0x12: > - d->i.bmdma[0].status = (val & 0x60) | (d->i.bmdma[0].status & 1) | > - (d->i.bmdma[0].status & ~val & 6); > + bmdma_clear_status(&d->i.bmdma[0], val); > break; > case 0x18: > bmdma_cmd_writeb(&d->i.bmdma[1], val); > @@ -170,8 +169,7 @@ static void sii3112_reg_write(void *opaque, hwaddr addr, > d->regs[1].swdata = val & 0x3f; > break; > case 0x1a: > - d->i.bmdma[1].status = (val & 0x60) | (d->i.bmdma[1].status & 1) | > - (d->i.bmdma[1].status & ~val & 6); > + bmdma_clear_status(&d->i.bmdma[1], val); > break; > case 0x100: > d->regs[0].scontrol = val & 0xfff; > diff --git a/hw/ide/via.c b/hw/ide/via.c > index 35dd97e49b..afb97f302a 100644 > --- a/hw/ide/via.c > +++ b/hw/ide/via.c > @@ -75,7 +75,7 @@ static void bmdma_write(void *opaque, hwaddr addr, > bmdma_cmd_writeb(bm, val); > break; > case 2: > - bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06); > + bmdma_clear_status(bm, val); > break; > default:; > } > diff --git a/hw/ide/trace-events b/hw/ide/trace-events > index a479525e38..d219c64b61 100644 > --- a/hw/ide/trace-events > +++ b/hw/ide/trace-events > @@ -30,6 +30,7 @@ bmdma_write_cmd646(uint64_t addr, uint64_t val) "bmdma: writeb 0x%"PRIx64" : 0x% > # pci.c > bmdma_reset(void) "" > bmdma_cmd_writeb(uint32_t val) "val: 0x%08x" > +bmdma_update_status(uint32_t val) "val: 0x%08x" > bmdma_addr_read(uint64_t data) "data: 0x%016"PRIx64 > bmdma_addr_write(uint64_t data) "data: 0x%016"PRIx64 > >