From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 AE0722F25EF for ; Mon, 24 Nov 2025 08:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763974678; cv=none; b=J6fIRyNc+HoZVUDJhrRjnEu5MaoZrw9gl3FFdBeTNMbG6F4WrJGov/bXa+PyST6e7ET1SpTH3yMDHK0Ba4llvR9zkPrumUFQCB4uau3KG7kSDZ7CfCWnRPBmQf1zLYFUA2KY72H0pjMv9WHaBzbVdtU638EJUcU0RS6nfr9dvVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763974678; c=relaxed/simple; bh=J2bHmerP7OUNs8ZaWTEL1a8jMCTh21nVM4RfZB6/6Og=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BQUKmFCqbolIsJL6+fm4aJvcqWzBJAwpblKlM6EWpFc2of1oG9vZ6nMa4muwDIa1Pk/5U3m30MfbTiDSfdq5sM0LPhGJNCIKGAab3dSBTC+jHOiGm0GJFUtlbsC8vjDa88fvSi3IuFHUqeEwUwjG1mX/srbXxgiOY0ODPFzDTSc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kHBmHwJp; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kHBmHwJp" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-7ade456b6abso3163082b3a.3 for ; Mon, 24 Nov 2025 00:57:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763974676; x=1764579476; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=czb3fnbBSxKZv3Zr+URuWLRc9ArEdJmn0eOeXiDBNB8=; b=kHBmHwJpO1SZcyOsAMGphfX9jdyRP8iWBPW6O25aTuM90tIMWU2HLxrMvoS6P8td8P BSSfgcmeXjjjaXLTJSh32uwEl6lHm47sqhle/DZ6ZmfugKatizzXh/1/RbxuxCno3iAz WSe50Tig1Iw02X44ICTNOatdKXkDkw77ahd9L8n61e+wx9MuxXaNHWGdKDhckLRGHJA3 a6f94j5b5cFbZyp6rcY6+jlV1r1md+DrKw0vrfOQiaG1eN9Ul1v7//H/ekXrmPCXq7Ir rvewrlLHGpg5gYzEAMwCGNxYtJJ7+aKo8Sle2DwQ17m99aZaKgeXa9FCumGknILayNzQ uZCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763974676; x=1764579476; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=czb3fnbBSxKZv3Zr+URuWLRc9ArEdJmn0eOeXiDBNB8=; b=kdpj1el0vDEcgP+iqtucUAH0hHiecd5UXxYnjZ/T97PlIrJTOrSidHGWB/aPdV0GU2 zJ3mVkbyYbdFvCxWQtHkspHK6D8BYmi0RzHm95F7YDma+G49samxbU5N45VKZK8Og+th Zm3Xkmesspc8/y+FQzeRFE+414yJxFbJMqz5OOmgE+LpCib194PX8RziXfIIYq3SbSGZ HA3/9RLqmLATDMIydNtCOgUWEtJIe4MUiWuKv+KZ8lhwD++qTUxX/xe9Ti3DdSvGm+Yq 19WWUGThRup7etqLSfo2jdU3OmRb8OihrsCoxUEoi6/LBL9X23UN7gSOv8HOcOkOYH6o jvWw== X-Forwarded-Encrypted: i=1; AJvYcCUeFd+ypwDng5DiP9Wo0QvSQvZux7gzpNNImSAQ4/Cah6Ba4WbQcW3leuMQcElbH2HnaU3F4XmOZt5+uPo=@vger.kernel.org X-Gm-Message-State: AOJu0YxtM5rQitj4sBcvQiMLyZ/fm9EqTwWTq0PgM30tKxCzcIs6zsgp WfplM4eoYSsV3L/U2LUsWVlmWyrVspL6GjNJdJrFhLMQSQooASdaukU2 X-Gm-Gg: ASbGncvQukc0JJ23Zt3jMWmh68wNjhiwcPwhJ6SS8glTCEv4udllYopyRXVZJH7qZBZ mlfXOspCJXTlK2sinLbGGsu+UD+h0JwRda0A47HOTomII8d+4hvYDDiLZ5pjKW0scQ5Ix60aPCV sy/0WIO0tNNVP3VVFzcuBN08tDvgy4biEGO9NvRHHsa3uFkfFrvCVWAI5ImlTMG7wzgcM6EBAvn M8Si0uZCnFPVYTwIwzYFiNK1vxw4suyZyr/NvJU1NN36chPhi8AUXNioWwDJeZl2XiHcYf/8D// 1MnfFURQXURaKbZrQ/cpTMY0jC0jcYHMKpmsmvoqWOhJmeCN3QwsBkhhXg4d5cnKqEu4KkthtAH QJhX5sb+CdkIo/N/Aiqjo7YODjgQaJJmRx7eNeJ2FJZNmt/tJFWWJT753gVeCyODDx2OVSvecZI ADNOnoQ6R1p9Mr2LGdhHFO X-Google-Smtp-Source: AGHT+IHFekblb7KicwQpReq80UtB03v/yPS7+MDXNbGBz9I+dfucMHhbuMp182FLflGYTFhQYw4QzA== X-Received: by 2002:a05:6a20:914d:b0:35d:3b70:7629 with SMTP id adf61e73a8af0-36150e5fe3bmr11369237637.18.1763974675886; Mon, 24 Nov 2025 00:57:55 -0800 (PST) Received: from google.com ([2401:fa00:95:201:ffba:e533:8aad:fcd5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7c3f174d2c0sm13799807b3a.66.2025.11.24.00.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Nov 2025 00:57:55 -0800 (PST) Date: Mon, 24 Nov 2025 16:57:51 +0800 From: Kuan-Wei Chiu To: Nikolay Borisov Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, bp@alien8.de, Yazen.Ghannam@amd.com Subject: Re: [PATCH v2] RAS/AMD/ATL: Remove bitwise_xor_bits Message-ID: References: <20251124084011.1575166-1-nik.borisov@suse.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20251124084011.1575166-1-nik.borisov@suse.com> Hi Nikolay, On Mon, Nov 24, 2025 at 10:40:11AM +0200, Nikolay Borisov wrote: > Both LLVM/GCC support a __builtin_parity function which is functionally > equivalent to the custom bitwise_xor_bits() one. Let's simplify the code by > relying on the built-in. No functional changes. IIRC in some cases, if the compiler decides not to inline __builtin_parity(), it generates a libgcc function call like __paritysi2(). Since the kernel currently lacks this symbol, this could lead to a build failure at link time. Although the compiler inlines it in most cases, I am not sure if using __builtin_parity() here is a good idea. Regards, Kuan-Wei > > Signed-off-by: Nikolay Borisov > --- > > Changes since v1: > > * Reworded the commit message > > drivers/ras/amd/atl/umc.c | 22 +++++----------------- > 1 file changed, 5 insertions(+), 17 deletions(-) > > diff --git a/drivers/ras/amd/atl/umc.c b/drivers/ras/amd/atl/umc.c > index 6e072b7667e9..7ff4a5a1c5da 100644 > --- a/drivers/ras/amd/atl/umc.c > +++ b/drivers/ras/amd/atl/umc.c > @@ -49,18 +49,6 @@ static u8 get_coh_st_inst_id_mi300(struct atl_err *err) > return i; > } > > -/* XOR the bits in @val. */ > -static u16 bitwise_xor_bits(u16 val) > -{ > - u16 tmp = 0; > - u8 i; > - > - for (i = 0; i < 16; i++) > - tmp ^= (val >> i) & 0x1; > - > - return tmp; > -} > - > struct xor_bits { > bool xor_enable; > u16 col_xor; > @@ -250,17 +238,17 @@ static unsigned long convert_dram_to_norm_addr_mi300(unsigned long addr) > if (!addr_hash.bank[i].xor_enable) > continue; > > - temp = bitwise_xor_bits(col & addr_hash.bank[i].col_xor); > - temp ^= bitwise_xor_bits(row & addr_hash.bank[i].row_xor); > + temp = (u16)__builtin_parity(col & addr_hash.bank[i].col_xor); > + temp ^= (u16)__builtin_parity(row & addr_hash.bank[i].row_xor); > bank ^= temp << i; > } > > /* Calculate hash for PC bit. */ > if (addr_hash.pc.xor_enable) { > - temp = bitwise_xor_bits(col & addr_hash.pc.col_xor); > - temp ^= bitwise_xor_bits(row & addr_hash.pc.row_xor); > + temp = (u16)__builtin_parity(col & addr_hash.pc.col_xor); > + temp ^= (u16)__builtin_parity(row & addr_hash.pc.row_xor); > /* Bits SID[1:0] act as Bank[5:4] for PC hash, so apply them here. */ > - temp ^= bitwise_xor_bits((bank | sid << NUM_BANK_BITS) & addr_hash.bank_xor); > + temp ^= (u16)__builtin_parity((bank | sid << NUM_BANK_BITS) & addr_hash.bank_xor); > pc ^= temp; > } > > -- > 2.52.0 > >