From owner-svn-src-all@freebsd.org Tue Mar 20 22:01:19 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 652F9F4E6D2; Tue, 20 Mar 2018 22:01:19 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 142286A49F; Tue, 20 Mar 2018 22:01:19 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0F2FB226C1; Tue, 20 Mar 2018 22:01:19 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2KM1Io9085332; Tue, 20 Mar 2018 22:01:18 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2KM1Isd085328; Tue, 20 Mar 2018 22:01:18 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201803202201.w2KM1Isd085328@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 20 Mar 2018 22:01:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331271 - in head/sys/dev: cardbus pccard pccbb X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: in head/sys/dev: cardbus pccard pccbb X-SVN-Commit-Revision: 331271 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 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: Tue, 20 Mar 2018 22:01:19 -0000 Author: imp Date: Tue Mar 20 22:01:18 2018 New Revision: 331271 URL: https://svnweb.freebsd.org/changeset/base/331271 Log: Push down Giant one layer. In the days of yore, back when Penitums were the new kids on the block and F00F hacks were all the rage, one needed to take out Giant to do anything moderately complicated with the VM, mappings and such. So the pccard / cardbus code held Giant for the entire insertion or removal process. Today, the VM is MP safe. The lock is only needed for dealing with newbus things. Move locking and unlocking Giant to be only around adding and probing devices in pccard and cardbus. Modified: head/sys/dev/cardbus/cardbus.c head/sys/dev/pccard/pccard.c head/sys/dev/pccbb/pccbb.c Modified: head/sys/dev/cardbus/cardbus.c ============================================================================== --- head/sys/dev/cardbus/cardbus.c Tue Mar 20 22:00:58 2018 (r331270) +++ head/sys/dev/cardbus/cardbus.c Tue Mar 20 22:01:18 2018 (r331271) @@ -197,6 +197,7 @@ cardbus_attach_card(device_t cbdev) domain = pcib_get_domain(cbdev); bus = pcib_get_bus(cbdev); slot = 0; + mtx_lock(&Giant); /* For each function, set it up and try to attach a driver to it */ for (func = 0; func <= cardbusfunchigh; func++) { struct cardbus_devinfo *dinfo; @@ -230,6 +231,7 @@ cardbus_attach_card(device_t cbdev) else pci_cfg_save(dinfo->pci.cfg.dev, &dinfo->pci, 1); } + mtx_unlock(&Giant); if (cardattached > 0) return (0); /* POWER_DISABLE_SOCKET(brdev, cbdev); */ Modified: head/sys/dev/pccard/pccard.c ============================================================================== --- head/sys/dev/pccard/pccard.c Tue Mar 20 22:00:58 2018 (r331270) +++ head/sys/dev/pccard/pccard.c Tue Mar 20 22:01:18 2018 (r331271) @@ -236,6 +236,7 @@ pccard_attach_card(device_t dev) DEVPRINTF((dev, "Card has %d functions. pccard_mfc is %d\n", i + 1, pccard_mfc(sc))); + mtx_lock(&Giant); STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { if (STAILQ_EMPTY(&pf->cfe_head)) continue; @@ -248,6 +249,7 @@ pccard_attach_card(device_t dev) pf->dev = child; pccard_probe_and_attach_child(dev, child, pf); } + mtx_unlock(&Giant); return (0); } Modified: head/sys/dev/pccbb/pccbb.c ============================================================================== --- head/sys/dev/pccbb/pccbb.c Tue Mar 20 22:00:58 2018 (r331270) +++ head/sys/dev/pccbb/pccbb.c Tue Mar 20 22:01:18 2018 (r331271) @@ -470,14 +470,6 @@ cbb_event_thread(void *arg) sc->flags |= CBB_KTHREAD_RUNNING; while ((sc->flags & CBB_KTHREAD_DONE) == 0) { mtx_unlock(&sc->mtx); - /* - * We take out Giant here because we need it deep, - * down in the bowels of the vm system for mapping the - * memory we need to read the CIS. In addition, since - * we are adding/deleting devices from the dev tree, - * and that code isn't MP safe, we have to hold Giant. - */ - mtx_lock(&Giant); status = cbb_get(sc, CBB_SOCKET_STATE); DPRINTF(("Status is 0x%x\n", status)); if (!CBB_CARD_PRESENT(status)) { @@ -503,7 +495,6 @@ cbb_event_thread(void *arg) not_a_card = 0; /* We know card type */ cbb_insert(sc); } - mtx_unlock(&Giant); /* * First time through we need to tell mountroot that we're