From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA72A2C190; Sun, 1 Sep 2024 17:07:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725210430; cv=none; b=QC5RXu8ugYBgm2cgsBGqkViL+Xw8du6763AZjhp+r81rr1H0JyEB1oAdmX1cZ3jZBthL/g5FTaDO9GNNokFoUV5RKB3rvr++LPGm31VOlYV1K/cYS0+XIpFrECppVtOU6ln4s5wPmcXbGWFsu7lRNO+TRVXX3PEFxn8w8uVzn0s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725210430; c=relaxed/simple; bh=7l+Bp7MBmrchRcRFS6rGnxLXpc/C58BsKSYKIu4mcWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ag79Ab1wqKBk5ZYEPgLlsExiyZHehO1mdq9ESwo2la5cN4hXhKlvq4m0IDUAqyzdbrbgtDOOV69sMDokuojp2HEUBnKr4M+AZcl4NcN64p+i9dFi8QXmwX9puYczAdzNrKU2YVBGt45MNez3WRy9wB6KQXCyZNi5dsy+j81/ZYc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=L4fsT4R9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="L4fsT4R9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F5FCC4CEC3; Sun, 1 Sep 2024 17:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725210430; bh=7l+Bp7MBmrchRcRFS6rGnxLXpc/C58BsKSYKIu4mcWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L4fsT4R9vYQ4bddDnqzfAQTdT/HRT2y5h8CM2WB9C+nHhJ6ON12KyePgiyh3pfVJl tTuq4u9UQCn6Wq2JTc6+0vmPNmGUEtesjhyLp6O+tcua0zdwSD6VpL5B7eAQikvaxp 4Hy8N6cNgwRd8XZpTLG9KQg1Yk00HN/IVhuu8zeM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Krzysztof Kozlowski , Pierre-Louis Bossart , Vinod Koul Subject: [PATCH 5.15 188/215] soundwire: stream: fix programming slave ports for non-continous port maps Date: Sun, 1 Sep 2024 18:18:20 +0200 Message-ID: <20240901160830.465052492@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240901160823.230213148@linuxfoundation.org> References: <20240901160823.230213148@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Krzysztof Kozlowski commit ab8d66d132bc8f1992d3eb6cab8d32dda6733c84 upstream. Two bitmasks in 'struct sdw_slave_prop' - 'source_ports' and 'sink_ports' - define which ports to program in sdw_program_slave_port_params(). The masks are used to get the appropriate data port properties ('struct sdw_get_slave_dpn_prop') from an array. Bitmasks can be non-continuous or can start from index different than 0, thus when looking for matching port property for given port, we must iterate over mask bits, not from 0 up to number of ports. This fixes allocation and programming slave ports, when a source or sink masks start from further index. Fixes: f8101c74aa54 ("soundwire: Add Master and Slave port programming") Cc: stable@vger.kernel.org Signed-off-by: Krzysztof Kozlowski Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20240729140157.326450-1-krzysztof.kozlowski@linaro.org Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/soundwire/stream.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -1445,18 +1445,18 @@ struct sdw_dpn_prop *sdw_get_slave_dpn_p unsigned int port_num) { struct sdw_dpn_prop *dpn_prop; - u8 num_ports; + unsigned long mask; int i; if (direction == SDW_DATA_DIR_TX) { - num_ports = hweight32(slave->prop.source_ports); + mask = slave->prop.source_ports; dpn_prop = slave->prop.src_dpn_prop; } else { - num_ports = hweight32(slave->prop.sink_ports); + mask = slave->prop.sink_ports; dpn_prop = slave->prop.sink_dpn_prop; } - for (i = 0; i < num_ports; i++) { + for_each_set_bit(i, &mask, 32) { if (dpn_prop[i].num == port_num) return &dpn_prop[i]; }