Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1791016pxk; Tue, 1 Sep 2020 07:55:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzaM4q3yaa4f7rvLFlJ11Pe/U4WWOjlWwfRPdDSbhSSrhTUFIvjr/sQsxfYzwckSZiRm2a X-Received: by 2002:a17:907:7292:: with SMTP id dt18mr1913694ejc.512.1598972136891; Tue, 01 Sep 2020 07:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598972136; cv=none; d=google.com; s=arc-20160816; b=EaXc2uZedLsSWvT096rOeripoW2qcw3G97pqhfjAmJMFVbb50zJ2mOohBClC0RTWk8 Nko0KR48cyQjP37UmhKjDmYkiQSnte40aX0PIhJbwG9L5bXRnOG6ClYvtrOr4iCYaNEE 2HMDElLKvg/YOzfj7bUE4SwGzQpyAm/pHgYksLYm1Dk+0+U1mH1hEfCCkX1Ghge3/7F+ bbhJTrRm/rue+W7uNZ5WZfdbgAun0J2YyjvkyPFJmZFUzqWpNOiRiitA4tYV+ukSsXow 6LCP72ejH8kNzt6HMxSTCjFIPKMyt+/S/te+V3LoS9LvEsXIBM4Brb0ClZX+aAdGhtYV gAzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:dkim-signature; bh=sTzSmVBP2+AWYCSsx6iXl76WgXrHcsjtHUMtn0qSmTs=; b=KSuBAmrYimrXxEW7dZ7moZWeLIdag0jpHe+GJ1Cs5PLPk4u9FdsYJaJ9/259AJIQ93 jN/QZL419YCPeSDp2Q/pG+B1RPg98U9c2O+K5qRH19tqCGPx6+jo8sBMMFFHVJC9AcEK f0+VYF5JINyMjBqfSy5egL2Kcd9w65+s/XJ5/97AjwbhYHahqAca8KLwuH0wgWMiAAsO LMscCV5oev/EOcPmrFjBK/NtgX4FUlTAmf1woZ0cLmWCP13BMTCeHTls8uPzdDW9AEKX HFDS3JG6Rf8ZPdGF15yx+HWFF1rbQ6OHG8F5v7aRRi9fZC97WKnn0zYRftYlHuBZBibe 2W6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=wObSEMiI; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=aKMifmu3; 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=hansenpartnership.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v9si777515ejy.486.2020.09.01.07.55.13; Tue, 01 Sep 2020 07:55:36 -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; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=wObSEMiI; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=aKMifmu3; 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=hansenpartnership.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728680AbgIAOxW (ORCPT + 99 others); Tue, 1 Sep 2020 10:53:22 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:42334 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728454AbgIAOwp (ORCPT ); Tue, 1 Sep 2020 10:52:45 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 2FA1E8EE112; Tue, 1 Sep 2020 07:52:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1598971964; bh=5QgiJp1XQuU8WeasWKUrByXxrzK/9M/xvKJovjxtOSE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=wObSEMiIFiMQqpuLxaCfGj6fWwMB1SR5uR3WpqveV9O4eMPwCERYxZe+pGeu45B1s Hh0lHOhPmaDzTL+z1MwoTQwce39LAcI0HTI6j6IhhJYI3h5nKO0TMp801H3LPYpAS2 cAlNurtUenHcZUudnTaoIqyV7yZakslR9e7UqKeA= Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0Zy3Ukh5UkrA; Tue, 1 Sep 2020 07:52:44 -0700 (PDT) Received: from [153.66.254.174] (c-73-35-198-56.hsd1.wa.comcast.net [73.35.198.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id C9BD38EE0F5; Tue, 1 Sep 2020 07:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1598971963; bh=5QgiJp1XQuU8WeasWKUrByXxrzK/9M/xvKJovjxtOSE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=aKMifmu3auQ6FWaycnVm58I6hz9G+D25US7ZBIQmKPWtl/OO3oAlisEasTKoEqxvs l6ihGgc23PPx6Vjc2Wtc/36E47y53pW7IPIx5bd2ov50jG73PyojCzhwq4i11ZzTyB Dg3UC/gKa12A9sw0Wl45QN34rTiyU/vUbrJxeAio= Message-ID: <1598971960.4238.5.camel@HansenPartnership.com> Subject: Re: [PATCH 07/28] 53c700: improve non-coherent DMA handling From: James Bottomley To: Christoph Hellwig , Mauro Carvalho Chehab , Thomas Bogendoerfer , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Ben Skeggs , Pawel Osciak , Marek Szyprowski , Matt Porter , iommu@lists.linux-foundation.org Cc: Tom Lendacky , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, nouveau@lists.freedesktop.org, netdev@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, linux-mm@kvack.org, alsa-devel@alsa-project.org Date: Tue, 01 Sep 2020 07:52:40 -0700 In-Reply-To: <20200819065555.1802761-8-hch@lst.de> References: <20200819065555.1802761-1-hch@lst.de> <20200819065555.1802761-8-hch@lst.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-08-19 at 08:55 +0200, Christoph Hellwig wrote: > Switch the 53c700 driver to only use non-coherent descriptor memory > if it really has to because dma_alloc_coherent fails. This doesn't > matter for any of the platforms it runs on currently, but that will > change soon. > > To help with this two new helpers to transfer ownership to and from > the device are added that abstract the syncing of the non-coherent > memory. The two current bidirectional cases are mapped to transfers > to the device, as that appears to what they are used for. Note that > for parisc, which is the only architecture this driver needs to use > non-coherent memory on, the direction argument of dma_cache_sync is > ignored, so this will not change behavior in any way. I think this looks mostly OK, except for one misnamed parameter below. Unfortunately, the last non-coherent parisc was the 700 series and I no longer own a box, so I can't test that part of it (I can fire up the C360 to test it on a coherent arch). [...] > diff --git a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h > index 05fe439b66afe5..0f545b05fe611d 100644 > --- a/drivers/scsi/53c700.h > +++ b/drivers/scsi/53c700.h > @@ -209,6 +209,7 @@ struct NCR_700_Host_Parameters { > #endif > __u32 chip710:1; /* set if really a 710 not > 700 */ > __u32 burst_length:4; /* set to 0 to disable > 710 bursting */ > + __u32 noncoherent:1; /* needs to use non- > coherent DMA */ > > /* NOTHING BELOW HERE NEEDS ALTERING */ > __u32 fast:1; /* if we can alter the > SCSI bus clock > @@ -429,7 +430,7 @@ struct NCR_700_Host_Parameters { > for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); > i++) { \ > __u32 val = > bS_to_cpu((script)[A_##symbol##_used[i]]) + da; \ > (script)[A_##symbol##_used[i]] = bS_to_host(val); \ > - dma_cache_sync((dev), > &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ > + dma_sync_to_dev((dev), > &(script)[A_##symbol##_used[i]], 4); \ > DEBUG((" script, patching %s at %d to %pad\n", \ > #symbol, A_##symbol##_used[i], &da)); \ > } \ > @@ -441,7 +442,7 @@ struct NCR_700_Host_Parameters { > dma_addr_t da = value; \ > for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); > i++) { \ > (script)[A_##symbol##_used[i]] = bS_to_host(da); \ > - dma_cache_sync((dev), > &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ > + dma_sync_to_dev((dev), > &(script)[A_##symbol##_used[i]], 4); \ > DEBUG((" script, patching %s at %d to %pad\n", \ > #symbol, A_##symbol##_used[i], &da)); \ > } \ > @@ -456,7 +457,7 @@ struct NCR_700_Host_Parameters { > val &= 0xff00ffff; \ > val |= ((value) & 0xff) << 16; \ > (script)[A_##symbol##_used[i]] = bS_to_host(val); \ > - dma_cache_sync((dev), > &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ > + dma_sync_to_dev((dev), > &(script)[A_##symbol##_used[i]], 4); \ > DEBUG((" script, patching ID field %s at %d to > 0x%x\n", \ > #symbol, A_##symbol##_used[i], val)); \ > } \ > @@ -470,7 +471,7 @@ struct NCR_700_Host_Parameters { > val &= 0xffff0000; \ > val |= ((value) & 0xffff); \ > (script)[A_##symbol##_used[i]] = bS_to_host(val); \ > - dma_cache_sync((dev), > &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ > + dma_sync_to_dev((dev), > &(script)[A_##symbol##_used[i]], 4); \ > DEBUG((" script, patching short field %s at %d to > 0x%x\n", \ > #symbol, A_##symbol##_used[i], val)); \ > } \ These macro arguments need updating. Since you changed the input from hostdata->dev to hostdata, leaving the macro argument as dev is simply misleading. It needs to become hostdata or h. James