Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp334249rdb; Sat, 27 Jan 2024 08:21:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNZZJO0RrsWFj6/hlHbJLmQ5ZjIcFGj4xICgqpTKUpv0Pb9d0Q6Hlm07SoIdBKS3ON6rJE X-Received: by 2002:a05:620a:4109:b0:783:e1fc:ab84 with SMTP id j9-20020a05620a410900b00783e1fcab84mr1927865qko.80.1706372467862; Sat, 27 Jan 2024 08:21:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706372467; cv=pass; d=google.com; s=arc-20160816; b=QToPCWrAUMjFUvTorZLeXoZ7a78Rio/oxA1mcw7PQp51ozsjib2UIeEQeZkworMfb9 lcz4F8ibIpdemX7700NX6+ND4YZGmH5YcGPDMT7mOFfj+00JJ/O6MdgmJt1mOz0/5YPG yMo4lrT2chcauokcU0YDZ+/RG6eVjWLxQfO/Jq+gz8cPBP19zgP8fkL2Qmq/owcZyE2m ATlY2eSHElMekkNeGOjxqy+59EPhch1Ca/ikkdbaoStFqp47BKedAi/l/K3kz0V8xv18 WTkwpue0d60xh5BAIS4OY8lJS32q6ZUTIdVmJ8B47r3UTLu5Lh0tbJUoEwLLJAarL8GU ZlCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=23M+0gXGV/RoYlzBP/uez72ZRf4lEwzw20QI/B+WyQg=; fh=706cnY5t7hpwBXQypCTGH3HYLPe+/lcVAB5kbpxvl24=; b=lM2kIJ3SwWo7p+WsCsfWI+dxm6+ABJe2ZEVEfZWVvv3/CJDdi8kVzW+qaifW6f/fRh p0RgAevaMotB3+8HUMjVHlIWLRkmaN4/aa/EIatpk8IddzDZek2FAR/UabNdnN2Usunf pWemJN+nA8tI++bsUNPXHNuznikBWwYZ7SsyIb+4Ud6nlJju3Gr70AzwpE4SjwkjKi56 XvFWwRODEuA0ww6KmzyQz05t7iCMIFo+LPzJZd+Gm92mI/sgJxDmoSkliydAUW1k95sM OFXcB1Y6myuGFuMuccYNPTNj0n+Hhim0hUooCOsQNoWjkvdSGtsu56WFCZ1YUoO2iZ25 dDmw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=f8YtWLgR; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41282-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41282-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f20-20020a05620a12f400b00783dd01f146si2851827qkl.277.2024.01.27.08.21.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:21:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41282-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=f8YtWLgR; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41282-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41282-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 540251C22065 for ; Sat, 27 Jan 2024 16:21:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE6952D03C; Sat, 27 Jan 2024 16:19:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="f8YtWLgR" Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82D9241C84 for ; Sat, 27 Jan 2024 16:19:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372346; cv=none; b=L2bEIhU9vhjM6YFARDJ2crA0O6jrKACRQT+7u1usQP/6zbd1FJTFyUB1lqrsztOcNVI8ZXHfViTxe0Gp2h2PA2YSEN7zxflVheNXNHKaZxzomfWzoPkKc3qbbkDcchQijn8oRHS1pbm+q8fkuvfBklYxqi1iMtvaTYBPcUTSkWs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372346; c=relaxed/simple; bh=Zf4/ivIR0VEAEJonc6D3gdQYCPz0KYFQZzGI79d0D+4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NlC1v3dsxjyzLPJQV0B5qCBUy1/ScXMRSvJLI3dCI7cES9Xv2bPhDLSkTLobl15Tt5h8pHGGl0BJ8p4OyUtO3GhZWmBxvCd3x3pI4GdXbBCH/NH5Bl+ht+zIy+s4btb1UUP8u38/lmm9znM9NdH6BmDLEaengXdC/3cnUFQQV3U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=f8YtWLgR; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2945ce598bfso728544a91.0 for ; Sat, 27 Jan 2024 08:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706372345; x=1706977145; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=23M+0gXGV/RoYlzBP/uez72ZRf4lEwzw20QI/B+WyQg=; b=f8YtWLgRtKhWyPfNWZTlKXkFl8Hehhmw0pZ2sK60hmsJfPxS/azizLSWl7JpmBGIwN vMJygjkUkqeVXJHZU+5T8UZOz8z76dTsrU/S4ooR0L3L3J/HsKdbud83M3e+nLFCloEK v1dAZOmVWCH4YDd7xyw4EpZvCmD470bWcNkipUorTSE+Z0h01PaA2l7G0yF0Ge9KLtgh SVsay+uIIfoUvtKEnWrXDgliLg+Ub9Nr/wSJXwHpN5JtRBGzlYl6sQCo7rR5BO6V+CQW tYA7c9LEeA6bBpUnlopOp728RNkXLJXhnWdDxYSGmBSVEEXgS8p1mcHBhR3FD/pUIXWn U1Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706372345; x=1706977145; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=23M+0gXGV/RoYlzBP/uez72ZRf4lEwzw20QI/B+WyQg=; b=MOy557Hy3yT8l2sxsGwvw1wjMf+aBlXBD8BlR4hB8tj0NFHv6JOq8EiXaQAIRKJB36 KEyKLo/9hEgkwb3hSCJamqnBE8plGOPgzlvkKm1+Myq3afZOrRE7dXqd1EBq9/PH9Hnc wrfIQkQisX97UrffiPHDsYWFj2U5+Ox6lBRN0lsRw3yLZ0y1WvpRhaxREJmGKPh0r7Ng /OuTZtuwxRYdPdx2cWapHC4uiEhiA8t0KcH5gd9YWCs9hmk2tGVCpZLZyt2nJY29tKen R3P3jKUOT+Zh7rlDGpyeW6Zjcdb8jFv9XmUsJa80nBC/YTANZqdxFOhI++LcNIaW8qkl ak7A== X-Gm-Message-State: AOJu0YxPRK/uXWmw65qmVuHZe+iv+L8ShN/TFxu0KkH0t3m94o8FtnSV ZUIN2oXnxedKefyV+n32Kq1WF61kdELqykTugw8ji+WSBWLHev6XBcpCqyNjT/w= X-Received: by 2002:a17:90b:3cd:b0:294:f682:b349 with SMTP id go13-20020a17090b03cd00b00294f682b349mr832564pjb.1.1706372344606; Sat, 27 Jan 2024 08:19:04 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.86.17]) by smtp.gmail.com with ESMTPSA id d11-20020a17090ac24b00b00290f8c708d0sm5091620pjx.57.2024.01.27.08.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:19:04 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Marc Zyngier , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v12 08/25] genirq/msi: Split msi_domain_alloc_irq_at() Date: Sat, 27 Jan 2024 21:47:36 +0530 Message-Id: <20240127161753.114685-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240127161753.114685-1-apatel@ventanamicro.com> References: <20240127161753.114685-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Thomas Gleixner In preparation for providing a special allocation function for wired interrupt which are connected to a wire to MSI bridge, split the inner workings of msi_domain_alloc_irq_at() out into a helper function so the code can be shared. No functional change. Signed-off-by: Thomas Gleixner Signed-off-by: Anup Patel --- kernel/irq/msi.c | 76 +++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index c0e73788e878..8d463901c864 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1446,34 +1446,10 @@ int msi_domain_alloc_irqs_all_locked(struct device *dev, unsigned int domid, int return msi_domain_alloc_locked(dev, &ctrl); } -/** - * msi_domain_alloc_irq_at - Allocate an interrupt from a MSI interrupt domain at - * a given index - or at the next free index - * - * @dev: Pointer to device struct of the device for which the interrupts - * are allocated - * @domid: Id of the interrupt domain to operate on - * @index: Index for allocation. If @index == %MSI_ANY_INDEX the allocation - * uses the next free index. - * @affdesc: Optional pointer to an interrupt affinity descriptor structure - * @icookie: Optional pointer to a domain specific per instance cookie. If - * non-NULL the content of the cookie is stored in msi_desc::data. - * Must be NULL for MSI-X allocations - * - * This requires a MSI interrupt domain which lets the core code manage the - * MSI descriptors. - * - * Return: struct msi_map - * - * On success msi_map::index contains the allocated index number and - * msi_map::virq the corresponding Linux interrupt number - * - * On failure msi_map::index contains the error code and msi_map::virq - * is %0. - */ -struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, unsigned int index, - const struct irq_affinity_desc *affdesc, - union msi_instance_cookie *icookie) +static struct msi_map __msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, + unsigned int index, + const struct irq_affinity_desc *affdesc, + union msi_instance_cookie *icookie) { struct msi_ctrl ctrl = { .domid = domid, .nirqs = 1, }; struct irq_domain *domain; @@ -1481,17 +1457,16 @@ struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, u struct msi_desc *desc; int ret; - msi_lock_descs(dev); domain = msi_get_device_domain(dev, domid); if (!domain) { map.index = -ENODEV; - goto unlock; + return map; } desc = msi_alloc_desc(dev, 1, affdesc); if (!desc) { map.index = -ENOMEM; - goto unlock; + return map; } if (icookie) @@ -1500,7 +1475,7 @@ struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, u ret = msi_insert_desc(dev, desc, domid, index); if (ret) { map.index = ret; - goto unlock; + return map; } ctrl.first = ctrl.last = desc->msi_index; @@ -1513,7 +1488,42 @@ struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, u map.index = desc->msi_index; map.virq = desc->irq; } -unlock: + return map; +} + +/** + * msi_domain_alloc_irq_at - Allocate an interrupt from a MSI interrupt domain at + * a given index - or at the next free index + * + * @dev: Pointer to device struct of the device for which the interrupts + * are allocated + * @domid: Id of the interrupt domain to operate on + * @index: Index for allocation. If @index == %MSI_ANY_INDEX the allocation + * uses the next free index. + * @affdesc: Optional pointer to an interrupt affinity descriptor structure + * @icookie: Optional pointer to a domain specific per instance cookie. If + * non-NULL the content of the cookie is stored in msi_desc::data. + * Must be NULL for MSI-X allocations + * + * This requires a MSI interrupt domain which lets the core code manage the + * MSI descriptors. + * + * Return: struct msi_map + * + * On success msi_map::index contains the allocated index number and + * msi_map::virq the corresponding Linux interrupt number + * + * On failure msi_map::index contains the error code and msi_map::virq + * is %0. + */ +struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, unsigned int index, + const struct irq_affinity_desc *affdesc, + union msi_instance_cookie *icookie) +{ + struct msi_map map; + + msi_lock_descs(dev); + map = __msi_domain_alloc_irq_at(dev, domid, index, affdesc, icookie); msi_unlock_descs(dev); return map; } -- 2.34.1