Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Aug 2019 10:47:39 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Mariappan N <nmarijoe@outlook.com>, "freebsd-usb@freebsd.org" <freebsd-usb@freebsd.org>
Subject:   Re: Problem attaching USB Garmin device
Message-ID:  <99e96292-a7e3-f40d-5dc7-79a024b26e50@selasky.org>
In-Reply-To: <MAXPR01MB294488EED39ECC519B668A71C5D70@MAXPR01MB2944.INDPRD01.PROD.OUTLOOK.COM>
References:  <MAXPR01MB2944036F77333AE51E8EE717C5C10@MAXPR01MB2944.INDPRD01.PROD.OUTLOOK.COM> <a0b1c069-0716-3405-0ad2-a09c6cc62c07@selasky.org> <4aaaaadf-cf6b-8dc6-62a8-d4a577d19691@selasky.org> <MAXPR01MB2944063272F35B324622BDF9C5C00@MAXPR01MB2944.INDPRD01.PROD.OUTLOOK.COM> <c19c35e1-e1c0-4ea7-d076-8e9eb5a02e3d@selasky.org> <dc939281-1716-b839-2726-b69aea39ebf4@selasky.org> <MAXPR01MB2944169058EDDE7A7F55BB4AC5C20@MAXPR01MB2944.INDPRD01.PROD.OUTLOOK.COM> <MAXPR01MB2944810CD093ED926AC0FBE7C5DD0@MAXPR01MB2944.INDPRD01.PROD.OUTLOOK.COM> <2f317631-7e92-6fcc-7061-ae098ce99a68@selasky.org> <d1fb157c-9efc-b4a8-c177-c61803680ccb@selasky.org> <MAXPR01MB294464445E98B6CFDAEEDB6FC5DC0@MAXPR01MB2944.INDPRD01.PROD.OUTLOOK.COM> <59b187eb-6b64-f051-a2a5-2807668e6890@selasky.org> <MAXPR01MB2944F0DC73A68AB981ED687EC5DF0@MAXPR01MB2944.INDPRD01.PROD.OUTLOOK.COM> <65a1fe1b-cf8d-c981-f915-a3252c50c2b5@selasky.org> <MAXPR01MB294488EED39ECC519B668A71C5D70@MAXPR01MB2944.INDPRD01.PROD.OUTLOOK.COM>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------13EB458A8902A3DC0D32082E
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

Can you revert previous patch and apply new patch and re-try the capture 
of dmesg and wire?

--HPS

--------------13EB458A8902A3DC0D32082E
Content-Type: text/x-patch;
 name="xhci4.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="xhci4.diff"

Index: sys/compat/linuxkpi/common/include/linux/device.h
===================================================================
--- sys/compat/linuxkpi/common/include/linux/device.h	(revision 350625)
+++ sys/compat/linuxkpi/common/include/linux/device.h	(working copy)
@@ -110,8 +110,8 @@
 	void		*driver_data;
 	unsigned int	irq;
 #define	LINUX_IRQ_INVALID	65535
-	unsigned int	msix;
-	unsigned int	msix_max;
+	unsigned int	irq_start;
+	unsigned int	irq_end;
 	const struct attribute_group **groups;
 	struct fwnode_handle *fwnode;
 
Index: sys/compat/linuxkpi/common/include/linux/interrupt.h
===================================================================
--- sys/compat/linuxkpi/common/include/linux/interrupt.h	(revision 350625)
+++ sys/compat/linuxkpi/common/include/linux/interrupt.h	(working copy)
@@ -55,9 +55,11 @@
 static inline int
 linux_irq_rid(struct device *dev, unsigned int irq)
 {
-	if (irq == dev->irq)
+	/* check for MSI- or MSIX- interrupt */
+	if (irq >= dev->irq_start && irq < dev->irq_end)
+		return (irq - dev->irq_start + 1);
+	else
 		return (0);
-	return irq - dev->msix + 1;
 }
 
 extern void linux_irq_handler(void *);
