From patchwork Fri Oct 13 14:11:22 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: 733224 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489420wrv; Fri, 13 Oct 2023 07:12:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgNLjDtgJwJBiU15r2nZGzHrICmJ9stcf2q1qkcEU/eOzQDceUg6VFgQX9nDR32qzdJGuW X-Received: by 2002:a1f:df43:0:b0:48f:f026:27de with SMTP id w64-20020a1fdf43000000b0048ff02627demr17709012vkg.15.1697206371016; Fri, 13 Oct 2023 07:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206370; cv=none; d=google.com; s=arc-20160816; b=oYIP5MsTA5NL0qLkS8PJ4s18zfxGyrZ7Lr0NusCtjaaZ6kk13uJGiOmVp4JRW6Dofb IHo6poeC/LeU6o/q/3bwk30PiA26bhlfEpT10bu2kHtDXilfsA9TFoA+D4cOKNRgVo8f 3r2YxDddlJxU0dZJdYhwgD+5HdInQnv+tkOY6pUGtaCo8fZzL2fEX8P9s8Ac3kiNkoAZ J23P6dBkUWrncvcJ3nSIS5Irc8sLJgO5H/ZLUs29l+tJ/rkkBvA0gFu3KIsdyZUOr4rO A3FJe4Gl3Wxhtv0SSsEaVu3L4+NYjLvDFCZyKXDhQBPamEu3qtBks28O7Tbdkwh4lTRA COiA== 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=tAZvf0/lxzzRafQirPbdSKogeoxVhHxgjxTZIWfzoxQ=; fh=iNlBFRzKWcUVyIm7M2O0DMt8HyVCk33Ec3Usyd6Qlks=; b=eOs4VMO+pvxh5yk8Gy+jRffALcfHyFuXGKY7xMnfTroNT/+6aGKuXdyaVCxQWPxP2F X/Hm+5+6N63DLlXK4Sc22k7ZTG8B3/0eiFYoB9FdTzVbnR1cumH0sjVxz8RpMDnM1orb gB+KoGLhQ26cQ1vdTbTXJD9IfqUlZRJmBdb/9fEHjwSUASRN47CuaBgnCTWvpkUr7t1H 2TrCPDyRKVclAAASiYkaICfavjgzC2t99x68nGCuhubOp11F2IZTdt3gxeB1+m0HJ+ww y0BMiMZANPdROHke4nhJkDXM57F7UFx4SQjIqt7NFl0lkWl2FbXgHTSgt1+Un60vzQGC NXyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WWWC8OQf; 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 i15-20020ab0374f000000b0079d9dd2bf90si173786uat.72.2023.10.13.07.12.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:12:50 -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=WWWC8OQf; 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 1qrItK-0007Q4-US; Fri, 13 Oct 2023 10:11:50 -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 1qrItH-00077g-LK for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:11:49 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrItF-0004NF-FF for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:11:46 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-9b64b98656bso343934766b.0 for ; Fri, 13 Oct 2023 07:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206302; x=1697811102; 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=tAZvf0/lxzzRafQirPbdSKogeoxVhHxgjxTZIWfzoxQ=; b=WWWC8OQf1JeXx0TgWjohAatB7GEaI6k8JO7QzQLRoLma5lgwQhNxDBRRKNEH083XAG /YwCaCoQMmtQct7kwx1eRgJzjbBOutA0QPWEZSlzkXCXynyHUovMrEGldOXblEN3O2Jq HikSgOUaHnsHO5jav8Ey4QDtwz2hUaco3jmJzN1LQJlsyp4ySjy+d/B+E5IC3rlbwN0w mzEPyDk0e/o3MMobmtcB2sRAvNIBY++fGhV+0l3UM1BYAHc9oLK/QGspGffmsTISU1ek I82PB87uETiJzdP6rF+kq+IgSJeHfAmF66aXVVvuWZuE4vmLFfhdessL4P3zsDoBn77B ddrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206302; x=1697811102; 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=tAZvf0/lxzzRafQirPbdSKogeoxVhHxgjxTZIWfzoxQ=; b=jh/ig+NNom/h/+wEzL3zN60Yb3euFVQHgbW6Tg6X6u9CsGCqpo1CM9KYHijRt7CehF KxNhAcgzS4oupGXmJe+EBew+Nny5Mx23oEVQWs3mRqNM/dF0uBK3SWTs6caGt+SBCbEM ki61rWO5NGCUOeAINuOcp5RBZtC7C173q6xJs4e5dRMJLhMXdTRnBqYOjDUrreZSsKPL irVQ18fftmz3ohNEe7e3Gr+7SRnlMprBXrCZbbPXkAOZOaReYptSVX3ZUOLygzQGrMyx n40/iZJQfxarjcz7fvptAYlRsgdp8KvjSLsCaPQOf9Iq4r7Qqfd/IkLT9g7+2GwrowLZ XByg== X-Gm-Message-State: AOJu0YzxsLbZfL8TtAzdIj6EGnwEG8UopDSitA4kzCxDui2We/NK++wI qjqSm9K6dKRPYaAUY6PZP1nARVMM/pwgafOUDnc= X-Received: by 2002:a17:906:13:b0:9ae:1de:f4fb with SMTP id 19-20020a170906001300b009ae01def4fbmr22360044eja.46.1697206301756; Fri, 13 Oct 2023 07:11:41 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id 17-20020a170906059100b00992f2befcbcsm12380964ejn.180.2023.10.13.07.11.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:11:41 -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?= , Francisco Iglesias Subject: [PATCH v3 1/10] util/fifo8: Allow fifo8_pop_buf() to not populate popped length Date: Fri, 13 Oct 2023 16:11:22 +0200 Message-ID: <20231013141131.1531-2-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::632; envelope-from=philmd@linaro.org; helo=mail-ej1-x632.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=unavailable 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 There might be cases where we know the number of bytes we can pop from the FIFO, or we simply don't care how many bytes is returned. Allow fifo8_pop_buf() to take a NULL numptr. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Francisco Iglesias Reviewed-by: Alex Bennée --- include/qemu/fifo8.h | 10 +++++----- util/fifo8.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index 16be02f361..d0d02bc73d 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -71,7 +71,7 @@ uint8_t fifo8_pop(Fifo8 *fifo); * fifo8_pop_buf: * @fifo: FIFO to pop from * @max: maximum number of bytes to pop - * @num: actual number of returned bytes + * @numptr: pointer filled with number of bytes returned (can be NULL) * * Pop a number of elements from the FIFO up to a maximum of max. The buffer * containing the popped data is returned. This buffer points directly into @@ -82,16 +82,16 @@ uint8_t fifo8_pop(Fifo8 *fifo); * around in the ring buffer; in this case only a contiguous part of the data * is returned. * - * The number of valid bytes returned is populated in *num; will always return - * at least 1 byte. max must not be 0 or greater than the number of bytes in - * the FIFO. + * The number of valid bytes returned is populated in *numptr; will always + * return at least 1 byte. max must not be 0 or greater than the number of + * bytes in the FIFO. * * Clients are responsible for checking the availability of requested data * using fifo8_num_used(). * * Returns: A pointer to popped data. */ -const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *num); +const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); /** * fifo8_reset: diff --git a/util/fifo8.c b/util/fifo8.c index d4d1c135e0..032e985440 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -66,16 +66,20 @@ uint8_t fifo8_pop(Fifo8 *fifo) return ret; } -const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *num) +const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) { uint8_t *ret; + uint32_t num; assert(max > 0 && max <= fifo->num); - *num = MIN(fifo->capacity - fifo->head, max); + num = MIN(fifo->capacity - fifo->head, max); ret = &fifo->data[fifo->head]; - fifo->head += *num; + fifo->head += num; fifo->head %= fifo->capacity; - fifo->num -= *num; + fifo->num -= num; + if (numptr) { + *numptr = num; + } return ret; } From patchwork Fri Oct 13 14:11:23 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: 733223 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489415wrv; Fri, 13 Oct 2023 07:12:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEH3HppGpguR78vXMty/im3a9DRehVKELroWKVlxwNv3lAAMVsXjjTn3FctYuKXceuYfDCQ X-Received: by 2002:a05:6214:5a0d:b0:658:23a5:e062 with SMTP id lu13-20020a0562145a0d00b0065823a5e062mr28627347qvb.31.1697206370188; Fri, 13 Oct 2023 07:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206370; cv=none; d=google.com; s=arc-20160816; b=yIFGBNw4W94dI4pFthJ9AW4AGKA6Hl7ntl5sCGvhz8rCXD5y9o0VhppCUYYN1JkIZ2 0FdPGCFLpTIengHj60pWDvUvwGHTmUdzyGGyjtk4+0zjCnoVEeOM6gVSAIM3bwtf7XtQ InTrvkJxPDMr+QhzUi0YRIoTcFW5OB7Rw6Ja8YwAKzCMPdbFjNd/X7CUcvqqjDYKHnLK WftI3tJKwE9fp88tTMx85uPVzb5cqrKsJ0t4nLlWhFVi3eMI461bZxBkx7hkN2jiUjnT hWTuemvPIXfwx1hJ6o5NfX+8bCGwN+N9ZV/Q2sWphPpgvD7QcG6G4QyyqAAFDgq/z7kL eLQA== 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=V9tZVJmu9kzGvsLFPu4hpPnpsYV8GknZmAK3SQkWufw=; fh=iNlBFRzKWcUVyIm7M2O0DMt8HyVCk33Ec3Usyd6Qlks=; b=zVZcI88mfWj7qXO5CjBxqPjCgWXmmRcvDezdTgKBG/VWRpOLye+8MjpIg6/MDT36eo oeENUY2wLF4/z+qZvgPz33I7hmR95n3wSnO3aOttw2sBMUJEpDwGrL5mQ4tNW04NuFQg jgGqyVKenwpiDawGBXJtwwbEJOATB4pH7JM1aoYOYzI3aOGWvcCXsBj2l+gsf4+W2a7v YytyDmj559tv8Z0OcmUwohEQ4OEObz5/rixfi00SukZWmOmjyO+rZWzKkDoZwBqOgezT uRLUkprIWkG4TG68aArypO1UJH4IkW1ntWZnzim0QUOQ0pXXGRquz3NYtxakai3dofwE g9oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DlScgFwH; 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 pc16-20020a056214489000b0066d138d1bf1si1240539qvb.308.2023.10.13.07.12.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:12:50 -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=DlScgFwH; 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 1qrItN-0007RJ-Mt; Fri, 13 Oct 2023 10:11:53 -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 1qrItM-0007Ql-4g for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:11:52 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrItJ-0004O9-HM for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:11:51 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9a58dbd5daeso356578466b.2 for ; Fri, 13 Oct 2023 07:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206308; x=1697811108; 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=V9tZVJmu9kzGvsLFPu4hpPnpsYV8GknZmAK3SQkWufw=; b=DlScgFwHf4Ru11bhBCZ1tD5Z7Z4vPeb9GTCggYNBTQVDj1s6c7n2xkJfpltupClxrN eXy/KFTaKtFeHhvcSdeBPt3sGjoHMQrd38t96XFkMW1teHX8AiuK48CuD1+6JBK+Xi1a GJbt27VuqaTw17XKdypGzBKhiHMNMeo7H3PAvmyHyCwWxN+/uz0gUopIXx/UXbAo25S/ gftM88Hfddecjo+gh/6+ZQLd4vw/Hn8MLjokOE1WQxzCvIzGxAIed1Usx6569R0gNAJs gTNjvvQLnjy7AAY4SLNcdlOKbXb17o333L0DnzJVqezzYhjEP4nynuC7gPLBUPSdbRUH yh7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206308; x=1697811108; 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=V9tZVJmu9kzGvsLFPu4hpPnpsYV8GknZmAK3SQkWufw=; b=tPlD4X0eOxlKUcXl/Kx+HfkSotQgvgjzg61xPV1HNtDXZi9Q3W6q3WV5ptjMwfJZpW wLLMpCOec6fxJympB80nS8cpAEP4kshyi/ol/3iOUdp/0df9MJ/ASLOMwMQ5nIBWbwEU iQvBajnMpBU6txDSxvpwJvN4JbChkwsxsFlZ7nxJyPVbAVgDYgQq9gaV9ZhMdTZks6eE qofiHTEL3V6ds/rSCU/TKeMOf1RFv2RyE6+QnrCcMgjGjpRoUmPVIFVY0zE4quuxjVBW F//5tpzO51gRZLUDiCoeX23VnrFfuL4a74E1oINOkd6WKu3AeyepLbl4q9ipOiOuwaEt b0Eg== X-Gm-Message-State: AOJu0Yxsnn1+wvDBMZ6AMLGFFISX7g1zx9pWrGo6CRCnkcJ9EO2LhD25 y8xu/KtshNBy4YE+NuHlOuqzn8HJiS8citG55+A= X-Received: by 2002:a17:907:2e19:b0:9b2:c2a9:357a with SMTP id ig25-20020a1709072e1900b009b2c2a9357amr23260747ejc.68.1697206308015; Fri, 13 Oct 2023 07:11:48 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id m14-20020a1709066d0e00b00991d54db2acsm12404171ejr.44.2023.10.13.07.11.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:11:47 -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?= , Francisco Iglesias Subject: [PATCH v3 2/10] util/fifo8: Introduce fifo8_peek_buf() Date: Fri, 13 Oct 2023 16:11:23 +0200 Message-ID: <20231013141131.1531-3-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::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.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=unavailable 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 To be able to peek at FIFO content without popping it, introduce the fifo8_peek_buf() method by factoring common content from fifo8_pop_buf(). Reviewed-by: Francisco Iglesias Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- include/qemu/fifo8.h | 27 +++++++++++++++++++++++++++ util/fifo8.c | 22 ++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index d0d02bc73d..c6295c6ff0 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -93,6 +93,33 @@ uint8_t fifo8_pop(Fifo8 *fifo); */ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); +/** + * fifo8_peek_buf: read upto max bytes from the fifo + * @fifo: FIFO to read from + * @max: maximum number of bytes to peek + * @numptr: pointer filled with number of bytes returned (can be NULL) + * + * Peek into a number of elements from the FIFO up to a maximum of max. + * The buffer containing the data peeked into is returned. This buffer points + * directly into the FIFO backing store. Since data is invalidated once any + * of the fifo8_* APIs are called on the FIFO, it is the caller responsibility + * to access it before doing further API calls. + * + * The function may return fewer bytes than requested when the data wraps + * around in the ring buffer; in this case only a contiguous part of the data + * is returned. + * + * The number of valid bytes returned is populated in *numptr; will always + * return at least 1 byte. max must not be 0 or greater than the number of + * bytes in the FIFO. + * + * Clients are responsible for checking the availability of requested data + * using fifo8_num_used(). + * + * Returns: A pointer to peekable data. + */ +const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); + /** * fifo8_reset: * @fifo: FIFO to reset diff --git a/util/fifo8.c b/util/fifo8.c index 032e985440..e12477843e 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -66,7 +66,8 @@ uint8_t fifo8_pop(Fifo8 *fifo) return ret; } -const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) +static const uint8_t *fifo8_peekpop_buf(Fifo8 *fifo, uint32_t max, + uint32_t *numptr, bool do_pop) { uint8_t *ret; uint32_t num; @@ -74,15 +75,28 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) assert(max > 0 && max <= fifo->num); num = MIN(fifo->capacity - fifo->head, max); ret = &fifo->data[fifo->head]; - fifo->head += num; - fifo->head %= fifo->capacity; - fifo->num -= num; + + if (do_pop) { + fifo->head += num; + fifo->head %= fifo->capacity; + fifo->num -= num; + } if (numptr) { *numptr = num; } return ret; } +const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) +{ + return fifo8_peekpop_buf(fifo, max, numptr, false); +} + +const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr) +{ + return fifo8_peekpop_buf(fifo, max, numptr, true); +} + void fifo8_reset(Fifo8 *fifo) { fifo->num = 0; From patchwork Fri Oct 13 14:11:24 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: 733230 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489990wrv; Fri, 13 Oct 2023 07:13:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYCbku2ZMcjZ9zpzOrSw7FqrC++6cfadcEF+18n9j42V4lmAoeisJWijB7UPNOX/3fP4Vt X-Received: by 2002:a05:6808:1287:b0:3a7:2690:94e0 with SMTP id a7-20020a056808128700b003a7269094e0mr38989384oiw.4.1697206432332; Fri, 13 Oct 2023 07:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206432; cv=none; d=google.com; s=arc-20160816; b=TOEotaFnQGXswivNaDXGJvDIhTQxT2YL1OMIeYikfSI6wqQEQVDh3Cx6cyaXkq2ucQ Wt3loAOZIe8ZsKr1fXtEgr7U/UiGfQQzwVoeVJdoxYt9HuOhSH4Be9JGqQ0Z/l8YQuNc ZW+NQvKh7qfqriJhocqHvb2Yf9092UGFGZ6Gg4oyFoKdABr+AFE5kRiiecTgXZYoQg5N KbRhSnJ4aoiy6LPWDhmwBhc5cHHC5eebE8FD2F+iEGzIbTDSpwmgB3SODk9EvOEe/RAq t2ixpen+caWxXJXlXVQQZabFnLuytnfQMEvpTKVVUHW4Qej8ig+eABkpyvjBbZ/Wg/6w fP4g== 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=mP8e7F+MNf59pa1iU6FTfmv7Sb18zKeyajADdz6BZOc=; fh=MusjSs7gXCZ/MKYOlww+3pkKR+FOAC+Wy5x6PlCIutc=; b=GlEKrWZHcVpQ/Jt+UG3ZqmczNXkNA/VGfEOWV42a9nwC/dcIaZup1k0Ks7gPk6cvCq o6u+fQBbPxrlpOSTDJf2duAi3Y3lY17DRH/eKianwqYoXi3ZKQptGp3uu9xLqvSGghgP yew6o2VFtqGoFOcDXhs3b8uwVTlO4Qtlq9GKmkpq5OhwedqVKSX1yCjSWBKGuz14fV2P lFDjQLHV2GYyPCKL8zse2yNvzAlzT1dl6V5yCeeBhdp7onCkhbT2kb6DTYQLGjEwQGyv srO5fcuAA7OrQK4KSqyZQPz8Bj8Vuy+43Qn92Ag5kvnEUAsZPWZVIpudeaC2NwfTyiK4 bMjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b3IAmPpA; 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 l10-20020a05622a174a00b004055a48136fsi1290209qtk.129.2023.10.13.07.13.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:13:52 -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=b3IAmPpA; 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 1qrItT-0007a4-CH; Fri, 13 Oct 2023 10:11:59 -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 1qrItR-0007ZE-Kn for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:11:57 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrItQ-0004QM-1d for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:11:57 -0400 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-53d82bea507so3767421a12.2 for ; Fri, 13 Oct 2023 07:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206314; x=1697811114; 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=mP8e7F+MNf59pa1iU6FTfmv7Sb18zKeyajADdz6BZOc=; b=b3IAmPpAJi5ExYA87/gFCN2PyWuhZLwOoYAKoEkgbr5RtOhpVBptt9ox2Id3DdF+BU nAg+QQZCGqpmkgvXe2zRr/TzbILGRWOsjCbsSDle9LKO0lw3Fgz7KQVnyiUGzEK643+O IqwnR6pU/6eE+TgBK6Ox1oPG1tPAaseC+cTGKhfA4KMFg9GEaeMXRU5ARB90PyabyDtu PwqUmNc0znl4RCqz9PsbYm/kP060uw9QMoE34NNPmi+YmLPg4BmUW6D0IV8f5xm5XTLd rtX6iRUCxUA49ElGXD3PsEBx7BvbjyTQA9E4jbi+sUBxPzwpT054dIII3jn5oxALQCNS tACQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206314; x=1697811114; 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=mP8e7F+MNf59pa1iU6FTfmv7Sb18zKeyajADdz6BZOc=; b=g+J4JdgCR4y3hVErcPkK1hvibgOIVqHnCHwgxthjSe20WDmfbzqbttiDx3LaesIFl8 Nh8aoTiCF7/j/bsaScVXNbFe20dNGtLICBLHUTzdpBaYuafrxQGvpn8DXfSVuFB7lWW+ 280N6zh9LcNBRv5sTOE4hOnzbc52gyAQeCTKJ819YKyFO44OCjR8Kwtu4duomvs199OE 8yOVdiHVN31T0tcFvHYx0i33LnI758i4aWh4RsqSQW0l0vthWHDjQgFvEMxsj/ChtYfs FpZ85Am1L7kDgsZtEdOQ44gS+jDfmpHQ47+JfbmpA3xFZ1iwu6jTajTf22oKk6DY0+RA t6lg== X-Gm-Message-State: AOJu0YzOf503Gb5l7nLUa/h5ecekBasr4VIJV9uxfyGO+PHIgI24VzHi 9QpG4i43CtgPOmDEH+5jTVwtBaAsfV7V4hL5K3Q= X-Received: by 2002:a50:c047:0:b0:53e:3b8f:8ce1 with SMTP id u7-20020a50c047000000b0053e3b8f8ce1mr2139072edd.23.1697206314358; Fri, 13 Oct 2023 07:11:54 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id c5-20020a50f605000000b0053dd798e38asm3529569edn.69.2023.10.13.07.11.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:11:53 -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?= , Richard Henderson Subject: [PATCH v3 3/10] hw/char/pl011: Split RX/TX path of pl011_reset_fifo() Date: Fri, 13 Oct 2023 16:11:24 +0200 Message-ID: <20231013141131.1531-4-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::52c; envelope-from=philmd@linaro.org; helo=mail-ed1-x52c.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=unavailable 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 To be able to reset the RX or TX FIFO separately, split pl011_reset_fifo() in two. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- hw/char/pl011.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 58edeb9ddb..1f07c7b021 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -132,14 +132,21 @@ static inline unsigned pl011_get_fifo_depth(PL011State *s) return pl011_is_fifo_enabled(s) ? PL011_FIFO_DEPTH : 1; } -static inline void pl011_reset_fifo(PL011State *s) +static inline void pl011_reset_rx_fifo(PL011State *s) { s->read_count = 0; s->read_pos = 0; /* Reset FIFO flags */ - s->flags &= ~(PL011_FLAG_RXFF | PL011_FLAG_TXFF); - s->flags |= PL011_FLAG_RXFE | PL011_FLAG_TXFE; + s->flags &= ~PL011_FLAG_RXFF; + s->flags |= PL011_FLAG_RXFE; +} + +static inline void pl011_reset_tx_fifo(PL011State *s) +{ + /* Reset FIFO flags */ + s->flags &= ~PL011_FLAG_TXFF; + s->flags |= PL011_FLAG_TXFE; } static uint64_t pl011_read(void *opaque, hwaddr offset, @@ -289,7 +296,8 @@ static void pl011_write(void *opaque, hwaddr offset, case 11: /* UARTLCR_H */ /* Reset the FIFO state on FIFO enable or disable */ if ((s->lcr ^ value) & LCR_FEN) { - pl011_reset_fifo(s); + pl011_reset_rx_fifo(s); + pl011_reset_tx_fifo(s); } if ((s->lcr ^ value) & LCR_BRK) { int break_enable = value & LCR_BRK; @@ -506,7 +514,8 @@ static void pl011_reset(DeviceState *dev) s->ifl = 0x12; s->cr = 0x300; s->flags = 0; - pl011_reset_fifo(s); + pl011_reset_rx_fifo(s); + pl011_reset_tx_fifo(s); } static void pl011_class_init(ObjectClass *oc, void *data) From patchwork Fri Oct 13 14:11:25 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: 733231 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1490123wrv; Fri, 13 Oct 2023 07:14:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIRzLj71lNCnB4nGplyJkSMu1eGtCjGA6SMHu7WRc4PkeyGLaaEp0SvBGeWnc6ZHiMnnI5 X-Received: by 2002:a05:620a:40c9:b0:772:63e5:5ab8 with SMTP id g9-20020a05620a40c900b0077263e55ab8mr32213608qko.3.1697206446196; Fri, 13 Oct 2023 07:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206446; cv=none; d=google.com; s=arc-20160816; b=vkpU9OIcx9Oa7UOn/aiQJ6XHeWXacbQsJ2HN/ItBgCGtD4KCHQjQiodk8qEG2Yfi2q JZtUhgfm0BexT9Sf8tg61Pwl3S1gChzEkXtljOtFBK22UlKh4y1sYPD0lkfTh8/Ppwcz SRw2omY+cWHq46Ff6+chpSv1JuJjXxuRiDMwUTqA5l1juf6aR09lzujV+fR7bRYXqOd9 j6BsdRZz9I+R6Ycg+G13xgCKueDRosxDjlZnFo3kMNv/sjro4c4t8vdGBhMc/OjT8gu1 xW/s6u8+3bnOXQPuZV4Ex8iHRPTpF+1Fdmcny1XJv3gwvaQhJw6GZLayTh00NnqLikIP kEWw== 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=4RcEaeq0Z+56TpsJGBFP08HsnS3amqPkJQB4mf707C8=; fh=rgPM1QcSOyRuPluCdnsNd8knie+1OCUx2q8ta7MpVFI=; b=pnfVcgbnXcJDdSHagggLSZqZ7WsOl+W6g0C3DB2tqer8ynG42W2nGs7c1W6BbY8Ghx GkVH8rQ+1yD8QSxMdGCfJYQ23pJkbBkWrm7w5GWz2lIRH8QZ5oOhXS6ZIvF8ZFURp2Cx q78BQypCLyg6uY3jOU4DovHl2vkGiuNCw8MLtGzjdg3F6wKPbpOyTxjuB9ZVTN9MQtt2 LOCLZUK7tjLMznaheLfvJqyNJT6Wzvyh1R3NubKwYHpyvVIi0TTdQ4vAh+A83KcZZu+x BvEH67lbgIlvPFlMg2he4SvGRylyY4FFXlczSSUmMu5D4NvG+X2ONDCij6mu0rB6C+8f IBXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hsIVvSeI; 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 b26-20020a05620a089a00b0077582e44a28si1199922qka.620.2023.10.13.07.14.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:14:06 -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=hsIVvSeI; 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 1qrItd-00084I-BD; Fri, 13 Oct 2023 10:12:09 -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 1qrItb-0007zM-9l for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:07 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrItZ-0004WI-5g for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:07 -0400 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-53e08b60febso3124543a12.1 for ; Fri, 13 Oct 2023 07:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206323; x=1697811123; 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=4RcEaeq0Z+56TpsJGBFP08HsnS3amqPkJQB4mf707C8=; b=hsIVvSeI6N0lVpK5iRJ5DXPNg0Tw8ECT7O0q2XWV48rx5cF2KVF5xNYGHXhS73rnZA 5gyKjVcWwkbz/rUh38KPDF/5m+5wrekrY+D7S4JdX/5GyBC9Q5MgeZ6AqT46lTRX9hu+ ruRiXc0gzY9Mckn7sX3+5eA0xLz4uUZyaR/yF85AQYqj3UJV2iXjnpEifK3IeZ1McSad 8+q1WdELEEqkJrQn+TU16+M4jEOZKGkiDgabPJpkcFf8J7WIrfDSlF3HVWpYcTD/Ori9 fthUgyNXIfcPsISGBJ8Kj3pAUVFObVzcWivcr8fbWN66w+lIaE0B9EUFuvSwJeE3HBBn bPTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206323; x=1697811123; 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=4RcEaeq0Z+56TpsJGBFP08HsnS3amqPkJQB4mf707C8=; b=sEDxurJZeVne91baQExCDSJfkO/BekUJP1JiFwbDSu59O4cC+x86SCS9EJJG4CQifL Iov68BMrTRx5qiy03WY2Mx80EE/g3rLLAZQEUYzbpU3TLN5yiqemu48R9Kj2YByYVYdZ ipt4HiE1495MIh7vVpK65HNnPoASlXqlLFbqc+kJP3eEV9cVYvg8spTvP9Wxb1ABAut1 VslBtQWQ/zBDtaQDnGIbkBzt1orD1K2qz2yr9r1nu+gxZy/i8kC8DNNfy+ZoX1wa24jW pGv/WeriJcDEBbWgwASFak8Nvq26+F5rvPaWjdBJzyf7cz8MiYUOScqgVOXV/NzJtW1u jbUg== X-Gm-Message-State: AOJu0YzPGdMUYFT/nuIqnlt8OHI+ZqkgMJtVeoeylXCS0pl0HuRvZe3m TEkQE1Wwww5DKyitlCw9yxMxzZHikFtEQjQj60E= X-Received: by 2002:a50:c048:0:b0:53e:4dc6:a2e8 with SMTP id u8-20020a50c048000000b0053e4dc6a2e8mr1221176edd.19.1697206323563; Fri, 13 Oct 2023 07:12:03 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id c26-20020a056402101a00b00533e915923asm11479677edu.49.2023.10.13.07.12.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:12:03 -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 4/10] hw/char/pl011: Extract pl011_write_txdata() from pl011_write() Date: Fri, 13 Oct 2023 16:11:25 +0200 Message-ID: <20231013141131.1531-5-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::52e; envelope-from=philmd@linaro.org; helo=mail-ed1-x52e.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=unavailable 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 When implementing FIFO, this code will become more complex. Start by factoring it out to a new pl011_write_txdata() function. No functional change intended. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- hw/char/pl011.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 1f07c7b021..1cb9015ea2 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -149,6 +149,17 @@ static inline void pl011_reset_tx_fifo(PL011State *s) s->flags |= PL011_FLAG_TXFE; } +static void pl011_write_txdata(PL011State *s, uint8_t data) +{ + /* ??? Check if transmitter is enabled. */ + + /* XXX this blocks entire thread. Rewrite to use + * qemu_chr_fe_write and background I/O callbacks */ + qemu_chr_fe_write_all(&s->chr, &data, 1); + s->int_level |= INT_TX; + pl011_update(s); +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { @@ -262,19 +273,13 @@ static void pl011_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { PL011State *s = (PL011State *)opaque; - unsigned char ch; trace_pl011_write(offset, value, pl011_regname(offset)); switch (offset >> 2) { case 0: /* UARTDR */ - /* ??? Check if transmitter is enabled. */ - ch = value; - /* XXX this blocks entire thread. Rewrite to use - * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&s->chr, &ch, 1); - s->int_level |= INT_TX; - pl011_update(s); + s->readbuff = value; + pl011_write_txdata(s, value); break; case 1: /* UARTRSR/UARTECR */ s->rsr = 0; From patchwork Fri Oct 13 14:11:26 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: 733225 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489852wrv; Fri, 13 Oct 2023 07:13:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFhC+hyYocQhYoSteWMRSOr2UmAkYzAYYO5UvTKgL80umyTBx/+h66Q/jgRAM2oCHIffQ5 X-Received: by 2002:a05:622a:105:b0:418:14ee:ac55 with SMTP id u5-20020a05622a010500b0041814eeac55mr26309061qtw.25.1697206418622; Fri, 13 Oct 2023 07:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206418; cv=none; d=google.com; s=arc-20160816; b=BsomrTNdTBR0KYwCyvf3YdG0Q287J1mgY9vIef5ttAKHR0YcFqh+9pUFQwtcoOeLkW yBEysVnnkSngaU8S3ad4hOb8gBqA3k7WPEO+CS7OIXDLCp4qqWsNx1bJv1Glbi0YTBWQ 2Cz4gaFgungh8D5uszvxuc6uFDtP8wBszkVOd+u9vDdULRrb3GVFUphPQfilAl26EJ6y XUa/3zho1f7L97mwei3Rz0B+N9u+ccARV9ku3U5+sNWbM9qd2HpmJ8rwSXhabufFKa9m xzfHjmzlzcQ2hPTLRmMSuaLcn4kBja0+VNZDc6blhp7YWllFYtMSkTLY/samOzaj7aV4 tIiA== 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=5g0UHLmrzpBXUAHJbDdjYHH8dsW06tpS080WDx/2FO0=; fh=MusjSs7gXCZ/MKYOlww+3pkKR+FOAC+Wy5x6PlCIutc=; b=Iye3KTJBIXVdF6vaWBVkhy6Dp2FP0ktGvHRi7QhpvoyAx7WYLbT9PCRuzaov/ll7ZC 0c1UQi7RijwTZy440NNSXPC+6YI1ObVlumqTR/puovi/Dd6WvztUmvyPEobV/XNZGAZg 1UqN0wkK9Ty3YBvlxKOfaGh0z3dHlJbWlykc7ugmZypyRYkJbm8joy2Yw+vYDw++hbVQ puAtfgoA6fkdjFQXHDFiY5L1NLVPRIXcxZc++ij0R6U5CCGIrPJNkfP8WCqO/DKLJ5oq ru2hjyTkDQTjhzpp5Ns6ghsz2ydHEVqcsf6km0bJK7TaIy5p9onddGcuUpgDzn3YsdLq oVxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LbR4l6wh; 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 o7-20020a05622a044700b0041805d0969bsi1245996qtx.210.2023.10.13.07.13.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:13:38 -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=LbR4l6wh; 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 1qrItl-0000CI-F8; Fri, 13 Oct 2023 10:12:17 -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 1qrIti-0008JR-LE for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:15 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrIth-0004Y0-30 for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:14 -0400 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-533d31a8523so3764885a12.1 for ; Fri, 13 Oct 2023 07:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206331; x=1697811131; 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=5g0UHLmrzpBXUAHJbDdjYHH8dsW06tpS080WDx/2FO0=; b=LbR4l6wh4PeuIsGyPnZOBHs/BTmVrry41/p4vuPe+zq5cnbuno+NLxKAo1rvpdhFrR bNsGlEf7ptEkDoMqCmYO2PWR4cFSC4/R9xzz+hnjOV7p1Dm1Hox9nLiuiogsRe5kjaYo i1IZd9yViATOLSwQdx519DHWmamyONFlI1n+tyn5ZtGEvHrjHzxH9oORk++EexRKLPcm Q+3QSoi86bkEa2uNcfKMSBFf0o/TBV6Gfz3K6OhNU8Vxie0IHuCusmcwb3ZtbY4qEYtk Xa52P2mbxd2is6lJ+jD2G+m8RbYP7UlRk9EdwavW9vV6I6miq2Dd1fXia8C2bEB9FXWa lgjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206331; x=1697811131; 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=5g0UHLmrzpBXUAHJbDdjYHH8dsW06tpS080WDx/2FO0=; b=vt1ddHcZI/C3tLeXswGYQzNN25lTEQU5cr1vkm99W0CCypR0rHDA5DUUjLyMRvR/wF ztlHOLdl8N4bfuL60ZgJTEvsDoyFLZvPS2CchCZkxPO4Xfvp+bosr4PpA/znWbn8dj+g dnx00/66ntHTF8qZKxKGR0fqQYwD9Fur6m3y3gkZ8O8EabWOPdhXv3BWU2P3/lBdVqaa 0uCXrHQW4sNtbGBUvbO7VhxhE/NDWI02PbBqOPbuW/h83UyDApF8okw7IuUq9sday18G G0SevxlwvexkSBKYLnHK8VVix3YfgfbWnMAI8Ds3bteCmvGUdaVEXgu9B9oHKqu9ZO/Y dmRw== X-Gm-Message-State: AOJu0YzLdPHUhlCGdIKUFSqhExN0G3ftnqAh69QbDyI3haakBQ0MMi23 XgpOPbr0W01vYGWznZjDk3crXHcdRSawkm5WT6Q= X-Received: by 2002:a17:907:a0c7:b0:9ba:33ef:fe51 with SMTP id hw7-20020a170907a0c700b009ba33effe51mr9836619ejc.11.1697206331196; Fri, 13 Oct 2023 07:12:11 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id jw5-20020a170906e94500b009ae6a6451fdsm12419392ejb.35.2023.10.13.07.12.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:12:10 -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?= , Richard Henderson Subject: [PATCH v3 5/10] hw/char/pl011: Extract pl011_read_rxdata() from pl011_read() Date: Fri, 13 Oct 2023 16:11:26 +0200 Message-ID: <20231013141131.1531-6-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::534; envelope-from=philmd@linaro.org; helo=mail-ed1-x534.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 To keep MemoryRegionOps read/write handlers with similar logic, factor pl011_read_txdata() out of pl011_read(), similar to what the previous commit did to pl011_write(). No functional change intended. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- hw/char/pl011.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 1cb9015ea2..30309337b1 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -160,31 +160,38 @@ static void pl011_write_txdata(PL011State *s, uint8_t data) pl011_update(s); } +static uint32_t pl011_read_rxdata(PL011State *s) +{ + uint32_t c; + + s->flags &= ~PL011_FLAG_RXFF; + c = s->read_fifo[s->read_pos]; + if (s->read_count > 0) { + s->read_count--; + s->read_pos = (s->read_pos + 1) & (pl011_get_fifo_depth(s) - 1); + } + if (s->read_count == 0) { + s->flags |= PL011_FLAG_RXFE; + } + if (s->read_count == s->read_trigger - 1) { + s->int_level &= ~ INT_RX; + } + trace_pl011_read_fifo(s->read_count); + s->rsr = c >> 8; + pl011_update(s); + qemu_chr_fe_accept_input(&s->chr); + return c; +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { PL011State *s = (PL011State *)opaque; - uint32_t c; uint64_t r; switch (offset >> 2) { case 0: /* UARTDR */ - s->flags &= ~PL011_FLAG_RXFF; - c = s->read_fifo[s->read_pos]; - if (s->read_count > 0) { - s->read_count--; - s->read_pos = (s->read_pos + 1) & (pl011_get_fifo_depth(s) - 1); - } - if (s->read_count == 0) { - s->flags |= PL011_FLAG_RXFE; - } - if (s->read_count == s->read_trigger - 1) - s->int_level &= ~ INT_RX; - trace_pl011_read_fifo(s->read_count); - s->rsr = c >> 8; - pl011_update(s); - qemu_chr_fe_accept_input(&s->chr); - r = c; + r = pl011_read_rxdata(s); break; case 1: /* UARTRSR */ r = s->rsr; From patchwork Fri Oct 13 14:11:27 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: 733222 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489410wrv; Fri, 13 Oct 2023 07:12:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEl/7UZbQfHh5SjleXO2tX8fiaPFYRi5ojERRfYNC6c7VMD6JiepffvNVaMvvGx4SvlIbE0 X-Received: by 2002:a05:620a:4046:b0:775:7fdc:42ac with SMTP id i6-20020a05620a404600b007757fdc42acmr32653148qko.7.1697206369842; Fri, 13 Oct 2023 07:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206369; cv=none; d=google.com; s=arc-20160816; b=DxYxVkQEJ0NL/lqccfZilpkoPXOSIV/EdOsDODi19VI0mBpgP7prXLsoQg4oKLkv+H D5cb1VQ9Et3yMEHPu0Zb/nPnKghu9hUfPxA+cqCJARVOluYF4zo9CBgnuJ8bhYrDjNf6 3tNXiqaOvGWE9CruSso4ENGD2i71zWO/N8P3B9+RI6hmaw9bMEpP9m6tr/IwusOElBDj 2vtuo1M6z8pwRLubGvXO5W0VwhVXcEbXTqfk2rzM4w28ZhlDLkF0vWMxwizwZuudR604 58CUitlW8ydT0EwBm5xzlkDC32+UywRqG6ZEkPXqoQ6xMg62PrJitS4Pc3uXzb5jAyrY H/xA== 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=TEZCH3t9203jXT8Ca8hiOxWdvxGRGRt32KSzy33l+nU=; fh=MusjSs7gXCZ/MKYOlww+3pkKR+FOAC+Wy5x6PlCIutc=; b=iCZM5ZraqjEA1pSe1j/ibU9bHoeIxxZa/QYtGzbVLeigoBRT8RH0R6D4tIfBOUU5fQ wPD8fW7JxmLeU68Q4jtdZNMTsIqrvn9D3ldDdzkXp4I8S3t5u3homD2bfaZckADSpBAx cNjwsJvxQuVyiJzjWFjvX0xutKZyJBlzCOTBG6sl1N+jZpKrGn8sHicZVTU1NCSUtO7a axWhIRjViFfB3I6z6C2/nDelpEZ3bPxqfDJXn2ZtaREP83Ja8cIhVdUy7tyt1L+EY7im 93rMAdNIHzDFsYRAlnPThJ0r2i+7iixUEtKighJj8EI5KgT07OmEcjrvVg57Am12V67x U5QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lxz7tNbJ; 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 c6-20020a05620a268600b0076eeed38118si1269798qkp.131.2023.10.13.07.12.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:12:49 -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=Lxz7tNbJ; 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 1qrItr-0000Rd-I0; Fri, 13 Oct 2023 10:12:23 -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 1qrIto-0000Na-D4 for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:20 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrItm-0004Z1-RZ for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:20 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5347e657a11so3489425a12.2 for ; Fri, 13 Oct 2023 07:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206337; x=1697811137; 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=TEZCH3t9203jXT8Ca8hiOxWdvxGRGRt32KSzy33l+nU=; b=Lxz7tNbJotN8Tfrk8q0pfRt/TV0V1hzMBHT+rLxCCnVsrbcgnI68UefH3MGJeljeFs RSaYa5MLJd59AQJIHyxVmXLO7fk2dcvYWVv55XFvwLg8UnaGYOk8xoJ0BKu91cpwzLpC 3OWlJj5i4NefZ79i/M47B2Jhn7mlM5VXkivJhVPaUOGiARv4Ff3EMPv/cUhz0fy8JREO 1Le/KNBcDh82kZ2PoMn022NbFx6D1O2F4+MWK9GONpCqqBjs12E9TdYfrDD0wbVv9Wxm te780/MtOx1HhTMi/TPj1qBwOszgEatFsoA8aiO99DWw6yBnr4oOZJEDS+PZvS3UO1fp Q+qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206337; x=1697811137; 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=TEZCH3t9203jXT8Ca8hiOxWdvxGRGRt32KSzy33l+nU=; b=iVtzzu0OMADY4iYTWh+9OfYdZMd/1iMOHlum+UoREP7ZWb8FmbZbbv3jDgAwtapwSZ V7gktkKbsqQPZcM9qB1Kys03wUvpliegBXyso05Ov2MXPPx7KjddKEHthL1f3XmSr1uR JWfq8uJwdA9wyOUHHetg7GiD8IVkizyN73PrwB7slokLvgERRHaPVpjmt/EMK6cNH9L7 SJiMjYS0KY4Lt7juKbMcAoDbo3xwOO9A5E6hwmylLRAuvPHqBZ5psr7FbF/K5eTglCIR hRVzhm//ziJZAgSX/PcoDcBjYc6952skZDo9yyqZeOCmi3KROZ0glbd3KtydJwHIll6u z6dA== X-Gm-Message-State: AOJu0YxKbKMd6wLE1jr0029Ff6/VyuvDOr6zyf1HpzJhQaBl2jvxrRAr 7TQH/lgG1joCg/J09nb4kt0SkGXxdSXDVmYgiDk= X-Received: by 2002:a05:6402:35c5:b0:53e:6215:76ee with SMTP id z5-20020a05640235c500b0053e621576eemr229010edc.10.1697206337349; Fri, 13 Oct 2023 07:12:17 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id c25-20020aa7d619000000b0053622a35665sm11366351edr.66.2023.10.13.07.12.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:12:16 -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?= , Richard Henderson Subject: [PATCH v3 6/10] hw/char/pl011: Warn when using disabled transmitter Date: Fri, 13 Oct 2023 16:11:27 +0200 Message-ID: <20231013141131.1531-7-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::533; envelope-from=philmd@linaro.org; helo=mail-ed1-x533.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=unavailable 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 We shouldn't transmit characters when the full UART or its transmitter is disabled. However we don't want to break the possibly incomplete "my first bare metal assembly program"s, so we choose to simply display a warning when this occurs. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- hw/char/pl011.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 30309337b1..9c43cb47bf 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -76,6 +76,10 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define LCR_FEN (1 << 4) #define LCR_BRK (1 << 0) +/* Control Register, UARTCR */ +#define CR_TXE (1 << 8) +#define CR_UARTEN (1 << 0) + static const unsigned char pl011_id_arm[8] = { 0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; static const unsigned char pl011_id_luminary[8] = @@ -151,7 +155,12 @@ static inline void pl011_reset_tx_fifo(PL011State *s) static void pl011_write_txdata(PL011State *s, uint8_t data) { - /* ??? Check if transmitter is enabled. */ + if (!(s->cr & CR_UARTEN)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled UART\n"); + } + if (!(s->cr & CR_TXE)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX UART\n"); + } /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ From patchwork Fri Oct 13 14:11:28 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: 733229 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489987wrv; Fri, 13 Oct 2023 07:13:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+liiJR+xxtxeygxisYtNIsPgUijkeaw7PIMO8u6yyjJfYipx/9bTJcgdl/41Xq+Jd+FcW X-Received: by 2002:ac8:7f49:0:b0:417:b975:6d85 with SMTP id g9-20020ac87f49000000b00417b9756d85mr406278qtk.5.1697206432280; Fri, 13 Oct 2023 07:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206432; cv=none; d=google.com; s=arc-20160816; b=TtQPBCmBr1he88HtLXR4STqGro/OXpUhZutnSnwUoeoCAZKNl1TkrY1xTOYgMwqdZ2 s3plYL4v+wawmo7plBFp/SonXWFq1Dcgev6whuXIjsCRCU+6N2HIRP9uygJ6SdW13uAR nzmSjMV60TdRnuqA+EZBxjiRaQC+RwxPEhNv1ED/lttyS4Mvv58N2rv3WS3vznvNjTqI 8+bBowi3lL2DRMdlHPbtcJboqr7NRjTGzK2EPrSXn010HyfeqChMkSSVz+s7e8v88u04 jP3g6ML5sVhR1Kl2C/XCUVg1ZYR9DJ7icWgn42p4wo2KYUZQ4BbeUuOkeOjXP2sY41bQ M9jw== 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=FHrHAGB/EmMRyrEmXuczDQ4ZEQoq+gXqneExLSOiqGU=; fh=MusjSs7gXCZ/MKYOlww+3pkKR+FOAC+Wy5x6PlCIutc=; b=d/l9/StoJwYKB1PYzeeqFC6yDUihoalKwCx92a9BZ5AztFvL+FWmoqhBitQE0mStdH D+ghF2AUfhXOJikn+softVairpp7B5gKjw5vB4w6AQoo69ESVEztnK4Ah3OwRNeLKxG9 RUFrcjvQxBxrAXIlQTFggX/OLNjEwVamHj2nwBNcZOhcyA0IMk7mVhY/JJ8N/HptvKqI 6x8zy+dkfFUtDQGnMDttYMpTOCi54DrBA05OoBtcGryg/mZBeiUnRnXoTaU4cQOshkx7 KNyjCIp/jLXpKcdgJuqz6ukAbI/B2b0ljfjZYNXpBoAkjE+usGZhZCU4K/hIqZq98zmD XKPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l4LTrDoI; 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 w14-20020ac87e8e000000b00411838ef9d3si1213970qtj.552.2023.10.13.07.13.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:13:52 -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=l4LTrDoI; 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 1qrIu5-0000e4-Bw; Fri, 13 Oct 2023 10:12:37 -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 1qrItu-0000Uo-RH for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:27 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrItt-0004aD-EO for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:26 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-53d8320f0easo3615077a12.3 for ; Fri, 13 Oct 2023 07:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206343; x=1697811143; 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=FHrHAGB/EmMRyrEmXuczDQ4ZEQoq+gXqneExLSOiqGU=; b=l4LTrDoIAZJWVT43yCCbr8T2C1CHBzuzb2SiOp3AyEzBEaeJ42bWEaFTZaSb8eScH7 rt5uFQj3PJwUlK9APa/hOw4slO5UIE+WtgIlDvgbqNWIkvuCmMMBr4qXsSfrgTCAs36c TT1CzS49gZ8CFN3xYAeqUqGQoPhRFX7IxB5uaQQ4UtdStENGf6R/kT4ORkfhcPqiSM0f uyWjIapXEbKFYmLUsLG3ZGQB+4j5V/OV/fURZPR3XjKtLFy15fVgJYJ2FK3FVLlWsyNS yPtB6EPOugQMTp0U+EX8r2aqfmsd992IJT2OujTV6+6UQHIGa08UOwxEUdaSVbO8q44O 5/1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206343; x=1697811143; 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=FHrHAGB/EmMRyrEmXuczDQ4ZEQoq+gXqneExLSOiqGU=; b=YZrPpss1fhffsKCUEpgjzVcEvNS2WGQe7g4sC6ntAXTISfzU+h6d6BSH/0nc8BYIDD qrJlBcpEcN0AUc0L/c7paPHjYZCJW3Tc8bj+JjBXNolvMPKBfOGP5BN1Fh6AAwIiFqrl wN/qqjMTzpcvBc2z3i/6RMujFIsqIzKoV82SCfMyK7Qx+O8fRhFABLYy6OdAtXW1t/Sr 0ShRnxpa2MofHyFve/i+Y6av5du+UbBIqRpb3GvZLMQgZRC6qUM8o9SLZtPuSAJ4YcZf tXCRqbbcuhHLJtYxa9ViXfAkfZMr8IVeZYr/KVPiODsm1thUryUc4fg1Y/ZudZvL5cGQ UXWQ== X-Gm-Message-State: AOJu0Yyl1iwO7x+idL1EYRMC2JgRAnbDfGIDYld/0PD51rmXE1YYRFPj K9HLvTO7k2b9KUmoesL3Mld9ZH3NN3n96fqHNPY= X-Received: by 2002:a50:ef0d:0:b0:522:2782:537 with SMTP id m13-20020a50ef0d000000b0052227820537mr23076679eds.15.1697206343741; Fri, 13 Oct 2023 07:12:23 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id r19-20020a056402035300b00522828d438csm11613766edw.7.2023.10.13.07.12.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:12:23 -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?= , Richard Henderson Subject: [PATCH v3 7/10] hw/char/pl011: Check if receiver is enabled Date: Fri, 13 Oct 2023 16:11:28 +0200 Message-ID: <20231013141131.1531-8-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::532; envelope-from=philmd@linaro.org; helo=mail-ed1-x532.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=unavailable 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 Do not receive characters when UART or receiver are disabled. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- TODO: Understand Richard comment from v2: this doesn't fall under "my first assembly program" because it isn't part of "Hello, World"? --- hw/char/pl011.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 9c43cb47bf..ca931be139 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -77,6 +77,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define LCR_BRK (1 << 0) /* Control Register, UARTCR */ +#define CR_RXE (1 << 9) #define CR_TXE (1 << 8) #define CR_UARTEN (1 << 0) @@ -359,9 +360,11 @@ static void pl011_write(void *opaque, hwaddr offset, static int pl011_can_receive(void *opaque) { PL011State *s = (PL011State *)opaque; - int r; + int r = 0; - r = s->read_count < pl011_get_fifo_depth(s); + if ((s->cr & CR_UARTEN) && (s->cr & CR_RXE)) { + r = s->read_count < pl011_get_fifo_depth(s); + } trace_pl011_can_receive(s->lcr, s->read_count, r); return r; } From patchwork Fri Oct 13 14:11:29 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: 733226 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489873wrv; Fri, 13 Oct 2023 07:13:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0Z7Zakep2HKyP918VopCgzu1eV/1Ds7jhVmjB+L475HTe2epI22vPoALSD0Y+AuKrCwGm X-Received: by 2002:a05:6808:91a:b0:3a1:e7fb:76fc with SMTP id w26-20020a056808091a00b003a1e7fb76fcmr29037246oih.17.1697206420758; Fri, 13 Oct 2023 07:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206420; cv=none; d=google.com; s=arc-20160816; b=zjGBXBZRcWUIkxXoQADte8LdkskTTw0SBxXGzXAFUfBr+bO7sIrG/0WXFXIinr3Xou ehY8VUrMnfLLHY5MZAGZEcmIYTP/WkKrPoNAJD5Ls8q9Oh3XUF2xoAk14KpXPy/lptrb nRFIA069qfbctMen/RWLhOR2TqJNID4Q9ZaNap9qP9hsIKsFHek63ToBfyxG5tFvR0YE aHckqHU3WS51LbTtgUQWUAUW7PYP5FKnbagFFFxoMD1CRxgd+RzVYNFgEV9ZvCq6rNpp PVJCpYg8K8pWJvw9XkQ2xkDwp1CYMWo60zfAAR3ziFShe9boo7gUoaldfa8vMRmG2ziL acSA== 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=iLskZGD/UzWh5WAc5o6F/s/jz7ba3gS2xd/rMg/gdOg=; fh=MusjSs7gXCZ/MKYOlww+3pkKR+FOAC+Wy5x6PlCIutc=; b=yGJQ/9HCCCrahCGMA5HuCZV9E5BOnLztey7ukWfyrwBE06Mtb6VCBOtqHCVgOonJzE 6fxZnY447fnzUQSzHbUqBjLEl9DEqKTQrU+lV7nT4y7PUbpFfsFNtRl6PNW4e1gPTRDZ D3jP0DBeixnKNdIZAwdQpxUFGHBcymOkjOPZB+UQ9M76GUf+snIY/uyD8zjNgnuuPh7J eOql0ldkVN4+y6XEfpZgaKplz0wl0H7XF4s98L9PS6fp5jvXmsmI27CVmBpUreAnhRB6 2bnTbhTFstYwF6Az0pDhXRBNRieQD/irGHQaR733PlC3ekMJoQZigIS/aO+twAS14I3j /EEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="u/HozZJg"; 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 o8-20020a0cecc8000000b0065b231f117dsi1243417qvq.205.2023.10.13.07.13.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:13:40 -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="u/HozZJg"; 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 1qrIuB-00018V-E0; Fri, 13 Oct 2023 10:12:43 -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 1qrIu6-0000sR-4N for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:39 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrIu1-0004cW-8e for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:37 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9b95622c620so379165366b.0 for ; Fri, 13 Oct 2023 07:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206351; x=1697811151; 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=iLskZGD/UzWh5WAc5o6F/s/jz7ba3gS2xd/rMg/gdOg=; b=u/HozZJg5I/TKkCBjweOmbd+Ji5RBc9z7PH4A6+Kvb5kHqHMQCNIAQ1/3WrPUVIH/b ZA6BP4jMYPfCuQqC5NmHE2NnRVdezHww3zymABLazQVSdkYWfze/B1236wNSgyuRSO7A 9sIQhJ/ZTQ43X1kQrxb3t421GzZkXEXLpIOXErRARDgO4ezZfmZ1myBv/BqW6libOVS8 mWi1jiBeV3DBXxCTe9QkbDM6MhAZdewCpxkMsIpvySnZKjeqEZDHUVDf54BkjeV5JE9a BTnNsCPszx+FTZNOAyAEBumuK936wLW/pUGsU1+etTkjucy+x3JdXRCrN4gQro632hsR 6V7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206351; x=1697811151; 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=iLskZGD/UzWh5WAc5o6F/s/jz7ba3gS2xd/rMg/gdOg=; b=RnBWVSoiPgifbHpPoYkQWfrf4LngMWocNLo4UxpxGoJSXPnIPDwKX/9NR8SgEkm9CD 4x3yBEWATw88zPsRrUPzL1nXo+q/EurrQrmwSkdt5MkQFFH+PIoldPWBT70bHQYHWnlf wqq7CBbqQGwHl8vCE8dtI8AnHDLxsloFtXncez+LsCNihLz7A6RY/EZ2E7mMcE1vVHv7 Zwuv/jCZ7fydNXxSw6ZZQhBg5+jKVJQqZY1A0x7uZZSnkx2XAWsbuymIa67OfWdrBDBm aSROgSFzSykmR5tZztZdVsspa4K48JPxGyd71I7EMkkn7zuuqBVFrAJxzxSDavQERhbq fH8g== X-Gm-Message-State: AOJu0YyS2mHLQ9thhaiC/I27dP5iFguijXqSnoG4yMV8VsiBmB5ACFoQ i8/+9qu4ME5Ak0v47CxUoLladWqNpDVVaWSEDqk= X-Received: by 2002:a17:906:2254:b0:9b9:4509:d575 with SMTP id 20-20020a170906225400b009b94509d575mr24930528ejr.2.1697206351113; Fri, 13 Oct 2023 07:12:31 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id lr5-20020a170906fb8500b009adcb6c0f0esm12454048ejb.193.2023.10.13.07.12.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:12:30 -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?= , Richard Henderson Subject: [PATCH v3 8/10] hw/char/pl011: Rename RX FIFO methods Date: Fri, 13 Oct 2023 16:11:29 +0200 Message-ID: <20231013141131.1531-9-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::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.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, T_SPF_TEMPERROR=0.01 autolearn=unavailable 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 preparation of having a TX FIFO, rename the RX FIFO methods. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- hw/char/pl011.c | 10 +++++----- hw/char/trace-events | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index ca931be139..727decd428 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -369,7 +369,7 @@ static int pl011_can_receive(void *opaque) return r; } -static void pl011_put_fifo(void *opaque, uint32_t value) +static void pl011_fifo_rx_put(void *opaque, uint32_t value) { PL011State *s = (PL011State *)opaque; int slot; @@ -380,9 +380,9 @@ static void pl011_put_fifo(void *opaque, uint32_t value) s->read_fifo[slot] = value; s->read_count++; s->flags &= ~PL011_FLAG_RXFE; - trace_pl011_put_fifo(value, s->read_count); + trace_pl011_fifo_rx_put(value, s->read_count); if (s->read_count == pipe_depth) { - trace_pl011_put_fifo_full(); + trace_pl011_fifo_rx_full(); s->flags |= PL011_FLAG_RXFF; } if (s->read_count == s->read_trigger) { @@ -393,13 +393,13 @@ static void pl011_put_fifo(void *opaque, uint32_t value) static void pl011_receive(void *opaque, const uint8_t *buf, int size) { - pl011_put_fifo(opaque, *buf); + pl011_fifo_rx_put(opaque, *buf); } static void pl011_event(void *opaque, QEMUChrEvent event) { if (event == CHR_EVENT_BREAK) { - pl011_put_fifo(opaque, DR_BE); + pl011_fifo_rx_put(opaque, DR_BE); } } diff --git a/hw/char/trace-events b/hw/char/trace-events index babf4d35ea..9fd40e3aae 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -58,8 +58,8 @@ pl011_read(uint32_t addr, uint32_t value, const char *regname) "addr 0x%03x valu pl011_read_fifo(int read_count) "FIFO read, read_count now %d" pl011_write(uint32_t addr, uint32_t value, const char *regname) "addr 0x%03x value 0x%08x reg %s" pl011_can_receive(uint32_t lcr, int read_count, int r) "LCR 0x%08x read_count %d returning %d" -pl011_put_fifo(uint32_t c, int read_count) "new char 0x%x read_count now %d" -pl011_put_fifo_full(void) "FIFO now full, RXFF set" +pl011_fifo_rx_put(uint32_t c, int read_count) "new char 0x%02x read_count now %d" +pl011_fifo_rx_full(void) "RX FIFO now full, RXFF set" pl011_baudrate_change(unsigned int baudrate, uint64_t clock, uint32_t ibrd, uint32_t fbrd) "new baudrate %u (clk: %" PRIu64 "hz, ibrd: %" PRIu32 ", fbrd: %" PRIu32 ")" # cmsdk-apb-uart.c 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, };