From patchwork Tue Oct 27 12:10:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 319046 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp1512023ilc; Tue, 27 Oct 2020 05:14:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+leC9CRIGFON+rzeoTdxCc1ujkBCAO9vDV+qnrbp/y4bM267H4oja36cV7nrjLj49NWL5 X-Received: by 2002:a17:906:3a02:: with SMTP id z2mr2061312eje.452.1603800866462; Tue, 27 Oct 2020 05:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603800866; cv=none; d=google.com; s=arc-20160816; b=e+MPwooydcYol+XhGgryUUFjRHFwvABKth9sB1sD8NeoUCirTl4zZBQfyWep2JLzB9 Hgot008Acb+EqSXIkvLStkMAPG2XVGqJaz/E1ab1acxQ7BR+KZZFarrHH3o+hAYpoFIN DyPetVaRv2SFUNwID890qQwayuSMk1H04dQ3Epl9D7oQtYJdgljClBKs7HHeOitBWPfU wdNU0Cs0Op4soODNpaPdqAFOJRIn4x2zRwmygzCzGuwoGRgnOevBgdCMroB/wbUK+DEm J5JPoknfcRhQzVQURut3RRVnKJo4ag8JUhhTFXtmsRqQy/c3GdbJwEu+QI7ujtBScsAs rDNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=aCEIpMwgg+u3tf9VQdUAnn+aKJZXtuB8PgB4OnL4TQw=; b=02dcXZXPKogO5R/NdfKabFWgs6oqdyCLqeC5uOlrfCRkmZ9QBP1gk1XB50+2LYe0l3 6lveFc9pnbjJZm6By3FDgQq3Mm09GvMk5jh+qHtho2N+5V8q2kzwhUhwkUbT3ymm6YYe 0ZxvkcmLBDbSGQIh4TfTqpQbC/PPPpHS58Lm2WDjhNJ/+I3Ny6xBsLKDKf/0I5I6QNCP xaFkJ/fW6GUDrerUS03YT0X/SHQF0QsmYUgp+1KPCPMgCF5d1AZlN3oQb8OZuOtmVVp1 0pXlwfJUmplqWQUEKVrbvzZgYOg0CNm4c64MSWc9wHpIqBJ/FG03Tggn9tHd5+/b3Yuw DsdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-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 h22si749788edj.40.2020.10.27.05.14.26 for ; Tue, 27 Oct 2020 05:14:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2899633AbgJ0MOW (ORCPT ); Tue, 27 Oct 2020 08:14:22 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:6407 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750751AbgJ0MOR (ORCPT ); Tue, 27 Oct 2020 08:14:17 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CL9cB1QKKz6yFQ; Tue, 27 Oct 2020 20:14:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Tue, 27 Oct 2020 20:14:04 +0800 From: John Garry To: , , , , CC: , , , , John Garry Subject: [PATCH 1/3] genirq/affinity: Add irq_update_affinity_desc() Date: Tue, 27 Oct 2020 20:10:22 +0800 Message-ID: <1603800624-180488-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1603800624-180488-1-git-send-email-john.garry@huawei.com> References: <1603800624-180488-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Thomas Gleixner Add a function to allow the affinity of an interrupt be switched to managed, such that interrupts allocated for platform devices may be managed. [jpg: Add commit message and add prototypes] Signed-off-by: John Garry --- Thomas, I just made you author since you provided the original code, hope it's ok. include/linux/interrupt.h | 8 ++++++++ kernel/irq/manage.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) -- 2.26.2 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index ee8299eb1f52..870b3251e174 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -352,6 +352,8 @@ extern int irq_can_set_affinity(unsigned int irq); extern int irq_select_affinity(unsigned int irq); extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m); +extern int irq_update_affinity_desc(unsigned int irq, + struct irq_affinity_desc *affinity); extern int irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify); @@ -387,6 +389,12 @@ static inline int irq_set_affinity_hint(unsigned int irq, return -EINVAL; } +static inline int irq_update_affinity_desc(unsigned int irq, + struct irq_affinity_desc *affinity) +{ + return -EINVAL; +} + static inline int irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify) { diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index c460e0496006..b96af4cde4bc 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -371,6 +371,25 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask, return ret; } +int irq_update_affinity_desc(unsigned int irq, + struct irq_affinity_desc *affinity) +{ + unsigned long flags; + struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); + + if (!desc) + return -EINVAL; + + if (affinity->is_managed) { + irqd_set(&desc->irq_data, IRQD_AFFINITY_MANAGED); + irqd_set(&desc->irq_data, IRQD_MANAGED_SHUTDOWN); + } + + cpumask_copy(desc->irq_common_data.affinity, &affinity->mask); + irq_put_desc_unlock(desc, flags); + return 0; +} + int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force) { struct irq_desc *desc = irq_to_desc(irq);