From owner-freebsd-usb@freebsd.org Thu Aug 8 08:48:29 2019 Return-Path: Delivered-To: freebsd-usb@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FA67C80ED for ; Thu, 8 Aug 2019 08:48:29 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46428X0bMzz42jm for ; Thu, 8 Aug 2019 08:48:27 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [62.141.129.235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 991C3260282; Thu, 8 Aug 2019 10:48:19 +0200 (CEST) Subject: Re: Problem attaching USB Garmin device To: Mariappan N , "freebsd-usb@freebsd.org" References: <4aaaaadf-cf6b-8dc6-62a8-d4a577d19691@selasky.org> <2f317631-7e92-6fcc-7061-ae098ce99a68@selasky.org> <59b187eb-6b64-f051-a2a5-2807668e6890@selasky.org> <65a1fe1b-cf8d-c981-f915-a3252c50c2b5@selasky.org> From: Hans Petter Selasky Message-ID: <99e96292-a7e3-f40d-5dc7-79a024b26e50@selasky.org> Date: Thu, 8 Aug 2019 10:47:39 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------13EB458A8902A3DC0D32082E" Content-Language: en-US X-Rspamd-Queue-Id: 46428X0bMzz42jm X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 88.99.82.50 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-6.46 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net:c]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; HAS_ATTACHMENT(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; DMARC_NA(0.00)[selasky.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; IP_SCORE(-3.19)[ip: (-9.36), ipnet: 88.99.0.0/16(-4.74), asn: 24940(-1.82), country: DE(-0.01)]; FREEMAIL_TO(0.00)[outlook.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:24940, ipnet:88.99.0.0/16, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 08:48:29 -0000 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--