From patchwork Fri Mar 9 15:11:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 131140 Delivered-To: patch@linaro.org Received: by 10.80.194.209 with SMTP id u17csp1135193edf; Fri, 9 Mar 2018 07:13:49 -0800 (PST) X-Google-Smtp-Source: AG47ELuQX7TIjeszyA7MR2g8G3fGRFcnirOWZ+zIGbKhdniQek42k1hUf6e1NvqZXAf0h2bfDtat X-Received: by 10.107.78.1 with SMTP id c1mr36586016iob.120.1520608429331; Fri, 09 Mar 2018 07:13:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520608429; cv=none; d=google.com; s=arc-20160816; b=w4LIsDzfDl3yQpWrzE362tLwf/RvklFggShmECUe5Z5T9nLtkMj1m6u1sCeisVaiyz yAhJrWH84BRrRkPTp1TCkNjP3ba3KpuLwapW0noMJmwWaEoOFHStqKJrKXXU08tKou1s vfH382cekiYcBf6e6FhtQCV/1vPpGTG53nZOGXuwnIMupxcd/yVinE/kdwnoC1jNdXPY t4r3P3JfjWU02yh+hFxJ1MadBDbJ/r5kczRgcNOIgQGcOj+46cEGDkLYHC/Ouf4cnEEr O035oLLb8urVw3FoljcxNSd6d+v3Nrms5VwgYZaEyoSO3q06uSPrYh+2u8OAvXKMdYKJ kjQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=7GTVohp4612QEdgCrbmOOvImQH/jY40RJ8wAQGMatAg=; b=b+NBCd+qFcyftqNSd5XKEAKjBJs9bzn47fZHyW7VatBuSTBwmpbJgWU4FCXWAR69Ul 5WOEyhb9jChtve5hAl6bJOrg7BnkWMv1R7wFfRamBmBQVrAs8oVXup8uB6PzZHbXHQ4K QigmSBFkUp/eGPCVrQcUK9oxFVZfcwMkweTsD+RJ346ipXm8TCj8/+a/y/11BZaOdSu9 FvZWe1khtSE/t3UT1Tfbf8YFWiFUHDUbummuXneFsPYTXynWMoE/OqL+7m7LZIOYTYOS 8QU80IGky+0dBCY3/n1CeXsfgtR1oZpd1b0zFlkM8cIyX/mDZsygGAK+E8dUMRwy6dos QnVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bJoibgOA; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w21si1326068ite.21.2018.03.09.07.13.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 07:13:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bJoibgOA; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euJgg-00066r-J3; Fri, 09 Mar 2018 15:12:02 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1euJgf-000659-A3 for xen-devel@lists.xenproject.org; Fri, 09 Mar 2018 15:12:01 +0000 X-Inumbo-ID: 0c1d699f-23ac-11e8-ba59-bc764e045a96 Received: from mail-wm0-x243.google.com (unknown [2a00:1450:400c:c09::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0c1d699f-23ac-11e8-ba59-bc764e045a96; Fri, 09 Mar 2018 16:10:48 +0100 (CET) Received: by mail-wm0-x243.google.com with SMTP id t6so4487821wmt.5 for ; Fri, 09 Mar 2018 07:12:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HDKrFyoGMHOyShbnDnmnyivkc3EZoECPkO9bdvlnmhc=; b=bJoibgOAyA/m348i/TtlOtpqxeb7elrDoGZmUsfkCOtzSQFjWSe7npoIiyE68poq6V rGkDLD71PDYuy6phePfBmgoWNT03MLqscP4N4v2zjHBylhB3OZZqXajyk1EccfJ4ApoU gCISze6UWCnTy/kykgNDXWQxRhd1kJ9QHrD+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HDKrFyoGMHOyShbnDnmnyivkc3EZoECPkO9bdvlnmhc=; b=pDQhloiI0LWPfUnUWB2MaCdOiLpSp35ZQPTOtbiznLc2ByIfWPNTD8eoln/mOC5PQ8 3V7ESaw+j+PAMn49BNp7zEJO/lF+/B10qXkpUszTFQXTHYINa/GMB1Mn0k1ThIhLBX4f ImYNqxufcVR1WD58rvC/qswsPLj2XRTe1T7hFPa/5YB45dTPycxDKBg06vnCGUVnGyLY M5WCtJOhhixbjzlAnX+EzUsP3IkiEw9qAO01G5/B2IludqK4rgb6U1Cxk6WBOe6Pdbnr 1/NS4NT6WwZfPbejzFVgqLPpgzVnip0shIV8qKdYPjB6K/0NLuPrAdOnV9s7t++5vS2K EIZw== X-Gm-Message-State: AElRT7F/uuGWkaUnX3ua9Vtr5EXXyOwhImMeOIJXbJAosFIM/dZ7tyxn vDAy/rPqVklZPDezJ8grlfCH3w== X-Received: by 10.28.195.133 with SMTP id t127mr2293845wmf.156.1520608319410; Fri, 09 Mar 2018 07:11:59 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id 1sm1721198wmj.35.2018.03.09.07.11.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 07:11:58 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Fri, 9 Mar 2018 15:11:32 +0000 Message-Id: <20180309151133.31371-17-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180309151133.31371-1-andre.przywara@linaro.org> References: <20180309151133.31371-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 16/17] ARM: GICv3: poke_irq: make RWP optional X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A GICv3 hardware implementation can be implemented in several parts that communicate with each other (think multi-socket systems). To make sure that critical settings have arrived at all endpoints, some bits are tracked using the RWP bit in the GICD_CTLR register, which signals whether a register write is still in progress. However this only applies to *some* registers, namely the bits in the GICD_ICENABLER (disabling interrupts) and some bits in the GICD_CTLR register (cf. Arm IHI 0069D, 8.9.4: RWP, bit[31]). But our gicv3_poke_irq() was always polling this bit before returning, resulting in pointless MMIO reads for many registers. Add an option to gicv3_poke_irq() to state whether we want to wait for this bit and use it accordingly to match the spec. Replace a "1 << " with a "1U << " on the way to fix a potentially undefined behaviour when the argument evaluates to 31. Signed-off-by: Andre Przywara Reviewed-by: Julien Grall --- xen/arch/arm/gic-v3.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 8b41704cf1..09b49a07d5 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -428,9 +428,9 @@ static void gicv3_dump_state(const struct vcpu *v) } } -static void gicv3_poke_irq(struct irq_desc *irqd, u32 offset) +static void gicv3_poke_irq(struct irq_desc *irqd, u32 offset, bool wait_for_rwp) { - u32 mask = 1 << (irqd->irq % 32); + u32 mask = 1U << (irqd->irq % 32); void __iomem *base; if ( irqd->irq < NR_GIC_LOCAL_IRQS ) @@ -439,17 +439,19 @@ static void gicv3_poke_irq(struct irq_desc *irqd, u32 offset) base = GICD; writel_relaxed(mask, base + offset + (irqd->irq / 32) * 4); - gicv3_wait_for_rwp(irqd->irq); + + if ( wait_for_rwp ) + gicv3_wait_for_rwp(irqd->irq); } static void gicv3_unmask_irq(struct irq_desc *irqd) { - gicv3_poke_irq(irqd, GICD_ISENABLER); + gicv3_poke_irq(irqd, GICD_ISENABLER, false); } static void gicv3_mask_irq(struct irq_desc *irqd) { - gicv3_poke_irq(irqd, GICD_ICENABLER); + gicv3_poke_irq(irqd, GICD_ICENABLER, true); } static void gicv3_eoi_irq(struct irq_desc *irqd)