Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp35730lqb; Tue, 28 May 2024 08:12:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWCT3uF0x1o2iptPmQ2BxXSJEPrZNZreBzo/5NlV6xsUNEXPoY2Zx+KxxqhKEs2UhXxuKoL2FK2v3cp8QKfpEgCsHwsCNBqMZdx80eS0w== X-Google-Smtp-Source: AGHT+IF/W8Y7wXiCZmQgAetUj5uXpVEk2JYYxIH3fLhG7WRdvFKwIishhA0I1lQieLpwd236Y2EN X-Received: by 2002:a05:6359:c29:b0:192:4dd2:2b49 with SMTP id e5c5f4694b2df-197e50c3c2fmr1349473555d.4.1716909124782; Tue, 28 May 2024 08:12:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716909124; cv=pass; d=google.com; s=arc-20160816; b=l12Tqt6RoJnLIzNf3EPdC0Vy5iluDTPD1y9qov8VKAwQMrbj6BPuuwylxtyfTpqZI7 MfHOxYr2au9y5tLcDTsbLNGHq+4YcYD90153PLjeJHq9y/pXe0laaPWI/zcaH8+gM8Cm tGPD87NNFK7ct+cKIS4wkaK3xwB+u7r0Fs+UGl5KDMznJUGeAlvzLx1xUeHTGEWkELZY XT6d66TWgGsXcVQfZM8M7jXY0zLeLACBSf0Zpnq2X1tnoqciAeua4ih/AEegntXFdcXf Di63GMf8KCVLo5hLbqqK5V4EnhVKwR67uxkH19GjdaQPtbtEOeWmlEE9J9NZFu+THQrO l2eA== 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:subject:cc:to :from:dkim-signature; bh=k0AGpQFir7bYkY6Hm/qOL+w8L3+MGNDSpFH+GMgURdQ=; fh=T1MXX9gFw/OElNn9gIFc2JAypEM4NBjBL5eD9xHp51Y=; b=L/EGGUhaOCTwSBEBqf+FYIQ+mnZp09Yorl28SilhtO1sX41SVX02DPO2mr7tU2xs25 0uJft1olE8D0hlSnc6S7b5KOB11l3al5dcp3L79j29ZFfggsd6wIi+kAjKdqhohUuZCN aYS6l0KTxnTUw7JTordITxYoZ/rzf2tV9CNPmjPfRi6Vgav9zf7mKACMht/ZqON/27ps kGQwFskGLQqxPTrRF765Ltm9mXH/oP2reAIyYhthxbqxUpc4paa9PwgyzYdViuMrE9Qu p9iAGuc6UdN5rQACjEw+TfQoWDKdvuzOhQBhGHjD4dYf1P0pP9rW2Fo8vOl91hnZY4PH dI7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="m7/NlM3S"; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-192625-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192625-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794abd3e1c7si1001780685a.529.2024.05.28.08.12.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 08:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192625-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="m7/NlM3S"; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-192625-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192625-linux.lists.archive=gmail.com@vger.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 7F95C1C22D75 for ; Tue, 28 May 2024 15:12:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67B88171651; Tue, 28 May 2024 15:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="m7/NlM3S" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E17817106C for ; Tue, 28 May 2024 15:10:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716909058; cv=none; b=EsVf6IbVfIpim6KAcPJUAxnfJb1GY6ha/w4en1diy29T/1qdpZjyHPjzMtiMvwohtwcfVDhmxP1KH0irJrFul1fUVpjFIGdjqNoYMbhQ8cXv135yOaPDzjs417CpS9USI4Tz/6t3rkN2JOEB1k+ZtsF43qhaZAaQMbqklqfaXyM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716909058; c=relaxed/simple; bh=CJR5ijuAPP0OxGC2o3LndPnStx7BgQTf9sVBO3oNvzo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Ke0jrh5/IUdKxzDYZ4qIxFW6TPUV0Q669yEqOU6qDfCCD2atmORC7Lp2lyGeCmbspwdgKPOPr4w+Gd9ouB6s7HI7CNqHyewfQrKoo+3usrlzar/uJGPmX2Txo54u4u5vv2S8E+2797TFQL6axu+en3wwAOUNo+7TchyjjGreB/U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=m7/NlM3S; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-42101a2ac2cso7738145e9.0 for ; Tue, 28 May 2024 08:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1716909055; x=1717513855; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=k0AGpQFir7bYkY6Hm/qOL+w8L3+MGNDSpFH+GMgURdQ=; b=m7/NlM3SphncbkbnwVkDjnP9JpIRjqVX89ff5dRcH0RkRw7lXcjxigQcCZa7prbWje almcX48vDmdlcWGaA1L6APIwY6fXRs+p/oUpW6MHwRz2N8v52uAh7e1zwAHu8LnjaLWE F5j13D/UKuVIeTnPYGG370f78BrGISkWKjQ31ZF26YvN88IkIIoMiJ+I35JOL8zJbIPh z07WreENbZHzt3Vd8KEkKhYKO3h5TTfQ0woJyalKc7+di4j/JYUh/9gY5v7nqsug+UNa zvAXPjwqBoxac8zpbuD0oKvhoLa9BD8Hf79FmfgvIaBA+1hObTptoaAOsVR6JGSZD++f RPiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716909055; x=1717513855; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=k0AGpQFir7bYkY6Hm/qOL+w8L3+MGNDSpFH+GMgURdQ=; b=gEWQYr0rlQ0YW4bYW9cMkvRoMGFpTVVInqiwwkyy0I+b2QJPZ7bvjy+JjlqM3+B3Tn cmfc/Em37KAqO1BUf3eHUPcj2R1IzKGyEkEVmrQGR5KgDsuZf6u2XFBLZrN6qxSh3Gju hVv8OyrI5ALrqtUgtthuNtkT1bG+m7DcbS+0AVLYO3UjNWcr+qkicL13FVYxRiTvAr2l x7u09cZQg9GwRuHpq8soReGuNs1CTmbphxjrxgSoYBCZO/PdvrxqahRNbhRJKvMtY7lH t3sD0TPlbpYHmvMr0coe5Xamv8iwNbizVT42Qqi+wrYXWAmavSYo7EGZy0/v3Y+dg0yG xVtA== X-Forwarded-Encrypted: i=1; AJvYcCXIvNpSv36goPR5GMwV4xwaWNI2xuEm47aawRKveZmdUJsJz4Xr1rLtPZ4GZoKL+XtNv0gMMSxlqF1T2SBH6Q9tyrhHxOpSg6Yu4nvy X-Gm-Message-State: AOJu0Yy/FwiTB9t6ac5888JgI5CCvAbmS8nlSnNjK/67/Np6qQSi+Ld1 bINw3yWrZkc9vceyEOqCPd10GXSjKIP4SQNfSX0RURVa1giljHE/G5WX1cY4akY= X-Received: by 2002:a05:600c:4703:b0:420:1fab:1798 with SMTP id 5b1f17b1804b1-421089fe2c2mr95474985e9.29.1716909054785; Tue, 28 May 2024 08:10:54 -0700 (PDT) Received: from alex-rivos.home (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35579d7da64sm12293475f8f.4.2024.05.28.08.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 08:10:54 -0700 (PDT) From: Alexandre Ghiti To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Arnd Bergmann , Leonardo Bras , Guo Ren , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH 0/7] Zacas/Zabha support and qspinlocks Date: Tue, 28 May 2024 17:10:45 +0200 Message-Id: <20240528151052.313031-1-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This implements [cmp]xchgXX() macros using Zacas and Zabha extensions and finally uses those newly introduced macros to add support for qspinlocks: note that this implementation of qspinlocks satisfies the forward progress guarantee. Thanks to Guo and Leonardo for their work! Alexandre Ghiti (5): riscv: Implement cmpxchg32/64() using Zacas riscv: Implement cmpxchg8/16() using Zabha riscv: Implement arch_cmpxchg128() using Zacas riscv: Implement xchg8/16() using Zabha riscv: Add qspinlock support based on Zabha extension Guo Ren (2): asm-generic: ticket-lock: Reuse arch_spinlock_t of qspinlock asm-generic: ticket-lock: Add separate ticket-lock.h .../locking/queued-spinlocks/arch-support.txt | 2 +- arch/riscv/Kconfig | 35 ++++++ arch/riscv/Makefile | 21 ++++ arch/riscv/include/asm/Kbuild | 4 +- arch/riscv/include/asm/cmpxchg.h | 114 ++++++++++++++++-- arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/include/asm/spinlock.h | 39 ++++++ arch/riscv/kernel/cpufeature.c | 1 + arch/riscv/kernel/setup.c | 18 +++ include/asm-generic/qspinlock.h | 2 + include/asm-generic/spinlock.h | 87 +------------ include/asm-generic/spinlock_types.h | 12 +- include/asm-generic/ticket_spinlock.h | 105 ++++++++++++++++ 13 files changed, 336 insertions(+), 105 deletions(-) create mode 100644 arch/riscv/include/asm/spinlock.h create mode 100644 include/asm-generic/ticket_spinlock.h -- 2.39.2