Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3166112rwb; Fri, 20 Jan 2023 12:08:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXt0raqaK8faxi312CwnT/PIVFT+aDCdwTb4f6TC+txIO+fkus8iLxK4pYfcjWPMyCw6lSlC X-Received: by 2002:a17:907:86a5:b0:870:d4f3:61b3 with SMTP id qa37-20020a17090786a500b00870d4f361b3mr21653927ejc.12.1674245298097; Fri, 20 Jan 2023 12:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674245298; cv=none; d=google.com; s=arc-20160816; b=yvLL0reIVsgEIeAOzsTPyhXwR/2SPRiCbnyFEv9+kJr/m+n/Ea86zJEYfmwW7BJZwv 2FEu7OagiQy2oyy4249vmiShWdLFnmYGD01YGPtdfRgCCITFKZeScW/g3WEWhtG0endD wp6wc9ykZxqDXOV1n2QFG5vCmu1GsbsZJ6VyfmmS6ln5Q0s1T+NHQpfAWxlQaF8B3KQO nVdmwAz/yf8iC3450SP6sPVHmXWoYdX8m/NGjsNzRsrg8EH/MZ/Zty0Xn1pcuYzxCe1y pOFONv6r4zMqP7oZzxbi1gzcCUuQGGbNMNBIL8AsluTqWENKOJHyGZ6iPjzMHRvsEadM 8oxA== 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=iKGnDqBz7ezSdhhYcfCRH9meiz3agvn9lXeaxym2/2w=; b=jts9Rjhg4GV5tvru1aJ2BYOuO6xGxKK5DvBr7NUGqAghOOKZcQRTTZmmtNuMdOcEVV EMW1n47Gn3OAf81cObSVEYT3KOlbiHYoVDqRRQ7t4PcMIxgTyv2rySmjQQUW2HpdPc+n DaaB6EWbtKgW8Z99Et54xeFnSgsjzdN0zj0WGkYGRgQzVTZrHvapuZtdWA85Rpy/HJBE 4MClhvAJ0AEoXx3BLMZJp27+B+fxSXMn0qxNy3LZIrq10TSVl/uZN6fKvhOzcOb8fHCd QsHklediNHXK6wXWha2jl1aUkGMNjr2tSCjGIf7Qymayscg3UF4hpXmxrHTpkZsAH+jt LRFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gQX+Yqgl; 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 cr11-20020a170906d54b00b00877a67bb40esi2070161ejc.803.2023.01.20.12.08.05; Fri, 20 Jan 2023 12:08:18 -0800 (PST) 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=gQX+Yqgl; 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 S230228AbjATTQv (ORCPT + 50 others); Fri, 20 Jan 2023 14:16:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230121AbjATTQn (ORCPT ); Fri, 20 Jan 2023 14:16:43 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF5E59D291 for ; Fri, 20 Jan 2023 11:16:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674242202; x=1705778202; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=8RxJmJCTilGnrtWWSCiuVo11UCJbpns4JVnRmQGbTTw=; b=gQX+YqglSUNmX5l/371/tI2AFw4+L2nbgs50sGseHU91Wsqx/nQ6ndAe /ibr5aTh2983ukUjjcVPWPK0SPwaMxDfYircqICIz/SaANXQ4CumQYxy8 0GEG7QZkubLqlxHX/pyJvch4heaTwjjfQleRyS0f9AZiKB+NCeG255dm2 im/l6TKOzTjx0EtZUoMS1aRgk0BbqS9H6kT3FUiF806Jp58UcYo+msa8N hzLo/4vQLQVpWy0lPy08eOZDePkKDDtor1s9t+YQTgDDz8AO70dthvFzO ygkEM3QbocKSpDdmyeefiIZA5eFrJCZGBqE8TtKAd3Izfj4SVIGm+Nirg w==; X-IronPort-AV: E=McAfee;i="6500,9779,10596"; a="388026929" X-IronPort-AV: E=Sophos;i="5.97,233,1669104000"; d="scan'208";a="388026929" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2023 11:16:42 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10596"; a="691156080" X-IronPort-AV: E=Sophos;i="5.97,233,1669104000"; d="scan'208";a="691156080" Received: from gallegos-mobl1.amr.corp.intel.com (HELO [10.212.24.2]) ([10.212.24.2]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2023 11:16:41 -0800 Message-ID: <881088ad-95d7-2462-20d2-72a6a9d3ba68@linux.intel.com> Date: Fri, 20 Jan 2023 10:20:50 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.4.2 Subject: Re: [PATCH 2/2] soundwire: bus: Allow SoundWire peripherals to register IRQ handlers Content-Language: en-US To: Charles Keepax Cc: vkoul@kernel.org, yung-chuan.liao@linux.intel.com, sanyog.r.kale@intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com References: <20230119165104.3433290-1-ckeepax@opensource.cirrus.com> <20230119165104.3433290-2-ckeepax@opensource.cirrus.com> <20230120095941.GL36097@ediswmail.ad.cirrus.com> From: Pierre-Louis Bossart In-Reply-To: <20230120095941.GL36097@ediswmail.ad.cirrus.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, 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 On 1/20/23 03:59, Charles Keepax wrote: > On Thu, Jan 19, 2023 at 11:12:04AM -0600, Pierre-Louis Bossart wrote: >> No objection on this addition, just a couple of comments to improve it: >> >>> EXPORT_SYMBOL(sdw_bus_master_add); >>> @@ -158,6 +183,8 @@ static int sdw_delete_slave(struct device *dev, void *data) >>> mutex_lock(&bus->bus_lock); >>> >>> if (slave->dev_num) { /* clear dev_num if assigned */ >>> + irq_dispose_mapping(irq_find_mapping(bus->domain, slave->dev_num)); >>> + >> >> could this be done conditionally. e.g. >> >> if (slave->prop.irq) >> irq_dispose_mapping(irq_find_mapping(bus->domain, slave->dev_num)); >> >>> + slave->irq = irq_create_mapping(bus->domain, dev_num); >>> + if (!slave->irq) { >>> + dev_err(bus->dev, "Failed to map IRQ\n"); >>> + return -EINVAL; >>> + } >> >> ...and here.... >> >> if (slave->prop.irq) { >> slave->irq = irq_create_mapping(bus->domain, dev_num); >> if (!slave->irq) { >> dev_err(bus->dev, "Failed to map IRQ\n"); >> return -EINVAL; >> } >> } >> > > Yeah I am happy to make those conditional, I guess it is cleaner > to not map IRQs if they wont be used. ok > >>> @@ -369,6 +371,7 @@ struct sdw_dpn_prop { >>> * @clock_reg_supported: the Peripheral implements the clock base and scale >>> * registers introduced with the SoundWire 1.2 specification. SDCA devices >>> * do not need to set this boolean property as the registers are required. >>> + * @irq: call actual IRQ handler on slave, as well as callback >>> */ >>> struct sdw_slave_prop { >>> u32 mipi_revision; >>> @@ -393,6 +396,7 @@ struct sdw_slave_prop { >>> u8 scp_int1_mask; >>> u32 quirks; >>> bool clock_reg_supported; >>> + bool irq; >> >> this can be confused with the 'wake_capable' property. >> >> maybe 'out_of_band_irq' ? >> > > Yes I struggle on the name a bit and then just gave up and > went with plain "irq", hard to know what to call it. Not sure > out_of_band is quite right since it not really out of band, > handle_nested_irq pretty much basically boils down to a function > call really. Maybe something like "map_irq", or "use_domain_irq"? Naming is hard. I use 'in-band wake' for SoundWire-based notifications, so I used 'out-of-band' for non-SoundWire stuff. use_domain_irq sounds goods to me, it's different enough that confusions are not possible. >> There should be an explanation and something checking that both are not >> used concurrently. > > I will try to expand the explanation a litte, but I dont see any > reason to block calling both handlers, no ill effects would come > for a driver having both and it is useful if any soundwire > specific steps are needed that arn't on other control buses. I think it's problematic if the peripheral tries to wake-up the manager from clock-stop with both an in-band wake (i.e. drive the data line high) and a separate GPIO-based interrupt. It's asking for trouble IMHO. We spent hours in the MIPI team to make sure there were no races between the manager-initiated restarts and peripheral-initiated restarts, adding a 3rd mechanism in the mix gives me a migraine already.