Index: sys/compat/linuxkpi/common/include/linux/pci.h
===================================================================
--- sys/compat/linuxkpi/common/include/linux/pci.h	(revision 350625)
+++ sys/compat/linuxkpi/common/include/linux/pci.h	(working copy)
@@ -228,6 +228,7 @@
 	unsigned int		devfn;
 	uint32_t		class;
 	uint8_t			revision;
+	bool			msi_enabled;
 };
 
 static inline struct resource_list_entry *
@@ -262,7 +263,7 @@
 	spin_lock(&pci_lock);
 	list_for_each_entry(pdev, &pci_devices, links) {
 		if (irq == pdev->dev.irq ||
-		    (irq >= pdev->dev.msix && irq < pdev->dev.msix_max)) {
+		    (irq >= pdev->dev.irq_start && irq < pdev->dev.irq_end)) {
 			found = &pdev->dev;
 			break;
 		}
@@ -424,10 +425,25 @@
 	 * linux_pci_find_irq_dev() does no longer see them by
 	 * resetting their references to zero:
 	 */
-	pdev->dev.msix = 0;
-	pdev->dev.msix_max = 0;
+	pdev->dev.irq_start = 0;
+	pdev->dev.irq_end = 0;
 }
 
+#define	pci_disable_msi(pdev) \
+  linux_pci_disable_msi(pdev)
+
+static inline void
+linux_pci_disable_msi(struct pci_dev *pdev)
+{
+
+	pci_release_msi(pdev->dev.bsddev);
+
+	pdev->dev.irq_start = 0;
+	pdev->dev.irq_end = 0;
+	pdev->irq = pdev->dev.irq;
+	pdev->msi_enabled = false;
+}
+
 unsigned long	pci_resource_start(struct pci_dev *pdev, int bar);
 unsigned long	pci_resource_len(struct pci_dev *pdev, int bar);
 
@@ -562,10 +578,10 @@
 		return avail;
 	}
 	rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1);
-	pdev->dev.msix = rle->start;
-	pdev->dev.msix_max = rle->start + avail;
+	pdev->dev.irq_start = rle->start;
+	pdev->dev.irq_end = rle->start + avail;
 	for (i = 0; i < nreq; i++)
-		entries[i].vector = pdev->dev.msix + i;
+		entries[i].vector = pdev->dev.irq_start + i;
 	return (0);
 }
 
@@ -595,7 +611,33 @@
 	return (nvec);
 }
 
+#define	pci_enable_msi(pdev) \
+  linux_pci_enable_msi(pdev)
+
 static inline int
+pci_enable_msi(struct pci_dev *pdev)
+{
+	struct resource_list_entry *rle;
+	int error;
+	int avail;
+
+	avail = pci_msi_count(pdev->dev.bsddev);
+	if (avail < 1)
+		return -EINVAL;
+
+	avail = 1;	/* this function only enable one MSI IRQ */
+	if ((error = -pci_alloc_msi(pdev->dev.bsddev, &avail)) != 0)
+		return error;
+
+	rle = linux_pci_get_rle(pdev, SYS_RES_IRQ, 1);
+	pdev->dev.irq_start = rle->start;
+	pdev->dev.irq_end = rle->start + avail;
+	pdev->irq = rle->start;
+	pdev->msi_enabled = true;
+	return (0);
+}
+
+static inline int
 pci_channel_offline(struct pci_dev *pdev)
 {
 
Index: sys/dev/usb/controller/xhci.c
===================================================================
--- sys/dev/usb/controller/xhci.c	(revision 350625)
+++ sys/dev/usb/controller/xhci.c	(working copy)
@@ -1454,6 +1454,12 @@
 		/* execute set address command */
 		usbd_get_page(&hdev->input_pc, 0, &buf_inp);
 
+		/* wait 20ms */
+		if (address != 0) {
+			printf("WAITING A BIT\n");
+			usb_pause_mtx(NULL, hz / 50);
+		}
+
 		err = xhci_cmd_set_address(sc, buf_inp.physaddr,
 		    (address == 0), index);
 

--------------13EB458A8902A3DC0D32082E--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?99e96292-a7e3-f40d-5dc7-79a024b26e50>