Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp368101imn; Fri, 29 Jul 2022 09:17:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR5JJKMX4TnWuowpPBun5vFSwK0vAk6DoByk0iMAEp1YIYgoadLOhTWjwPxYFpBSxDgpMuAK X-Received: by 2002:a17:902:dac9:b0:16d:5cfc:6fb7 with SMTP id q9-20020a170902dac900b0016d5cfc6fb7mr4716484plx.64.1659111446487; Fri, 29 Jul 2022 09:17:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659111446; cv=none; d=google.com; s=arc-20160816; b=U7NMnHCcvkFMymjJ/+qveZdyq5KovBrNlr4Akul3uLXkBEIe2LyB4luwEeO1Jmjd1R agrQaFKo5ka4yge1OS7P4ecHuHri27SGkIGp9dH24oH0Z95rtf5OHe6DURUUvMKqSQA5 Qxq6s32Ny3xwu8+1odZhk9UAC64amAPuWeUxsIiInuIiF8Jwxrl6YjBmsXsbPRHODQgh Y1gQVwn5R2hmjo2s7rE389Df8AUF/kx4fqz1uLxA2ZkkrXbiZoJ483QffEDZy0m0uhh2 3Q7qnN1waHSDfVyQ02durnqyWzJsHKshFVgrTqZ0ECXhGgCCRRYouTb6+g+gNGx22qxg 6kZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OT1wAVvY3kRB3vqWwvg5/7CDRiIEo8aCU4Ez8Wz29Yg=; b=giyopyMdVM+S7yseegsOiXFl0DVxzTUYFHtnte3J5wuUrpMoxs5Sn+dWIo2nVNP5oH zlmiYFZZYP84ATEClUPf1uo94nT0i4DOx5Zq+IwgYjkb6icT3GzMjcsY4NbWgJuwt6JU Iwr0aWVzawtBQlQGQsk6Jg4cM+nHXtj0mqKRfTv/g3LN+fvJfDRJX8+ilxD92y7P1th8 z8tLkm3kwakoMt5by1sAuj3DKbR6srL9l9xQ80wLRWyjyAVgoMcIgoH/o3Z8Zwsm9vUa FMJdITJyIniQpkGKiOK/uc08BJxScSAkEFHFmVPXTFsEkA0A4AlUJWoIqhOSepyvkyV4 6RCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="HXSyP/oD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p6-20020a056a000b4600b0052ad083f789si4408988pfo.312.2022.07.29.09.17.10; Fri, 29 Jul 2022 09:17:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="HXSyP/oD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236725AbiG2Pwc (ORCPT + 99 others); Fri, 29 Jul 2022 11:52:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbiG2Pwa (ORCPT ); Fri, 29 Jul 2022 11:52:30 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAF731F2FD for ; Fri, 29 Jul 2022 08:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659109949; x=1690645949; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=UAUPEMcuCVe8VZDe3qyzrxa6b7jqOvbpuUOTVLjcXf4=; b=HXSyP/oDkVukmoe8a7cdMSt8G6zy72133zZh08XH647nn7nVRPgot5aB DYY5c/0l+zJ86vbLJOHbnyWYJljTZtqLvrKeIg+tRz24BdOYTEzQyuDFr OeHasYq0sDaB+MLBC9BohC8QNvnCPrf5auR4+7Lw3gRyOLbvViPpj11r3 1TCcXIkJjIViclIQcTR57tDCmUC29lWrgdvJ6RQccX5QnSOHTrFBDQAb1 G2jGovHkEGZibL3tIwoyRoIh16ZdHQKzxiANiAV/PfuaouSZHdmtyYlgm umRzjTXSJ2Q2PilSOaCVAs1L6bqxyInhKJnb6z7GNfsj3iY+y4B48uhdN g==; X-IronPort-AV: E=McAfee;i="6400,9594,10423"; a="289562366" X-IronPort-AV: E=Sophos;i="5.93,201,1654585200"; d="scan'208";a="289562366" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2022 08:52:29 -0700 X-IronPort-AV: E=Sophos;i="5.93,201,1654585200"; d="scan'208";a="605001231" Received: from kaholo-mobl.amr.corp.intel.com (HELO [10.212.97.86]) ([10.212.97.86]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2022 08:52:28 -0700 Message-ID: <5caffe2a-f5a6-e312-a564-5fe29c4e2323@linux.intel.com> Date: Fri, 29 Jul 2022 10:52:28 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.11.0 Subject: Re: [PATCH 2/5] soundwire: sysfs: cleanup the logic for creating the dp0 sysfs attributes Content-Language: en-US To: Greg Kroah-Hartman Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Vinod Koul , Sanyog Kale , Bard Liao References: <20220729135041.2285908-1-gregkh@linuxfoundation.org> <20220729135041.2285908-2-gregkh@linuxfoundation.org> <9365e038-2146-98f8-f989-02827f221c34@linux.intel.com> From: Pierre-Louis Bossart In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>>>> diff --git a/drivers/soundwire/sysfs_slave.c b/drivers/soundwire/sysfs_slave.c >>>>> index 83e3f6cc3250..3723333a5c2b 100644 >>>>> --- a/drivers/soundwire/sysfs_slave.c >>>>> +++ b/drivers/soundwire/sysfs_slave.c >>>>> @@ -174,6 +174,16 @@ static ssize_t words_show(struct device *dev, >>>>> } >>>>> static DEVICE_ATTR_RO(words); >>>>> >>>>> +static umode_t dp0_is_visible(struct kobject *kobj, struct attribute *attr, >>>>> + int n) >>>>> +{ >>>>> + struct sdw_slave *slave = dev_to_sdw_dev(kobj_to_dev(kobj)); >>>>> + >>>>> + if (slave->prop.dp0_prop) >>>>> + return attr->mode; >>>>> + return 0; >>>>> +} >>>> >>>> This changes the results slightly by creating an empty 'dp0' directory >>>> with no attributes inside. >>>> >>>> Before: >>>> >>>> [root@fedora ~]# cd /sys/bus/soundwire/devices/sdw:3:025d:0714:01 >>>> [root@fedora sdw:3:025d:0714:01]# ls dp0 >>>> ls: cannot access 'dp0': No such file or directory >>>> >>>> After: >>>> [root@fedora sdw:3:025d:0714:01]# ls dp0 >>> >>> That should be fine, tools should just be looking for the attributes, >>> not the existance of a directory, right? >> >> The idea what that we would only expose ports that actually exist. >> That's helpful information anyone with a basic knowledge of the >> SoundWire specification would understand. > > Is "dp0" a port? If so, why isn't it a real device? The SoundWire spec defines the concept of 'data port'. The valid ranges are 1..14, but in all existing devices the number of data ports is way smaller, typically 2 to 4. Data ports (DPn) are source or sink, and there's no firm rule that data ports needs to be contiguous. DP0 is a 'special case' where the data transport is used for control information, e.g. programming large set of registers or firmware download. DP0 is completely optional in hardware, and not handled in Linux for now. DP0 and DPn expose low-level transport registers, which define how the contents of a FIFO will be written or read from the bus. Think of it as a generalization of the concept of TDM slots, where instead of having a fixed slot per frame the slot position/repetition/runlength can be programmed. The data ports could be as simple as 1-bit PDM, or support 8ch PCM 24-bits. That's the sort of information reported in attributes. >> The attributes are really details that few people/applications would >> understand, and unfortunately the information reported in DSDT is more >> often than not complete garbage. > > I don't understand what DSDT is, or how it is relevant here :( Platform firmware typically exposes the presence of ports and the details since there are no descriptors in hardware. The DSDT in ACPI exposes _DSD properties under the SoundWire device scope, which are compatible with DT properties. In other words, what the driver exposes in sysfs is just a mirror of what was reported by platform firmware - unless it was overridden by a driver.