Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2223141/?format=api
{ "id": 2223141, "url": "http://patchwork.ozlabs.org/api/patches/2223141/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260414141514.1341429-8-den@valinux.co.jp/", "project": { "id": 28, "url": "http://patchwork.ozlabs.org/api/projects/28/?format=api", "name": "Linux PCI development", "link_name": "linux-pci", "list_id": "linux-pci.vger.kernel.org", "list_email": "linux-pci@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260414141514.1341429-8-den@valinux.co.jp>", "list_archive_url": null, "date": "2026-04-14T14:15:14", "name": "[v14,7/7] PCI: endpoint: pci-ep-msi: Add embedded doorbell fallback", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "e8beb021b25d7ae164e84f287073f7b8776534d7", "submitter": { "id": 91573, "url": "http://patchwork.ozlabs.org/api/people/91573/?format=api", "name": "Koichiro Den", "email": "den@valinux.co.jp" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260414141514.1341429-8-den@valinux.co.jp/mbox/", "series": [ { "id": 499855, "url": "http://patchwork.ozlabs.org/api/series/499855/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=499855", "date": "2026-04-14T14:15:08", "name": "PCI: endpoint: pci-ep-msi: Add embedded doorbell fallback", "version": 14, "mbox": "http://patchwork.ozlabs.org/series/499855/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2223141/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2223141/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-pci+bounces-52495-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linux-pci@vger.kernel.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=valinux.co.jp header.i=@valinux.co.jp\n header.a=rsa-sha256 header.s=selector1 header.b=F6OwtxgG;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org;\n envelope-from=linux-pci+bounces-52495-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=valinux.co.jp header.i=@valinux.co.jp\n header.b=\"F6OwtxgG\"", "smtp.subspace.kernel.org;\n arc=fail smtp.client-ip=52.101.125.92", "smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=valinux.co.jp", "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=valinux.co.jp", "dkim=none (message not signed)\n header.d=none;dmarc=none action=none header.from=valinux.co.jp;" ], "Received": [ "from sin.lore.kernel.org (sin.lore.kernel.org\n [IPv6:2600:3c15:e001:75::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fw5w31GFFz1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 00:17:55 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sin.lore.kernel.org (Postfix) with ESMTP id DF1583025F4D\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 14:16:42 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id EF9CD3E6DC1;\n\tTue, 14 Apr 2026 14:16:33 +0000 (UTC)", "from TYVP286CU001.outbound.protection.outlook.com\n (mail-japaneastazon11021092.outbound.protection.outlook.com [52.101.125.92])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A34D83E63A3;\n\tTue, 14 Apr 2026 14:16:31 +0000 (UTC)", "from TY7P286MB7722.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:38f::10)\n by TYWP286MB3623.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:392::5) with\n Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.48; Tue, 14 Apr\n 2026 14:16:28 +0000", "from TY7P286MB7722.JPNP286.PROD.OUTLOOK.COM\n ([fe80::2305:327c:28ec:9b32]) by TY7P286MB7722.JPNP286.PROD.OUTLOOK.COM\n ([fe80::2305:327c:28ec:9b32%5]) with mapi id 15.20.9769.046; Tue, 14 Apr 2026\n 14:16:28 +0000" ], "ARC-Seal": [ "i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776176193; cv=fail;\n b=mv9Kvh1dkZwtKdRqPrUMCHN1hCjbPWjzOkCVxT9PpC8YPBq7idKt0Gev5VRMKpHyFPd4HMD8NLmdtJb0mTpOxrlpa9E58w9ZX37HHfNzFVYuUuxywKcPOjqtB3t3vwBdPkhgapvuGY68oaG2caoJpE+7lLycYJTcK2X9X4CJvis=", "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=yyl8Qwa1FoInG7Au2KGr3NkDyzukVfH820ZNmWN1/q7IYBoLUrfXrymJ2Ya7giz0E5n1mDRvLPSvEJCk9AMoDT4sRzy2kQCrPYDyuBAmsj2781kBpYxQBwlkZj1NUS6bGAG4Gy87CfjPqXqn1skt5UbQ4ojpZ33o8W9boN/NRVTjQv2T69nr9IkAfDX1mGvZA1WTM1n6NtrjrR27H46ElAHXuG4S5Z8fuh8GpAmMwWrrB1pAilkULJiqo45lAQSzrvjfjM5YZEzclEMbx3VJ1vnv/SMDZA5P/bQzxaqzgo+Z5bGmKTEd2cbpW7JNiG45xJ+DtkmITGllHmfuAGV8Ow==" ], "ARC-Message-Signature": [ "i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776176193; c=relaxed/simple;\n\tbh=MW1Aj0gv67C9tvqQ6LpR4zRW1c/whgc3oVW6U+bAGXg=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t Content-Type:MIME-Version;\n b=Gvjhu25Hj1fyJT9cM7Rxrj2JX7/gpABamS26zZBwiNaEQTJFEkNi7cwHNKhXlT0sKpohuwtP4CLE7/sFucDhc42T5BhlTv8QtoeBDhZb+PE+NPZHHoUF9k2ZSHbFoG+XwCDDrIPrwdNBjGJuzMIY3b9bFnLER8o7IEzyhTt9LUI=", "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=trU5O1holpV7RmRFQF4xflLdExKLZ5LXpwXvnw5UsGY=;\n b=pPOiTWeG9TfXrLdPSOIgOQdPpbTyyAHI0j85IcNZkiEEzPex+U6PHq3aBg6eyI0moI0j8P8M3Ap+iLKo7baC2uTC2bXLSV7r9SbEutfLyddWb39OtQ1TYPAtrl3XIHYuRcsDjNkv1coyUKt80G1m9JxzWg056FoRpKeCMu+MCsTmMdICw5YjdpGtPipAhruIGbWKy8Ith5ZyBI8toGKrLw8AugtE/LHtA+1UQF3lf6J7C/LjaiEgOb8Lk/5BkuinNCUVwWMrTpF0Dj4okC7d2qpksiRuhDPNLt4KvGiS1U6qZBV8BxJQlpdUmjWEh37FG4B3qvRWSBGtEujn8uI6dQ==" ], "ARC-Authentication-Results": [ "i=2; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=valinux.co.jp;\n spf=pass smtp.mailfrom=valinux.co.jp;\n dkim=pass (1024-bit key) header.d=valinux.co.jp header.i=@valinux.co.jp\n header.b=F6OwtxgG; arc=fail smtp.client-ip=52.101.125.92", "i=1; mx.microsoft.com 1; spf=pass\n smtp.mailfrom=valinux.co.jp; dmarc=pass action=none\n header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=valinux.co.jp;\n s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=trU5O1holpV7RmRFQF4xflLdExKLZ5LXpwXvnw5UsGY=;\n b=F6OwtxgG2W9H8ZhGas4VKn9ZYbetLYq+1gBtONnEMZ9MJ8/01jQ4BKRAgnciHiJppslLoa+ujU9S74Ug0qU0OOwF2EcSysTu3oaoicCqg0PujnvGTVJfTc9oA7KrIdKL70uGX8vncQb3abwZHFsdYQ2+Mszrh/pvL+D7EmrgpC8=", "From": "Koichiro Den <den@valinux.co.jp>", "To": "Jingoo Han <jingoohan1@gmail.com>,\n Manivannan Sadhasivam <mani@kernel.org>,\n Lorenzo Pieralisi <lpieralisi@kernel.org>, =?utf-8?q?Krzysztof_Wilczy=C5=84?=\n\t=?utf-8?q?ski?= <kwilczynski@kernel.org>, Rob Herring <robh@kernel.org>,\n Bjorn Helgaas <bhelgaas@google.com>,\n Kishon Vijay Abraham I <kishon@kernel.org>, Jon Mason <jdmason@kudzu.us>,\n Dave Jiang <dave.jiang@intel.com>, Allen Hubbe <allenbh@gmail.com>,\n Niklas Cassel <cassel@kernel.org>, Frank Li <Frank.Li@nxp.com>,\n Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>,\n Marco Crivellari <marco.crivellari@suse.com>,\n Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,\n Manikanta Maddireddy <mmaddireddy@nvidia.com>", "Cc": "linux-pci@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tntb@lists.linux.dev", "Subject": "[PATCH v14 7/7] PCI: endpoint: pci-ep-msi: Add embedded doorbell\n fallback", "Date": "Tue, 14 Apr 2026 23:15:14 +0900", "Message-ID": "<20260414141514.1341429-8-den@valinux.co.jp>", "X-Mailer": "git-send-email 2.51.0", "In-Reply-To": "<20260414141514.1341429-1-den@valinux.co.jp>", "References": "<20260414141514.1341429-1-den@valinux.co.jp>", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain", "X-ClientProxiedBy": "TYCP286CA0290.JPNP286.PROD.OUTLOOK.COM\n (2603:1096:400:3c8::7) To TY7P286MB7722.JPNP286.PROD.OUTLOOK.COM\n (2603:1096:405:38f::10)", "Precedence": "bulk", "X-Mailing-List": "linux-pci@vger.kernel.org", "List-Id": "<linux-pci.vger.kernel.org>", "List-Subscribe": "<mailto:linux-pci+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:linux-pci+unsubscribe@vger.kernel.org>", "MIME-Version": "1.0", "X-MS-PublicTrafficType": "Email", "X-MS-TrafficTypeDiagnostic": "TY7P286MB7722:EE_|TYWP286MB3623:EE_", "X-MS-Office365-Filtering-Correlation-Id": "fb121408-0e84-4733-7503-08de9a306b6e", "X-MS-Exchange-SenderADCheck": "1", "X-MS-Exchange-AntiSpam-Relay": "0", "X-Microsoft-Antispam": "\n\tBCL:0;ARA:13230040|10070799003|366016|1800799024|7416014|376014|921020|56012099003|18002099003|22082099003;", "X-Microsoft-Antispam-Message-Info": "\n\tKxbF948hg92+CX8XejSVgazrvq4L1+hqxjfCs2UbyKbdNhinEcmExQ1v1vge1FnltLRUMPkHKp2lQ8lsassJ/4UOn6oVY8i+rdaVZRagcCkUC+bLgbgzb6MWxWzAINl2bApDVDUgZDAv6HcIVmO22QwtIl8mOTJIen4WLar3pQ/zGGPLxWHdwsijJ/o2/Id+a/ztcRmOw9ewIoA71zo/ZXT2t/EPCWfpL446+9Q0IHKy/q/tlYgcLlVnSKcDxuqv4+RI7dmqq3frrQG/obaEG8ZFNr27VRvrhaVgkcRRJI6IG53cQLnZDVnjHC7hHYHkstaQTwGzWBbzoZ1vokYtc0NmgCCoGjM6wljn4H4zrQ9FTtnbA5XcNpESJK9OcsaI8yptNPNjX0AK3Riygc/gVHKdsCWlowcVW240f03dL3NBJ7vEqqzhwBK79OnwHvS9x8t/SvIaTRwa4s+SdWmMyzkVRGi4nIsBMLEZK8pew8/DxmzWTSRZDj5gCIU8xjiCzP/4lrrDDckRRWc1LBYl0R10Ux4/qEBHEO6ChRINRmT1eAfOErIvo1jczNShMibrdPnv08RS/2a62nvjtXU5wtYxj3s3klDg4SMBn2HktENcZI6XX5MQY6m4angJKRYy0pYw3gI41wnHr5X7JqYtnL107HHzUzY7mpkPN5OQZA93QGWrdDfBtsmQAd5iDSrhnnOKt6p19uwbOsnFY0zcQroSusZV2UwEWkEDe+7lejF0GE5Axz3HB6pxsaKHlHPhT7oWOLL7jBY/7skKNPAF0A==", "X-Forefront-Antispam-Report": "\n\tCIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TY7P286MB7722.JPNP286.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(366016)(1800799024)(7416014)(376014)(921020)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1102;", "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1", "X-MS-Exchange-AntiSpam-MessageData-0": "\n EOXDI2NaM7Kjb/29+oqV+zphvle3qweicqA4RlXrGkwRUr/GaeLD5RylQ1TLNzmLhiLoqkrgODywm1LiObquE6HqovIGsXbVSUJCN434EPK981BpeBWJQxjMtz782TXv2Ylhnq2hwsgYaTsZaMbJMF/J40vl1rPh3JDU1MizmHM6HpjswFA07olEsqveCeuu2JEwo9jt7GZO1uAH9iIMIMCwF0Byzorj+L4xnTKEw8N350yBkDkzyBD9jyWjLjLcB5394n3mlMgqBN7Gn8uxEwYvnj1F6vFyFZ/wXI/LaYlhCSzzXeiWyyM8f78cCzvzhT9vUXeblVayQ38GT7JyhSnchF6bzbJzz5wvU/yvXYo6q4M9xT63nGkHO0jVp0sYSGTW6bjfcQaIma9mduBwZc7U+jPRo7nrAbuWT8zuaprCiYb2ibCtpWMkJ3ooIgZU6sHk2LwBfYdMJT6KwXpN3xpHfV0O1JZgo+RLwbkexFbwcQK6WJtk6982blnCZzO+donxKglbrB8ws7h6RliGRKRD/OX0q7HWYa8IG9fgGO6q/ihEeh2MGgm/P4iiha754eNE+fg+M6UWqJvhcfkDnWwv5+DZ7BIONBy3CiUMj8BZFNn6dv6gvhydv6TbGgQQOS7ujtnVOsY6rqanFxtX/5KgejL7m1jBcAApTUoW2Z+WwN6uDp+p/xzGmxmHS/QyDTbhGjI+2esXA/RgudIaQprJyhh4QT+nRZ17Z3nq6eK8LZFCMdCMuOcnAIoPpOf7XgYMXPKskGQsKsCRy30paAOti/9rjN+nplmpzZ572rrQdslutOcPRjS85dNLZUaa2kvBw48DxuCsBI52zysFleRANdob+elxmD6rS76N0G+971bRK6uwJSEyKKlt/pMozbKxlZRn2RjRIKgUWOCLnt/3XPTmgpnzg9T0/xGeF1EkaUEHbk+DvBpCUBeQc1kUjaAi1fSY2H02SsEUC2yJRJwkqStL4MKkukf4QOYwyBarI8c3iGT1PnIHoNk526oKFqkC6J+wv/CG5/nG6sYLiYcojLHMgvbSOn2ah0Bw0nesjZwy8zk2hIoTMJ/Ew7AkHjOwkALjgbnItKhVZM6dmXNkWMxTH9k9KymOG+Zo2eg/vjppg+XEE7ignu3e2u67QiYUcb5RlIYHQpY83NscfigmG7FjuSMcZl+VxbFLPixa++Q93JQcnferCR7YnGCcjNoked9PDdiOUHkgIjSrM1CDm2yEpu4Thh9vTlYu369J69RPDH8W8LCh3rGOtRKOjbg1GK9Z4Cyu+DxZQqSRvb6zRWWWdqMYwZpKbgnEWZMvQcNoist6S5VOKkWPqxZxzQtWbI/PuMK45CVPyTMvoZcw8VZiyX79gTNtxIqEpaPyuKdQCrclxIocHvmViQ5mrCcKNCGIq4+4Xhs3HiCquvVDARCx0XuQffut2Thp4tI68OHQCyFTP4DD3/646tPsVFd5Wry++NX4pUTOstFjxawQ7jrqA0wWr3IixoYFmDfshAfZSwbsQd/NqFfsA3tYsmF3CFLsdSaD2ZGdHRH9hXk5bxf75tpMCfFY8sMK/kPcaZU4KYZA4YOx3sSLMTo0d8hWs7hrZa53bnONeJP7/PPVhc/c7/OxZ3UWsOgXyZ1gchMgiP+dQyRo5ZAvkh2SjuHhUZPoj2vM5zr+8/HGgHELXJZploVJTMVRshXvso7oD77RACvmVEK8uKGoQ5v0t0BftGYPPWQdsmk+ve4KB1rQtFueguTsyhrCR68W+G2hFs8dTPw0L+bxLY1d6PGu", "X-OriginatorOrg": "valinux.co.jp", "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n fb121408-0e84-4733-7503-08de9a306b6e", "X-MS-Exchange-CrossTenant-AuthSource": "TY7P286MB7722.JPNP286.PROD.OUTLOOK.COM", "X-MS-Exchange-CrossTenant-AuthAs": "Internal", "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "14 Apr 2026 14:16:28.5143\n (UTC)", "X-MS-Exchange-CrossTenant-FromEntityHeader": "Hosted", "X-MS-Exchange-CrossTenant-Id": "7a57bee8-f73d-4c5f-a4f7-d72c91c8c111", "X-MS-Exchange-CrossTenant-MailboxType": "HOSTED", "X-MS-Exchange-CrossTenant-UserPrincipalName": "\n 25PLQRcAAzqZAuBWdm6Ss+4HwpAz8oPpqo0ZJTKbKb4PQ3Pt2ASjfnksKEUgIhqX0tBHUwrEBXIfwg4L8PB+JQ==", "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "TYWP286MB3623" }, "content": "Some endpoint platforms cannot use platform MSI / GIC ITS to implement\nEP-side doorbells. In those cases, EPF drivers cannot provide an\ninterrupt-driven doorbell and often fall back to polling.\n\nAdd an \"embedded\" doorbell backend that uses a controller-integrated\ndoorbell target (e.g. DesignWare integrated eDMA interrupt-emulation\ndoorbell).\n\nThe backend locates the doorbell register and a corresponding Linux IRQ\nvia the EPC aux-resource API. If the doorbell register is already\nexposed via a fixed BAR mapping, provide BAR+offset. Otherwise provide\nthe DMA address returned by dma_map_resource() (which may be an IOVA\nwhen an IOMMU is enabled) so EPF drivers can map it into BAR space.\n\nWhen MSI doorbell allocation fails with -ENODEV,\npci_epf_alloc_doorbell() falls back to this embedded backend.\n\nSuggested-by: Manivannan Sadhasivam <mani@kernel.org>\nSigned-off-by: Koichiro Den <den@valinux.co.jp>\n---\nChanges in v14:\n - Drop -EOPNOTSUPP to -ENODEV conversions.\n\n drivers/pci/endpoint/pci-ep-msi.c | 131 +++++++++++++++++++++++++++++-\n include/linux/pci-epf.h | 8 ++\n 2 files changed, 136 insertions(+), 3 deletions(-)", "diff": "diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-ep-msi.c\nindex 85fe46103220..0855c7930abb 100644\n--- a/drivers/pci/endpoint/pci-ep-msi.c\n+++ b/drivers/pci/endpoint/pci-ep-msi.c\n@@ -6,6 +6,8 @@\n * Author: Frank Li <Frank.Li@nxp.com>\n */\n \n+#include <linux/align.h>\n+#include <linux/cleanup.h>\n #include <linux/device.h>\n #include <linux/export.h>\n #include <linux/interrupt.h>\n@@ -36,6 +38,109 @@ static void pci_epf_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg)\n \tpci_epc_put(epc);\n }\n \n+static int pci_epf_alloc_doorbell_embedded(struct pci_epf *epf, u16 num_db)\n+{\n+\tconst struct pci_epc_aux_resource *doorbell = NULL;\n+\tstruct pci_epf_doorbell_msg *msg;\n+\tstruct pci_epc *epc = epf->epc;\n+\tsize_t map_size = 0, off = 0;\n+\tdma_addr_t iova_base = 0;\n+\tphys_addr_t phys_base;\n+\tint count, ret, i;\n+\tu64 addr;\n+\n+\tcount = pci_epc_get_aux_resources_count(epc, epf->func_no,\n+\t\t\t\t\t\tepf->vfunc_no);\n+\tif (count < 0)\n+\t\treturn count;\n+\tif (!count)\n+\t\treturn -ENODEV;\n+\n+\tstruct pci_epc_aux_resource *res __free(kfree) =\n+\t\t\t\tkcalloc(count, sizeof(*res), GFP_KERNEL);\n+\tif (!res)\n+\t\treturn -ENOMEM;\n+\n+\tret = pci_epc_get_aux_resources(epc, epf->func_no, epf->vfunc_no,\n+\t\t\t\t\tres, count);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* TODO: Support multiple DOORBELL_MMIO resources per EPC. */\n+\tfor (i = 0; i < count; i++) {\n+\t\tif (res[i].type != PCI_EPC_AUX_DOORBELL_MMIO)\n+\t\t\tcontinue;\n+\n+\t\tdoorbell = &res[i];\n+\t\tbreak;\n+\t}\n+\tif (!doorbell)\n+\t\treturn -ENODEV;\n+\taddr = doorbell->phys_addr;\n+\tif (!IS_ALIGNED(addr, sizeof(u32)))\n+\t\treturn -EINVAL;\n+\n+\t/*\n+\t * Reuse the pre-exposed BAR window if available. Otherwise map the MMIO\n+\t * doorbell resource here. Any required IOMMU mapping is handled\n+\t * internally, matching the MSI doorbell semantics.\n+\t */\n+\tif (doorbell->bar == NO_BAR) {\n+\t\tphys_base = addr & PAGE_MASK;\n+\t\toff = addr - phys_base;\n+\t\tmap_size = PAGE_ALIGN(off + sizeof(u32));\n+\n+\t\tiova_base = dma_map_resource(epc->dev.parent, phys_base,\n+\t\t\t\t\t map_size, DMA_FROM_DEVICE, 0);\n+\t\tif (dma_mapping_error(epc->dev.parent, iova_base))\n+\t\t\treturn -EIO;\n+\n+\t\taddr = iova_base + off;\n+\t}\n+\n+\tmsg = kcalloc(num_db, sizeof(*msg), GFP_KERNEL);\n+\tif (!msg) {\n+\t\tret = -ENOMEM;\n+\t\tgoto err_unmap;\n+\t}\n+\n+\t/*\n+\t * Embedded doorbell backends (e.g. DesignWare eDMA interrupt emulation)\n+\t * typically provide a single IRQ and do not offer per-doorbell\n+\t * distinguishable address/data pairs. The EPC aux resource therefore\n+\t * exposes one DOORBELL_MMIO entry (u.db_mmio.irq).\n+\t *\n+\t * Still, pci_epf_alloc_doorbell() allows requesting multiple doorbells.\n+\t * For such backends we replicate the same address/data for each entry\n+\t * and mark the IRQ as shared (IRQF_SHARED). Consumers must treat them\n+\t * as equivalent \"kick\" doorbells.\n+\t */\n+\tfor (i = 0; i < num_db; i++)\n+\t\tmsg[i] = (struct pci_epf_doorbell_msg) {\n+\t\t\t.msg.address_lo = (u32)addr,\n+\t\t\t.msg.address_hi = (u32)(addr >> 32),\n+\t\t\t.msg.data = doorbell->u.db_mmio.data,\n+\t\t\t.virq = doorbell->u.db_mmio.irq,\n+\t\t\t.irq_flags = IRQF_SHARED,\n+\t\t\t.type = PCI_EPF_DOORBELL_EMBEDDED,\n+\t\t\t.bar = doorbell->bar,\n+\t\t\t.offset = (doorbell->bar == NO_BAR) ? 0 :\n+\t\t\t\t doorbell->bar_offset,\n+\t\t\t.iova_base = iova_base,\n+\t\t\t.iova_size = map_size,\n+\t\t};\n+\n+\tepf->num_db = num_db;\n+\tepf->db_msg = msg;\n+\treturn 0;\n+\n+err_unmap:\n+\tif (map_size)\n+\t\tdma_unmap_resource(epc->dev.parent, iova_base, map_size,\n+\t\t\t\t DMA_FROM_DEVICE, 0);\n+\treturn ret;\n+}\n+\n static int pci_epf_alloc_doorbell_msi(struct pci_epf *epf, u16 num_db)\n {\n \tstruct pci_epf_doorbell_msg *msg;\n@@ -109,18 +214,38 @@ int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db)\n \tif (!ret)\n \t\treturn 0;\n \n-\tdev_err(dev, \"Failed to allocate doorbell: %d\\n\", ret);\n-\treturn ret;\n+\t/*\n+\t * Fall back to embedded doorbell only when platform MSI is unavailable\n+\t * for this EPC.\n+\t */\n+\tif (ret != -ENODEV)\n+\t\treturn ret;\n+\n+\tret = pci_epf_alloc_doorbell_embedded(epf, num_db);\n+\tif (ret) {\n+\t\tdev_err(dev, \"Failed to allocate doorbell: %d\\n\", ret);\n+\t\treturn ret;\n+\t}\n+\n+\tdev_info(dev, \"Using embedded (DMA) doorbell fallback\\n\");\n+\treturn 0;\n }\n EXPORT_SYMBOL_GPL(pci_epf_alloc_doorbell);\n \n void pci_epf_free_doorbell(struct pci_epf *epf)\n {\n+\tstruct pci_epf_doorbell_msg *msg0;\n+\tstruct pci_epc *epc = epf->epc;\n+\n \tif (!epf->db_msg)\n \t\treturn;\n \n-\tif (epf->db_msg[0].type == PCI_EPF_DOORBELL_MSI)\n+\tmsg0 = &epf->db_msg[0];\n+\tif (msg0->type == PCI_EPF_DOORBELL_MSI)\n \t\tplatform_device_msi_free_irqs_all(epf->epc->dev.parent);\n+\telse if (msg0->type == PCI_EPF_DOORBELL_EMBEDDED && msg0->iova_size)\n+\t\tdma_unmap_resource(epc->dev.parent, msg0->iova_base,\n+\t\t\t\t msg0->iova_size, DMA_FROM_DEVICE, 0);\n \n \tkfree(epf->db_msg);\n \tepf->db_msg = NULL;\ndiff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h\nindex cd747447a1ea..8a6c64a35890 100644\n--- a/include/linux/pci-epf.h\n+++ b/include/linux/pci-epf.h\n@@ -171,6 +171,12 @@ enum pci_epf_doorbell_type {\n * (NO_BAR if not)\n * @offset: offset within @bar for the doorbell target (valid iff\n * @bar != NO_BAR)\n+ * @iova_base: Internal: base DMA address returned by dma_map_resource() for the\n+ * embedded doorbell MMIO window (used only for unmapping). Valid\n+ * when @type is PCI_EPF_DOORBELL_EMBEDDED and @iova_size is\n+ * non-zero.\n+ * @iova_size: Internal: size of the dma_map_resource() mapping at @iova_base.\n+ * Zero when no mapping was created (e.g. pre-exposed fixed BAR).\n */\n struct pci_epf_doorbell_msg {\n \tstruct msi_msg msg;\n@@ -179,6 +185,8 @@ struct pci_epf_doorbell_msg {\n \tenum pci_epf_doorbell_type type;\n \tenum pci_barno bar;\n \tresource_size_t offset;\n+\tdma_addr_t iova_base;\n+\tsize_t iova_size;\n };\n \n /**\n", "prefixes": [ "v14", "7/7" ] }