Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp895120lqa; Sun, 28 Apr 2024 08:53:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMfIigSGla7Q7AK0DKV5pmIsA/FJhzCoQIQM560yx5nra5YNK22Cd/8zzFgMr/PhGOhYKrTpp2zCuzxeAsSrkdRV5utwrn6cHYdbJ38Q== X-Google-Smtp-Source: AGHT+IGM8TT5YeC4TwMuvOkW2i4B5k93zdEDuHW9s0GaXiMyWQKxfh4RIlu8VZgu3Y+NlXzQcx0o X-Received: by 2002:a17:903:428e:b0:1dd:dde1:31dc with SMTP id ju14-20020a170903428e00b001dddde131dcmr7379454plb.26.1714319585250; Sun, 28 Apr 2024 08:53:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714319585; cv=pass; d=google.com; s=arc-20160816; b=Rg0cPQ4fdf4PoaLZ/Xjm3cLwTITLYTlD3FVqM9GHP/RweUM7hlEoEU51Tww4Wh7Ton HeTSbziE3+hb9dwfabWRb6upv+JzlIe+WFClfs5TONhIQIG6Bjkhazeaw9WBSWnr2ACA MCQw//RZ2JYQQafeaFd4sC62bjcb96eAdNia6l8PKuwdbDwXyoROM0uCpz5HbX5NJ8wq hmQew2RiyuigyH8bK8t6HOMUQDk+VuNMmJmCqyxYnQEeFbFrZ5u6A2hTnJJ2EwiXTaLW pVSi3Bzhwgco4/hueqBYAPr8Kn2bn4CTg/1CKUmjlANmot6m4cZow6omSyuHYoOTTcKH 1Puw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:organization:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=pZykVLyPTHNf2oLD7SWZNyhDuAGshWhY8pTDiUHRDL8=; fh=jFOOuidUDCpTDkU9VRSAV1os9tEp6aSyJrlFzZOr71o=; b=qN7qEJp+IxtfTy8vXDMZeJkRnv9BKlkUBAiC/+m09P3ctBmA5JZvv7UgP1c4fr+65A HYpGxig22Bo+Jdo58iCAok1l89m80KWMIGYcXYd0orW8tQ7JM22sy6Pta2fcCvZaG6Sm RTuAq02CGc+5RKqa+V/fm2kq1RYUVAfx5FcuGD8froLVlV7fZnZFfGnl+mVYt3TxfjlV RG6nGubNDexs0pgfrENDqxRiCcfDXjT2zpmLVzJJ9RrOifPvJCxf1iWDSWxqwVmW0SJ8 mGNqAb/osD/wFxdXixVbCS3XfUz6RuoAHkLr3vIjAnjiNXN9RsTK2KkYOSrty9rmx/0k 5kHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eOeyAI4o; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-161475-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161475-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z14-20020a170902ccce00b001debbc0f034si19423871ple.98.2024.04.28.08.53.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 08:53:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161475-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=@redhat.com header.s=mimecast20190719 header.b=eOeyAI4o; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-161475-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161475-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 A957C281A49 for ; Sun, 28 Apr 2024 15:53:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97C236F505; Sun, 28 Apr 2024 15:52:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eOeyAI4o" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 0F65C4A01 for ; Sun, 28 Apr 2024 15:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714319574; cv=none; b=HxRhV9sePXzTYVi5TLmCLF2ReytrkoGxx2KarYAat7V7FQcJXV29HARChg25aUJmaJl946F+R2xT63V2kQ/jRCWfYtEVa4nHm3HwpS2j+LWkuoy9JdQzIULFdcKBeP7tXiHCLIXyO9W84l7Fm2/CfniPHjn6TVRWt3OyJ3LCvro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714319574; c=relaxed/simple; bh=2wIGyMsyZwzKQCoJugGWjKv1x94RRNkPSOrpppHoAXQ=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=Kb7UOZJD7kVH+D4MvSAQt+OztzclH+zxBqgWmacPRg4N6qzR80C10fMg4FYnIRhx4c7ZMflvHjjYZKIrchYd4tg2oQ79pMySFqWtcVNm1ScjgxrdWiqiEJ0yBr+MnWyWZQrzFMJEwCD+yFVP7GkCn06NafH8R2LQPNQquf7MCoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=eOeyAI4o; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714319571; 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=pZykVLyPTHNf2oLD7SWZNyhDuAGshWhY8pTDiUHRDL8=; b=eOeyAI4oTxIIFDKYG2ZnGn3PIWdKFVXxoPJD7710PiVaEV3FNcABDIDa8Qwk5hPziB0mD1 uVChteTdTNsBpNglaUzt4ECvx4fyslmvTeHjFrH3aWS+K95CMXzsISSJZVLZW8o1tDJDxq imc2QCksIi21z2oneNXQPK+eZ/Dpz2s= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-56-txyoNerbM5O42PWMhgEmuA-1; Sun, 28 Apr 2024 11:52:50 -0400 X-MC-Unique: txyoNerbM5O42PWMhgEmuA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-78d5fed0e1aso409532485a.2 for ; Sun, 28 Apr 2024 08:52:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714319569; x=1714924369; h=mime-version:user-agent:content-transfer-encoding:organization :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pZykVLyPTHNf2oLD7SWZNyhDuAGshWhY8pTDiUHRDL8=; b=u1Vg1CqbMK/wZtT1DvhG25ug6k/IgfYrARWxfpUFdIU8om8yxx1yAb/NGa5ifNB2Wh jzFeaN0kuUGSK0q4mNaOQpbWPyeA+87TGxGtlmL76FMjeD8QtnJXBlIsYMZ2oFrtG1NN dWSnCvN+vBllUEArzB04MyMxb3w0ol64R//WOXsayNWGQz25Z6IXdqKvk3Hiv+IaXnVX JvDYr3mIt+q5LTk/9447XXqdyId0fgVM6e6Fd83DrlBlGsPT5d+pwyDyBdfU7zKTm41x a8idde1iXmrX6oheAAdvLyaQCAIb7xIPwihKrwdQOr5OiAV95nLCnt7RF4gQ2JUWHgxD 8mzQ== X-Forwarded-Encrypted: i=1; AJvYcCX6vDhCq606tCVhNuokAy2D4xitKfRxIs7tScwB/D3JjjNVoYKYVnZD6H7yd+1+IXUf3WsHkvbRqB7NPdtko70hSrfRsf2UjZ/qV8NY X-Gm-Message-State: AOJu0YzWQz4+FgcyMQDSRIhvNDW8S3/qXm/Bf0ZF9QlA/FeTpFkWJlcD E8f5nnJf7r7Y/lJoHduDXnM/ToEpcHq9LFzUzBmTno+LxYjqXxK/p5kElyDm8VNyxd3CcIKk8Pk 7AqqwmURLlBbqwihFRRSa3bVxHeVBPeZzSDEiPDTUYIHmjS/bK8xK37U44MI5lg== X-Received: by 2002:a05:620a:2415:b0:790:f40f:e24e with SMTP id d21-20020a05620a241500b00790f40fe24emr1246036qkn.22.1714319569616; Sun, 28 Apr 2024 08:52:49 -0700 (PDT) X-Received: by 2002:a05:620a:2415:b0:790:f40f:e24e with SMTP id d21-20020a05620a241500b00790f40fe24emr1246022qkn.22.1714319569338; Sun, 28 Apr 2024 08:52:49 -0700 (PDT) Received: from chopper.lyude.net ([2600:4040:5c6c:a300::789]) by smtp.gmail.com with ESMTPSA id f18-20020a05620a20d200b0078eaf335331sm9718788qka.77.2024.04.28.08.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 08:52:48 -0700 (PDT) Message-ID: <35b0ffe54f5e4077d5ebee6b82ae9ccd568dd77d.camel@redhat.com> Subject: Re: [PATCH 1/2] drm/nouveau/firmware: Fix SG_DEBUG error with nvkm_firmware_ctor() From: Lyude Paul To: Timur Tabi , "nouveau@lists.freedesktop.org" Cc: "bskeggs@redhat.com" , "kherbst@redhat.com" , "airlied@redhat.com" , "justinstitt@google.com" , "dri-devel@lists.freedesktop.org" , "keescook@chromium.org" , "airlied@gmail.com" , "dakr@redhat.com" , "linux-kernel@vger.kernel.org" , "daniel@ffwll.ch" Date: Sun, 28 Apr 2024 11:52:47 -0400 In-Reply-To: <4294e43a0165a36a063d74c7ef62fbdeb156f8c4.camel@nvidia.com> References: <20240426154138.64643-1-lyude@redhat.com> <4294e43a0165a36a063d74c7ef62fbdeb156f8c4.camel@nvidia.com> Organization: Red Hat Inc. Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.1 (3.52.1-1.fc40) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2024-04-26 at 15:47 +0000, Timur Tabi wrote: > On Fri, 2024-04-26 at 11:41 -0400, Lyude Paul wrote: > > We hit this because when initializing firmware of type > > NVKM_FIRMWARE_IMG_DMA we allocate coherent memory and then attempt > > to > > include that coherent memory in a scatterlist.=20 >=20 > I'm sure this patch is a good one, and I will try to test it soon, > but I am > very curious to know why including coherent memory in a scatterlist > is bad. Thanks for asking this as I think you unintentionally pointed out this explanation I gave doesn't make sense - so I looked a bit more into it. The issue isn't coherent memory in the scatterlist, the issue is that we're allocating with dma_alloc_coherent(). And according to the source in dma_alloc_attrs() (which dma_alloc_coherent() is just a wrapper) for): /* * DMA allocations can never be turned back into a page pointer, so * requesting compound pages doesn't make sense (and can't even be * supported at all by various backends). */ if (WARN_ON_ONCE(flag & __GFP_COMP)) return NULL; Which explains the check in sg_set_buf() that this patch stops us from hitting: BUG_ON(!virt_addr_valid(buf)); Scatterlists need page pointers (we use one later down here:) sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf)); But we can't get a page pointer from an allocation made by dma_alloc_coherent() - but we can from vmalloc(). I'll fix the patch explanation in the next version, I have to send out another version anyhow since I realized that patch #2 still needs one more check to work properly --=20 Cheers, Lyude Paul (she/her) Software Engineer at Red Hat