Received: by 10.223.185.116 with SMTP id b49csp245509wrg; Tue, 13 Feb 2018 20:59:19 -0800 (PST) X-Google-Smtp-Source: AH8x224Owgl8Mf7m2aUN5ipbGAXbRyfNAc5cU94P9byBXWQxMFt10LvyrpAgbKt79s9WZLli0ddq X-Received: by 10.101.66.76 with SMTP id d12mr2876745pgq.45.1518584359158; Tue, 13 Feb 2018 20:59:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518584359; cv=none; d=google.com; s=arc-20160816; b=mhTAOXosZVTYplyqZyXjsWAVKqJES5rk7QOoTAXBFlE9KsdPoaHRpHSnPOh/jemWU6 yJi3iNp04YWUM2x5FUjuO/I1clypGJIAubLjzncxBBCEmCsSF009jPIQ4/tcd2jl0Kfh z73vEuQW873STRI7OlHpANExUJQn7HfG/mYsVMj9YeevCdMzKCW5Gjin7SlzjdHR0mpy o7GHApW9Ykwd8tk4sXUZ1oAO5udIx9ACcT+uC+qMScJ5g2hMFA2683vnPKIVAAMn6oMw h4usKONJaGm/buEAojcyMfAtkVsoA90XtZL9gjt5gput+S4ejzvbnisWLT6aXZZpI46n rvmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=SwJgqZJAoImPjYTWc6y7oYMg2w3uVmVWj3DuN8UYeYc=; b=0DEJpx72e/xGpyW1b2c0bQvDP5Xc+mExjW7zhxzkZ41oD4i+yFhzlXhw3sAahpqdjf QGbJA0Bic65LxWwbvmh6Y70Us+hkPHABZevANSjasmTc3IMG3fE89Knci7gOONlbnypk jzxPla49e0JXn19n1Y1RsG5uEZRuiTtIzy6RhSIIdCIlAFUbP/OgvVLaqkJ4gSu1V3M8 K822wumCHEuM9QknZuB3YtRnOrFAGuhWBJFjRsgwp7orUq5b04r840Wl/QZiYuOUyzYF k9d7cOHwhjD8Gul/65twwDETxyBVnAhHWzEwX2gHjOiEtPzXuesBOrjbyaWy3CWKkvUP MQtg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t2-v6si736558plm.674.2018.02.13.20.59.05; Tue, 13 Feb 2018 20:59:19 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966898AbeBNE6S (ORCPT + 99 others); Tue, 13 Feb 2018 23:58:18 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41734 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966813AbeBNE6R (ORCPT ); Tue, 13 Feb 2018 23:58:17 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1E4tFxo068045 for ; Tue, 13 Feb 2018 23:58:16 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g4afnqcsb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Feb 2018 23:58:16 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Feb 2018 04:58:14 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Feb 2018 04:58:10 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1E4wAhQ47972444; Wed, 14 Feb 2018 04:58:10 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C2D111C054; Wed, 14 Feb 2018 04:51:23 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A097C11C050; Wed, 14 Feb 2018 04:51:20 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.79.185.252]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 14 Feb 2018 04:51:20 +0000 (GMT) From: Anshuman Khandual To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, bart.vanassche@wdc.com, jthumshirn@suse.de, axboe@kernel.dk, chris@chris-wilson.co.uk, tvrtko.ursulin@intel.com Cc: khandual@linux.vnet.ibm.com Subject: [PATCH] lib/scatterlist: Add SG_CHAIN and SG_EMARK macros for LSB encodings Date: Wed, 14 Feb 2018 10:28:04 +0530 X-Mailer: git-send-email 2.9.3 X-TM-AS-GCONF: 00 x-cbid: 18021404-0040-0000-0000-0000042F8B48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021404-0041-0000-0000-000020D350FF Message-Id: <20180214045804.9113-1-khandual@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-14_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802140055 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This replaces scatterlist->page_link LSB encodings with SG_CHAIN and SG_EMARK definitions without any functional change. Signed-off-by: Anshuman Khandual --- include/linux/scatterlist.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 22b2131bcdcd..63d00bdb2fb3 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -65,16 +65,18 @@ struct sg_table { */ #define SG_MAGIC 0x87654321 +#define SG_CHAIN 0x01 +#define SG_EMARK 0x02 /* * We overload the LSB of the page pointer to indicate whether it's * a valid sg entry, or whether it points to the start of a new scatterlist. * Those low bits are there for everyone! (thanks mason :-) */ -#define sg_is_chain(sg) ((sg)->page_link & 0x01) -#define sg_is_last(sg) ((sg)->page_link & 0x02) +#define sg_is_chain(sg) ((sg)->page_link & SG_CHAIN) +#define sg_is_last(sg) ((sg)->page_link & SG_EMARK) #define sg_chain_ptr(sg) \ - ((struct scatterlist *) ((sg)->page_link & ~0x03)) + ((struct scatterlist *) ((sg)->page_link & ~(SG_CHAIN | SG_EMARK))) /** * sg_assign_page - Assign a given page to an SG entry @@ -88,13 +90,13 @@ struct sg_table { **/ static inline void sg_assign_page(struct scatterlist *sg, struct page *page) { - unsigned long page_link = sg->page_link & 0x3; + unsigned long page_link = sg->page_link & (SG_CHAIN | SG_EMARK); /* * In order for the low bit stealing approach to work, pages * must be aligned at a 32-bit boundary as a minimum. */ - BUG_ON((unsigned long) page & 0x03); + BUG_ON((unsigned long) page & (SG_CHAIN | SG_EMARK)); #ifdef CONFIG_DEBUG_SG BUG_ON(sg->sg_magic != SG_MAGIC); BUG_ON(sg_is_chain(sg)); @@ -130,7 +132,7 @@ static inline struct page *sg_page(struct scatterlist *sg) BUG_ON(sg->sg_magic != SG_MAGIC); BUG_ON(sg_is_chain(sg)); #endif - return (struct page *)((sg)->page_link & ~0x3); + return (struct page *)((sg)->page_link & ~(SG_CHAIN | SG_EMARK)); } /** @@ -178,7 +180,8 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, * Set lowest bit to indicate a link pointer, and make sure to clear * the termination bit if it happens to be set. */ - prv[prv_nents - 1].page_link = ((unsigned long) sgl | 0x01) & ~0x02; + prv[prv_nents - 1].page_link = ((unsigned long) sgl | SG_CHAIN) + & ~SG_EMARK; } /** @@ -198,8 +201,8 @@ static inline void sg_mark_end(struct scatterlist *sg) /* * Set termination bit, clear potential chain bit */ - sg->page_link |= 0x02; - sg->page_link &= ~0x01; + sg->page_link |= SG_EMARK; + sg->page_link &= ~SG_CHAIN; } /** @@ -215,7 +218,7 @@ static inline void sg_unmark_end(struct scatterlist *sg) #ifdef CONFIG_DEBUG_SG BUG_ON(sg->sg_magic != SG_MAGIC); #endif - sg->page_link &= ~0x02; + sg->page_link &= ~SG_EMARK; } /** -- 2.11.0