Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3594585pxb; Sun, 26 Sep 2021 20:48:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkTVVxoG0N1LMhChaPPBGUmOIk6t4mU5jssO+yIajgDWViezy2rpGe95+5Jpv3CFepeb4P X-Received: by 2002:a17:90a:a389:: with SMTP id x9mr17056736pjp.167.1632714525971; Sun, 26 Sep 2021 20:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632714525; cv=none; d=google.com; s=arc-20160816; b=Xm3FtOOZwY2SAMY1L2LOVssCTPjEAY3EJm+JRO8EOfI8MPUFG17aM4P7W50x6z1/ML X3BurE2PRP1fx0CRmDWySGjFIXr6DyeV5Enhb03/eOI2kTGYuMwTrSBZljxUlaGCTOv0 mwdq1Ew1jfdgQauykA02ji/mbid9xPW3gQjT+kr9vDFesqrDBb4cbiKBdozjmnNJ5q9o XVAINL9t9vXhaNVADK3eiDxzKKSc3Pk4zItsxJ0VXZC+763dvnmfvL4eDi/zCCgcix7a 3YB9V3hiOwWU9H+KI02hsOK/Yy4Y08PcIGBV7n7Zkyqqtpn53BYM9u12hLD0uQuArW/Z IQDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=bktuO6P0thYO3QbazFm9mZW5cofXlZySWPbwKIKA3GQ=; b=tfDgvxjujJjcOtQqXThS1VcpR5L+8hKpmjlaK6izdyF964vN4mUSkkl3+1UkSU02r2 tauct60HcWn8j+dsz4rEZW5Vcl5qz1uxKqOZHLLioCJAcX2alwXLxAxmHfaZ4/Jruimn XdtPJ5c8h0eUGbozxDl8XEh9nce8Eg58uQ5umjgBdX+WxZ9PuPcU6Up/yQajF/DMLqju AzcAkRDU3FgNebSDXWNBmGGQNGQdE5jNXl8ZUivInsgHb6cds9W1lI5FtSpbCza2bzpV 1jM8Wis9bXOLM+R74uwCM9E4wCASW8IV6uEK9Pc4akffNZp1TQDZ1BfzB546o35AEbu8 PPgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x64si18367645pgd.638.2021.09.26.20.48.12; Sun, 26 Sep 2021 20:48:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232531AbhI0Drw (ORCPT + 99 others); Sun, 26 Sep 2021 23:47:52 -0400 Received: from mailgw.kylinos.cn ([123.150.8.42]:9428 "EHLO nksmu.kylinos.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232488AbhI0Dru (ORCPT ); Sun, 26 Sep 2021 23:47:50 -0400 X-UUID: a013bda241304fef8d0013d2f5512c96-20210927 X-CPASD-INFO: d1e693d2028646ec93ce80f3e3a234c2@rYGfVmZlkmJcUnqCg3mwnVlkk5VoXIa Cp22BYmFkj1KVhH5xTWJsXVKBfG5QZWNdYVN_eGpQYl9gZFB5i3-XblBgXoZgUZB3s3OfVmlhlA== X-CPASD-FEATURE: 0.0 X-CLOUD-ID: d1e693d2028646ec93ce80f3e3a234c2 X-CPASD-SUMMARY: SIP:-1,APTIP:-2.0,KEY:0.0,FROMBLOCK:1,EXT:0.0,OB:0.0,URL:-5,T VAL:168.0,ESV:0.0,ECOM:-5.0,ML:0.0,FD:0.0,CUTS:266.0,IP:-2.0,MAL:0.0,ATTNUM:0 .0,PHF:-5.0,PHC:-5.0,SPF:4.0,EDMS:-3,IPLABEL:4480.0,FROMTO:0,AD:0,FFOB:0.0,CF OB:0.0,SPC:0.0,SIG:-5,AUF:5,DUF:14810,ACD:54,DCD:156,SL:0,AG:0,CFC:0.861,CFSR :0.022,UAT:0,RAF:2,VERSION:2.3.4 X-CPASD-ID: a013bda241304fef8d0013d2f5512c96-20210927 X-CPASD-BLOCK: 1000 X-CPASD-STAGE: 1, 1 X-UUID: a013bda241304fef8d0013d2f5512c96-20210927 X-User: lizhenneng@kylinos.cn Received: from [172.20.108.41] [(116.128.244.169)] by nksmu.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 128/128) with ESMTP id 1100316321; Mon, 27 Sep 2021 11:43:22 +0800 Subject: Re: [PATCH] PCI/sysfs: add write attribute for boot_vga To: Bjorn Helgaas Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210926202027.GA588220@bhelgaas> From: =?UTF-8?B?5p2O55yf6IO9?= Message-ID: <70a472b8-7a3e-1792-efe4-125584231824@kylinos.cn> Date: Mon, 27 Sep 2021 11:45:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210926202027.GA588220@bhelgaas> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 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 >> --- >> 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