From patchwork Fri Jun 28 20:55:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13716610 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 2A780C30658 for ; Fri, 28 Jun 2024 20:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yE9oKvUPTJO5P4eknJqbpkKp4npe0lZq3QlGK04td/c=; b=lL3FOOj0hQoiFE EhBWcdae/gvLNNV5noPSE8PjKQhZNDhB9EG6HTjHD+capchVuPLPdHXF25LgK3cP1INCcP0FscElB jOr3QU2tOENoF1PmsLcAnrcFXxiukFI74mMH/nYMnU93Ac6DnHJlUS04/d9o5raBSnaP2cPxh7n8B KF8Ssf16ytU4anZbMxVrDKjeBKoXdbXEzqcyKIAeh2ht4urMfYCVZG0IsMNCVa7NRGdMKCfytLHfW 5d1pkFzzLDevhBnB7keA9qK1q1DaRalrk5ic8fUC3LMH8XUapSmsDncBESGa1QaW8b1xHPoHOklzb Se7HAfCyR/9HZ6Gl9A9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNIei-0000000EwNi-2xjv; Fri, 28 Jun 2024 20:57:16 +0000 Received: from out-174.mta1.migadu.com ([2001:41d0:203:375::ae]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNIdd-0000000EviM-1Fs9 for linux-phy@lists.infradead.org; Fri, 28 Jun 2024 20:56:13 +0000 X-Envelope-To: radhey.shyam.pandey@amd.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719608167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ePtnv+mOy1V2a9C9AGkoMpYJ4bWTIeHu876bvQ6PA7w=; b=LoRjkfufmI+It1uHsu+j94T3quZNHVJZk802KYnAcvZadmEkuQvNWwdhnFHJ4kw+oR2Ajg p6tUKCEhXJioBIeC4VbIwlNoiQnr6fhdJV6h52a03Xhh2CiwUHtWPLPzjFNlBEEx0KrMkM SF3sSn/s3gj1eQhQb7b1oiKD9rrpHro= X-Envelope-To: laurent.pinchart@ideasonboard.com X-Envelope-To: linux-phy@lists.infradead.org X-Envelope-To: vkoul@kernel.org X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: kishon@kernel.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: michal.simek@amd.com X-Envelope-To: sean.anderson@linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson To: Radhey Shyam Pandey , Laurent Pinchart , linux-phy@lists.infradead.org Cc: Vinod Koul , linux-arm-kernel@lists.infradead.org, Kishon Vijay Abraham I , linux-kernel@vger.kernel.org, Michal Simek , Sean Anderson Subject: [PATCH v3 4/5] phy: zynqmp: Take the phy mutex in xlate Date: Fri, 28 Jun 2024 16:55:39 -0400 Message-Id: <20240628205540.3098010-5-sean.anderson@linux.dev> In-Reply-To: <20240628205540.3098010-1-sean.anderson@linux.dev> References: <20240628205540.3098010-1-sean.anderson@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_135609_652891_50BB8805 X-CRM114-Status: UNSURE ( 7.50 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Take the phy mutex in xlate to protect against concurrent modification/access to gtr_phy. This does not typically cause any issues, since in most systems the phys are only xlated once and thereafter accessed with the phy API (which takes the locks). However, we are about to allow userspace to access phys for debugging, so it's important to avoid any data races. Signed-off-by: Sean Anderson --- Changes in v3: - New drivers/phy/xilinx/phy-zynqmp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/phy/xilinx/phy-zynqmp.c b/drivers/phy/xilinx/phy-zynqmp.c index 4d697e11d8eb..991be42eef3d 100644 --- a/drivers/phy/xilinx/phy-zynqmp.c +++ b/drivers/phy/xilinx/phy-zynqmp.c @@ -759,6 +759,7 @@ static struct phy *xpsgtr_xlate(struct device *dev, phy_type = args->args[1]; phy_instance = args->args[2]; + guard(mutex)(>r_phy->phy->mutex); ret = xpsgtr_set_lane_type(gtr_phy, phy_type, phy_instance); if (ret < 0) { dev_err(gtr_dev->dev, "Invalid PHY type and/or instance\n");