From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96E95C004D4 for ; Thu, 19 Jan 2023 17:15:02 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E7EE034DE; Thu, 19 Jan 2023 18:14:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E7EE034DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1674148500; bh=3PfvGA6LG6n0VOKqUA3+pvpEy/KwfivVBi7XGfFWq54=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=extoCNf6dU1hv3gwIa931ZZiEt4tlcA+RP8PJuRn21P9J+5e0oHFt7RsqCnwbgX6I YLBM4DuMpQ6v443UFHN1bHPlzy2fTDyK+QLnkDhApL+FTJmouuWlS/zyPWUeQy0ikQ rxIuesMp134H+0Au5nGRtVZpgIlQPWf6ePW+4q1Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9DA66F8025D; Thu, 19 Jan 2023 18:14:09 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E9C85F8047B; Thu, 19 Jan 2023 18:14:08 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id ABCE0F8024D for ; Thu, 19 Jan 2023 18:14:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ABCE0F8024D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=nfPsGYXD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674148447; x=1705684447; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=3PfvGA6LG6n0VOKqUA3+pvpEy/KwfivVBi7XGfFWq54=; b=nfPsGYXDmH1FjvuPLbzsuokKBSyMOQeOEmPlUGKMumztSABD99rDpugS IVx5AGxSUeGeCwRrVVu3LvzQqIGjsYRch6cBKAxiXBTAmNcNmQoOe7uuM 8wj09q9+vBZ59tNPMlFm/4TlIw/51Rig5BjeW2GH/G/LVPh907iDm32Wn k60EDvf1k6Crl5rUzFzfuaIraI8Wnb/ivLWsHtnBxhl5sMX8nfPfN7/aV JqxLHPOqCoh+Z1MGTBJgxDitPgVD2CdyX93XlswTIusBjc1aGWRrfY8PL 55LCkNny3asznfFBAyMS+qYpRbk1n6slZhgJ3IRjBoHaLsl9B84lTlYV+ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10595"; a="325391661" X-IronPort-AV: E=Sophos;i="5.97,229,1669104000"; d="scan'208";a="325391661" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2023 09:12:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10595"; a="728786641" X-IronPort-AV: E=Sophos;i="5.97,229,1669104000"; d="scan'208";a="728786641" Received: from sahamad-mobl1.amr.corp.intel.com (HELO [10.213.187.97]) ([10.213.187.97]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2023 09:12:05 -0800 Message-ID: Date: Thu, 19 Jan 2023 11:12:04 -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 , vkoul@kernel.org References: <20230119165104.3433290-1-ckeepax@opensource.cirrus.com> <20230119165104.3433290-2-ckeepax@opensource.cirrus.com> From: Pierre-Louis Bossart In-Reply-To: <20230119165104.3433290-2-ckeepax@opensource.cirrus.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@opensource.cirrus.com, sanyog.r.kale@intel.com, yung-chuan.liao@linux.intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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)); ... > clear_bit(slave->dev_num, bus->assigned); > if (bus->dev_num_ida_min) > ida_free(&sdw_peripheral_ida, slave->dev_num); > @@ -178,6 +205,9 @@ static int sdw_delete_slave(struct device *dev, void *data) > void sdw_bus_master_delete(struct sdw_bus *bus) > { > device_for_each_child(bus->dev, NULL, sdw_delete_slave); > + > + irq_domain_remove(bus->domain); > + > sdw_master_device_del(bus); > > sdw_bus_debugfs_exit(bus); > @@ -717,6 +747,12 @@ static int sdw_assign_device_num(struct sdw_slave *slave) > slave->dev_num = dev_num; > slave->dev_num_sticky = dev_num; > new_device = true; > + > + 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; } } > } else { > slave->dev_num = slave->dev_num_sticky; > } > @@ -1682,6 +1718,9 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) > struct device *dev = &slave->dev; > struct sdw_driver *drv = drv_to_sdw_driver(dev->driver); > > + if (slave->prop.irq && slave->irq) > + handle_nested_irq(slave->irq); .... that would be consistent with this conditional use. > @@ -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' ? There should be an explanation and something checking that both are not used concurrently.