From owner-svn-src-all@freebsd.org Wed Aug 14 19:00:55 2019 Return-Path: Delivered-To: svn-src-all@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 0B0A5B709C; Wed, 14 Aug 2019 19:00:55 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 467zSQ4HkZz3Jcf; Wed, 14 Aug 2019 19:00:54 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id xyVshsWkMIhW9xyVuhpd0Z; Wed, 14 Aug 2019 13:00:51 -0600 X-Authority-Analysis: v=2.3 cv=FcFJO626 c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=FmdZ9Uzk2mMA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=qSNgbIn8TdgJ77-XzEkA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy8 [10.2.2.6]) by spqr.komquats.com (Postfix) with ESMTPS id 74B41A8C; Wed, 14 Aug 2019 12:00:46 -0700 (PDT) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id x7EJ0RiI058094; Wed, 14 Aug 2019 12:00:27 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id x7EJ0RxC058082; Wed, 14 Aug 2019 12:00:27 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201908141900.x7EJ0RxC058082@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Hans Petter Selasky cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r351009 - head/sys/compat/linuxkpi/common/include/linux In-reply-to: <201908140936.x7E9aQAc069612@repo.freebsd.org> References: <201908140936.x7E9aQAc069612@repo.freebsd.org> Comments: In-reply-to Hans Petter Selasky message dated "Wed, 14 Aug 2019 09:36:26 -0000." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 14 Aug 2019 12:00:27 -0700 X-CMAE-Envelope: MS4wfC3H+mnL/16vjHpJ+0OaL/u+h6spEiEC0l296TslFqlY4OqAKOmhAgg7ahaz+vE6km2jh0O6i8s6E7rpuUpSUgWTbkASoeYgWmWPcQd8F04ILlhU+rGC EVHeRss8yMVHtR1kouYRxIPqJbjTGb7hheJd4CW5BpVYuep9+MfqwssMdCsU3e2TzW1CLK29LFQvux6R6oAr7AYyNVEijn5JrjedXefXAnUSuhYbSYIhj7wU XHG+fGo1z6zHpsD5V713441M4agrm1dX/dbc1Y5TmUgUSydL2CLzgTpDpC/q+uvU X-Rspamd-Queue-Id: 467zSQ4HkZz3Jcf X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.95 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.95)[-0.947,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Aug 2019 19:00:55 -0000 In message <201908140936.x7E9aQAc069612@repo.freebsd.org>, Hans Petter Selasky writes: > Author: hselasky > Date: Wed Aug 14 09:36:25 2019 > New Revision: 351009 > URL: https://svnweb.freebsd.org/changeset/base/351009 > > Log: > Implement pci_enable_msi() and pci_disable_msi() in the LinuxKPI. > This patch makes the DRM graphics driver in ports usable on aarch64. > > Submitted by: Greg V > Differential Revision: https://reviews.freebsd.org/D21008 > MFC after: 1 week > Sponsored by: Mellanox Technologies > > Modified: > head/sys/compat/linuxkpi/common/include/linux/device.h > head/sys/compat/linuxkpi/common/include/linux/interrupt.h > head/sys/compat/linuxkpi/common/include/linux/pci.h > > Modified: head/sys/compat/linuxkpi/common/include/linux/device.h > ============================================================================= > = > --- head/sys/compat/linuxkpi/common/include/linux/device.h Wed Aug 14 06:4 > 1:22 2019 (r351008) > +++ head/sys/compat/linuxkpi/common/include/linux/device.h Wed Aug 14 09:3 > 6:25 2019 (r351009) > @@ -110,8 +110,8 @@ struct device { > 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; > > > Modified: head/sys/compat/linuxkpi/common/include/linux/interrupt.h > ============================================================================= > = > --- head/sys/compat/linuxkpi/common/include/linux/interrupt.h Wed Aug 14 06:4 > 1:22 2019 (r351008) > +++ head/sys/compat/linuxkpi/common/include/linux/interrupt.h Wed Aug 14 09:3 > 6:25 2019 (r351009) > @@ -55,9 +55,11 @@ struct irq_ent { > 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 *); > > Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h > ============================================================================= > = > --- head/sys/compat/linuxkpi/common/include/linux/pci.h Wed Aug 14 06:4 > 1:22 2019 (r351008) > +++ head/sys/compat/linuxkpi/common/include/linux/pci.h Wed Aug 14 09:3 > 6:25 2019 (r351009) > @@ -228,6 +228,7 @@ struct pci_dev { > unsigned int devfn; > uint32_t class; > uint8_t revision; > + bool msi_enabled; > }; > > static inline struct resource_list_entry * > @@ -262,7 +263,7 @@ linux_pci_find_irq_dev(unsigned int irq) > 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 @@ pci_disable_msix(struct pci_dev *pdev) > * 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 @@ pci_enable_msix(struct pci_dev *pdev, struct msix_entr > 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); > } > > @@ -593,6 +609,32 @@ pci_enable_msix_range(struct pci_dev *dev, struct msix > } > } while (rc); > 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 > John's patch to drm-current-kmod (ports r508877) works! This broke drm-current-kmod. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.