From patchwork Fri Oct 13 14:11:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 733227 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489890wrv; Fri, 13 Oct 2023 07:13:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGb2lQjIhyMs1MCoy9X9DGItY554Ix1NlA+/C3Duu3ZyOjPNQ2PtbU16pmCemyBgc6N2Yrd X-Received: by 2002:ac8:5fd6:0:b0:413:bd3:cda5 with SMTP id k22-20020ac85fd6000000b004130bd3cda5mr32396732qta.49.1697206421652; Fri, 13 Oct 2023 07:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206421; cv=none; d=google.com; s=arc-20160816; b=Diien77rLUJkPcZgDq/AUq7IHoAsifVclSPoKrtciBdfXPGp8Ex3LptxQS3z0a104J CgCazprcrQXnU+itVHXB6pitJaGuBuL0crHJ34XtuiFAAak7wsSwGuIyKDKn5ScjRsuz CQYdURer7zIlINoxdHdHshB0uNSGilFKMuWEju33BbK9OvpxE+WkIpyFkb65QOetMuus J4id4xvzjhpSgJDgL5JWvp4796cMMX4eNcTuogPfGiKqLxh8QJQSVy7nrgQOr3m+P0r5 UgnEQ/YWbrwWUdFT7uCAtRuZS0EaWj1hEj1bHMcL7oMIDXdMo3TwHOX76oj/vCrstjjM AcWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RXqOSAIoOSfKO3CZGpouGHrieUGtQ4nqVPJcnN9WYt4=; fh=rgPM1QcSOyRuPluCdnsNd8knie+1OCUx2q8ta7MpVFI=; b=xm3Kzk/RjY+mR3C6AKsusSUE7oHSOUsL5OQIRhK4EgA436KqE8YdugmweNdU8Ow9ca IJfIU0Ohg+EQsWvSe08KC+sfuISGk8VWuzKwayjt/REeN0ncBoibjyPr9Sm1bT1W9ouu zvkyVhd3ZzEYmjNGETQxHOZ+LgusONmcxe+3BfATXKxdT9JnnipgwzoithppSFNclYWl +Nzz0GGSvHNIQC1F1GHi2Jvk6V21A7EpOchhLGf2+jsB9H5fNonqIz5yOg5D/7giSAjj 7QGIxsNwwNFC1p7fg6zYdQi4xfStWuGwlWnwXbjaVRwoirLC+W6HoQDKbNgtCYTI3R4J EORA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LbUNeRTR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o9-20020a05622a008900b0041979a08b5esi1251146qtw.726.2023.10.13.07.13.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:13:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LbUNeRTR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qrIuC-0001Bv-I4; Fri, 13 Oct 2023 10:12: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 1qrIuB-0001B5-Um for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:43 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrIu9-0004dA-6f for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:43 -0400 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5384975e34cso4036249a12.0 for ; Fri, 13 Oct 2023 07:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206358; x=1697811158; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RXqOSAIoOSfKO3CZGpouGHrieUGtQ4nqVPJcnN9WYt4=; b=LbUNeRTRUq6H5+oG5/0NnGy2w56fte0LOAJgmlmCrYziinC86bSzFnJctWAMEjnCNQ Hw0S15NLnob9TxL5VOKcLOYy0c2WLRHHfrg+U5cNOy4As8XlfdR0gP/ZHjEfSn9mWEYJ lMtJD1PadybvKoifw8MT/0MZHrtwb5gZ/UVjv6gfpX1nEbqqSa3UFO/jF7ev58nHEtYY Rg0vlZiKp6BlH5CdWjx1kzBtGZY9d8J79LTOJeXCH02A7qNvG1bIYa05HRBXVyur0DkA o4BVPuxujrOa075h/g5fB0d35aM5D7rhxovEmdENtgINnoqVA/SuVH1SE+E/sGPeg3XX zYVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206358; x=1697811158; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RXqOSAIoOSfKO3CZGpouGHrieUGtQ4nqVPJcnN9WYt4=; b=C7IDa212kd1yCp2eebKM9iBTPl9KB7jTQ1pMHg/IuMhP2y/0lsj1nOHIP/GiZVMbGR Db3kEb/K9YSZl6sMxPQY8HN9B/kglOSUwh9hZmCuMn7BL85knd45dAmFuAefhJkTZJxR OQcuL9qVNYafd6ljFxi9SVF+t4QTNRSGAY+7meBpnfyC8LWbr5sWTxw2/FxS1LAyiW07 b52knOa4/47C80duKb0Giqi5fPEdC/jsk58gWtIQmtaQu3ISHl4f6P2MUf+PnkAGt69D rIjgfeck/Y4y4CAyiOw805eWhrA0wBt7pxaQF/z15A9XBw0lHxBZboDK4UojZrGRcZP0 0whg== X-Gm-Message-State: AOJu0YxWC/jH/mG0+kP/2BqSLC7o0CHDUsAV6Ia+RKJvuo3Ao8vWYL9d tP2A+i6WXw5IcjdqxtHE/JmCoeAE8/b+H3YOFE0= X-Received: by 2002:a05:6402:1bc6:b0:53d:bde4:fa15 with SMTP id ch6-20020a0564021bc600b0053dbde4fa15mr6820322edb.0.1697206357811; Fri, 13 Oct 2023 07:12:37 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id s14-20020a056402014e00b005309eb7544fsm11447251edu.45.2023.10.13.07.12.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:12:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Evgeny Iakovlev , =?utf-8?q?Marc-Andr=C3=A9_?= =?utf-8?q?Lureau?= , Gavin Shan , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v3 9/10] hw/char/pl011: Add transmit FIFO to PL011State Date: Fri, 13 Oct 2023 16:11:30 +0200 Message-ID: <20231013141131.1531-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231013141131.1531-1-philmd@linaro.org> References: <20231013141131.1531-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=philmd@linaro.org; helo=mail-ed1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In order to make the next commit easier to review, introduce the transmit FIFO, but do not yet use it. Uninline pl011_reset_tx_fifo(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- include/hw/char/pl011.h | 2 ++ hw/char/pl011.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h index d853802132..20898f43a6 100644 --- a/include/hw/char/pl011.h +++ b/include/hw/char/pl011.h @@ -18,6 +18,7 @@ #include "hw/sysbus.h" #include "chardev/char-fe.h" #include "qom/object.h" +#include "qemu/fifo8.h" #define TYPE_PL011 "pl011" OBJECT_DECLARE_SIMPLE_TYPE(PL011State, PL011) @@ -53,6 +54,7 @@ struct PL011State { Clock *clk; bool migrate_clk; const unsigned char *id; + Fifo8 xmit_fifo; }; DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr); diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 727decd428..9d98bd8f9a 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -147,11 +147,13 @@ static inline void pl011_reset_rx_fifo(PL011State *s) s->flags |= PL011_FLAG_RXFE; } -static inline void pl011_reset_tx_fifo(PL011State *s) +static void pl011_reset_tx_fifo(PL011State *s) { /* Reset FIFO flags */ s->flags &= ~PL011_FLAG_TXFF; s->flags |= PL011_FLAG_TXFE; + + fifo8_reset(&s->xmit_fifo); } static void pl011_write_txdata(PL011State *s, uint8_t data) @@ -436,6 +438,22 @@ static const VMStateDescription vmstate_pl011_clock = { } }; +static bool pl011_xmit_fifo_state_needed(void *opaque) +{ + return false; +} + +static const VMStateDescription vmstate_pl011_xmit_fifo = { + .name = "pl011/xmit_fifo", + .version_id = 1, + .minimum_version_id = 1, + .needed = pl011_xmit_fifo_state_needed, + .fields = (VMStateField[]) { + VMSTATE_FIFO8(xmit_fifo, PL011State), + VMSTATE_END_OF_LIST() + } +}; + static int pl011_post_load(void *opaque, int version_id) { PL011State* s = opaque; @@ -487,7 +505,11 @@ static const VMStateDescription vmstate_pl011 = { .subsections = (const VMStateDescription * []) { &vmstate_pl011_clock, NULL - } + }, + .subsections = (const VMStateDescription * []) { + &vmstate_pl011_xmit_fifo, + NULL + }, }; static Property pl011_properties[] = { @@ -502,6 +524,7 @@ static void pl011_init(Object *obj) PL011State *s = PL011(obj); int i; + fifo8_create(&s->xmit_fifo, PL011_FIFO_DEPTH); memory_region_init_io(&s->iomem, OBJECT(s), &pl011_ops, s, "pl011", 0x1000); sysbus_init_mmio(sbd, &s->iomem); for (i = 0; i < ARRAY_SIZE(s->irq); i++) { @@ -514,6 +537,13 @@ static void pl011_init(Object *obj) s->id = pl011_id_arm; } +static void pl011_finalize(Object *obj) +{ + PL011State *s = PL011(obj); + + fifo8_destroy(&s->xmit_fifo); +} + static void pl011_realize(DeviceState *dev, Error **errp) { PL011State *s = PL011(dev); @@ -557,6 +587,7 @@ static const TypeInfo pl011_arm_info = { .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(PL011State), .instance_init = pl011_init, + .instance_finalize = pl011_finalize, .class_init = pl011_class_init, };