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 864E8184529; Sun, 1 Sep 2024 16:46:55 +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=1725209215; cv=none; b=DnekFgYFf6wPBeANjhtK84lR8O1y/jNW+lJ37utTIIE+Ry4frt1U+Q6BxNXS6/R2ttT4xWVsKBm1HRty/Shm9Hd0+vJzOHePZ244zRk+bG4V3eqdZQQTCyAKY8vwfTM5eoiCVlEQl++qniLx5/O5BNP5iDBTRFozvw4UC8cEvng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725209215; c=relaxed/simple; bh=q0wy6GkfSbfoaXrXYXWAO/irJ5GXt0Gsho+5U43B6j8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hkrceFbQBhW61wk5BCcSMxprqLO5rJPlwo0G4htWOeSCh8huNX6v6eH5doytdU4M1GQWhDc/5bBL7Qj/TrvcZ6/JeBtx35nPwwqdk9y5TK4eJr3XxzpcDAsR6fK27fhzsC9aSGnNu5sLyqglTacKx3ooTedIf2S3Uo2fCCZafN0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=STv1m5YP; 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="STv1m5YP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B894C4CEC3; Sun, 1 Sep 2024 16:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725209215; bh=q0wy6GkfSbfoaXrXYXWAO/irJ5GXt0Gsho+5U43B6j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=STv1m5YPS3gZZ2FKDXQk3JZ8jghSmby9VP2eM0kpBqiocjbHTI8hx5H098s/FIJbM 2c6tl1cejZbIquP3oxpoWEj4bFo6KMjhu2gR4NheSL8agzK/rFNedI6CljbCCOzhVW BCg7qAIWVityewliGj+he3mPJB3a3KrY9kGy2/Wg= 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.1 36/71] soundwire: stream: fix programming slave ports for non-continous port maps Date: Sun, 1 Sep 2024 18:17:41 +0200 Message-ID: <20240901160803.255768489@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240901160801.879647959@linuxfoundation.org> References: <20240901160801.879647959@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.1-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 @@ -1272,18 +1272,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]; }