Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1027768ybe; Wed, 4 Sep 2019 11:22:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGrKVqCKajlzbo/ogEHNbrGvm5ZXiH8eEyub7YZznXArCfJuQqHYvgsT/cMBfGHeKbSr4Q X-Received: by 2002:aa7:83d1:: with SMTP id j17mr41368795pfn.35.1567621326822; Wed, 04 Sep 2019 11:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567621326; cv=none; d=google.com; s=arc-20160816; b=QZeqDMRiTX921QNi3zt0w0oirs63OR26E/xU9RGE+EXMgXOk00nRB6TZLZrwQpUOEE Zt9Ou1G5u2jS1nXz3tSQoMAmDJYyoliQfBixfu8/j+D/OMlZpqxw3BCJ7ixQv+PW5oPg moa2wdJtdbV8vxdQh0o9+kOHjOkHT77L/bpvJEOAZVBUVeOdSiGv/3Rn4rDCT93hqHsE 3z40JcNU/0vTMPESfoA4U9Gsdy9rRcI9+mXAGZfy/PeTvtweE4+Qi7+1N/6MUHZztvxE +e+7IvlD7Xcd6J/1jUmUHHhKl0FqLLbxabTHxrZyHuopWYUWPuPuk/G3RJAPF19jEmnt qOlw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ifym481Ls/4tpSE3aswrANXojDNGopP6DuTAiIvE7f0=; b=iNjHBVMee0mD3etzULHs4ci/mBq5G2M1DOcjVQr+l6xDrGnKzeW1mxvE5i1Exajx80 5XJ+LRR+bRE8Dw6+OoMzrBZCNYT7fl7PI17wsQUrh8boAHl9UASpTeqjtem3j1Sqksmi 4HGlzha/h0UZPtUzfmZu5mUGndHF+xu+53Fw9njddOYidi8XthqMZa7sJSZkN6ueFyZW Sr3FhnffeX2/OHlSr6SbuWj1ntGBiotuZjHGT2SORPEgmAo+qEP9x2Ykq9H/OcwB5dLE BtMj1OMTT93tDXcFw4mJy5XkXfe8wtvDvuQ2DK8AP5ksScatCBlKO1HQ2StRDWS8wQbX nSAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="vJ/FR/23"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si17731451plo.47.2019.09.04.11.21.51; Wed, 04 Sep 2019 11:22:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="vJ/FR/23"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390053AbfIDSKO (ORCPT + 99 others); Wed, 4 Sep 2019 14:10:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:53688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389303AbfIDSKN (ORCPT ); Wed, 4 Sep 2019 14:10:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7EE7B208E4; Wed, 4 Sep 2019 18:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620612; bh=dQ1SFDjgCSInOxteCI1SVB9kLKMUxh7ABJ8IJAwqUNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vJ/FR/23SKSSFbrn/bI4MbZ8nEVE0hyLjO5D2vlvupIqOfzrSNiq/PjvrhwQvBNA0 4gmFvsHvSlx9PdIF2aVCddh+16CxXEQzqaNEQaxDsrWfRRBLIBv6m6AalXjrq8MDrE yCnloL50R/t14yeg6xR3qCzBmFFz+eb5dIJqAo5o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Segal , Oded Gabbay , Sasha Levin Subject: [PATCH 5.2 030/143] habanalabs: fix completion queue handling when host is BE Date: Wed, 4 Sep 2019 19:52:53 +0200 Message-Id: <20190904175315.236361927@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 4e87334a0ef43663019dbaf3638ad10fd8c3320c ] This patch fix the CQ irq handler to work in hosts with BE architecture. It adds the correct endian-swapping macros around the relevant memory accesses. Signed-off-by: Ben Segal Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/irq.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/misc/habanalabs/irq.c b/drivers/misc/habanalabs/irq.c index ea9f72ff456cf..199791b57caf2 100644 --- a/drivers/misc/habanalabs/irq.c +++ b/drivers/misc/habanalabs/irq.c @@ -80,8 +80,7 @@ irqreturn_t hl_irq_handler_cq(int irq, void *arg) struct hl_cs_job *job; bool shadow_index_valid; u16 shadow_index; - u32 *cq_entry; - u32 *cq_base; + struct hl_cq_entry *cq_entry, *cq_base; if (hdev->disabled) { dev_dbg(hdev->dev, @@ -90,29 +89,29 @@ irqreturn_t hl_irq_handler_cq(int irq, void *arg) return IRQ_HANDLED; } - cq_base = (u32 *) (uintptr_t) cq->kernel_address; + cq_base = (struct hl_cq_entry *) (uintptr_t) cq->kernel_address; while (1) { - bool entry_ready = ((cq_base[cq->ci] & CQ_ENTRY_READY_MASK) + bool entry_ready = ((le32_to_cpu(cq_base[cq->ci].data) & + CQ_ENTRY_READY_MASK) >> CQ_ENTRY_READY_SHIFT); if (!entry_ready) break; - cq_entry = (u32 *) &cq_base[cq->ci]; + cq_entry = (struct hl_cq_entry *) &cq_base[cq->ci]; - /* - * Make sure we read CQ entry contents after we've + /* Make sure we read CQ entry contents after we've * checked the ownership bit. */ dma_rmb(); - shadow_index_valid = - ((*cq_entry & CQ_ENTRY_SHADOW_INDEX_VALID_MASK) + shadow_index_valid = ((le32_to_cpu(cq_entry->data) & + CQ_ENTRY_SHADOW_INDEX_VALID_MASK) >> CQ_ENTRY_SHADOW_INDEX_VALID_SHIFT); - shadow_index = (u16) - ((*cq_entry & CQ_ENTRY_SHADOW_INDEX_MASK) + shadow_index = (u16) ((le32_to_cpu(cq_entry->data) & + CQ_ENTRY_SHADOW_INDEX_MASK) >> CQ_ENTRY_SHADOW_INDEX_SHIFT); queue = &hdev->kernel_queues[cq->hw_queue_id]; @@ -122,8 +121,7 @@ irqreturn_t hl_irq_handler_cq(int irq, void *arg) queue_work(hdev->cq_wq, &job->finish_work); } - /* - * Update ci of the context's queue. There is no + /* Update ci of the context's queue. There is no * need to protect it with spinlock because this update is * done only inside IRQ and there is a different IRQ per * queue @@ -131,7 +129,8 @@ irqreturn_t hl_irq_handler_cq(int irq, void *arg) queue->ci = hl_queue_inc_ptr(queue->ci); /* Clear CQ entry ready bit */ - cq_base[cq->ci] &= ~CQ_ENTRY_READY_MASK; + cq_entry->data = cpu_to_le32(le32_to_cpu(cq_entry->data) & + ~CQ_ENTRY_READY_MASK); cq->ci = hl_cq_inc_ptr(cq->ci); -- 2.20.1