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 BAEAF143894; Sun, 1 Sep 2024 16:26:44 +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=1725208004; cv=none; b=Qrspevf7c8JRPYiAajXqMpxPtjce21UZSKdWt5pKfaTkvV+z3hHsaOar/eQNNIOMtYEpKkrUkXgH4pnIm54oUjJzJDWpkh2VmYWoXqgputN32uNasPRh/FqF3J+xexH2RmrPBZUFehS2Vf6mKMqpHpKC0+zZ7Y1CV3uBQLJqwgY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725208004; c=relaxed/simple; bh=EPF5SRjjc19aLCHWKI5DhdPEg5+aXc6hLitiPbQPB3A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=enjyDEEASyHcSSXcCckOL0TEgeIR5EUejV4LIGPZ3DafBVY74g6+i5DYKbAEavraV+1WPGe26UF8WEf28T0BTZ6hz9BbkFTivjewVYVBYSF0P562YYGjwPIpj9SoSk9O70tAznefoE+AJUnHJYlvn6oqHe6AJcLjVy1Pq9dBL4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nfFzmobb; 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="nfFzmobb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BBF8C4CEC3; Sun, 1 Sep 2024 16:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725208004; bh=EPF5SRjjc19aLCHWKI5DhdPEg5+aXc6hLitiPbQPB3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nfFzmobbIus/XTBgntP6gis6n19yNwZx62qK33BRCIE1KiUtCWbRzRzLHPlNYbnSz t96OG+gxPpW3wJGp25OHNMqK5B+jt4fjNLEVNTk2xf+iCi2idh6W8Vf2P2spfjvADZ Ekpd1f2mA0JICkHGKNc3Rlp8n3TLAzpce1U0bxMk= 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 6.6 45/93] soundwire: stream: fix programming slave ports for non-continous port maps Date: Sun, 1 Sep 2024 18:16:32 +0200 Message-ID: <20240901160809.057830052@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240901160807.346406833@linuxfoundation.org> References: <20240901160807.346406833@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 @@ -1286,18 +1286,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]; }