From nobody Thu Nov 25 16:37:15 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1725718B3BFB; Thu, 25 Nov 2021 16:37:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J0Nnl51Hyz4ql0; Thu, 25 Nov 2021 16:37:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 87B6E20773; Thu, 25 Nov 2021 16:37:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1APGbFJ1054935; Thu, 25 Nov 2021 16:37:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1APGbFnY054934; Thu, 25 Nov 2021 16:37:15 GMT (envelope-from git) Date: Thu, 25 Nov 2021 16:37:15 GMT Message-Id: <202111251637.1APGbFnY054934@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 437ea82ce7fc - main - agp: Handle multiple devices more gracefully List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 437ea82ce7fc3e664447b9e7d08f5c135a7e2f31 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637858235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ok/y0LKAQ5/iNH9DuEgKIlEkEIV6YifwwgX0UkHhzwE=; b=pLIklKB7SZvmeoH81ED8l+k9tIZ4EZhO4KMxWjWcdo/piaso6dCSbDcQacYrKEt9oi3T9+ qO9BHptcvNHhiElzBL12IvFZtoMkduGBaJbgeokN3ACj6BJXawpP9JoeyIGIboxhdpi+H+ p1P+6BAUFKEYdIhZEHEXeasM5HcvIg1RFe2HHgyarBt2EtmbbNPg6khHTqQDq9CNP4K9lg Zs/r/GTFuWddHPomxRSEFnWRYH1kFlMNZpo3ibUjiQ3/h9ikPknWu6g427AbRpa87sgklX nNaiTeyMumqLW1jjvM3XJiu3n7W/CoaSHbavIDQUOf5jporb/hWTyuLbMzsgcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637858235; a=rsa-sha256; cv=none; b=O86sihKDfliAYDKdyw0VKKndFp28gBKFk640z4iSzHlgSS+hRgi7pABbU2Ixi23XYsEIQE AU4bh/AJ4D0PWYZEozlK1RJNKp/F1h9TUmrjelXxiVxj9g5E4u2P8CNXoTj4pknvm0nv7B npHNUihBeq8seRHR0pkPs3XOqDBzi2ki0WOKA8nG97RCl9pguM5heFKfWyxuBYT6s2KvTT JqBEC7v12+HyR1wjR5LkGUP3K69D9h+ZhmqTfk+ROu2jotr1vMG97Wup+syCYS270Xy0Lb OPicxTpJvfeqGTFkB9eH7VzQnSt7FjCnp0VpAfzmYaTZK1Az3J/t9AWXP/x3fA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=437ea82ce7fc3e664447b9e7d08f5c135a7e2f31 commit 437ea82ce7fc3e664447b9e7d08f5c135a7e2f31 Author: Mark Johnston AuthorDate: 2021-11-25 16:27:49 +0000 Commit: Mark Johnston CommitDate: 2021-11-25 16:36:33 +0000 agp: Handle multiple devices more gracefully Currently agp(4) effectively assumes that only one driver instance exists, as the generic attach routine attempts to create /dev/agpgart and triggers a panic if it already exists. Instead, handle this situation by creating /dev/agpgart and making /dev/agpgart an alias of /dev/agpgart0 for compatibility. PR: 187015 Reviewed by: imp, kib Tested by: Yoshihiro Ota (earlier version) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33068 --- sys/dev/agp/agp.c | 33 ++++++++++++++++++++++++++++----- sys/dev/agp/agppriv.h | 1 + 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c index aaae2176f85a..39e9d5dd64e7 100644 --- a/sys/dev/agp/agp.c +++ b/sys/dev/agp/agp.c @@ -205,8 +205,9 @@ agp_set_aperture_resource(device_t dev, int rid) int agp_generic_attach(device_t dev) { + struct make_dev_args mdargs; struct agp_softc *sc = device_get_softc(dev); - int i; + int error, i, unit; u_int memsize; /* @@ -250,11 +251,31 @@ agp_generic_attach(device_t dev) TAILQ_INIT(&sc->as_memory); sc->as_nextid = 1; - sc->as_devnode = make_dev(&agp_cdevsw, - 0, UID_ROOT, GID_WHEEL, 0600, "agpgart"); - sc->as_devnode->si_drv1 = dev; + sc->as_devalias = NULL; - return 0; + make_dev_args_init(&mdargs); + mdargs.mda_devsw = &agp_cdevsw; + mdargs.mda_uid = UID_ROOT; + mdargs.mda_gid = GID_WHEEL; + mdargs.mda_mode = 0600; + mdargs.mda_si_drv1 = sc; + mdargs.mda_si_drv2 = NULL; + + unit = device_get_unit(dev); + error = make_dev_s(&mdargs, &sc->as_devnode, "agpgart%d", unit); + if (error == 0) { + /* + * Create an alias for the first device that shows up. + */ + if (unit == 0) { + (void)make_dev_alias_p(MAKEDEV_CHECKNAME, + &sc->as_devalias, sc->as_devnode, "agpgart"); + } + } else { + agp_free_res(dev); + } + + return error; } void @@ -263,6 +284,8 @@ agp_free_cdev(device_t dev) struct agp_softc *sc = device_get_softc(dev); destroy_dev(sc->as_devnode); + if (sc->as_devalias != NULL) + destroy_dev(sc->as_devalias); } void diff --git a/sys/dev/agp/agppriv.h b/sys/dev/agp/agppriv.h index f6fa3c5526bd..525f4bced245 100644 --- a/sys/dev/agp/agppriv.h +++ b/sys/dev/agp/agppriv.h @@ -76,6 +76,7 @@ struct agp_softc { int as_nextid; /* next memory block id */ int as_isopen; /* user device is open */ struct cdev *as_devnode; /* from make_dev */ + struct cdev *as_devalias; struct mtx as_lock; /* lock for access to GATT */ };