Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp448361lqg; Thu, 11 Apr 2024 07:44:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkDQxbHyU+1AXCBoxbbAx0xO45E3WkFV1yZNJKveDLKAgRJL8rQNfg33Z0oWB8kCFRpMLqs6emeeUCGQ2Mgb+ktVJMjPK0nSWmoEt9WA== X-Google-Smtp-Source: AGHT+IHwWza1rWCaVgPeNEeOptv0/+E4JW0veU58lS6ZBM8mzo0t7AvqmUs9cYS6OxF4d3/Ou8wa X-Received: by 2002:a05:6512:209:b0:517:5e62:fdd2 with SMTP id a9-20020a056512020900b005175e62fdd2mr4081559lfo.10.1712846694626; Thu, 11 Apr 2024 07:44:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712846694; cv=pass; d=google.com; s=arc-20160816; b=OuqH+gm7eq9xGJ8M5zVCULSIyNQJpabNToMdSYmHop3dD/O4VBDDm53GbUKpwXkZk0 Vl9JkDXWzYv7BDpx0KSZJWWrSC2GnhnvMYa7PYFX0oC2UkTtaGqH4don6mFaY6FUL6gd uvvXy6HW2QT+vTap0J0vXFeGCw+YcuHFRZNnmqVj18u/APY8rsyhBOrfcZGjysXfOrZA bJzjT41gHPabqTNBF4k9RsDjUiIQiWHVBi2mBZ5r1hI5zo8mYenmpR9JVCstl/EFch/w 23u/7ODBajGBclLwLb87kYSH+XNQFwVSLPE27bnssVOunkyDMkb5J8nNIy0xYL/3wy0H gOaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=oQ6XrMhbmV9JcuJYPpZB8KbT6+36el4HPonD3p5qbr8=; fh=iNF1PBRLuyk0wyephE6lIMa2aDVRE/eVvlOHc9mrLlo=; b=j/iu0xWshN3EwiHbVfa/4AzRHb3jryyVV8p+PNohvDt0Gf+JEKxOykPwhwFQyMeQmB N4GCGWmIbCJoiN2mbAu19tbEKBWZEMJmCsJQtHo+uJxEeudl5mA+BS1aRWCj8K0xWARl qLez21ulftm9ITP7cxaVA6kffMrzd+VVQRSs4er9fyPR5VElGh6zYzPGKTivrpHa/HGa 2yAs6q5hm5Y9VQ1NGKZls44xj4rCMnzFKZXYsT3Xl+pnCxJTZVf7te81SrB8qBjgb2Fs J2GOgr5qRvNg++YVgUvf4rmY4lihEAFsbV2V0ia2jPlkvj7Ub59WaeqymY/Ww3PK0jda joIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=InRaF0wP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-140682-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140682-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id es15-20020a056402380f00b0056c36a20006si823712edb.205.2024.04.11.07.44.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:44:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140682-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=InRaF0wP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-140682-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140682-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2D5071F2120E for ; Thu, 11 Apr 2024 14:44:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F59B17BCA; Thu, 11 Apr 2024 14:43:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="InRaF0wP" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 9B4A210A12; Thu, 11 Apr 2024 14:43:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712846603; cv=none; b=n/MgCPvqi+OIQz566ULeaYQmnoTxTv0qygiiHV12nVZtjTZ9pRZewSiMS5CdqEvgv7nn9v0cKLm87GtF6IRCWgym3kCPI6BJGJ5VCr5F9fFNbzWCXUdYq+RxpNvq7yeRwSTxWhxCTReNP1RiKnoqDDlBnlCkRyGJQcrSqqtq8Rk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712846603; c=relaxed/simple; bh=x/18Z9algBXQxM9quW+7AyCJRcmj23RiT3ilEq9hIAk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VZUxTx0J5seKsO1kbrwIf7SRYxeT3L1vWNuRFFfUNO7fDknKGuKaO0N0hnOIsuUHwYECzC/RnSowkVy/YjgLfyS7IImrhcoQb/keMMzhlTo3Z8oWmKCQ9aOZlPtw3vgMNKMAu4/0/GDT8JLsC+Iv7V83qYMu5oIAvEpU5hVrJuA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=InRaF0wP; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712846602; x=1744382602; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=x/18Z9algBXQxM9quW+7AyCJRcmj23RiT3ilEq9hIAk=; b=InRaF0wPVfqTY0u+IqB+pPm50dc8keL2IDUc8yCyxg8+hJUxldS4+84q uGjlUf0nQl24A7R7cQkTFrcVUW5hNOt2RPZuNjaOYZR1cnaUSNmTW+SSW kvtcoyfjcUvYhnuswW4uFhcpjHgJMzb3+IIdQZr90jIGGuF0uCid4ZJuz vi1TfxLZ5YRKHpgYRKIFa6Eg+fgUIILlW+MAaqyVKU8y7+3B12bL+OZGs YpeZgP+AxNEQ8vOLO7suEirGVY6rx6Jgmrecbvgsafk027zTT2dhnKRZc LQe9Ef8tB6sVnViED0eCcPuualxFLlZYkQ02ASpUegf7A9hnoB6FAtVs+ g==; X-CSE-ConnectionGUID: 9D6xSLu1Rh2kpEBl+4SD/w== X-CSE-MsgGUID: 4EW9GTblQX2X/ggDoeTlJg== X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="8422089" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="8422089" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 07:43:21 -0700 X-CSE-ConnectionGUID: il7oItqBTpS6AB0o+c+M2Q== X-CSE-MsgGUID: FCVgRjC5T7mnEpCgcjHhyQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="20927053" Received: from npirooza-mobl1.amr.corp.intel.com (HELO [10.212.34.202]) ([10.212.34.202]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 07:43:21 -0700 Message-ID: <3995e049-30db-4e31-a5fb-ca998b1822b6@linux.intel.com> Date: Thu, 11 Apr 2024 09:24:52 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 6/7] soundwire: debugfs: add interface to read/write commands To: Vinod Koul Cc: Bard Liao , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, bard.liao@intel.com References: <20240326090122.1051806-1-yung-chuan.liao@linux.intel.com> <20240326090122.1051806-7-yung-chuan.liao@linux.intel.com> <19f21879-885c-4120-9411-7022f526426f@linux.intel.com> Content-Language: en-US From: Pierre-Louis Bossart In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/11/24 04:28, Vinod Koul wrote: > On 05-04-24, 10:12, Pierre-Louis Bossart wrote: >> On 4/5/24 06:45, Vinod Koul wrote: >>> On 26-03-24, 09:01, Bard Liao wrote: >>>> From: Pierre-Louis Bossart >>>> >>>> We have an existing debugfs files to read standard registers >>>> (DP0/SCP/DPn). >>>> >>>> This patch provides a more generic interface to ANY set of read/write >>>> contiguous registers in a peripheral device. In follow-up patches, >>>> this interface will be extended to use BRA transfers. >>>> >>>> The sequence is to use the following files added under the existing >>>> debugsfs directory for each peripheral device: >>>> >>>> command (write 0, read 1) >>>> num_bytes >>>> start_address >>>> firmware_file (only for writes) >>>> read_buffer (only for reads) >>>> >>>> Example for a read command - this checks the 6 bytes used for >>>> enumeration. >>>> >>>> cd /sys/kernel/debug/soundwire/master-0-0/sdw\:0\:025d\:0711\:01/ >>>> echo 1 > command >>>> echo 6 > num_bytes >>>> echo 0x50 > start_address >>>> echo 1 > go >>> >>> can we have a simpler interface? i am not a big fan of this kind of >>> structure for debugging. >>> >>> How about two files read_bytes and write_bytes where you read/write >>> bytes. >>> >>> echo 0x50 6 > read_bytes >>> cat read_bytes >>> >>> in this format I would like to see addr and values (not need to print >>> address /value words (regmap does that too) >>> >>> For write >>> >>> echo start_addr N byte0 byte 1 ... byte N > write_bytes >> >> I think you missed the required extension where we will add a new >> 'command_type' to specify which of the regular or BTP/BRA accesses is used. >> >> Also the bytes can come from a firmware file, it would be very odd to >> have a command line with 32k value, wouldn't it? > > ofc no one should expect that... it should be written directly from the firmware file > >> I share your concern about making the interface as simple as possible, >> but I don't see how it can be made simpler really. We have to specify >> - read/write >> - access type (BRA or regular) >> - start address >> - number of bytes >> - a firmware file for writes >> - a means to see the read data. >> >> And I personally prefer one 1:1 mapping between setting and debugfs >> file, rather than a M:1 mapping that require users to think about the >> syntax and which value maps to what setting. At my age I have to define >> things that I will remember on the next Monday. > > Exactly, you won't remember all the files to write to, my idea was a > simple format or addr, N and data.. a TLV kind of structure.. So your updated proposal for a write is echo 1 0 0x50 6 test.bin > write_bytes Mine was echo 1 > command echo 0 > access echo 0x50 > start_addr echo 6 > num_bytes echo test.bin > firmware echo 1 > go I find the last version a lot more explicit and self-explanatory. There is no need to look-up the documentation of the list and order of arguments. You can argue that there are just three files needed (write command, read command, read results), but there's more work to parse arguments and remember the arguments order. There's also the scripting part. In my tests, I relied on scripts where I modified one line, it's just easier to visualize than modifying one argument in the middle of a line. The last point is extensibility. In the existing BPT/BRA tests, the data is sent by chunks in each frame. We know that some peripherals cannot tolerate back-to-back transfers in contiguous frames, that would require additional arguments to control the flow. If we have to do this with a list of arguments, it's not straightforward to do without a versioning scheme. The risk of getting things wrong is not really a concern, if the destination or number of bytes is incorrect the command will fail. It will not cause any issues. It's a debugfs interface to inject commands, it's expected that people will actually try to make things fail... Again, this is NOT how the BPT/BRA protocol would be used in a real product. The integration would rely on the codec driver initiating those transfers. What this debugfs interface helps with is only for initial integration tests between a host and peripheral to simulate that the codec driver will do in the final iteration. > What would happen if you issue go, but missed writing one of the files. > Also I would expect you to do error checking of inputs... Please see the patch, the inputs are checked when possible to avoid buffer overflows, etc, but as mentioned above it's important to allow for bad commands to be issued to test the robustness of the driver. There is e.g. no check on the start_addr, number of bytes, the interface allows access to any part of the peripheral memory space. That's a feature, not a bug.