Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp19288rdh; Tue, 13 Feb 2024 08:11:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzrssIF+NVl3w2PZwYhsfejXnIot+It98UG5Tu9N5k90PvWlro9Ny0X9GLFjUEaUhf+xjT X-Received: by 2002:a17:902:c10c:b0:1d9:7039:3519 with SMTP id 12-20020a170902c10c00b001d970393519mr10868272pli.2.1707840691116; Tue, 13 Feb 2024 08:11:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707840691; cv=pass; d=google.com; s=arc-20160816; b=pGX3UTVWk79ph9zFAVA29wsUmXAQYVBk/+P2fE8bW5jk6BrVEJHULppgk3nRCi0Xmp D2o5L8zpfXFx7dFb7X8DDF6vkjxuNqj8VyPuGdSPCsgZ1CKiRWDbOhtaLvhPss1uy69h jX50gPUxjGkCImsacuWkLultS7U4I3xdYKPhhInSGam9W4Mi+cmhnKNlBlwNF2h7NXbZ wofypx37dBVSgIzmScubCwIQXWj4qus06yiHcNg6rWd6cZzin046T6mVyAyRVps1+/dZ hd+gaqvANvd9N5Tb86Cj5ID+xn5DI5qe8gnLW2znGqwzEJLuPkZkPZUqSWz0aNNXi5rs M5nA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=NdXff2HKhkHBa8EZi7NPSQYCYp0SJeGlooiKKxB4EZU=; fh=uuyaiJ6h/cmwh8kJhZ3Ht5rlVJ6L/wXG7VivPNbIn9Q=; b=RD2qdWSL3C2n6MRUSLE6z/Zm7WUKFuCNqWVRHXtaD0T7KYG7NaORVBmi8HWa0GIm6c 0Df9LzQT0Ch7nRS82BBDPFHHMjFtZhzxYsXEuFGq/SQdsAvesoLtkdFzWfNurPilUfoH bYwA8dcamgNUpRs4gR7E9a4IRT8dirwBcH89pBKGIr2ut0FgkgG/rqlwlJTO0N+nm70S O23BGWZHUJXSu+YzTSRpC3Up8VKOVjJKdkPnsYLoIeh69nUy7w/MBW2a1hXJEoMPiyjW yTIzPFrqpLy1dgvEKakx2sst9Z31UIk5cGMnBablqQBBSCI7xzjEM7OrPs/VXz1njzNj kFeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cUUxxoWJ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63831-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCVaZHS1X+ngr576Q4bqJsidbeDoQBLl8MBDV5PtUfqFVIdgmP5h5GoZPRFVcjcWTYqaUNOTux8jsmaaDPeC9ny9gJAOilAeguFwZOCimw== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y21-20020a170902ed5500b001d8a5c7a37fsi2112914plb.240.2024.02.13.08.11.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 08:11:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cUUxxoWJ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63831-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id ED323B215AE for ; Tue, 13 Feb 2024 15:48:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 630285EE94; Tue, 13 Feb 2024 15:48:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="cUUxxoWJ" Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 692935EE72 for ; Tue, 13 Feb 2024 15:48:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707839303; cv=none; b=NlToxxg/BfgoTxAKO+itwssHezTNzzlSMSOmC+I6OKvp42FJAEqwVH8Z/fLMAkW/6BXBFflifgwR0diaXkG+t0IGcfSThbNjCRJp/oyiYK+YsxkV34kL/l9YnDNouYTzyYwooaJ6tngOySYGbOqD9PnHopJV1ScasJCx9q4E1/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707839303; c=relaxed/simple; bh=w4l6xchzgDPveYf3jkjUBQu5hN9tYPEa+bUtNK5UN+U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PSdkyvA3MdDqZthUUf9I2FpuyvEnxSHeznD5IjaWBv0gpCcd5LWuMUGFEJEVULddVw5NgbsD+gTlGXUBtDZNW5jDgb2ts82aFP4VPHO4VuI0D+aAPMakL+mkCMqfBhXUT+tiD/O3gp6olkKPFDq4Ok2UrYqT09BLxnuo/dA0Vzw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=cUUxxoWJ; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <45292232-af27-4945-9285-e1c42f1ba65e@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707839297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NdXff2HKhkHBa8EZi7NPSQYCYp0SJeGlooiKKxB4EZU=; b=cUUxxoWJ+nEcgp1Xd4gvcJnoOUn0IX/OwvYELXLEKAWWrEcb8XV0n6dcmiw6kAa9mDNXtM ZNjZ99/1Uj5N1nfkBVASWW5ycGUGXRcDf6+1FOrS0eeG5PeU4MQhJlPyFYAOvZwjHsY8lk m3gQ/BmN+r3r7wR+pjvbzeHpC6Guaas= Date: Tue, 13 Feb 2024 23:48:07 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [etnaviv-next v13 7/7] drm/etnaviv: Add support for vivante GPU cores attached via PCI(e) To: Maxime Ripard Cc: Lucas Stach , Russell King , Christian Gmeiner , David Airlie , Thomas Zimmermann , dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20240206172759.421737-1-sui.jingfeng@linux.dev> <20240206172759.421737-8-sui.jingfeng@linux.dev> <65qv24hhkmmy4haylh53muvz2xliejysc3uywq44pl3xx7rus4@ynyau4djposv> <67936300-7bfb-4f5e-9b80-ee339313fd61@linux.dev> <7ejh5uoppa257ap64ps33wrtabn4iu6flf4fn5lqhuuhbtmpjj@25rqv7mnko5q> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sui Jingfeng In-Reply-To: <7ejh5uoppa257ap64ps33wrtabn4iu6flf4fn5lqhuuhbtmpjj@25rqv7mnko5q> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT Hi, On 2024/2/13 22:38, Maxime Ripard wrote: > On Sat, Feb 10, 2024 at 12:25:33AM +0800, Sui Jingfeng wrote: >> On 2024/2/9 23:15, Maxime Ripard wrote: >>> On Fri, Feb 09, 2024 at 12:02:48PM +0100, Daniel Vetter wrote: >>>> On Thu, Feb 08, 2024 at 04:27:02PM +0100, Maxime Ripard wrote: >>>>> On Wed, Feb 07, 2024 at 10:35:49AM +0100, Daniel Vetter wrote: >>>>>> On Wed, Feb 07, 2024 at 01:27:59AM +0800, Sui Jingfeng wrote: >>>>>>> The component helper functions are the glue, which is used to bind multiple >>>>>>> GPU cores to a virtual master platform device. Which is fine and works well >>>>>>> for the SoCs who contains multiple GPU cores. >>>>>>> >>>>>>> The problem is that usperspace programs (such as X server and Mesa) will >>>>>>> search the PCIe device to use if it is exist. In other words, usperspace >>>>>>> programs open the PCIe device with higher priority. Creating a virtual >>>>>>> master platform device for PCI(e) GPUs is unnecessary, as the PCI device >>>>>>> has been created by the time drm/etnaviv is loaded. >>>>>>> >>>>>>> we create virtual platform devices as a representation for the vivante GPU >>>>>>> ip core. As all of subcomponent are attached via the PCIe master device, >>>>>>> we reflect this hardware layout by binding all of the virtual child to the >>>>>>> the real master. >>>>>>> >>>>>>> Signed-off-by: Sui Jingfeng >>>>>> Uh so my understanding is that drivers really shouldn't create platform >>>>>> devices of their own. For this case here I think the aux-bus framework is >>>>>> the right thing to use. Alternatively would be some infrastructure where >>>>>> you feed a DT tree to driver core or pci subsystem and it instantiates it >>>>>> all for you correctly, and especially with hotunplug all done right since >>>>>> this is pci now, not actually part of the soc that cannot be hotunplugged. >>>>> I don't think we need intermediate platform devices at all. We just need >>>>> to register our GPU against the PCI device and that's it. We don't need >>>>> a platform device, we don't need the component framework. >>>> Afaik that's what this series does. The component stuff is for the >>>> internal structure of the gpu ip, so that the same modular approach that >>>> works for arm-soc also works for pci chips. >>> But there should be a single PCI device, while we have multiple "DT" >>> devices, right? Or is there several PCI devices too on that PCI card? >> >> There is only a single PCI(e) device on that PCI(e) card, this single >> PCI(e) device is selected as the component master. All other Hardware IP >> blocks are shipped by the single PCI(e) master. It may includes Display >> controllers, GPUs, video decoders, HDMI display bridges hardware unit etc. >> >> But all of those Hardware IP share the same MMIO registers PCI BAR, this >> PCI BAR is a kind of PCI(e) MEM resource. It is a relative *big* chunk, >> as large as 32MB in address ranges for the JingJia Macro dGPU. Therefore, >> I break the whole registers memory(MMIO) resource into smaller pieces by >> creating platform device manually, manually created platform device is >> called as virtual child in this series. >> >> In short, we cut the whole into smaller piece, each smaller piece is a >> single hardware IP block, thus deserve a single device driver. We will >> have multiple platform devices if the dGPU contains multiple hardware >> IP block. On the driver side, we bind all of the scattered driver module >> with component. > That's kind of my point then. If there's a single device, there's no > need to create intermediate devices and use the component framework to > tie them all together. You can have a simpler approach where you create > a function that takes the memory area it operates on (and whatever > additional resource it needs: interrupt, clocks, etc.) and call that > directly from the PCIe device probe, and the MMIO device bind. Yes, you are right. I have implemented the method just as you told me at V12 of this series (see 0004 patch at [1]). But at V13, I suddenly realized that the component code path plus(+) non-component code path yield a "side-by-side" implement. The old non-component approach can not support binding multiple sub-core, it can only support one Vivante GPU IP core case. But there are dGPU which shipping two identical core. While, the component-based approach implemented at this version is the most universal and the most flexible and extensible. We could bind a virtual display driver and/or a real display driver to the real master (refer to the PCI(e) device). The PCI(e) device is responsible for present the DRM service to userspace, like a leader or agent. All other sub hardware and software are hiding behind of the master. Besides, Lucas asked me implement the driver like this way at V10 (see [2]) Lucas said: "My favorite option would be to just always use the component path even when the GPU is on a PCI device to keep both paths mostly aligned. One could easily image both a 3D and a 2D core being made available though the same PCI device." Lucas, are you watching? How about this version? Can you help to review please? [1] https://patchwork.freedesktop.org/series/127084/ [2] https://lore.kernel.org/dri-devel/0f1095ef333da7ea103486a1121ca9038815e57c.camel@pengutronix.de/ > Maxime