Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2311546rdb; Wed, 21 Feb 2024 03:59:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXTB/vZy2FyPtE7Ox1e4OzwWf3QlwLe6XgxSmph8KlmlYMAoL75S5JfxozoqBolo8Okmo6Zy9YYlsmJaomxExrUAyHJYODl/F59JZTT6Q== X-Google-Smtp-Source: AGHT+IH9yBJrHm50qy9u09h49AA84M3eJzIbvh+JZX5JGAb3e9RqDvmuuOhWmQdrF7EsI7tZYxau X-Received: by 2002:a0c:e34f:0:b0:68f:5d39:5d9f with SMTP id a15-20020a0ce34f000000b0068f5d395d9fmr9745481qvm.55.1708516774809; Wed, 21 Feb 2024 03:59:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708516774; cv=pass; d=google.com; s=arc-20160816; b=ZllPcnO8s23zTU1/DPSdgUihPVl8P2h8HeMbht4J4KM/s2K7PyqxOhEZzuxwENL/Vd PhZZDJ78dp/1cAMpZTEj9Fh+VJfG+nSOi7vejJweTJhAbEJM5K6ZfNq/CWcHNqMH4Rq8 5nwDlgHLbrNLKQ6M7mt5OltMnIW40+hGvR8b6sHRHO0uEhxeQycjWhbD9Rl35nAWJrGC TP8p/eF+7LRNU40CpcmkRCPr2ODSe1hC68JMOJhHqtl6CPhKtX5XdxLm17c4QMxVVuLW tox46JDvKGeGG3kCK65rGzF1ZkNSEN5tcQZZXnAxIJNfuWPHgQViKSpoiTPpU72Ddi// vW0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=J2b7jJYfNIqBQdIx+fbpx4stlgr3/b4dMyKFK9QrHvU=; fh=HnfsOTxl37B17MrABL8pqAX6uHYSqDh2XRcNOgN5Exw=; b=ZGiMs7Wb5DUJeUo8IbLARQzPCOJnoZSMfXaCzDFqtl0bPau8KY4yc1ebU0qx7MBf7i HO3iep0FWjUzt229e4Mv3DfQpzjQ0TjkhvEYVhFctPiahZM58TAGiMxV64XEntQ/VqKs BLiLA/pOqTln8KZ/AaIteUWfemL1iMUasxngPw5hsvvpKUYozNhVmlORj6qZkFqRgHGb c3Zai7Vjscf4Uzvm2xRcmCZCXvlUXMpzncJsj/1/siSOUyJYioPXRGXSpu+mFA5AWOav EOSL/vQljiTcGwnP5BiNjB0r44v/OdhxENV8rIa4tBdOiemMTdjCzvWWjIl833Wv9jkt sFSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b7osNXPc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-74671-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74671-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jl14-20020ad45e8e000000b0068f8b839896si4331045qvb.472.2024.02.21.03.59.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 03:59:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74671-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b7osNXPc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-74671-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74671-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7F7251C22A2F for ; Wed, 21 Feb 2024 11:59:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94A4B48CDD; Wed, 21 Feb 2024 11:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b7osNXPc" 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 BD19247A7A; Wed, 21 Feb 2024 11:59:26 +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=1708516766; cv=none; b=iYgVt52ESAbXWF/ysuRgBTystn0elpTHtgIr1V9O1QCVWN5QwTvnB738H3FuMZuOCsQBa3H4JlnRkn6t74aWx/XbywiXN4YD9erdE+0uthmKlMhxfD/iwIIhIwSsqTCRcZRdw36Rpaxp/Tj36H+cycuU8ef6q5rrgiD9kmXc46U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708516766; c=relaxed/simple; bh=icr+Ws7AdDS8MhLtU6pYh5gnTY6nWC5oeWHCPgrtqac=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=owZQUFcjHJzMR21BziImQjc1qzp2qJldyEQKiR1AfAqrWiKL94Mg8gohEQNB/JxZfWSGjXUcIv+JmeVkk3HFprioRS/d4jcJjLDjYaiBo8y8tGmQX/V9h1lhSyX4yYrKr+w1DcaZWZv/X+Tuq9gu0P+e+ARnLFXz2VTzCBXzkGY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b7osNXPc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7916C433C7; Wed, 21 Feb 2024 11:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708516766; bh=icr+Ws7AdDS8MhLtU6pYh5gnTY6nWC5oeWHCPgrtqac=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=b7osNXPcai2BCK0LMvdyyVsWjG8RLcrHGFG+6UbibZYadg2QRj/Z1m97e21ExmSir oaIgimntM9xsZx7LwugvwJsbiyP9wjgCgJSNyamLpQLD7IrsCp8fKlSbI1jcVV9xK7 /D/P9Ly3/hwyJZQ8oVUDUNDuX/4NNKz7dH9hcOCb8gtPFRnNDAQ/7o5Mzn3WZ3D6Ar MrNWSLpU4k9tIZNkBl5aK6z5RH8wg7h/2beqT0F9JWnbT6MdTJg0UONe6QvH1yBlB3 UgAhnRaDhOuDIPN84qqxS/sEjIi+j0qodNBdSHukYfN5Z7CLZTEJj4kuVpL1WW7hU3 klWq4Xxg8m6qw== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Anup Patel Cc: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley , devicetree@vger.kernel.org, Saravana Kannan , Marc Zyngier , Anup Patel , linux-kernel@vger.kernel.org, Atish Patra , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Andrew Jones Subject: Re: [PATCH v13 06/13] irqchip: Add RISC-V incoming MSI controller early driver In-Reply-To: References: <20240220060718.823229-1-apatel@ventanamicro.com> <20240220060718.823229-7-apatel@ventanamicro.com> <87frxnfj3p.fsf@all.your.base.are.belong.to.us> Date: Wed, 21 Feb 2024 12:59:22 +0100 Message-ID: <874je2yqn9.fsf@all.your.base.are.belong.to.us> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Anup Patel writes: >> > +void imsic_vector_mask(struct imsic_vector *vec) >> > +{ >> > + struct imsic_local_priv *lpriv; >> > + >> > + lpriv =3D per_cpu_ptr(imsic->lpriv, vec->cpu); >> > + if (WARN_ON(&lpriv->vectors[vec->local_id] !=3D vec)) >> > + return; >> > + >> > + /* >> > + * This function is called through Linux irq subsystem with >> > + * irqs disabled so no need to save/restore irq flags. >> > + */ >> > + >> > + raw_spin_lock(&lpriv->lock); >> > + >> > + vec->enable =3D false; >> > + bitmap_set(lpriv->dirty_bitmap, vec->local_id, 1); >> > + __imsic_remote_sync(lpriv, vec->cpu); >> > + >> > + raw_spin_unlock(&lpriv->lock); >> > +} >> >> Really nice that you're using a timer for the vector affinity change, >> and got rid of the special/weird IMSIC/sync IPI. Can you really use a >> timer for mask/unmask? That makes the mask/unmask operation >> asynchronous! >> >> That was what I was trying to get though with this comment: >> https://lore.kernel.org/linux-riscv/87sf24mo1g.fsf@all.your.base.are.bel= ong.to.us/ >> >> Also, using the smp_* IPI functions, you can pass arguments, so you >> don't need the dirty_bitmap tracking the changes. > > The mask/unmask operations are called with irqs disabled so if > CPU X does synchronous IPI to another CPU Y from mask/unmask > operation then while CPU X is waiting for IPI to complete it cannot > receive IPI from other CPUs which can lead to crashes and stalls. > > In general, we should not do any block/busy-wait work in > mask/unmask operation of an irqchip driver. Hmm, OK. Still, a bit odd that when the .irq_mask callback return, the masking is not actually completed. 1. CPU 0 tries to mask an interrupt tried to CPU 1. 2. The timer is queued on CPU 1. 3. The call irq_mask returns on CPU 0 4. ...the irq is masked at some future point, determined by the callback at CPU 1 Is that the expected outcome? There are .irq_mask implementation that does seem to go at length (blocking) to perform the mask, e.g.: gic_mask_irq() which calls gic_{re,}dist_wait_for_rwp that have sleep/retry loops. The GIC3 ITS code has similar things going on. I'm not saying you're wrong, I'm just trying to wrap my head around the masking semantics. > The AIA IMSIC spec allows setting ID pending bit using MSI write > irrespective whether ID is enabled or not but the interrupt will be > taken only after ID is enabled. In other words, there will be no > loss of interrupt with delayed mask/unmask using async IPI or > lazy timer. No loss, but we might *get* an interrupt when we explicitly asked not to get any. Maybe that's ok? Bj=C3=B6rn