From nobody Sat May 4 14:44:25 2024 X-Original-To: dev-commits-src-all@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 4VWr6K2NCJz5Kghn; Sat, 4 May 2024 14:44:25 +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 4VWr6K1gZLz4R2L; Sat, 4 May 2024 14:44:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714833865; 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=VFNXtxZbG30kMQG1GdWNiGfy6cXuFkp7a/YnWV6tzyU=; b=opo9I3hKPqebMrL4yKTlbSSWlm6Qj9EFxxDVIM+nGCgMV7znuW+bZO5n5aIImlaf/92V7n yCHAdOLNV4UhbmbEt6ZB6ruPbzXJOA4L49apRUMMto6bGVRusJbz0E0AP02fXX+NF39dj/ ioJqFg1y4bjS72LG4tNWE4d/GwhZdwqbG7xyUyw1wdxy38vrAbn/1DaQTYGuQRujFtGxKI UsiZpAB8RD/N0uQivScTh+Ad71REtTxjjPqoxVx5MELhQrbZnfV/J6DI0aBFLZ8DVepprF e8wIFUgvFjXnHs0VEnA4OCVM4jp/zeDENydvzxhM0XnMUxOAyoqwQXLqWtlbOA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714833865; a=rsa-sha256; cv=none; b=b9d5KcKleeSL7/8lSv2RpyoaDSXrrVTCpA963eqNK9dyuxqkvUWHg37sGKWRLqbHNxAiKS sIaUSau44Gtk4G47cj1p4syvK9EE12/OcNrDs2lr6ZlR/VkRB4iA9duRYeGeOSC9LNfJun wa0FzApJhlWiafp05GmuA94iUnNXEu75AqzyI1OQ5qCo1Qdwv/RURZ+R5PhKsvz8t7NMQW 7DLaXpygJDkQFJeHi2eMEcrDY1UD6+oGJYY1nhJ/juIgoZI+m/i+aEAHG4ntczppnjIV/a inIBeyzYCh08nHnmlqtZ811jxk0dUmPji171rw5cqFrQaf+d5ptzT5qlC+/8gA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714833865; 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=VFNXtxZbG30kMQG1GdWNiGfy6cXuFkp7a/YnWV6tzyU=; b=YLI2KRDzxkKqlcPzQG/yELM1Lmh3NurXWjDMvv2m9KkvX64QcuAxFhT2NiaVIBnTOnLDLR eHiUqsJW9oOGf780PACgUMh3M3v+79zUlMo3Q6yfE0gpEKktqSISJZ8RPNTGnsUaMJteDQ dqajgrF1HKHLTaCvXgUE76mytVphO2d5cbEoSP4w8D8OGL10msSA2vvcqz9x230YPQtNI8 3DsqiigIUPC07tEk0vsL8QeAYNNZEDDVRD9Vj4RzCb3N0TOClZGe4BbBLq5HBruEkFC190 G6O8q9C/emLHkJGcdtAhI3c6tbBTBNSplba0ekoilZkoPC+fV4riEDnJcx0Zvw== 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 4VWr6K1HXxzZS8; Sat, 4 May 2024 14:44:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 444EiPmv094498; Sat, 4 May 2024 14:44:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 444EiPrU094495; Sat, 4 May 2024 14:44:25 GMT (envelope-from git) Date: Sat, 4 May 2024 14:44:25 GMT Message-Id: <202405041444.444EiPrU094495@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 6279646f47d3 - main - aic7xxx: make target mode enable a device hint List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6279646f47d3f6b916d1c9272f9db39134783ab4 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=6279646f47d3f6b916d1c9272f9db39134783ab4 commit 6279646f47d3f6b916d1c9272f9db39134783ab4 Author: HP van Braam AuthorDate: 2024-05-04 14:40:15 +0000 Commit: Warner Losh CommitDate: 2024-05-04 14:40:38 +0000 aic7xxx: make target mode enable a device hint Previously it was only possible to enable target mode for these drivers by rebuilding the kernel with AHC_TMODE_ENABLE or AHD_TMODE_ENABLE and a bitmask of which units to statically enable for target mode. There is no space-savings in the driver by not having AHC_TMODE_ENABLE set, so in addition to the compile time option lets also introduce some tunables: hint.ahc..tmode_enable=0/1 hint.ahd..tmode_enable=0/1 For compatibility the old behavior is retained, but it can be overridden with tunables Signed-off-by: HP van Braam Reviewed by: imp, mav Pull Request: https://github.com/freebsd/freebsd-src/pull/1208 --- share/man/man4/ahc.4 | 68 +++++++++++++++++++++++++++-------------------- share/man/man4/ahd.4 | 36 ++++++++++++++++--------- sys/dev/aic7xxx/aic79xx.c | 19 ++++++++++++- sys/dev/aic7xxx/aic7xxx.c | 19 ++++++++++++- 4 files changed, 99 insertions(+), 43 deletions(-) diff --git a/share/man/man4/ahc.4 b/share/man/man4/ahc.4 index a666885f8f4a..7d5e092089bb 100644 --- a/share/man/man4/ahc.4 +++ b/share/man/man4/ahc.4 @@ -40,12 +40,6 @@ kernel configuration file: .Pp For one or more PCI cards: .Cd "device pci" -.Pp -To allow PCI adapters to use memory mapped I/O if enabled: -.Cd options AHC_ALLOW_MEMIO -.Pp -To configure one or more controllers to assume the target role: -.Cd options AHC_TMODE_ENABLE .Ed .Pp Alternatively, to load the driver as a @@ -66,29 +60,6 @@ Driver features include support for twin and wide busses, fast, ultra or ultra2 synchronous transfers depending on controller type, tagged queueing, SCB paging, and target mode. .Pp -Memory mapped I/O can be enabled for PCI devices with the -.Dq Dv AHC_ALLOW_MEMIO -configuration option. -Memory mapped I/O is more efficient than the alternative, programmed I/O. -Most PCI BIOSes will map devices so that either technique for communicating -with the card is available. -In some cases, -usually when the PCI device is sitting behind a PCI->PCI bridge, -the BIOS may fail to properly initialize the chip for memory mapped I/O. -The typical symptom of this problem is a system hang if memory mapped I/O -is attempted. -Most modern motherboards perform the initialization correctly and work fine -with this option enabled. -.Pp -Individual controllers may be configured to operate in the target role -through the -.Dq Dv AHC_TMODE_ENABLE -configuration option. -The value assigned to this option should be a bitmap -of all units where target mode is desired. -For example, a value of 0x25, would enable target mode on units 0, 2, and 5. -A value of 0x8a enables it for units 1, 3, and 7. -.Pp Per target configuration performed in the .Tn SCSI-Select menu, accessible at boot @@ -156,6 +127,45 @@ Multiple Target IDs - Allows the controller to respond to selection as a target on multiple SCSI IDs. .El .Ed +.Sh CONFIGURATION OPTIONS +.Pp +To allow PCI adapters to use memory mapped I/O if enabled: +.Pp +.Cd options AHC_ALLOW_MEMIO +.Bd -ragged -offset indent +Memory mapped I/O is more efficient than the alternative, programmed I/O. +Most PCI BIOSes will map devices so that either technique for communicating +with the card is available. In some cases, usually when the PCI device is +sitting behind a PCI->PCI bridge, the BIOS may fail to properly initialize +the chip for memory mapped I/O. The typical symptom of this problem is a +system hang if memory mapped I/O is attempted. +.Pp +Most modern motherboards perform the initialization correctly and work fine +with this option enabled. +.Ed +.Pp +To statically configure one or more controllers to assume the target role: +.Pp +.Cd options AHC_TMODE_ENABLE +.Bd -ragged -offset indent +The value assigned to this option should be a bitmap of all units where target +mode is desired. For example, a value of 0x25, would enable target mode on +units 0, 2, and 5. A value of 0x8a enables it for units 1, 3, and 7. +.Pp +Note that controllers can be dynamically configured through a device hint +documented below. +.El +.Ed +.Sh BOOT OPTIONS +The following options are switchable by setting values in +.Pa /boot/device.hints . +.Pp +They are: +.Bl -tag -width indent +.It Va hint.ahc. Ns Ar N Ns Va .tmode_enable +A hint to define whether the SCSI target mode is enabled (0 -- disabled, 1 -- enabled). +.El +.Ed .Sh HARDWARE The .Nm diff --git a/share/man/man4/ahd.4 b/share/man/man4/ahd.4 index cf04863ce1c8..e7f9b73f085a 100644 --- a/share/man/man4/ahd.4 +++ b/share/man/man4/ahd.4 @@ -45,9 +45,6 @@ To compile in debugging code: .Cd options AHD_DEBUG .Cd options AHD_DEBUG_OPTS= .Cd options AHD_REG_PRETTY_PRINT -.Pp -To configure one or more controllers to assume the target role: -.Cd options AHD_TMODE_ENABLE= .Ed .Pp Alternatively, to load the driver as a @@ -99,15 +96,6 @@ that is printed by the debugging code. However, it also bloats the compiled size of the driver by approximately 215KB. .Pp -Individual controllers may be configured to operate in the target role -through the -.Dv AHD_TMODE_ENABLE -configuration option. -The value assigned to this option should be a bitmap -of all units where target mode is desired. -For example, a value of 0x25 would enable target mode on units 0, 2, and 5. -Note that target mode is only supported for ultra160 speeds and below. -.Pp Per target configuration performed in the .Tn SCSI-Select menu, accessible at boot, @@ -119,6 +107,30 @@ disconnection, and the host adapter's .Tn SCSI ID. +.El +.Ed +.Sh CONFIGURATION OPTIONS +To statically configure one or more controllers to assume the target role: +.Pp +.Cd options AHD_TMODE_ENABLE +.Bd -ragged -offset indent +The value assigned to this option should be a bitmap of all units where target +mode is desired. For example, a value of 0x25, would enable target mode on +units 0, 2, and 5. A value of 0x8a enables it for units 1, 3, and 7. +.Pp +Note that controllers can be dynamically configured through a device hint +documented below. + +.Sh BOOT OPTIONS +The following options are switchable by setting values in +.Pa /boot/device.hints . +.Pp +They are: +.Bl -tag -width indent +.It Va hint.ahd. Ns Ar N Ns Va .tmode_enable +A hint to define whether the SCSI target mode is enabled (0 -- disabled, 1 -- enabled). +.El +.Ed .Sh HARDWARE The .Nm diff --git a/sys/dev/aic7xxx/aic79xx.c b/sys/dev/aic7xxx/aic79xx.c index 1b1d31769f90..0c4b615c5b24 100644 --- a/sys/dev/aic7xxx/aic79xx.c +++ b/sys/dev/aic7xxx/aic79xx.c @@ -6229,6 +6229,9 @@ ahd_init(struct ahd_softc *ahd) size_t driver_data_size; int i; int error; +#ifdef AHD_TARGET_MODE + int tmode_enable; +#endif u_int warn_user; uint8_t current_sensing; uint8_t fstat; @@ -6261,8 +6264,22 @@ ahd_init(struct ahd_softc *ahd) /* * Only allow target mode features if this unit has them enabled. */ - if ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) == 0) +#ifdef AHD_TARGET_MODE + tmode_enable = ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) != 0); + resource_int_value(device_get_name(ahd->dev_softc), + device_get_unit(ahd->dev_softc), + "tmode_enable", &tmode_enable); + + if (tmode_enable == 0) { ahd->features &= ~AHD_TARGETMODE; + } else { + if (bootverbose && ((ahd->features & AHD_TARGETMODE) != 0)) + printf("%s: enabling target mode\n", ahd_name(ahd)); + } + +#else + ahd->features &= ~AHD_TARGETMODE; +#endif /* DMA tag for mapping buffers into device visible space. */ if (aic_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1, diff --git a/sys/dev/aic7xxx/aic7xxx.c b/sys/dev/aic7xxx/aic7xxx.c index 1560aa4fe312..c09876e9f589 100644 --- a/sys/dev/aic7xxx/aic7xxx.c +++ b/sys/dev/aic7xxx/aic7xxx.c @@ -4774,6 +4774,9 @@ ahc_init(struct ahc_softc *ahc) { int max_targ; int error; +#ifdef AHC_TARGET_MODE + int tmode_enable; +#endif u_int i; u_int scsi_conf; u_int ultraenb; @@ -4826,8 +4829,22 @@ ahc_init(struct ahc_softc *ahc) /* * Only allow target mode features if this unit has them enabled. */ - if ((AHC_TMODE_ENABLE & (0x1 << ahc->unit)) == 0) +#ifdef AHC_TARGET_MODE + tmode_enable = ((AHC_TMODE_ENABLE & (0x1 << ahc->unit)) != 0); + resource_int_value(device_get_name(ahc->dev_softc), + device_get_unit(ahc->dev_softc), + "tmode_enable", &tmode_enable); + + if (tmode_enable == 0) { ahc->features &= ~AHC_TARGETMODE; + } else { + if (bootverbose && ((ahc->features & AHC_TARGETMODE) != 0)) + printf("%s: enabling target mode\n", ahc_name(ahc)); + } + +#else + ahc->features &= ~AHC_TARGETMODE; +#endif /* DMA tag for mapping buffers into device visible space. */ if (aic_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,