From nobody Mon Nov 23 04:26:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1793614432; cv=none; d=zohomail.com; s=zohoarc; b=Cq94z2K/L/7KdimlibvEr7+2x6BOI3o2mVXHYbyikw2EQl2NWpB2pj7//VO4Q9Rf+bMT72g0ue3170vQafhDH2rr0REjxDIGML54w5608SaS+2388gpO+qX3FrVRcj4EqQAbZB+i7+Xc7LGovCrPwHyNolRWAK23UGoPl1Y6F+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793614432; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aWwCyBtB9uV+fA+YGZ54qKoI3L3xW4hyyTN2yprS9nA=; b=ewCz5q4dOcfbJ2dEopVtdIzuvpoqdlQ8TnaS5I4Nuga9br0cuSmg0JXEfS0pIkqdDL6gZLggRvABLAakU3P8DknpnW1wDHcJKlpX8stLpoF5eR9mjPo4fU4ezlNNzlPXij1GuqoKI27DXmuiyZ+xuNK61GBKf0BlQ61c8sL2p7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793614432293881.6777773647904; Mon, 2 Nov 2026 02:13:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNp2o-0000Ea-Ik; Mon, 02 Nov 2026 05:13:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNp2d-0000Cq-FG for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:13:29 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xNp2Z-0005Sq-Ub for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:13:26 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-48c5358fc28so2237496f8f.0 for ; Mon, 02 Nov 2026 02:13:23 -0800 (PST) Received: from localhost.localdomain (email.telematik-zentrum.de. [87.138.218.176]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71ba53d7sm24478519f8f.53.2026.11.02.02.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 02:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793614401; x=1794219201; 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:content-type; bh=aWwCyBtB9uV+fA+YGZ54qKoI3L3xW4hyyTN2yprS9nA=; b=PoGWlV+t3hVkJS1U5+x3zIeqWoo9JqnGAn0zrudqRl/m+W1VfGPAEJeTUPwLrIa3FN cKEDXawZx6PqPLvrG9x5n/ZJ7diScHDOfUeYnGdp3foS/NdfMCQZ3vdRt5BpBi0tJAkK wyojDmnnlJgVZFymUVmfKIFWF2n67H0s2/bIFxKJFV3Eh5IW9O4bNs8n3B91JasXJy/3 W8vLPfz6R9YQ1MHiYS2lspI4oORLXLIwD81kEbBmRF7md5E+4w8Ipsve5lwBeMQDwqNB szTU1gMeBa2QmtNpvuwiREE7eIcfGedThJ5L5ttudjwUtLPIf3b2ekj3GtRFyGJJHtn+ jbjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793614401; x=1794219201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=aWwCyBtB9uV+fA+YGZ54qKoI3L3xW4hyyTN2yprS9nA=; b=kmAdw4R/w/+uR4qOYZ0KjbyuFSCwsb7fOQ+e51FyGRHppx+Y5wD076qz4cskYY6Oyo H/bd0AuwkTxyuqn09qlap2IJ6a/v3rdPYX8tU8wuJQQjxust303f8Iy7xX3kHxX0AlID hil1B13sVJ8/hcUQM7FFUkFI5h+fPJVFerLcCFWchbA1YWZGD1ZuiC2nNDjnRqJaNNR+ mXLOBUjxca+2hQZWcDJVNNZOv5E14xoomg6ZB3i+VAHj9r94UMC+yLiULbueWL+5k3EW fcSSqCb5LPYKd+gOV9JqF4m+/H8riUYSHs2BaGPeUAVUv+H7MMySJWtwnGGRM1IXZHTN 2ZAw== X-Gm-Message-State: APuU4Z80BkuY6HcEF78BOw7PYxj0HtsvOdksc4yqHRSomVFUI5jYyt37 XViE4IMcXvrnoIGaQxt1qKM/PhasHr57PjFOCkDtjHSOX2730fqW75rxKFW46C6iDOU= X-Gm-Gg: AYBFou1ulTZZevrewFJ+pgwKCE8ZXDIzW7QYwXpHYU8M7/Xh9mh2d58Fag6nQKFGCo+ KLOQCrGm7fM7Pfh5szu8BprjloXVZUCYST6V8fQ6PxkjpH9b3/6FzPPWn4qJZu48yhwnxfIF9OO PVuG/NYeSZqyJhUfstbXkBNi8YZtunQQbWOpqsa33XFAsHBXC0bKyvaahMeRvLBq1RgTKVxRauT aWS7qwuC9Yb+XrSaC12OibZA9b/Y3yRxO+oqOahK5eXGb8R1tpQ8Iux1Ofh1v7UzFF3479Go5+Z lP9gO+r++onIZKVbC+hRQgteYnOsyw6p7n+hUE5/LBl/sbXK9znrP2wGtFvsvaO3oUbnUvQG9I1 sjwy9D6U67cadJPctBJbMYXgLgsTqbtlpDxAPVsRbXgtthSlUYF8RV8SQW1WwtX6if5wq41KHGw VTOCNWbKtLQpgu0XwCuqI4samu0U8oAn8JaOZkFH7kLK4f6HUSG6qYkwUxvXNhMUpELiUmYtwkw Ph76EmB8YsCSBSG/9z7fC98B5/kvnHhU9ny12xd6E6KSG2k1IBMi3ChSD9gwn/HmPsPpTKp1MzD uV/0Vmlk+PwVmpgh7rX5i+/mMqjbm92nfVGITgXnF4/LJaCzwh7TsMmpfSzc01AydTCtBglpOva DSA== X-Received: by 2002:a05:6000:2213:b0:48c:7f18:c85e with SMTP id ffacd0b85a97d-48e6e3042d5mr21486005f8f.45.1793614401266; Mon, 02 Nov 2026 02:13:21 -0800 (PST) From: Lorand Marton To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, philmd@oss.qualcomm.com, qemu-arm@nongnu.org, farosas@suse.de, lvivier@redhat.com, pbonzini@redhat.com, alistair@alistair23.me Subject: [PATCH 1/5] MAINTAINERS: list the BCM283x qtests under Raspberry Pi Date: Mon, 2 Nov 2026 11:13:19 +0100 Message-ID: <0deb097d24128afea6839a2d6e222c2cf33de45d.1793613972.git.lorandmarton.dev@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=lorandmarton.dev@gmail.com; helo=mail-wr1-x42e.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, FREEMAIL_FROM=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1793614434579154100 Content-Type: text/plain; charset="utf-8" tests/qtest/bcm2835-dma-test.c, bcm2835-i2c-test.c and bcm2835-ic-test.c test Raspberry Pi devices, but no MAINTAINERS section lists them, so get_maintainer.pl names no one for a change to them. Add them, and the BCM283x qtests that follow, to the Raspberry Pi section. Signed-off-by: Lorand Marton Reviewed-by: Peter Maydell --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3b12ba90f2..fd08d80aba 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1046,6 +1046,7 @@ F: include/hw/*/bcm283* F: docs/system/arm/raspi.rst F: tests/functional/arm/test_raspi2.py F: tests/functional/aarch64/test_raspi*.py +F: tests/qtest/bcm283*-test.c =20 Real View M: Peter Maydell --=20 2.56.0 From nobody Mon Nov 23 04:26:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1793614768; cv=none; d=zohomail.com; s=zohoarc; b=RxKi1sH3cuumIIQjzow6oagMK7HbcQ1RJadThH9pb4wr0RZTq5wpkIKyU4C1ucnUBexo4zEhHy8hy1ytQ+TCKRX+SwSsUcKvBICXn2U7HPvCnQrO0DLr4ACoq0pwlDBZqObfole4AriGZoyfbreB/6Zbfk02yvT1BWwrX+sw7UU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793614768; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7/EbRasFtecU6OLNucc5FQYJM1nWp9yJXQrAU5T2JSg=; b=O2lW8zveHUoV94scuj3T9BnEJqPG19VMBtCH11vuGSRbX58UPjNkYtDRJA4/zia57Rr7NIojKza+thS4uyVSvjsPIlmfIjf72Mby5RfesrNJA91IjT+AynciPf5PlwtsDvudPu6+B41k4tbp6gh0F0XOkL145ScVzanqr6hbMvg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793614768785199.59541628814623; Mon, 2 Nov 2026 02:19:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNp7u-0001UM-2L; Mon, 02 Nov 2026 05:18:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNp7h-0001TF-BX for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:18:43 -0500 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 1xNp7c-0005v2-P7 for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:18:40 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-48dee593f18so2642624f8f.3 for ; Mon, 02 Nov 2026 02:18:33 -0800 (PST) Received: from localhost.localdomain (email.telematik-zentrum.de. [87.138.218.176]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4ac09fadb75sm173692795e9.3.2026.11.02.02.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 02:18:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793614712; x=1794219512; 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:content-type; bh=7/EbRasFtecU6OLNucc5FQYJM1nWp9yJXQrAU5T2JSg=; b=xVCCxEI9dEhsps7nbRZSy9KctoMbOZiiMIySw5PtWuG3otTrW15UrMBv8LFUMxOeQk beGThVYfQgdQMcwYFdzVzFQG4W/jcJc+0K7rlDqJIeLDyyAMUXMFvkeGvacoaKiM5mLi R1EP2h0MsWFlyJU9SJDJ7gBKcr5YY87poMTcCaC0v8w1e8d2YF3CjbwWa5I4d56KjPqj NY8R1vOF/esLwMfUTLw2mLK6Svev5AjPphueDJ79jiBS7KhJ75RMVeL6nnlrgAiVnqIg yGpcFRpnQEs709VwdvCqPiUWs5eYPPPDGeuPG9AoHl6Lsg9I6Ya2yhsUe++G++4BNBIG HaNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793614712; x=1794219512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=7/EbRasFtecU6OLNucc5FQYJM1nWp9yJXQrAU5T2JSg=; b=yKpJ4BB4pmBLrRmXDPl+pi3rD4PsHNNXh76RIwh5UJ/AP2QJ94JHuAciFq3t5jS+co rNvUTCyGsHypP+cerUxs1Kj6N8rg7+yxn4xd62aNWAuPtnD3JhjnTLEuIgjDYWKHeE1X iBceQTxqQPG2gRgiy2yV9UrZp/ow94GA8uaNZVBjDZ0v8SlWuzfEi1oITSjolmvF43Nx R0kkivqegtcEr2M+OVa/dgoCU8WvZClRC3srg0B23lVu5K7iQ4X8w7AgxGxrOQ/Qj4X9 MOSNfDP4SxgPUBB7gyPHlS/YCWEaVrTzVV3ApmRf+PklStB5OJ0RF6ZjGHIvUpwTreZc drgg== X-Gm-Message-State: AFq9FYJvwF0kzhWjxP/sjhH2aWdyeLOjywjSuxEw1wZjaBGDip6d7Y2V Xl+nNb0ZKgXTVW9WDqMrz11PpNMoceyyxSyUBFs7Yvz1toCU5fKUKwbraKALbY1AKeM= X-Gm-Gg: AYBFou2tUPJ/Bl1TcRcqUdZbr0nTPNLIEeSyRBpjS1dYhjOQZuJ+7GAXYdSjk+w6n3W cKr3HjpiE8y+WuJ3wCkTrxbev4inh/PgC8N5ibMrYUOrNp4NIHnSUmiT61nIbsskHsTUkOhZG7t XhL+9LQNFfOcaML5WbteHnMjFCdaso5bAii0VQSDTSAdZBsmF5nF75Eelw3Hd8GvLqm7ltHl6a2 5zEFbqhYd+bwKSi9sf5gYZ6xSGIQpOMA0ADV2wy1E13Ub8ATE7m/pmI425JcgnVT+i0AOqawX9O v06INkQ63HL/XYeEmEqEe3W3YdiEq6js3gtDUPXxqmv5Xpp78KSRLPaByRz+FxKZMQ6LI9b5BLP FMxUHBHyNKnnxsptA9qBoAvO1f6Dcnau/Zi18F87EirFErZgHxmNd1+vYWl99h9/ShjT3pzmmRQ 8uDB4287yqZvlKDWdd+UAs/d6FEaHiowBPOHhOuJs8PfQkxMFmxoB0rU+5/8NQ89MeIca7y/OxP HFUCmshXA7ZlKVagkyCBHH/h9/fzn7Flm1RgyDimkzQDADwmf2BCQai9cdMSstgppwJ1J1xNJfG HEW1OumCCVSAJ8W6HMbQzPATL5X9sffqb6fdrBChzntA0GU/K09EQnrBM0x0lJmFdwxZXmJteA9 uIQ== X-Received: by 2002:a05:600c:46d1:b0:4a1:df52:3e36 with SMTP id 5b1f17b1804b1-4ac17b2cdc2mr221602475e9.27.1793614712319; Mon, 02 Nov 2026 02:18:32 -0800 (PST) From: Lorand Marton To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, philmd@oss.qualcomm.com, qemu-arm@nongnu.org, farosas@suse.de, lvivier@redhat.com, pbonzini@redhat.com, alistair@alistair23.me Subject: [PATCH 2/5] hw/i2c/bcm2835_i2c: update the interrupt when the status is cleared Date: Mon, 2 Nov 2026 11:18:30 +0100 Message-ID: <9c983d1ee9590f2dc2d373a4a035f1b3c1a04801.1793613972.git.lorandmarton.dev@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=lorandmarton.dev@gmail.com; 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, FREEMAIL_FROM=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1793614770718158500 Content-Type: text/plain; charset="utf-8" Writing 1 to DONE, ERR or CLKT in the S register clears the bit, but bcm2835_i2c_write() did not recompute the interrupt, so with INTD set the DONE interrupt stayed raised after the guest acknowledged it. Linux i2c-bcm2835 clears C before it clears S and so lowers the line anyway; a driver that clears DONE in S and keeps INTD set took the interrupt again and again. Update the interrupt after the write, as the C and FIFO writes do. Test that clearing DONE lowers the interrupt. Fixes: 9cf3bc65afdb ("hw/i2c: Implement Broadcom Serial Controller (BSC)") Signed-off-by: Lorand Marton Reviewed-by: Peter Maydell --- hw/i2c/bcm2835_i2c.c | 1 + tests/qtest/bcm2835-i2c-test.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/hw/i2c/bcm2835_i2c.c b/hw/i2c/bcm2835_i2c.c index 5f6093087d..60f9d953c4 100644 --- a/hw/i2c/bcm2835_i2c.c +++ b/hw/i2c/bcm2835_i2c.c @@ -166,6 +166,7 @@ static void bcm2835_i2c_write(void *opaque, hwaddr addr, /* Clear DONE, CLKT and ERR by writing 1 */ s->s &=3D ~(writeval & (BCM2835_I2C_S_DONE | BCM2835_I2C_S_ERR | BCM2835_I2C_S_CLKT)); + bcm2835_i2c_update_interrupt(s); break; case BCM2835_I2C_DLEN: s->dlen =3D writeval; diff --git a/tests/qtest/bcm2835-i2c-test.c b/tests/qtest/bcm2835-i2c-test.c index 1599194926..12c6ebdbcf 100644 --- a/tests/qtest/bcm2835-i2c-test.c +++ b/tests/qtest/bcm2835-i2c-test.c @@ -89,6 +89,29 @@ static void test_i2c_read_write(gconstpointer data) =20 } =20 +/* Clearing DONE in the status register lowers the DONE interrupt */ +static void test_i2c_irq(void) +{ + uint32_t base_addr =3D bsc_base_addrs[0]; + + qtest_irq_intercept_out_named(global_qtest, + "/machine/soc/peripherals/bcm2835-i2c0", + "sysbus-irq"); + + writel(base_addr + BCM2835_I2C_A, 0x50); + writel(base_addr + BCM2835_I2C_DLEN, 1); + writel(base_addr + BCM2835_I2C_C, BCM2835_I2C_C_I2CEN | + BCM2835_I2C_C_INTD | BCM2835_I2C_C_ST | BCM2835_I2C_C_CLEAR); + writel(base_addr + BCM2835_I2C_FIFO, TMP105_REG_T_HIGH); + g_assert_cmphex(readl(base_addr + BCM2835_I2C_S) & BCM2835_I2C_S_DONE, + =3D=3D, BCM2835_I2C_S_DONE); + g_assert_true(get_irq(0)); + + writel(base_addr + BCM2835_I2C_S, BCM2835_I2C_S_DONE); + g_assert_false(get_irq(0)); + writel(base_addr + BCM2835_I2C_C, 0); +} + int main(int argc, char **argv) { int ret; @@ -102,6 +125,7 @@ int main(int argc, char **argv) qtest_add_data_func(test_name, (void *)(intptr_t) i, test_i2c_read_write); } + qtest_add_func("/bcm2835/bcm2835-i2c0/irq", test_i2c_irq); =20 /* Run I2C tests with TMP105 slaves on all three buses */ qtest_start("-M raspi3b " --=20 2.56.0 From nobody Mon Nov 23 04:26:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1793614935; cv=none; d=zohomail.com; s=zohoarc; b=OhZJ4QHFJppfI+OF7mjvWYUssmnfv660WaEnlSl96QPm85x3Tv0mdGPfRHutPcvCXqNsHVAvBS0n2c4LzMMU3H+LrNIs2fu5LTYZ6S208QVaFlrMGlVg9AxiiHqqN1ZwFO/zSxw/LOkzSBXrGWzKUrQukd9gOxojv/YE/dPOaF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793614935; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=92x6VYbWsp8ciG3WX4q28/bD1bwxNpteWF3TJUaiUvo=; b=WJm+XX1wgPFw0dymSGLZGGJuO+E50eiRFoZd2FI3OwTBi+lN8kexyxuNB8vAzI13geeUqMJga+l8aoqfuNxuIUZtidVI7OJUCHo9UIX/am2yd2mGDv7Njrre/9bXE0VdVDG53MqhYHbBVdMbSwy3rYI1Kyh1RKcuTtjc3EK6zN8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793614935369361.22240610516883; Mon, 2 Nov 2026 02:22:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNpAY-0002W8-9a; Mon, 02 Nov 2026 05:21:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNpAV-0002VE-Gr for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:21:35 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xNpAT-0006Pv-Nf for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:21:35 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-48c4d99c32bso1918383f8f.1 for ; Mon, 02 Nov 2026 02:21:33 -0800 (PST) Received: from localhost.localdomain (email.telematik-zentrum.de. [87.138.218.176]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b9eaeesm19273411f8f.49.2026.11.02.02.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 02:21:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793614892; x=1794219692; 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:content-type; bh=92x6VYbWsp8ciG3WX4q28/bD1bwxNpteWF3TJUaiUvo=; b=eACJTi8++y6uxm+/KqdL8jh6wnCmm3ZdY0bGylYNpcuzpFRG6b1A5V730nz94nRAEe KevYVtcZkQVwjgtimCZ0PBI0QAf55spf39jx7s1DIdBr3JA7yyJRn6qBIOYIhkYVFUfS lyWNLBVua0vXZVDUFwWLeJ4N1F05KsFgqlpbTUGHpexNsxeC2dRrP3p3QiGhoIqjHYfB Vf0KseCiuW95yq9r5uWTNocP5+4At3L5eNDDciDAgDRoVmZxyP8daUesY8+3dMVQHNmj r6nZdstQpvRJo8Ti1dsLYWhtkwfm/8L2Zvq1qTTB+F3N4m8Y4VtsCSmnXcqFiFWoU7xV ubzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793614892; x=1794219692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=92x6VYbWsp8ciG3WX4q28/bD1bwxNpteWF3TJUaiUvo=; b=vnzYGcdBl2/TrD/3PP+Gq851TYL5vc2bLj/c1a+h2uO+COHb7HMASxiB/Rt6R9CKXC eM9pRkynYCdP5aU1MWnmIfmwioan2wySIj1RZHbL3Spps7OiwPTje1JdrXybqAgueE7e Q3wwUYGva9ZY3L9On3xyhfqVHc8cz6KWTxciaKJjg5JYrnkQ/zOUEB59CDbMaOpQVpAa QPHxiU1A41jZNDyC6f/TPl9f+L1KzkfekbV9Ha0Bnn1ZeH9rmW2Ep746oLnK3PARdQwB 3CN86y0/+EQZfSZiG8wSqKlD2jy6m4RCTL58XZuUElE+ymQqoMTB9OZXoUT4V5zUH26f pYWw== X-Gm-Message-State: AFq9FYLsHQ+mEep56blMZgi2n8KGa2REfuimJEgu3dfaPio2T/snuHzX Nd7Y4wN7XJsBofSAVi8LEuqNJShoCB2l9c23k8QXRfvvI77QMuEE7wbUUDT4K96nBog= X-Gm-Gg: AYBFou2MNgeXQ8RVEFgxSlfZFiy/SzZLbsFJbxtFgoLpSdK4Z0qz8dS3cR0P1zZ7BI1 NnR48zRz+ZvzAzouyz9Khnl9F4MLenqOcMRtQz8Xz405MIYGjxaS0JUNvk5FWs07lKeHWNQd2dy E6vjx7dWJgNv3h6clYAsW5MeIt2FC2OSjn+UpJwdoQ5yPREQqFm+xHrNMFx+JIU8OreTLdHSMeA YX70mA4CSUKBcUoRzcS7AodF1zU8tMqHq2t/m58wWhqVnHqpolt9OBrHv+oS6kPz+J0CjeLYIyN 6cggzSrDZpNdjNaOgbLYyaxhGk9hxtPNLY5UDl50oKNlkVyERzvg3RKcJgopqQO+e1x27SI0p9M 5bdCbMsvcQxdmhgsvAMxv03g0Uhn4eHWTNjvjWizmsCtHm1s3y4/ffKI4cYr/TpuoXkyomYaGg/ vtFp7ja6CH4e1Nd5clzYJy3N6NxEAq7PCvT7hCaZE6d0LoK/Ax3QDJPXKaZuXfXyty95NG2NPHl 6LJcv1rYyJEZbIP4FT3vFnI+DHtH8VXXk+xuKamnNT/dVfZWXBd5xGQJcvmVuBa0dtBnejlSbBW 2LSbYlbZQnOXKGPGtIoxEhz1E26HR8q1X/AEjKUzuyli/MyHuR1HaI3KHrjVyt2bUvp1RhLuMDF jZQ== X-Received: by 2002:a05:600c:3547:b0:4a1:e69d:90e8 with SMTP id 5b1f17b1804b1-4ac1889d442mr219147845e9.22.1793614891762; Mon, 02 Nov 2026 02:21:31 -0800 (PST) From: Lorand Marton To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, philmd@oss.qualcomm.com, qemu-arm@nongnu.org, farosas@suse.de, lvivier@redhat.com, pbonzini@redhat.com, alistair@alistair23.me Subject: [PATCH 3/5] hw/ssi/bcm2835_spi: lower the interrupt on reset Date: Mon, 2 Nov 2026 11:21:30 +0100 Message-ID: <9772fc00645a13988570f4107bf2eec7f5bbe2b7.1793613972.git.lorandmarton.dev@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=lorandmarton.dev@gmail.com; helo=mail-wr1-x42a.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, FREEMAIL_FROM=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1793614938269158500 Content-Type: text/plain; charset="utf-8" bcm2835_spi_reset() cleared CS, so neither DONE nor RXR is set afterwards, but left the interrupt line as it was: a reset in the middle of an interrupt-driven transfer (a guest reboot while spi-bcm2835 waits for DONE) kept the line raised into the next boot. Update the interrupt from the new register values. Test that a reset during a transfer with INTD set drops the line. Fixes: 28004fb74134 ("hw/ssi: Implement BCM2835 SPI Controller") Signed-off-by: Lorand Marton --- hw/ssi/bcm2835_spi.c | 2 ++ tests/qtest/bcm2835-spi-test.c | 42 ++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 3 ++- 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/bcm2835-spi-test.c diff --git a/hw/ssi/bcm2835_spi.c b/hw/ssi/bcm2835_spi.c index 01763c458c..4ab47787a4 100644 --- a/hw/ssi/bcm2835_spi.c +++ b/hw/ssi/bcm2835_spi.c @@ -246,6 +246,8 @@ static void bcm2835_spi_reset(DeviceState *dev) s->dlen =3D 0; s->ltoh =3D 0x1; s->dc =3D 0x30201020; + + bcm2835_spi_update_int(s); } =20 static const VMStateDescription vmstate_bcm2835_spi =3D { diff --git a/tests/qtest/bcm2835-spi-test.c b/tests/qtest/bcm2835-spi-test.c new file mode 100644 index 0000000000..4888171e5b --- /dev/null +++ b/tests/qtest/bcm2835-spi-test.c @@ -0,0 +1,42 @@ +/* + * QTest testcase for the BCM2835 SPI controller + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/bitops.h" +#include "libqtest.h" + +#define SPI0_BASE 0x3f204000 +#define SPI_CS 0x00 +#define SPI_FIFO 0x04 + +#define CS_CLEAR_RXTX (3 << 4) +#define CS_TA BIT(7) +#define CS_INTD BIT(9) + +/* A reset in the middle of a transfer drops the interrupt */ +static void test_reset_irq(void) +{ + QTestState *qts =3D qtest_init("-M raspi3b"); + + qtest_irq_intercept_out_named(qts, "/machine/soc/peripherals/bcm2835-s= pi0", + "sysbus-irq"); + qtest_writel(qts, SPI0_BASE + SPI_CS, CS_CLEAR_RXTX | CS_TA); + qtest_writel(qts, SPI0_BASE + SPI_FIFO, 0xa5); + qtest_writel(qts, SPI0_BASE + SPI_CS, CS_TA | CS_INTD); + g_assert_true(qtest_get_irq(qts, 0)); + + qtest_system_reset(qts); + g_assert_false(qtest_get_irq(qts, 0)); + + qtest_quit(qts); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + qtest_add_func("/bcm2835-spi/reset-irq", test_reset_irq); + return g_test_run(); +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 6f74b519c7..d4a20cd408 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -285,7 +285,8 @@ qtests_aarch64 =3D \ ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + = \ (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test'= , 'fuzz-xlnx-dp-test'] : []) + \ (config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', = 'xlnx-versal-trng-test'] : []) + \ - (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test', 'bcm2= 835-i2c-test', 'bcm2835-ic-test'] : []) + \ + (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test', 'bcm2= 835-i2c-test', 'bcm2835-ic-test', + 'bcm2835-spi-test'] : = []) + \ (config_all_accel.has_key('CONFIG_TCG') and = \ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test',= 'tpm-tis-i2c-swtpm-test'] : []) + \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : [])= + \ --=20 2.56.0 From nobody Mon Nov 23 04:26:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1793616437; cv=none; d=zohomail.com; s=zohoarc; b=Lmhg2qbNmQnzdwpOJOC5gerWItoWwkeJAuzeH8R6Hyii1S8FZ/z/dX1QRt9rl/+XjEIHPXD95+pS54ZwbrIw4dtI/mEDwkRzm03vWBWMA1nioE7Iub85i8kVNkT7orx5N/LeJV+Z+QS1Q/+JCQEhL6VlDStLJRlzY72yYufd1U4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793616437; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lazOyce7RHVbWkwdFCVuG2iG+AC86pgxd0if11bb8Is=; b=JfQ8CV+2Hbv7+LpVsS05rCFUqrPSmy6In82MizvELms7LoAEbcAA39JxNv9JqB4/5HE0+fMfzgiY9EI5eVxDH9ir6YWKkjZPFcs+B8ZHSlmr+lnEG9Z1LgamGYZH2lNGo9E/EWrt+L88D9PtaG+/zGHTbyyKSmWT7Wuimgxkmi4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793616437938552.1651991098868; Mon, 2 Nov 2026 02:47:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNpG9-0003Zh-V8; Mon, 02 Nov 2026 05:27:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNpG5-0003Yr-VL for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:27:23 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xNpG4-0006jX-1x for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:27:21 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4a2000d5fb1so18145695e9.1 for ; Mon, 02 Nov 2026 02:27:19 -0800 (PST) Received: from localhost.localdomain (email.telematik-zentrum.de. [87.138.218.176]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4ac09ad5ff8sm185193425e9.4.2026.11.02.02.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 02:27:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793615238; x=1794220038; 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:content-type; bh=lazOyce7RHVbWkwdFCVuG2iG+AC86pgxd0if11bb8Is=; b=QjtttEa4boucV80ZIxLOGJnqySJWrFMAIH6FqsWm9I4qv8AOstedoMSQFXr6GLf85j EwUplsVnqY3X5Gy2DWVThqXrkxHGl/aRlJy1OXi/JCKMi7kzSto0QT0IdtoiVu4ad9oQ 87J1aqhA2ULn+XgoJr9dlDKW8mgt8VMXO0wcpCuMCL1Eqi+oWX0IxRMSREdigEpgWMn4 gWB08NRw6txJ/CrlGt6s+yQHrdgLjlBASCVzvu5hzieInBGcPrWD3tT2f1ntFpSCoV1u JqCXthZ7ObWvbTIXq1EbUZgFdf2Oel7X4jLyakve7VqIUWV81mItOeyBZkR/x0oj87HJ 3Asw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793615238; x=1794220038; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=lazOyce7RHVbWkwdFCVuG2iG+AC86pgxd0if11bb8Is=; b=QSFZL50q9BA/rJZb+qRpNBVEK87Rc73pTUDfcTUSMHZVklOM82tIhfVfTFVivQ0vEY ZJ8ZguOptYj6Tn+GEALrms7BBPljj+ZzZ3FSvfAKTIxyrZ0cBLtQWlvUdW4Av5uBDsSK Q0MI+iuFhdEYqCaX8kFZTaIxf2kLk5fc0fiF2J8wkGuyJqisNA4ND/vdkLfuo3H16KG3 r3V0EF4sNDYDfcFC0xlwGWre72saUbGNxeM4qOq1gYEZMKTKFMFbli442jFTLLnMpZwL naEpXVMaYWrOCOrRViEBDSwscW9EsBMj0F4hybVKDdtVAMSCmiG19M0j4weveT5q/1yg 12eg== X-Gm-Message-State: AFq9FYLeP2p4zEIUHhfwb8n6xhJCWlt77z6E5PRBE8GXdYbitS5oSefV atjqTyHTyhfATEiwzaB2qBACyv7rMG8SU2XhLtcVQIOfMGV9T0NDxnyKmbRuJjP+X7I= X-Gm-Gg: AYBFou2PnnvukJ7aiFs7n0IfqmkKCpUXTO4yPv+PcFJae+YFuzlnz2AUqqMNLE3MqO3 sPLnkbMd/eT2ghJp/kQS5xKXN6Nss3Klj5mEjVsm0NRpW3frY/w09spgqvdxLdfcKrPgn414DDR M7BjTl9MpJraIyo5Guh4q16EtfxFDb9HqO00JvjEA0K+tfA9Y8pC1QBYbQ8z2EyG7gk2vFmW8DQ 2gcySjsSU7tuvfNDK8eTuVV+oQv2KSvQpRNFx2dt0HlWgPzWlIRuKIymFSu1tfuRjho5VtwDAw8 aJGfBIAvC38g+cGCgQwi+BeMpzBZ5vvU26orkJCPj54bC9ZvyRISz6gip3RwJMmVA66vjO+a9lS j48QUwcG5Fsgvz79hV3OjfV90SCxo3brVEdsSF/UnB5s+vZaMe5ORaNIKnV3grMf+u5EJXCoOrB +ctlqWBzC54FJf47YlefpOe6+f/MgORxShzHPox0KlduJPxHTl2Mluy4ZFyAOcmUHY7SPzJXS1y pjgqXTSifvfNfm9T1iStHuMQPryadyflgVVN9xiR2S0VO40jCv9a0GQ0Tut2bCxbz/n+eBEO+nF BpgG6pq/OPnuasgsM0a39B0MIl+X68d7NenDR1Hk5aJgaLE10k4cElnhhB8VsK7mXfQb6wVFSxr qm+3gQDPVVnUAvE+6ngUUKxE= X-Received: by 2002:a05:600c:8b55:b0:4a1:ddca:8b66 with SMTP id 5b1f17b1804b1-4ac19234a06mr213422935e9.31.1793615238341; Mon, 02 Nov 2026 02:27:18 -0800 (PST) From: Lorand Marton To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, philmd@oss.qualcomm.com, qemu-arm@nongnu.org, farosas@suse.de, lvivier@redhat.com, pbonzini@redhat.com, alistair@alistair23.me Subject: [PATCH 4/5] hw/timer/bcm2835_systmr: cancel the compares and lower the IRQs on reset Date: Mon, 2 Nov 2026 11:27:17 +0100 Message-ID: X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=lorandmarton.dev@gmail.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1793616440486154100 Content-Type: text/plain; charset="utf-8" bcm2835_systmr_reset() cleared the match bits and the compare registers, but a channel whose match had raised its interrupt kept the line raised, and a compare armed before the reset still fired after it, setting its match bit and raising the interrupt in a guest that had not armed it. Both happen when a guest reboots with a system timer channel in use (the firmware or a bare-metal guest's tick). Delete the timers and lower the interrupts in the reset, as the register values now say. Test that a reset drops a raised channel and that a compare set before it does not fire. Fixes: be95dffa326a ("hw/timer/bcm2835: Support the timer COMPARE registers= ") Signed-off-by: Lorand Marton --- hw/timer/bcm2835_systmr.c | 4 +++ tests/qtest/bcm2835-systmr-test.c | 54 +++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/bcm2835-systmr-test.c diff --git a/hw/timer/bcm2835_systmr.c b/hw/timer/bcm2835_systmr.c index 06a919b1f8..3c03c98193 100644 --- a/hw/timer/bcm2835_systmr.c +++ b/hw/timer/bcm2835_systmr.c @@ -123,6 +123,10 @@ static void bcm2835_systmr_reset(DeviceState *dev) BCM2835SystemTimerState *s =3D BCM2835_SYSTIMER(dev); =20 memset(&s->reg, 0, sizeof(s->reg)); + for (size_t i =3D 0; i < ARRAY_SIZE(s->tmr); i++) { + timer_del(&s->tmr[i].timer); + qemu_set_irq(s->tmr[i].irq, 0); + } } =20 static void bcm2835_systmr_realize(DeviceState *dev, Error **errp) diff --git a/tests/qtest/bcm2835-systmr-test.c b/tests/qtest/bcm2835-systmr= -test.c new file mode 100644 index 0000000000..a70fc46b92 --- /dev/null +++ b/tests/qtest/bcm2835-systmr-test.c @@ -0,0 +1,54 @@ +/* + * QTest testcase for the BCM2835 system timer + * + * A compare match raises the interrupt of its channel; a reset clears the + * matches, lowers the interrupts and cancels the pending compares. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/bitops.h" +#include "libqtest.h" + +#define SYSTMR_BASE 0xfe003000 +#define SYSTMR_PATH "/machine/soc/peripherals/systimer" +#define CS 0x00 +#define CLO 0x04 +#define C(n) (0x0c + (n) * 4) + +#define US 1000 /* the timer counts microseconds */ + +static void test_reset(void) +{ + QTestState *qts =3D qtest_init("-M raspi4b"); + uint32_t clo; + + qtest_irq_intercept_out_named(qts, SYSTMR_PATH, "sysbus-irq"); + + clo =3D qtest_readl(qts, SYSTMR_BASE + CLO); + qtest_writel(qts, SYSTMR_BASE + C(1), clo + 1000); + qtest_writel(qts, SYSTMR_BASE + C(3), clo + 100000); + qtest_clock_step(qts, 2000 * US); + g_assert_cmphex(qtest_readl(qts, SYSTMR_BASE + CS), =3D=3D, BIT(1)); + g_assert_true(qtest_get_irq(qts, 1)); + g_assert_false(qtest_get_irq(qts, 3)); + + qtest_system_reset(qts); + g_assert_cmphex(qtest_readl(qts, SYSTMR_BASE + CS), =3D=3D, 0); + g_assert_false(qtest_get_irq(qts, 1)); + + /* the compare of channel 3 was set before the reset */ + qtest_clock_step(qts, 200000 * US); + g_assert_cmphex(qtest_readl(qts, SYSTMR_BASE + CS), =3D=3D, 0); + g_assert_false(qtest_get_irq(qts, 3)); + + qtest_quit(qts); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + qtest_add_func("/bcm2835-systmr/reset", test_reset); + return g_test_run(); +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index d4a20cd408..76448c5d4f 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -286,7 +286,7 @@ qtests_aarch64 =3D \ (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test'= , 'fuzz-xlnx-dp-test'] : []) + \ (config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', = 'xlnx-versal-trng-test'] : []) + \ (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test', 'bcm2= 835-i2c-test', 'bcm2835-ic-test', - 'bcm2835-spi-test'] : = []) + \ + 'bcm2835-spi-test', 'b= cm2835-systmr-test'] : []) + \ (config_all_accel.has_key('CONFIG_TCG') and = \ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test',= 'tpm-tis-i2c-swtpm-test'] : []) + \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : [])= + \ --=20 2.56.0 From nobody Mon Nov 23 04:26:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1793616921; cv=none; d=zohomail.com; s=zohoarc; b=EXsDPx0VB3U2JTk3YOgwgyulYiv+eLqz+g/mbco1BQwibGP4jVGHMbme50SamwZCYe6oQWLA0B8ealVvfDNqUVVVBfQ0HhPn1kdbZX4g2X8Z8mn52d76+2Ux9EKwWRMBPcatoFmQDDjXBLf97Vryvs0UiX4NN7nBsE0b9eaXK6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793616921; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RczUIxregWa1M8gqPkz64zsf3SPjohpyF1RKCj4FQ7c=; b=J5+XSN0OpfplYVO6Mip7aOo1HFY63jUuBGTdDTNHPn6fCLzlsp/SG4dE2ThMyEVhYsq9S9HzeyWh2/APDbKQ/nqe6KBunDaKfrA7KJxyjTzRXx1fq+XFwnPGbShab2BmFVLF8XlPsDpx4l4KNUIWyBeZkjnZ7us7snZhTVmjIZM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793616921465450.2098257739094; Mon, 2 Nov 2026 02:55:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNpLu-0004oy-7C; Mon, 02 Nov 2026 05:33:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNpLl-0004o2-MK for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:33:15 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xNpLj-0007Fj-Vg for qemu-devel@nongnu.org; Mon, 02 Nov 2026 05:33:13 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-48afcd7ba9bso1500819f8f.3 for ; Mon, 02 Nov 2026 02:33:11 -0800 (PST) Received: from localhost.localdomain (email.telematik-zentrum.de. [87.138.218.176]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e71b9b54dsm18886774f8f.47.2026.11.02.02.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 02:33:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793615590; x=1794220390; 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:content-type; bh=RczUIxregWa1M8gqPkz64zsf3SPjohpyF1RKCj4FQ7c=; b=mebH8PTx8u5edkKn4BvXbkRG1NJUfkeEpaaKNFoh5lDHCM/bmZ7qRspIubYvdUVBOB NSssbhS4KhsJzUWWPHB7op/dKE++nLt00R0qZ+jpQ5PeiUf6DkMfAR5rgGd3yU//sqxq N136it8tKjitwao13PApJjho9CQLeZ1isghggV3PxnvyzS4+q+bhmKO26nyd6KGYUCKq qASDw7ORzlbLmYog9uJ9qdtkvr2kQLIKrgy+oTUQf061lZWumDGCt029ZbKA02fMecDU 3yMRhdXKQgf5gxk6MB/EOErJ18FHiMHFwsffSDLVO+WAaAefmoebx1njMlvznTRSLxrp iF2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793615590; x=1794220390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RczUIxregWa1M8gqPkz64zsf3SPjohpyF1RKCj4FQ7c=; b=HzMgbB9yoMHG6ch8nGvy/TWSxyUwVRq4RpqNxr1o+29QToMms3sw88IV9bDFw6ZUEV aQAxGDKhL3J+M5weGyMjD9iefV77KKs74U5UixGfKnFNrbhoyu3bOl/lMcFElyk3LZGZ Uzy6QShex5AlaCNMOIQMT6Q0SdmZjaqEJ9fAOyMDUOriqz2bj+laO7LxqGgoeKmM0aRK c+eIvgXgD/Z94SLvKAVHY9S2fxryL3qEzpYHUKqjWkUKh+X8kotrjt+SE5VHml0/liew aFCVKwD4OC6wMf1xu5VlDpq89SQ+3zP9k22nHeL1yE/5KMGdRIp4mf7FOOQGbuKnxR5e woYg== X-Gm-Message-State: APuU4Z+dib7pZNFlOv9aE7RHYDP6qk8wi9DfFsEYAOWU+BN+iIFwYTw5 r4g1xWrHRaypJnW1OuGOWa17BRNn/0z3KNW70qmHA6R7QyqR/XuFc/3yZC9ED8M3zes= X-Gm-Gg: AYBFou1TPjUDt2OYpPzdnEj+TQ7e5Jl5EfkH8BF8+qWTu05xCzFNyrOJZIqe4Abb0XP FX7Acg+8UQljcfAazdqpGfbkRz76a9Zz7bwvmBtRA+ogey6KVbOtw7nGt0Vln843pNIXIULvjuV KqNf5+ZrvBWKgFiyjQ692Dy51iHaAPho2goYv8rEQnvBVZXCOtJpW3Zm3FO+J5PnyENhctx3byt es2IdGrgbK3Bo0NchAW8zjxhEDM0GVqLfbZDhfCh5+1KMsowk04rtnIIVZv4SF+xFf9bLw/egam 6/UyCJnrzcQ5bEVjf2pPF28H3hy7sCvKiq82Fu53Ht1II2DOET5lgRnC76I3cHmkAgHVrevHDua 0vwfBYgnH+T7nGgX+GD5NouUyg2Lhbku/4lPEpwj60nvBkyXoG6ob/B7QTOz6gscxnf0ptYAyrd UVTxqae7/1BhRGtmZljTeqI2NCNbXJ1qOxt06MztYWyDnjr1Q29nK+o4q6bGN0/eXpwhOMZMBMt +hPeShKLHxT7wj5hILlopth2Aef8R4lOi8HkjmSMb7ZexxufX4SE2Hr7GcvLztCTrZzHBBOyV7B tEzKuSrpgSxm/0vGaPLiJhetG6UJPY+EyBJfHu75cKvUv6J9DLObQLO6hN3srUDe6iilbQLqEcG eOw== X-Received: by 2002:a05:6000:40d9:b0:48e:202:6718 with SMTP id ffacd0b85a97d-48e6e3042camr22388501f8f.25.1793615590178; Mon, 02 Nov 2026 02:33:10 -0800 (PST) From: Lorand Marton To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, philmd@oss.qualcomm.com, qemu-arm@nongnu.org, farosas@suse.de, lvivier@redhat.com, pbonzini@redhat.com, alistair@alistair23.me Subject: [PATCH 5/5] hw/misc/bcm2835_cprman: a PLL channel divider of 0 divides by 256 Date: Mon, 2 Nov 2026 11:33:08 +0100 Message-ID: <6262fa90e0dcbb87c33ed61c53ef55e83335a45f.1793613972.git.lorandmarton.dev@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=lorandmarton.dev@gmail.com; helo=mail-wr1-x429.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, FREEMAIL_FROM=0.001, 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1793616922603158500 Content-Type: text/plain; charset="utf-8" The 8-bit DIV field of an A2W PLL channel divides by 256 when it is 0, as Linux clk-bcm2835 describes it (CLK_DIVIDER_MAX_AT_ZERO on the PLL dividers: 2^width at 0). pll_channel_update() took 0 as 255, so the channel and every clock fed from it ran 0.4% fast, and QEMU and the guest disagreed on its rate. Test the rate of PLLD_PER against PLLD with the divider at 0. Fixes: 957458111280 ("hw/misc/bcm2835_cprman: implement PLL channels behavi= our") Signed-off-by: Lorand Marton --- hw/misc/bcm2835_cprman.c | 6 ++-- tests/qtest/bcm2835-cprman-test.c | 49 +++++++++++++++++++++++++++++++ tests/qtest/meson.build | 3 +- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 tests/qtest/bcm2835-cprman-test.c diff --git a/hw/misc/bcm2835_cprman.c b/hw/misc/bcm2835_cprman.c index 10cad07623..144e553432 100644 --- a/hw/misc/bcm2835_cprman.c +++ b/hw/misc/bcm2835_cprman.c @@ -184,10 +184,10 @@ static void pll_channel_update(CprmanPllChannelState = *channel) =20 if (!div) { /* - * It seems that when the divider value is 0, it is considered as - * being maximum by the hardware (see the Linux driver). + * A divider of 0 divides by 256, one more than the largest value + * the field holds (Linux clk-bcm2835 uses CLK_DIVIDER_MAX_AT_ZERO= ). */ - div =3D R_A2W_PLLx_CHANNELy_DIV_MASK; + div =3D 1 << R_A2W_PLLx_CHANNELy_DIV_LENGTH; } =20 /* Some channels have an additional fixed divider */ diff --git a/tests/qtest/bcm2835-cprman-test.c b/tests/qtest/bcm2835-cprman= -test.c new file mode 100644 index 0000000000..49a5245639 --- /dev/null +++ b/tests/qtest/bcm2835-cprman-test.c @@ -0,0 +1,49 @@ +/* + * QTest testcase for the BCM2835 clock manager + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "qobject/qdict.h" + +#define CPRMAN_BASE 0x3f101000 +#define A2W_PLLD_PER 0x1540 +#define A2W_PASSWORD 0x5a000000 +#define CPRMAN_PATH "/machine/soc/peripherals/cprman" + +/* The frequency of a clock, from its period in 2^-32 ns */ +static uint64_t clock_hz(QTestState *qts, const char *path) +{ + QDict *rsp =3D qtest_qmp(qts, "{ 'execute': 'qom-get', 'arguments': " + "{ 'path': %s, 'property': 'qtest-clock-period'= } }", + path); + uint64_t period =3D qdict_get_int(rsp, "return"); + + qobject_unref(rsp); + g_assert_cmpuint(period, !=3D, 0); + return (1000000000ULL << 32) / period; +} + +/* A PLL channel divider of 0 divides by 256 */ +static void test_channel_div_zero(void) +{ + QTestState *qts =3D qtest_init("-M raspi3b"); + uint32_t per =3D qtest_readl(qts, CPRMAN_BASE + A2W_PLLD_PER); + uint64_t pll_hz, chan_hz; + + qtest_writel(qts, CPRMAN_BASE + A2W_PLLD_PER, + A2W_PASSWORD | (per & ~0xffu)); + pll_hz =3D clock_hz(qts, CPRMAN_PATH "/plld/out"); + chan_hz =3D clock_hz(qts, CPRMAN_PATH "/plld-per/out"); + g_assert_cmpuint((pll_hz + chan_hz / 2) / chan_hz, =3D=3D, 256); + qtest_quit(qts); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + qtest_add_func("/bcm2835-cprman/channel-div-zero", test_channel_div_ze= ro); + return g_test_run(); +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 76448c5d4f..02fd0ca73a 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -286,7 +286,8 @@ qtests_aarch64 =3D \ (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test'= , 'fuzz-xlnx-dp-test'] : []) + \ (config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', = 'xlnx-versal-trng-test'] : []) + \ (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test', 'bcm2= 835-i2c-test', 'bcm2835-ic-test', - 'bcm2835-spi-test', 'b= cm2835-systmr-test'] : []) + \ + 'bcm2835-cprman-test',= 'bcm2835-spi-test', + 'bcm2835-systmr-test']= : []) + \ (config_all_accel.has_key('CONFIG_TCG') and = \ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test',= 'tpm-tis-i2c-swtpm-test'] : []) + \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : [])= + \ --=20 2.56.0