Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1128710ybt; Tue, 7 Jul 2020 08:23:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfhk1Z0CPD4SG3vpEcSAkh/jcaGaomYQtDgL/632k1CKi5pcp3JSMXe9YUED0dNPVoJxl9 X-Received: by 2002:a17:906:1998:: with SMTP id g24mr44879603ejd.11.1594135433319; Tue, 07 Jul 2020 08:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594135433; cv=none; d=google.com; s=arc-20160816; b=lhLLYDLymoSB60qG6ZmxUqFgK18ufzjryPz+qvloH2GIcoFXH3XgflE+LpxwKz90t9 kQhNzuc5S8uyR1S6jv/v4i8ouw1UFUG8kOVXoACdqBeW4AjkF83dRDl5Bl8JDoJqKpvz L0nXCxNGkgIpntH6EL7xZHhEw8U4qngp1BdNpIWNfhOb7DGaUbif1RnlWoTK876z0Dan eFvR++dZqhINvSPyzNZec6pS+dhEeFuN/ReAA+7ghoudQkRPoaUR5KvYKqLca435tLrm L1xJ676Y9ILQbUmzB6dN6UGx5iDWeAORek6HR/P94++Zua+TJT4EZEmsZK4LAI2pJstR Alag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=r65PTSjHgY2h2xXakdsd3qU89B0ovx3QsEFvsX1rbXk=; b=dmUNZomT5WQfMmsYJHwBV0GCFot+W2T99aP/RHnna0jQl6Igw7pRVbaYFySemVhYRJ wchvS9it7Zi2PoDKWYmFeR6dNS0a0QWB0UtoaYeS2SVy8e5922+N5mZvn7glGYDsfDdF hDaKfBbOqdxorLR0WhrOQrTur4ykGK8bo++6C0yv+kfl9FrUcpsjytwLmJA1zovuBnPO kibGIWuimA+2uOavlmjpihCa6++rfK1/t6tn26FCLfuGoTFGjQT7cSHIMBweznJEqF0B EBm+rWrJZQVxQoYAXUj3mYplNpwIFzU1+1JU5KzQIiy7mkIM1DWBcwP96TBkw56QThTF KcWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fVBmU643; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d18si13747789ejm.684.2020.07.07.08.23.30; Tue, 07 Jul 2020 08:23:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fVBmU643; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729020AbgGGPWH (ORCPT + 99 others); Tue, 7 Jul 2020 11:22:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:34380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729788AbgGGPWC (ORCPT ); Tue, 7 Jul 2020 11:22:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B655E20663; Tue, 7 Jul 2020 15:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594135322; bh=8AF14UblYs3ptHNxNzaQdjEKUMpZrRcDcrOJjLDL8Is=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fVBmU6435HkOiWF0yN652aHaKNZ4cpLVYSVSOXODCVpEEGYvf7W4FtN4gNux3gLnu PsYYgS054QUEm/9rZ7paN9aaHD4t1fg2aPwiY/gKH1YLzKzstcBD8QL8hPJ710htiC o/Nxtb194wjPMbOEWrKKKSnaIT/IyuFFd1krjsm4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier Subject: [PATCH 5.4 60/65] irqchip/gic: Atomically update affinity Date: Tue, 7 Jul 2020 17:17:39 +0200 Message-Id: <20200707145755.366625112@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200707145752.417212219@linuxfoundation.org> References: <20200707145752.417212219@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 005c34ae4b44f085120d7f371121ec7ded677761 upstream. The GIC driver uses a RMW sequence to update the affinity, and relies on the gic_lock_irqsave/gic_unlock_irqrestore sequences to update it atomically. But these sequences only expand into anything meaningful if the BL_SWITCHER option is selected, which almost never happens. It also turns out that using a RMW and locks is just as silly, as the GIC distributor supports byte accesses for the GICD_TARGETRn registers, which when used make the update atomic by definition. Drop the terminally broken code and replace it by a byte write. Fixes: 04c8b0f82c7d ("irqchip/gic: Make locking a BL_SWITCHER only feature") Cc: stable@vger.kernel.org Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- drivers/irqchip/irq-gic.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -329,10 +329,8 @@ static int gic_irq_set_vcpu_affinity(str static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, bool force) { - void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + (gic_irq(d) & ~3); - unsigned int cpu, shift = (gic_irq(d) % 4) * 8; - u32 val, mask, bit; - unsigned long flags; + void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + gic_irq(d); + unsigned int cpu; if (!force) cpu = cpumask_any_and(mask_val, cpu_online_mask); @@ -342,13 +340,7 @@ static int gic_set_affinity(struct irq_d if (cpu >= NR_GIC_CPU_IF || cpu >= nr_cpu_ids) return -EINVAL; - gic_lock_irqsave(flags); - mask = 0xff << shift; - bit = gic_cpu_map[cpu] << shift; - val = readl_relaxed(reg) & ~mask; - writel_relaxed(val | bit, reg); - gic_unlock_irqrestore(flags); - + writeb_relaxed(gic_cpu_map[cpu], reg); irq_data_update_effective_affinity(d, cpumask_of(cpu)); return IRQ_SET_MASK_OK_DONE;