From: 李真能 <lizhenneng@kylinos.cn>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI/sysfs: add write attribute for boot_vga
Date: Mon, 27 Sep 2021 11:45:59 +0800 [thread overview]
Message-ID: <70a472b8-7a3e-1792-efe4-125584231824@kylinos.cn> (raw)
In-Reply-To: <20210926202027.GA588220@bhelgaas>
在 2021/9/27 上午4:20, Bjorn Helgaas 写道:
> On Sun, Sep 26, 2021 at 03:15:39PM +0800, Zhenneng Li wrote:
>> Add writing attribute for boot_vga sys node,
>> so we can config default video display
>> output dynamically when there are two video
>> cards on a machine.
>>
>> Xorg server will determine running on which
>> video card based on boot_vga node's value.
> When you repost this, please take a look at the git commit log history
> and make yours similar. Specifically, the subject should start with a
> capital letter, and the body should be rewrapped to fill 75
> characters.
>
> Please contrast this with the existing VGA arbiter. See
> Documentation/gpu/vgaarbiter.rst. It sounds like this may overlap
> with the VGA arbiter functionality, so this should explain why we need
> both and how they interact.
"Some "legacy" VGA devices implemented on PCI typically have the same
hard-decoded addresses as they did on ISA. When multiple PCI devices are
accessed at same time they need some kind of coordination. ", this is
the explain of config VGA_ARB, that is to say, some legacy vga devices
need use the same pci bus address, if user app(such as xorg) want access
card A, but card A and card B have same bus address, then VGA
agaarbiter will determine will card to be accessed.
And xorg will read boot_vga to determine which graphics card is the
primary graphics output device.
That is the difference about boot_vga and vgaarbiter.
>
>> Signed-off-by: Zhenneng Li <lizhenneng@kylinos.cn>
>> ---
>> drivers/pci/pci-sysfs.c | 24 +++++++++++++++++++++++-
>> 1 file changed, 23 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
>> index 7bbf2673c7f2..a6ba19ce7adb 100644
>> --- a/drivers/pci/pci-sysfs.c
>> +++ b/drivers/pci/pci-sysfs.c
>> @@ -664,7 +664,29 @@ static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr,
>> !!(pdev->resource[PCI_ROM_RESOURCE].flags &
>> IORESOURCE_ROM_SHADOW));
>> }
>> -static DEVICE_ATTR_RO(boot_vga);
>> +
>> +static ssize_t boot_vga_store(struct device *dev, struct device_attribute *attr,
>> + const char *buf, size_t count)
>> +{
>> + unsigned long val;
>> + struct pci_dev *pdev = to_pci_dev(dev);
>> + struct pci_dev *vga_dev = vga_default_device();
>> +
>> + if (kstrtoul(buf, 0, &val) < 0)
>> + return -EINVAL;
>> +
>> + if (val != 1)
>> + return -EINVAL;
>> +
>> + if (!capable(CAP_SYS_ADMIN))
>> + return -EPERM;
>> +
>> + if (pdev != vga_dev)
>> + vga_set_default_device(pdev);
>> +
>> + return count;
>> +}
>> +static DEVICE_ATTR_RW(boot_vga);
>>
>> static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
>> struct bin_attribute *bin_attr, char *buf,
>> --
>> 2.25.1
>>
>>
>> No virus found
>> Checked by Hillstone Network AntiVirus
next prev parent reply other threads:[~2021-09-27 3:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-26 7:15 [PATCH] PCI/sysfs: add write attribute for boot_vga Zhenneng Li
2021-09-26 20:00 ` Krzysztof Wilczyński
2021-09-27 3:06 ` 李真能
2021-09-26 20:20 ` Bjorn Helgaas
2021-09-27 3:45 ` 李真能 [this message]
2021-09-27 3:57 ` Kai-Heng Feng
2021-09-28 23:37 ` Bjorn Helgaas
2021-09-29 1:45 ` 李真能
-- strict thread matches above, loose matches on Subject: below --
2021-08-31 7:55 Zhenneng Li
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=70a472b8-7a3e-1792-efe4-125584231824@kylinos.cn \
--to=lizhenneng@kylinos.cn \
--cc=bhelgaas@google.com \
--cc=helgaas@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.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).