Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B986CC64ED6 for ; Mon, 27 Feb 2023 11:08:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWbN2-0006Uv-EN; Mon, 27 Feb 2023 06:08:40 -0500 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 1pWbMv-0006KV-S8; Mon, 27 Feb 2023 06:08:34 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWbMt-0000DC-TR; Mon, 27 Feb 2023 06:08:33 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 3BEFB746369; Mon, 27 Feb 2023 12:08:30 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id F15E9745720; Mon, 27 Feb 2023 12:08:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id F00AB745706; Mon, 27 Feb 2023 12:08:29 +0100 (CET) Date: Mon, 27 Feb 2023 12:08:29 +0100 (CET) From: BALATON Zoltan To: Bernhard Beschow cc: =?ISO-8859-15?Q?Philippe_Mathieu-Daud=E9?= , qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Gerd Hoffmann , Daniel Henrique Barboza , Peter Maydell , Jiaxun Yang , ReneEngel80@emailn.de Subject: Re: [PATCH v3 4/8] hw/isa/vt82c686: Implement PCI IRQ routing In-Reply-To: <57051528-2FE3-4624-A042-F51813A1C302@gmail.com> Message-ID: References: <0fd9eac9174a840054c511fbc015048929c7bc40.1677445307.git.balaton@eik.bme.hu> <0E10FCF9-465D-462A-8031-880B0907CCDA@gmail.com> <57051528-2FE3-4624-A042-F51813A1C302@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3866299591-998313976-1677496109=:43063" Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --3866299591-998313976-1677496109=:43063 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT On Mon, 27 Feb 2023, Bernhard Beschow wrote: > Am 26. Februar 2023 23:58:32 UTC schrieb BALATON Zoltan : >> On Sun, 26 Feb 2023, Bernhard Beschow wrote: >>> Am 26. Februar 2023 22:27:50 UTC schrieb "Philippe Mathieu-Daudé" : >>>> On 25/2/23 19:11, BALATON Zoltan wrote: >>>>> From: Bernhard Beschow >>>>> >>>>> The real VIA south bridges implement a PCI IRQ router which is configured >>>>> by the BIOS or the OS. In order to respect these configurations, QEMU >>>>> needs to implement it as well. >>>>> >>>>> Note: The implementation was taken from piix4_set_irq() in hw/isa/piix4. >>>>> >>>>> Signed-off-by: Bernhard Beschow >>>>> [balaton: declare gpio inputs instead of changing pci bus irqs so it can >>>>> be connected in board code; remove some empty lines] >>>>> Signed-off-by: BALATON Zoltan >>>>> Tested-by: Rene Engel >>>>> --- >>>>> hw/isa/vt82c686.c | 39 +++++++++++++++++++++++++++++++++++++++ >>>>> 1 file changed, 39 insertions(+) >>>> >>>>> +static int via_isa_get_pci_irq(const ViaISAState *s, int irq_num) >>>>> +{ >>>>> + switch (irq_num) { >>>>> + case 0: >>>>> + return s->dev.config[0x55] >> 4; >>>>> + case 1: >>>>> + return s->dev.config[0x56] & 0xf; >>>>> + case 2: >>>>> + return s->dev.config[0x56] >> 4; >>>>> + case 3: >>>>> + return s->dev.config[0x57] >> 4; >>>>> + } >>>>> + return 0; >>>>> +} >>>>> + >>>>> +static void via_isa_set_pci_irq(void *opaque, int irq_num, int level) >>>>> +{ >>>>> + ViaISAState *s = opaque; >>>>> + PCIBus *bus = pci_get_bus(&s->dev); >>>>> + int pic_irq; >>>>> + >>>>> + /* now we change the pic irq level according to the via irq mappings */ >>>>> + /* XXX: optimize */ >>>>> + pic_irq = via_isa_get_pci_irq(s, irq_num); >>>>> + if (pic_irq < ISA_NUM_IRQS) { >>>> >>>> the ISA IRQ is stored in 4-bit so will always be in range. >>> >>> Indeed. I'd turn this into an assert to keep this assum visible. I'll do another iteration of the PCI IRQ router series. >> >> I don't like a useless assert in an irq handler that's potentially called a lot. If you want to keep that add a comment instead. > > It won't because it will only affect debug builds. If it fails it's > immediately clear in which direction to look for the culprit. You may think so but it's not. QEMU cannot be built with NDEBUG (there was even some discussion about this recently on the list) so all the asserts are there in release builds. Let's at least keep them out from frequently called parts especially if they can never fire. Regards, BALATON Zoltan --3866299591-998313976-1677496109=:43063--