Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp885694rdb; Tue, 30 Jan 2024 01:13:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGibOgvw7Kae1Ullnpc8PsJeUOO2SUudweevrK9bFaPZnBeJ3YySrLcijE+BokBY43iJU8l X-Received: by 2002:a05:6358:98a4:b0:176:6270:8cb6 with SMTP id q36-20020a05635898a400b0017662708cb6mr7895464rwa.25.1706606010697; Tue, 30 Jan 2024 01:13:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706606010; cv=pass; d=google.com; s=arc-20160816; b=n0WwiPxy/u8/o7+AEdxHckYrQbjCHmlQJ9+AA9AiynB9wEmVzN5wOBiKC3MG9CiQN6 FkAUx4ByI7gsFOKmcn0eNgVaGmKmA+QLx+GJbCnKMiP3T2GO9K64UHlIBsJyAHznSWK6 CnCaHxEr6NJGEZJnmqX7aGaP0TkfhVWzugLKJVJZU0+bgcZ+cpJ8TORZeoo6HOfLE+We h1Jr+n5f8umFUTUUwKLST3ElsHR7wfcw4G6DPFVbGq07QZLq+yYe1RNRzQR3x5k3x0Nu +FjO8Qh2zIwj6JIGkEY1iYvMGIgoesC0mLtK+Cwlv/5GyLmX//3PwuEHnOgj8HiMqwWT sRXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FtHLxH7cs3c5SJogzL1Yq2dCgbgujdB2fUN48I8yxUw=; fh=I+54zIykRcJm9tbVx6VCrktx+2hMgpbws9wgl+pSTUw=; b=ooHtVB7lTq6iUAb/380C24zSnqWQPKCLsYp9a+JdAKyROdwNTqWMZeKaddByt25EGt ZWhGkDJWLi9QIpZ0aomQTXAs32b131Xht9X2c+efrrFe6zkf4cEvZSs0BeVTxMje2ehX dQiULKvGL+FxnRjecYN5yKqzyxctV7bifD3pFM2099ECr7xHJM3EY0m20s/ddVYB12qh lavunIdkfOCls8BSgqpKa+L/XIkcx71HdoJ2XHyDIp+TOTux4fFRYc80KUP8guHxX4VO QBWHkW9vqrM8EtWjI1BrHtsBlrHegNmJLGjaCs7oKXRxvvYnTKHe+1o8RK58plOeuhNY erkA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=rc9Mc+Vb; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-44209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44209-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f28-20020a63381c000000b005ce08c4bff5si7033862pga.760.2024.01.30.01.13.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:13:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=rc9Mc+Vb; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-44209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44209-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C3FE728AC69 for ; Tue, 30 Jan 2024 09:08:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C698604C8; Tue, 30 Jan 2024 09:07:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="rc9Mc+Vb" Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 8BAB159157 for ; Tue, 30 Jan 2024 09:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706605661; cv=none; b=blIAi9FpWAXz0JMWX1CWo9zd2u5QQAq8jyUDW/ZH5FXm8oJn0PLoaFUrul56IaZ5sM8pGaCx0u5cxCk0m889W1oshOfUrStYH+dh/N37Odj7ghPeuTykCX3fRvXbIn85Er9GaJEFonRIXpj9b0jaZHVCkCKowqACNAUMpZzdYTQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706605661; c=relaxed/simple; bh=44XkCsZCctr6fIPl85tILYlsF3Pmyb1/in21HOr3WR4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lEi7QrHH7M9STj+DWlUzneJcrckCcGbhbG1MQ3oG579Sty2CytcfhcdNJI+MRMcwEDwwW40Kuth9mqPPmKlkKC19j+jaeGlQ0Z7PXLgiQZhfw99X6iUOtrnQbBnwqhk/GTtyTacFudbm1TLZawQr69lPZMBgBGX1gtsSevA5R9s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com; spf=pass smtp.mailfrom=cloud.com; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b=rc9Mc+Vb; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloud.com Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-33af40493f4so901561f8f.3 for ; Tue, 30 Jan 2024 01:07:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1706605658; x=1707210458; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=FtHLxH7cs3c5SJogzL1Yq2dCgbgujdB2fUN48I8yxUw=; b=rc9Mc+Vb/Az0DcPkzb5uTooYwF5tQFJ49mGYm074w8x33a00dkrSTZKPG60WKZbpfu 3cp3ON48ja/mAkwLU9u+xSpZ14ElXpRv6+oU2EAAuPRdGaTrKgPfY0UXyi+2+zr6f17T sN4Gkvi+f0JfMhAub6X1n6DzqA58YAkdN4Meg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706605658; x=1707210458; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FtHLxH7cs3c5SJogzL1Yq2dCgbgujdB2fUN48I8yxUw=; b=nNyUlz7fveJSK/3qYpYzgm6ygZjSRefRNMwPscJrM1R5saa1Cjv+ft9dbElyYoxBNR Hppz2cSrQKSSzJtcq2PDfq7iYZUxexdKSM/Bgce2xG1D6Yq29iOIg9qIENFUPr9YGn1R utqWv8O4xdhLOTgSwvwvEwPQrvz7U2nm9XM7TmWVP2ivwmpuukiCDQFZXBARqFHVXi3D cyfmaQsXettSMusfjZUCeQeYBfDb2edUUnOLG4/j+ixx1gB83YYjMinNbt1Q+VArsTud m3OkWuoBSJ59WsFAd20R4LWdPWTEskGVodzLE8snpddcrXfaYDzfjLWyUv1aShVkm+Gt HVmQ== X-Gm-Message-State: AOJu0YwE2uVYpHiepIhgF65mOGcP4ocD27S5XxcBJrll8fDU83W7Aht8 /rt0do/WecupkVZQoa+AwDNY9Pi8y1aKocax9W05CTNqBzAEWdvgWqPn/SpwEyk= X-Received: by 2002:a5d:6da3:0:b0:33a:eda8:336a with SMTP id u3-20020a5d6da3000000b0033aeda8336amr4089276wrs.26.1706605657835; Tue, 30 Jan 2024 01:07:37 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id ck14-20020a5d5e8e000000b0033afcf26e11sm586620wrb.29.2024.01.30.01.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:07:37 -0800 (PST) Date: Tue, 30 Jan 2024 10:07:36 +0100 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Bjorn Helgaas Cc: "Chen, Jiqian" , "Rafael J . Wysocki" , Len Brown , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Boris Ostrovsky , Bjorn Helgaas , "xen-devel@lists.xenproject.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "Hildebrand, Stewart" , "Huang, Ray" , "Ragiadakou, Xenia" Subject: Re: [RFC KERNEL PATCH v4 3/3] PCI/sysfs: Add gsi sysfs for pci_dev Message-ID: References: <20240129220113.GA475965@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240129220113.GA475965@bhelgaas> On Mon, Jan 29, 2024 at 04:01:13PM -0600, Bjorn Helgaas wrote: > On Thu, Jan 25, 2024 at 07:17:24AM +0000, Chen, Jiqian wrote: > > On 2024/1/24 00:02, Bjorn Helgaas wrote: > > > On Tue, Jan 23, 2024 at 10:13:52AM +0000, Chen, Jiqian wrote: > > >> On 2024/1/23 07:37, Bjorn Helgaas wrote: > > >>> On Fri, Jan 05, 2024 at 02:22:17PM +0800, Jiqian Chen wrote: > > >>>> There is a need for some scenarios to use gsi sysfs. > > >>>> For example, when xen passthrough a device to dumU, it will > > >>>> use gsi to map pirq, but currently userspace can't get gsi > > >>>> number. > > >>>> So, add gsi sysfs for that and for other potential scenarios. > > >> ... > > > > > >>> I don't know enough about Xen to know why it needs the GSI in > > >>> userspace. Is this passthrough brand new functionality that can't be > > >>> done today because we don't expose the GSI yet? > > I assume this must be new functionality, i.e., this kind of > passthrough does not work today, right? > > > >> has ACPI support and is responsible for detecting and controlling > > >> the hardware, also it performs privileged operations such as the > > >> creation of normal (unprivileged) domains DomUs. When we give to a > > >> DomU direct access to a device, we need also to route the physical > > >> interrupts to the DomU. In order to do so Xen needs to setup and map > > >> the interrupts appropriately. > > > > > > What kernel interfaces are used for this setup and mapping? > > > > For passthrough devices, the setup and mapping of routing physical > > interrupts to DomU are done on Xen hypervisor side, hypervisor only > > need userspace to provide the GSI info, see Xen code: > > xc_physdev_map_pirq require GSI and then will call hypercall to pass > > GSI into hypervisor and then hypervisor will do the mapping and > > routing, kernel doesn't do the setup and mapping. > > So we have to expose the GSI to userspace not because userspace itself > uses it, but so userspace can turn around and pass it back into the > kernel? No, the point is to pass it back to Xen, which doesn't know the mapping between GSIs and PCI devices because it can't execute the ACPI AML resource methods that provide such information. The (Linux) kernel is just a proxy that forwards the hypercalls from user-space tools into Xen. > It seems like it would be better for userspace to pass an identifier > of the PCI device itself back into the hypervisor. Then the interface > could be generic and potentially work even on non-ACPI systems where > the GSI concept doesn't apply. We would still need a way to pass the GSI to PCI device relation to the hypervisor, and then cache such data in the hypervisor. I don't think we have any preference of where such information should be exposed, but given GSIs are an ACPI concept not specific to Xen they should be exposed by a non-Xen specific interface. Thanks, Roger.