Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp540058pxb; Wed, 25 Aug 2021 09:01:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkfN4lVeAhuJa9a896fLR1eYUNptNYV2Zp0MYPbyo+UvcTxCR3eQ/IlPQVbHoQpe8s6IzZ X-Received: by 2002:a17:906:2696:: with SMTP id t22mr1529048ejc.184.1629907315572; Wed, 25 Aug 2021 09:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629907315; cv=none; d=google.com; s=arc-20160816; b=IuplNfqSvfFmmx4HKPkHZTua0s8+SMx34h0EFgbx5bCpptXCpvxnqOkv6b8nSakoK6 DS6dtmQa9Vix0BoTLX5dnryFgO/iqRlDcPN3b1S/AwWXjPncXZeoJU88wn3JW0EqKYIK jddTn5K1/bEF4kw0zRd7n5D5VKhtugox7Gat1whQnea7tJc8SPgMJ8GJF9Y2ybzyIOa6 8y/l0GpU7FPhbmiIeLqdHwtaJhiN0+8VB6B4j9M/dNapeoFmIBNCA76lEIDZKTO/UjMO 2r6wxhwuARcgx0ls3mybAufTWnVG7gbfbn7XJzMhchVOmb50Mo1zF7VxcrxCY2CYRy4X euVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=WtG3K5eA/aCi/8AJbqxdKbAGP8XpWL+BvH/rotyRSw0=; b=oD7eE/bOPtmGrEPyn/8Tl1zRmLMb1Shf39XzHBRNjikFPs++aoWuXgwaDATx6Ehs4O VntnQjd8RXiBV38iOXEcIe8JhgcJiBcjnmhFnM7CVC/t3Cf4QW/46ku6e70aT3++ZGnD JEvxs6b7DIYzTlnP1s35IaU7KrAuCCxrpsNttKYyGdtOU2+o8QGFmgd19ZTt4OE1IL4l Sj2JQ/BxeJZfJUOLc2EtJZt17NEM++3cLxpL5qg5ByI9XQAZ7VtlIEEkMvhgKce7BzYm 8UvoQ87rQUeE4KSoWfNHXZmIZv4HBnoHkKeQjSLa/6As7uwbgJ2GNTA8auqUmxmbqQBD ukbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd8si192409ejc.405.2021.08.25.09.01.30; Wed, 25 Aug 2021 09:01:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241760AbhHYOfV (ORCPT + 99 others); Wed, 25 Aug 2021 10:35:21 -0400 Received: from foss.arm.com ([217.140.110.172]:52390 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241757AbhHYOfV (ORCPT ); Wed, 25 Aug 2021 10:35:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 13A58106F; Wed, 25 Aug 2021 07:34:35 -0700 (PDT) Received: from [192.168.1.179] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C7F533F5A1; Wed, 25 Aug 2021 07:34:33 -0700 (PDT) Subject: Re: [PATCH v2 4/4] drm/panfrost: Handle non-aligned lock addresses To: Alyssa Rosenzweig Cc: Alyssa Rosenzweig , dri-devel@lists.freedesktop.org, Rob Herring , Tomeu Vizoso , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org References: <20210824173028.7528-1-alyssa.rosenzweig@collabora.com> <20210824173028.7528-5-alyssa.rosenzweig@collabora.com> <6fe675c4-d22b-22da-ba3c-f6d33419b9ed@arm.com> From: Steven Price Message-ID: <8db73065-e8e8-7894-7eac-befd082a25e1@arm.com> Date: Wed, 25 Aug 2021 15:34:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/08/2021 15:07, Alyssa Rosenzweig wrote: >>> In practice, the current callers pass PAGE_SIZE aligned inputs, avoiding >>> the bug. Therefore this doesn't need to be backported. Still, that's a >>> happy accident and not a precondition of lock_region, so we let's do the >>> right thing to future proof. >> >> Actually it's worse than that due to the hardware behaviour, the spec >> states (for LOCKADDR_BASE): >> >>> Only the upper bits of the address are used. The address is aligned to a >>> multiple of the region size, so a variable number of low-order bits are >>> ignored, depending on the selected region size. It is recommended that software >>> ensures that these low bits in the address are cleared, to avoid confusion. >> >> It appears that indeed this has caused confusion ;) >> >> So for a simple request like locking from 0xCAFE0000 - 0xCB010000 (size >> = 0x30000) the region width gets rounded up (to 0x40000) which causes >> the start address to be effectively rounded down (by the hardware) to >> 0xCAFC0000 and we fail to lock 0xCB000000-0xCB010000. >> >> Interestingly (unless my reading of this is wrong) that means to lock >> 0xFFFF0000-0x100010000 (i.e. crossing the 4GB boundary) requires locking >> *at least* 0x00000000-0x200000000 (i.e. locking the first 8GB). >> >> This appears to be broken in kbase (which actually does zero out the low >> bits of the address) - I've raised a bug internally so hopefully someone >> will tell me if I've read the spec completely wrong here. > > Horrifying, and not what I wanted to read my last day before 2 weeks of > leave. Let's drop this patch, hopefully by the time I'm back, your > friends in GPU can confirm that's a spec bug and not an actual > hardware/driver one... > > Can you apply the other 3 patches in the mean time? Thanks :-) > Yeah, sure. I'll push the first 3 to drm-misc-next-fixes (should land in v5.15). It's interesting that if my (new) reading of the spec is correct then kbase has been horribly broken in this respect forever. So clearly it can't be something that crops up very often. It would have been good if the spec could have included wording such as "naturally aligned" if that's what was intended. Enjoy your holiday! Thanks, Steve