mcusim / freebsd-src

sys/dev/dpaa2 drivers work-in-progress
https://www.FreeBSD.org/
Other
4 stars 3 forks source link

Build failure without INVARIANTS (includes suggested patch) #5

Closed BSDer closed 2 years ago

BSDer commented 2 years ago

When you try and build a kernel without INVARIANTS, such as a NODEBUG kernel, compilation fails with:

--- all_subdir_dpaa2 ---
/usr/src/sys/dev/dpaa2/dpaa2_swp.c:1034:5: error: variable 'r' set but not used [-Werror,-Wunused-but-set-variable]
        } *r;
           ^
1 error generated.
*** [dpaa2_swp.o] Error code 1

make[4]: stopped in /usr/src/sys/modules/dpaa2
1 error

make[4]: stopped in /usr/src/sys/modules/dpaa2

A possible fix is to surround by #if ... both the definition and the assignment of variable r.

In this case I took the #if ... from sys/sys/kassert.h, where KASSERT is also defined:


diff --git a/sys/dev/dpaa2/dpaa2_swp.c b/sys/dev/dpaa2/dpaa2_swp.c
index 200beb8dce57..c2b231826d38 100644
--- a/sys/dev/dpaa2/dpaa2_swp.c
+++ b/sys/dev/dpaa2/dpaa2_swp.c
@@ -1028,10 +1028,12 @@ static int
 dpaa2_swp_exec_mgmt_command(struct dpaa2_swp *swp, struct dpaa2_swp_cmd *cmd,
     struct dpaa2_swp_rsp *rsp, uint8_t cmdid)
 {
+#if (defined(_KERNEL) && defined(INVARIANTS)) || defined(_STANDALONE)
        struct __packed with_verb {
                uint8_t verb;
                uint8_t _reserved[63];
        } *r;
+#endif
        uint16_t flags;
        int error;

@@ -1057,7 +1059,9 @@ dpaa2_swp_exec_mgmt_command(struct dpaa2_swp *swp, struct dpaa2_swp_cmd *cmd,
        }
        dpaa2_swp_unlock(swp);

+#if (defined(_KERNEL) && defined(INVARIANTS)) || defined(_STANDALONE)
        r = (struct with_verb *) rsp;
+#endif
        KASSERT((r->verb & CMD_VERB_MASK) == cmdid,
            ("wrong VERB byte in response: resp=0x%02x, expected=0x%02x",
            r->verb, cmdid));

With the patch the NODEBUG kernel builds and after a two way transfer of ~1G in both directions (at ~ 960mbps):

# sysctl dev.dpaa2_ni.0 && netstat -i -b -n -I dpni0
dev.dpaa2_ni.0.stats.in_all_frames: 1087188
dev.dpaa2_ni.0.stats.in_all_bytes: 1120373738
dev.dpaa2_ni.0.stats.in_multi_frames: 70
dev.dpaa2_ni.0.stats.eg_all_frames: 1086856
dev.dpaa2_ni.0.stats.eg_all_bytes: 1120347810
dev.dpaa2_ni.0.stats.eg_multi_frames: 0
dev.dpaa2_ni.0.stats.in_filtered_frames: 0
dev.dpaa2_ni.0.stats.in_discarded_frames: 0
dev.dpaa2_ni.0.stats.in_nobuf_discards: 0
dev.dpaa2_ni.0.stats.rx_ieoi_err_frames: 0
dev.dpaa2_ni.0.stats.rx_enq_rej_frames: 0
dev.dpaa2_ni.0.stats.rx_sg_buf_frames: 0
dev.dpaa2_ni.0.stats.rx_single_buf_frames: 1087192
dev.dpaa2_ni.0.stats.rx_anomaly_frames: 0
dev.dpaa2_ni.0.channels.15.tx_dropped: 0
dev.dpaa2_ni.0.channels.15.tx_frames: 0
dev.dpaa2_ni.0.channels.14.tx_dropped: 0
dev.dpaa2_ni.0.channels.14.tx_frames: 0
dev.dpaa2_ni.0.channels.13.tx_dropped: 0
dev.dpaa2_ni.0.channels.13.tx_frames: 0
dev.dpaa2_ni.0.channels.12.tx_dropped: 0
dev.dpaa2_ni.0.channels.12.tx_frames: 0
dev.dpaa2_ni.0.channels.11.tx_dropped: 0
dev.dpaa2_ni.0.channels.11.tx_frames: 0
dev.dpaa2_ni.0.channels.10.tx_dropped: 0
dev.dpaa2_ni.0.channels.10.tx_frames: 0
dev.dpaa2_ni.0.channels.9.tx_dropped: 0
dev.dpaa2_ni.0.channels.9.tx_frames: 0
dev.dpaa2_ni.0.channels.8.tx_dropped: 0
dev.dpaa2_ni.0.channels.8.tx_frames: 0
dev.dpaa2_ni.0.channels.7.tx_dropped: 0
dev.dpaa2_ni.0.channels.7.tx_frames: 0
dev.dpaa2_ni.0.channels.6.tx_dropped: 0
dev.dpaa2_ni.0.channels.6.tx_frames: 0
dev.dpaa2_ni.0.channels.5.tx_dropped: 0
dev.dpaa2_ni.0.channels.5.tx_frames: 0
dev.dpaa2_ni.0.channels.4.tx_dropped: 0
dev.dpaa2_ni.0.channels.4.tx_frames: 0
dev.dpaa2_ni.0.channels.3.tx_dropped: 0
dev.dpaa2_ni.0.channels.3.tx_frames: 0
dev.dpaa2_ni.0.channels.2.tx_dropped: 0
dev.dpaa2_ni.0.channels.2.tx_frames: 0
dev.dpaa2_ni.0.channels.1.tx_dropped: 0
dev.dpaa2_ni.0.channels.1.tx_frames: 0
dev.dpaa2_ni.0.channels.0.tx_dropped: 0
dev.dpaa2_ni.0.channels.0.tx_frames: 1086897
dev.dpaa2_ni.0.%parent: dpaa2_rc0
dev.dpaa2_ni.0.%pnpinfo: 
dev.dpaa2_ni.0.%location: 
dev.dpaa2_ni.0.%driver: dpaa2_ni
dev.dpaa2_ni.0.%desc: DPAA2 Network Interface
Name    Mtu Network       Address              Ipkts Ierrs Idrop     Ibytes    Opkts Oerrs     Obytes  Coll
dpni0  1500 <Link#1>      82:e3:3f:86:00:11        0     0     0 1120375388        0     0          0     0
dpni0     - 192.168.1.0/2 192.168.1.52       1087085     -     - 1105137104  1086901     - 1105137884     -
dsalychev commented 2 years ago

Fixed in b02e944aa6acd1b1c355dfe21f029456ec149cba.