From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 223FDD12663 for ; Tue, 5 Nov 2024 08:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/leph5S+W3yNeLUCzxbkpGKIqttpuqEQF6RdkoG4cpY=; b=PxgDDpo5YwRASXZMsaDLS39LdB Kqjvg3ha6kRByUDs3oJuIruK4Ki667mkO+z7Zm2Cj6HVGDHSuIJJaozxqZP4xvlloTa4sUyHF/1JO ngZTmcQcNX54mDiASKW9ppiwVS+qmsvIY+8uI2p7LPSa6nHrJiHLS5UXfuh4PE8SR3Re4HknBctKl rJyeftoH7c0NVcWXpEZTOaRYcizihH/gc2w3bGlHDVHERMcjNreIrk26wAUBr70NNbwugqR1xfNJ5 pEiD/vCeEhSgfxrSARndmcNseVOalGzNqPr8wfXQlNv1hfCyL6IdkYfOogSsUAXQNI19onwumLhSw qHuOzrHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t8EjZ-0000000GIyc-2X3L; Tue, 05 Nov 2024 08:16:17 +0000 Received: from ionic.de ([2001:41d0:700:3394:1::2] helo=mail.ionic.de) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t8DfE-0000000G9Tz-2Twf for ath11k@lists.infradead.org; Tue, 05 Nov 2024 07:07:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ionic.de; s=default; t=1730790463; bh=yDkBeWqIAm14jlWKhvWbuyU4fpIdkQ5gQWI4SPycAVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o8eH/untXyN7Jb564AC5vveupTC3g+yhhM/y/mwF1EpfBFGBzOOwU5WWkUBbckQ33 dw0QZvsvVXsKq7l5N91Zg9urofZvq2Z1cpgoBcOSwx4qLL3X/ZnGZ2tzYGCFwC6D7V AzqdsNh7C0haqe3r1LYFmwmv+0ihdW25Dd+4zmMI= Received: from grml.local.home.ionic.de (unknown [IPv6:2a00:11:fb41:7a00:21b:21ff:fe5e:dddc]) by mail.ionic.de (Postfix) with ESMTPSA id 1494B14886E2; Tue, 05 Nov 2024 08:07:43 +0100 (CET) From: Mihai Moldovan To: ath11k@lists.infradead.org Cc: Mihai Moldovan Subject: [DONOTMERGE] [NOTEVENRFC] [PATCH 04/11] soc: qcom: qmi_helpers: optionally bind to QRTR endpoint ID in qmi_sock_create Date: Tue, 5 Nov 2024 08:06:18 +0100 Message-ID: <613fae361da4b507ea43e6e4acfbf0ed4ace5527.1730790062.git.ionic@ionic.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241104_230744_866658_68204E44 X-CRM114-Status: GOOD ( 11.74 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath11k" Errors-To: ath11k-bounces+ath11k=archiver.kernel.org@lists.infradead.org For clients that already know the QRTR endpoint ID before actually creating the QMI socket and set it in struct qmi_handle, optionally try to bind to this QRTR endpoint ID when creating the socket. This can fail, and qmi_sock_create will issue diagnostic messages, but otherwise ignore the error. Signed-off-by: Mihai Moldovan --- drivers/soc/qcom/qmi_interface.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/soc/qcom/qmi_interface.c b/drivers/soc/qcom/qmi_interface.c index bb98b06e87f8..893e5a6accd9 100644 --- a/drivers/soc/qcom/qmi_interface.c +++ b/drivers/soc/qcom/qmi_interface.c @@ -586,6 +586,7 @@ static struct socket *qmi_sock_create(struct qmi_handle *qmi, struct sockaddr_qrtr *sq) { struct socket *sock; + const struct proto_ops *ops = NULL; int ret; ret = sock_create_kern(&init_net, AF_QIPCRTR, SOCK_DGRAM, @@ -593,6 +594,33 @@ static struct socket *qmi_sock_create(struct qmi_handle *qmi, if (ret < 0) return ERR_PTR(ret); + ops = READ_ONCE(sock->ops); + + if (!ops) { + pr_warn("sock->ops not available for QMI socket, will not be " + "able to bind to endpoint ID.\n"); + /* N.B.: this error value will not be passed out. */ + ret = -ENXIO; + } + + if (!ret && !ops->setsockopt) { + pr_warn("ops->setsockopt not available for QMI socket, will " + "not be able to bind to endpoint ID.\n"); + /* N.B.: this error value will not be passed out. */ + ret = -ENXIO; + } + + /* Only bind to a specific endpoint if a valid one was provided. */ + if (!ret && qmi->endpoint_id) { + ret = ops->setsockopt(sock, SOL_QRTR, QRTR_BIND_ENDPOINT, + KERNEL_SOCKPTR(&qmi->endpoint_id), + sizeof(qmi->endpoint_id)); + + if (ret < 0) + pr_warn("binding to QRTR endpoint ID requested, but " + "operation failed: %d\n", ret); + } + ret = kernel_getsockname(sock, (struct sockaddr *)sq); if (ret < 0) { sock_release(sock); -- 2.45.2