Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1018537ybe; Wed, 4 Sep 2019 11:13:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyG51sUhdKBkfCqcjvQE2MQwmsBVOGLz4Fe103kzEyucJ4TPkGIySqd2xBnojCWp9dTmoqX X-Received: by 2002:a17:902:8506:: with SMTP id bj6mr17687083plb.79.1567620796052; Wed, 04 Sep 2019 11:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620796; cv=none; d=google.com; s=arc-20160816; b=g9RiM6sx78tkz9WTaXpUppjGVMeiv7Af6TlfG2b2o0bzYlwqECpuCztJZ0Wtd3VtdP QSRgTCcWUsJwhMylrnzy0zoZc1Hjm3GtHPrYaYFbMGoMlAEXJ/SW9pjTzsx6HjmEWEzt MHgTZu3SKhSwHNOexygX6t5wIbSDPBCDYkJjQWMtmqF4qE7biNsLPxgClkOGwqz0CYXt Hq1S+uUnfOh7Ev0snKlppB9XFEr5KK2WzcsgDVdM7Rb+F39VhFtttsZK2e8zpY6kJ8M6 Ifnd1ak/dmBwkp4elW71sVsGwTnSWEgTLQNpRXYobRMdRv04jjpaMdDFDZejnKfriyKq nYjQ== 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=JQbggWSF6c23hUXgL8KI9s9i8d6KyY+4+s/td3nosMY=; b=xDNjNF9ickyibf+fQv5uuLISPc+yBdR2/1YM1Dlr+5f/UPpu0kgIisFuk2imeFpFfS QviELCQiOAuu34zSjbZRqR/D8ZyWwnxzpU8qy6I2MHiC6a8YvC+Ki5kGKaUd3jW3r3U5 3xoSousKtIjjieWtRZvMCDbNGMZBnkNPUD6IhyRODlnE5LSV+00T8lxXZWA87shcPZKg rI9j5nKO9baP60IKcHpnOzhcSA86dKeAd2+i+3N7omYFl0t6OyGqtRAwFXAAZF82GwN7 1Wrresh363KHUNCUv9pWxl5lwoumAWz4NK053jeYnkm1kx0fsWcVl/O10FkTIjT5C0s9 ghUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oNtDOvSE; 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 o3si2836304pls.424.2019.09.04.11.13.00; Wed, 04 Sep 2019 11:13:16 -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=oNtDOvSE; 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 S2390077AbfIDSKW (ORCPT + 99 others); Wed, 4 Sep 2019 14:10:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:53866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390071AbfIDSKU (ORCPT ); Wed, 4 Sep 2019 14:10:20 -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 6280B208E4; Wed, 4 Sep 2019 18:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620619; bh=jhaaG0FSfHAZnceMxY8dpHpbGb3lwOtzwFAxl2ten4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oNtDOvSEq2VS/gnlTvZ6RzBVFgGKWCN8GuvxS3ak+WQ8Snv4GVIS2kliWmIfS9OKz fOirk90NpOaS9+EC8w8en9QVkHlONyFx011x1D3OpLqIhyslfGvmwz9FrfgT7/A58z KoF8Y7LJ7S23g6cEtXnWUw3FsZvNXZWF09x08Hig= 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 032/143] habanalabs: fix device IRQ unmasking for BE host Date: Wed, 4 Sep 2019 19:52:55 +0200 Message-Id: <20190904175315.310835376@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 b421d83a3947369fd5718824aecfaebe1efbf7ed ] When unmasking IRQs inside the ASIC, the driver passes an array of all the IRQ to unmask. The ASIC's CPU is working in LE so when running in a BE host, the driver needs to do the proper endianness swapping when preparing this array. In addition, this patch also fixes the endianness of a couple of kernel log debug messages that print values of packets Signed-off-by: Ben Segal Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/goya/goya.c | 33 +++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index 9216cc3599178..ac6b252a1ddcb 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c @@ -3311,9 +3311,11 @@ static int goya_validate_dma_pkt_no_mmu(struct hl_device *hdev, int rc; dev_dbg(hdev->dev, "DMA packet details:\n"); - dev_dbg(hdev->dev, "source == 0x%llx\n", user_dma_pkt->src_addr); - dev_dbg(hdev->dev, "destination == 0x%llx\n", user_dma_pkt->dst_addr); - dev_dbg(hdev->dev, "size == %u\n", user_dma_pkt->tsize); + dev_dbg(hdev->dev, "source == 0x%llx\n", + le64_to_cpu(user_dma_pkt->src_addr)); + dev_dbg(hdev->dev, "destination == 0x%llx\n", + le64_to_cpu(user_dma_pkt->dst_addr)); + dev_dbg(hdev->dev, "size == %u\n", le32_to_cpu(user_dma_pkt->tsize)); ctl = le32_to_cpu(user_dma_pkt->ctl); user_dir = (ctl & GOYA_PKT_LIN_DMA_CTL_DMA_DIR_MASK) >> @@ -3342,9 +3344,11 @@ static int goya_validate_dma_pkt_mmu(struct hl_device *hdev, struct packet_lin_dma *user_dma_pkt) { dev_dbg(hdev->dev, "DMA packet details:\n"); - dev_dbg(hdev->dev, "source == 0x%llx\n", user_dma_pkt->src_addr); - dev_dbg(hdev->dev, "destination == 0x%llx\n", user_dma_pkt->dst_addr); - dev_dbg(hdev->dev, "size == %u\n", user_dma_pkt->tsize); + dev_dbg(hdev->dev, "source == 0x%llx\n", + le64_to_cpu(user_dma_pkt->src_addr)); + dev_dbg(hdev->dev, "destination == 0x%llx\n", + le64_to_cpu(user_dma_pkt->dst_addr)); + dev_dbg(hdev->dev, "size == %u\n", le32_to_cpu(user_dma_pkt->tsize)); /* * WA for HW-23. @@ -3384,7 +3388,8 @@ static int goya_validate_wreg32(struct hl_device *hdev, dev_dbg(hdev->dev, "WREG32 packet details:\n"); dev_dbg(hdev->dev, "reg_offset == 0x%x\n", reg_offset); - dev_dbg(hdev->dev, "value == 0x%x\n", wreg_pkt->value); + dev_dbg(hdev->dev, "value == 0x%x\n", + le32_to_cpu(wreg_pkt->value)); if (reg_offset != (mmDMA_CH_0_WR_COMP_ADDR_LO & 0x1FFF)) { dev_err(hdev->dev, "WREG32 packet with illegal address 0x%x\n", @@ -4252,6 +4257,8 @@ static int goya_unmask_irq_arr(struct hl_device *hdev, u32 *irq_arr, size_t total_pkt_size; long result; int rc; + int irq_num_entries, irq_arr_index; + __le32 *goya_irq_arr; total_pkt_size = sizeof(struct armcp_unmask_irq_arr_packet) + irq_arr_size; @@ -4269,8 +4276,16 @@ static int goya_unmask_irq_arr(struct hl_device *hdev, u32 *irq_arr, if (!pkt) return -ENOMEM; - pkt->length = cpu_to_le32(irq_arr_size / sizeof(irq_arr[0])); - memcpy(&pkt->irqs, irq_arr, irq_arr_size); + irq_num_entries = irq_arr_size / sizeof(irq_arr[0]); + pkt->length = cpu_to_le32(irq_num_entries); + + /* We must perform any necessary endianness conversation on the irq + * array being passed to the goya hardware + */ + for (irq_arr_index = 0, goya_irq_arr = (__le32 *) &pkt->irqs; + irq_arr_index < irq_num_entries ; irq_arr_index++) + goya_irq_arr[irq_arr_index] = + cpu_to_le32(irq_arr[irq_arr_index]); pkt->armcp_pkt.ctl = cpu_to_le32(ARMCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY << ARMCP_PKT_CTL_OPCODE_SHIFT); -- 2.20.1