From: Greg KH <gregkh@linuxfoundation.org>
To: Iouri Tarassov <iourit@linux.microsoft.com>
Cc: kys@microsoft.com, haiyangz@microsoft.com,
sthemmin@microsoft.com, wei.liu@kernel.org,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
spronovo@microsoft.com
Subject: Re: [PATCH v1 1/9] drivers: hv: dxgkrnl: Driver initialization and creation of dxgadapter
Date: Fri, 14 Jan 2022 06:40:53 +0100 [thread overview]
Message-ID: <YeEM5asW5XtqD0Pi@kroah.com> (raw)
In-Reply-To: <19e524e6-d0fc-20a7-03c6-c1094681a2a6@linux.microsoft.com>
On Thu, Jan 13, 2022 at 04:08:07PM -0800, Iouri Tarassov wrote:
>
> On 1/12/2022 11:46 PM, Greg KH wrote:
> > On Wed, Jan 12, 2022 at 11:55:06AM -0800, Iouri Tarassov wrote:
> > > + dev_dbg(dxgglobaldev, "%s: %x:%x %p %pUb\n",
> > > + __func__, adapter->luid.b, adapter->luid.a, hdev->channel,
> > > + &hdev->channel->offermsg.offer.if_instance);
> >
> > When I see something like "global device pointer", that is a HUGE red
> > flag.
> >
> > No driver should ever have anything that is static to the driver like
> > this, it should always be per-device. Please use the correct device
> > model here, which does not include a global pointer, but rather unique
> > ones that are given to you by the driver core. That way you are never
> > tied to only "one device per system" as that is a constraint that you
> > will have to fix eventually, might as well do it all correctly the first
> > time as it is not any extra effort to do so
> Hi Greg,
>
> dxgglobaldev is a pointer to the global driver data. By design there is a
> single hyper-v VM bus and a single corresponding /dev/dxg device.
That's fine, but use the pointer that you create based on your bus
device, not some static pointer please.
> Virtual GPU adapters are present on the VM bus. /dev/dxg device is used
> to enumerate all virtual GPUs, which are accessible only via IOCTLs
> to /dev/dxg. dxgglobaldev has a list of all vGPU adapters and
> other global driver state. This follows the design on Windows where a single
> global object in dxgkrnl.sys driver is used to enumerate and access all
> GPU devices. This is also how the public D3DKMT interface to dxgkrnl is
> structured.
First off, remember this isn't Windows, let's not make the same mistakes
they have made there please :)
Secondly, this isn't the problem, the issue is that you have a
non-dynamic device here, which is not how Linux drivers should ever
work. It's fine to have a "mux" device like this, but create it
properly, based on the device that the driver core gives you as you must
respect that lifetime, not the lifetime of a static pointer embedded in
a module.
thanks,
greg k-h
prev parent reply other threads:[~2022-01-14 5:40 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 19:55 [PATCH v1 0/9] drivers: hv: dxgkrnl: Driver overview Iouri Tarassov
2022-01-12 19:55 ` [PATCH v1 2/9] drivers: hv: dxgkrnl: Open device object, adapter enumeration, dxgdevice, dxgcontext creation Iouri Tarassov
2022-01-13 7:41 ` Greg KH
2022-01-13 7:44 ` kernel test robot
2022-01-12 19:55 ` [PATCH v1 3/9] drivers: hv: dxgkrnl: Implement creation/destruction of GPU allocations/resources Iouri Tarassov
2022-01-13 8:56 ` kernel test robot
2022-01-12 19:55 ` [PATCH v1 4/9] drivers: hv: dxgkrnl: Implement operations with GPU sync objects Iouri Tarassov
2022-01-12 19:55 ` [PATCH v1 5/9] drivers: hv: dxgkrnl: Implement sharing resources and " Iouri Tarassov
2022-01-12 19:55 ` [PATCH v1 6/9] drivers: hv: dxgkrnl: Seal the shared resource object when dxgk_share_objects is called Iouri Tarassov
2022-01-12 19:55 ` [PATCH v1 7/9] drivers: hv: dxgkrnl: Implementation of submit command, paging and hardware queue Iouri Tarassov
2022-01-12 19:55 ` [PATCH v1 8/9] drivers: hv: dxgkrnl: Implement various WDDM ioctls Iouri Tarassov
2022-01-13 7:47 ` Greg KH
2022-01-14 0:19 ` Iouri Tarassov
2022-01-14 5:38 ` Greg KH
2022-01-15 2:16 ` Iouri Tarassov
2022-01-12 19:55 ` [PATCH v1 9/9] drivers: hv: dxgkrnl: Implement DXGSYNCFILE Iouri Tarassov
2022-01-13 7:41 ` Greg KH
2022-01-14 22:26 ` Iouri Tarassov
2022-01-14 18:03 ` Daniel Vetter
2022-01-14 18:52 ` Iouri Tarassov
2022-01-17 9:35 ` Daniel Vetter
2022-02-05 0:35 ` Iouri Tarassov
2022-02-08 12:28 ` Daniel Vetter
2022-01-12 22:12 ` [PATCH v1 0/9] drivers: hv: dxgkrnl: Driver overview Nathan Chancellor
2022-01-12 23:39 ` Iouri Tarassov
2022-01-26 0:27 ` Nathan Chancellor
2022-02-05 0:31 ` Iouri Tarassov
[not found] ` <1b26482b50832b95a9d8532c493cee6c97323b87.1641937419.git.iourit@linux.microsoft.com>
2022-01-13 1:49 ` [PATCH v1 1/9] drivers: hv: dxgkrnl: Driver initialization and creation of dxgadapter kernel test robot
2022-01-13 6:42 ` kernel test robot
2022-01-13 7:43 ` Greg KH
2022-01-13 7:46 ` Greg KH
2022-01-14 0:08 ` Iouri Tarassov
2022-01-14 5:40 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YeEM5asW5XtqD0Pi@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=iourit@linux.microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=spronovo@microsoft.com \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).