From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769744; cv=none; d=zohomail.com; s=zohoarc; b=ifH3Q6FHg5nrHIcDklC/KRyVXUdJWbKdMzA+HlhDMCprRwBpbU0tCHrUCZDO4vBaASxV8aa2XtNCZSyoRGsUJEIPsCBTFn8ZTFTODTSiU1EUt/oqEdUv97Rrgbeja2ObSOlErumgmMIACkXgHcyTlLUBnKvId7xu2z0gvD4rgqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769744; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=glXXfgsRplQFxPF2FEdJ5asogB54RtufXxooiyPAR7A=; b=Yda1oQ0FOJiSpdfs7Hfb07witm+T9rWXtcExQ8KiYqRl/ojjFwj5+VOfSSgn7WfexBvhSwEjOs+swH2AmANlooLfcpYfMd3d6PcRXtanGJIzB1WxBJw7sFkxxIdd0P2uCvoTXS7ejakYlROBpfscthftHL1HdxFXoWBNN7AQ8j0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769744691448.97823496526894; Mon, 22 May 2023 08:35:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Wb-0007VA-6h; Mon, 22 May 2023 11:32:41 -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 1q17Vr-0007Mr-TM for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:03 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17Vq-0001Ju-BJ for qemu-devel@nongnu.org; Mon, 22 May 2023 11:31:55 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f603e0edddso10172285e9.1 for ; Mon, 22 May 2023 08:31:53 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id f15-20020a7bcd0f000000b003f0aefcc457sm11845054wmj.45.2023.05.22.08.31.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:31:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769513; x=1687361513; 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=glXXfgsRplQFxPF2FEdJ5asogB54RtufXxooiyPAR7A=; b=N0ERuWsLU6iXzOmNBKOlOpg4dVkGIjpNumO8nlBuo/g3l/21CGfmxDKG1N7GJHIODC xCjmdmKdHuOGQoAkqrhwNkOM6uT88izAuP3FNvvfanq3672NomTXUdILkhUxwC0a/sp9 pn9WJZchyTXwhmGPVJMVCOhemcgIzwWs6X8tVscCiw12/7/1QLhGqWtV/rlzRdmkZsDL K54krVxaFq8L9I28MWlWWq+S0m9wjStStKhVHGEc+Xuroh0ag4vwadyLsW7JN0s/tFFZ /HbGaIxvd+PaBTr+bRLhP/UN7MdfhJW7lvLzTZSuiui4WalCkBefKzxfbp8TjbkbFBME 0YBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769513; x=1687361513; 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=glXXfgsRplQFxPF2FEdJ5asogB54RtufXxooiyPAR7A=; b=QbeDMYF3dApeplxU9N5D1XyOuXFI3IkMrTPg7E6pamBHljmiFjJt5ndZH/CtJUYg1t M1xjXAz5PznIF+y2GHNMJWT9B0h34xeFzB2/z1UHZph9bzO4kjq2fMFJ+m/BfFfoCQD7 b9uz68vohWvCj1Pbdbr8+aa7pl3PU3LqbK+7uC8TsW/wC0uyulPFEeXifvU3vvUAJq7L faOTQLWkQjWrXP9gLzlSnIoImMdG1Dq2aeHkjOamynj0iNqV5sry6va/qEkBVx1I5jiJ HnFkXQwX+cdYcNGwVNpFwhErf9MBnnQHJMX/vYkyEuVt7f38BZN7sa3LoSSAb9uMSotf 5ZLA== X-Gm-Message-State: AC+VfDzrIaUfHValu8EZitwE1w8HLq9OpGzB/8Q0JN9US9peT8N0aV3V H+Kg/Tg8BZXuFnpToQYdWCIj28p3JQwZTfAwYlI= X-Google-Smtp-Source: ACHHUZ76Trc8v9vEFbD2AWUKqFB0luBfRmsTYpHZPG+DYF4hzmK1sSjy1HfwK+v4/lpt1CFMe8JjBg== X-Received: by 2002:a05:600c:220d:b0:3f6:3bc:8562 with SMTP id z13-20020a05600c220d00b003f603bc8562mr3097333wml.1.1684769512764; Mon, 22 May 2023 08:31:52 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 01/12] util/fifo8: Fix typo in fifo8_push_all() description Date: Mon, 22 May 2023 17:31:33 +0200 Message-Id: <20230522153144.30610-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769746330100005 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Francisco Iglesias --- include/qemu/fifo8.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index 28bf2cee57..16be02f361 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -46,7 +46,7 @@ void fifo8_push(Fifo8 *fifo, uint8_t data); * fifo8_push_all: * @fifo: FIFO to push to * @data: data to push - * @size: number of bytes to push + * @num: number of bytes to push * * Push a byte array to the FIFO. Behaviour is undefined if the FIFO is fu= ll. * Clients are responsible for checking the space left in the FIFO using --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769765; cv=none; d=zohomail.com; s=zohoarc; b=WB2mBOpTD2/pTenV6DSjsxJUBU6RznaultlaQrTkPddJDAKlZQXcXfSucGldsjEu0XtXi9XpGcz6peTQ89acl5KdXgwGb4UJvkaNktPlC4eYBT4eis7FXibjh0cCVdI7CmXPS/Ex13Rht7LbzmQfMhacOAZkzIRHldvw86h1H8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769765; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/HFQ4TQ858TQsjYOnqPZRPL59qIZV5loVHcO3ItffVk=; b=F4iQszSNFGs4BrH7O1h8mAGOb4pAV3soJdGNcWNuewWwNhSCZHYA9qahhDg3dAoLSQPUu6Fd5gsZyH1HSo54wo5GNfUimOd5OTMb6e1OG+gerdn+KkGKvR0YS0JTwNaQ6ZYUuy6PqDA9GgTO0BduFZ+skXRWfeDLS8Z69h2Wgr8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769765385977.145851402399; Mon, 22 May 2023 08:36:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Wc-0007aA-S6; Mon, 22 May 2023 11:32:42 -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 1q17Vz-0007NB-3K for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:07 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17Vx-0001Kb-Fu for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:02 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f60410106cso9527775e9.1 for ; Mon, 22 May 2023 08:31:59 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id z20-20020a7bc7d4000000b003f4ecf1fcbcsm11862770wmk.22.2023.05.22.08.31.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769518; x=1687361518; 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=/HFQ4TQ858TQsjYOnqPZRPL59qIZV5loVHcO3ItffVk=; b=JxZXjjckkKkgHydUr4Lviu/5YMUz8RRXJdofqyzRla9aFSCih3kMeEDlzc2dZd/rWC FxQ9L2UweED6uJXGa0Y81/Z4T6f6Bz9FKWyYoUC5JttfiFuZhwTETVkLqQ2tit4YqZi+ vFmuLxNql1IRFauW+5HqdfsALBV4Fz44tHok7cwNt7ZL0yYKGBsCRSp7Vz056zNr3vDp ORncD5wf0HsEv+t3uB5Y2g2pFu3lDF8bmNO2c38k4VqqANiwfKywKHHHzQsXFcG+PRK/ Eo7VTZypnqH16KVBJPLkalAdIbuBHex0TrcdF5lc4QeYq2+jB8ewG+lNUujRE3xNcQe2 lDtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769518; x=1687361518; 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=/HFQ4TQ858TQsjYOnqPZRPL59qIZV5loVHcO3ItffVk=; b=It3wE8MCMCKOatRrUREl+v2PykgBlXK1JCD0kXvexrft1rdrWdfhxYMZ/CjdqOAGWD w6tUpMjFZ3+bs/Qtdsk0mip+grCyCjY3BNIFDST0cw+CeTrTP/CVKoUmZxxnM384GEhD 0a2gB5CmL/KQC5WI1caAYZ9zs0R3Vl6p0SW39NXF7sQ008D0ByeSUoLGFatuTlT7aInh CEaZSFhLXqxG9U4FGjTgGHUc8tLXn03ugcth2WLSFapwSQjj3janJVxwf5uS3WytrxHm KLMhnG5OeIJA93+h2simPrYN9EpQQwQaWbVp0UxtDk1V85D1Xp+Rx+sedl0GCcMdiFSv 7xQA== X-Gm-Message-State: AC+VfDwhe3a8o7Hudb8mB2HIT2mO5+SyGX9K6p11uSHlQLVUSUWyoQ/O g2TLPRIoFVR8wrzJrg1sSV9V1Z9CTcgRaWHW0nw= X-Google-Smtp-Source: ACHHUZ7/Wq1BH2VOBPcnbW2UzMD8xKd0wdpFsluJ0Pacj+5WeRF3tY8x34tlDTeMgoIOek98Ynit0w== X-Received: by 2002:a7b:c046:0:b0:3f6:1c0:aa7a with SMTP id u6-20020a7bc046000000b003f601c0aa7amr3844982wmc.29.1684769518388; Mon, 22 May 2023 08:31:58 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 02/12] util/fifo8: Allow fifo8_pop_buf() to not populate popped length Date: Mon, 22 May 2023 17:31:34 +0200 Message-Id: <20230522153144.30610-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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, T_SCC_BODY_TEXT_LINE=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769765879100001 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=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Francisco Iglesias --- 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 buff= er * 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 d= ata * is returned. * - * The number of valid bytes returned is populated in *num; will always re= turn - * 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); =20 /** * 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; } =20 -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; =20 assert(max > 0 && max <=3D fifo->num); - *num =3D MIN(fifo->capacity - fifo->head, max); + num =3D MIN(fifo->capacity - fifo->head, max); ret =3D &fifo->data[fifo->head]; - fifo->head +=3D *num; + fifo->head +=3D num; fifo->head %=3D fifo->capacity; - fifo->num -=3D *num; + fifo->num -=3D num; + if (numptr) { + *numptr =3D num; + } return ret; } =20 --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769634; cv=none; d=zohomail.com; s=zohoarc; b=U+2BIdWuZo1pQhAy7oiIfZqmpE/Xbs9S2mwWvYeG1Si6S7Fy2Fw3u5InB1KT3I3C2rBy8v3n9lbDt+wwmSOzvtMwQyVdPgLAR+joo2zyuPWzYA/OljTTs8X+r/qDkWejJWc3MDIeVoxlg5vAckLCo0Qe6gA82Y179BP4mEDIMrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769634; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D/v69wjcgQjzqhC98DKwcbYpCW+hDbd/3U2ovkdSDfw=; b=SaWFLLALAV+XJPHpsSYWXxQ66EtlXRKdblGBqQJ2gSFPTRvvdU4B9awdHgabCVTinwdcCgMJscMYTDkXGLhBwyScao2GnCUHJwSzIf6QwXQglRuCcCEOvnshNcecbu6zx7kZSWU75NsoVaVK72EAPxc+aAezP7bBIoV1yi3u31M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769634128210.38215110005444; Mon, 22 May 2023 08:33:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Wb-0007VB-6v; Mon, 22 May 2023 11:32:41 -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 1q17W4-0007NO-6T for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:15 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17W2-0001Lg-AC for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:07 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f42b984405so38783925e9.3 for ; Mon, 22 May 2023 08:32:05 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id o3-20020a1c7503000000b003f09d7b6e20sm8747145wmc.2.2023.05.22.08.32.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769524; x=1687361524; 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=D/v69wjcgQjzqhC98DKwcbYpCW+hDbd/3U2ovkdSDfw=; b=GcIeHWq7ho6Wb3vxdbkOS5rHBfm+Q2V7gO4V4OinnFC6S0gSjLClHkroxEPcEyBaiu 7MN6KFbKVsg6IS2/mEYBDXvvWGb5hFPXSOYD8BTCxDIs2O3v0Z2hXbxqz/04U0D2XO81 zfmxZ1tI2Kgjtvi4WPDOOwZx+MhlPIzOCmN//oGJgNdRbHG98G30XTWgB4dArEtQHTEs yPZoNvsSaATl7Vpc/dk4BOvEEwPVxp1b6X2mlxkv8eqLchb+TTC1dtkBsUF2CWhh1B0C AXudY0VYO+0Jz0PNoSG0gV0Y410OlUG7MEioweVbxP+FhwaiBT/CsVCVxoCnsld6T4Ej X1Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769524; x=1687361524; 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=D/v69wjcgQjzqhC98DKwcbYpCW+hDbd/3U2ovkdSDfw=; b=f82gFw7GBNDKrOXc1Qn/DOfzCecOlbwYlv2FRwViaTFNDrkaP8/fnzEVo0+WTDmrHo yb2H/rRrSJgQ4bpfrck2FsMG81U1FVrGDEYbdFVkJGDzYBdGsh6R2DWELivhIIc2o8rQ BjTldXkvECJkd/uVRk6J+Ho+ts3FiwhuEOoLyLYLCh7hWs1F6vPjZRpM7LR2JciTiQNK kM1T0NiVysWS4UYC0cjS2uZ4PtDaBvY8m0xZ99UZlvs9UCtQebI0jv168H2HdN+/JA5g WJz/PsR/LrMtcTZvTLizEue5jUkJfSJy0eFAvOAsgNTTegCmugABKIOCuW5Wsll2LS/Z 8Reg== X-Gm-Message-State: AC+VfDzHbGckKVYMSlLIEGk4FFRaFErVIn22ypKCveL772u5wFFj442r E2LU36hBs3V5O7wunNGaF0kO5xDPyNxCrOQUawY= X-Google-Smtp-Source: ACHHUZ4DB49NeA6IuP4gNB8rRn3/y8nnkvLLXF4r34C3aepgjSKB030tIOAZ6MWs9ndDwosRDKjDMA== X-Received: by 2002:a1c:f70e:0:b0:3f4:2b1a:553b with SMTP id v14-20020a1cf70e000000b003f42b1a553bmr7727352wmh.28.1684769524506; Mon, 22 May 2023 08:32:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 03/12] util/fifo8: Introduce fifo8_peek_buf() Date: Mon, 22 May 2023 17:31:35 +0200 Message-Id: <20230522153144.30610-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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, T_SCC_BODY_TEXT_LINE=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769635656100001 To be able to poke at FIFO content without popping it, introduce the fifo8_peek_buf() method by factoring common content from fifo8_pop_buf(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Francisco Iglesias --- include/qemu/fifo8.h | 26 ++++++++++++++++++++++++++ util/fifo8.c | 22 ++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h index d0d02bc73d..7acf6d1347 100644 --- a/include/qemu/fifo8.h +++ b/include/qemu/fifo8.h @@ -93,6 +93,32 @@ uint8_t fifo8_pop(Fifo8 *fifo); */ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr); =20 +/** + * fifo8_peek_buf: + * @fifo: FIFO to poke from + * @max: maximum number of bytes to pop + * @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 buff= er + * containing the popped data is returned. This buffer points directly into + * the FIFO backing store and data is invalidated once any of the fifo8_* = APIs + * are called on the FIFO. + * + * 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 d= ata + * 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; } =20 -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 <=3D fifo->num); num =3D MIN(fifo->capacity - fifo->head, max); ret =3D &fifo->data[fifo->head]; - fifo->head +=3D num; - fifo->head %=3D fifo->capacity; - fifo->num -=3D num; + + if (do_pop) { + fifo->head +=3D num; + fifo->head %=3D fifo->capacity; + fifo->num -=3D num; + } if (numptr) { *numptr =3D num; } return ret; } =20 +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 =3D 0; --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769827; cv=none; d=zohomail.com; s=zohoarc; b=KudJS1ONF3NVrg3G5CFccUYu24Hw+ABJ13WTslvASRmZYqBR70xfduljWozgH5phKGN1XP7jLc/HbL5PrvPvnQdsqTf4Zru0M/aeh9jb94mInOGP0PR8P/GjFVEglF2QgRluiMRUsTRGr2JCXjxFL7QXxEd/RLsGj1kRcsOeTFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769827; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DeXq+k+iZcDwEahQV3X8F7cWs5VQQu6bE5Hamux2tak=; b=cB0BHKps+nUIsaKCtatATslssXXm3ZzbZjAVaylQ8Z/3QKcVwSo3hBy5qzcVIA3z2aHnBKNDQS2Y2whFcfa3Wn3xZk7RTo4BV2kHNtLTUWnfab2q23E5SKcEk0ko6bcazMDbs3Y/TJUotiba0K57bgLaffbbuRsWNxT5FWQ+Zmc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769827935841.0852066918477; Mon, 22 May 2023 08:37:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Wf-0007dg-GJ; Mon, 22 May 2023 11:32:45 -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 1q17WE-0007Oj-8G for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:21 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17WB-0001Mf-JT for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:17 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-30a95ec7744so726655f8f.3 for ; Mon, 22 May 2023 08:32:11 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id y21-20020a7bcd95000000b003f4e8530696sm8629406wmj.46.2023.05.22.08.32.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769530; x=1687361530; 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=DeXq+k+iZcDwEahQV3X8F7cWs5VQQu6bE5Hamux2tak=; b=TlsPvy9MfS9Tl92mIBU70ctzv29X3LgoBlOL++96iLZmUChBKbFkNb4FhlMw9Ko8XX VmhrgBgpOLJmx1zCjuei/gyAsgRORwDzeHJ63CTjc0lI3AGWPs8idGHISVwrl29eYYy9 b0wzJRFQAsamkNncWQGwxF1bW92OpNs3IcIOAofaJRX6XgAM+TTZs9OZOSJKYJbYKx26 gR6Y5TnwlYJOsaLYTPHqflzOPMRnmgS040pLIDqWt/PaOwdBB5Pk/vwgi68c2Zw58onS +fLGq/LmYkM2H3+SFcWpUAgUn3bRHtm/Q49xR7NjC0UEwyZ/anaVhbA1koOTnxheND04 T6mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769530; x=1687361530; 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=DeXq+k+iZcDwEahQV3X8F7cWs5VQQu6bE5Hamux2tak=; b=b3tvrVa///k8AdJxfTwGVVbHLJa/B88+VqIDJuORrB8dIp7MxukmJ/8onh4kXzRzUi m4dsLluCjrG+UEuPoiJDmcY+4NoyL0hqmdwFQEhIssKcvu7zO/E2NH+Yq2d68PJETwkj 6GACzuwHZ0XtsrlkncDoIA1zNF5Z9eVyfLl8/sRuAq/QYqlrFZiJ4iI6Iw3Vbr8fqraa IoaQTGCldkki+zgo/6gxV28AlcJYBTtB6E/dhCrafqoSqG0ka+UnWHzy79RoROrYdl8m JdjGsseQxWlP/p1oTFo400y3lbDHiMXdwq2vbzjVFHiF4VtR36lcTgUJ13+EY8PVxSxX pPVA== X-Gm-Message-State: AC+VfDyAXuG921ttGfvRZhtfDWNnK6F37usmrrc9heoiVtCYfpKwvluY F95eGkXmjMmO5ZqNv1lG0MyGW+kNh5+ia5RAJXA= X-Google-Smtp-Source: ACHHUZ4LJvxpc80HXLS2C8s3syqktw2me3xxNmUzE/3ZXCbGVJu9SvMT3pnZZTHDTyl6FrFDDsWrlQ== X-Received: by 2002:adf:ce08:0:b0:309:4d12:64e7 with SMTP id p8-20020adfce08000000b003094d1264e7mr9228156wrn.31.1684769530067; Mon, 22 May 2023 08:32:10 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 04/12] hw/char/pl011: Display register name in trace events Date: Mon, 22 May 2023 17:31:36 +0200 Message-Id: <20230522153144.30610-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769828252100001 To avoid knowing the register addresses by heart, display their name along in the trace events. Since the MMIO region is 4K wide (0x1000 bytes), displaying the address with 3 digits is enough, so reduce the address format. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- hw/char/pl011.c | 25 ++++++++++++++++++++++--- hw/char/trace-events | 4 ++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 77bbc2a982..274e48003f 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -51,6 +51,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Char= dev *chr) #define PL011_INT_TX 0x20 #define PL011_INT_RX 0x10 =20 +/* Flag Register, UARTFR */ #define PL011_FLAG_TXFE 0x80 #define PL011_FLAG_RXFF 0x40 #define PL011_FLAG_TXFF 0x20 @@ -76,6 +77,24 @@ static const unsigned char pl011_id_arm[8] =3D static const unsigned char pl011_id_luminary[8] =3D { 0x11, 0x00, 0x18, 0x01, 0x0d, 0xf0, 0x05, 0xb1 }; =20 +static const char *pl011_regname(hwaddr offset) +{ + static const char *const rname[] =3D { + [0] =3D "DR", [1] =3D "RSR", [6] =3D "FR", [8] =3D "ILPR", [9] =3D= "IBRD", + [10] =3D "FBRD", [11] =3D "LCRH", [12] =3D "CR", [13] =3D "IFLS", = [14] =3D "IMSC", + [15] =3D "RIS", [16] =3D "MIS", [17] =3D "ICR", [18] =3D "DMACR", + }; + unsigned idx =3D offset >> 2; + + if (idx < ARRAY_SIZE(rname) && rname[idx]) { + return rname[idx]; + } + if (idx >=3D 0x3f8 && idx <=3D 0x400) { + return "ID"; + } + return "UNKN"; +} + /* Which bits in the interrupt status matter for each outbound IRQ line ? = */ static const uint32_t irqmask[] =3D { INT_E | INT_MS | INT_RT | INT_TX | INT_RX, /* combined IRQ */ @@ -191,7 +210,7 @@ static uint64_t pl011_read(void *opaque, hwaddr offset, break; } =20 - trace_pl011_read(offset, r); + trace_pl011_read(offset, r, pl011_regname(offset)); return r; } =20 @@ -234,7 +253,7 @@ static void pl011_write(void *opaque, hwaddr offset, PL011State *s =3D (PL011State *)opaque; unsigned char ch; =20 - trace_pl011_write(offset, value); + trace_pl011_write(offset, value, pl011_regname(offset)); =20 switch (offset >> 2) { case 0: /* UARTDR */ @@ -252,7 +271,7 @@ static void pl011_write(void *opaque, hwaddr offset, case 6: /* UARTFR */ /* Writes to Flag register are ignored. */ break; - case 8: /* UARTUARTILPR */ + case 8: /* UARTILPR */ s->ilpr =3D value; break; case 9: /* UARTIBRD */ diff --git a/hw/char/trace-events b/hw/char/trace-events index 2ecb36232e..babf4d35ea 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -54,9 +54,9 @@ escc_sunmouse_event(int dx, int dy, int buttons_state) "d= x=3D%d dy=3D%d buttons=3D0x%0 =20 # pl011.c pl011_irq_state(int level) "irq state %d" -pl011_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" +pl011_read(uint32_t addr, uint32_t value, const char *regname) "addr 0x%03= x value 0x%08x reg %s" pl011_read_fifo(int read_count) "FIFO read, read_count now %d" -pl011_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" +pl011_write(uint32_t addr, uint32_t value, const char *regname) "addr 0x%0= 3x value 0x%08x reg %s" pl011_can_receive(uint32_t lcr, int read_count, int r) "LCR 0x%08x read_co= unt %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" --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769863; cv=none; d=zohomail.com; s=zohoarc; b=G6j8T+TtOg0BGwrK8rzU6TqsNB5sX0rLJBHnVOcT1TK5WaHPMCTxKPQx9cEZqegVZVeKmIaZMdjmTujI/RdF1g0wn1YMz1Lt5hh5IFwKUFYIJMs+LRfcl8o5TekSYcfgJV8DsMAjDN5c6cDAYWD6L+Z46pgROpo9aE216fch0aQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769863; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tnpVE0KcY4+JRcfuSFzjf1/8d9/S4c9dHftftoYjEBk=; b=YLTlPpLUF2RSJBglFrCxoqHaLu22+ZO+wLtRScN16+DVq6p4ewCeNUCi7Nu+68Ivla77Yg4/7QdkL3kk/J3itL2JVG9MBOOt5h6mna0Xvw4nAD5TUACGqP/akcwxBDQlIFVGzr3rwc8P6cdz1VaYZUZGRm/B1KPun5bCFpDpybY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769863528732.9894620377916; Mon, 22 May 2023 08:37:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Wd-0007bC-Eu; Mon, 22 May 2023 11:32: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 1q17WG-0007QU-TE for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:21 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17WD-0001Nb-Bx for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:20 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f41d087a84so26344355e9.1 for ; Mon, 22 May 2023 08:32:16 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id h19-20020a05600c28d300b003f427cba193sm11884546wmd.41.2023.05.22.08.32.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769535; x=1687361535; 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=tnpVE0KcY4+JRcfuSFzjf1/8d9/S4c9dHftftoYjEBk=; b=wrPfWhfARqAZEI26T8s2j5R4+TGHe7B/jSYVvOJNK4gsHgEG6HV9e2eXDLZsT71Jm3 ODoxO7HsYFmg+bgZbiPQGBuxMnmsKfOp6fax0jrPepxdlA3f4rVuRrg6ouctiQ2XmZcm yLNScv4q91N8KvsU4f8RDA3pS9XYR7JCI4JDMv91dyLmtDkOyD54QigtvAJrz3LdgcIe ufPkfT9D2YnIu6/f1TKGetyJ+zImBnwN/heNu6+2RHZXPrWHpLbhBKa5IM9kcWwowD2s AN1CzLtixljLrASPCMmelwfMLD9kgWTVcGmaKtR8+ADS7sFGZaE60Gf7YyAujI3qBL5s Cyfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769535; x=1687361535; 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=tnpVE0KcY4+JRcfuSFzjf1/8d9/S4c9dHftftoYjEBk=; b=NdPDFKTe0COgOfq48DzfVdNR7IJglEt1dGS/f18gvw/clL5LIbpJRfOob0nmmkf9qE 6CvTzFQzgUBkz/UhXyS6wpTaE2OmgXBvONvUPAFQ+pecGXpuskstgTTtSJftaTyURLPR yRDn5AAhlcl67eDbbamG508YJqqx15eExJ3gaj6LIwPWnSXugiq7xUFDZcPDZzqMTV35 RQVnv3oQYFAulUtnzLk6L4wW3eenRKLdtwx8MKJ6dMHGLB6wv/uPkpQYnxBkILQMJEbt WkJzTEW8kPdJW3JJgVTeGjTNSoR7aZ+dsAVZmOUiOr4EauCTmjMNtURbURqs2t4pR5pH m8rQ== X-Gm-Message-State: AC+VfDxP8bN/WPR8tfhOeO91fseDptcXKGaZno9O0lsbCptnen0ZewGI G7B5z4njkc92hT7XZDNe9qLIW65nq/ms9V91gh8= X-Google-Smtp-Source: ACHHUZ5nWLq1Q6uL75RxBlw3CYXHjQj51PfGGGaNKb+Y7t3d/zBETgyzGb17ORcbG6GAY8LoTeALFQ== X-Received: by 2002:a05:600c:3146:b0:3f4:ed2a:4347 with SMTP id h6-20020a05600c314600b003f4ed2a4347mr7854105wmo.16.1684769535492; Mon, 22 May 2023 08:32:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 05/12] hw/char/pl011: Remove duplicated PL011_INT_[RT]X definitions Date: Mon, 22 May 2023 17:31:37 +0200 Message-Id: <20230522153144.30610-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769864547100002 PL011_INT_TX duplicates INT_TX, and PL011_INT_RX INT_RX. Follow other register fields definitions from this file, keep the shorter form. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- hw/char/pl011.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 274e48003f..93e19b2c40 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -48,9 +48,6 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Char= dev *chr) return dev; } =20 -#define PL011_INT_TX 0x20 -#define PL011_INT_RX 0x10 - /* Flag Register, UARTFR */ #define PL011_FLAG_TXFE 0x80 #define PL011_FLAG_RXFF 0x40 @@ -157,7 +154,7 @@ static uint64_t pl011_read(void *opaque, hwaddr offset, s->flags |=3D PL011_FLAG_RXFE; } if (s->read_count =3D=3D s->read_trigger - 1) - s->int_level &=3D ~ PL011_INT_RX; + s->int_level &=3D ~ INT_RX; trace_pl011_read_fifo(s->read_count); s->rsr =3D c >> 8; pl011_update(s); @@ -262,7 +259,7 @@ static void pl011_write(void *opaque, hwaddr offset, /* 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 |=3D PL011_INT_TX; + s->int_level |=3D INT_TX; pl011_update(s); break; case 1: /* UARTRSR/UARTECR */ @@ -350,7 +347,7 @@ static void pl011_put_fifo(void *opaque, uint32_t value) s->flags |=3D PL011_FLAG_RXFF; } if (s->read_count =3D=3D s->read_trigger) { - s->int_level |=3D PL011_INT_RX; + s->int_level |=3D INT_RX; pl011_update(s); } } --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769608; cv=none; d=zohomail.com; s=zohoarc; b=Y4bIbfuglaVpB0fWn+oB9zdTSweHLAY42AUZ8LYuXNIR7VfaxHxGV/qItQhA54hZD2KPGqKYdFjFexH9XeFMbHqYN4RiUT0LcpRxSKU/W1bFXyutABdem71ezNmHfNJVDsGy7kds3xMcvJwVsKwrfF52YhE0GEDrFlI3fvfKnRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769608; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PcPyr1Hd/Zw7pAX4B7gZfLX+zfoHJG12lzmzj0tU/xY=; b=M78LxXF5htd/iUF72a3Td2LWeYa7NQWcPmG3dwW/yQNz0TKwMnW8syWAczuWiJ1q4uEZBRyo20yWfYBLh81Nq7MEiLJ/cvWt5nR+0ZJxMT+hb05/0Vvixr05B1/0a+k6/O4lXCkfI3xNKEiyzzcGE9/JFZHiM9tajDGWpychNII= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769608675847.5155309493834; Mon, 22 May 2023 08:33:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17We-0007bz-Bw; Mon, 22 May 2023 11:32: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 1q17WS-0007Sp-4U for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:40 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17WJ-0001QG-Rp for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:31 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3f475366514so42744295e9.2 for ; Mon, 22 May 2023 08:32:22 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id f20-20020a7bcd14000000b003f17848673fsm8688467wmj.27.2023.05.22.08.32.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769541; x=1687361541; 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=PcPyr1Hd/Zw7pAX4B7gZfLX+zfoHJG12lzmzj0tU/xY=; b=hrPWDhgPUFiBuAMhA5CDRbl9BVs8bETJD7pwCAZ5uhag+rdaBUug4RgowQqjaEhxuM +fSrM+tvfbW9e5Cr3eJIY9N0rjM0VQpSrg6QkPETPvt5EWGG5+jGeeLghnx4DzymM+Nu lR/BBDrel+DVWDmU2r/3TLcPzBDppUkfo/pccf/BWPWf+lxGSaDP2hBKILuouM9OuJLc arCCSLhFVSFQMASuCGNHxBnTBBj4ccKzOM2rCsCFMN3Pmpi5CbZh2ypz5pDkPkUlb5sb YLLcYqiwj28v1nUE8NpWeohdHCcnv8yOGJsNuvGG+y4Dke4tQBnRJYZF2ShR+WQBmIfr yN/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769541; x=1687361541; 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=PcPyr1Hd/Zw7pAX4B7gZfLX+zfoHJG12lzmzj0tU/xY=; b=PgiEgunFpSVbtpxOiom0IiMx9t1hyg9fTmz17as1jrYkaMWGR0BUWC7BRQRMjf0nj4 ifYziSv0pY7XSyC9oiVguQtPED9sIMKkd2ExUkf9QCPOoD1hrRrxbmiUkoEcEMar46b8 3mz8U8Xq9M0zWCt3XKjFbY9+Y6jAigQIFf83nmdlUTKWmCIO71Sk+2sr1+vrMEWJZSKL ERK9HNg4UOiWxNDoCSC+bBMf8BnAIOLEMA6VeRx7r0mH8eKfCOM+AnKQV8KvM/dFp1tp mlWoQrnDVTSbOLH4chWKMFHyzG8JW3WK2c9F47hc0xk7LUj3TGOEZsf6nN4U4Hx5oSCx BxZw== X-Gm-Message-State: AC+VfDyWhhTSDY5UGgmo5coKeQI/RCOJcb/tQfjM3cbyqaLkoQB685cz uc5EnhGlWXldXHXQQ0WJaO2xb235NxtW+KPFHCo= X-Google-Smtp-Source: ACHHUZ41Lu1ostv+MOkaW5Ot1RWFYYpgCpfgOpbGq8Jr5VShUHgNitA0+MeQTErk6rAJ1JkJCxk0EQ== X-Received: by 2002:a05:600c:220a:b0:3f0:b1c9:25d4 with SMTP id z10-20020a05600c220a00b003f0b1c925d4mr7732831wml.21.1684769541121; Mon, 22 May 2023 08:32:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 06/12] hw/char/pl011: Replace magic values by register field definitions Date: Mon, 22 May 2023 17:31:38 +0200 Message-Id: <20230522153144.30610-7-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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, T_SCC_BODY_TEXT_LINE=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769609230100001 0x400 is Data Register Break Error (DR_BE), 0x10 is Line Control Register Fifo Enabled (LCR_FEN) and 0x1 is Send Break (LCR_BRK). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- hw/char/pl011.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 93e19b2c40..98c5268388 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -54,6 +54,9 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Char= dev *chr) #define PL011_FLAG_TXFF 0x20 #define PL011_FLAG_RXFE 0x10 =20 +/* Data Register, UARTDR */ +#define DR_BE (1 << 10) + /* Interrupt status bits in UARTRIS, UARTMIS, UARTIMSC */ #define INT_OE (1 << 10) #define INT_BE (1 << 9) @@ -69,6 +72,10 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Cha= rdev *chr) #define INT_E (INT_OE | INT_BE | INT_PE | INT_FE) #define INT_MS (INT_RI | INT_DSR | INT_DCD | INT_CTS) =20 +/* Line Control Register, UARTLCR_H */ +#define LCR_FEN (1 << 4) +#define LCR_BRK (1 << 0) + static const unsigned char pl011_id_arm[8] =3D { 0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; static const unsigned char pl011_id_luminary[8] =3D @@ -116,7 +123,7 @@ static void pl011_update(PL011State *s) =20 static bool pl011_is_fifo_enabled(PL011State *s) { - return (s->lcr & 0x10) !=3D 0; + return (s->lcr & LCR_FEN) !=3D 0; } =20 static inline unsigned pl011_get_fifo_depth(PL011State *s) @@ -218,7 +225,7 @@ static void pl011_set_read_trigger(PL011State *s) the threshold. However linux only reads the FIFO in response to an interrupt. Triggering the interrupt when the FIFO is non-empty see= ms to make things work. */ - if (s->lcr & 0x10) + if (s->lcr & LCR_FEN) s->read_trigger =3D (s->ifl >> 1) & 0x1c; else #endif @@ -281,11 +288,11 @@ static void pl011_write(void *opaque, hwaddr offset, break; case 11: /* UARTLCR_H */ /* Reset the FIFO state on FIFO enable or disable */ - if ((s->lcr ^ value) & 0x10) { + if ((s->lcr ^ value) & LCR_FEN) { pl011_reset_fifo(s); } - if ((s->lcr ^ value) & 0x1) { - int break_enable =3D value & 0x1; + if ((s->lcr ^ value) & LCR_BRK) { + int break_enable =3D value & LCR_BRK; qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_BREAK, &break_enable); } @@ -359,8 +366,9 @@ static void pl011_receive(void *opaque, const uint8_t *= buf, int size) =20 static void pl011_event(void *opaque, QEMUChrEvent event) { - if (event =3D=3D CHR_EVENT_BREAK) - pl011_put_fifo(opaque, 0x400); + if (event =3D=3D CHR_EVENT_BREAK) { + pl011_put_fifo(opaque, DR_BE); + } } =20 static void pl011_clock_update(void *opaque, ClockEvent event) --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769841; cv=none; d=zohomail.com; s=zohoarc; b=VMYemQ0rKcsqlfW5zdT2K2GGnLJCMCLUAxV637eGV6hZbstHbW+w6ylSeQ3dQtGsGNVyScx6g8Sy/ncgwhLPtfQDvvlW3ysgG4qCucmi96JKOhNCu8A9ldCtHBEXquLJnDf1WhyRJZTLGeFO9zFWzSHhzqznwf/5F46xUgLK6Y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769841; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=256qRxVoRgmn8ZQNw96BSPjzs8Oo5GL3PGwhSL7cRNw=; b=ZO5YUjl34QKIgvRs33j/sWHB1RSemJ2PXsho1a3nHjMDei5BDEMSiNg/RlUJ8u0sq3szCbgTIrza+JOk+PTrlFDt/VeUNlXqDwozDQcz1nsweS4cALTF3G2tpIKf4s3jwt1+MJT8JitlN8IfSJBpVymNAJ9IILYkD6FPLwWocpc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769841900556.7192804681099; Mon, 22 May 2023 08:37:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17We-0007cB-Gj; Mon, 22 May 2023 11:32: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 1q17Wa-0007Uu-WD for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:41 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17WP-0001RU-J8 for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:36 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f606912ebaso9303235e9.3 for ; Mon, 22 May 2023 08:32:27 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id 18-20020a05600c229200b003f42d8dd7d1sm12078857wmf.7.2023.05.22.08.32.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769546; x=1687361546; 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=256qRxVoRgmn8ZQNw96BSPjzs8Oo5GL3PGwhSL7cRNw=; b=C/t7JMkQsTbjpIgJ59MHwv63ucFDE2WtK1AE0dsf4JCAAsNUrp1pDlOCrmtxwNAj+C oceIXdKSpx4vUBXmKDLfyQ+5HS+At35HtKg2gvcngba7a/Lzav1Jvpv7XGm969IfTPKc lh2eTjhN3LR5TiRFc3LSSFTVtFhLGmUPEmwd7xIC+rcCrEjG46BtGVY9L3KlhU26iMxw JCv4Lu5Xx+PjGfWP86KsSoMROJ14gykSKxfg4Jkbvcv1xGpblT1+KdtLfCwft61nCPVX n/NBbkh4uHNUUC/CjtuAokQbW7UQTZu7tv9rUWGkpX3Px2K1MiFXZEzchZTE26af3RZy k57w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769546; x=1687361546; 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=256qRxVoRgmn8ZQNw96BSPjzs8Oo5GL3PGwhSL7cRNw=; b=jGa+kwnUivsN0UlyBum8r609n9WLig9jdOPFvRJAfm22xRXoClQPLyl8bDk/Lx1xMK FXRlQx0HuPNpktlC3Q+vL93BzyA3wA/qkcZNBvXS8+eCSwPwOUGrcCWZRwiOd46nmn1y RAffMP1FwcbZG9b8XCH7Cjuvf/M8C37MKCVOk0t6xQgK69SllvklM2gHHcQHFjjT8ik+ iBEkwACzEsrEnx2g5CEVmHWvCKdSB4sjCa2Vtp6LXHZfZbCjYkrxGQi1CyUCYBGIawM6 +b4PrtqhUt2pbtSPJFvmTjroqOQdFD5iZNapufjjW0/qRVqLuH3Fibhu8beN3uQueTgO HwGw== X-Gm-Message-State: AC+VfDxWpH476QPo/LHGZtZMQ6h6jv2mtYsxYeXnaJxzUjcCj6QdGfbB jEZZMQR3aYZBl022SI4BLyh8ciuft8/VOeLIi7c= X-Google-Smtp-Source: ACHHUZ4nod3UtzH9pNJ6BVfmAx/Fej6Cz66sTAoSu24l4cQfeNXH5SGQcmVgRqo9cwDkeYxmt+Bklg== X-Received: by 2002:a7b:cc8e:0:b0:3f6:89a:94c8 with SMTP id p14-20020a7bcc8e000000b003f6089a94c8mr658221wma.24.1684769546718; Mon, 22 May 2023 08:32:26 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 07/12] hw/char/pl011: Split RX/TX path of pl011_reset_fifo() Date: Mon, 22 May 2023 17:31:39 +0200 Message-Id: <20230522153144.30610-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769843276100003 To be able to reset the RX or TX FIFO separately, split pl011_reset_fifo() in two. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- 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 98c5268388..f0b305e5d7 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -132,14 +132,21 @@ static inline unsigned pl011_get_fifo_depth(PL011Stat= e *s) return pl011_is_fifo_enabled(s) ? PL011_FIFO_DEPTH : 1; } =20 -static inline void pl011_reset_fifo(PL011State *s) +static inline void pl011_reset_rx_fifo(PL011State *s) { s->read_count =3D 0; s->read_pos =3D 0; =20 /* Reset FIFO flags */ - s->flags &=3D ~(PL011_FLAG_RXFF | PL011_FLAG_TXFF); - s->flags |=3D PL011_FLAG_RXFE | PL011_FLAG_TXFE; + s->flags &=3D ~PL011_FLAG_RXFF; + s->flags |=3D PL011_FLAG_RXFE; +} + +static inline void pl011_reset_tx_fifo(PL011State *s) +{ + /* Reset FIFO flags */ + s->flags &=3D ~PL011_FLAG_TXFF; + s->flags |=3D PL011_FLAG_TXFE; } =20 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 =3D value & LCR_BRK; @@ -504,7 +512,8 @@ static void pl011_reset(DeviceState *dev) s->ifl =3D 0x12; s->cr =3D 0x300; s->flags =3D 0; - pl011_reset_fifo(s); + pl011_reset_rx_fifo(s); + pl011_reset_tx_fifo(s); } =20 static void pl011_class_init(ObjectClass *oc, void *data) --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769743; cv=none; d=zohomail.com; s=zohoarc; b=apaeHH04jMNvVcY7fkWZk33f0eXKjHtVx+xZemZ9asfA20m+i3RQT8YFiozLp4olsrNYG4/+txeCIwRwoIKcLxkO7WhUCwJeO3d876D5lSBw9ms7NLE1Nrpl6K16LGCYSF6igUX+wcXKEAqYxmGAOpwRiJ1QAmVrVU92N3trN2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769743; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9q108c2Lliqjn2JXt6hPBTH1oW++ckhJeDwIAiOICrs=; b=Z6FekzglK5jypqy4E/vDdJm5fp878S1K85fcqBPft5jJ6rHbgisEsjPiKi+wy+C8v9RHySGQE/kIQU4BwjNUmP9OIZEn47nUHfsKkkxW/KY4TzHkusrcCkFqefEYSkhoCoRRRpmucwp/4DGZKQZg/MRUA1MTZV7+OtDerA5hexE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769743389182.5356158266818; Mon, 22 May 2023 08:35:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Wh-0007fH-0Z; Mon, 22 May 2023 11:32:47 -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 1q17WV-0007TB-LU for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:40 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17WU-0001Sb-2G for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:35 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f42c86543bso40693915e9.3 for ; Mon, 22 May 2023 08:32:33 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id o14-20020a5d670e000000b003062b2c5255sm7999526wru.40.2023.05.22.08.32.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769552; x=1687361552; 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=9q108c2Lliqjn2JXt6hPBTH1oW++ckhJeDwIAiOICrs=; b=IMHyvW6b41w7xSQpLSpQKb/8I2BRZydodmSpCk/NRscgvzIhUtZMGKq5KcvWaFEhOk Kq70ExoxrZc3in+/b0WTJVRJTql9fCnKjgwxk4UTIBsCmo/ZqBTLH/PGLV9bspkR7JCU QucW5H14V+L+xxo2ZQnmqRjlxK7vHItTLcDcyrYvBAtTI3fmQEs+ZFEVvJCGDV7F2SH4 NcXQLKdGt6NfS5pCmdLaVvxNp82i5dkrT6AtUuyRlBW3pxd++Km/O4C9lG9/bC3sbco+ K/0d97xu9qcqWdRqZ+z/QdH9D1XUPeSqJAu8WUoEDLCbpYnZD5c2NowZnrPpSDZC1weZ xLZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769552; x=1687361552; 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=9q108c2Lliqjn2JXt6hPBTH1oW++ckhJeDwIAiOICrs=; b=Th8hVQ5flf9+2tDFVQutLUh2zJErXMMNZiIhYdY1WhzHa+JZjYRJ+elw1WLtWYCkQf HbyAqvg2lAcCULmmKxBxBMhH5ttqqdu4wVCoMwhG+/7/OWUD/MDhm3sbzGroM9aU+qEg Y3yDZxlwuxqJzeSSUYavpE6i3hgeaq1HQQygYhTxryXUR4oaGb7zcipcmBkUdVV7ajO5 DCUl0zzPHWb9yvhij18NPkG59U8EkfTUWc7mIPpRjtJntntHqlHOvqfpg5TP70LKaqPB p5j962SqVrRdVwO+vLg0H1ZjE/GIbCQceTqJ1UwPvty1yMRSprnMoXoPE1dVtx0nmQdo OxSg== X-Gm-Message-State: AC+VfDwfF8hmxnUhv39QVk2b/aC80SURN5uLfnsv/a7JTvJ/VqdV8wnQ Wl+9sHf1+oDlg3mVTPGZ0MDvgnXwFPFeF5Ue7PM= X-Google-Smtp-Source: ACHHUZ5daT317HebxC6rzNCrJzzvlRIQAwbUTOm48bB91IEBi8el7d5GDaIyU5ujf/bHkMcUQahh9g== X-Received: by 2002:adf:dcc7:0:b0:309:32d1:59d8 with SMTP id x7-20020adfdcc7000000b0030932d159d8mr7907619wrm.64.1684769552397; Mon, 22 May 2023 08:32:32 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 08/12] hw/char/pl011: Extract pl011_write_tx() from pl011_write() Date: Mon, 22 May 2023 17:31:40 +0200 Message-Id: <20230522153144.30610-9-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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, T_SCC_BODY_TEXT_LINE=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769744792100003 When implementing FIFO, this code will become more complex. Start by factoring it out to a new pl011_write_tx() function. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- hw/char/pl011.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index f0b305e5d7..c55ef41fbf 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 |=3D PL011_FLAG_TXFE; } =20 +static void pl011_write_tx(PL011State *s, const uint8_t *buf, int length) +{ + /* ??? 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, buf, 1); + s->int_level |=3D INT_TX; + pl011_update(s); +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { @@ -262,19 +273,12 @@ static void pl011_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { PL011State *s =3D (PL011State *)opaque; - unsigned char ch; =20 trace_pl011_write(offset, value, pl011_regname(offset)); =20 switch (offset >> 2) { case 0: /* UARTDR */ - /* ??? Check if transmitter is enabled. */ - ch =3D 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 |=3D INT_TX; - pl011_update(s); + pl011_write_tx(s, (uint8_t *) &value, 1); break; case 1: /* UARTRSR/UARTECR */ s->rsr =3D 0; --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769864; cv=none; d=zohomail.com; s=zohoarc; b=CxJvWUKScmudGy8QdUFfflN3PHAflo64W2ERXezvK/B1uwE7Kq64bU9D05sHgw6f5kqb2P2dPrbvjSOWf4E1+E5EiRWbIbWuizY0EHUw3e7pBZfy3qeYdqnp7u5sLECqNvXtO19B24Kt+FQd/HiaM8JAF/ZjFrjkhQt0tH89SP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769864; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zbYgJ/CF6X8oXk1c18I3fiTWkENuu1esnlnJzdOgw0U=; b=Bz6h5pwBSXEz7J5ZvZCrrf08fOJb2cuy5S+cGkEWuR50ZkbwPJKRUdMYMlN5fy/dt4ZJUgoTwzDdY5MapwOkAokfYKZz/tqwgqo45epVLAhWBZ8nbPe7wxOPc6qUrt7oI9yaFlFEzOYYtE11VyAOhZlCgW+Ajoi35lLIJ50QgOM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769864187436.9443840353573; Mon, 22 May 2023 08:37:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Wd-0007bF-HK; Mon, 22 May 2023 11:32: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 1q17Wc-0007Z7-6b for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:42 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17Wa-0001Tm-H5 for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:41 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3078d1c8828so5996737f8f.3 for ; Mon, 22 May 2023 08:32:39 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id f15-20020a0560001b0f00b00307acec258esm8082350wrz.3.2023.05.22.08.32.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769558; x=1687361558; 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=zbYgJ/CF6X8oXk1c18I3fiTWkENuu1esnlnJzdOgw0U=; b=sQTsuO1+IR3wG1880nFla6zQQ4pT1gMu2cJlzad94PzBKPVJQZ1U+TWNTTNFvSXnEk S5E+9kvIAUfjTOolpryQJJLDJaL4mkJ5AK3rL5Gd1X3q+j1KYU/ivJH5OScWV+fEDSvv /IWAEWg/EpFl/t/nb1SmEBVCbuqMW7cEKesoiLB1uF1B2iJczBnDt+bzz3tBXpu0WM9R Thwuq0eIgb36ABh/BtBlJYuMSM+pYVEsjStML30tSr7ngWXXZ5tHnQB+z3Lx10VhZUW7 qhQylGRGA5IJT1WBRbw1Atx4k0whDA2qDQM7BrQiPDZfgDRkVNyylKwexiX121ORirQ2 v1Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769558; x=1687361558; 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=zbYgJ/CF6X8oXk1c18I3fiTWkENuu1esnlnJzdOgw0U=; b=MTXd2qiItqTS0RAUX8OxAPNCQ04yDqvtcL7BsUlQy+6G0W2WNhD9TwISwZhcXnlDbG ZidpUS+6Z/AmuH8udgdGt3QzEhbN6o/4R3W3c88XwftacositUZmRZa0N8FjVHbTMkP+ FtkGbg9FPA6PrrO/9ohd69n5V8u9jB+KidZY8uDOroTP8mNCFuo3Fr63syNfk+Lq7zP5 gs4tFeQSpPN3uvWALRqii6SaWTD4JvpiKO4itGLm7G54qBrQ1oe44yaRO/bHmBUpDwx3 8x48TEGEQcqg3FlGw1p3/AFacYBDwabzh8px9nJMxELeZ2OfI5uVs3jJQWsElM9b5mjz MaZw== X-Gm-Message-State: AC+VfDzEIkI85/82ONlsRa6awuJtExRCiHxTT883nnqw1gvM6FG5Qyjl yO+sxwTlJ/PPqOVcKzO8sLlpI47aATC/oOxW3ss= X-Google-Smtp-Source: ACHHUZ5HXvOYmrb1/Rt7YTNlFxzOSDqkPd+oX8zm7imtF+5ZhV72MJMEdczweHN95gDKYUOPqDPzUA== X-Received: by 2002:a5d:44cf:0:b0:309:54b6:33b0 with SMTP id z15-20020a5d44cf000000b0030954b633b0mr7758639wrr.44.1684769557960; Mon, 22 May 2023 08:32:37 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 09/12] hw/char/pl011: Check if transmitter is enabled Date: Mon, 22 May 2023 17:31:41 +0200 Message-Id: <20230522153144.30610-10-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769865530100005 Do not transmit characters when UART or transmitter are disabled. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- hw/char/pl011.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index c55ef41fbf..30bedeac15 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -76,6 +76,10 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Cha= rdev *chr) #define LCR_FEN (1 << 4) #define LCR_BRK (1 << 0) =20 +/* Control Register, UARTCR */ +#define CR_TXE (1 << 8) +#define CR_UARTEN (1 << 0) + static const unsigned char pl011_id_arm[8] =3D { 0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; static const unsigned char pl011_id_luminary[8] =3D @@ -151,7 +155,9 @@ static inline void pl011_reset_tx_fifo(PL011State *s) =20 static void pl011_write_tx(PL011State *s, const uint8_t *buf, int length) { - /* ??? Check if transmitter is enabled. */ + if (!(s->cr & (CR_UARTEN | CR_TXE))) { + return; + } =20 /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769794; cv=none; d=zohomail.com; s=zohoarc; b=ll17ev4PaNly5wOFS+dvAtPQq/Qa0YWitUklWUUqXGXujh77JvYirp1AP+vJcfN09e6ZH6bbSjuB8SptT79SrxrEPpgwlBE3Xf3ci19QpDTYT1UUivGjcrmr2PXgHxLvj+C5XfoxSHiHKbctiD32GBFIbHztqZr9/nC9Y8UKVwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769794; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0Cw30KRr0qwwjcjVLXiu2a6Jw/GDPIIDdtlKN9G+WEg=; b=PosZBIFgxS+Rat30wVv/pNdCq52dVtEkIe5s2Pe60NM6DpuY/5N0NZbKzGJ2X3P7WP8Es2+qMvjsrG/Vv8CIzUi6+TNCtnuT+zxrC9hPkXcNTUonWV90luIovTTj1lm8vgB1laGF/y+Srj6U6gavNb/mnQ8dq9AiGiNPWWZLdW8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769794827517.7008850601195; Mon, 22 May 2023 08:36:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Wi-0007hu-CD; Mon, 22 May 2023 11:32:48 -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 1q17Wh-0007fR-0B for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:47 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17Wf-0001W1-5N for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:46 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f606a89795so8951065e9.2 for ; Mon, 22 May 2023 08:32:44 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id j17-20020adfea51000000b003063938bf7bsm8019037wrn.86.2023.05.22.08.32.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769563; x=1687361563; 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=0Cw30KRr0qwwjcjVLXiu2a6Jw/GDPIIDdtlKN9G+WEg=; b=jZVIhtxgsZKCPAyVJ1rubFhXRwSyB8yBf951IXSK22A8pvhlLdv9fEUSwo8Md8NWYg Fdgor+NAr64RrgZ+I653NYWxogB3UAB0pJQVVpsKh1gBDJqW3az+RCeMONd8U/cI8z+h SyS0IGSDNWx5h0Wdg5PaTsEsmUgg0gLB2GomrRRN9Pq4kIExCWsgDrRFhH/YFIw9234z BJYmoNeW8LkTcQ/xWT4BE1pLU6XpJMKTmZgdVfNmZrrGibgtwqMLOC4KlQkvHCU+yDd/ giRI1DsGTdZp9YkuRb3sVO7arCM0qlqHOfZwBKEQW+CueT00kbQxWyEsWqQThmwYnepE Jraw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769563; x=1687361563; 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=0Cw30KRr0qwwjcjVLXiu2a6Jw/GDPIIDdtlKN9G+WEg=; b=jgwOXxmTIa3H8AiwChXtXaxvWHFR3dMb0YXHYWW9NuVtLEFhAzsU1j8mIb8N2rzgZb hSsrBQgK8AJVAncja4rkb4ehCpiXHRmoYe4Yboz8wnG1yKja+aHxZff1X1GCWqHsumth FN7G59gdQwZqNLm4lfmIUWsrS55xTTFD/7hZsR5KRaK42XhHiPy2DkLVoAcUMHsJyPwp +0jYOfpSwHK/9uYdMzCnM22bdlbTh69tMIWaa3zklaJncdjCrNrkNJp8+oSBI2Id/4vE cqLuFUELCbYJ/5BIt7s2k2uZO7yMK15LNp23eMBNTGF2dOzYttq12eGam1ATDOWTnII/ yh7A== X-Gm-Message-State: AC+VfDwRu48L5XrmVHf7jrORldPV76SKIk4itYw0Bz1pAsiPec0P19VA HepdClA/XzHPNdLuhcJEcykKs64mpw0YMZTp8cg= X-Google-Smtp-Source: ACHHUZ7V+Ar12+UJMLcbWfJE71sPxCd6cPLuMDkPRtta0A4DvstrTKk/Jri6QgCzk2oKZJjqCMvO7g== X-Received: by 2002:a05:600c:22d7:b0:3f6:8f5:f9e4 with SMTP id 23-20020a05600c22d700b003f608f5f9e4mr200948wmg.35.1684769563339; Mon, 22 May 2023 08:32:43 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 10/12] hw/char/pl011: Check if receiver is enabled Date: Mon, 22 May 2023 17:31:42 +0200 Message-Id: <20230522153144.30610-11-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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, T_SCC_BODY_TEXT_LINE=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769796001100001 Do not receive characters when UART or receiver are disabled. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- 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 30bedeac15..1ec102d8de 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -77,6 +77,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Char= dev *chr) #define LCR_BRK (1 << 0) =20 /* Control Register, UARTCR */ +#define CR_RXE (1 << 9) #define CR_TXE (1 << 8) #define CR_UARTEN (1 << 0) =20 @@ -348,9 +349,11 @@ static void pl011_write(void *opaque, hwaddr offset, static int pl011_can_receive(void *opaque) { PL011State *s =3D (PL011State *)opaque; - int r; + int r =3D 0; =20 - r =3D s->read_count < pl011_get_fifo_depth(s); + if (s->cr & (CR_UARTEN | CR_RXE)) { + r =3D s->read_count < pl011_get_fifo_depth(s); + } trace_pl011_can_receive(s->lcr, s->read_count, r); return r; } --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769845; cv=none; d=zohomail.com; s=zohoarc; b=HGI60vs9pvUwc9EW/aYsClUrZUwiL3WELYjyML4iE3pal1x/ajvqcvO6vZ+eCoIvP8EhcOSGg6fOwqMmhhKoRKbItylJjyh45u52fHvZkFI0i1WqXIVwd/6I3tzfpPr7Fo6Tcn99/VBjlP/tdWfG6/Rrw7D+z2eUHPY5SnjbC8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769845; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A4NEdvvVpuVzw0Qn5uC2iypDr0fWHEDLqqeZGtVwP7o=; b=UY3UQncKMNfiCWftmgdFXohyYMmXVXzQ6XuErqNRm79dwVLJmBrahwfncKBxTu2/u/deYTSRGOcUJARiB41WkLPv1QtyKpwN6Z83deSz0W9e3yhdI1zHBMsk6f/SRDTo63sR5ChlIkZ40Pgts2ukdnXZAn48XvzHCf8A7hfMlpE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769845535612.78450995516; Mon, 22 May 2023 08:37:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Ws-0007l6-8a; Mon, 22 May 2023 11:32:58 -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 1q17Wo-0007kN-8T for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:54 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17Wk-0001WZ-HW for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:53 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3078cc99232so5978155f8f.3 for ; Mon, 22 May 2023 08:32:50 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id y11-20020adff6cb000000b003063a1cdaf2sm8046868wrp.48.2023.05.22.08.32.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769569; x=1687361569; 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=A4NEdvvVpuVzw0Qn5uC2iypDr0fWHEDLqqeZGtVwP7o=; b=bb/CPJDlZE3O8+Gr6hYx0FTiPCVvThuj/wbwKpHTQ6taKkcCafnD0RUUdXqgOQdTfP vZCL5mKUV0TGhagPeetazHKAhjwh94/TFmOWrB8v4jzILm0YXtNmfob0TPTIXiuoGWWE 7n77wj/R4gFxkF0YA9mygsxMHho1a6ZQYDJjiKJmktaGifNR2O8yKOxE28imuCglHntg xmm0obzCX/wASoYmjRYiDAY2IicsVSfmsI13NXleKZ2tWDi0O2+Mq12rk7xK3Gbplm2M zK5ykPaLQZzpoH++aPOQ5vr4TmnuqgYpmAwQBGmy3e12PRbVB6yakD7jCmm11a3suFbr mWaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769569; x=1687361569; 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=A4NEdvvVpuVzw0Qn5uC2iypDr0fWHEDLqqeZGtVwP7o=; b=dbiCkvMc+2VzJxfnPw/t9aaefKhzg6tdm2JEe/d2RxFIYcUHlVUrDZjJN8SEr853dc Imm1Lj5CxmxGHpC+hVeW987HbGONp5J4wq33dErJFbWaZJx1T86n284DCG2UoJiy5zy8 89mxg0R+2Rul5EZWFWQRqYvR9tz++DCODIdJ4LAIyaJcM0NCCOYUcsubzBFamd6a/KHu XKzJDT/AOaX89fvsX4VLZcvYXHSe9GFEgWl/qPDuyicKfwRoHpKseU+9nl0c0DRj7Yxm JPa8HHBTGZJ6nAt7LN4JfsXc1CGbeRomXu6d/f18wieOmaxu77G7G+YYcecumtxxBjxx cz8g== X-Gm-Message-State: AC+VfDxf6GrD8Rs7Q15Yhgizp0xIapblhMjV2/fPBc3h+XcXkWN1O1KL /qkfyL85uyL5PeuCivGwIEv7jEEgkiO0oCp64y4= X-Google-Smtp-Source: ACHHUZ5kQAl8ogeBWflbUQH7VYByjmF9Lr4XrWPrssj6qCYYRRwUqy0QOvlSEPJGjxuaXYR2Jt+F6w== X-Received: by 2002:adf:cf11:0:b0:306:36b5:8ada with SMTP id o17-20020adfcf11000000b0030636b58adamr7958771wrj.29.1684769568907; Mon, 22 May 2023 08:32:48 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 11/12] hw/char/pl011: Rename RX FIFO methods Date: Mon, 22 May 2023 17:31:43 +0200 Message-Id: <20230522153144.30610-12-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769846469100001 In preparation of having a TX FIFO, rename the RX FIFO methods. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e --- 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 1ec102d8de..03c006199e 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -358,7 +358,7 @@ static int pl011_can_receive(void *opaque) return r; } =20 -static void pl011_put_fifo(void *opaque, uint32_t value) +static void pl011_fifo_rx_put(void *opaque, uint32_t value) { PL011State *s =3D (PL011State *)opaque; int slot; @@ -369,9 +369,9 @@ static void pl011_put_fifo(void *opaque, uint32_t value) s->read_fifo[slot] =3D value; s->read_count++; s->flags &=3D ~PL011_FLAG_RXFE; - trace_pl011_put_fifo(value, s->read_count); + trace_pl011_fifo_rx_put(value, s->read_count); if (s->read_count =3D=3D pipe_depth) { - trace_pl011_put_fifo_full(); + trace_pl011_fifo_rx_full(); s->flags |=3D PL011_FLAG_RXFF; } if (s->read_count =3D=3D s->read_trigger) { @@ -382,13 +382,13 @@ static void pl011_put_fifo(void *opaque, uint32_t val= ue) =20 static void pl011_receive(void *opaque, const uint8_t *buf, int size) { - pl011_put_fifo(opaque, *buf); + pl011_fifo_rx_put(opaque, *buf); } =20 static void pl011_event(void *opaque, QEMUChrEvent event) { if (event =3D=3D CHR_EVENT_BREAK) { - pl011_put_fifo(opaque, DR_BE); + pl011_fifo_rx_put(opaque, DR_BE); } } =20 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 *reg= name) "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%0= 3x value 0x%08x reg %s" pl011_can_receive(uint32_t lcr, int read_count, int r) "LCR 0x%08x read_co= unt %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 ", f= brd: %" PRIu32 ")" =20 # cmsdk-apb-uart.c --=20 2.38.1 From nobody Sat May 18 19:24:20 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1684769848; cv=none; d=zohomail.com; s=zohoarc; b=BwL9T+QI+jD5ae/q11OBX510UvwmTzeYkbHGqQr28dtfH3dcEWddx/OfPnKotSCADIWgxT+P9Sy2hSlitBf8zXTz8360KBkYaKFML5rcqw0gV53Us6OSGMiOahbVKHuYgNGAKC2pQfUjtoJ7FONO9UxLeVYsd3JL7/tsD7xMHiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684769848; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lE3AFLRBDeHmAd75tRobhpSnEmgT2M+g2etmHg9JWDI=; b=H8xGqDt1TMwHqLnf5k439/0nrCDZho55u5JiOoF4JS5XEKFQCOei47doObG+eppukWFfPBTXeUY4Rq42yzduh5Jzk+rihSBpICJz8WDyopbTZFGNNiMar0F2W9AvM0StnXRAUz9yWk9XDRcrIGk2YpV2S73qJ/p55/DsDDIkAR0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684769848969288.48949591947246; Mon, 22 May 2023 08:37:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q17Wv-0007o3-2l; Mon, 22 May 2023 11:33:01 -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 1q17Ws-0007m1-UN for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:59 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q17Wp-0001Sb-Vh for qemu-devel@nongnu.org; Mon, 22 May 2023 11:32:58 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f42c86543bso40698035e9.3 for ; Mon, 22 May 2023 08:32:55 -0700 (PDT) Received: from localhost.localdomain ([176.176.153.164]) by smtp.gmail.com with ESMTPSA id o3-20020a05600c378300b003f4f8cc4285sm8674869wmr.17.2023.05.22.08.32.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 May 2023 08:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684769575; x=1687361575; 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=lE3AFLRBDeHmAd75tRobhpSnEmgT2M+g2etmHg9JWDI=; b=q9nke18z0/+Mg9Q+nIwUINvI+Yse7bF2z1947OEzoTG6vk5SHi95KEIBqw0TvQe6jS XKhcRyQ83B7ClLUigsD+gZa9JqHpC6tQNnaf801rZni4UaPbJIj3ENK9aY4ztv1Il4RJ 1d4eqYP5pkX/7yn3oodHvzzPgY0Nhp+6ge+AEYD3kYcLDb8eKIYSKDBNTzdnA+1C2E4i AhgDDRR6bjr9Anw2b3rSn0Q0dDCKYtHn1y9c4gCJJH+8/1kpNhPHSjePq0MTmYwiNAeY AoG2FSksrIyFC0IEfQwlB3HNTfcp105k4zXS7ZJDuAS70Blsnk31qJUbuUlWkfWN3Gc5 1VrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684769575; x=1687361575; 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=lE3AFLRBDeHmAd75tRobhpSnEmgT2M+g2etmHg9JWDI=; b=AxncAzDsKcOGjdvKPFu2fMrfccPx7wXJjVsn3eYMYT4T+fVTYm9K6nK/899w3Ixn/P 29ZF6BWZ17sAaELAd76z9NxS2+LnhnBUXaaMgGzkIjVZQ91oBEmRpJAo8moXclGo+Au6 MU38Ijt35e1gW8hud5MLMGdo6PnZrMKHpXIPLpog+4lpSzRzwnhTJz6QZsOOPr62eS9y F2AoTlgH6FaWvUWoYkgNuYa25XHzx6p5kDHz4hFki5vfEF3GfZL4ikG7/lZuPTvKyMmh vcTOLjUYky3eLE4WIfRAw+bqydpuL3gRrF4/v010lkIc098jOfwn8MCtW+HbbMK1CFPu Zf7A== X-Gm-Message-State: AC+VfDxpfed1vEVapBMP5UGMoWmx3iYNJSrZaK+JU1eVUvUNTpqh/wvn 1LXHndFkctVJhJfKPSgYp4mpeiwslYTQjy8//lM= X-Google-Smtp-Source: ACHHUZ5iOb7zJShU7RpQ6rQOYLEt2EVDHtUK9BII9rZfcgbH/iITSg5pZMQA0r1BgbZsNqhAYxfunw== X-Received: by 2002:a7b:c390:0:b0:3f4:2805:c3a with SMTP id s16-20020a7bc390000000b003f428050c3amr8063059wmj.21.1684769574891; Mon, 22 May 2023 08:32:54 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Evgeny Iakovlev , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mikko Rapeli Subject: [PATCH 12/12] hw/char/pl011: Implement TX FIFO Date: Mon, 22 May 2023 17:31:44 +0200 Message-Id: <20230522153144.30610-13-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230522153144.30610-1-philmd@linaro.org> References: <20230522153144.30610-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1684769850363100003 If the UART back-end chardev doesn't drain data as fast as stdout does or blocks, buffer in the TX FIFO to try again later. This avoids having the IO-thread busy waiting on chardev back-ends, reported recently when testing the Trusted Reference Stack and using the socket backend: https://linaro.atlassian.net/browse/TRS-149?focusedCommentId=3D149574 Implement registering a front-end 'watch' callback on back-end events, so we can resume transmitting when the back-end is writable again, not blocking the main loop. Similarly to the RX FIFO path, FIFO level selection is not implemented (interrupt is triggered when a single byte is available in the FIFO). Due to the addition of the TX FIFO in the instance state, increase the migration stream version. Reported-by: Mikko Rapeli Suggested-by: Alex Benn=C3=A9e Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- RFC because I'm pretty sure I got the migration code wrong. After writing this I noticed the hw/char/cmsdk-apb-uart.c model is much more complete. Instead of copy/pasting its code, I'd rather try to extract some generic/bstract "FIFO based chardev" QOM class; but this is beyond the scope of this series. --- include/hw/char/pl011.h | 2 + hw/char/pl011.c | 105 +++++++++++++++++++++++++++++++++++++--- hw/char/trace-events | 4 ++ 3 files changed, 105 insertions(+), 6 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" =20 #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; }; =20 DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr); diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 03c006199e..a957138405 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -57,6 +57,9 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Char= dev *chr) /* Data Register, UARTDR */ #define DR_BE (1 << 10) =20 +/* Receive Status Register/Error Clear Register, UARTRSR/UARTECR */ +#define RSR_OE (1 << 3) + /* Interrupt status bits in UARTRIS, UARTMIS, UARTIMSC */ #define INT_OE (1 << 10) #define INT_BE (1 << 9) @@ -152,19 +155,94 @@ static inline void pl011_reset_tx_fifo(PL011State *s) /* Reset FIFO flags */ s->flags &=3D ~PL011_FLAG_TXFF; s->flags |=3D PL011_FLAG_TXFE; + + fifo8_reset(&s->xmit_fifo); +} + +static gboolean pl011_drain_tx(PL011State *s) +{ + trace_pl011_fifo_tx_drain(fifo8_num_used(&s->xmit_fifo)); + pl011_reset_tx_fifo(s); + s->rsr &=3D ~RSR_OE; + return FALSE; +} + +static gboolean pl011_xmit(void *do_not_use, GIOCondition cond, void *opaq= ue) +{ + PL011State *s =3D opaque; + int ret; + const uint8_t *buf; + uint32_t buflen; + uint32_t count; + + if (!qemu_chr_fe_backend_connected(&s->chr)) { + /* Instant drain the fifo when there's no back-end */ + return pl011_drain_tx(s); + } + + count =3D fifo8_num_used(&s->xmit_fifo); + if (!count) { + return FALSE; + } + if (!(s->cr & CR_UARTEN)) { + /* Allow completing the current FIFO character before stopping. */ + count =3D 1; + } + + /* Transmit as much data as we can */ + buf =3D fifo8_peek_buf(&s->xmit_fifo, count, &buflen); + ret =3D qemu_chr_fe_write(&s->chr, buf, buflen); + if (ret >=3D 0) { + /* Pop the data we could transmit */ + trace_pl011_fifo_tx_xmit(ret); + fifo8_pop_buf(&s->xmit_fifo, ret, NULL); + s->int_level |=3D INT_TX; + } + + if ((s->cr & CR_UARTEN) && !fifo8_is_empty(&s->xmit_fifo)) { + /* Reschedule another transmission if we couldn't transmit all */ + guint r =3D qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, + pl011_xmit, s); + if (!r) { + return pl011_drain_tx(s); + } + } + + pl011_update(s); + + return FALSE; } =20 static void pl011_write_tx(PL011State *s, const uint8_t *buf, int length) { if (!(s->cr & (CR_UARTEN | CR_TXE))) { + if (!fifo8_is_empty(&s->xmit_fifo)) { + /* + * If the UART is disabled in the middle of transmission + * or reception, it completes the current character before + * stopping. + */ + pl011_xmit(NULL, G_IO_OUT, s); + } return; } =20 - /* XXX this blocks entire thread. Rewrite to use - * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&s->chr, buf, 1); - s->int_level |=3D INT_TX; - pl011_update(s); + if (length > fifo8_num_free(&s->xmit_fifo)) { + /* + * The FIFO contents remain valid because no more data is + * written when the FIFO is full, only the contents of the + * shift register are overwritten. The CPU must now read + * the data, to empty the FIFO. + */ + trace_pl011_fifo_tx_overrun(); + s->rsr |=3D RSR_OE; + return; + } + + trace_pl011_fifo_tx_put(length); + fifo8_push_all(&s->xmit_fifo, buf, length); + + pl011_xmit(NULL, G_IO_OUT, s); } =20 static uint64_t pl011_read(void *opaque, hwaddr offset, @@ -444,12 +522,17 @@ static int pl011_post_load(void *opaque, int version_= id) s->read_pos =3D 0; } =20 + if (version_id >=3D 3 && !fifo8_is_empty(&s->xmit_fifo)) { + /* Reschedule another transmission */ + qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, pl011_xmit, s); + } + return 0; } =20 static const VMStateDescription vmstate_pl011 =3D { .name =3D "pl011", - .version_id =3D 2, + .version_id =3D 3, .minimum_version_id =3D 2, .post_load =3D pl011_post_load, .fields =3D (VMStateField[]) { @@ -462,6 +545,7 @@ static const VMStateDescription vmstate_pl011 =3D { VMSTATE_UINT32(int_enabled, PL011State), VMSTATE_UINT32(int_level, PL011State), VMSTATE_UINT32_ARRAY(read_fifo, PL011State, PL011_FIFO_DEPTH), + VMSTATE_FIFO8(xmit_fifo, PL011State), VMSTATE_UINT32(ilpr, PL011State), VMSTATE_UINT32(ibrd, PL011State), VMSTATE_UINT32(fbrd, PL011State), @@ -505,10 +589,18 @@ static void pl011_realize(DeviceState *dev, Error **e= rrp) { PL011State *s =3D PL011(dev); =20 + fifo8_create(&s->xmit_fifo, PL011_FIFO_DEPTH); qemu_chr_fe_set_handlers(&s->chr, pl011_can_receive, pl011_receive, pl011_event, NULL, s, NULL, true); } =20 +static void pl011_unrealize(DeviceState *dev) +{ + PL011State *s =3D PL011(dev); + + fifo8_destroy(&s->xmit_fifo); +} + static void pl011_reset(DeviceState *dev) { PL011State *s =3D PL011(dev); @@ -534,6 +626,7 @@ static void pl011_class_init(ObjectClass *oc, void *dat= a) DeviceClass *dc =3D DEVICE_CLASS(oc); =20 dc->realize =3D pl011_realize; + dc->unrealize =3D pl011_unrealize; dc->reset =3D pl011_reset; dc->vmsd =3D &vmstate_pl011; device_class_set_props(dc, pl011_properties); diff --git a/hw/char/trace-events b/hw/char/trace-events index 9fd40e3aae..4c25564066 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -60,6 +60,10 @@ pl011_write(uint32_t addr, uint32_t value, const char *r= egname) "addr 0x%03x val pl011_can_receive(uint32_t lcr, int read_count, int r) "LCR 0x%08x read_co= unt %d returning %d" 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_fifo_tx_put(int count) "TX FIFO push %d" +pl011_fifo_tx_xmit(int count) "TX FIFO pop %d" +pl011_fifo_tx_overrun(void) "TX FIFO overrun" +pl011_fifo_tx_drain(unsigned drained) "TX FIFO draining %u" pl011_baudrate_change(unsigned int baudrate, uint64_t clock, uint32_t ibrd= , uint32_t fbrd) "new baudrate %u (clk: %" PRIu64 "hz, ibrd: %" PRIu32 ", f= brd: %" PRIu32 ")" =20 # cmsdk-apb-uart.c --=20 2.38.1