Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp209630rwl; Wed, 29 Mar 2023 00:07:39 -0700 (PDT) X-Google-Smtp-Source: AKy350Zclz0FpqGpHXvT+gZmrsdBoA/L2IVV8asbHX+9UNjgtKrXS+B81zSgJgAEO4tfAm5Mqjgr X-Received: by 2002:a17:90b:33ce:b0:23d:4b01:b27 with SMTP id lk14-20020a17090b33ce00b0023d4b010b27mr21789721pjb.10.1680073659143; Wed, 29 Mar 2023 00:07:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680073659; cv=pass; d=google.com; s=arc-20160816; b=k930xeNE5dwwxgsKchQh6bJYqViwDgq/57PwI8lSQaBnbewuUtqRKbg+QHufcbFz+W 8cXlHEUhjWPyDztWBs9OeTP1eq/1U+bmBZLBjQhSHTGgJfU0fZSA3UPoNFIoghROJsqM w3dgU1DPvuS/CZFudLbZETOsex9zkFcDvDg79/sfPex1O+XnIx3f9Bc/rXl+xsaJVWuN HaDyfLi9rq5B4OZ4bqzzMgQW8+FjoJWSiYsEBod9q6K1hI4nYKPtRgkrmPWKIFN6vR8o iBNIYj9JNfhQq+BFYo1UnRGsx7rs8v4oEsiRDz9gSS1ETYJbhs/RnjDFBeCO/NbCwunf mC2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=0UhnNXwf9fUrtQPAfLEwCxY7dpb1KIAQqB3KNNN+Pyg=; b=RG8hZuSSAUqjTFW5ga5IbK178LK0n/TrQ7QALqpRQyS+Ldu4UYZG5fUegRKCOkL72j +rS+R26U+LK2/E4Kw0jGTNYnyUIzDytr+Vh9lfCQW62fuxcKUoHdwLwiUnlPeCBNT4ZG Da0pU3I1z8wJj74s2gcHZ4A5VQGdTNf6kd69m/2Khc0QBQgg51tkWHXdeOeS7SMbtN0g 1b0VEMsLyKy0QdiM6s60IEbps1EI+b94YDwoh8Ksuoa3XBRlKrO+gjlKd86kBNy8qjrX sJdieA9J3MLnsrxDKge9eSEAyUR6AFKd3VRkISgPG3NrQzxuMHrg5w8gpCUKfxrRH3I9 MdQw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="bgC57/oo"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a17090a348f00b00234ba2fe34bsi896271pjb.102.2023.03.29.00.07.28; Wed, 29 Mar 2023 00:07:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="bgC57/oo"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbjC2HFK (ORCPT + 99 others); Wed, 29 Mar 2023 03:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjC2HFH (ORCPT ); Wed, 29 Mar 2023 03:05:07 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2048.outbound.protection.outlook.com [40.107.94.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8CC426AD for ; Wed, 29 Mar 2023 00:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GLjDCHB8GOpVmUo4YTKq8WKOnOT0+R1/UIFkN87+SB+zN6Xki7eqCkhB/78Qc5uAfMi/p3ucV7Ff+4oWktXxI/bxB+Kd/h2DQ5+3T823xr4nNkBUOPHHMM3UlhODhT7Yllfkaz5G+uykWzoPD3hKVZMh/unh3PFGDihUA/cVKSXLS5x9iFs6zbzPq/qntNUOJk3vAiG9tezVbZdB+iuSx+sorTz7NGTRVGZXkOMVvRkbX86K3QPgF37vF/+wjL4Ng/GRcdnd/AyXCv1UBEKasOlbccw72cLliPF5SVKZD2hwOvHYFOh+AXDOc8EZDijHoTUE2/AmZkgOLQqa6ZMzZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0UhnNXwf9fUrtQPAfLEwCxY7dpb1KIAQqB3KNNN+Pyg=; b=lq8TTIToyoRAzcH45TS8RPB74/LAR/DmM5xakm501OzFrYMILlPz7KUdP1dDaF79mOSRg8aQmpznRNgVR8XhX1j4G6s6uKXZELz1v3moiZNvbx72pBGaO/S7h1SLLfhz7Eh9g8HJX5fwUzL9KjHMFhiyMGLdqrw/Bwoa08bEmz983/pQf7/KDZwVWeiAtiYL5lYCvH1mOUlSPVKvj55tYGF6ddhC6uVGlbQjuOpop8FDDe0+ggfSbZ6AnlGqPaLOIAN5YXZs02SlWtZfWDteaZu3PiFiDk659mFecOFDC4JcczeAj7lP0VZYYebXcJ8feZE/tuwzadrQaoawRUtzEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0UhnNXwf9fUrtQPAfLEwCxY7dpb1KIAQqB3KNNN+Pyg=; b=bgC57/ooUFh+PAxQaZog46cB0wdVSejkcUf0154x5QZ7aCoxjKkzJFWE5AHkt64w9OuX64CfagaUhoZ1ALoE3cRJuF4udd+Bk0hJdVyORMV5yUHDSrsJak86hnycQyTrYaPZJ5By+FrJ9zJGkKwXDn85mXOgHm+upbp+mkLel/M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by CH3PR12MB8753.namprd12.prod.outlook.com (2603:10b6:610:178::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.33; Wed, 29 Mar 2023 07:05:01 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::4624:dc39:943e:6ae]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::4624:dc39:943e:6ae%5]) with mapi id 15.20.6222.032; Wed, 29 Mar 2023 07:05:00 +0000 Message-ID: <91873ac5-a15d-a405-c2ee-24674e17cbd3@amd.com> Date: Wed, 29 Mar 2023 09:04:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 1/2] drm: buddy_allocator: Fix buddy allocator init on 32-bit systems Content-Language: en-US To: David Gow , =?UTF-8?Q?Lu=c3=ads_Mendes?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , =?UTF-8?Q?Ma=c3=adra_Canal?= , Arthur Grillo Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20230329065532.2122295-1-davidgow@google.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20230329065532.2122295-1-davidgow@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR3P281CA0146.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::18) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR12MB3587:EE_|CH3PR12MB8753:EE_ X-MS-Office365-Filtering-Correlation-Id: 4dc424d6-0c79-4098-4f4c-08db3023e995 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jzWK4XYbkGqkGPAcy+fda2ACqjkSyTAHZ38gSKiCpzzWODsvg+kRcAMwgJ9z4EJF6TNWjxC/nX04uKF62hWFJqtQwGBw03up5812NdgLJHz6d155i0kaeA3IaHu78jLzYud4SAE/TeXUGYe4CKAh/Zms7RK5vVb2oS7HJHVKuy5uXMqeyFUL98bEFasfAqpizHaSZyZp7usEXpEmGbFFRsPNz4Y0418l9vyHQulZvQ15LVJ6PodO5HLpOLjRMtODVwEMIwdIomnG1zswI3gTdsF/8uTc6/GqvhVvziL+vhPfYvtB3n6ymVAXHgJ6XNlNGQQsByN3xqTC0t8p1CblaxVLzPrNKDxgO7epPE+YedVvwhKheNi8GxYxiz4arfsnhEKIa7jymbwldsZuoptde5kNN2oUKE1W+Y8ikZ4Wb+jyupTbumfqe8MKkZHUaOFPS/EmF+7o3iiTKTfNic2B2Z2jPX9xJWBcUUVPZAnsxiEdCT1U5oxKkPcnu02qyfXjAVsfHQFqH9WTl+Dbg6XiDXj13s5OZjKnTPEc//tHrNxycSCFNzIXI8MeGbcbBUfsSQl+bObyN9WOKTEMwrnX7DfAfbVAwiWrtZH2nRyYts1K1OSKX3yPkIhhfiekTWdo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(136003)(346002)(376002)(39860400002)(366004)(451199021)(6666004)(6506007)(6512007)(6486002)(966005)(31686004)(110136005)(478600001)(316002)(186003)(66574015)(66476007)(8676002)(66556008)(66946007)(2616005)(83380400001)(41300700001)(8936002)(4326008)(7416002)(5660300002)(2906002)(38100700002)(86362001)(31696002)(36756003)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SWFYUy9qMlNDajJOWjlvZmxOS0NKNWZaZ1QrZmw0azcyREZNeVNORWNIazlN?= =?utf-8?B?NkJkRUFpWUR4RVJ4MThxQnF0UEY5R1RGSEZtV0FjT0JOQmhlRG5ReEM3TDRZ?= =?utf-8?B?N2FzWjJyc3lSMzdwNEpoQkVzY095QjFqUlEyZkg1K1lUcTJiNU5RZDVXbEY4?= =?utf-8?B?MjBzdi81ZFdDa2JHVHcrbDRvdE1HU0JTS3NQR0haT0w2OXFiRmVabysrQU8v?= =?utf-8?B?eERuTnlVZ0k3ajRuNzFsUkhHK3hCbU1ZcS8wTUZWZ1RUWmxBMVdWTmJJSms1?= =?utf-8?B?WWlZRGpubks5cHBUN3VCc1VTSkdOS3hNbEhZdnhkSzhKYjRYN3hwNzgvbTFo?= =?utf-8?B?ajdhZVpLNGYvWUU0czU2NjI0YnZKa3B4RmFtK0pCWnZDWUxneUNDTXM0dW5v?= =?utf-8?B?TnhrS0FOOU1LamU5WVhNNmp6T2prTEM1SExpbU1BM1NqNEFoMGVPN2YvSEp4?= =?utf-8?B?ZTZicVJDOE5JdGk5N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MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 07:05:00.6023 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HQsJHHfZjcQjbqEDj9dKrd9cW5ZXqdhpiMwl6lVtVqbbkzVERl8HPzGT76XmdHiK X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8753 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 29.03.23 um 08:55 schrieb David Gow: > The drm buddy allocator tests were broken on 32-bit systems, as > rounddown_pow_of_two() takes a long, and the buddy allocator handles > 64-bit sizes even on 32-bit systems. > > This can be reproduced with the drm_buddy_allocator KUnit tests on i386: > ./tools/testing/kunit/kunit.py run --arch i386 \ > --kunitconfig ./drivers/gpu/drm/tests drm_buddy > > (It results in kernel BUG_ON() when too many blocks are created, due to > the block size being too small.) > > This was independently uncovered (and fixed) by Luís Mendes, whose patch > added a new u64 variant of rounddown_pow_of_two(). This version instead > recalculates the size based on the order. > > Reported-by: Luís Mendes > Link: https://lore.kernel.org/lkml/CAEzXK1oghXAB_KpKpm=-CviDQbNaH0qfgYTSSjZgvvyj4U78AA@mail.gmail.com/T/ > Signed-off-by: David Gow Acked-by: Christian König for the series. > --- > drivers/gpu/drm/drm_buddy.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c > index 3d1f50f481cf..7098f125b54a 100644 > --- a/drivers/gpu/drm/drm_buddy.c > +++ b/drivers/gpu/drm/drm_buddy.c > @@ -146,8 +146,8 @@ int drm_buddy_init(struct drm_buddy *mm, u64 size, u64 chunk_size) > unsigned int order; > u64 root_size; > > - root_size = rounddown_pow_of_two(size); > - order = ilog2(root_size) - ilog2(chunk_size); > + order = ilog2(size) - ilog2(chunk_size); > + root_size = chunk_size << order; > > root = drm_block_alloc(mm, NULL, order, offset); > if (!root)