* [PATCH v2] 8250_pci.c: Update NI specific devices class to multi serial
@ 2019-01-15 10:10 Guan Yung Tseng
2019-01-15 13:31 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Guan Yung Tseng @ 2019-01-15 10:10 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Guan Yung Tseng
Modified NI devices class to PCI_CLASS_COMMUNICATION_MULTISERIAL.
The reason of doing this is because all NI multi port serial cards
use PCI_CLASS_COMMUNICATION_OTHER class and thus fail the
serial_pci_is_class_communication test added in the commit 7d8905d06405
("serial: 8250_pci: Enable device after we check black list").
Signed-off-by: Guan Yung Tseng <guan.yung.tseng@ni.com>
---
Changes in v2:
- added comment to pci_ni_probe function
drivers/tty/serial/8250/8250_pci.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 4986b4a..1f91858 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -663,6 +663,18 @@ static int pci_xircom_init(struct pci_dev *dev)
return 0;
}
+/*
+ * NI Serial devices incorrectly identify themselves
+ * PCI_CLASS_COMMUNICATION_OTHER, instead of what
+ * they really are: PCI_CLASS_COMMUNICATION_MULTISERIAL
+ */
+static int pci_ni_probe(struct pci_dev *dev)
+{
+ dev->class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8 |
+ (dev->class & 0xff);
+ return 0;
+}
+
static int pci_ni8420_init(struct pci_dev *dev)
{
void __iomem *p;
@@ -1850,6 +1862,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PCI23216,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1859,6 +1872,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PCI2328,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1868,6 +1882,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PCI2324,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1877,6 +1892,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PCI2322,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1886,6 +1902,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PCI2324I,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1895,6 +1912,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PCI2322I,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1904,6 +1922,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PXI8420_23216,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1913,6 +1932,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PXI8420_2328,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1922,6 +1942,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PXI8420_2324,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1931,6 +1952,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PXI8420_2322,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1940,6 +1962,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PXI8422_2324,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1949,6 +1972,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_DEVICE_ID_NI_PXI8422_2322,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8420_init,
.setup = pci_default_setup,
.exit = pci_ni8420_exit,
@@ -1958,6 +1982,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
.device = PCI_ANY_ID,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
+ .probe = pci_ni_probe,
.init = pci_ni8430_init,
.setup = pci_ni8430_setup,
.exit = pci_ni8430_exit,
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] 8250_pci.c: Update NI specific devices class to multi serial
2019-01-15 10:10 [PATCH v2] 8250_pci.c: Update NI specific devices class to multi serial Guan Yung Tseng
@ 2019-01-15 13:31 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2019-01-15 13:31 UTC (permalink / raw)
To: Guan Yung Tseng; +Cc: gregkh, linux-serial, linux-kernel
On Tue, Jan 15, 2019 at 06:10:05PM +0800, Guan Yung Tseng wrote:
> +/*
> + * NI Serial devices incorrectly identify themselves
> + * PCI_CLASS_COMMUNICATION_OTHER, instead of what
> + * they really are: PCI_CLASS_COMMUNICATION_MULTISERIAL
> + */
> +static int pci_ni_probe(struct pci_dev *dev)
> +{
> + dev->class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8 |
> + (dev->class & 0xff);
> + return 0;
> +}
This looks odd. dev->class should just contain the class code read from
config space. I think you need to work around this in the places that
check the classcode instead and add a quirk for these devices.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] 8250_pci.c: Update NI specific devices class to multi serial
@ 2019-01-22 9:19 Guan Yung Tseng
0 siblings, 0 replies; 3+ messages in thread
From: Guan Yung Tseng @ 2019-01-22 9:19 UTC (permalink / raw)
To: gregkh, hch; +Cc: linux-serial, linux-kernel, Guan Yung Tseng
On, Jan 14, 2019 at 10:10:05PM +0800, Guan Yung Tseng wrote:
>> Modified NI devices class to PCI_CLASS_COMMUNICATION_MULTISERIAL.
>> The reason of doing this is because all NI multi port serial cards
>> use PCI_CLASS_COMMUNICATION_OTHER class and thus fail the
>> serial_pci_is_class_communication test added in the commit 7d8905d06405
>> ("serial: 8250_pci: Enable device after we check black list").
>>
>> Signed-off-by: Guan Yung Tseng <guan.yung.tseng@ni.com>
>> ---
>> drivers/tty/serial/8250/8250_pci.c | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>>
>> diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
>> index 4986b4a..0949db1 100644
>> --- a/drivers/tty/serial/8250/8250_pci.c
>> +++ b/drivers/tty/serial/8250/8250_pci.c
>> @@ -663,6 +663,13 @@ static int pci_xircom_init(struct pci_dev *dev)
>> return 0;
>> }
>>
>> +static int pci_ni_probe(struct pci_dev *dev)
>> +{
>> + dev->class = PCI_CLASS_COMMUNICATION_MULTISERIAL << 8 |
>> + (dev->class & 0xff);
>
> As Christoph said, this looks really odd. This field comes from the
> PCI structure on the device, it should not be modified by the kernel.
>
> Unless the device is broken and needs to be fixed up in the kernel?
>
> Also, you have sent 2 different patches here for this type of issue, are
> both needed? If so, please resend both of them as a patch series, with
> more explainations in this one as to why you are modifying this field.
>
> I've dropped all pending patches from you from my queue now.
>
Hi Christoph and Greg,
Sorry for the confusion sending 2 different patches to solve the same
issue. I should have wait for your response before sending antoher
patch to solve the similar issue.
For some historical reason, NI serial devices use
PCI_CLASS_COMMUNICATION_OTHER class code. Yes, I understand that
the class code should read from config space instead modified from
kernel. But these devices are shipped to the market for many years.
That's why I am trying to fix the problem in the kernel.
I will send another simple patch again to fix the problem.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-22 9:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-15 10:10 [PATCH v2] 8250_pci.c: Update NI specific devices class to multi serial Guan Yung Tseng
2019-01-15 13:31 ` Christoph Hellwig
2019-01-22 9:19 Guan Yung Tseng
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).