From owner-svn-src-head@FreeBSD.ORG Fri Oct 24 19:58:01 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 60C1984B; Fri, 24 Oct 2014 19:58:01 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 330AA658; Fri, 24 Oct 2014 19:58:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9OJw1qK014546; Fri, 24 Oct 2014 19:58:01 GMT (envelope-from rpaulo@FreeBSD.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9OJw1em014545; Fri, 24 Oct 2014 19:58:01 GMT (envelope-from rpaulo@FreeBSD.org) Message-Id: <201410241958.s9OJw1em014545@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rpaulo set sender to rpaulo@FreeBSD.org using -f From: Rui Paulo Date: Fri, 24 Oct 2014 19:58:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273602 - head/sys/dev/acpica X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Oct 2014 19:58:01 -0000 Author: rpaulo Date: Fri Oct 24 19:58:00 2014 New Revision: 273602 URL: https://svnweb.freebsd.org/changeset/base/273602 Log: HPET: avoid handling the multiple file-descriptor case. It had two bugs: one where mmap was still allowed and another where D_TRACKCLOSE doesn't handle all cases. Thanks to jhb and kib for pointing them out. MFC after: 1 week Modified: head/sys/dev/acpica/acpi_hpet.c Modified: head/sys/dev/acpica/acpi_hpet.c ============================================================================== --- head/sys/dev/acpica/acpi_hpet.c Fri Oct 24 19:55:49 2014 (r273601) +++ head/sys/dev/acpica/acpi_hpet.c Fri Oct 24 19:58:00 2014 (r273602) @@ -111,19 +111,15 @@ struct hpet_softc { struct cdev *pdev; int mmap_allow; int mmap_allow_write; - int devinuse; }; static d_open_t hpet_open; -static d_close_t hpet_close; static d_mmap_t hpet_mmap; static struct cdevsw hpet_cdevsw = { .d_version = D_VERSION, - .d_flags = D_TRACKCLOSE, .d_name = "hpet", .d_open = hpet_open, - .d_close = hpet_close, .d_mmap = hpet_mmap, }; @@ -344,24 +340,11 @@ hpet_open(struct cdev *cdev, int oflags, sc = cdev->si_drv1; if (!sc->mmap_allow) return (EPERM); - if (atomic_cmpset_32(&sc->devinuse, 0, 1) == 0) - return (EBUSY); else return (0); } static int -hpet_close(struct cdev *cdev, int fflag, int devtype, struct thread *td) -{ - struct hpet_softc *sc; - - sc = cdev->si_drv1; - sc->devinuse = 0; - - return (0); -} - -static int hpet_mmap(struct cdev *cdev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, vm_memattr_t *memattr) { @@ -378,7 +361,7 @@ hpet_mmap(struct cdev *cdev, vm_ooffset_ } /* Discover the HPET via the ACPI table of the same name. */ -static void +static void hpet_identify(driver_t *driver, device_t parent) { ACPI_TABLE_HPET *hpet; @@ -710,8 +693,8 @@ hpet_attach(device_t dev) #ifdef DEV_APIC if ((t->caps & HPET_TCAP_FSB_INT_DEL) && t->irq >= 0) { uint64_t addr; - uint32_t data; - + uint32_t data; + if (PCIB_MAP_MSI( device_get_parent(device_get_parent(dev)), dev, t->irq, &addr, &data) == 0) { @@ -825,8 +808,8 @@ hpet_resume(device_t dev) #ifdef DEV_APIC if (t->irq >= 0 && (sc->legacy_route == 0 || i >= 2)) { uint64_t addr; - uint32_t data; - + uint32_t data; + if (PCIB_MAP_MSI( device_get_parent(device_get_parent(dev)), dev, t->irq, &addr, &data) == 0) { @@ -897,7 +880,7 @@ hpet_remap_intr(device_t dev, device_t c struct hpet_softc *sc = device_get_softc(dev); struct hpet_timer *t; uint64_t addr; - uint32_t data; + uint32_t data; int error, i; for (i = 0; i < sc->num_timers; i++) {