Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3063022imu; Mon, 19 Nov 2018 10:04:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/UEXF9M9to2YF2jtP9vU/BSNbJ9h2DWDEa2WElbVQX2Q7IiBq0YlzNoEkEIag+TTOffCthr X-Received: by 2002:a17:902:292b:: with SMTP id g40mr759240plb.82.1542650682885; Mon, 19 Nov 2018 10:04:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542650682; cv=none; d=google.com; s=arc-20160816; b=QLLj7pHckUsbv8yDO5lvqeuFZYxMKQZYPCdrGYNtW7uQMyDkX52yVYNpGPNAuhnjSb eAq4zfxOIUxNUUNuHVXwqdPCo1zwfPAZjQtQjEiMP1bgW3z5Sq1L+NzkLUEtEz95/OfS Vn8W15FT3npV72A+zYupoVEhmGg9mfThrFLA4kpYZR14OxzxjbV4HOIKRwo0l2n19ASs GH6QmWqCaJJE5dglSrTi8nMNpYNOa6zQyGxsfOyj2AM2QUMuzyMsh5s9FhgkgZECTeKl 5N9jREPm3uVe7hb5o8JDqUeFnpPApobOq6598uNJeKGCkDuHOcbNSSrVRogdT09O38cX wcbw== 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=5uMrqCiIZQtw0l0BkKtumNWvjeTcK1P0tFpCqtUviA8=; b=vLn8dSMXdF2SN4A836RlnAP7i/BXYLWfb3+iGJKqYV9WgdqmZuORXm3sl2bn2cYzh8 jp+KYn7BtXa+KSsQyUHANwfAup4UCvpf30QZmZ+RjEKb/owBb5eS4JT/Vek3DnSwTM7x WCvKeuN2F6F2ULRGvp3CD7jdB6QmjqOtfb3kjia+2WKjzZNt9GGwUmQUcTA6HywZB0Il A82h4IZNIkRqyTU4hDNhOg7lgW6yC9EdyjLU+Ckg7QjZC+nXQm1DEXQEVISfoIsrt3nO 9j54sTFT+I549ZGmoMWaGLoi7fJl4vbCttqadD5bYHCc+Z0YPxz8okWFZmHStwYgPEmH bWBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JdrDPIG5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 63-v6si42463709pfe.182.2018.11.19.10.04.16; Mon, 19 Nov 2018 10:04:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JdrDPIG5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730300AbeKTC6m (ORCPT + 99 others); Mon, 19 Nov 2018 21:58:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:57782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730381AbeKTC6l (ORCPT ); Mon, 19 Nov 2018 21:58:41 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 2EDF82086A; Mon, 19 Nov 2018 16:34:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645272; bh=iihfgzdVniE2bqK9y30TYvWWVNrmXGBcDqyh4LxGCJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JdrDPIG5TOZu8XfikSAUs/IK+YyisW+M+M9tzKjMXaVYu8DCng9gGBDAEG0QHM8mC cjfWfBomJP1YGd3TcLHHdaXnX6RPCSl6GUOecXzUBgqHjOZ6JsQ7Zo0FghQakDYK97 AtqknAf/MjQ9rKocepdJyRxRZLiGqugM4oGzfZek= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Santosh Shilimkar , Marc Zyngier , Olof Johansson Subject: [PATCH 4.19 100/205] soc: ti: QMSS: Fix usage of irq_set_affinity_hint Date: Mon, 19 Nov 2018 17:26:47 +0100 Message-Id: <20181119162633.300987367@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marc Zyngier commit 832ad0e3da4510fd17f98804abe512ea9a747035 upstream. The Keystone QMSS driver is pretty damaged, in the sense that it does things like this: irq_set_affinity_hint(irq, to_cpumask(&cpu_map)); where cpu_map is a local variable. As we leave the function, this will point to nowhere-land, and things will end-up badly. Instead, let's use a proper cpumask that gets allocated, giving the driver a chance to actually work with things like irqbalance as well as have a hypothetical 64bit future. Cc: stable@vger.kernel.org Acked-by: Santosh Shilimkar Signed-off-by: Marc Zyngier Signed-off-by: Olof Johansson Signed-off-by: Greg Kroah-Hartman --- drivers/soc/ti/knav_qmss.h | 4 ++-- drivers/soc/ti/knav_qmss_acc.c | 10 +++++----- drivers/soc/ti/knav_qmss_queue.c | 22 +++++++++++++++------- 3 files changed, 22 insertions(+), 14 deletions(-) --- a/drivers/soc/ti/knav_qmss.h +++ b/drivers/soc/ti/knav_qmss.h @@ -329,8 +329,8 @@ struct knav_range_ops { }; struct knav_irq_info { - int irq; - u32 cpu_map; + int irq; + struct cpumask *cpu_mask; }; struct knav_range_info { --- a/drivers/soc/ti/knav_qmss_acc.c +++ b/drivers/soc/ti/knav_qmss_acc.c @@ -205,18 +205,18 @@ static int knav_range_setup_acc_irq(stru { struct knav_device *kdev = range->kdev; struct knav_acc_channel *acc; - unsigned long cpu_map; + struct cpumask *cpu_mask; int ret = 0, irq; u32 old, new; if (range->flags & RANGE_MULTI_QUEUE) { acc = range->acc; irq = range->irqs[0].irq; - cpu_map = range->irqs[0].cpu_map; + cpu_mask = range->irqs[0].cpu_mask; } else { acc = range->acc + queue; irq = range->irqs[queue].irq; - cpu_map = range->irqs[queue].cpu_map; + cpu_mask = range->irqs[queue].cpu_mask; } old = acc->open_mask; @@ -239,8 +239,8 @@ static int knav_range_setup_acc_irq(stru acc->name, acc->name); ret = request_irq(irq, knav_acc_int_handler, 0, acc->name, range); - if (!ret && cpu_map) { - ret = irq_set_affinity_hint(irq, to_cpumask(&cpu_map)); + if (!ret && cpu_mask) { + ret = irq_set_affinity_hint(irq, cpu_mask); if (ret) { dev_warn(range->kdev->dev, "Failed to set IRQ affinity\n"); --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c @@ -118,19 +118,17 @@ static int knav_queue_setup_irq(struct k struct knav_queue_inst *inst) { unsigned queue = inst->id - range->queue_base; - unsigned long cpu_map; int ret = 0, irq; if (range->flags & RANGE_HAS_IRQ) { irq = range->irqs[queue].irq; - cpu_map = range->irqs[queue].cpu_map; ret = request_irq(irq, knav_queue_int_handler, 0, inst->irq_name, inst); if (ret) return ret; disable_irq(irq); - if (cpu_map) { - ret = irq_set_affinity_hint(irq, to_cpumask(&cpu_map)); + if (range->irqs[queue].cpu_mask) { + ret = irq_set_affinity_hint(irq, range->irqs[queue].cpu_mask); if (ret) { dev_warn(range->kdev->dev, "Failed to set IRQ affinity\n"); @@ -1262,9 +1260,19 @@ static int knav_setup_queue_range(struct range->num_irqs++; - if (IS_ENABLED(CONFIG_SMP) && oirq.args_count == 3) - range->irqs[i].cpu_map = - (oirq.args[2] & 0x0000ff00) >> 8; + if (IS_ENABLED(CONFIG_SMP) && oirq.args_count == 3) { + unsigned long mask; + int bit; + + range->irqs[i].cpu_mask = devm_kzalloc(dev, + cpumask_size(), GFP_KERNEL); + if (!range->irqs[i].cpu_mask) + return -ENOMEM; + + mask = (oirq.args[2] & 0x0000ff00) >> 8; + for_each_set_bit(bit, &mask, BITS_PER_LONG) + cpumask_set_cpu(bit, range->irqs[i].cpu_mask); + } } range->num_irqs = min(range->num_irqs, range->num_queues);