Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp145075lqt; Mon, 18 Mar 2024 04:18:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFsgiFhPOcpXK++axPzPERxV72RxnEdRtVdD23IIvNUCi14vlCiaD0VlIRZLZplhwNLrMQREYijJ0kwsbbE3LIs9K4g2M1QF56ZrV2Pg== X-Google-Smtp-Source: AGHT+IFYW6obvwwTfWWiBeQ7lNDtyhNENtsu62lPQKjRAg9AuQGN3RFn//fYONnVd97B0MdU8P// X-Received: by 2002:a17:90a:8685:b0:29a:e0bc:4a9b with SMTP id p5-20020a17090a868500b0029ae0bc4a9bmr9936837pjn.16.1710760723712; Mon, 18 Mar 2024 04:18:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710760723; cv=pass; d=google.com; s=arc-20160816; b=ysK4LfTCREstnzRKMndUOWgVg2kKXKDPXutKNkf5vChvC1+PGX7DMHuIszLE/6KE1J OVasC4MDqA+HmKf9P9hlSGCvLUyVX2zvQHYs2sO8UrDToYbowAwy8F6Z8BrQR/BUdyZ4 3qCGPknC+GtotLDXsHVLwBv0b9K/O5etYBTsBz9Y2lDTR4M7FOHBJZmS3fNK6qEsDjZi wyD4DoUncXdbBXVNSXzHAYugwGTA6t1hGX58cQkxLFTCLgfcbqU69DGh+fcNwmt3P3ri 9oo07/F4D0aXnS3C8D3Mwixa0rC49EyaAZUdOWtwejyzM0Xnr7q1iyusyzqjUQLB0cfc YWXQ== 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:dkim-signature:dkim-signature:from; bh=gvIggp9l8ynrqFOvlVbqfquG9gIGDPBk0SZBCYKXfbU=; fh=dUBKQalt+inm4mVnrYKUvfUmt1EtjdyZPkuKGn7WgrI=; b=nl/dVmxAEJ9FOZPwjF0jHqz+mFFpI9N9HDlXvc9U0ypfoQpyFGthmv52BeYYXMCDmJ ittGP+am5Q5Tmvg59oBbIkVoegL/OEuIHeNhX1vbghBxuLYOjYxQ71S3yHwR2O0gxLdF 5LIIsnqsIXjgQWCn9YmveAfPQTJsNY8Qsd2xwZum8NpbXc0na4y8dsJ91VcpLOUaHm/z ycWptMHmH0ebdnsvgbKRGziSTUZjMyShjMPJfPZAF+C3ULSC/QcacdKVjkK46YEgcpHR MEeZSekPe7Xxb7I56Mup79DiJyvayBCnwvyOyKoSJvcEQUbVB7xDSw36AJIU4plt2phV wtvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lMZaw6oQ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-106052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106052-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n16-20020a17090ac69000b0029b03b22b1bsi7864678pjt.125.2024.03.18.04.18.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 04:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lMZaw6oQ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-106052-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106052-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6236728274D for ; Mon, 18 Mar 2024 11:18:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5136537162; Mon, 18 Mar 2024 11:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lMZaw6oQ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Ns21CzD8" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 1BC4A364C0; Mon, 18 Mar 2024 11:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760709; cv=none; b=pmPeod7ZmFa/K+2p8rAxtYq5hmg11H463WssbB4MB09KeGapmdySpW1a98FKohaU+AWdmWxq4aT94WkgR+/bK3E/Xpg5c9a0eTtz/ZUFlgqmIPlJJSousJsVOl5IZuoFRJkddr3aFqXFrpwGoWS0JRP7D73IdOP6k3f3sLON43Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760709; c=relaxed/simple; bh=mrxJiPMIzd1108cDGaKA2JQTQvRqDxwh+7+B6ymHd2Y=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=J5x+1/7ggtDwC/msf14t2MRaYZG+8YFr06XboZxtCzPsMMy1oP3tIiUgiWeTnEm89QD2gK8GCjUFsy4Lwo0vrHsldVEUQFsdU7N0g6JL9VegvgtYKl1F7a3EeSwdCkBmqTFxcArPdJzPxcNeHooZxA3oc3I3qLwWCSG/H1IzGy4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=lMZaw6oQ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Ns21CzD8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1710760706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gvIggp9l8ynrqFOvlVbqfquG9gIGDPBk0SZBCYKXfbU=; b=lMZaw6oQ1fHGFGfKXCbfbhQRu7naS85vR947W3thfkBD4nW96p4X1auZ0a2fcRXnpsApw0 f+UsUpnhrmvCbwvtaJIvjMEmVL6T9gPBGcPUtZm+q5NQ9cgapVCvmBRpQl7WiiuTT9jIty ZCB8vqzv8d7U5eu4EEonzAxX1iKaSdRqMIYx5ldBORa8KwirkFyxJc8fQ5FptnJyzcax/U WhuNaT6bxPBVSeDLROBwyarp0PjPfAm8PF0oy+iUkeiMhw1vlcU1Yb3HDp8oIAXbAP/9pD FFFJg/fq3N6sg/Pjceqby7CB1jSNBLGUvTZRYh9PXM76nKzBRK8bYqQvBmEcNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1710760706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gvIggp9l8ynrqFOvlVbqfquG9gIGDPBk0SZBCYKXfbU=; b=Ns21CzD8Yfb/RqS9JQPTBOvmfNr2KLQ+6eTddGTLI5Jdh2G94eMwmSkVj9GoMc9QotccU9 EqE3VMvo5z562IBg== To: Christophe JAILLET , Tianyang Zhang , chenhuacai@kernel.org, jiaxun.yang@flygoat.com Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Baoqi Zhang , Biao Dong Subject: Re: [PATCH V2] irqchip/loongson-pch-pic: Update interrupt registration policy In-Reply-To: <0fda46c7-87e1-41f1-b3f0-ee3d1a4ac601@wanadoo.fr> References: <20240316082141.26139-1-zhangtianyang@loongson.cn> <0fda46c7-87e1-41f1-b3f0-ee3d1a4ac601@wanadoo.fr> Date: Mon, 18 Mar 2024 12:18:25 +0100 Message-ID: <87wmpziy9q.ffs@tglx> 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 On Sat, Mar 16 2024 at 15:03, Christophe JAILLET wrote: > Le 16/03/2024 =C3=A0 09:21, Tianyang Zhang a =C3=A9crit=C2=A0: >> @@ -171,6 +183,27 @@ static int pch_pic_domain_translate(struct irq_doma= in *d, >> return -EINVAL; >>=20=20=20 >> *hwirq =3D fwspec->param[0] - priv->gsi_base; >> + >> + raw_spin_lock_irqsave(&priv->pic_lock, flags); >> + /* Check pic-table to confirm if the hwirq has been assigned */ >> + for (i =3D 0; i < priv->inuse; i++) { >> + if (priv->table[i] =3D=3D *hwirq) { >> + *hwirq =3D i; >> + break; >> + } >> + } >> + if (i =3D=3D priv->inuse) { >> + /* Assign a new hwirq in pic-table */ >> + if (priv->inuse >=3D PIC_COUNT) { >> + pr_err("pch-pic domain has no free vectors\n"); >> + raw_spin_unlock_irqrestore(&priv->pic_lock, flags); >> + return -EINVAL; >> + } >> + priv->table[priv->inuse] =3D *hwirq; >> + *hwirq =3D priv->inuse++; >> + } >> + raw_spin_unlock_irqrestore(&priv->pic_lock, flags); > > Hi, > > not sure if it helps or if this is a hot path, but, IIUC, taking the=20 > lock could be avoided with some code reordering and 'inuse' being an=20 > atomic_t. It's the translate and setup path, so nothing to optimize here.