Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp68517ybk; Thu, 14 May 2020 16:29:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIKPcXp59dl2cKqKTg3TeXrjfzdyMWD94ekDYW7fqlve2tvwuMhHaePvv9J7g1GecgKuaf X-Received: by 2002:a05:6402:783:: with SMTP id d3mr396874edy.295.1589498962971; Thu, 14 May 2020 16:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589498962; cv=none; d=google.com; s=arc-20160816; b=IWz3VNtXfVdHI18UwuoV7twOWFmIytK1xu5AldA4Rt9KkYmeefs9DRvTF3RNKaZyo+ G0UEvVepEEWeYI3d5+CojngYGqRzYJC5zNys9QFpa9EB4Tuya93P1HszrhKOGT+sDf3g G6E6DekfiDT5Kvc6FCVqLz9654JdzpsbWIXiSkIowjzDnMpdmrWB+5/ufM5mfcALhIqk BsBgsy8l8KXz/bTLqFBD6xm5ecAqHJWkmJl6i/DiZKetCHIKvSbFgXtj1HdphwatXpU1 sFZ9hljzRgqXDP2m8Kw7O/sX+r+NI5ufqV40Tt+A6MHM4hexh3rbZ4APggeeMQ1lJlfG ZaZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=Y5T+MJYaIViPJtEuNTvEac/EmrQtDU34UwdXS4dOR98=; b=TIYMXwgpv8RBAJ646F8sjXZdCxCM0pwrWqu9wczNP07N3Qw+EZe4w5Bzw7uU/jF1uD ekPQMpXJ+jKMdHxZomNJgdxqUzzEg4eFOVxqi6HK16lhzI9XCF4QEoIHqOiRV6OF2xNc Mnh3gPcOX1BxG9L097IDEZVnm6LahN3KsyaS//Lr+0ydBhCgPg3RrlL0O1q62/jeY9/7 hJkrTK36g48RxLHzVgevmW+ClgVp505FnVEWqrGYAwODayTwm92RHhV8FHi2AdpIfmbr abcaklHbq+zbgdUyZSzRXe3plqHrTbmrKC4mgzJW5JGOBLexjx1G+o2qOk7FwWWGF4Jp ypMA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rl12si230374ejb.199.2020.05.14.16.29.00; Thu, 14 May 2020 16:29:22 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728444AbgENWVP (ORCPT + 99 others); Thu, 14 May 2020 18:21:15 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59861 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728332AbgENWVO (ORCPT ); Thu, 14 May 2020 18:21:14 -0400 Received: from mail-qt1-f174.google.com ([209.85.160.174]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPSA (Nemesis) id 1N3bfB-1j949L2GJP-010dRa; Fri, 15 May 2020 00:21:12 +0200 Received: by mail-qt1-f174.google.com with SMTP id l1so299005qtp.6; Thu, 14 May 2020 15:21:12 -0700 (PDT) X-Gm-Message-State: AOAM531BIsBiBaz8ZUJNJbrOhMd6y1xbmLXI+BI3KySEYddF7Z1yM6cL 23vymXJfpWSJKIVdreNwwraMQng7rrcHNTx9xhU= X-Received: by 2002:ac8:6914:: with SMTP id e20mr439652qtr.7.1589494871298; Thu, 14 May 2020 15:21:11 -0700 (PDT) MIME-Version: 1.0 References: <1589465266-20056-1-git-send-email-jhugo@codeaurora.org> <1589465266-20056-6-git-send-email-jhugo@codeaurora.org> In-Reply-To: From: Arnd Bergmann Date: Fri, 15 May 2020 00:20:55 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 5/8] qaic: Implement data path To: Jeffrey Hugo Cc: gregkh , Manivannan Sadhasivam , Bjorn Andersson , wufan@codeaurora.org, pratanan@codeaurora.org, linux-arm-msm , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:T8hMKti8wveVg2CIcH8fDurzlkCWkCPWYP/4qRVYC8sbuA3vm5F jYXgeYNWOM9MzKi0UvWTUgLEurDFPdow0DvVfluiW6JRr66v3TsjMSAW/5kfY/TuLgUlnGw jVk6dtf9xRnsjGL1MHVXOnLCFtw29gOlJjms4wGFFVbaXnLGo6Rg2Vxl67v2ohwUvie46fp Ck/yGQdE/bU0Sr3wPgHXQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:NB7j5rnVavY=:0kkwDsSPm1yfhhQWbySiCW RYdGDNDEqal6tP+cdB3sU2oBI3a+QfZXT6Xvbn6N4reK9t4xA85MqKSAle9fHefIjnPLvmfEy it4S6LhgHQnEhbTSVEo9kwj3f1ayPIStcJAwONBv55DLQeuRc/TZ/45FZPdvmIN+XzGq8OEBV dpnYij8tlPqIdBzT7v4JQPVaA/EZQhNAfdmEZQ6ms1kCmmtTPnz3T8AZ5/NdaOFQ6IPTpVwSu tMwt3ly+OYMN4cKUUpNu6JjbYaS7533EAt5ftbovOYPKjYZzFIZM2jW/6OI/daiNl3gXE4m/T yJM+bnxtMfMSTmchnB/5qZTX5t/IMKQxHfsBbLmkoi/D9pAlyl8Xxi4FNirbeTIPD5i2Daswc RqEsvY97JTnefSxn1qj0bySkk4233qP56D/oVuwbF58ySreq0vAWzgQMOLzd8SQMy0Wij8wGE oXMzEIeApA9VUbjOcMS1BvBP9xS62o1KTs2uRfr8JPxJZL3zPBjJe2pAnT5BixaeAy0G00tga DDABt76KdSynJ+kuvJ/GG0aAVpiaKps8a2IjwJGM6Pij07LLggJNWUYctge1bKkoVoCuyfgtb HjJjtAckKMgxzryIH3kxmEVmHFX8ctkiDq0AudUCnD3Hw+e///iitQ9PSc2t1z/CQUPzW7PRV 0F5nYMQXcxWOacJdbBQWoAYMHKkvaxqAjzYvZrCAZZSgxlZyE9ohszko+aYqmOhrBtYD/zYCK 0k3txFvFt6fP09/cMgp2q0D9mk84iCAbSHm2OJQnZQOCOTaK6MlOYMCtA8II/uWJzak067RXu YA/+s0x0EFofgE//Sc1y71B04obJbdwhjVp30zKKQh3yug0bO4= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 12:06 AM Jeffrey Hugo wrote: > >> + u16 req_id; > >> + u8 seq_id; > >> + u8 cmd; > >> + u32 resv; > >> + u64 src_addr; > >> + u64 dest_addr; > >> + u32 len; > >> + u32 resv2; > >> + u64 db_addr; /* doorbell address */ > >> + u8 db_len; /* not a raw value, special encoding */ > >> + u8 resv3; > >> + u16 resv4; > >> + u32 db_data; > >> + u32 sem_cmd0; > >> + u32 sem_cmd1; > >> + u32 sem_cmd2; > >> + u32 sem_cmd3; > >> +} __packed; > > > > All members are naturally aligned, so better drop the __packed > > annotation get better code, unless the structure itself is > > at an unaligned offset in memory. > > I'm going to have to disagree. While most "sane" compilers would not > add extra padding, I've debugged enough issues in the past when > sending/receiving data with foreign environments to never trust anything > that isn't "packed". > > Unless I missed something in the C spec that requires naturally aligned > structures to have an identical layout in memory, I'll take safety and > functional correctness over performance. The C standard does not mandate the layout and individual ABIs can be different, but Linux does only runs on ABIs that have the correct layout for the structure above The problem is that the compiler will split up word accesses into bytes on some architectures such as older ARM, to avoid unaligned loads and stores. It should be fine if you add both __packed and __aligned(8) to make the structure aligned again. > >> + init_completion(&mem->xfer_done); > >> + list_add_tail(&mem->list, &dbc->xfer_list); > >> + tail = (tail + mem->nents) % dbc->nelem; > >> + __raw_writel(cpu_to_le32(tail), dbc->dbc_base + REQTP_OFF); > > > > What is this __raw accessor for? This generally results in non-portable > > code that should be replaced with writel() or something specific to > > the bus on the architecture you deal with. > > The barrier(s) that comes with writel are unnecessary in this case. > Since this is part of our critical path, we are sensitive to its > performance. > > What are the portability issues around the __raw variant? The access may not be atomic on all architectures but get either split up or combined with adjacent accesses. There is no guarantee about endianess: while most architectures treat __raw access as a simple load/store, some might have an implied byteswap. __raw accesses might be completely reordered around other mmio accesses or spinlocks. If you want to avoid the barrier, there is the writel_relaxed()/readl_relaxed() that skips most barriers, so they can be reordered against MSI interrupts and DMA accesses on architectures that allow (e.g. ARM or PowerPC) but not against each other. If you do use them, I'd still expect a comment that explains why this instance is performance critical and how it is synchronized against DMA or MSI if necessary. Arnd