From patchwork Fri Jul 19 18:10:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813414 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877795wro; Fri, 19 Jul 2024 11:13:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVUH2DFgC1jjK/I90EzXLc8yarxW2z68pPu/hxwMkV3FXaS2hhS+nJjAnG5f7ktIhDFGjEqlH2t+Fye2fqFm+1v X-Google-Smtp-Source: AGHT+IGUHZFotG/7xKsw2xGsDhPhatnHIm3EmKltyYcn8EpeMCv1KwjQlWOAr9CUk/OKVMqa1wCM X-Received: by 2002:a05:6830:dc3:b0:703:5ab9:b0bc with SMTP id 46e09a7af769-708fdb0fa51mr655138a34.11.1721412807210; Fri, 19 Jul 2024 11:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412807; cv=none; d=google.com; s=arc-20160816; b=FOY+/c7Pay0dGzbBvMj3++Ge2aDYvWTEnDbp4gq+JSaSxhHLNtFqHrC2Fh0bvxuKfb tGVsFzu7yw8TGrxdZSuUY59JIDNP3wmnhpDyUFDZPbaK7c8/bijlrVobDMObj1Bzngvs saDRYha96XLRLdfB4E96zKfTbmuS+Z+uuUoEHZ/+RUEqATBmFoOoBpWxGqipeiYLWmb8 HkEkQgPK10gx7fEprxOQcbKgwkErLBjxpi8UsP046EQ7L45bZM27b8DVPXsYbFmYXdJB z8MN5BY0nS5S35kTMJTDPuBciqurMdHJJ/yaihadLjVRLklDPYHUgvKffZk64btSeKRt qVBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YFJ4F+v2FoWmOAeJ1TmNHGk/Gzzzixlx237F5Z9Ojzw=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=ZWLO9Ym+teb2Q6DQUHvi1UD0jgupBPzb4qSmk5BdOBjiVBirHbz937586+7d7x13p6 3oPgVGTljFkYy76EDKKTezhmrCh2FGCspBSNMAsrDxQH0Ewwxz799JMkGFrqIjNO1OhV YoYmEwnc8VaFU1UfOoRZOdz4342QpMcoQXcl/TP5YfRjOhVGBtS0KRUIDg3m6PZsk8zy bWK3tW+IHMGiq8HHbthh1DH5BbNtXqYXewVJx7sMsNd7IhlXfjMKZ6Cis2zmEFC7hn9Q OVhWbFGCPy5ozj3iOgXPfPPa9optU2DXzL2hBtIosVGwNOFZcWMwoAtkjguD4X7lBWcb 140A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VBETMt0H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a1990aa4fcsi219691485a.683.2024.07.19.11.13.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:13:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VBETMt0H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs4I-0001dM-7m; Fri, 19 Jul 2024 14:10: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 1sUs4G-0001Tl-M9 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:10:56 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs4D-0003g5-AU for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:10:56 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4266edee10cso13003065e9.2 for ; Fri, 19 Jul 2024 11:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412651; x=1722017451; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YFJ4F+v2FoWmOAeJ1TmNHGk/Gzzzixlx237F5Z9Ojzw=; b=VBETMt0H49QZlZi7ww/N4jyVRsKizfTYdwpwYRgrmaJqrP8aBh7sEADN0/nSIuf0Ve vRUXG+tQdAdrjFiPf1lwvLaAixfPdimGUgPjC8fZ2aKKofge7zaIsxREYjKvmhzAhblV uNV1WxnVoXWEz2ZM5jLjawToHeURHca/n7sfOLIlhSTEJnEw3hkSTtbL+TZayMLZbGE2 DmFwnGMv5XmJebMnoXxXptDKDywqIHeI+cQrU5sNE0WZi+FLxKu+YmpxH8rYDUKSvCV8 nPqTsZPpFbQ21wBYZSERdOgQl520P+jBbPHDAHCkCIOlhMSJB/5ZqWXlvIq69ubdJZ47 BLow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412651; x=1722017451; 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=YFJ4F+v2FoWmOAeJ1TmNHGk/Gzzzixlx237F5Z9Ojzw=; b=keofp2rbttagmwpaTYRfhgynVGcSGCHDDkPtQB4aJolIomlOVFUHFIVRjSLMK3f6Vz D+CO9eSJh6J5/XtwfHoPJJqBeCXDCl80+B4OuLju53PC/sl5/mnZRy4EitFYpncmweKT cqPNJLpU1D2fnW5mPy+q0AIrBi8JkPVLLUWuXSQubfDIIHfA6XZzER36iDleyuISMIDq Ni51MjnmEWpkotysekTzQWxdN3WUO536g0ZHO9aPUWNqFcSlcEABeFnezFyThI8G1anr KcatmbVIAMD/aDudib9XIKKiKsU1qYjQikzD2/mc+/4kiJg9bRLDG5zLV9aaoxCF2J58 PNug== X-Gm-Message-State: AOJu0YytvAmDTAR1T0gG174AKayP068JunLjdB88qW/mhmR93fHKInPx pA4VLUvYkOQ2TD4ujGHee2QBI98dl69MNjzcC/Pep2QflzVpFCAymrZHKqGn4zabB6U7f6faK/C T X-Received: by 2002:a05:600c:1d96:b0:426:5ee3:728b with SMTP id 5b1f17b1804b1-427daa28651mr1991465e9.13.1721412651427; Fri, 19 Jul 2024 11:10:51 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a3c0fasm61914525e9.7.2024.07.19.11.10.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:10:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 01/16] tests/avocado: Add 'device:pl011' tag to tests exercising PL011 UART Date: Fri, 19 Jul 2024 20:10:26 +0200 Message-ID: <20240719181041.49545-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add the 'device:pl011' tag to various tests using the PL011 UART, so we can run them all at once using: $ make check-avocado AVOCADO_TAGS='device:pl011' Signed-off-by: Philippe Mathieu-Daudé --- tests/avocado/boot_linux.py | 1 + tests/avocado/boot_linux_console.py | 2 ++ tests/avocado/boot_xen.py | 1 + tests/avocado/machine_aarch64_sbsaref.py | 1 + tests/avocado/machine_aarch64_virt.py | 1 + tests/avocado/smmu.py | 1 + tests/avocado/tuxrun_baselines.py | 5 +++++ 7 files changed, 12 insertions(+) diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py index df6cf209ef..6717f452eb 100644 --- a/tests/avocado/boot_linux.py +++ b/tests/avocado/boot_linux.py @@ -70,6 +70,7 @@ class BootLinuxAarch64(LinuxTest): def test_virt_kvm(self): """ :avocado: tags=machine:virt + :avocado: tags=device:pl011 :avocado: tags=accel:kvm :avocado: tags=cpu:host """ diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py index c35fc5e9ba..f595324979 100644 --- a/tests/avocado/boot_linux_console.py +++ b/tests/avocado/boot_linux_console.py @@ -362,6 +362,7 @@ def test_arm_virt(self): """ :avocado: tags=arch:arm :avocado: tags=machine:virt + :avocado: tags=device:pl011 :avocado: tags=accel:tcg """ kernel_url = ('https://archives.fedoraproject.org/pub/archive/fedora' @@ -1380,6 +1381,7 @@ def test_arm_vexpressa9(self): """ :avocado: tags=arch:arm :avocado: tags=machine:vexpress-a9 + :avocado: tags=device:pl011 """ tar_hash = '32b7677ce8b6f1471fb0059865f451169934245b' self.vm.add_args('-dtb', self.workdir + '/day16/vexpress-v2p-ca9.dtb') diff --git a/tests/avocado/boot_xen.py b/tests/avocado/boot_xen.py index 93bfb0c161..c4c01afa76 100644 --- a/tests/avocado/boot_xen.py +++ b/tests/avocado/boot_xen.py @@ -66,6 +66,7 @@ class BootXen(BootXenBase): :avocado: tags=accel:tcg :avocado: tags=cpu:cortex-a57 :avocado: tags=machine:virt + :avocado: tags=device:pl011 """ def test_arm64_xen_411_and_dom0(self): diff --git a/tests/avocado/machine_aarch64_sbsaref.py b/tests/avocado/machine_aarch64_sbsaref.py index e920bbf08c..f04ac2b11c 100644 --- a/tests/avocado/machine_aarch64_sbsaref.py +++ b/tests/avocado/machine_aarch64_sbsaref.py @@ -20,6 +20,7 @@ class Aarch64SbsarefMachine(QemuSystemTest): """ :avocado: tags=arch:aarch64 :avocado: tags=machine:sbsa-ref + :avocado: tags=device:pl011 :avocado: tags=accel:tcg As firmware runs at a higher privilege level than the hypervisor we diff --git a/tests/avocado/machine_aarch64_virt.py b/tests/avocado/machine_aarch64_virt.py index 0ef6df4b0d..2d586c8459 100644 --- a/tests/avocado/machine_aarch64_virt.py +++ b/tests/avocado/machine_aarch64_virt.py @@ -23,6 +23,7 @@ class Aarch64VirtMachine(QemuSystemTest): """ :avocado: tags=arch:aarch64 :avocado: tags=machine:virt + :avocado: tags=device:pl011 """ KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' timeout = 360 diff --git a/tests/avocado/smmu.py b/tests/avocado/smmu.py index 4ebfa7128c..4b265e2435 100644 --- a/tests/avocado/smmu.py +++ b/tests/avocado/smmu.py @@ -21,6 +21,7 @@ class SMMU(LinuxTest): :avocado: tags=arch:aarch64 :avocado: tags=machine:virt :avocado: tags=distro:fedora + :avocado: tags=device:pl011 :avocado: tags=smmu :avocado: tags=flaky """ diff --git a/tests/avocado/tuxrun_baselines.py b/tests/avocado/tuxrun_baselines.py index 736e4aa289..98ab40bbb5 100644 --- a/tests/avocado/tuxrun_baselines.py +++ b/tests/avocado/tuxrun_baselines.py @@ -254,6 +254,7 @@ def test_arm64(self): :avocado: tags=arch:aarch64 :avocado: tags=cpu:cortex-a57 :avocado: tags=machine:virt + :avocado: tags=device:pl011 :avocado: tags=tuxboot:arm64 :avocado: tags=console:ttyAMA0 :avocado: tags=shutdown:nowait @@ -270,6 +271,7 @@ def test_arm64be(self): :avocado: tags=cpu:cortex-a57 :avocado: tags=endian:big :avocado: tags=machine:virt + :avocado: tags=device:pl011 :avocado: tags=tuxboot:arm64be :avocado: tags=console:ttyAMA0 :avocado: tags=shutdown:nowait @@ -285,6 +287,7 @@ def test_armv5(self): :avocado: tags=arch:arm :avocado: tags=cpu:arm926 :avocado: tags=machine:versatilepb + :avocado: tags=device:pl011 :avocado: tags=tuxboot:armv5 :avocado: tags=image:zImage :avocado: tags=console:ttyAMA0 @@ -306,6 +309,7 @@ def test_armv7(self): :avocado: tags=arch:arm :avocado: tags=cpu:cortex-a15 :avocado: tags=machine:virt + :avocado: tags=device:pl011 :avocado: tags=tuxboot:armv7 :avocado: tags=image:zImage :avocado: tags=console:ttyAMA0 @@ -324,6 +328,7 @@ def test_armv7be(self): :avocado: tags=cpu:cortex-a15 :avocado: tags=endian:big :avocado: tags=machine:virt + :avocado: tags=device:pl011 :avocado: tags=tuxboot:armv7be :avocado: tags=image:zImage :avocado: tags=console:ttyAMA0 From patchwork Fri Jul 19 18:10:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813408 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877525wro; Fri, 19 Jul 2024 11:12:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX6lMSMUhCDKhSLqdIwfcxWYeNKDoiwIq845WVkuEggzsuMqgi6pItd6CjlBDUiL3I91LdQaByBAoMvyFj1sgEW X-Google-Smtp-Source: AGHT+IE5KPCk+lr8dZYjvthsZDP3v7lLR5v14zjd61BWp7ejx6Jv2EfdF2HSQWZb4fPjOMmQ4VYz X-Received: by 2002:a05:620a:45a5:b0:79f:1873:5463 with SMTP id af79cd13be357-7a1a1309d07mr82230385a.6.1721412764809; Fri, 19 Jul 2024 11:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412764; cv=none; d=google.com; s=arc-20160816; b=G2ejIojJRNlU29xYanaH5Dr0W4FENE6X5/y2l5seDplsUqsAm1XmDJLdf9n7hSDmch NFsgfaImUW72hhEjRnWo/4pUYvd5yHufW8/doVnmDrKHVCSMg19SuA9FPsJ5lE3Ocq2t JYnthvrcYketBKcznurl5y8QYEOo7/kvCruySTaQG2Q7N1PqIZDV3vfUJHv58di7jFj/ il6EIEDOfY6+NxC9IqTiX4G3/AWisyKEubHv7BFsX6mPULh2+EyG7kDM0MLgWkEQd4oi p8IbJNHKxLO+bFbp6HdBg9q5TsrVI2SbI1IoHJjEmeTBlYWrs9jPcqfnZpu3P1WSu97P 9e9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=q1/EHJXKlUMSicfL7BY9ywX9D2Y7SpR4mdCel9zTlhc=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=bOc8euDPA0yZIak7cnBFgO2jxcZJKgjbC+1w15pM3ah4Yz3mqE3mg4TcbLuV6eHK5J JlIUQaF+cvHRv3NaszBDOzTxF0xV3T8XODqtxsfjiFvL1Oh2gkG7NUNamNOQzCpbclAy u9zW7IJXGUfIfA7tCjZji9WOXuo8O/2CB+J7ujFsedMK39rz+cTLFK4zr75YdvYLlwz/ pyPKhdn2FXdWrr6AIcfTzPtz+xoo5CIM1XBtQ8WJ0gcil5BpIQuq37ZOWWXOsZ3CTnYl wYtD6LNB25qqQ9+g9Kb+yq4stjO1v2t4Zh03TI7w416VbBxZW2x8+XZm8eNeQwZGHLAl dINQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=glagd9JJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a198f984bfsi219842285a.56.2024.07.19.11.12.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:12:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=glagd9JJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs4L-0001qt-S6; Fri, 19 Jul 2024 14:11: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 1sUs4K-0001mm-D8 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:00 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs4I-0003j9-Rs for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:00 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4266edee10cso13003745e9.2 for ; Fri, 19 Jul 2024 11:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412657; x=1722017457; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q1/EHJXKlUMSicfL7BY9ywX9D2Y7SpR4mdCel9zTlhc=; b=glagd9JJPvlW0574i9+zBvBeHneb6LLGuuFol6VVmx3tdmqlgnqy2K0HplpHqvztru 3X3AWinFxb5CYgEbCZGxuazu3SQZ6pJQzH9E9UjVKEbktNaSiR1Xh0WAaoJB6+PNrOEK Dm6UP7I5BlZ8MlX4gUsRUSXy/oSzcPcldTqMnmQhkJebIuOaoeqXRFMsGdrQSfOcp8hv WiZAuV0xYBB8SD0t++Q2FJz65DQ3OUHuOa4WBmIWZXe9MrxWRKfnLhznWpB0Ri9v3VNX jti6yM7AXWE2/K9YC1Hpn+0jRXLca6i0fCo5kXfLyGPmyrR2h5vnNKvs4JfdJCnJ8zRo Oivw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412657; x=1722017457; 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=q1/EHJXKlUMSicfL7BY9ywX9D2Y7SpR4mdCel9zTlhc=; b=Y7kmqOGEcmfIAydVdLStVfmO/dLkvyMtywLVgbubnDf9zhFaSlHolAJt4IGUJ3DuVk xcOXkyg2w86jn2PBs1Yy5Bd7b4K2LsDolYfeiq6w8fIMBHOocGQ8xTIDicit+khjMhjt KZK+YfAI7mB9sKuadi5FRTFtIyyoNooC6JCiE7n8y4DTm0Q5FSDKhpGfbW3LbnUjuNWa H1cLvlUeD8gUq4Z72BDv5y9OtoTN7sGR69R7Ah7jEEohW6sVdpq5hLz4yKVcgPt1MlPX WeM60MvOTf2VRpxEn+UDxSIALh299rJc6B00KbxQ7O2v5pRAPF1SYp7SESfvv0eLsbW+ 1pqA== X-Gm-Message-State: AOJu0YxNCPO1/Z50EQE6H9pdrCTAkkPRWQM4w2jK5pE4Vkhh7Nhz4oWy v6DvsWyzWK4TKFnMKkhq9Fgs5AdRb+wvh9N0lOIrOsd8bv/YFVg29Ncqja/3aDb/McHeRCxh6fj + X-Received: by 2002:adf:fa03:0:b0:367:8876:68e6 with SMTP id ffacd0b85a97d-3683175b8aamr6577658f8f.48.1721412657188; Fri, 19 Jul 2024 11:10:57 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878684801sm2258633f8f.11.2024.07.19.11.10.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:10:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 02/16] hw/char/pl011: Remove unused 'readbuff' field Date: Fri, 19 Jul 2024 20:10:27 +0200 Message-ID: <20240719181041.49545-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since its introduction in commit cdbdb648b7 ("ARM Versatile Platform Baseboard emulation.") PL011State::readbuff as never been used. Remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- include/hw/char/pl011.h | 1 - hw/char/pl011.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h index d853802132..4fcaf3d7d3 100644 --- a/include/hw/char/pl011.h +++ b/include/hw/char/pl011.h @@ -32,7 +32,6 @@ struct PL011State { SysBusDevice parent_obj; MemoryRegion iomem; - uint32_t readbuff; uint32_t flags; uint32_t lcr; uint32_t rsr; diff --git a/hw/char/pl011.c b/hw/char/pl011.c index f8078aa216..260f5fc0bc 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -549,7 +549,7 @@ static const VMStateDescription vmstate_pl011 = { .minimum_version_id = 2, .post_load = pl011_post_load, .fields = (const VMStateField[]) { - VMSTATE_UINT32(readbuff, PL011State), + VMSTATE_UNUSED(sizeof(uint32_t)), VMSTATE_UINT32(flags, PL011State), VMSTATE_UINT32(lcr, PL011State), VMSTATE_UINT32(rsr, PL011State), From patchwork Fri Jul 19 18:10:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813405 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877277wro; Fri, 19 Jul 2024 11:12:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXhJa1lgQDojFHfgf8DWg12WE95YOT6eYiLpK92sdchpvS2TGkIk8aNiQq//EshYAFwOsSSAS6/jZIRa15X2t7w X-Google-Smtp-Source: AGHT+IHxpgKqN43pxDoHgDPyWoydUOGA8SHq3Ba6kc90ywp7x21Dj1wsjzB7D45Iw2eQa/1bpxmn X-Received: by 2002:ad4:5aea:0:b0:6b5:26f7:76b5 with SMTP id 6a1803df08f44-6b78caf88e6mr125709896d6.7.1721412724914; Fri, 19 Jul 2024 11:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412724; cv=none; d=google.com; s=arc-20160816; b=kyFOhgdKZ4oq6uQDBQK17ZpTv8kHl0hsH2aSJqP7kz8HTzltEyNWxaIotNBqEcdd6f RB3pkth8wM/DfKOvRg3by2140OyOypLdQiVU5ZXGFP6IhJCRNtEi8GNwJdX+0afAc8Ts 91VmsSW1SlyAlbBDSNuDDpfB/QF3UfYs6ww9NX6t+fGrDLcwXRzyIYrYllIim6l9wBa4 JYgNwvW9rVjSmR0m/CHgyREjgGQemjWrQY0+88W0B4VVB+a1eGqdqtepNmpR8nIO6qSB lqbNodcRFVmF8gevuW+UhGCKld6xRFGKPXAj0NgbhP2rNYYYTz9XD4iFzFvrJgbwoKV2 CZ1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Pcbf3AvGHvD4fhRiEOLagM3LlfJ7dGGey9tdUSZ+O4Q=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=LH5I9vcID923hcFXaJbss/Qe4QEH0i0Y5tUUEDrTootGVF37G5ikSwC7Yw+DcoXsbZ xKuiOzO2IPqYK69OaYTaDXLpV8CTrEjXt8tzKQ1cdJLfL2FXz1c9srfRgdffonvr19tT ExcK3BdyLK+3FKMKcavnNxwERz+zRhmmgUXflBju9NAm37zXjBtyu+15LzqGTIEevIxu qwZ6PQtNm67b6iWPkHM7vXzYWmwMf6ytgGKxxraA+4ao+f0EV/2vd7Cgn9GrwUTV4mr3 FQF2n3VAzsxX69yuU1V8bMvkVAUOCqM2NogyoqvvYcItkYwbgZ3GR4moeUE+HxMbECZE wDZw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mhKZhomJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7ac999581si21743316d6.246.2024.07.19.11.12.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mhKZhomJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs4b-0002Es-Sl; Fri, 19 Jul 2024 14:11:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sUs4S-00029p-8k for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:09 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs4P-0003l5-27 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:07 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3685afd0c56so760932f8f.1 for ; Fri, 19 Jul 2024 11:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412663; x=1722017463; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pcbf3AvGHvD4fhRiEOLagM3LlfJ7dGGey9tdUSZ+O4Q=; b=mhKZhomJyM87Wnf33M27vaUvQnkhzXG5qTx9GbmHTTOxcPqxGmLBUQXkvtk0B6NwlB oEHREdYmApFHZt6UE5lriGCOuvZmxk8uL/tIP17jl1VCwFOh1UNgyhaHaPthbqDEhLSE Jkf2d9agKlW69TtapaqaAMjhxoLHs6L1uidVyfMFmWLs16tFKsEZbSsOMe/+voA31JRi SrQmdfsexzUwhnvgfdTriwCE9E3qOo1+MRxAXFSIZkQ5sEhxAhyCqnTb54YPNIk/SloC wXzZdD4dTenzZkk6ihcqeXpymQM2cIOcf9SYMWpvAVKwYuUYIleUqXCyehcGK8xg/Bev 0ERg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412663; x=1722017463; 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=Pcbf3AvGHvD4fhRiEOLagM3LlfJ7dGGey9tdUSZ+O4Q=; b=rpL7n6uxT58uesBHYs6lkJD3YTwbFLJcVMUByk8J4efcbm5zQ2b2PYiWEPsmsn+geG xL57cX9jYAEdyleEQ3m0zkC0QEgtMU02aIgq6F/qDlX6L05GWZ1k0J57MicFF7EJcVfb FmimhhbERAsJS3GX7v5zz+UZuNUnz2xDcZXVH9v7OG8P0MyfYmHy0zRlrFT1HJp2FiuD 40xCFhK6qeLu37bLrwmH6W8mH907jrhsQEVqOFcU2xK3jqBX5ov2HdMFHI6LrzxvwdrF wZjbUB2evQL58fpoNG+qvAufyWo3KueQnWSMp5Y2BN6sitqUvxuY9qlkz2c4e3/RPR6U F8hw== X-Gm-Message-State: AOJu0Yx6ZyMfLRa+mM7TWuJ8VWLpCKvIA4QNyDaGsSlIxU/CbcfkLYRE ek0ZviUZ7mLxpUg/tKwNYYQt4mpYdLyvOryZpAQ/BpnJM8zFLMTygan7MUv5JYDKefRQ5u/6PP2 V X-Received: by 2002:a5d:4cc4:0:b0:367:f054:7aba with SMTP id ffacd0b85a97d-3683175ce54mr5619270f8f.41.1721412663012; Fri, 19 Jul 2024 11:11:03 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868420fsm2231578f8f.3.2024.07.19.11.11.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 03/16] hw/char/pl011: Move pl011_put_fifo() earlier Date: Fri, 19 Jul 2024 20:10:28 +0200 Message-ID: <20240719181041.49545-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Avoid forward-declaring pl011_put_fifo() by moving it earlier. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- hw/char/pl011.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 260f5fc0bc..edb5395fb8 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -159,6 +159,28 @@ static inline void pl011_reset_fifo(PL011State *s) s->flags |= PL011_FLAG_RXFE | PL011_FLAG_TXFE; } +static void pl011_put_fifo(void *opaque, uint32_t value) +{ + PL011State *s = (PL011State *)opaque; + int slot; + unsigned pipe_depth; + + pipe_depth = pl011_get_fifo_depth(s); + slot = (s->read_pos + s->read_count) & (pipe_depth - 1); + s->read_fifo[slot] = value; + s->read_count++; + s->flags &= ~PL011_FLAG_RXFE; + trace_pl011_put_fifo(value, s->read_count); + if (s->read_count == pipe_depth) { + trace_pl011_put_fifo_full(); + s->flags |= PL011_FLAG_RXFF; + } + if (s->read_count == s->read_trigger) { + s->int_level |= INT_RX; + pl011_update(s); + } +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { @@ -314,8 +336,6 @@ static void pl011_loopback_mdmctrl(PL011State *s) pl011_update(s); } -static void pl011_put_fifo(void *opaque, uint32_t value); - static void pl011_loopback_tx(PL011State *s, uint32_t value) { if (!pl011_loopback_enabled(s)) { @@ -440,28 +460,6 @@ static int pl011_can_receive(void *opaque) return r; } -static void pl011_put_fifo(void *opaque, uint32_t value) -{ - PL011State *s = (PL011State *)opaque; - int slot; - unsigned pipe_depth; - - pipe_depth = pl011_get_fifo_depth(s); - slot = (s->read_pos + s->read_count) & (pipe_depth - 1); - s->read_fifo[slot] = value; - s->read_count++; - s->flags &= ~PL011_FLAG_RXFE; - trace_pl011_put_fifo(value, s->read_count); - if (s->read_count == pipe_depth) { - trace_pl011_put_fifo_full(); - s->flags |= PL011_FLAG_RXFF; - } - if (s->read_count == s->read_trigger) { - s->int_level |= INT_RX; - pl011_update(s); - } -} - static void pl011_receive(void *opaque, const uint8_t *buf, int size) { /* From patchwork Fri Jul 19 18:10:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813404 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877276wro; Fri, 19 Jul 2024 11:12:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUbzS/SO9H5m8WOLTVnWsEr/paGvmGpnNHMUob9YB6aXyalSAMxfpVMbpQMuoiMqJczmyupulUeRCRX3oJosWIb X-Google-Smtp-Source: AGHT+IEM5YTJWbLIs9IeZJUcyMpvL4O4KWkBqRnU3F5neynNBmQfCZyXKWPXucFKqH1Zft6LoN93 X-Received: by 2002:a05:620a:2901:b0:79d:6bba:4a66 with SMTP id af79cd13be357-7a187503d4amr1130505685a.66.1721412724939; Fri, 19 Jul 2024 11:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412724; cv=none; d=google.com; s=arc-20160816; b=eD9kwIJ+hWExhxgjv5byQkn5m4Xd0LAP1WD+rN14Zxsd0QS2kyU2bEUpIgWjoFn64v 5/8iaSG+dj/oWjhkTg8gvteJAOjCVs6C6KgzZUECPaFwIbAnhIQTlsWQE/61kj0pA1CC LvqGuLuZAeDfGctAd9cXj3/lyo02YED3008D6HG7yZ+j/e3UQNNGEMhI9YLFYRuMC6V0 bYJNbUgY/ROfA2865u6I14mAfUdMmqqpVmp5qMjHcSLMrNyr4RsWex6KIS4IwWQkmLBW GTewer3vdWnm8VghaOeNhTCRWyHYmPs/V9BZGhTbMCYtx4q0nPXiwCo+Qt6CrYm0jFV8 BdDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HKEyUF5vAQXhfPoZ9bEoVMEJKlfitjNK1zaxUdDv/iQ=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=M+PbM3WPlJQmnt1h1SXBkujdSlhdIKOrABFzDBM42HnU/sF4aSlybTGDumdzCtPwl5 szoFIsylU9W7mb0GJdPdZyXB69WkUOhQor/WsLUNWOebHUcZOnsyH/tQ9kR0dFh4oqh7 XabK0WI0Km63OdcBD1vjkBQBKBOf6Uq1XrW8WHi0r4D2TX/6kUtKQzWgpF+xhCP8nJnQ PmC2i8bxc2Oi8N2cmxzXfWRJKFizjU5DSDIvteYtADO4W5OTPbSc6tRS/T3CS9lz2y2C 65OaOy7fA8GDCS0HD2x6nrWorbLiSQuZ+OoTUaaUBdQkaUUrkIoNdfvKyhAju15WDr/Z JkmA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K+xj+DNn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a19904b351si219781785a.381.2024.07.19.11.12.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K+xj+DNn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs4n-0002bu-P1; Fri, 19 Jul 2024 14:11:30 -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 1sUs4b-0002GE-WB for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:18 -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 1sUs4Y-0003nu-DQ for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:17 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4266eda81c5so16418445e9.0 for ; Fri, 19 Jul 2024 11:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412669; x=1722017469; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HKEyUF5vAQXhfPoZ9bEoVMEJKlfitjNK1zaxUdDv/iQ=; b=K+xj+DNn+cLdbOJg2lsW1RNdGSbc2+LzGrWNlsg+GVp3iTOknM7bX3ktPnQ/oadrdI vpMhCfL9tpyETxVcsEpjm94mPO6fnLfPguYYf4Nw5FL1XRrw4+7Sy25oh/5L3csN0JKj p/r7UYS/ZKtt7n9NyGlafq815UviiokuLJhoEGks0Q8pifEAXz0ZU0vHAJn/VkkOQpXb wozv0c4ZXB3hUyHSC30hzSzDiE7K2wkeYo5IhpNCygwwtSacwpWmbU1UYTnnQy8i81ks PnG0UaKqqd5ovW5hBpOicppQut2NRsmlBvq6fAOmQc2JeeczIVru2z6T0An2s/HEKnur UK0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412669; x=1722017469; 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=HKEyUF5vAQXhfPoZ9bEoVMEJKlfitjNK1zaxUdDv/iQ=; b=YR8h+ElBJraR/Dq4wnRbBCMUAESw5zlnjn2yI0hzMgIy0vTymccNbn9MOAoKSc/CWo Wwk2hdV7UwyTC+TgBrbvTQ6YYasezD+ERklHoHzbROiagaXUfIUhK17t7idL72dH1W1B qu4e2OHs5jOWzn0UBKBXupQJhdn9XRd1Kl1W3J/pgk770dmF8fAWR1A0TtG+gZDgN1CK fpceKoNmhbnlatKP+6inR1sxHCkoRFS7Srqp8UXDZ2Zy9OYKPz9kGqV1qHLBcA9fjyXM qmP1nOSyrpDMZaGkvtwy5CuD3AF+zCdpBxOF/fRQ3Awr6IfPziB4V+zgiQnmWLKNIbbU Z0qA== X-Gm-Message-State: AOJu0YzQgNpXKS6uuymPX6XnURSCemhlrEgybzI1LLtR5FLMD/yQkk3u 8mbMuzUs1Wfnbc77jdRXtEQMXrw8KCOCI3Lxtu24h4bB/jkn+FdArMQRHCUCkFTUCGcP4VkEvgJ 9 X-Received: by 2002:a05:600c:3b8f:b0:426:5520:b835 with SMTP id 5b1f17b1804b1-427c2cacf1emr61880365e9.5.1721412668901; Fri, 19 Jul 2024 11:11:08 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d7263687sm29524065e9.4.2024.07.19.11.11.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 04/16] hw/char/pl011: Move pl011_loopback_enabled|tx() around Date: Fri, 19 Jul 2024 20:10:29 +0200 Message-ID: <20240719181041.49545-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We'll soon use pl011_loopback_enabled() and pl011_loopback_tx() from functions defined before their declarations. In order to avoid forward-declaring them, move them around. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell --- hw/char/pl011.c | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index edb5395fb8..22195ead7b 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -138,6 +138,11 @@ static void pl011_update(PL011State *s) } } +static bool pl011_loopback_enabled(PL011State *s) +{ + return !!(s->cr & CR_LBE); +} + static bool pl011_is_fifo_enabled(PL011State *s) { return (s->lcr & LCR_FEN) != 0; @@ -181,6 +186,34 @@ static void pl011_put_fifo(void *opaque, uint32_t value) } } +static void pl011_loopback_tx(PL011State *s, uint32_t value) +{ + if (!pl011_loopback_enabled(s)) { + return; + } + + /* + * Caveat: + * + * In real hardware, TX loopback happens at the serial-bit level + * and then reassembled by the RX logics back into bytes and placed + * into the RX fifo. That is, loopback happens after TX fifo. + * + * Because the real hardware TX fifo is time-drained at the frame + * rate governed by the configured serial format, some loopback + * bytes in TX fifo may still be able to get into the RX fifo + * that could be full at times while being drained at software + * pace. + * + * In such scenario, the RX draining pace is the major factor + * deciding which loopback bytes get into the RX fifo, unless + * hardware flow-control is enabled. + * + * For simplicity, the above described is not emulated. + */ + pl011_put_fifo(s, value); +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { @@ -290,11 +323,6 @@ static void pl011_trace_baudrate_change(const PL011State *s) s->ibrd, s->fbrd); } -static bool pl011_loopback_enabled(PL011State *s) -{ - return !!(s->cr & CR_LBE); -} - static void pl011_loopback_mdmctrl(PL011State *s) { uint32_t cr, fr, il; @@ -336,34 +364,6 @@ static void pl011_loopback_mdmctrl(PL011State *s) pl011_update(s); } -static void pl011_loopback_tx(PL011State *s, uint32_t value) -{ - if (!pl011_loopback_enabled(s)) { - return; - } - - /* - * Caveat: - * - * In real hardware, TX loopback happens at the serial-bit level - * and then reassembled by the RX logics back into bytes and placed - * into the RX fifo. That is, loopback happens after TX fifo. - * - * Because the real hardware TX fifo is time-drained at the frame - * rate governed by the configured serial format, some loopback - * bytes in TX fifo may still be able to get into the RX fifo - * that could be full at times while being drained at software - * pace. - * - * In such scenario, the RX draining pace is the major factor - * deciding which loopback bytes get into the RX fifo, unless - * hardware flow-control is enabled. - * - * For simplicity, the above described is not emulated. - */ - pl011_put_fifo(s, value); -} - static void pl011_loopback_break(PL011State *s, int brk_enable) { if (brk_enable) { From patchwork Fri Jul 19 18:10:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813415 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp878145wro; Fri, 19 Jul 2024 11:14:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUt7YmD9zkAqCBdSTieRIuSawfm68rOs9Zvyy4z0jpRJQwrU52bkxN6Oma411Uysmg0cD5mNvn+GtH383rNz2Qn X-Google-Smtp-Source: AGHT+IFoCxvJCt1UCn/3RHAOmZkVbeJyUecOcYZ0FT/HF8xoTHjJf9itznAOTK/vt+nZQj/q7YpZ X-Received: by 2002:a4a:e90b:0:b0:5ce:f75b:175e with SMTP id 006d021491bc7-5d564f5fb1fmr575208eaf.4.1721412868761; Fri, 19 Jul 2024 11:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412868; cv=none; d=google.com; s=arc-20160816; b=Crqa0f3li5+zoIKLyUQ66ArHracvD+uzD2RUeaBgSjnu0YOjMyWext4QmIKJJTSYlR 3iwxvcl9sS7zMJDp+SXZn8S3mH3t4TZFrSkh5TrKFPqnT1DXCO3zeb7kb8dLZ8HUxi5c ghlNaTsem8Y9oG2O6imxjtsZTTHG7J4i9mIExCHs3iYLkxQvPNJjkzzo2sahX4EJ+SxL me99SGBu31LrwRU/R7akQZnzr2hgYGpF/iirBe5CAJoMUr1HJOtDJpU9RMgM1CAbgwVk 9kJ/ELe7eTsbE5yezGHDC/WKbwb8KqfafyKRWZCEQ0lfmcz0Yobmisa8+sY+RBVZjaC/ GIJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WBQBL5W8xgFprC/jppYzPypv2gfWoCKhxuevh4igzXc=; fh=8nLw5DkymCkC7Fl2VB/6HOK2iJbyi0CR8pyTF7gwHbU=; b=zRdUzRKDzi69NVGSUOz7wofHg1RF+piZmNJ9hTCMedmVBvwAEC1rkgnQM3KdCnxcQj srtbYwy3eyVnFg9cvWqKYznrbwileWmFFU0cu5N6HLeKgMyfz26yxT+vInCNRQYyb+Jd Li6cIbSIAfLDFF75hcO3A/0nLBx2unmLIIfc16IJW6Frd1w0Va/baxPLpj2o5T04MOlG rkHGBdGtcq1JdRgeVGG7LcT8PK25HPsaoOQZfJEcYcte5KEIZr0UMLOCbJo5zoCsxEcj xO+RIx31wGoXCqDYfPYUboAljhgDKPYk6ISpRQsrBMUwb3kGZR/HJLwxB7yirvAisax8 CYuA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cHDup4H5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7acb1028asi21423306d6.540.2024.07.19.11.14.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:14:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cHDup4H5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs4y-00039d-H0; Fri, 19 Jul 2024 14:11: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 1sUs4e-0002Qd-AS for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:21 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs4b-0003ok-Mp for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:19 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4266edee10cso13005545e9.2 for ; Fri, 19 Jul 2024 11:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412675; x=1722017475; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WBQBL5W8xgFprC/jppYzPypv2gfWoCKhxuevh4igzXc=; b=cHDup4H5TPWAimxswXCit7TSGbrQixMkYckcWu8Lqxk8n3YDSE+HGcFpvaaaIdXf+T LwOYwyQfqRzoVBjpJ3pWNFdEPpY7lmm0Br1KxonT4+PuCkRPu8rsdG06nwcPPGitjTEw rFk779FCoXpXYMrCHvVBHSquRXFij60RK2EUuBO6IdD4Lgwp1NNYQOLZcauPZJsrmNV3 KqOuFGQkLNvv4n7wEAa2xHyn39P4QdnrEna/KWPIj8gtM+yUk/0mernOWHbmAQhpiBlj BLMt2AZKDRE6YTxicO3hvRvc+HqCQM7nxUAibI2HXV6dFhV2NMxo4GNVwEUioTsqQxT4 HJaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412675; x=1722017475; 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=WBQBL5W8xgFprC/jppYzPypv2gfWoCKhxuevh4igzXc=; b=eNnG38kKE0pp8/+RjsZOUxnuxgdmhDbSmTenTolcy+PDdSzFpX32vMplfStZtB5fE6 ZU8hnL8+CrZIB+ZovGGbekc1xKVjqvA/QsuFxhp4mgsdAG7FdmezVqVPgUjieVowDlFO YxhMuzeG0IRL0LCwNJzCAyHUzR21lvzHCKYi062tAyJWHXlWTlShzkBPtTiVSoqsS7sy 2GF9VGjD12pfe6FJUCz7PxHmV7nARN930GuJyCnvQKcnoFpBjzex6ZsCZlqL5m+vvVyI mn+uyhvKwA+5r+NegBm4SzbgKrcJTmqtbDAkcnPwejR34YmHdo5MZnC1cc5p5tCcZlnb Pv1Q== X-Gm-Message-State: AOJu0Yypf88jwb3oqODMtkDQ3Ro58IvKahruqUfZ1Shbq0cCUSDaMzYR dhq8ahi4o90yCTuGgRP8qo9WuEc+OQcxMzaUin2AhAPUewcmz0s+9DTvZxvaVV4+mJAgz68aKwC L X-Received: by 2002:a5d:58da:0:b0:368:65a0:a423 with SMTP id ffacd0b85a97d-36865a0a82amr3024174f8f.27.1721412674957; Fri, 19 Jul 2024 11:11:14 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a94c0dsm59991275e9.46.2024.07.19.11.11.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v5 05/16] hw/char/pl011: Split RX/TX path of pl011_reset_fifo() Date: Fri, 19 Jul 2024 20:10:30 +0200 Message-ID: <20240719181041.49545-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org To be able to reset the RX or TX FIFO separately, split pl011_reset_fifo() in two. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- hw/char/pl011.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 22195ead7b..3d294c3b52 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -154,14 +154,21 @@ static inline unsigned pl011_get_fifo_depth(PL011State *s) return pl011_is_fifo_enabled(s) ? PL011_FIFO_DEPTH : 1; } -static inline void pl011_reset_fifo(PL011State *s) +static inline void pl011_reset_rx_fifo(PL011State *s) { s->read_count = 0; s->read_pos = 0; /* Reset FIFO flags */ - s->flags &= ~(PL011_FLAG_RXFF | PL011_FLAG_TXFF); - s->flags |= PL011_FLAG_RXFE | PL011_FLAG_TXFE; + s->flags &= ~PL011_FLAG_RXFF; + s->flags |= PL011_FLAG_RXFE; +} + +static inline void pl011_reset_tx_fifo(PL011State *s) +{ + /* Reset FIFO flags */ + s->flags &= ~PL011_FLAG_TXFF; + s->flags |= PL011_FLAG_TXFE; } static void pl011_put_fifo(void *opaque, uint32_t value) @@ -410,7 +417,8 @@ static void pl011_write(void *opaque, hwaddr offset, case 11: /* UARTLCR_H */ /* Reset the FIFO state on FIFO enable or disable */ if ((s->lcr ^ value) & LCR_FEN) { - pl011_reset_fifo(s); + pl011_reset_rx_fifo(s); + pl011_reset_tx_fifo(s); } if ((s->lcr ^ value) & LCR_BRK) { int break_enable = value & LCR_BRK; @@ -619,7 +627,8 @@ static void pl011_reset(DeviceState *dev) s->ifl = 0x12; s->cr = 0x300; s->flags = 0; - pl011_reset_fifo(s); + pl011_reset_rx_fifo(s); + pl011_reset_tx_fifo(s); } static void pl011_class_init(ObjectClass *oc, void *data) From patchwork Fri Jul 19 18:10:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813411 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877646wro; Fri, 19 Jul 2024 11:13:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2UL+OJ41SkKDol5ve4sRrMZ90mt8IccJAERtK+2ZEVbW+rS/7TuM0ULYA35Vck4oYXP3K526UjOvn6z86Rark X-Google-Smtp-Source: AGHT+IFzgbr7+Q4MPn2Rs0yc4PYKybjn0wG+Zzp2nntTLea2CYkg+MasaLRCuteOXdnRnZPWiY5j X-Received: by 2002:a05:620a:2545:b0:79d:55f0:d092 with SMTP id af79cd13be357-7a187413337mr964737385a.8.1721412782818; Fri, 19 Jul 2024 11:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412782; cv=none; d=google.com; s=arc-20160816; b=YNJ3V06XX0aD1hv+bJ2HNQMKwHq/u92ORQjohQMSobVd2Vw8/dLiZcZFU4IvAMdM2m 4XfN4dXXFhPK3PKDBR2mQOjg04E3VnA22CBvqnjI3JACjNjI5zH6hOAE9UHvE5SuS8C2 oLmUx6WRUhIpiTgiTYr/wiaUITW7yUbBPxo3FIZ7uHYLzMLP/A2CAIQa0c97FmGc0S74 7grWF+Fd6ZsNXWyCygUDBgojH4w6736zy4YGYRrkcF/D14lkmNxLUyf4ARUWlr3ICMLU IbcTrPYQXBWe6FCoAV/hcQQkjBtyWGgNSqcRF0gCZUauVa0DTxoOdwCJO7e9qVABKSwt l4bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=t1KnnMz9QclH4DdZ0a7ONIaMOEDb8CpMIUXc7bRjrWI=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=LCoLMmVPmYGnfLvCikdR0jyfzL9W4TzPS3OiGvJ5Z/G7Hs0ufNHt4o31B2rNfKep3i VJyUUNWSvyzwSOdD/ud3+JqUNeOZHowxj8KKCVj8n0SolFryDlOk93NjbynrsPKXKev3 DF4teLvNpRHO0sdjorQ84A9g1QevEep7H2I861XWRGqctE+Px56GovbX1KKI2tyoPJU2 Rv/hz40T1kRQ8N2+XxJm4xCEXPFC2ury7DnQ7Cjo2C/b7HFpSihOGiZ+AYplIKjOTgNt hC98HLOEMSNicbW3M9YTOljc2oeOU9kvvaj0oEpH9NMhFlbMMv+MDgJ211glN7uiWMbY 9EiA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tzpf0W61; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a19904a643si223265785a.352.2024.07.19.11.13.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:13:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tzpf0W61; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs50-0003VA-Ts; Fri, 19 Jul 2024 14:11: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 1sUs4m-0002kQ-2z for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:28 -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 1sUs4i-0003qG-Lo for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:27 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-36798779d75so1108452f8f.3 for ; Fri, 19 Jul 2024 11:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412680; x=1722017480; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t1KnnMz9QclH4DdZ0a7ONIaMOEDb8CpMIUXc7bRjrWI=; b=Tzpf0W61kW6KWL6zDf4iEIn75s8Cqd/ELkfoZaXfKnGZ21aVntorBjBwsScpMejugQ sKFXTQ/vtyYvda4LL3IfBuMfmst2GbjZI3N2a6ljAdvvtMQdNtLixX70+LAtFvIrS0AK fxZlikzpFsd9T6gyVSjsdwvgBPhNyyO4FBD/UZhohsD1Wlk5yghX9i6adBSyKfZGutCx MR0J/E8LLfqiu9ZL3i/j8+Ic9MmP0bpc4DEHG+1f9UNnwyW65EUcuF1SUTwzbW2frNxl 4hCOxa73R+bR4Q5bVoTe33rU4ACoGp9jqpuCxEj5pw6XRPqXULimJNPj6uA+6WL5x0tu Ch/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412680; x=1722017480; 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=t1KnnMz9QclH4DdZ0a7ONIaMOEDb8CpMIUXc7bRjrWI=; b=AW+bWak7HhmstJcD3SDfX2PU9c9vOrBOEQM4cnkDAqQU0aDZxITJD+tohpAjI3PsAT opp1QpaINDWaeHf/15OiA7yo+5iVOj/SZFWhurYqJSPPelK/GC/lF2tRgs8KbyOLXsIM KbRJj6q9GmgaLN7/ff8aYqGvfUPB2HuOGW8F7mJvh5GXWLs/FFBSNFMs9IgFsIjNTz0c ijOAk5eik92axu0gArG11RRPkmXV245RMqVKZ6+/0GuwNOlSoubJ+joX9PbUbKXhifJp nTRMGGYgXZ8YgTMWGUapmcL81DON9souwowraFBbtT4Sqlo03HEq5eLsKduYucqo/kl1 XEqQ== X-Gm-Message-State: AOJu0Ywn18QEX0xUArtV7OqOTMfrJtozQqJZse7v1hy7EtJhiYsT8LVt oSPsBc85PnLODCHk+rlF2UOSrra2tETMJ/MeFyPAzIAqdV2f0adDIp3PD5funHVY6NYoiioptRS v X-Received: by 2002:a5d:4609:0:b0:368:78d0:c240 with SMTP id ffacd0b85a97d-36878d0c769mr2212400f8f.35.1721412680638; Fri, 19 Jul 2024 11:11:20 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868bb00sm2245597f8f.43.2024.07.19.11.11.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 06/16] hw/char/pl011: Extract pl011_write_txdata() from pl011_write() Date: Fri, 19 Jul 2024 20:10:31 +0200 Message-ID: <20240719181041.49545-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When implementing FIFO, this code will become more complex. Start by factoring it out to a new pl011_write_txdata() function. No functional change intended. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- hw/char/pl011.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 3d294c3b52..c2ee9b0321 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -221,6 +221,18 @@ static void pl011_loopback_tx(PL011State *s, uint32_t value) pl011_put_fifo(s, value); } +static void pl011_write_txdata(PL011State *s, uint8_t data) +{ + /* ??? Check if transmitter is enabled. */ + + /* XXX this blocks entire thread. Rewrite to use + * qemu_chr_fe_write and background I/O callbacks */ + qemu_chr_fe_write_all(&s->chr, &data, 1); + pl011_loopback_tx(s, data); + s->int_level |= INT_TX; + pl011_update(s); +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { @@ -388,14 +400,8 @@ static void pl011_write(void *opaque, hwaddr offset, switch (offset >> 2) { case 0: /* UARTDR */ - /* ??? Check if transmitter is enabled. */ ch = value; - /* XXX this blocks entire thread. Rewrite to use - * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&s->chr, &ch, 1); - pl011_loopback_tx(s, ch); - s->int_level |= INT_TX; - pl011_update(s); + pl011_write_txdata(s, ch); break; case 1: /* UARTRSR/UARTECR */ s->rsr = 0; From patchwork Fri Jul 19 18:10:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813418 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp878245wro; Fri, 19 Jul 2024 11:14:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUug96g76J5cdgsax695Q6RRuwtJAofeWPYIT5FFOl4+k1ot+ATHcxLUWANjvnZ5OnJ5NITFJ01gtqldjxGUsdH X-Google-Smtp-Source: AGHT+IEYXrCzyOB9T4NKJa432YP0PBaaRHGW5B83RRwLwtAkTq1TlJaDc9i81oaOICrZ368mqi6A X-Received: by 2002:a05:622a:252:b0:447:f2c5:fd1 with SMTP id d75a77b69052e-44fa527f99amr9009321cf.26.1721412883686; Fri, 19 Jul 2024 11:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412883; cv=none; d=google.com; s=arc-20160816; b=0bHx0MvvJ+5Z2p/5lwPv5zgSZhr4ZmrUeHGR4qNbhumCy1Jf21HmVqz93p+HK79N1c mzPWo+dAR17oOWxpeibMMFrIj2PXU+N+DownMVCZuVl+nX0mXXZ1pj0v/rmmRIhe1xNW 5InYqywAZQKaF5NxRpbCiFYur4a+R1ZB4Cmjppi8ERF0Sr/gFPppBvjb0K7r5EH/TpgD 08wkzOnhb5XDoaGDngbNSkMHxUuPQDCXpubdsyMbTmtXAS3Z+37VdZCjTgwt60y2beEY BeHcP9ZW4ZwM6jlQKJG7VnkCo6I1aH1qszVnUE0NDg5v7k3otwQsn/o/q+y/0QzcX0/z kjaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DMaUbmKJbBglpDupXq1EpryBjAO9Dx7J7NA5WWzmpPw=; fh=8nLw5DkymCkC7Fl2VB/6HOK2iJbyi0CR8pyTF7gwHbU=; b=TAKwqJJurTmPI7+KBgA1E6o8Kc1c8jTDMMrWehTujRs2txfDIrYHMmbwXCBSHZO7sa JIJmxfUgAfDQk5J1CeLPSLYMy10n5cwHahoFtIoAOWx+UvPXvb0CixzXuTU7XgH1hiI2 RoCdOK4RLgU6IugknaZj9T3JtIJROUNCjjUR7XzozhWMO8pGvyy45f/XPPAEp5t3S9iZ KF2aCIGDUlxk9eGm21unCKHm/UkWw9Sqki6K0Pmk9Ob1FErkcNZepBP6h5Pa1e1vpLUG VWLk5k+hJ/A/2M+PAXu9Vz1AJogGsEG0ur4I6bOrwo85TT55SYsBmOUIbcN3Nj6O9Pfk MI5g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mDIRd1HL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ccf8e13si21616021cf.76.2024.07.19.11.14.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:14:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mDIRd1HL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs51-0003Ww-76; Fri, 19 Jul 2024 14:11: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 1sUs4p-0002sW-2a for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:32 -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 1sUs4m-0003r6-V5 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:30 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-427b1d4da32so10126915e9.0 for ; Fri, 19 Jul 2024 11:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412687; x=1722017487; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DMaUbmKJbBglpDupXq1EpryBjAO9Dx7J7NA5WWzmpPw=; b=mDIRd1HLnzN3H1mIfCrSmtcXIWAFBcZs1dNcYbTGm9qpPh70h3uuHpZrfyqf4HF96n 77yS+/N9SGZ0Q36xEyKyDyBXk4slP9R8yN/fhlfiiYFY3AH/XK9xErnVQ8Zm27sgdDCG oDARJIq2QiElOoPO/L5cjUW36OcXF0MhUk23kcNqTiwyp8H3D9ZWNbBaq01byIlezkq1 o4IP8NTnZGHldSduG2tkPnjDfLyyxtHABTEgtVT1nxMVAmPh6ka1MECVHJALQE2+Q9LS sf/m6TYvkNAiVOo8OPXRKaQXT18ghcTtrMi7cO7ahCu7SViA1OYhK2hmPHDcCLH8eIbz Gj8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412687; x=1722017487; 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=DMaUbmKJbBglpDupXq1EpryBjAO9Dx7J7NA5WWzmpPw=; b=tR/F6M2+OAjpJ7gtHuI2VXKz8JLkm8gl7RibN2wMHZY6I+p7J1cpIYcgi77eDEdJbo PE5e8VCUmMDvuYoSzAPMhRZJYtmZTCU//K/+egOVJn99hCCuX5rV8mZ4wQYmO4z5Q+xF xe0keaEWat5cWQAeYrAkGaEaaaktIBA6e+xRBhTvn5bmNHSXhg+Vl4+bCwAj7FSjhsnb 9rOrLuUhCgFWwwM203jRSuNoS8Z4d80yeKgp8VFwNqws6hMDEcghh93dF4656lOA8bEs eMc7yczMGgLzEwicEilRd5vIgoPPCa1xXE/xAM/pdOpETEYkEO4MlK8vzr5r/7e7JrAV a73w== X-Gm-Message-State: AOJu0Yy2aV0STi7ZeLw4FVzR0QfsIorXvVsNSpJP0XBtD9GA26pCZeTR oowJx9UyYaaZzhALbSUNo45u9mZZIMBIlCCrBmmmiu7qDD+MC2h7AMoWX8aX6H2IdlsO1zCnfxb m X-Received: by 2002:adf:a3c8:0:b0:368:4488:66f8 with SMTP id ffacd0b85a97d-36873f18f12mr2144385f8f.23.1721412686920; Fri, 19 Jul 2024 11:11:26 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787cedabsm2217831f8f.84.2024.07.19.11.11.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v5 07/16] hw/char/pl011: Extract pl011_read_rxdata() from pl011_read() Date: Fri, 19 Jul 2024 20:10:32 +0200 Message-ID: <20240719181041.49545-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org To keep MemoryRegionOps read/write handlers with similar logic, factor pl011_read_txdata() out of pl011_read(), similar to what the previous commit did to pl011_write(). No functional change intended. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- hw/char/pl011.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index c2ee9b0321..5e44837206 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -233,31 +233,38 @@ static void pl011_write_txdata(PL011State *s, uint8_t data) pl011_update(s); } +static uint32_t pl011_read_rxdata(PL011State *s) +{ + uint32_t c; + + s->flags &= ~PL011_FLAG_RXFF; + c = s->read_fifo[s->read_pos]; + if (s->read_count > 0) { + s->read_count--; + s->read_pos = (s->read_pos + 1) & (pl011_get_fifo_depth(s) - 1); + } + if (s->read_count == 0) { + s->flags |= PL011_FLAG_RXFE; + } + if (s->read_count == s->read_trigger - 1) { + s->int_level &= ~ INT_RX; + } + trace_pl011_read_fifo(s->read_count); + s->rsr = c >> 8; + pl011_update(s); + qemu_chr_fe_accept_input(&s->chr); + return c; +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { PL011State *s = (PL011State *)opaque; - uint32_t c; uint64_t r; switch (offset >> 2) { case 0: /* UARTDR */ - s->flags &= ~PL011_FLAG_RXFF; - c = s->read_fifo[s->read_pos]; - if (s->read_count > 0) { - s->read_count--; - s->read_pos = (s->read_pos + 1) & (pl011_get_fifo_depth(s) - 1); - } - if (s->read_count == 0) { - s->flags |= PL011_FLAG_RXFE; - } - if (s->read_count == s->read_trigger - 1) - s->int_level &= ~ INT_RX; - trace_pl011_read_fifo(s->read_count); - s->rsr = c >> 8; - pl011_update(s); - qemu_chr_fe_accept_input(&s->chr); - r = c; + r = pl011_read_rxdata(s); break; case 1: /* UARTRSR */ r = s->rsr; From patchwork Fri Jul 19 18:10:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813410 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877638wro; Fri, 19 Jul 2024 11:13:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUjKvoAMCuBH3c++52rwJSFu/JqBBe7OC/eM4FhEkJgl/+JYrOVRHiSIZKiJS/U5z6z+4sDD1iuv9GNbQv/Jay3 X-Google-Smtp-Source: AGHT+IFPgcs2nlyYb87adx3p0Aq3ra98gNfkhbqPzmcI8BmxxLkBQv5mrU66Tn/1M4X4VU1ObfP5 X-Received: by 2002:a05:6214:d87:b0:6b7:a042:6866 with SMTP id 6a1803df08f44-6b95a74c7afmr10093626d6.36.1721412781624; Fri, 19 Jul 2024 11:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412781; cv=none; d=google.com; s=arc-20160816; b=nhJfdV3f0ppzkDlzboPU01ESV+/wD4SwXDoEXSSzq3KiqW83jk55jUoTjG666qSCKW t/kLZYr7m/vFYCxHOkUvHCqNIxVF9Rv825MKg3aSoftKyloyEQoRvdBzrGLKAKSetp7k FZ3Gp4gEVJbQRncIfN2TTgUk7kr6JdDcaC1DdxewA5OXsFhNsq8enBcmZQ/vIuFBakAN cP/0cDhJxCqgdYIvGJeEz1FAUsmEvApDdS/EMsqZNjiXURDRQ7XZKkEpdTpVrPE6wULs svYJcpEZk/8aDtMLZ3Gp5K9FmAAsUo0/zi0II4WXZNEgDKBFlwnLQ1M3IpoBl643TKAO kcBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k2XEnhFM3nuD2qGNt8O7aO/xmQeeA1+fM2YLyMtjpsg=; fh=8nLw5DkymCkC7Fl2VB/6HOK2iJbyi0CR8pyTF7gwHbU=; b=LWIcLfKi27NVxpiqJStohEsfzRFLWJqQFDmrXxkZP9vSwT3gjw35IszKk6kyFjNuyU zbMejFu8UrvFTQwwTzVw6Vk9vlLT+ts5leVoobjjLwB596Mo8vb3dRHmnILzJ2bJ/gF7 EoAEXmaPeKVM2/RTcU2Pi1D2vxZ+3bZ7GMas6DMPN06exevgmufBLWVPGJY+yw9vH6LB wayEI9DsVZdOeaePsh55S7p1MIJCy1hzyPqObrmxythFl6cdaDc0DiXnS3lnuY33m7HZ pPkG1oqHyW8pSrK7c7wdbZG0VpePbL9kYp8ENrMqCkxmgeEGWDx6Q/pgq6Nn0WQq6spI b/Ig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=viZsthjW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7acb10df0si21906896d6.546.2024.07.19.11.13.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:13:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=viZsthjW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs52-0003ej-7Y; Fri, 19 Jul 2024 14:11: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 1sUs4x-0003G4-9O for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:40 -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 1sUs4u-0003sc-IM for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:39 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-427db004e36so248275e9.3 for ; Fri, 19 Jul 2024 11:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412694; x=1722017494; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k2XEnhFM3nuD2qGNt8O7aO/xmQeeA1+fM2YLyMtjpsg=; b=viZsthjWLt1sOM9/zWtp6qw4w6uBYfCHHCU6A5TmK+Pv4Cs608fLDMdtlBqqvzAgIY iqpOuJ0DoGZz4lbuCehZBo+oQq1DahlxqS2I7Wyz5lgWdaBzmhqWtGTbNKOTxwXsvHcn r5hWH//RA3i4fgnKgMMDMtg9K8VhGKoXQB6sPx23PXgua3wvqcZiV2JI2X8kEdajMqBS V/8IEDnLIHwSYV3WKO+8g9sDQldDMyfsOSENRALuJSAHOt7MaalVXAUe+sjtSE8bnhU2 BvS3DI1lCs2r0+4kkfykj3iGrmqYJSm/iW8zesF/Dm1NCfGI6x8GF2Sqmttvfxm+CLzT yGtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412694; x=1722017494; 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=k2XEnhFM3nuD2qGNt8O7aO/xmQeeA1+fM2YLyMtjpsg=; b=ojFtWrN/uB8/hQNrJB8i8UG8mZvG9J2eqos8ih/9+OiGXBi/6+ekm7ENoUDfumf+LZ eQu8Gi6pVS902FSgKkiHi3nBmMK3FZ9h+EsaBJQXAzYD3x2qY9qvuRnj38PgcVUzsoey GtE5eq9NRBvSbLMaDCwUg60xQ7VfLZ+cqGPqzeoR67mB2TFFYH8+Ii1vfMPAwxocpNhJ ejngXI7qsUQg2shpvakotCDkphx+sSghMg1xKzG2BOf2fkyAzvfECzoThC/YEE3WZleP KFmPYFMsTDk7MIh4JLh5+RrA98hcJWCjGNKMlU4V4Z4eZh2rzh6aEBdOVeGYLQJT/mtX BHfA== X-Gm-Message-State: AOJu0YyLxeFpnzNq9CkgSjwp5JLICeEpbDMhXhRvnRiqYudYegquOmcR TMENNoh9ZFbRn6O6W2xXCdRogW0UnvZ7Tmg82WEYXTcvDwIE9w5SZX7/1gzMbxuYcJc+hUhcV49 M X-Received: by 2002:a05:600c:1c21:b0:426:5d0d:a2c9 with SMTP id 5b1f17b1804b1-427c2cd36d1mr63774875e9.10.1721412694282; Fri, 19 Jul 2024 11:11:34 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a7257esm59439785e9.28.2024.07.19.11.11.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v5 08/16] hw/char/pl011: Warn when using disabled transmitter Date: Fri, 19 Jul 2024 20:10:33 +0200 Message-ID: <20240719181041.49545-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We shouldn't transmit characters when the full UART or its transmitter is disabled. However we don't want to break the possibly incomplete "my first bare metal assembly program"s, so we choose to simply display a warning when this occurs. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- hw/char/pl011.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 5e44837206..c76283dccf 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -85,7 +85,9 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define CR_OUT1 (1 << 12) #define CR_RTS (1 << 11) #define CR_DTR (1 << 10) +#define CR_TXE (1 << 8) #define CR_LBE (1 << 7) +#define CR_UARTEN (1 << 0) /* Integer Baud Rate Divider, UARTIBRD */ #define IBRD_MASK 0x3f @@ -223,7 +225,12 @@ static void pl011_loopback_tx(PL011State *s, uint32_t value) static void pl011_write_txdata(PL011State *s, uint8_t data) { - /* ??? Check if transmitter is enabled. */ + if (!(s->cr & CR_UARTEN)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled UART\n"); + } + if (!(s->cr & CR_TXE)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX UART\n"); + } /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ From patchwork Fri Jul 19 18:10:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813409 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877575wro; Fri, 19 Jul 2024 11:12:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVgzvItmDef2SAKSH0TRpnQBzPsKticl0OZatuwciYzWGdOiWPWJjLjJuDxz3OKGgGX/zApEan2MRHYw5Nr5QPj X-Google-Smtp-Source: AGHT+IGekrlhBUT3c7B6iGcM06dijoMn0QRQ60QBrCmT3uDDH1bkYOtWEXSMwdSO1Eh18EQjUVFu X-Received: by 2002:a05:620a:3949:b0:79f:720:ebad with SMTP id af79cd13be357-7a1a132c7b0mr96734285a.21.1721412772395; Fri, 19 Jul 2024 11:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412772; cv=none; d=google.com; s=arc-20160816; b=SYIjeIUWJhOr5bs5sMxjhWlQ+L/lhMW8VyoQ+UJeN3pmMdY2+IdYOqB4R0tBnjHcXI 61yI4S08SaX+QOOnaqhxztPnl1Tu9IrEgL1N3FDCrSCskuae5VMW4Tu/dBrj1Y5U4Uqx 6ghVVrI5fV0jzvmeRFoeUR8R8gVe6rJS8JoFzRW55vuzXCRrviFFrFsZ+wPXchXWpBnH MZnauu1hZ4XvQeQmGvdmgb2p02Qd837EhYS4NUWMeiPGy9/uzE44fdGi/1CfKowRQGVD Mq2VGoF0OBZbJxNzwKKCLgY02yJMPe7RczxF4Jz+sshGaKZ6u4zrjLEbbsJ3joUYVOxd Ebuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g8wjXx2GxaXvhCmT3K/sKVDQtxch9aqIxPKOi+RY35s=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=mRwtQBVO2zHfspAmkVZ0GacQiHLhfNKRtHxxAGuYPM9o9pY/p6R6j1Ho8C88NlnPGT X8FdohSE/aUNANv2Gx1BHgs9TtLSTc2+EqdIfoEhQpEl3zP6e564JcWWoKwFolWqV9op 9mqqZKe4Qlosg2GM5m5YP5geC1J26O0K6rC25J1aKZi6JKGzkS1Ez7KB6N9i6tuQmCX2 YnuakjLQqXqY4pfGVJtQ0YLQR7eaqDcRb7JBQKhyk5KYFMpjvfYawXkc0OqSFTjfLZ/k UnU3v5ZqclHeeBfg7r47Ne1LGvu3gC6tJMeK4VyJumqN+dWYVzAs/8bfqChOvcPzGt4X wuUQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Izxs50ha; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ceff8cesi21879431cf.633.2024.07.19.11.12.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:12:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Izxs50ha; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs54-0003sS-99; Fri, 19 Jul 2024 14:11:46 -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 1sUs52-0003gb-I7 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:44 -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 1sUs50-0003uI-Cw for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:44 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42660b8dd27so13652825e9.3 for ; Fri, 19 Jul 2024 11:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412700; x=1722017500; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g8wjXx2GxaXvhCmT3K/sKVDQtxch9aqIxPKOi+RY35s=; b=Izxs50haudGCc2YV2T/tqmBa/fy+QhBkgPFUssAGU4kgTAw7S/vwFstBJm5Mealdxx 5ol8W/ozfkMK9eEXE1RUFmzsVpWrtjX0TPjqovzOVdZZs5vAPH/RqO2WZs0di6VacaYr da51phfxhcLPvQxOer3tf9QoxgUxJD4C9fRiVgWaC453RerVT2b+NjpptIC+nUhTev0k uJhXnGePt9Z4vxkKF7n5uUurpYQxKOrDsg/wsDH02/8LHHSIniJKQq9DyZlMnt3Zisaa vvC5F2lNZELkRiikBxY0/CazCWF8e3SlgxZnIKzOFasXIcgcSvsv8n6JIJwvn3aA96gi jpNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412700; x=1722017500; 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=g8wjXx2GxaXvhCmT3K/sKVDQtxch9aqIxPKOi+RY35s=; b=GQVKEuuH0JNq0cvsZm8d4VB4HdeLma4LPNWosyePji0sVvDyhEX5EmNNAQZ+9sfm1E uUsAUa8upLrX36e/dEeXXUxsP25YAtjgTJz3ls42wpvvMSk6njmDtHEhIO69yXVaZtQg pkGeLNiXMNsXOnsc5q995MwzP8C0TWZVUjc/aSpuSgJE9HmmyRhgT5gYT49ObkcKec47 ZixC0mfaq+Kw3k9/HPEIDGPS+N4yzgWytKXYeGNoeHyFCuk9WbYVNF1JGQ6OAmn16wTC FaLi68zzXgen3klMVyej+FH6D/F6SyVbLTZiEcWR1hdAA5kurW9XlH7Kxy64OFI/m7eS GrPA== X-Gm-Message-State: AOJu0YyKzDH+RHj5Y5kFgxYUljUHi+AFOnSOMbMtJfPZZrf+cYWy2s1v LTsmtYRPu3okIYljnj3l4SM0FMUnaoaLDZ+u4Y1KWKVmcu2yPiudXqv7RyF9iIGH7XGSLKFYNxA 1 X-Received: by 2002:a05:600c:1550:b0:426:68f2:4d7b with SMTP id 5b1f17b1804b1-427c2ca57admr55957355e9.3.1721412700009; Fri, 19 Jul 2024 11:11:40 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868420fsm2232641f8f.3.2024.07.19.11.11.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 09/16] tests/qtest: Update tests using PL011 UART Date: Fri, 19 Jul 2024 20:10:34 +0200 Message-ID: <20240719181041.49545-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We weren't enabling the PL011 TX UART before using it on the raspi and virt machines. Update the ASM code prefixing: *UART_CTRL = UART_ENABLE | TX_ENABLE; to: while (true) { *UART_DATA = 'T'; } Signed-off-by: Philippe Mathieu-Daudé --- tests/qtest/boot-serial-test.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c index 3b92fa5d50..5cb309ccf0 100644 --- a/tests/qtest/boot-serial-test.c +++ b/tests/qtest/boot-serial-test.c @@ -70,18 +70,23 @@ static const uint8_t kernel_plml605[] = { }; static const uint8_t bios_raspi2[] = { - 0x08, 0x30, 0x9f, 0xe5, /* ldr r3,[pc,#8] Get base */ + 0x10, 0x30, 0x9f, 0xe5, /* ldr r3,[pc,#8] Get base */ + 0x10, 0x20, 0x9f, 0xe5, /* ldr r2,[pc,#8] Get CR */ + 0xb0, 0x23, 0xc3, 0xe1, /* strh r2,[r3, #48] Set CR */ 0x54, 0x20, 0xa0, 0xe3, /* mov r2,#'T' */ - 0x00, 0x20, 0xc3, 0xe5, /* strb r2,[r3] */ - 0xfb, 0xff, 0xff, 0xea, /* b loop */ + 0x00, 0x20, 0xc3, 0xe5, /* strb r2,[r3] loop: */ + 0xfd, 0xff, 0xff, 0xea, /* b loop */ 0x00, 0x10, 0x20, 0x3f, /* 0x3f201000 = UART0 base addr */ + 0x01, 0x01, 0x00, 0x00, /* 0x101 = CR UARTEN|TXE */ }; static const uint8_t kernel_aarch64[] = { - 0x81, 0x0a, 0x80, 0x52, /* mov w1, #0x54 */ 0x02, 0x20, 0xa1, 0xd2, /* mov x2, #0x9000000 */ + 0x21, 0x20, 0x80, 0x52, /* mov w1, #0x101 */ + 0x41, 0x60, 0x00, 0x79, /* strh w1, [x2, #48] */ + 0x81, 0x0a, 0x80, 0x52, /* mov w1, #0x54 */ 0x41, 0x00, 0x00, 0x39, /* strb w1, [x2] */ - 0xfd, 0xff, 0xff, 0x17, /* b -12 (loop) */ + 0xff, 0xff, 0xff, 0x17, /* b -4 (loop) */ }; static const uint8_t kernel_nrf51[] = { From patchwork Fri Jul 19 18:10:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813407 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877516wro; Fri, 19 Jul 2024 11:12:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWvJLAb3eF7DWHIJ84ICUUrjvfnnFlP5ck/D3oZMcwMYnZsU84HXF8MmwzlDDfEDkTmJs3huF5Q6U20L5mJORlo X-Google-Smtp-Source: AGHT+IGpt0aOnGh/LAGnActdFsjfKQ+I3Hc/OhCOHnj3/Jfo1/Cq9YHhO4kUitq30+WZ38KBPluI X-Received: by 2002:ad4:5f8b:0:b0:6b7:9c28:4cc9 with SMTP id 6a1803df08f44-6b79c285cdamr80046426d6.51.1721412763710; Fri, 19 Jul 2024 11:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412763; cv=none; d=google.com; s=arc-20160816; b=JQIEWZ19vcx0jE4NW2DBNGg1qCMOpyIOySFTT7v6IeEyKptDf6px0KL1OrYEI1iqZx XdMpzheZ2MpOq2BcHAEL3MUWgh7O4XAn1exCEByUpQmeM10QvNtcRjfBE6Abw1VVDdiL 2QsDO4MR1hZrbREgI2d7utG6La3A7R7KcMsfxS/UdPE2+3geF/DBKRUr8BhSjc5Amczc 4+2/xE5yWlmOIUsU71TBHDc10+tM2Wqcy99DfnhibCT9dXbODcqoBc+v+oghIsZFd0Vk jFD7/ZE1zpUCysg8D7ppek0nU3CAAM4UKGZYjpeUo0Vdz/UEAVBHvrIgcSg3AbhiHCtE zmww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=grsGKEIQC5JMZTvNvSN/qnaW61vNteYTEI5sYVegySE=; fh=8nLw5DkymCkC7Fl2VB/6HOK2iJbyi0CR8pyTF7gwHbU=; b=k6Typ8hQUqq+nhBnFI7203YZaitp65L1EyBslK5Oc45e8tbKuViKrgNbXw08u4ae30 /KAIMrMc0GXAx5Us05l5GhmuM2HqQjnNtxIaFwmRMVXpPUiUA1n6hdiTTFqj/qoArKCd bJw3XPLiA4YqhEufpcctD/nenLni+Jc8W5TnamPW/Mg5hQN3hm3iFk0ZwMPs7lL2jIKx ih16vVCZpQYGyIgTzWPb1SNlcdepd+4IleyZx0snUAkkODw9oJpZ+MSNDQF3747yVkRX yC6kVznxgS/lNiM/Ga0VmIcbPuCkgyCPvMgYo6TOkMn/yY1N0/1YHJMBEvKJkca+EX+m KVnQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSZEVosb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7ac9b8e8fsi21592316d6.340.2024.07.19.11.12.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSZEVosb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs5b-0005p8-P9; Fri, 19 Jul 2024 14:12:25 -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 1sUs5D-0004oL-Pd for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:59 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs59-0003vh-QJ for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:54 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4277a5ed48bso14848395e9.2 for ; Fri, 19 Jul 2024 11:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412707; x=1722017507; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=grsGKEIQC5JMZTvNvSN/qnaW61vNteYTEI5sYVegySE=; b=rSZEVosbJZE0iEj3ZcpATu6RmNENH2lcc3RRV1yZ026+vxKQdVsTffeAjTqDmwrq/c m+NLZz7Nc+i7ChbtiMBWfa7fRvygtn8oKm5R6EpggYoAgbYr/r/MQx7/zSh6sTb3VODm 4y9R8HL7sssqOjuWnHwCtcgH4+IBQgT4o9ZRiBcqLqVuvIJV2wckjJma/IOsBRgwbYod /ImD1KzefSI8vAQMJUJtSY3LfBQ2hCEfsKve0qQG3tKOjtckXhBfEd8a2O6/b2pjvajs bXWRYhum7j5CRlk2dhZcPojt5a5nOJLhM8plJMhtWpLxu/khacWuiXqyNr5+09ZW5+j3 P6Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412707; x=1722017507; 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=grsGKEIQC5JMZTvNvSN/qnaW61vNteYTEI5sYVegySE=; b=jSzJONYc5jYgXNuk/ZimapJ15cOoby8y4TY08iuVeSd2PjnkLgcTf2nIeseHGF1Tn+ SqYBBGddHB0vBlwGy9VZ40b2TuzyHeKMzdvTMKPU+BlGIAMNzJ41uWzqmAtiXW21qtzh Wqh7ib6bb5zTNzciLPunLc/AGWLC5WJQMKqvenLzlQpUgPS8nndWRKh6yDzq9GdyKsFy Qyk41sfPt5uJ5qJmt0vzRAjN7HyVRj8QTPqUQ/hIwZMQ1NW57AEUPY+C2GXnMljoYqDx dvQwkV05VDTpUVv9aUwYydWXKTti/e9ExDi+iIzOXNy7WwE3Vqom9nvovII742dpEyHQ j/Ew== X-Gm-Message-State: AOJu0YxmqindwNsj7QuGBLBEnapP/poIttex/S1AFzrqCWK6QwLZ2p6W b11nVLdmuQnsNcGKot3WIANZGpzQ+Hde8dYd86GUE1kCOzQ+d02I+XgXlR3lBO7fM2+fmB6O4zF R X-Received: by 2002:a05:600c:3d9a:b0:426:6ed2:6130 with SMTP id 5b1f17b1804b1-427c2cb6a6bmr54800415e9.14.1721412707456; Fri, 19 Jul 2024 11:11:47 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d6906a96sm34009935e9.22.2024.07.19.11.11.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:47 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v5 10/16] hw/char/pl011: Check if receiver is enabled Date: Fri, 19 Jul 2024 20:10:35 +0200 Message-ID: <20240719181041.49545-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Do not receive characters when UART or receiver are disabled. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- 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 c76283dccf..0ce91c13d3 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -85,6 +85,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define CR_OUT1 (1 << 12) #define CR_RTS (1 << 11) #define CR_DTR (1 << 10) +#define CR_RXE (1 << 9) #define CR_TXE (1 << 8) #define CR_LBE (1 << 7) #define CR_UARTEN (1 << 0) @@ -481,9 +482,11 @@ static void pl011_write(void *opaque, hwaddr offset, static int pl011_can_receive(void *opaque) { PL011State *s = (PL011State *)opaque; - int r; + int r = 0; - r = s->read_count < pl011_get_fifo_depth(s); + if ((s->cr & CR_UARTEN) && (s->cr & CR_RXE)) { + r = s->read_count < pl011_get_fifo_depth(s); + } trace_pl011_can_receive(s->lcr, s->read_count, r); return r; } From patchwork Fri Jul 19 18:10:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813406 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877510wro; Fri, 19 Jul 2024 11:12:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVI9WkImqDoqQxpBnmLfIoMFFMEj9i2GKh2lyHDEHsAbBZDnMovB1Pz7Eej62X6pP3sCsaQqLcZy2Dnww4SUaUU X-Google-Smtp-Source: AGHT+IGMsniN62it7r6aEqELR+73e//1KXh9HpSBI2tWm4+b2/s4881M11ueNZSYfY8a86gFYGEN X-Received: by 2002:a05:622a:24e:b0:447:dc9a:9240 with SMTP id d75a77b69052e-44fa525cc38mr7507851cf.8.1721412762432; Fri, 19 Jul 2024 11:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412762; cv=none; d=google.com; s=arc-20160816; b=s4md86/CKUEhysk0ZCz7xZm8X6TWPfsiFFNGbh5Cpzlblvie4ZgbtGF025ZaHLkUaD JkN1OKr+yN5VOQxaZ2VcDlMYp2v0gFRFvDLEy8V10RmciR6Ef9ZDSg3lHNgyRBbTVi4G Osq6LDLyHq+5FzoghVsCzd3kEkuhmSFKhc70qa/WsbMechH9LSFC65cB59Uwh2aYdllf dEG1sCZ955FdzyiD3D+abuHT1MwIT9FXuEj01DKlv3lsP9kFYoKviIipk6pV++rqZHYs SX1jRR392Lp6JTdCJmMO/s31xPGE9NRMf36/nwDMgYGm3podx6pd7C4/EM1ThgSgh6ef DVkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Lr9xFBvmiXrV+CsrPSg+/78zPNAgl06z+/3j2DOHoiE=; fh=8nLw5DkymCkC7Fl2VB/6HOK2iJbyi0CR8pyTF7gwHbU=; b=B9yNdPQpaFlFFp6CiLJNE5edF1B7kEKMbk0qW+PLTPnK7yFWuGuimI2YlYcU46Ym7c enusxprhEXGky89XpCe8PJARhcjlcjqyQNKnkJ4IolZmeX4e8X5f2YJ4/OLuvbIa94AX ydzdEZWLih5ctRIuKFYuHb+TvPGX3l+FVGPtIs7NXGGgx/xPZtbVNoM5dfTU+4O2DX8l Cbt5W+vtXeWE+6z6t+RYpXueeA9vSCJ/EcXRCFPScJd8/9swyssTg47WiZo47YFUo6kj uaypefKdN/4aej6j2DSxQr8IbrNyyIM2GnnLsAyloLenmJWXgrV547FWrrxzauOprKXS rB6g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bVH804gc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cdd30e9si21465301cf.398.2024.07.19.11.12.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:12:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bVH804gc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs5m-0006JE-30; Fri, 19 Jul 2024 14:12:32 -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 1sUs5H-00052D-J5 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:03 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs5E-0003yG-P5 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:11:58 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-367e50f71bbso899460f8f.2 for ; Fri, 19 Jul 2024 11:11:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412714; x=1722017514; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lr9xFBvmiXrV+CsrPSg+/78zPNAgl06z+/3j2DOHoiE=; b=bVH804gcJd/lt8vcj4B9UObTTlo8ioE3Jkk/DoOeg8Gsd8scIK/QVRbd8odaBqpSH1 dx8wd/l75JJDFmVUGpDqaHZQwaCmkDL8p/h08JN2nRHFYnEFxX4f70a12+/U2rjBSptM 8tauZDVg2Ye/6pil/gvDve7TgzNdX21m0kXhIrlmQXDX9jyS2B0468aECEjd+oVpOTsF IPDr6/1OkVFVBk5aOwYRwnJrtnlQSMyVY1eHJFCcSqfoMjxDII+sVtSr9QHMEp81Wt8J IwP6RzWUamSsg+j2/pcQbnwI1uH57aHsvH6CUpni5oquScT8/dEZOqX0DXT26kZZXaSY nyCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412714; x=1722017514; 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=Lr9xFBvmiXrV+CsrPSg+/78zPNAgl06z+/3j2DOHoiE=; b=gne8ujCUw3DIJGNF5PslGizGVBHpV9dmG/abZpsn+WxxSGEUesLWog4pVYfOtfIHm4 nhKgLqCE4P1nsQpzD9rLtwClf3igq3hZbuof808QycOR5JrmNgjy3EqbyZh98+yW3h/x T3KWOsr6n6I7HhMVx1aRB+JkDfVT2coMup6SDBO04GDUjJv+fEBLaMUfGZoxJasAfoLv D3ywpuhIE+U5aGkfcMnU5VLFgE4bL3ocRqRyD25gwhoy9ljJUBDuIeVbpDApsszALoOB LPNta+Lcl7qL6aE/lABgkX0CXIKM6haR70EpkBTBdwRSEopB1YtKGhltPFd+99YkqjCW THBQ== X-Gm-Message-State: AOJu0YzawIMFRbmTJ+zXNLtFqCxl13kYisi2MzuqxhMaBsx3i83e4jOz bnmXRyGFBQwfP0ZacB3j7NxCphLE9UqTWUFnS63EJLU7MDPHO11PoeiM6+f3eDT/Jzgwyp+BziN C X-Received: by 2002:a05:6000:4026:b0:365:32e0:f757 with SMTP id ffacd0b85a97d-36831737983mr6929266f8f.50.1721412714557; Fri, 19 Jul 2024 11:11:54 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a95530sm55455065e9.45.2024.07.19.11.11.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:11:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v5 11/16] hw/char/pl011: Rename RX FIFO methods Date: Fri, 19 Jul 2024 20:10:36 +0200 Message-ID: <20240719181041.49545-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In preparation of having a TX FIFO, rename the RX FIFO methods. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- hw/char/pl011.c | 12 ++++++------ hw/char/trace-events | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 0ce91c13d3..c42c6d1ac2 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -174,7 +174,7 @@ static inline void pl011_reset_tx_fifo(PL011State *s) s->flags |= PL011_FLAG_TXFE; } -static void pl011_put_fifo(void *opaque, uint32_t value) +static void pl011_fifo_rx_put(void *opaque, uint32_t value) { PL011State *s = (PL011State *)opaque; int slot; @@ -185,9 +185,9 @@ static void pl011_put_fifo(void *opaque, uint32_t value) s->read_fifo[slot] = value; s->read_count++; s->flags &= ~PL011_FLAG_RXFE; - trace_pl011_put_fifo(value, s->read_count); + trace_pl011_fifo_rx_put(value, s->read_count); if (s->read_count == pipe_depth) { - trace_pl011_put_fifo_full(); + trace_pl011_fifo_rx_full(); s->flags |= PL011_FLAG_RXFF; } if (s->read_count == s->read_trigger) { @@ -221,7 +221,7 @@ static void pl011_loopback_tx(PL011State *s, uint32_t value) * * For simplicity, the above described is not emulated. */ - pl011_put_fifo(s, value); + pl011_fifo_rx_put(s, value); } static void pl011_write_txdata(PL011State *s, uint8_t data) @@ -502,13 +502,13 @@ static void pl011_receive(void *opaque, const uint8_t *buf, int size) return; } - pl011_put_fifo(opaque, *buf); + pl011_fifo_rx_put(opaque, *buf); } static void pl011_event(void *opaque, QEMUChrEvent event) { if (event == CHR_EVENT_BREAK && !pl011_loopback_enabled(opaque)) { - pl011_put_fifo(opaque, DR_BE); + pl011_fifo_rx_put(opaque, DR_BE); } } diff --git a/hw/char/trace-events b/hw/char/trace-events index 8875758076..59e1f734a7 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -58,8 +58,8 @@ pl011_read(uint32_t addr, uint32_t value, const char *regname) "addr 0x%03x valu pl011_read_fifo(int read_count) "FIFO read, read_count now %d" pl011_write(uint32_t addr, uint32_t value, const char *regname) "addr 0x%03x value 0x%08x reg %s" pl011_can_receive(uint32_t lcr, int read_count, int r) "LCR 0x%08x read_count %d returning %d" -pl011_put_fifo(uint32_t c, int read_count) "new char 0x%x read_count now %d" -pl011_put_fifo_full(void) "FIFO now full, RXFF set" +pl011_fifo_rx_put(uint32_t c, int read_count) "new char 0x%02x read_count now %d" +pl011_fifo_rx_full(void) "RX FIFO now full, RXFF set" pl011_baudrate_change(unsigned int baudrate, uint64_t clock, uint32_t ibrd, uint32_t fbrd) "new baudrate %u (clk: %" PRIu64 "hz, ibrd: %" PRIu32 ", fbrd: %" PRIu32 ")" # cmsdk-apb-uart.c From patchwork Fri Jul 19 18:10:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813419 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp878258wro; Fri, 19 Jul 2024 11:14:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU+yj4NB2GuJ1rIndQiLHWea8gM83u4Z9iQ6C3kOcPnxH++AE9bQmLqekhd60gE1o0hTV6Hw8gI7Q2E6C5n41Mz X-Google-Smtp-Source: AGHT+IFBVPu+GLQe8ZNwyIs0B355+K4KzBk8wWU90Q1bICXGNyqYIm6/tDGHe1xeZqOjq7Jd34QB X-Received: by 2002:a05:622a:189d:b0:447:f323:28be with SMTP id d75a77b69052e-44fa5383becmr8200801cf.60.1721412885077; Fri, 19 Jul 2024 11:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412885; cv=none; d=google.com; s=arc-20160816; b=L0BQvqCQPl3jx7QfY8WYu5leo+osGzRizdJaWp9KZPGWBEd2bui38bwzqvxJtkqn90 ndP0fICCIx5enN9CqKY8a87ryozcMwxoIvqYJmarmiX5cnmcemWcL7YLyiXNaTu8SrRa VFD4yH+9Dp4/vOiwfGEr/cly1ijxOwvPqve5KYgBE9P9i4ABvU4kbAqRTAD8rcvgy7l9 JfbLpCRwCL9URH4r6sl+H0ocbGtagpLae2IUo81EwN6AHprToqCSslpzn0jpGOM7cEER 37W7aZVKWPV2ut8VHr1Cub5sVhbTSiCfAyiOcIc9TBxz7qk6xYvybDJNJ7B4k6AqK6Dr xK5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Sc6hQLwehuuiEKoTJDdG/35Ecq31WpA7x5boBSd7PGs=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=srYA4ZxYXW+Ep4NHA6ynncRXfRX49CbjoS6WDW6bHzMxCnyiS/G1ps6xtMODui0biM N0mNm36ox7eLGBfLT824TyvEJaVy6EG1ZAYlDcasjbpxyNjmmDo8+wvempZutJLdJZow xBbOgsJAx9GmO4AoKYAnSB/8H2oUgv+ShASQpA9OpDGDUPX2xzMFQusQ2qu2qMPQoQQI Bo+IW5SE8EgLR5wK7YwRA+f/Is6/iTnn46j20sz3FFVcNxEVF2vIIWBKcwDiTJgCqsQy wm6/9Mr/JXPqEGKJzJ431oOJReNoPOKtm6YLIiXfeeBFRltV0RciJkgG3Zbld2vdn5Vv LNAw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rhlE/7xW"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cdff389si20647761cf.579.2024.07.19.11.14.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:14:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rhlE/7xW"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs5u-0008Mk-3r; Fri, 19 Jul 2024 14:12:38 -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 1sUs5N-0005V1-9Y for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:06 -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 1sUs5L-0003zG-C9 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:04 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-427db004e36so251075e9.3 for ; Fri, 19 Jul 2024 11:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412721; x=1722017521; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Sc6hQLwehuuiEKoTJDdG/35Ecq31WpA7x5boBSd7PGs=; b=rhlE/7xWSjDrR2tviEFUxz6yrqRC5LzHu+NNlP6cmptjtK8jvqEa5aQyehTzAWFmIr iLEpTaPEjC1iaf+OcTBO52I0mh4tAU6MUhWvGc0Jqer5thPLOnMrA6tDLyklraAAj8qD iGYVBa52tinFQwoHdL0cwW1+ro9Ojm0CeNWKbViN3cCHZSo2aNZUplfbXOYNXvAoi/RG LyZuJYEgV4CzJf2RZMTfLHSWmXl602/e2BYiFj5/CAn8+FPkO9vOhF4/P/qGnznB6MV6 7FozfmDPVB68b3+ywIqCza85bXK3gsSbuLxiqX522nA4n6mr/xa+bLIkCvSGzXRVmHXa gILg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412721; x=1722017521; 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=Sc6hQLwehuuiEKoTJDdG/35Ecq31WpA7x5boBSd7PGs=; b=HZFkXk7ZAJ1SH4iiOE1LHhsWTkuNA/4YjMvCawYlM/e7B2ULY1BDx9K+4v6aCzifXy hdf5lXiWOllDpZUGvYZR1GxI3JCbC3iUAMlmjZO6tF3WluNqdQ3qMeK/4yTWzVjRAcm2 VgbGisJyRSuTIIlpApr8GmOczlSIl6lKyGSCvfV3Lr4XgFFkg0lUkgQW1eQdul51nQ8d /tRUnEXnOnDYrlYxKs9orYj7cGXiO6frm+rRIw0NPB/JMRwM1chmzUk3BcyXumfEWSsb BE0MYs/FUHzIYaAWplgHNq0movfqFwzszqAl1KbbCi4Z9obnwRxepeiZWMgui8btsRq1 /+6w== X-Gm-Message-State: AOJu0Yzw38kqTZD6VmcXJidi+lZ8sqjvgo8HXG2Nb9NQZOqbq3bdD45u 04JtalNSHDbr2XgZ0KL6jK2/3EsQKCD9nu4D6VkR3Q8ajkTXu0yvRME3VZYT6/9GMiNs4n8n3xZ 6 X-Received: by 2002:adf:e6c2:0:b0:367:97e7:879a with SMTP id ffacd0b85a97d-368317c0425mr6182998f8f.65.1721412721673; Fri, 19 Jul 2024 11:12:01 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878684230sm2257427f8f.17.2024.07.19.11.11.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:12:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 12/16] hw/char/pl011: Add transmit FIFO to PL011State Date: Fri, 19 Jul 2024 20:10:37 +0200 Message-ID: <20240719181041.49545-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In order to make the next commit easier to review, introduce the transmit FIFO, but do not yet use it. We only migrate the TX FIFO if it is in use. When migrating from new to old VM: - if the fifo is empty, migration will still work because of the subsection. - if the fifo is not empty, the subsection will be ignored, with the only consequence being that some characters will be dropped. Since the FIFO is created empty, we don't need a migration pre_load() handler. Uninline pl011_reset_tx_fifo(). Reviewed-by: Alex Bennée Signed-off-by: Philippe Mathieu-Daudé --- include/hw/char/pl011.h | 2 ++ hw/char/pl011.c | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h index 4fcaf3d7d3..e8d95961f6 100644 --- a/include/hw/char/pl011.h +++ b/include/hw/char/pl011.h @@ -18,6 +18,7 @@ #include "hw/sysbus.h" #include "chardev/char-fe.h" #include "qom/object.h" +#include "qemu/fifo8.h" #define TYPE_PL011 "pl011" OBJECT_DECLARE_SIMPLE_TYPE(PL011State, PL011) @@ -52,6 +53,7 @@ struct PL011State { Clock *clk; bool migrate_clk; const unsigned char *id; + Fifo8 xmit_fifo; }; DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr); diff --git a/hw/char/pl011.c b/hw/char/pl011.c index c42c6d1ac2..6519340b50 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -167,11 +167,13 @@ static inline void pl011_reset_rx_fifo(PL011State *s) s->flags |= PL011_FLAG_RXFE; } -static inline void pl011_reset_tx_fifo(PL011State *s) +static void pl011_reset_tx_fifo(PL011State *s) { /* Reset FIFO flags */ s->flags &= ~PL011_FLAG_TXFF; s->flags |= PL011_FLAG_TXFE; + + fifo8_reset(&s->xmit_fifo); } static void pl011_fifo_rx_put(void *opaque, uint32_t value) @@ -545,6 +547,24 @@ static const VMStateDescription vmstate_pl011_clock = { } }; +static bool pl011_xmit_fifo_state_needed(void *opaque) +{ + PL011State* s = opaque; + + return (s->lcr & LCR_FEN) && !fifo8_is_empty(&s->xmit_fifo); +} + +static const VMStateDescription vmstate_pl011_xmit_fifo = { + .name = "pl011/xmit_fifo", + .version_id = 1, + .minimum_version_id = 1, + .needed = pl011_xmit_fifo_state_needed, + .fields = (VMStateField[]) { + VMSTATE_FIFO8(xmit_fifo, PL011State), + VMSTATE_END_OF_LIST() + } +}; + static int pl011_post_load(void *opaque, int version_id) { PL011State* s = opaque; @@ -599,7 +619,11 @@ static const VMStateDescription vmstate_pl011 = { .subsections = (const VMStateDescription * const []) { &vmstate_pl011_clock, NULL - } + }, + .subsections = (const VMStateDescription * []) { + &vmstate_pl011_xmit_fifo, + NULL + }, }; static Property pl011_properties[] = { @@ -614,6 +638,7 @@ static void pl011_init(Object *obj) PL011State *s = PL011(obj); int i; + fifo8_create(&s->xmit_fifo, PL011_FIFO_DEPTH); memory_region_init_io(&s->iomem, OBJECT(s), &pl011_ops, s, "pl011", 0x1000); sysbus_init_mmio(sbd, &s->iomem); for (i = 0; i < ARRAY_SIZE(s->irq); i++) { @@ -626,6 +651,13 @@ static void pl011_init(Object *obj) s->id = pl011_id_arm; } +static void pl011_finalize(Object *obj) +{ + PL011State *s = PL011(obj); + + fifo8_destroy(&s->xmit_fifo); +} + static void pl011_realize(DeviceState *dev, Error **errp) { PL011State *s = PL011(dev); @@ -669,6 +701,7 @@ static const TypeInfo pl011_arm_info = { .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(PL011State), .instance_init = pl011_init, + .instance_finalize = pl011_finalize, .class_init = pl011_class_init, }; From patchwork Fri Jul 19 18:10:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813417 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp878213wro; Fri, 19 Jul 2024 11:14:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVQSSCiuSOfNoHrb4Gcvoq7yCnYW5IvjY1hx9Y1j3L6orLT9CV6AY8czxvWcJh1lVqrt5glg5D8kShceBEDVNvV X-Google-Smtp-Source: AGHT+IH1RxHVYXCiSoLBiQyCNJd4YWD3L5UmPO/m8H1kigrLnzLUDtUiJXkR0HY2kLgvPDyAC+N2 X-Received: by 2002:a0c:e944:0:b0:6af:c2ec:3313 with SMTP id 6a1803df08f44-6b79cd6b0bdmr100338966d6.26.1721412879397; Fri, 19 Jul 2024 11:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412879; cv=none; d=google.com; s=arc-20160816; b=d3rK+C/w1ve3TzNzqBtuM1AW/7X1BF1M/6qhZ95vF4jMjfojaJsIPE00XaHyU6B8BY J+I1U++njhC11n3QilCginwv4hVlRYlMWS5NEpBXLW/rjVo4ON9sZP3T68CUgVZygon3 7XlsY5QK+jtnHz83D2f55O9dzhFsKAMOKMytJHtwMeAlDWZj5cdQAZ0gCZDajRedA2wR gHb7asRT1srUQJAu/IWofJA3Xcec9/jCjLTpceERF8DePiZbAa0xPaMOkCSq1lDbdoZ8 8MOZlXcrqGb9uSVShwZUMs8Epsi+K/ejdzG/LMyHmBk6Q/NqH/XzlKa1y9GTPga/0gC6 hf3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=liDvD10Kju4SXJGwkPuAqGOs/WSuNz1hvgqWr6MAicc=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=kutUvMCzSTH/em7XZOUW64/pMnDuEa679e/2ToPDdJrmeZSa5Eu7LZv2ZjpVrnxd4f kkN3OBA3FgME0LuNBTAXnSy0qZyeJHkuOLN9QoK1Foq7vp38Kmex3k+TlUjimyvTA34M MR5jmgjYmN3RnFX6uC1t9LLsTb69h9Sv4DpOkzFEOCBdJy7Z5GeEPU3Jqk/a2dlB86sP 8c+acA8QiUMip4fQAhDiSnTf+9HArwp1I5PGLzHPpkTTaTYuHDK+4Zll7uS+qRoQ3icf Yx5W+/iQbhgXhB3quJxftq1i0VoB2ADIwoq3yEO8GesGA8X82AryYRjcz7jNEatlxwKQ Sraw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rGTHTFzt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7acb0fc30si21562796d6.539.2024.07.19.11.14.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:14:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rGTHTFzt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs5s-0007qX-0g; Fri, 19 Jul 2024 14:12:36 -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 1sUs5U-00061H-KA for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:15 -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 1sUs5R-00040Z-OZ for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:11 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4266ea6a488so16327295e9.1 for ; Fri, 19 Jul 2024 11:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412728; x=1722017528; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=liDvD10Kju4SXJGwkPuAqGOs/WSuNz1hvgqWr6MAicc=; b=rGTHTFztX9peVezqgLUNuQ3CINe0RG9R7/jirrZK151gVRdEU7d41Fno9aS9dpyHSn bougTfEUlk+Uy1j89Nfk1Zb9WzxHOnJHZ4a8C9O9pZYLXhiva1/SbX930da/nv3dRJfI JsI1q2IOGYG4w8woukLGXgsZA1VoU+j8EXFeOesnzIdwKxUxB74vObW0fCHzoq8eP03n jAv+PHLuMktriPm4a5UNUYl99zzLBXG20Ra4zqxMTasOKT/z6C97Pn3XjbqQkxpqgRmm iyZJ6/RbEAIBzBqeO8tAWKl4dVLodsYRZ14xUytxI+tMdQUXcFDiyduwYLkjXWA3FRgb hfBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412728; x=1722017528; 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=liDvD10Kju4SXJGwkPuAqGOs/WSuNz1hvgqWr6MAicc=; b=VYqrSTCsy707gMsyh5p5LqoFfErBDUZcY7ymwPOCQZ6Svy3vVtCr0iiddEUtWfZGLK QoxUd+lC6Yj1UbXxRmhx1LYJRPy+ZrWWCFPgLHp7O4bxwhWVO9XaJKmc48lVlhp+8Mu9 QA98nA/Etub9qZp4/YZaUSU17f3cc3GbUgfTM6pH9bsDSxsokbijjtAqbeNbCjl8MN2s DN3L1XWJWznnTq+i5WIhNhp4Kp3AdEuh+JSwA6dnkzLelLAd2G81V+4SGNpBHIFFehwM xnYj+/zqOIyvc3E5NS6XuJB80NZI7zL/XpUehyYY2AeMgLl4HJi0V4hFIDkmnCo+PHTa qgkQ== X-Gm-Message-State: AOJu0Yy+7Dy6Ep4p8M5y3cDjwjN0l1pDhCi0J/8AAzrxgsZsEkyqV0M9 BkdEqjb6Rmm1JpWkhlL85lTgLyQQ2gUZ03dNujFJ8+5ChKmb1QT5d3VWR9seTR1hsMbYiyPRFx2 7 X-Received: by 2002:a05:600c:3595:b0:426:5c81:2538 with SMTP id 5b1f17b1804b1-427c2cb8a05mr68634095e9.14.1721412727834; Fri, 19 Jul 2024 11:12:07 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d6929827sm33457315e9.34.2024.07.19.11.12.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:12:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 13/16] hw/char/pl011: Introduce pl011_xmit() as GSource Date: Fri, 19 Jul 2024 20:10:38 +0200 Message-ID: <20240719181041.49545-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Extract pl011_xmit() from pl011_write_txdata(). Use the FIFO to pass the character to be transmitted. Implement it using the FEWatchFunc prototype, since we want to register it as GSource later. While the return value is not yet used, we return G_SOURCE_REMOVE meaning the GSource is removed from the main loop (because we only send one char). Signed-off-by: Philippe Mathieu-Daudé --- hw/char/pl011.c | 30 +++++++++++++++++++++++++----- hw/char/trace-events | 2 ++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 6519340b50..6394d6eb36 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -226,6 +226,28 @@ static void pl011_loopback_tx(PL011State *s, uint32_t value) pl011_fifo_rx_put(s, value); } +static gboolean pl011_xmit(void *do_not_use, GIOCondition cond, void *opaque) +{ + PL011State *s = opaque; + int bytes_consumed; + uint8_t data; + + data = fifo8_pop(&s->xmit_fifo); + bytes_consumed = 1; + + /* + * XXX this blocks entire thread. Rewrite to use + * qemu_chr_fe_write and background I/O callbacks + */ + qemu_chr_fe_write_all(&s->chr, &data, bytes_consumed); + trace_pl011_fifo_tx_xmit(bytes_consumed); + s->int_level |= INT_TX; + + pl011_update(s); + + return G_SOURCE_REMOVE; +} + static void pl011_write_txdata(PL011State *s, uint8_t data) { if (!(s->cr & CR_UARTEN)) { @@ -235,12 +257,10 @@ static void pl011_write_txdata(PL011State *s, uint8_t data) qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX UART\n"); } - /* XXX this blocks entire thread. Rewrite to use - * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&s->chr, &data, 1); + trace_pl011_fifo_tx_put(data); pl011_loopback_tx(s, data); - s->int_level |= INT_TX; - pl011_update(s); + fifo8_push(&s->xmit_fifo, data); + pl011_xmit(NULL, G_IO_OUT, s); } static uint32_t pl011_read_rxdata(PL011State *s) diff --git a/hw/char/trace-events b/hw/char/trace-events index 59e1f734a7..30d06a2383 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -60,6 +60,8 @@ pl011_write(uint32_t addr, uint32_t value, const char *regname) "addr 0x%03x val pl011_can_receive(uint32_t lcr, int read_count, int r) "LCR 0x%08x read_count %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(uint8_t byte) "TX FIFO push char [0x%02x]" +pl011_fifo_tx_xmit(int count) "TX FIFO pop %d chars" pl011_baudrate_change(unsigned int baudrate, uint64_t clock, uint32_t ibrd, uint32_t fbrd) "new baudrate %u (clk: %" PRIu64 "hz, ibrd: %" PRIu32 ", fbrd: %" PRIu32 ")" # cmsdk-apb-uart.c From patchwork Fri Jul 19 18:10:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813412 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877647wro; Fri, 19 Jul 2024 11:13:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUxaDjeQlC+NpVxszno0s1njSGfqYEgdTJMwBD5hercfa7y86z32BXor+LyrdVASvy9JLixG6NsU37QekgexZLe X-Google-Smtp-Source: AGHT+IFh9qSEVaRHAMsukGTe7OXl13Ig016J+VKor6r7dJDMkrOkZjVIdsBnDn/VlurcZ8sDOw05 X-Received: by 2002:ad4:5744:0:b0:6b7:4319:ad6f with SMTP id 6a1803df08f44-6b95a6e95camr8916426d6.36.1721412782857; Fri, 19 Jul 2024 11:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412782; cv=none; d=google.com; s=arc-20160816; b=WjyskK1YSUh5OMYAxyJ/LkaKlcZnXd4Ly7VsWanFkOtO5K/5xdZY9goj6qDcf/5btV xBkOiPts1nbK+AV8UHFRWmF1VjKBrC9GiVMK0hiuP2LuPZf2GRwyMcINxdcVd/5/juj6 zVEy7qMbhNtkvDvx1S8+QFqcctmppCmpx1HYHqB+XT7coT06+aylltO3gKZuN5pk2qQK XHRCgOKwqcr/I7ymI9qObV55x0id4x2oaKbtJZ8JZg2c/fCKah0ZY2UjXeOui/Nkudii oY88XZN/spSc83WJSfis3Azp4WbV2cG/CNpmAT/MmV3/pkzP+6oWISDT9PtpBM+GCY8J mWzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Kzt7MO4LraScd40R9aNwzx12/7fqeBF/DeM0jkgAnc4=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=QeFoJKVjidb5EI8E7n1hPqDUg/2Hra5g6fcT17FCIJN1etoqBF5g9f3A90rcjwSWWd 7X7wVEE2XbTZo5IqKHwcgjxbIOO+ZNhKclqneFtwv0TVKUcav0HlNHn/8RzPC1W4z3IS qqyVHzKZG0ifwnlVI6YBevbsWwhPcGCMChEFQFUBqVGCY/4//xOU+tILtMdY8k1LbooI wXETr95j6W+DJSIciUnzvYoXXIbxFNCenHiiwaSGOfyLsplSzRWqf345rFQsNZIcvIAG pIrohkRQthRTda9ouNrm60cseVRpplZ073Bh/qs76VluJl6xe4tCXpDDOAK30KHkHyWY v5Cw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EeHvyC8/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b7ac9b7d91si22236466d6.326.2024.07.19.11.13.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:13:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EeHvyC8/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs5w-0000I1-3P; Fri, 19 Jul 2024 14:12:40 -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 1sUs5a-0006P1-0S for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:24 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs5X-00041X-HI for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:17 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4267345e746so15652315e9.0 for ; Fri, 19 Jul 2024 11:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412734; x=1722017534; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Kzt7MO4LraScd40R9aNwzx12/7fqeBF/DeM0jkgAnc4=; b=EeHvyC8/Ik2aQQ4eg9NE8B2lQAQxFUU1Bs0CG7RDzozuXK21MVZUkw+bcPCM8Is6hX 9V2k7xAQds1atqL0n13z8zkcmNk/UFDwizhdEGfXbN7UM0APf7jteulrxImdTL1M2a02 0ANlSLHVuNkXVteitL6lHoEatw8dYhCzeHkFVfTKyxZflHieTCczfaKQqpiWDcFfewzX kl+QuzRDTSNcNhItf17ispnimma18nJ4hd7tEFQ7LAeX/zNEKrpimKNylAmwn5HwXP58 1fINEeGb7tT3J54Yp60uBb78eVR/pzJl7odxeByR+bNKxKO1ROPyg6tQP4xFhOgF2WKM FvUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412734; x=1722017534; 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=Kzt7MO4LraScd40R9aNwzx12/7fqeBF/DeM0jkgAnc4=; b=sdoyekXWQc7ric1F8U+v9hhXVXU0J23SVnSW2V6KEL2deqoaq6dOU5hqHlCA0zjJFK iCmlsmP71IhwEgIfcDv8B4TAp32OI0WrOLmR/4iwQwqGPmlCTmPURbdSzs/KgQLSbgyJ sM93nQOD1XbuyXyjfCNHBIYUJUeZPxgfsPsBPuYqIEqY2K0ZbPeV6joDD2r5jQmsqzar z29MdkqoFe5uRHi82djXhouuxJpvileN5AR2NRJgTpuP0jsns2H2f+j9ReIayaJon5Y9 YNvtXz/PbsxqO2M0M1IQVM9IsI0PhzqIYbASEx5pv7lqr8rWhvPIcSEHVSOe/E5rzOcn 7b/A== X-Gm-Message-State: AOJu0Yy7gj3f51WlQnV8LHzizfJwgNvqbgIQ/xQUx2Ncerm6atZkY/PK B69IeVJPS9Y04TPZmfQKcYXR5hKkhYhSdt34XLujAwPhASQsjGLzwLQPtazKPgM1Gy0Zzb2A7G5 x X-Received: by 2002:a05:600c:c08:b0:426:6f15:2e4d with SMTP id 5b1f17b1804b1-427c2cc27f0mr56979845e9.9.1721412733714; Fri, 19 Jul 2024 11:12:13 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a6efc5sm60849745e9.21.2024.07.19.11.12.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:12:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 14/16] hw/char/pl011: Consider TX FIFO overrun error Date: Fri, 19 Jul 2024 20:10:39 +0200 Message-ID: <20240719181041.49545-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When transmission is disabled, characters are still queued to the FIFO which eventually overruns. Report that error condition in the status register. Signed-off-by: Philippe Mathieu-Daudé --- hw/char/pl011.c | 17 +++++++++++++++++ hw/char/trace-events | 1 + 2 files changed, 18 insertions(+) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 6394d6eb36..b8cde03f98 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -61,6 +61,9 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) /* Data Register, UARTDR */ #define DR_BE (1 << 10) +/* 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) @@ -232,6 +235,13 @@ static gboolean pl011_xmit(void *do_not_use, GIOCondition cond, void *opaque) int bytes_consumed; uint8_t data; + if (!(s->cr & CR_UARTEN)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled UART\n"); + } + if (!(s->cr & CR_TXE)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX UART\n"); + } + data = fifo8_pop(&s->xmit_fifo); bytes_consumed = 1; @@ -257,6 +267,13 @@ static void pl011_write_txdata(PL011State *s, uint8_t data) qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX UART\n"); } + if (fifo8_is_full(&s->xmit_fifo)) { + /* The FIFO is already full. Content remains valid. */ + trace_pl011_fifo_tx_overrun(); + s->rsr |= RSR_OE; + return; + } + trace_pl011_fifo_tx_put(data); pl011_loopback_tx(s, data); fifo8_push(&s->xmit_fifo, data); diff --git a/hw/char/trace-events b/hw/char/trace-events index 30d06a2383..4a9c0bd271 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -62,6 +62,7 @@ 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(uint8_t byte) "TX FIFO push char [0x%02x]" pl011_fifo_tx_xmit(int count) "TX FIFO pop %d chars" +pl011_fifo_tx_overrun(void) "TX FIFO overrun" pl011_baudrate_change(unsigned int baudrate, uint64_t clock, uint32_t ibrd, uint32_t fbrd) "new baudrate %u (clk: %" PRIu64 "hz, ibrd: %" PRIu32 ", fbrd: %" PRIu32 ")" # cmsdk-apb-uart.c From patchwork Fri Jul 19 18:10:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813416 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp878162wro; Fri, 19 Jul 2024 11:14:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVIB0dhMjZyhWr8T0/hEEy5GHC3kDQRRzS29/leeRlPw8TLcywvH/8fktch6UJEVhJ4ckT/23P3GC/83KVVl9nC X-Google-Smtp-Source: AGHT+IHU6sCWXYB1YnSjHPe9Cpivo/YBdKgvVidsZr2Iplne7oyH+COyW/9D3kP0MXMI2gx7v9Yx X-Received: by 2002:a05:622a:1193:b0:447:df17:5116 with SMTP id d75a77b69052e-44fa525e06amr8005931cf.7.1721412871138; Fri, 19 Jul 2024 11:14:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412871; cv=none; d=google.com; s=arc-20160816; b=f3+ewiiT+cGZQioYFDyHqV7I+xWfaQPHgUFFHLEnJxP5ntF4t4bVagajTWLOxMVTvO NpE0LbTLDKw9TAEFUlMFmLRNdLKWKh86cktxlGRm616fzliS0EP9dzg3WzO+sLRThhvB sBxalUVmuqc11c9umVRd/n+kYujK3y6ezXlE3E0CbXIdlXiRTx0WEEoXnWQcFSepL0Ug S+c9N2JrDDo2Q3wqJqHkmEmue4vFHCIaokbiCXohtKIJyzRCMBbt++dOakHA2q9iG0V5 F6Lpd8NlMjYhMwztD72LpvzCNPZKnqGr+E95nAI3lte03y3EmGX6hTY9DHYHQgds/Qbk pp/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/3cF/tU//YplS5nRyz5oLLMVLav+V+FPLOKof/J5MTo=; fh=a4LTsj9O+qaKvI8P1KF8P/8hcdvsQ8EHyfSuvL3yAcM=; b=AKhIK0DqW2OedYu+u5Fx8xujaAPKgK66FremVr6QQhyFq/C5DzU0eqK13iw1uUjpsT 64a5/kSAlyyG/7YkoiaK+mLR84oUn7wKKUXhXgRpn7XMPsqzTYDt2dDYapZFCTTDfqCP nst28DS41O/8Y6woO+X8g3f90WivR2wRTSQ3H0es5STZnfmk9A7/hWimdolWE0S4ided pi72b6lH04yylgC1hcmt8fwJ50a/6FaDtSBIdC5w6+IDOmG6Z+tbmrHFHNEcYdplJtGn DyaVjE7+XSo+MF4IausVwaL+L/JIEBn20TARFMkQe9RYBwqx3a+sNhtZ/lS0V71kehQu QM/g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JuiUZf/2"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ce049dcsi20463791cf.605.2024.07.19.11.14.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:14:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JuiUZf/2"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs6O-0002vg-5q; Fri, 19 Jul 2024 14:13:08 -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 1sUs5g-0006o1-37 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:30 -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 1sUs5e-00042p-CD for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:23 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4266f344091so14865695e9.0 for ; Fri, 19 Jul 2024 11:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412740; x=1722017540; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/3cF/tU//YplS5nRyz5oLLMVLav+V+FPLOKof/J5MTo=; b=JuiUZf/2vEba1fg7Xw+gSyXcl3g/LCwHZise8u3g/cBs3rDGnUr1c5lpVCBBuOAstt v5B0/SRBcTokOTxIU9PaJTTDipO2IYtpZrEfoTHP2OBtq52N47BvauF5T1ck9BH2kLeZ p9Kv/oWIqDHzCqFJY7y+yBFQ+T7fR9/X3Oj0vJu5uH6mIt2f6lQ/rB3ER4ZhZpm5mf/C vrpimojRHiiaK3KxBPBgMmw4sov5WaoMvWHDcExRTIwx16Dketpu1x9OmUYD6NrIOGr+ /PLxfjK5WZVuiuSaniLJWnX/OmqQQdTODUbBcf+6gbb3rkhhNGlqm822abjSzo34YpYG e3lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412740; x=1722017540; 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=/3cF/tU//YplS5nRyz5oLLMVLav+V+FPLOKof/J5MTo=; b=smzQrysEOj95zXeUTTRblPuulxjwTV2xS6J3WEmNBsCq48kNgvaGA6ge5J92/RPkDI xwNUH/xQPvUSw3ZrhmFE3UOUoMW8pINTGilu+VWQBxGkX13FzR8Q4AD6IHVwsEHFb9VL TKlXPyyxwjz7Yk4wkXqOGY5S6mlE8uozlEc9S9aJIxAyZkbJ/dytWWcdxDjGMfzHW/Un spyg3T8Bc+YV5VLkgLLWTrUgXCtSdf88WvRtCWTiFl4dQBtOk2rLJGUAgl5gi0SV4rJL oV2ZrnWmwT5lPhc4G9pFHUNKW5F9yJw3qmy31zJiaqbrmBJavrumzxlSh6kEfqjmZekv nj9A== X-Gm-Message-State: AOJu0Yzh4ortMJmrpvXul620tIFU68LTP17PKG3UQSqnxaKyPYG5QFcv DzBqLv+4B+6U15Xk20Xmk0113MkXpJdnRRNg5VpGi46qv7mlx54Wqvg1On4bCV1FRFKE4LVev0D v X-Received: by 2002:a05:600c:c09:b0:426:640b:73d9 with SMTP id 5b1f17b1804b1-427c2ca9070mr63116805e9.10.1721412739853; Fri, 19 Jul 2024 11:12:19 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68fa0a6sm33549825e9.9.2024.07.19.11.12.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:12:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v5 15/16] hw/char/pl011: Drain TX FIFO when no backend connected Date: Fri, 19 Jul 2024 20:10:40 +0200 Message-ID: <20240719181041.49545-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When no character backend is connected, the PL011 frontend just drains the FIFO. Signed-off-by: Philippe Mathieu-Daudé --- hw/char/pl011.c | 13 +++++++++++++ hw/char/trace-events | 1 + 2 files changed, 14 insertions(+) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index b8cde03f98..cfa3fd3da4 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -229,6 +229,13 @@ static void pl011_loopback_tx(PL011State *s, uint32_t value) pl011_fifo_rx_put(s, value); } +static void pl011_drain_tx(PL011State *s) +{ + trace_pl011_fifo_tx_drain(fifo8_num_used(&s->xmit_fifo)); + pl011_reset_tx_fifo(s); + s->rsr &= ~RSR_OE; +} + static gboolean pl011_xmit(void *do_not_use, GIOCondition cond, void *opaque) { PL011State *s = opaque; @@ -242,6 +249,12 @@ static gboolean pl011_xmit(void *do_not_use, GIOCondition cond, void *opaque) qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX UART\n"); } + if (!qemu_chr_fe_backend_connected(&s->chr)) { + /* Instant drain the fifo when there's no back-end. */ + pl011_drain_tx(s); + return G_SOURCE_REMOVE; + } + data = fifo8_pop(&s->xmit_fifo); bytes_consumed = 1; diff --git a/hw/char/trace-events b/hw/char/trace-events index 4a9c0bd271..bf586ba664 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -63,6 +63,7 @@ pl011_fifo_rx_full(void) "RX FIFO now full, RXFF set" pl011_fifo_tx_put(uint8_t byte) "TX FIFO push char [0x%02x]" pl011_fifo_tx_xmit(int count) "TX FIFO pop %d chars" pl011_fifo_tx_overrun(void) "TX FIFO overrun" +pl011_fifo_tx_drain(unsigned drained) "TX FIFO draining %u chars" pl011_baudrate_change(unsigned int baudrate, uint64_t clock, uint32_t ibrd, uint32_t fbrd) "new baudrate %u (clk: %" PRIu64 "hz, ibrd: %" PRIu32 ", fbrd: %" PRIu32 ")" # cmsdk-apb-uart.c From patchwork Fri Jul 19 18:10:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813413 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp877753wro; Fri, 19 Jul 2024 11:13:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVlMfyWacszTdVm0hsl93Jhty69zeUuDLFKS9dDUJK9pR5pxctdut2Nsg2yhWu4xo9nhc+DxLtXa1sZTNApjDg7 X-Google-Smtp-Source: AGHT+IGBXANgKrlcrLLrWF6JGvv1I8m/h8IMmMxNA/9nn6KXHT+krb/ppuHQaYFdoplZXE3cAZVN X-Received: by 2002:a05:620a:4404:b0:79e:f80a:2ab8 with SMTP id af79cd13be357-7a1a132c7d1mr79578285a.25.1721412797192; Fri, 19 Jul 2024 11:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721412797; cv=none; d=google.com; s=arc-20160816; b=VTFFtvjCx2GZv6rDPinA81IQSubSXFmh9wY5B09NCrOg5/UfGyENDarafbHnqfOshu mwqmyiYZD+Gt0CKXO0TUkE/B2gU4lLz65Afel61GiV+zDjZ4+Fc5b9BDWF3RVkvFjfVc /KBeLYEusMRZoFC9eA2dJQgEf5pDBxJv2llFW0yRRAThwNSz6qBNacLjJatgMcTN8/DY xax6zwogjK4+a1ZOLTQqIXr++MId2sZeZWr7vzVYzbM8ObB2u7b2En74zV/SoNMxM+4v lad/l7nm4FBKBvVi98AhnD6Y5Njbqw0ajB7+NK12AL1cTvv5qjjMJcPAL7fV/Ur8OoJr wEXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e/ZQe/yHYS+wM7PLPDCR+wv5t4w+2k62yQLSsqaNg4w=; fh=hg6N+tB96Hi7gSOq8x6wNArBoIjFiIb8KgmwOCXMiu8=; b=RqDY5vGChC1FseE2O3+i72i4DHgV6jJxson9fEV6mexXD9mH0n7HGxlb1T5iid3jVy GE+GwM5nCKFuuSRJGHrRZ7oz8amXzdwOPwWNUL1iimT2lUGcGvU+jQ+Cg1iMDruRbkfv Sab4uW6L9Lo8f1i78TXhDYzX8jymJUrRDOBkAcWIbWVMSKXNja0j6ts9Iyt1dXY8rDya XaKVIlsRra6lQht0sw0CvKsIM4kvVVsD6+lcJQb9Z/e5zji4zcRbJtTIyMm7KOExvUxM /gZBfgbcILj8hHAe8V+yoqOemwsQECfM8GhX6dvB46jZtKXYfws6zHmAC3ICWZ3RA2pa 3WBg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ema5H3bB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a19904c54esi219048285a.347.2024.07.19.11.13.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2024 11:13:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ema5H3bB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUs6R-0003VL-6Z; Fri, 19 Jul 2024 14:13:11 -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 1sUs5m-0007Bn-I4 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:32 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUs5j-00043c-H1 for qemu-devel@nongnu.org; Fri, 19 Jul 2024 14:12:30 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4266edee10cso13012035e9.2 for ; Fri, 19 Jul 2024 11:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721412746; x=1722017546; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e/ZQe/yHYS+wM7PLPDCR+wv5t4w+2k62yQLSsqaNg4w=; b=Ema5H3bBaCIiunby+hOcZuy9QZbFih2im+s00sAymMZBarnlQUsYk9SiucY/XCdMRS J3dW6jgBzRQprroy9tNv3/gilmIhvX6LlNKuST6cvZeGdzGdIKmVa4UvYlqMjiuTeZsZ 6YaXebypWCXWe5Fw+QtQZQ9CF46JzNgPBdKme00q43FeYylJYaPUYDG9GgJ/Vvp6FzJj K9mtqJ7XyPPYuW0wdT3HCEReYaV0wMpUU2AzMnJ5e7CuJR5mgCk3rtiWpwUfRj3So7gl lEbOlXdrUP36gBd1OYjiTM393qlRT3LEFM3WEQDrkIZFcpR1+X7o/htSb88mQaHJ25zi PKAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721412746; x=1722017546; 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=e/ZQe/yHYS+wM7PLPDCR+wv5t4w+2k62yQLSsqaNg4w=; b=bFuYEtVyw6bRhOoN0UvFyJMTbBj49yDY3tI5YWsdJrvuEpaXNagct49BlJS6Kz7i7I V7b/DiHgUfMq9NraxzAyoXNMvzcr7devv6AXmnc5CI/3ShRwtNUQgcwBAgVGdP1IVP6b v5oo1Dw4yV59cIwB3gFa+ThHEbVgY2LWLYjhsjv92Mbt89eg2UvoyYUhwmhMt+6YAe6g NpOhuuN9JQshudidORMQjWTm1M2irJWnut1gM9Lmhhdroqdzm+HtV9QahhTdIEGDcBOB pC1f5LwK1u42qbh9ULgfLLTta1iM76l7UPWzJ7gOv5Px9GzJLM4J2WevKvAI2kcYyqev UztQ== X-Gm-Message-State: AOJu0Ywbrxgew6tELksbjQf9WrZm69f8FIaFT9W4sLvxCUAbCdGNvFqw 7c5PWFNeGd2Lfr4xsbanwoRUcKqvxMbjX+0W+F/w15nvJUDX2ywIv4YHzxN1T9ACHCnqx9Tdtp/ f X-Received: by 2002:a05:600c:19cd:b0:427:dac4:d36 with SMTP id 5b1f17b1804b1-427dac4132fmr1307245e9.7.1721412745794; Fri, 19 Jul 2024 11:12:25 -0700 (PDT) Received: from localhost.localdomain (52.170.88.92.rev.sfr.net. [92.88.170.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d6929976sm33385325e9.29.2024.07.19.11.12.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jul 2024 11:12:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Mark Cave-Ayland , Tong Ho , Manos Pitsidianakis , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Mikko Rapeli Subject: [RFC PATCH v5 16/16] hw/char/pl011: Implement TX FIFO Date: Fri, 19 Jul 2024 20:10:41 +0200 Message-ID: <20240719181041.49545-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240719181041.49545-1-philmd@linaro.org> References: <20240719181041.49545-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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. 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). Reported-by: Mikko Rapeli Suggested-by: Alex Bennée Signed-off-by: Philippe Mathieu-Daudé --- RFC: Something is still broken, some characters are emitted async... --- hw/char/pl011.c | 60 ++++++++++++++++++++++++++++++++++++-------- hw/char/trace-events | 1 + 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index cfa3fd3da4..9f72b6a765 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -240,7 +240,9 @@ static gboolean pl011_xmit(void *do_not_use, GIOCondition cond, void *opaque) { PL011State *s = opaque; int bytes_consumed; - uint8_t data; + const uint8_t *buf; + uint32_t buflen; + uint32_t count; if (!(s->cr & CR_UARTEN)) { qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled UART\n"); @@ -249,25 +251,40 @@ static gboolean pl011_xmit(void *do_not_use, GIOCondition cond, void *opaque) qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX UART\n"); } + count = fifo8_num_used(&s->xmit_fifo); + if (count < 1) { + /* FIFO empty */ + return G_SOURCE_REMOVE; + } + if (!qemu_chr_fe_backend_connected(&s->chr)) { /* Instant drain the fifo when there's no back-end. */ pl011_drain_tx(s); return G_SOURCE_REMOVE; } - data = fifo8_pop(&s->xmit_fifo); - bytes_consumed = 1; + buf = fifo8_peek_buf(&s->xmit_fifo, count, &buflen); - /* - * XXX this blocks entire thread. Rewrite to use - * qemu_chr_fe_write and background I/O callbacks - */ - qemu_chr_fe_write_all(&s->chr, &data, bytes_consumed); + /* Transmit as much data as we can. */ + bytes_consumed = qemu_chr_fe_write(&s->chr, buf, buflen); trace_pl011_fifo_tx_xmit(bytes_consumed); + if (bytes_consumed < 0) { + /* Error in back-end: drain the fifo. */ + pl011_drain_tx(s); + return G_SOURCE_REMOVE; + } + + /* Pop the data we could transmit. */ + fifo8_pop_buf(&s->xmit_fifo, bytes_consumed, NULL); s->int_level |= INT_TX; pl011_update(s); + if (!fifo8_is_empty(&s->xmit_fifo)) { + /* Reschedule another transmission if we couldn't transmit all. */ + return G_SOURCE_CONTINUE; + } + return G_SOURCE_REMOVE; } @@ -290,6 +307,10 @@ static void pl011_write_txdata(PL011State *s, uint8_t data) trace_pl011_fifo_tx_put(data); pl011_loopback_tx(s, data); fifo8_push(&s->xmit_fifo, data); + if (fifo8_is_full(&s->xmit_fifo)) { + s->flags |= PL011_FLAG_TXFF; + } + pl011_xmit(NULL, G_IO_OUT, s); } @@ -488,10 +509,24 @@ static void pl011_write(void *opaque, hwaddr offset, pl011_trace_baudrate_change(s); break; case 11: /* UARTLCR_H */ - /* Reset the FIFO state on FIFO enable or disable */ if ((s->lcr ^ value) & LCR_FEN) { - pl011_reset_rx_fifo(s); + bool fifo_enabled = value & LCR_FEN; + + trace_pl011_fifo_enable(fifo_enabled); + if (fifo_enabled) { + /* Transmit and receive FIFO buffers are enabled (FIFO mode). */ + fifo8_change_capacity(&s->xmit_fifo, PL011_FIFO_DEPTH); + } else { + /* + * FIFOs are disabled (character mode) that is, the FIFOs + * become 1-byte-deep holding registers. + */ + pl011_drain_tx(s); + fifo8_change_capacity(&s->xmit_fifo, 1); + } + /* Reset the FIFO state on FIFO enable or disable */ pl011_reset_tx_fifo(s); + pl011_reset_rx_fifo(s); } if ((s->lcr ^ value) & LCR_BRK) { int break_enable = value & LCR_BRK; @@ -636,6 +671,11 @@ static int pl011_post_load(void *opaque, int version_id) s->read_pos = 0; } + if (!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); + } + s->ibrd &= IBRD_MASK; s->fbrd &= FBRD_MASK; diff --git a/hw/char/trace-events b/hw/char/trace-events index bf586ba664..2405819812 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -58,6 +58,7 @@ pl011_read(uint32_t addr, uint32_t value, const char *regname) "addr 0x%03x valu pl011_read_fifo(int read_count) "FIFO read, read_count now %d" pl011_write(uint32_t addr, uint32_t value, const char *regname) "addr 0x%03x value 0x%08x reg %s" pl011_can_receive(uint32_t lcr, int read_count, int r) "LCR 0x%08x read_count %d returning %d" +pl011_fifo_enable(bool enable) "enable:%u" 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(uint8_t byte) "TX FIFO push char [0x%02x]"