From nobody Sun Mar 13 20:02:05 2022 X-Original-To: freebsd-drivers@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 202091A19A18 for ; Sun, 13 Mar 2022 20:02:08 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from wforward3-smtp.messagingengine.com (wforward3-smtp.messagingengine.com [64.147.123.22]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4KGrDH2JWwz4pLc for ; Sun, 13 Mar 2022 20:02:07 +0000 (UTC) (envelope-from farhan@farhan.codes) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailforward.west.internal (Postfix) with ESMTP id 874FF1AC2080 for ; Sun, 13 Mar 2022 16:02:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 13 Mar 2022 16:02:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=SF1kes3YKSK/1iTK3 NAMaxTAMS09E2RowZGE6WS/gyE=; b=P8a71IEzA0dUR50/zbskydJYnNL1JeDp9 axUGhhrYwTlz8uJ6r/SomHeAvrdZEMiHCet3NFmsAWWQ7IjVHRk58cv1hbXUKvf5 +X3IkFm388xeD4ZUmpAxOaLix2FnSg6Iv1OcwmR/KoaVZMgx7eugDLT1muq2aTJh HeQkRSOxbrlJeabK34QUSzd4dGELkhBa/yEFvpC/CEZatF1tcIFmhry/fJzNwTje F9GisVG4vFEjbFTB26qaeXD2v0saCkW+CbQ0cABvcu+ZfynohaHFjAqafVszMR6g vWVS7y4WuYni1fFLgeUgnSs6jP3EssDpuAYQMYig2xe42kjoV3tAQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddruddviedgudefgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfvffhufgtgfesthejre dttdefjeenucfhrhhomhephfgrrhhhrghnucfmhhgrnhcuoehfrghrhhgrnhesfhgrrhhh rghnrdgtohguvghsqeenucggtffrrghtthgvrhhnpeefgfduvdefjeduveevudelteffve fhffdtteeugfehueekkefffeffieevieeugeenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehfrghrhhgrnhesfhgrrhhhrghnrdgtohguvghs X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 13 Mar 2022 16:02:05 -0400 (EDT) Message-ID: <706b2fc4-ce74-8716-d5c6-092d69c9c0fc@farhan.codes> Date: Sun, 13 Mar 2022 16:02:05 -0400 List-Id: Writing device drivers for FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-drivers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-drivers@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US To: freebsd-drivers@freebsd.org From: Farhan Khan Subject: Why mtx_sleep returning EWOUNDBLOCK? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4KGrDH2JWwz4pLc X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=P8a71IEz; dmarc=none; spf=none (mx1.freebsd.org: domain of farhan@farhan.codes has no SPF policy when checking 64.147.123.22) smtp.mailfrom=farhan@farhan.codes X-Spamd-Result: default: False [-3.40 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[messagingengine.com:s=fm2]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-drivers@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DWL_DNSWL_LOW(-1.00)[messagingengine.com:dkim]; RCVD_COUNT_THREE(0.00)[4]; DMARC_NA(0.00)[farhan.codes]; DKIM_TRACE(0.00)[messagingengine.com:+]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MLMMJ_DEST(0.00)[freebsd-drivers]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:29838, ipnet:64.147.123.0/24, country:US]; RCVD_TLS_LAST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[64.147.123.22:from] X-ThisMailContainsUnwantedMimeParts: N Hi all, Summary: I am running mtx_sleep() but getting an EWOUNDBLOCK response code and do not understand why. I am looking at port code from the OpenBSD side to FreeBSD. I am assuming that tsleep_nsec()'s equivalent on FreeBSD is mtx_sleep(). To that end, I am running mtx_sleep as this: mtx_lock(&(sc)->sc_mtx); error = mtx_sleep(sc, &sc->sc_mtx, 0 , "athnfw", hz); mtx_unlock(&(sc)->sc_mtx); However, the error code returns a EWOUNDBLOCK. I would expect this to be 0. From reading the man page for sleep(9), this means "A non-zero timeout was specified and the timeout". But if I slept for 1 hz, isn't that exactly what I want and thus it should return 0 (no error)? The OpenBSD line in question is: error = tsleep_nsec(&usc->wait_msg_id, 0, "athnfw", SEC_TO_NSEC(1)); Perhaps there is something I am not understanding here? Please advise. Thanks! Farhan